Changeset 206990 in webkit


Ignore:
Timestamp:
Oct 10, 2016 1:19:03 AM (8 years ago)
Author:
Antti Koivisto
Message:

Enable optimized stylesheet updates in shadow trees
https://bugs.webkit.org/show_bug.cgi?id=163180

Reviewed by Darin Adler.

Source/WebCore:

When we get a new stylesheet (for example when load completes) we invalidate only
those elements in DOM that are affected by the new sheet. This patch makes the
optimization also work in shadow trees.

Test: fast/shadow-dom/scoped-style-invalidation.html

  • css/StyleInvalidationAnalysis.cpp:

(WebCore::StyleInvalidationAnalysis::invalidateStyle):

  • css/StyleInvalidationAnalysis.h:
  • dom/Document.cpp:

(WebCore::Document::didRemoveAllPendingStylesheet):

  • style/StyleScope.cpp:

(WebCore::Style::Scope::removePendingSheet):
(WebCore::Style::Scope::analyzeStyleSheetChange):
(WebCore::Style::Scope::updateActiveStyleSheets):

LayoutTests:

  • fast/shadow-dom/scoped-style-invalidation-expected.txt: Added.
  • fast/shadow-dom/scoped-style-invalidation.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r206981 r206990  
     12016-10-09  Antti Koivisto  <antti@apple.com>
     2
     3        Enable optimized stylesheet updates in shadow trees
     4        https://bugs.webkit.org/show_bug.cgi?id=163180
     5
     6        Reviewed by Darin Adler.
     7
     8        * fast/shadow-dom/scoped-style-invalidation-expected.txt: Added.
     9        * fast/shadow-dom/scoped-style-invalidation.html: Added.
     10
    1112016-10-09  Gyuyoung Kim  <gyuyoung.kim@navercorp.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r206989 r206990  
     12016-10-09  Antti Koivisto  <antti@apple.com>
     2
     3        Enable optimized stylesheet updates in shadow trees
     4        https://bugs.webkit.org/show_bug.cgi?id=163180
     5
     6        Reviewed by Darin Adler.
     7
     8        When we get a new stylesheet (for example when load completes) we invalidate only
     9        those elements in DOM that are affected by the new sheet. This patch makes the
     10        optimization also work in shadow trees.
     11
     12        Test: fast/shadow-dom/scoped-style-invalidation.html
     13
     14        * css/StyleInvalidationAnalysis.cpp:
     15        (WebCore::StyleInvalidationAnalysis::invalidateStyle):
     16        * css/StyleInvalidationAnalysis.h:
     17        * dom/Document.cpp:
     18        (WebCore::Document::didRemoveAllPendingStylesheet):
     19        * style/StyleScope.cpp:
     20        (WebCore::Style::Scope::removePendingSheet):
     21        (WebCore::Style::Scope::analyzeStyleSheetChange):
     22        (WebCore::Style::Scope::updateActiveStyleSheets):
     23
    1242016-10-10  Youenn Fablet  <youenn@apple.com>
    225
  • trunk/Source/WebCore/css/StyleInvalidationAnalysis.cpp

    r196864 r206990  
    170170}
    171171
     172void StyleInvalidationAnalysis::invalidateStyle(ShadowRoot& shadowRoot)
     173{
     174    ASSERT(!m_dirtiesAllStyle);
     175
     176    for (auto& child : childrenOfType<Element>(shadowRoot)) {
     177        SelectorFilter filter;
     178        invalidateStyleForTree(child, &filter);
     179    }
     180}
     181
    172182void StyleInvalidationAnalysis::invalidateStyle(Element& element)
    173183{
  • trunk/Source/WebCore/css/StyleInvalidationAnalysis.h

    r204466 r206990  
    3636class RuleSet;
    3737class SelectorFilter;
     38class ShadowRoot;
    3839class StyleSheetContents;
    3940
     
    4647    bool hasShadowPseudoElementRulesInAuthorSheet() const { return m_hasShadowPseudoElementRulesInAuthorSheet; }
    4748    void invalidateStyle(Document&);
     49    void invalidateStyle(ShadowRoot&);
    4850    void invalidateStyle(Element&);
    4951
  • trunk/Source/WebCore/dom/Document.cpp

    r206975 r206990  
    30843084    m_needsNotifyRemoveAllPendingStylesheet = false;
    30853085
    3086     styleScope().didChangeCandidatesForActiveSet();
    3087 
    30883086    if (m_pendingSheetLayout == DidLayoutWithPendingSheets) {
    30893087        m_pendingSheetLayout = IgnoreLayoutWithPendingSheets;
  • trunk/Source/WebCore/style/StyleScope.cpp

    r206951 r206990  
    130130    }
    131131
    132     if (m_shadowRoot) {
    133         // FIXME: Make optimized updates work.
    134         didChangeContentsOrInterpretation();
    135         return;
    136     }
    137 
    138     m_document.didRemoveAllPendingStylesheet();
     132    didChangeCandidatesForActiveSet();
     133
     134    if (!m_shadowRoot)
     135        m_document.didRemoveAllPendingStylesheet();
    139136}
    140137
     
    301298    if (invalidationAnalysis.dirtiesAllStyle())
    302299        return styleResolverUpdateType;
    303     invalidationAnalysis.invalidateStyle(m_document);
     300
     301    if (m_shadowRoot)
     302        invalidationAnalysis.invalidateStyle(*m_shadowRoot);
     303    else
     304        invalidationAnalysis.invalidateStyle(m_document);
     305
    304306    requiresFullStyleRecalc = false;
    305307
     
    347349        return;
    348350    }
    349 
    350     // FIXME: Support optimized invalidation in shadow trees.
    351     if (m_shadowRoot)
    352         updateType = UpdateType::ContentsOrInterpretation;
    353351
    354352    m_didUpdateActiveStyleSheets = true;
Note: See TracChangeset for help on using the changeset viewer.