Title: [285493] trunk

Diff

Modified: trunk/LayoutTests/ChangeLog (285492 => 285493)


--- trunk/LayoutTests/ChangeLog	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/LayoutTests/ChangeLog	2021-11-09 13:53:12 UTC (rev 285493)
@@ -1,3 +1,17 @@
+2021-11-09  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r285486.
+        https://bugs.webkit.org/show_bug.cgi?id=232876
+
+        Made fast/ruby/generated-before-counter-doesnt-crash.html
+        flaky, possibly indicating perf problem
+
+        Reverted changeset:
+
+        "[CSS Cascade Layers] Support 'revert-layer' value"
+        https://bugs.webkit.org/show_bug.cgi?id=232236
+        https://commits.webkit.org/r285486
+
 2021-11-09  Antti Koivisto  <[email protected]>
 
         [CSS Cascade Layers] Support 'revert-layer' value

Modified: trunk/LayoutTests/TestExpectations (285492 => 285493)


--- trunk/LayoutTests/TestExpectations	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/LayoutTests/TestExpectations	2021-11-09 13:53:12 UTC (rev 285493)
@@ -2149,6 +2149,13 @@
 
 imported/w3c/web-platform-tests/css/css-cascade/important-prop.html [ ImageOnlyFailure ]
 webkit.org/b/187093 [ Debug ] imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml.html [ Skip ]
+webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-001.html [ ImageOnlyFailure ]
+webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-002.html [ ImageOnlyFailure ]
+webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-003.html [ ImageOnlyFailure ]
+webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-004.html [ ImageOnlyFailure ]
+webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-005.html [ ImageOnlyFailure ]
+webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-006.html [ ImageOnlyFailure ]
+webkit.org/b/232236 imported/w3c/web-platform-tests/css/css-cascade/revert-layer-007.html [ ImageOnlyFailure ]
 
 webkit.org/b/148801 imported/w3c/web-platform-tests/css/css-color/t422-rgba-onscreen-b.xht [ ImageOnlyFailure ]
 webkit.org/b/148801 imported/w3c/web-platform-tests/css/css-color/t422-rgba-onscreen-multiple-boxes-c.xht [ ImageOnlyFailure ]

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (285492 => 285493)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-11-09 13:53:12 UTC (rev 285493)
@@ -1,3 +1,17 @@
+2021-11-09  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r285486.
+        https://bugs.webkit.org/show_bug.cgi?id=232876
+
+        Made fast/ruby/generated-before-counter-doesnt-crash.html
+        flaky, possibly indicating perf problem
+
+        Reverted changeset:
+
+        "[CSS Cascade Layers] Support 'revert-layer' value"
+        https://bugs.webkit.org/show_bug.cgi?id=232236
+        https://commits.webkit.org/r285486
+
 2021-11-09  Tim Nguyen  <[email protected]>
 
         Rebaseline will-change-invalid.html after r285487 & r285486

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-layer-008-expected.txt (285492 => 285493)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-layer-008-expected.txt	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/revert-layer-008-expected.txt	2021-11-09 13:53:12 UTC (rev 285493)
@@ -1,3 +1,3 @@
 
-PASS 'revert-layer' should revert font-size to 20px and trigger a smooth transition
+FAIL 'revert-layer' should revert font-size to 20px and trigger a smooth transition assert_equals: expected "15px" but got "10px"
 

Modified: trunk/Source/WebCore/ChangeLog (285492 => 285493)


--- trunk/Source/WebCore/ChangeLog	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/ChangeLog	2021-11-09 13:53:12 UTC (rev 285493)
@@ -1,3 +1,17 @@
+2021-11-09  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r285486.
+        https://bugs.webkit.org/show_bug.cgi?id=232876
+
+        Made fast/ruby/generated-before-counter-doesnt-crash.html
+        flaky, possibly indicating perf problem
+
+        Reverted changeset:
+
+        "[CSS Cascade Layers] Support 'revert-layer' value"
+        https://bugs.webkit.org/show_bug.cgi?id=232236
+        https://commits.webkit.org/r285486
+
 2021-11-09  Tim Nguyen  <[email protected]>
 
         Refactor consumeWillChange() to make better use of consumeCustomIdent()

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (285492 => 285493)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.h	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h	2021-11-09 13:53:12 UTC (rev 285493)
@@ -120,7 +120,6 @@
     bool isInheritValue() const { return valueID() == CSSValueInherit; }
     bool isUnsetValue() const { return valueID() == CSSValueUnset; }
     bool isRevertValue() const { return valueID() == CSSValueRevert; }
