Changeset 291594 in webkit


Ignore:
Timestamp:
Mar 21, 2022 6:35:47 PM (4 months ago)
Author:
Oriol Brufau
Message:

[css-cascade] Let revert-layer roll back to preshints
https://bugs.webkit.org/show_bug.cgi?id=237532

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Add test.

  • web-platform-tests/css/css-cascade/presentational-hints-rollback-expected.txt: Added.
  • web-platform-tests/css/css-cascade/presentational-hints-rollback.html: Added.

Source/WebCore:

The patch makes presentational hints use a cascade layer priority of 0.
The priority of the lowest layer is then increased to 1.
This allows 'revert-layer' in author origin revert to the presentational
hints origin, which is between user origin and author origin.

Test: imported/w3c/web-platform-tests/css/css-cascade/presentational-hints-rollback.html

  • style/ElementRuleCollector.cpp:

(WebCore::Style::ElementRuleCollector::addElementStyleProperties):
(WebCore::Style::ElementRuleCollector::matchAllRules):
(WebCore::Style::ElementRuleCollector::addElementInlineStyleProperties):

  • style/ElementRuleCollector.h:
  • style/RuleSetBuilder.cpp:

(WebCore::Style::RuleSetBuilder::updateCascadeLayerPriorities):

Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r291589 r291594  
     12022-03-21  Oriol Brufau  <obrufau@igalia.com>
     2
     3        [css-cascade] Let revert-layer roll back to preshints
     4        https://bugs.webkit.org/show_bug.cgi?id=237532
     5
     6        Reviewed by Darin Adler.
     7
     8        Add test.
     9
     10        * web-platform-tests/css/css-cascade/presentational-hints-rollback-expected.txt: Added.
     11        * web-platform-tests/css/css-cascade/presentational-hints-rollback.html: Added.
     12
    1132022-03-21  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r291589 r291594  
     12022-03-21  Oriol Brufau  <obrufau@igalia.com>
     2
     3        [css-cascade] Let revert-layer roll back to preshints
     4        https://bugs.webkit.org/show_bug.cgi?id=237532
     5
     6        Reviewed by Darin Adler.
     7
     8        The patch makes presentational hints use a cascade layer priority of 0.
     9        The priority of the lowest layer is then increased to 1.
     10        This allows 'revert-layer' in author origin revert to the presentational
     11        hints origin, which is between user origin and author origin.
     12
     13        Test: imported/w3c/web-platform-tests/css/css-cascade/presentational-hints-rollback.html
     14
     15        * style/ElementRuleCollector.cpp:
     16        (WebCore::Style::ElementRuleCollector::addElementStyleProperties):
     17        (WebCore::Style::ElementRuleCollector::matchAllRules):
     18        (WebCore::Style::ElementRuleCollector::addElementInlineStyleProperties):
     19        * style/ElementRuleCollector.h:
     20        * style/RuleSetBuilder.cpp:
     21        (WebCore::Style::RuleSetBuilder::updateCascadeLayerPriorities):
     22
    1232022-03-21  Chris Dumez  <cdumez@apple.com>
    224
  • trunk/Source/WebCore/style/ElementRuleCollector.cpp

    r290457 r291594  
    127127}
    128128
    129 inline void ElementRuleCollector::addElementStyleProperties(const StyleProperties* propertySet, bool isCacheable, FromStyleAttribute fromStyleAttribute)
     129inline void ElementRuleCollector::addElementStyleProperties(const StyleProperties* propertySet, CascadeLayerPriority priority, bool isCacheable, FromStyleAttribute fromStyleAttribute)
    130130{
    131131    if (!propertySet || propertySet->isEmpty())
     
    136136
    137137    auto matchedProperty = MatchedProperties { propertySet };
     138    matchedProperty.cascadeLayerPriority = priority;
    138139    matchedProperty.fromStyleAttribute = fromStyleAttribute;
    139140    addMatchedProperties(WTFMove(matchedProperty), DeclarationOrigin::Author);
     
    550551        auto& styledElement = downcast<StyledElement>(element());
    551552        // https://html.spec.whatwg.org/#presentational-hints
    552         addElementStyleProperties(styledElement.presentationalHintStyle());
     553        addElementStyleProperties(styledElement.presentationalHintStyle(), RuleSet::cascadeLayerPriorityForPresentationalHints);
    553554
    554555        // Tables and table cells share an additional presentation style that must be applied
    555556        // after all attributes, since their style depends on the values of multiple attributes.
    556         addElementStyleProperties(styledElement.additionalPresentationalHintStyle());
     557        addElementStyleProperties(styledElement.additionalPresentationalHintStyle(), RuleSet::cascadeLayerPriorityForPresentationalHints);
    557558
    558559        if (is<HTMLElement>(styledElement)) {
     
    589590        // FIXME: Media control shadow trees seem to have problems with caching.
    590591        bool isInlineStyleCacheable = !inlineStyle->isMutable() && !element().isInShadowTree();
    591         addElementStyleProperties(inlineStyle, isInlineStyleCacheable, FromStyleAttribute::Yes);
     592        addElementStyleProperties(inlineStyle, RuleSet::cascadeLayerPriorityForUnlayered, isInlineStyleCacheable, FromStyleAttribute::Yes);
    592593    }
    593594
    594595    if (includeSMILProperties && is<SVGElement>(element()))
    595         addElementStyleProperties(downcast<SVGElement>(element()).animatedSMILStyleProperties(), false /* isCacheable */);
     596        addElementStyleProperties(downcast<SVGElement>(element()).animatedSMILStyleProperties(), RuleSet::cascadeLayerPriorityForUnlayered, false /* isCacheable */);
    596597}
    597598
  • trunk/Source/WebCore/style/ElementRuleCollector.h

    r290457 r291594  
    9797
    9898private:
    99     void addElementStyleProperties(const StyleProperties*, bool isCacheable = true, FromStyleAttribute = FromStyleAttribute::No);
     99    void addElementStyleProperties(const StyleProperties*, CascadeLayerPriority, bool isCacheable = true, FromStyleAttribute = FromStyleAttribute::No);
    100100
    101101    void matchUARules(const RuleSet&);
  • trunk/Source/WebCore/style/RuleSet.h

    r290257 r291594  
    106106    bool hasHostPseudoClassRulesMatchingInShadowTree() const { return m_hasHostPseudoClassRulesMatchingInShadowTree; }
    107107
     108    static constexpr auto cascadeLayerPriorityForPresentationalHints = std::numeric_limits<CascadeLayerPriority>::min();
    108109    static constexpr auto cascadeLayerPriorityForUnlayered = std::numeric_limits<CascadeLayerPriority>::max();
    109110
  • trunk/Source/WebCore/style/RuleSetBuilder.cpp

    r290329 r291594  
    290290    std::sort(layersInPriorityOrder.begin(), layersInPriorityOrder.end(), compare);
    291291
     292    // Priorities matter only relative to each other, so assign them enforcing these constraints:
     293    // - Layers must get a priority greater than RuleSet::cascadeLayerPriorityForPresentationalHints.
     294    // - Layers must get a priority smaller than RuleSet::cascadeLayerPriorityForUnlayered.
     295    // - A layer must get at least the same priority as the previous one.
     296    // - A layer should get more priority than the previous one, but this may be impossible if there are too many layers.
     297    //   In that case, the last layers will get the maximum priority for layers, RuleSet::cascadeLayerPriorityForUnlayered - 1.
    292298    for (unsigned i = 0; i < layerCount; ++i) {
    293         auto priority = std::min<unsigned>(i, RuleSet::cascadeLayerPriorityForUnlayered - 1);
     299        auto priority = std::min<unsigned>(i + RuleSet::cascadeLayerPriorityForPresentationalHints + 1, RuleSet::cascadeLayerPriorityForUnlayered - 1);
    294300        m_ruleSet->cascadeLayerForIdentifier(layersInPriorityOrder[i]).priority = priority;
    295301    }
Note: See TracChangeset for help on using the changeset viewer.