Changeset 250821 in webkit


Ignore:
Timestamp:
Oct 8, 2019 5:22:21 AM (4 years ago)
Author:
Antti Koivisto
Message:

[CSS Shadow Parts] Implement style invalidation
https://bugs.webkit.org/show_bug.cgi?id=202632

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-shadow-parts/invalidation-change-exportparts-forward-expected.txt:
  • web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-expected.txt:
  • web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-forward-expected.txt:

Source/WebCore:

Tests: fast/css/shadow-parts/invalidation-class-descendant-combinator-export.html

fast/css/shadow-parts/invalidation-class-descendant-combinator.html
fast/css/shadow-parts/invalidation-class-sibling-combinator-export.html
fast/css/shadow-parts/invalidation-class-sibling-combinator.html

  • css/RuleFeature.cpp:

(WebCore::isSiblingOrSubject):

Don't treat crossing to host as moving to ancestor when computing elements impacted by a selector.
StyleInvalidator expects these relations to be about the host element, shadow tree invalidation in handled separately.

  • dom/Element.cpp:

(WebCore::Element::attributeChanged):

Invalidate parts in shadow tree on 'exportparts' attribute mutation.

(WebCore::Element::partAttributeChanged):

Invalidate element on 'part' attribute mutation.

  • style/StyleInvalidator.cpp:

(WebCore::Style::Invalidator::Invalidator):
(WebCore::Style::Invalidator::invalidateIfNeeded):

Invalidate parts in shadow tree during class and attribute mutation invalidation.

(WebCore::Style::Invalidator::invalidateShadowParts):

  • style/StyleInvalidator.h:

(WebCore::Style::Invalidator::dirtiesAllStyle const):
(WebCore::Style::Invalidator::hasShadowPseudoElementRulesInAuthorSheet const): Deleted.

Remove an unncessary bool.

LayoutTests:

Add some tests to verify class mutations and combinators with ::part and exportpart.

  • fast/css/shadow-parts/invalidation-class-descendant-combinator-expected.txt: Added.
  • fast/css/shadow-parts/invalidation-class-descendant-combinator-export-expected.txt: Added.
  • fast/css/shadow-parts/invalidation-class-descendant-combinator-export.html: Added.
  • fast/css/shadow-parts/invalidation-class-descendant-combinator.html: Added.
  • fast/css/shadow-parts/invalidation-class-sibling-combinator-expected.txt: Added.
  • fast/css/shadow-parts/invalidation-class-sibling-combinator-export-expected.txt: Added.
  • fast/css/shadow-parts/invalidation-class-sibling-combinator-export.html: Added.
  • fast/css/shadow-parts/invalidation-class-sibling-combinator.html: Added.