-    bool isRevertLayerValue() const { return valueID() == CSSValueRevertLayer; }
     bool isCSSWideKeyword() const;
 
     static Ref<CSSPrimitiveValue> createIdentifier(CSSValueID valueID) { return adoptRef(*new CSSPrimitiveValue(valueID)); }

Modified: trunk/Source/WebCore/css/CSSValue.cpp (285492 => 285493)


--- trunk/Source/WebCore/css/CSSValue.cpp	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/css/CSSValue.cpp	2021-11-09 13:53:12 UTC (rev 285493)
@@ -510,11 +510,6 @@
     return is<CSSPrimitiveValue>(*this) && downcast<CSSPrimitiveValue>(*this).isRevertValue();
 }
 
-bool CSSValue::isRevertLayerValue() const
-{
-    return is<CSSPrimitiveValue>(*this) && downcast<CSSPrimitiveValue>(*this).isRevertLayerValue();
-}
-
 bool CSSValue::isCSSWideKeyword() const
 {
     return is<CSSPrimitiveValue>(*this) && downcast<CSSPrimitiveValue>(*this).isCSSWideKeyword();

Modified: trunk/Source/WebCore/css/CSSValue.h (285492 => 285493)


--- trunk/Source/WebCore/css/CSSValue.h	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/css/CSSValue.h	2021-11-09 13:53:12 UTC (rev 285493)
@@ -111,7 +111,6 @@
     bool isInitialValue() const;
     bool isUnsetValue() const;
     bool isRevertValue() const;
-    bool isRevertLayerValue() const;
     bool isCSSWideKeyword() const;
     bool treatAsInitialValue(CSSPropertyID) const;
     bool treatAsInheritedValue(CSSPropertyID) const;

Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (285492 => 285493)


--- trunk/Source/WebCore/css/CSSValueKeywords.in	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in	2021-11-09 13:53:12 UTC (rev 285493)
@@ -5,7 +5,6 @@
 initial
 unset
 revert
-revert-layer
 
 //
 // CSS_PROP_OUTLINE_STYLE

Modified: trunk/Source/WebCore/css/parser/CSSParserIdioms.h (285492 => 285493)


--- trunk/Source/WebCore/css/parser/CSSParserIdioms.h	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/css/parser/CSSParserIdioms.h	2021-11-09 13:53:12 UTC (rev 285493)
@@ -60,21 +60,12 @@
 
 bool isValueAllowedInMode(unsigned short, CSSParserMode);
 
-inline bool isCSSWideKeyword(CSSValueID valueID)
+static inline bool isCSSWideKeyword(CSSValueID valueID)
 {
-    switch (valueID) {
-    case CSSValueInitial:
-    case CSSValueInherit:
-    case CSSValueUnset:
-    case CSSValueRevert:
-    case CSSValueRevertLayer:
-        return true;
-    default:
-        return false;
-    };
+    return valueID == CSSValueInitial || valueID == CSSValueInherit || valueID == CSSValueUnset || valueID == CSSValueRevert;
 }
 
-inline bool isValidCustomIdentifier(CSSValueID valueID)
+static inline bool isValidCustomIdentifier(CSSValueID valueID)
 {
     // "default" is obsolete as a CSS-wide keyword but is still not allowed as a custom identifier.
     return !isCSSWideKeyword(valueID) && valueID != CSSValueDefault;

Modified: trunk/Source/WebCore/style/CascadeLevel.h (285492 => 285493)


--- trunk/Source/WebCore/style/CascadeLevel.h	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/style/CascadeLevel.h	2021-11-09 13:53:12 UTC (rev 285493)
@@ -36,18 +36,7 @@
     Author      = 1 << 2
 };
 
-inline CascadeLevel& operator--(CascadeLevel& level)
-{
-    switch (level) {
-    case CascadeLevel::Author:
-        return level = CascadeLevel::User;
-    case CascadeLevel::User:
-        return level = CascadeLevel::UserAgent;
-    case CascadeLevel::UserAgent:
-        ASSERT_NOT_REACHED();
-        return level;
-    }
-}
+static constexpr OptionSet<CascadeLevel> allCascadeLevels() { return { CascadeLevel::UserAgent, CascadeLevel::User, CascadeLevel::Author }; }
 
 }
 }

Modified: trunk/Source/WebCore/style/ElementRuleCollector.cpp (285492 => 285493)


--- trunk/Source/WebCore/style/ElementRuleCollector.cpp	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/style/ElementRuleCollector.cpp	2021-11-09 13:53:12 UTC (rev 285493)
@@ -124,7 +124,7 @@
     m_matchedRuleTransferIndex = 0;
 }
 
