diff options
Diffstat (limited to 'Source/WebCore/css')
-rw-r--r-- | Source/WebCore/css/CSSComputedStyleDeclaration.cpp | 6 | ||||
-rw-r--r-- | Source/WebCore/css/CSSFontFace.cpp | 2 | ||||
-rw-r--r-- | Source/WebCore/css/CSSGrammar.y.in | 26 | ||||
-rw-r--r-- | Source/WebCore/css/CSSParser.cpp | 10 | ||||
-rw-r--r-- | Source/WebCore/css/CSSParserValues.cpp | 25 | ||||
-rw-r--r-- | Source/WebCore/css/CSSParserValues.h | 6 | ||||
-rw-r--r-- | Source/WebCore/css/CSSPrimitiveValue.h | 1 | ||||
-rw-r--r-- | Source/WebCore/css/CSSPropertyNames.in | 3 | ||||
-rw-r--r-- | Source/WebCore/css/DocumentRuleSets.cpp | 3 | ||||
-rw-r--r-- | Source/WebCore/css/SelectorChecker.cpp | 4 | ||||
-rw-r--r-- | Source/WebCore/css/StyleBuilderConverter.h | 58 |
11 files changed, 110 insertions, 34 deletions
diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp index 79da5802c..afb1c69c2 100644 --- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -2991,6 +2991,12 @@ RefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, return zoomAdjustedPixelValueForLength(style->minWidth(), *style); case CSSPropertyObjectFit: return cssValuePool.createValue(style->objectFit()); + case CSSPropertyObjectPosition: { + RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); + list->append(zoomAdjustedPixelValueForLength(style->objectPosition().x(), *style)); + list->append(zoomAdjustedPixelValueForLength(style->objectPosition().y(), *style)); + return list; + } case CSSPropertyOpacity: return cssValuePool.createValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER); case CSSPropertyOrphans: diff --git a/Source/WebCore/css/CSSFontFace.cpp b/Source/WebCore/css/CSSFontFace.cpp index 552e99cfa..008ef8594 100644 --- a/Source/WebCore/css/CSSFontFace.cpp +++ b/Source/WebCore/css/CSSFontFace.cpp @@ -276,6 +276,8 @@ void CSSFontFace::setStatus(Status newStatus) void CSSFontFace::fontLoaded(CSSFontFaceSource&) { + Ref<CSSFontFace> protectedThis(*this); + // If the font is already in the cache, CSSFontFaceSource may report it's loaded before it is added here as a source. // Let's not pump the state machine until we've got all our sources. font() and load() are smart enough to act correctly // when a source is failed or succeeded before we have asked it to load. diff --git a/Source/WebCore/css/CSSGrammar.y.in b/Source/WebCore/css/CSSGrammar.y.in index 8cc70be80..0aad45663 100644 --- a/Source/WebCore/css/CSSGrammar.y.in +++ b/Source/WebCore/css/CSSGrammar.y.in @@ -294,12 +294,12 @@ static bool selectorListDoesNotMatchAnyPseudoElement(const Vector<std::unique_pt %type <keyframeRuleList> keyframes_rule %destructor { delete $$; } keyframes_rule -// These parser values never need to be destroyed because they are never functions or value lists. -%type <value> calc_func_term key unary_term +// These parser values never need to be destroyed because they are never functions, value lists, or variables. +%type <value> key unary_term -// These parser values need to be destroyed because they might be functions. -%type <value> calc_function function variable_function min_or_max_function term -%destructor { destroy($$); } calc_function function variable_function min_or_max_function term +// These parser values need to be destroyed because they might be functions, value lists, or variables. +%type <value> calc_func_term calc_function function min_or_max_function term variable_function +%destructor { destroy($$); } calc_func_term calc_function function min_or_max_function term variable_function %type <id> property @@ -823,14 +823,18 @@ key_list: } | key_list maybe_space ',' maybe_space key { $$ = $1; - ASSERT($5.unit != CSSParserValue::Function); // No need to call destroy. if ($$) $$->addValue($5); } ; key: - maybe_unary_operator PERCENTAGE { $$.id = CSSValueInvalid; $$.isInt = false; $$.fValue = $1 * $2; $$.unit = CSSPrimitiveValue::CSS_NUMBER; } + maybe_unary_operator PERCENTAGE { + $$.id = CSSValueInvalid; + $$.isInt = false; + $$.fValue = $1 * $2; + $$.unit = CSSPrimitiveValue::CSS_NUMBER; + } | IDENT { $$.id = CSSValueInvalid; $$.isInt = false; @@ -1838,10 +1842,10 @@ invalid_var_fallback: '!' | ';'; calc_func_term: - unary_term - | variable_function { $$ = $1; } - | unary_operator unary_term { $$ = $2; $$.fValue *= $1; } - ; + unary_term + | unary_operator unary_term { $$ = $2; $$.fValue *= $1; } + | variable_function + ; /* * The grammar requires spaces around binary ‘+’ and ‘-’ operators. diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp index 9aec1c8ac..3ac15d00c 100644 --- a/Source/WebCore/css/CSSParser.cpp +++ b/Source/WebCore/css/CSSParser.cpp @@ -2886,6 +2886,16 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) case CSSPropertyColumnWidth: // auto | <length> parsedValue = parseColumnWidth(); break; + case CSSPropertyObjectPosition: { + RefPtr<CSSPrimitiveValue> val1; + RefPtr<CSSPrimitiveValue> val2; + parseFillPosition(*m_valueList, val1, val2); + if (val1) { + addProperty(CSSPropertyObjectPosition, createPrimitiveValuePair(val1.release(), val2.release()), important); + return true; + } + return false; + } // End of CSS3 properties case CSSPropertyWillChange: // auto | [scroll-position | contents | <custom-ident>]# diff --git a/Source/WebCore/css/CSSParserValues.cpp b/Source/WebCore/css/CSSParserValues.cpp index db7540e8a..7fb74c6b8 100644 --- a/Source/WebCore/css/CSSParserValues.cpp +++ b/Source/WebCore/css/CSSParserValues.cpp @@ -46,29 +46,26 @@ void destroy(const CSSParserValue& value) CSSParserValueList::~CSSParserValueList() { - for (size_t i = 0, size = m_values.size(); i < size; i++) - destroy(m_values[i]); + for (auto& value : m_values) + destroy(value); } -void CSSParserValueList::addValue(const CSSParserValue& v) +void CSSParserValueList::addValue(const CSSParserValue& value) { - m_values.append(v); + m_values.append(value); } -void CSSParserValueList::insertValueAt(unsigned i, const CSSParserValue& v) +void CSSParserValueList::insertValueAt(unsigned i, const CSSParserValue& value) { - m_values.insert(i, v); + m_values.insert(i, value); } -void CSSParserValueList::deleteValueAt(unsigned i) +void CSSParserValueList::extend(CSSParserValueList& other) { - m_values.remove(i); -} - -void CSSParserValueList::extend(CSSParserValueList& valueList) -{ - for (unsigned int i = 0; i < valueList.size(); ++i) - m_values.append(*(valueList.valueAt(i))); + for (auto& value : other.m_values) { + m_values.append(value); + value.unit = 0; // We moved the CSSParserValue from the other list; this acts like std::move. + } } bool CSSParserValueList::containsVariables() const diff --git a/Source/WebCore/css/CSSParserValues.h b/Source/WebCore/css/CSSParserValues.h index 77a5b1957..ebc16fe0f 100644 --- a/Source/WebCore/css/CSSParserValues.h +++ b/Source/WebCore/css/CSSParserValues.h @@ -18,8 +18,7 @@ * Boston, MA 02110-1301, USA. */ -#ifndef CSSParserValues_h -#define CSSParserValues_h +#pragma once #include "CSSSelector.h" #include "CSSValueKeywords.h" @@ -140,7 +139,6 @@ public: void addValue(const CSSParserValue&); void insertValueAt(unsigned, const CSSParserValue&); - void deleteValueAt(unsigned); void extend(CSSParserValueList&); unsigned size() const { return m_values.size(); } @@ -274,5 +272,3 @@ template<unsigned length> inline bool equalLettersIgnoringASCIICase(const CSSPar } } - -#endif diff --git a/Source/WebCore/css/CSSPrimitiveValue.h b/Source/WebCore/css/CSSPrimitiveValue.h index ab5cd6094..23375815c 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.h +++ b/Source/WebCore/css/CSSPrimitiveValue.h @@ -210,6 +210,7 @@ public: #if ENABLE(CSS_SCROLL_SNAP) bool isLengthRepeat() const { return m_primitiveUnitType == CSS_LENGTH_REPEAT; } #endif + bool isPair() const { return m_primitiveUnitType == CSS_PAIR; } bool isPropertyID() const { return m_primitiveUnitType == CSS_PROPERTY_ID; } bool isRGBColor() const { return m_primitiveUnitType == CSS_RGBCOLOR; } bool isShape() const { return m_primitiveUnitType == CSS_SHAPE; } diff --git a/Source/WebCore/css/CSSPropertyNames.in b/Source/WebCore/css/CSSPropertyNames.in index 0fd1d491a..2621e483e 100644 --- a/Source/WebCore/css/CSSPropertyNames.in +++ b/Source/WebCore/css/CSSPropertyNames.in @@ -145,7 +145,7 @@ background [Longhands=background-image|background-position-x|background-position background-attachment [FillLayerProperty, NameForMethods=Attachment] background-blend-mode [FillLayerProperty, NameForMethods=BlendMode] background-clip [FillLayerProperty, NameForMethods=Clip] -background-color [VisitedLinkColorSupport, Initial=invalidColor, NoDefaultColor] +background-color [VisitedLinkColorSupport, NoDefaultColor] background-image [FillLayerProperty, NameForMethods=Image] background-origin [FillLayerProperty, NameForMethods=Origin] background-position [Longhands=background-position-x|background-position-y] @@ -274,6 +274,7 @@ max-width [Initial=initialMaxSize, Converter=LengthMaxSizing] min-height [Initial=initialMinSize, Converter=LengthSizing] min-width [Initial=initialMinSize, Converter=LengthSizing] object-fit +object-position [Converter=ObjectPosition] opacity // Honor -webkit-opacity as a synonym for opacity. This was the only syntax that worked in Safari 1.1, // and may be in use on some websites and widgets. diff --git a/Source/WebCore/css/DocumentRuleSets.cpp b/Source/WebCore/css/DocumentRuleSets.cpp index 9cc08deb7..93f28b94d 100644 --- a/Source/WebCore/css/DocumentRuleSets.cpp +++ b/Source/WebCore/css/DocumentRuleSets.cpp @@ -114,6 +114,9 @@ void DocumentRuleSets::collectFeatures() const m_siblingRuleSet = makeRuleSet(m_features.siblingRules); m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); + + m_ancestorClassRuleSets.clear(); + m_ancestorAttributeRuleSetsForHTML.clear(); } RuleSet* DocumentRuleSets::ancestorClassRules(AtomicStringImpl* className) const diff --git a/Source/WebCore/css/SelectorChecker.cpp b/Source/WebCore/css/SelectorChecker.cpp index 0f0d365c0..9b0fe19d8 100644 --- a/Source/WebCore/css/SelectorChecker.cpp +++ b/Source/WebCore/css/SelectorChecker.cpp @@ -912,6 +912,10 @@ bool SelectorChecker::checkOne(CheckingContext& checkingContext, const LocalCont if (m_strictParsing || element.isLink() || canMatchHoverOrActiveInQuirksMode(context)) { addStyleRelation(checkingContext, element, StyleRelation::AffectedByHover); + // See the comment in generateElementIsHovered() in SelectorCompiler. + if (checkingContext.resolvingMode == SelectorChecker::Mode::CollectingRulesIgnoringVirtualPseudoElements && !context.isMatchElement) + return true; + if (element.hovered() || InspectorInstrumentation::forcePseudoState(const_cast<Element&>(element), CSSSelector::PseudoClassHover)) return true; } diff --git a/Source/WebCore/css/StyleBuilderConverter.h b/Source/WebCore/css/StyleBuilderConverter.h index 34f6fe317..6ae433bd8 100644 --- a/Source/WebCore/css/StyleBuilderConverter.h +++ b/Source/WebCore/css/StyleBuilderConverter.h @@ -57,7 +57,7 @@ namespace WebCore { // Note that we assume the CSS parser only allows valid CSSValue types. class StyleBuilderConverter { public: - static Length convertLength(StyleResolver&, CSSValue&); + static Length convertLength(StyleResolver&, const CSSValue&); static Length convertLengthOrAuto(StyleResolver&, CSSValue&); static Length convertLengthSizing(StyleResolver&, CSSValue&); static Length convertLengthMaxSizing(StyleResolver&, CSSValue&); @@ -65,6 +65,7 @@ public: template <typename T> static T convertLineWidth(StyleResolver&, CSSValue&); static float convertSpacing(StyleResolver&, CSSValue&); static LengthSize convertRadius(StyleResolver&, CSSValue&); + static LengthPoint convertObjectPosition(StyleResolver&, CSSValue&); static TextDecoration convertTextDecoration(StyleResolver&, CSSValue&); template <typename T> static T convertNumber(StyleResolver&, CSSValue&); template <typename T> static T convertNumberOrAuto(StyleResolver&, CSSValue&); @@ -148,6 +149,10 @@ private: #if ENABLE(CSS_SCROLL_SNAP) static Length parseSnapCoordinate(StyleResolver&, const CSSValue&); #endif + + static Length convertTo100PercentMinusLength(const Length&); + static Length convertPositionComponent(StyleResolver&, const CSSPrimitiveValue&); + #if ENABLE(CSS_GRID_LAYOUT) static GridLength createGridTrackBreadth(CSSPrimitiveValue&, StyleResolver&); static GridTrackSize createGridTrackSize(CSSValue&, StyleResolver&); @@ -158,7 +163,7 @@ private: static CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver&); }; -inline Length StyleBuilderConverter::convertLength(StyleResolver& styleResolver, CSSValue& value) +inline Length StyleBuilderConverter::convertLength(StyleResolver& styleResolver, const CSSValue& value) { auto& primitiveValue = downcast<CSSPrimitiveValue>(value); CSSToLengthConversionData conversionData = styleResolver.useSVGZoomRulesForLength() ? @@ -298,6 +303,54 @@ inline LengthSize StyleBuilderConverter::convertRadius(StyleResolver& styleResol return LengthSize(radiusWidth, radiusHeight); } +inline Length StyleBuilderConverter::convertTo100PercentMinusLength(const Length& length) +{ + if (length.isPercent()) + return Length(100 - length.value(), Percent); + + // Turn this into a calc expression: calc(100% - length) + auto lhs = std::make_unique<CalcExpressionLength>(Length(100, Percent)); + auto rhs = std::make_unique<CalcExpressionLength>(length); + auto op = std::make_unique<CalcExpressionBinaryOperation>(WTFMove(lhs), WTFMove(rhs), CalcSubtract); + return Length(CalculationValue::create(WTFMove(op), CalculationRangeAll)); +} + +inline Length StyleBuilderConverter::convertPositionComponent(StyleResolver& styleResolver, const CSSPrimitiveValue& value) +{ + Length length; + + auto* lengthValue = &value; + bool relativeToTrailingEdge = false; + + if (value.isPair()) { + auto& first = *value.getPairValue()->first(); + if (first.getValueID() == CSSValueRight || first.getValueID() == CSSValueBottom) + relativeToTrailingEdge = true; + + lengthValue = value.getPairValue()->second(); + } + + length = convertLength(styleResolver, *lengthValue); + + if (relativeToTrailingEdge) + length = convertTo100PercentMinusLength(length); + + return length; +} + +inline LengthPoint StyleBuilderConverter::convertObjectPosition(StyleResolver& styleResolver, CSSValue& value) +{ + auto& primitiveValue = downcast<CSSPrimitiveValue>(value); + Pair* pair = primitiveValue.getPairValue(); + if (!pair || !pair->first() || !pair->second()) + return RenderStyle::initialObjectPosition(); + + Length lengthX = convertPositionComponent(styleResolver, *pair->first()); + Length lengthY = convertPositionComponent(styleResolver, *pair->second()); + + return LengthPoint(lengthX, lengthY); +} + inline TextDecoration StyleBuilderConverter::convertTextDecoration(StyleResolver&, CSSValue& value) { TextDecoration result = RenderStyle::initialTextDecoration(); @@ -735,7 +788,6 @@ inline std::unique_ptr<ScrollSnapPoints> StyleBuilderConverter::convertScrollSna return points; } - points->hasRepeat = false; for (auto& currentValue : downcast<CSSValueList>(value)) { auto& itemValue = downcast<CSSPrimitiveValue>(currentValue.get()); if (auto* lengthRepeat = itemValue.getLengthRepeatValue()) { |