Location:
trunk
Files:
9 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r250817 r250821  
     12019-10-08  Antti Koivisto  <antti@apple.com>
     2
     3        [CSS Shadow Parts] Implement style invalidation
     4        https://bugs.webkit.org/show_bug.cgi?id=202632
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Add some tests to verify class mutations and combinators with ::part and exportpart.
     9
     10        * fast/css/shadow-parts/invalidation-class-descendant-combinator-expected.txt: Added.
     11        * fast/css/shadow-parts/invalidation-class-descendant-combinator-export-expected.txt: Added.
     12        * fast/css/shadow-parts/invalidation-class-descendant-combinator-export.html: Added.
     13        * fast/css/shadow-parts/invalidation-class-descendant-combinator.html: Added.
     14        * fast/css/shadow-parts/invalidation-class-sibling-combinator-expected.txt: Added.
     15        * fast/css/shadow-parts/invalidation-class-sibling-combinator-export-expected.txt: Added.
     16        * fast/css/shadow-parts/invalidation-class-sibling-combinator-export.html: Added.
     17        * fast/css/shadow-parts/invalidation-class-sibling-combinator.html: Added.
     18
    1192019-10-08  Antti Koivisto  <antti@apple.com>
    220
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r250787 r250821  
     12019-10-08  Antti Koivisto  <antti@apple.com>
     2
     3        [CSS Shadow Parts] Implement style invalidation
     4        https://bugs.webkit.org/show_bug.cgi?id=202632
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * web-platform-tests/css/css-shadow-parts/invalidation-change-exportparts-forward-expected.txt:
     9        * web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-expected.txt:
     10        * web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-forward-expected.txt:
     11
    1122019-10-07  Rob Buis  <rbuis@igalia.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-exportparts-forward-expected.txt

    r250712 r250821  
    11The following text should be green:
    22
    3 FAIL Part in selected host changed color assert_not_equals: got disallowed value "rgb(255, 0, 0)"
     3PASS Part in selected host changed color
    44
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-expected.txt

    r250628 r250821  
    11The following text should be green:
    22
    3 FAIL Part in selected host changed color assert_not_equals: got disallowed value "rgb(255, 0, 0)"
     3PASS Part in selected host changed color
    44
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-part-name-forward-expected.txt

    r250712 r250821  
    11The following text should be green:
    22
    3 FAIL Part in selected host changed color assert_not_equals: got disallowed value "rgb(255, 0, 0)"
     3PASS Part in selected host changed color
    44
  • trunk/Source/WebCore/ChangeLog

    r250819 r250821  
     12019-10-08  Antti Koivisto  <antti@apple.com>
     2
     3        [CSS Shadow Parts] Implement style invalidation
     4        https://bugs.webkit.org/show_bug.cgi?id=202632
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Tests: fast/css/shadow-parts/invalidation-class-descendant-combinator-export.html
     9               fast/css/shadow-parts/invalidation-class-descendant-combinator.html
     10               fast/css/shadow-parts/invalidation-class-sibling-combinator-export.html
     11               fast/css/shadow-parts/invalidation-class-sibling-combinator.html
     12
     13        * css/RuleFeature.cpp:
     14        (WebCore::isSiblingOrSubject):
     15
     16        Don't treat crossing to host as moving to ancestor when computing elements impacted by a selector.
     17        StyleInvalidator expects these relations to be about the host element, shadow tree invalidation in handled separately.
     18
     19        * dom/Element.cpp:
     20        (WebCore::Element::attributeChanged):
     21
     22        Invalidate parts in shadow tree on 'exportparts' attribute mutation.
     23
     24        (WebCore::Element::partAttributeChanged):
     25
     26        Invalidate element on 'part' attribute mutation.
     27
     28        * style/StyleInvalidator.cpp:
     29        (WebCore::Style::Invalidator::Invalidator):
     30        (WebCore::Style::Invalidator::invalidateIfNeeded):
     31
     32        Invalidate parts in shadow tree during class and attribute mutation invalidation.
     33
     34        (WebCore::Style::Invalidator::invalidateShadowParts):
     35        * style/StyleInvalidator.h:
     36        (WebCore::Style::Invalidator::dirtiesAllStyle const):
     37        (WebCore::Style::Invalidator::hasShadowPseudoElementRulesInAuthorSheet const): Deleted.
     38
     39        Remove an unncessary bool.
     40
    1412019-10-08  Carlos Garcia Campos  <cgarcia@igalia.com>
    242
  • trunk/Source/WebCore/css/RuleFeature.cpp

    r248846 r250821  
    4343    case MatchElement::DirectSibling:
    4444    case MatchElement::AnySibling:
     45    case MatchElement::Host:
    4546        return true;
    4647    case MatchElement::Parent:
     
    4849    case MatchElement::ParentSibling:
    4950    case MatchElement::AncestorSibling:
    50     case MatchElement::Host:
    5151        return false;
    5252    }
  • trunk/Source/WebCore/dom/Element.cpp

    r250788 r250821  
    104104#include "SimulatedClick.h"
    105105#include "SlotAssignment.h"
     106#include "StyleInvalidator.h"
    106107#include "StyleProperties.h"
    107108#include "StyleResolver.h"
     
    17511752            partAttributeChanged(newValue);
    17521753        else if (name == HTMLNames::exportpartsAttr) {
    1753             if (auto* shadowRoot = this->shadowRoot())
     1754            if (auto* shadowRoot = this->shadowRoot()) {
    17541755                shadowRoot->invalidatePartMappings();
     1756                Style::Invalidator::invalidateShadowParts(*shadowRoot);
     1757            }
    17551758        }
    17561759    }
     
    18361839            partList->associatedAttributeValueChanged(newValue);
    18371840    }
     1841
     1842    if (needsStyleInvalidation() && isInShadowTree())
     1843        invalidateStyleInternal();
    18381844}
    18391845
  • trunk/Source/WebCore/style/StyleInvalidator.cpp

    r248846 r250821  
    3232#include "ElementRuleCollector.h"
    3333#include "HTMLSlotElement.h"
     34#include "RuntimeEnabledFeatures.h"
    3435#include "SelectorFilter.h"
    3536#include "ShadowRoot.h"
     
    8990    for (auto& sheet : sheets)
    9091        m_ownedRuleSet->addRulesFromSheet(*sheet, mediaQueryEvaluator);
    91 
    92     m_hasShadowPseudoElementRulesInAuthorSheet = m_ruleSet.hasShadowPseudoElementRules();
    9392}
    9493
    9594Invalidator::Invalidator(const RuleSet& ruleSet)
    9695    : m_ruleSet(ruleSet)
    97     , m_hasShadowPseudoElementRulesInAuthorSheet(ruleSet.hasShadowPseudoElementRules())
    9896{
    9997}
     
    10199Invalidator::CheckDescendants Invalidator::invalidateIfNeeded(Element& element, const SelectorFilter* filter)
    102100{
    103     if (m_hasShadowPseudoElementRulesInAuthorSheet) {
     101    if (m_ruleSet.hasShadowPseudoElementRules()) {
    104102        // FIXME: This could do actual rule matching too.
    105103        if (element.shadowRoot())
    106104            element.invalidateStyleForSubtreeInternal();
    107105    }
     106
     107    // FIXME: More fine-grained invalidation for ::part()
     108    if (!m_ruleSet.partPseudoElementRules().isEmpty() && element.shadowRoot())
     109        invalidateShadowParts(*element.shadowRoot());
    108110
    109111    bool shouldCheckForSlots = !m_ruleSet.slottedPseudoElementRules().isEmpty() && !m_didInvalidateHostChildren;
     
    263265}
    264266
    265 }
    266 }
     267void Invalidator::invalidateShadowParts(ShadowRoot& shadowRoot)
     268{
     269    if (!RuntimeEnabledFeatures::sharedFeatures().cssShadowPartsEnabled())
     270        return;
     271
     272    if (shadowRoot.mode() == ShadowRootMode::UserAgent)
     273        return;
     274
     275    for (auto& descendant : descendantsOfType<Element>(shadowRoot)) {
     276        // FIXME: We could only invalidate part names that actually show up in rules.
     277        if (!descendant.partNames().isEmpty())
     278            descendant.invalidateStyleInternal();
     279
     280        auto* nestedShadowRoot = descendant.shadowRoot();
     281        if (nestedShadowRoot && !nestedShadowRoot->partMappings().isEmpty())
     282            invalidateShadowParts(*nestedShadowRoot);
     283    }
     284}
     285
     286}
     287}
  • trunk/Source/WebCore/style/StyleInvalidator.h

    r227787 r250821  
    4747
    4848    bool dirtiesAllStyle() const { return m_dirtiesAllStyle; }
    49     bool hasShadowPseudoElementRulesInAuthorSheet() const { return m_hasShadowPseudoElementRulesInAuthorSheet; }
    5049    void invalidateStyle(Document&);
    5150    void invalidateStyle(ShadowRoot&);
    5251    void invalidateStyle(Element&);
    5352    void invalidateStyleWithMatchElement(Element&, MatchElement);
     53
     54    static void invalidateShadowParts(ShadowRoot&);
    5455
    5556private:
     
    6263    const RuleSet& m_ruleSet;
    6364    bool m_dirtiesAllStyle { false };
    64     bool m_hasShadowPseudoElementRulesInAuthorSheet { false };
    6565    bool m_didInvalidateHostChildren { false };
    6666};
Note: See TracChangeset for help on using the changeset viewer.