-inline void ElementRuleCollector::addElementStyleProperties(const StyleProperties* propertySet, bool isCacheable, FromStyleAttribute fromStyleAttribute)
+inline void ElementRuleCollector::addElementStyleProperties(const StyleProperties* propertySet, bool isCacheable)
 {
     if (!propertySet || propertySet->isEmpty())
         return;
@@ -132,9 +132,7 @@
     if (!isCacheable)
         m_result.isCacheable = false;
 
-    auto matchedProperty = MatchedProperties { propertySet };
-    matchedProperty.fromStyleAttribute = fromStyleAttribute;
-    addMatchedProperties(WTFMove(matchedProperty), DeclarationOrigin::Author);
+    addMatchedProperties({ propertySet }, DeclarationOrigin::Author);
 }
 
 void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest)
@@ -205,8 +203,7 @@
             &matchedRule.ruleData->styleRule().properties(),
             static_cast<uint16_t>(matchedRule.ruleData->linkMatchType()),
             matchedRule.ruleData->propertyAllowlist(),
-            matchedRule.styleScopeOrdinal,
-            matchedRule.cascadeLayerPriority
+            matchedRule.styleScopeOrdinal
         }, declarationOrigin);
     }
 }
@@ -563,7 +560,7 @@
     if (auto* inlineStyle = downcast<StyledElement>(element()).inlineStyle()) {
         // FIXME: Media control shadow trees seem to have problems with caching.
         bool isInlineStyleCacheable = !inlineStyle->isMutable() && !element().isInShadowTree();
-        addElementStyleProperties(inlineStyle, isInlineStyleCacheable, FromStyleAttribute::Yes);
+        addElementStyleProperties(inlineStyle, isInlineStyleCacheable);
     }
 
     if (includeSMILProperties && is<SVGElement>(element()))

Modified: trunk/Source/WebCore/style/ElementRuleCollector.h (285492 => 285493)


--- trunk/Source/WebCore/style/ElementRuleCollector.h	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/style/ElementRuleCollector.h	2021-11-09 13:53:12 UTC (rev 285493)
@@ -63,18 +63,14 @@
     const RuleData* ruleData;
     unsigned specificity;
     ScopeOrdinal styleScopeOrdinal;
-    CascadeLayerPriority cascadeLayerPriority;
+    unsigned cascadeLayerPriority;
 };
 
-enum class FromStyleAttribute : bool { No, Yes };
-
 struct MatchedProperties {
     RefPtr<const StyleProperties> properties;
     uint16_t linkMatchType { SelectorChecker::MatchAll };
     PropertyAllowlist allowlistType { PropertyAllowlist::None };
     ScopeOrdinal styleScopeOrdinal { ScopeOrdinal::Element };
-    CascadeLayerPriority cascadeLayerPriority { RuleSet::cascadeLayerPriorityForUnlayered };
-    FromStyleAttribute fromStyleAttribute { FromStyleAttribute::No };
 };
 
 struct MatchResult {
@@ -125,7 +121,7 @@
     bool didMatchUncommonAttributeSelector() const { return m_didMatchUncommonAttributeSelector; }
 
 private:
-    void addElementStyleProperties(const StyleProperties*, bool isCacheable = true, FromStyleAttribute = FromStyleAttribute::No);
+    void addElementStyleProperties(const StyleProperties*, bool isCacheable = true);
 
     void matchUARules(const RuleSet&);
 

Modified: trunk/Source/WebCore/style/PropertyCascade.cpp (285492 => 285493)


--- trunk/Source/WebCore/style/PropertyCascade.cpp	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/style/PropertyCascade.cpp	2021-11-09 13:53:12 UTC (rev 285493)
@@ -71,35 +71,30 @@
     }
 }
 
-PropertyCascade::PropertyCascade(const MatchResult& matchResult, CascadeLevel maximumCascadeLevel, IncludedProperties includedProperties, Direction direction)
+PropertyCascade::PropertyCascade(const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, IncludedProperties includedProperties, Direction direction)
     : m_matchResult(matchResult)
     , m_includedProperties(includedProperties)
-    , m_maximumCascadeLevel(maximumCascadeLevel)
     , m_direction(direction)
 {
-    buildCascade();
+    buildCascade(cascadeLevels);
 }
 
-PropertyCascade::PropertyCascade(const PropertyCascade& parent, CascadeLevel maximumCascadeLevel, CascadeLayerPriority maximumCascadeLayerPriority)
+PropertyCascade::PropertyCascade(const PropertyCascade& parent, OptionSet<CascadeLevel> cascadeLevels)
     : m_matchResult(parent.m_matchResult)
     , m_includedProperties(parent.m_includedProperties)
-    , m_maximumCascadeLevel(maximumCascadeLevel)
-    , m_maximumCascadeLayerPriority(maximumCascadeLayerPriority)
     , m_direction(parent.direction())
     , m_directionIsUnresolved(false)
 {
-    buildCascade();
+    buildCascade(cascadeLevels);
 }
 
 PropertyCascade::~PropertyCascade() = default;
 
-void PropertyCascade::buildCascade()
+void PropertyCascade::buildCascade(OptionSet<CascadeLevel> cascadeLevels)
 {
     OptionSet<CascadeLevel> cascadeLevelsWithImportant;
 
-    for (auto cascadeLevel : { CascadeLevel::UserAgent, CascadeLevel::User, CascadeLevel::Author }) {
-        if (cascadeLevel > m_maximumCascadeLevel)
-            break;
+    for (auto cascadeLevel : cascadeLevels) {
         bool hasImportant = addNormalMatches(cascadeLevel);
         if (hasImportant)
             cascadeLevelsWithImportant.add(cascadeLevel);
@@ -118,8 +113,6 @@
     property.id = id;
     property.level = cascadeLevel;
     property.styleScopeOrdinal = matchedProperties.styleScopeOrdinal;
-    property.cascadeLayerPriority = matchedProperties.cascadeLayerPriority;
-
     if (matchedProperties.linkMatchType == SelectorChecker::MatchAll) {
         property.cssValue[0] = &cssValue;
         property.cssValue[SelectorChecker::MatchLink] = &cssValue;
@@ -177,9 +170,6 @@
 
 bool PropertyCascade::addMatch(const MatchedProperties& matchedProperties, CascadeLevel cascadeLevel, bool important)
 {
-    if (matchedProperties.cascadeLayerPriority > m_maximumCascadeLayerPriority && cascadeLevel == m_maximumCascadeLevel && matchedProperties.styleScopeOrdinal == ScopeOrdinal::Element)
-        return false;
-
     auto& styleProperties = *matchedProperties.properties;
     auto propertyAllowlist = matchedProperties.allowlistType;
     bool hasImportantProperties = false;
@@ -247,14 +237,12 @@
 
 void PropertyCascade::addImportantMatches(CascadeLevel cascadeLevel)
 {
-    struct ImportantMatch {
+    struct IndexAndOrdinal {
         unsigned index;
         ScopeOrdinal ordinal;
-        CascadeLayerPriority layerPriority;
-        FromStyleAttribute fromStyleAttribute;
     };
-    Vector<ImportantMatch> importantMatches;
-    bool hasMatchesFromOtherScopesOrLayers = false;
+    Vector<IndexAndOrdinal> importantMatches;
+    bool hasMatchesFromOtherScopes = false;
 
     auto& matchedDeclarations = declarationsForCascadeLevel(m_matchResult, cascadeLevel);
 
@@ -264,25 +252,20 @@
         if (!hasImportantProperties(*matchedProperties.properties))
             continue;
 
-        importantMatches.append({ i, matchedProperties.styleScopeOrdinal, matchedProperties.cascadeLayerPriority, matchedProperties.fromStyleAttribute });
+        importantMatches.append({ i, matchedProperties.styleScopeOrdinal });
 
-        if (matchedProperties.styleScopeOrdinal != ScopeOrdinal::Element || matchedProperties.cascadeLayerPriority != RuleSet::cascadeLayerPriorityForUnlayered)
-            hasMatchesFromOtherScopesOrLayers = true;
+        if (matchedProperties.styleScopeOrdinal != ScopeOrdinal::Element)
+            hasMatchesFromOtherScopes = true;
     }
 
     if (importantMatches.isEmpty())
         return;
 
-    if (hasMatchesFromOtherScopesOrLayers) {
+    if (hasMatchesFromOtherScopes) {
+        // For !important properties a later shadow tree wins.
         // Match results are sorted in reverse tree context order so this is not needed for normal properties.
-        std::stable_sort(importantMatches.begin(), importantMatches.end(), [] (auto& a, auto& b) {
-            // For !important properties a later shadow tree wins.
-            if (a.ordinal != b.ordinal)
-                return a.ordinal < b.ordinal;
-            // Lower priority layer wins, except if style attribute is involved.
-            if (a.fromStyleAttribute != b.fromStyleAttribute)
-                return a.fromStyleAttribute == FromStyleAttribute::No;
-            return a.layerPriority > b.layerPriority;
+        std::stable_sort(importantMatches.begin(), importantMatches.end(), [] (const IndexAndOrdinal& a, const IndexAndOrdinal& b) {
+            return a.ordinal < b.ordinal;
         });
     }
 
@@ -290,6 +273,30 @@
         addMatch(matchedDeclarations[match.index], cascadeLevel, true);
 }
 
+const PropertyCascade* PropertyCascade::propertyCascadeForRollback(CascadeLevel cascadeLevel) const
+{
+    switch (cascadeLevel) {
+    case CascadeLevel::Author:
+        if (!m_authorRollbackCascade) {
+            auto cascadeLevels = OptionSet<CascadeLevel> { CascadeLevel::UserAgent, CascadeLevel::User };
+            m_authorRollbackCascade = makeUnique<const PropertyCascade>(*this, cascadeLevels);
+        }
+        return m_authorRollbackCascade.get();
+
+    case CascadeLevel::User:
+        if (!m_userRollbackCascade) {
+            auto cascadeLevels = OptionSet<CascadeLevel> { CascadeLevel::UserAgent };
+            m_userRollbackCascade = makeUnique<const PropertyCascade>(*this, cascadeLevels);
+        }
+        return m_userRollbackCascade.get();
+
+    case CascadeLevel::UserAgent:
+        return nullptr;
+    }
+    ASSERT_NOT_REACHED();
+    return nullptr;
+}
+
 PropertyCascade::Direction PropertyCascade::resolveDirectionAndWritingMode(Direction inheritedDirection) const
 {
     Direction result = inheritedDirection;

Modified: trunk/Source/WebCore/style/PropertyCascade.h (285492 => 285493)


--- trunk/Source/WebCore/style/PropertyCascade.h	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/style/PropertyCascade.h	2021-11-09 13:53:12 UTC (rev 285493)
@@ -46,8 +46,8 @@
         WritingMode writingMode;
     };
 
-    PropertyCascade(const MatchResult&, CascadeLevel, IncludedProperties, Direction);
-    PropertyCascade(const PropertyCascade&, CascadeLevel, CascadeLayerPriority maximumCascadeLayerPriority = RuleSet::cascadeLayerPriorityForUnlayered);
+    PropertyCascade(const MatchResult&, OptionSet<CascadeLevel>, IncludedProperties, Direction);
+    PropertyCascade(const PropertyCascade&, OptionSet<CascadeLevel>);
 
     ~PropertyCascade();
 
@@ -55,7 +55,6 @@
         CSSPropertyID id;
         CascadeLevel level;
         ScopeOrdinal styleScopeOrdinal;
-        CascadeLayerPriority cascadeLayerPriority;
         CSSValue* cssValue[3]; // Values for link match states MatchDefault, MatchLink and MatchVisited
     };
 
@@ -70,11 +69,10 @@
 
     Direction direction() const;
 
-    auto maximumCascadeLevel() const { return m_maximumCascadeLevel; }
-    auto maximumCascadeLayerPriority() const { return m_maximumCascadeLayerPriority; }
+    const PropertyCascade* propertyCascadeForRollback(CascadeLevel) const;
 
 private:
-    void buildCascade();
+    void buildCascade(OptionSet<CascadeLevel>);
     bool addNormalMatches(CascadeLevel);
     void addImportantMatches(CascadeLevel);
     bool addMatch(const MatchedProperties&, CascadeLevel, bool important);
@@ -87,8 +85,6 @@
 
     const MatchResult& m_matchResult;
     const IncludedProperties m_includedProperties;
-    const CascadeLevel m_maximumCascadeLevel;
-    const CascadeLayerPriority m_maximumCascadeLayerPriority { RuleSet::cascadeLayerPriorityForUnlayered };
     mutable Direction m_direction;
     mutable bool m_directionIsUnresolved { true };
 
@@ -97,6 +93,9 @@
 
     Vector<Property, 8> m_deferredProperties;
     HashMap<AtomString, Property> m_customProperties;
+
+    mutable std::unique_ptr<const PropertyCascade> m_authorRollbackCascade;
+    mutable std::unique_ptr<const PropertyCascade> m_userRollbackCascade;
 };
 
 inline bool PropertyCascade::hasProperty(CSSPropertyID id) const

Modified: trunk/Source/WebCore/style/RuleSet.h (285492 => 285493)


--- trunk/Source/WebCore/style/RuleSet.h	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/style/RuleSet.h	2021-11-09 13:53:12 UTC (rev 285493)
@@ -43,8 +43,6 @@
 class Resolver;
 class RuleSet;
 
-using CascadeLayerPriority = uint32_t;
-
 using InvalidationRuleSetVector = Vector<RefPtr<const RuleSet>, 1>;
 
 struct DynamicMediaQueryEvaluationChanges {
@@ -105,8 +103,8 @@
     bool hasShadowPseudoElementRules() const { return !m_shadowPseudoElementRules.isEmpty(); }
     bool hasHostPseudoClassRulesMatchingInShadowTree() const { return m_hasHostPseudoClassRulesMatchingInShadowTree; }
 
-    static constexpr auto cascadeLayerPriorityForUnlayered = std::numeric_limits<CascadeLayerPriority>::max();
-    CascadeLayerPriority cascadeLayerPriorityFor(const RuleData&) const;
+    static constexpr auto cascadeLayerPriorityForUnlayered = std::numeric_limits<unsigned>::max();
+    unsigned cascadeLayerPriorityFor(const RuleData&) const;
 
 private:
     friend class RuleSetBuilder;
@@ -138,7 +136,7 @@
     };
     CascadeLayer& cascadeLayerForIdentifier(CascadeLayerIdentifier identifier) { return m_cascadeLayers[identifier - 1]; }
     const CascadeLayer& cascadeLayerForIdentifier(CascadeLayerIdentifier identifier) const { return m_cascadeLayers[identifier - 1]; }
-    CascadeLayerPriority cascadeLayerPriorityForIdentifier(CascadeLayerIdentifier) const;
+    unsigned cascadeLayerPriorityForIdentifier(CascadeLayerIdentifier) const;
 
     struct DynamicMediaQueryRules {
         Vector<Ref<const MediaQuerySet>> mediaQuerySets;
@@ -195,7 +193,7 @@
     return tagRules->get(key);
 }
 
-inline CascadeLayerPriority RuleSet::cascadeLayerPriorityForIdentifier(CascadeLayerIdentifier identifier) const
+inline unsigned RuleSet::cascadeLayerPriorityForIdentifier(CascadeLayerIdentifier identifier) const
 {
     if (!identifier)
         return cascadeLayerPriorityForUnlayered;
@@ -202,7 +200,7 @@
     return cascadeLayerForIdentifier(identifier).priority;
 }
 
-inline CascadeLayerPriority RuleSet::cascadeLayerPriorityFor(const RuleData& ruleData) const
+inline unsigned RuleSet::cascadeLayerPriorityFor(const RuleData& ruleData) const
 {
     if (m_cascadeLayerIdentifierForRulePosition.size() <= ruleData.position())
         return cascadeLayerPriorityForUnlayered;

Modified: trunk/Source/WebCore/style/StyleBuilder.cpp (285492 => 285493)


--- trunk/Source/WebCore/style/StyleBuilder.cpp	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/style/StyleBuilder.cpp	2021-11-09 13:53:12 UTC (rev 285493)
@@ -80,8 +80,8 @@
     return false;
 }
 
-Builder::Builder(RenderStyle& style, BuilderContext&& context, const MatchResult& matchResult, CascadeLevel cascadeLevel, PropertyCascade::IncludedProperties includedProperties)
-    : m_cascade(matchResult, cascadeLevel, includedProperties, directionFromStyle(style))
+Builder::Builder(RenderStyle& style, BuilderContext&& context, const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, PropertyCascade::IncludedProperties includedProperties)
+    : m_cascade(matchResult, cascadeLevels, includedProperties, directionFromStyle(style))
     , m_state(*this, style, WTFMove(context))
 {
 }
@@ -121,6 +121,16 @@
     ASSERT(!m_state.fontDirty());
 }
 
+void Builder::applyPropertyValue(CSSPropertyID propertyID, CSSValue* value)
+{
+    if (!value)
+        return;
+
+    applyProperty(propertyID, *value, SelectorChecker::MatchDefault);
+
+    m_state.updateFont();
+}
+
 void Builder::applyDeferredProperties()
 {
     for (auto& property : m_cascade.deferredProperties())
@@ -235,7 +245,6 @@
 {
     m_state.m_cascadeLevel = property.level;
     m_state.m_styleScopeOrdinal = property.styleScopeOrdinal;
-    m_state.m_cascadeLayerPriority = property.cascadeLayerPriority;
 
     auto applyWithLinkMatch = [&](SelectorChecker::LinkMatchMask linkMatch) {
         if (property.cssValue[linkMatch]) {
@@ -286,27 +295,21 @@
 
     bool isUnset = valueToApply->isUnsetValue() || customPropertyValueID == CSSValueUnset;
     bool isRevert = valueToApply->isRevertValue() || customPropertyValueID == CSSValueRevert;
-    bool isRevertLayer = valueToApply->isRevertLayerValue() || customPropertyValueID == CSSValueRevertLayer;
 
-    if (isRevert || isRevertLayer) {
-        auto* rollbackCascade = isRevert
-            ? ensureRollbackCascadeForRevert(m_state.m_cascadeLevel)
-            : ensureRollbackCascadeForRevertLayer(m_state.m_cascadeLevel, m_state.m_cascadeLayerPriority);
-
-        if (rollbackCascade) {
+    if (isRevert) {
+        if (auto* rollback = m_cascade.propertyCascadeForRollback(m_state.m_cascadeLevel)) {
             // With the rollback cascade built, we need to obtain the property and apply it. If the property is
-            // not present, then we behave like "unset." Otherwise we apply the property instead of our own.
-            SetForScope cascadeLevelScope(m_state.m_cascadeLevel, rollbackCascade->maximumCascadeLevel());
-            SetForScope cascadeLayerPriorityScope(m_state.m_cascadeLayerPriority, rollbackCascade->maximumCascadeLayerPriority());
+            // not present, then we behave like "unset." Otherwise we apply the property instead of
+            // our own.
             if (customPropertyValue) {
-                if (customPropertyRegistered && customPropertyRegistered->inherits && rollbackCascade->hasCustomProperty(customPropertyValue->name())) {
-                    auto property = rollbackCascade->customProperty(customPropertyValue->name());
+                if (customPropertyRegistered && customPropertyRegistered->inherits && rollback->hasCustomProperty(customPropertyValue->name())) {
+                    auto property = rollback->customProperty(customPropertyValue->name());
                     if (property.cssValue[linkMatchMask])
                         applyProperty(property.id, *property.cssValue[linkMatchMask], linkMatchMask);
                     return;
                 }
-            } else if (rollbackCascade->hasProperty(id)) {
-                auto& property = rollbackCascade->property(id);
+            } else if (rollback->hasProperty(id)) {
+                auto& property = rollback->property(id);
                 if (property.cssValue[linkMatchMask])
                     applyProperty(property.id, *property.cssValue[linkMatchMask], linkMatchMask);
                 return;
@@ -370,32 +373,5 @@
     return CSSParser(m_state.document()).parseValueWithVariableReferences(propertyID, value, m_state);
 }
 
-const PropertyCascade* Builder::ensureRollbackCascadeForRevert(CascadeLevel rollbackCascadeLevel)
-{
-    if (rollbackCascadeLevel == CascadeLevel::UserAgent)
-        return nullptr;
-
-    auto key = makeRollbackCascadeKey(rollbackCascadeLevel, RuleSet::cascadeLayerPriorityForUnlayered);
-    return m_rollbackCascades.ensure(key, [&] {
-        return makeUnique<const PropertyCascade>(m_cascade, --rollbackCascadeLevel, RuleSet::cascadeLayerPriorityForUnlayered);
-    }).iterator->value.get();
 }
-
-const PropertyCascade* Builder::ensureRollbackCascadeForRevertLayer(CascadeLevel cascadeLevel, CascadeLayerPriority rollbackLayerPriority)
-{
-    if (!rollbackLayerPriority)
-        return nullptr;
-
-    auto key = makeRollbackCascadeKey(cascadeLevel, rollbackLayerPriority);
-    return m_rollbackCascades.ensure(key, [&] {
-        return makeUnique<const PropertyCascade>(m_cascade, cascadeLevel, rollbackLayerPriority - 1);
-    }).iterator->value.get();
 }
-
-auto Builder::makeRollbackCascadeKey(CascadeLevel cascadeLevel, CascadeLayerPriority cascadeLayerPriority) -> RollbackCascadeKey
-{
-    return { static_cast<unsigned>(cascadeLevel), static_cast<unsigned>(cascadeLayerPriority) };
-}
-
-}
-}

Modified: trunk/Source/WebCore/style/StyleBuilder.h (285492 => 285493)


--- trunk/Source/WebCore/style/StyleBuilder.h	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/style/StyleBuilder.h	2021-11-09 13:53:12 UTC (rev 285493)
@@ -35,7 +35,7 @@
 class Builder {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    Builder(RenderStyle&, BuilderContext&&, const MatchResult&, CascadeLevel, PropertyCascade::IncludedProperties = PropertyCascade::IncludedProperties::All);
+    Builder(RenderStyle&, BuilderContext&&, const MatchResult&, OptionSet<CascadeLevel>, PropertyCascade::IncludedProperties = PropertyCascade::IncludedProperties::All);
     ~Builder();
 
     void applyAllProperties();
@@ -45,6 +45,8 @@
     void applyProperty(CSSPropertyID propertyID) { applyProperties(propertyID, propertyID); }
     void applyCustomProperty(const String& name);
 
+    void applyPropertyValue(CSSPropertyID, CSSValue*);
+
     BuilderState& state() { return m_state; }
 
 private:
@@ -61,16 +63,7 @@
     Ref<CSSValue> resolveValue(CSSPropertyID, CSSValue&);
     RefPtr<CSSValue> resolvedVariableValue(CSSPropertyID, const CSSValue&);
 
-    const PropertyCascade* ensureRollbackCascadeForRevert(CascadeLevel);
-    const PropertyCascade* ensureRollbackCascadeForRevertLayer(CascadeLevel, CascadeLayerPriority);
-
-    using RollbackCascadeKey = std::pair<unsigned, unsigned>;
-    RollbackCascadeKey makeRollbackCascadeKey(CascadeLevel, CascadeLayerPriority);
-
     const PropertyCascade m_cascade;
-    // Rollback cascades are build on demand to resolve 'revert' and 'revert-layer' keywords.
-    HashMap<RollbackCascadeKey, std::unique_ptr<const PropertyCascade>> m_rollbackCascades;
-
     BuilderState m_state;
 };
 

Modified: trunk/Source/WebCore/style/StyleBuilderState.h (285492 => 285493)


--- trunk/Source/WebCore/style/StyleBuilderState.h	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/style/StyleBuilderState.h	2021-11-09 13:53:12 UTC (rev 285493)
@@ -29,7 +29,6 @@
 #include "CSSToStyleMap.h"
 #include "CascadeLevel.h"
 #include "RenderStyle.h"
-#include "RuleSet.h"
 #include "SelectorChecker.h"
 #include <wtf/Bitmap.h>
 
@@ -137,7 +136,6 @@
 
     CascadeLevel m_cascadeLevel { };
     ScopeOrdinal m_styleScopeOrdinal { };
-    CascadeLayerPriority m_cascadeLayerPriority { };
     SelectorChecker::LinkMatchMask m_linkMatch { };
 
     bool m_fontDirty { false };

Modified: trunk/Source/WebCore/style/StyleResolver.cpp (285492 => 285493)


--- trunk/Source/WebCore/style/StyleResolver.cpp	2021-11-09 13:08:17 UTC (rev 285492)
+++ trunk/Source/WebCore/style/StyleResolver.cpp	2021-11-09 13:53:12 UTC (rev 285493)
@@ -283,7 +283,7 @@
     state.setStyle(RenderStyle::clonePtr(*elementStyle));
     state.setParentStyle(RenderStyle::clonePtr(context.parentStyle ? *context.parentStyle : *elementStyle));
 
-    Builder builder(*state.style(), builderContext(state), result, CascadeLevel::Author);
+    Builder builder(*state.style(), builderContext(state), result, { CascadeLevel::Author });
     builder.applyAllProperties();
 
     Adjuster adjuster(document(), *state.parentStyle(), nullptr, nullptr);
@@ -436,7 +436,7 @@
 
     auto& result = collector.matchResult();
 
-    Builder builder(*state.style(), builderContext(state), result, CascadeLevel::Author);
+    Builder builder(*state.style(), builderContext(state), result, { CascadeLevel::Author });
     builder.applyAllProperties();
 
     // Now return the style.
@@ -555,13 +555,13 @@
         // If so, we cache the border and background styles so that RenderTheme::adjustStyle()
         // can look at them later to figure out if this is a styled form control or not.
         auto userAgentStyle = RenderStyle::clonePtr(style);
-        Builder builder(*userAgentStyle, builderContext(state), matchResult, CascadeLevel::UserAgent);
+        Builder builder(*userAgentStyle, builderContext(state), matchResult, { CascadeLevel::UserAgent });
         builder.applyAllProperties();
 
         state.setUserAgentAppearanceStyle(WTFMove(userAgentStyle));
     }
 
-    Builder builder(*state.style(), builderContext(state), matchResult, CascadeLevel::Author, includedProperties);
+    Builder builder(*state.style(), builderContext(state), matchResult, allCascadeLevels(), includedProperties);
 
     // High priority properties may affect resolution of other properties (they are mostly font related).
     builder.applyHighPriorityProperties();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to