Changeset 206311 in webkit


Ignore:
Timestamp:
Sep 23, 2016 9:35:04 AM (8 years ago)
Author:
Antti Koivisto
Message:

Move stylesheet change logic from Document to AuthorStyleSheets
https://bugs.webkit.org/show_bug.cgi?id=162488

Reviewed by Andreas Kling.

That's where it belongs.

  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSStyleSheet.cpp:

(WebCore::CSSStyleSheet::didMutateRules):
(WebCore::CSSStyleSheet::didMutate):
(WebCore::CSSStyleSheet::clearOwnerNode):

  • dom/AuthorStyleSheets.cpp:

(WebCore::AuthorStyleSheets::AuthorStyleSheets):
(WebCore::AuthorStyleSheets::flushPendingUpdates):
(WebCore::AuthorStyleSheets::scheduleOptimizedUpdate):
(WebCore::AuthorStyleSheets::didChange):
(WebCore::AuthorStyleSheets::optimizedUpdateTimerFired):

  • dom/AuthorStyleSheets.h:

(WebCore::AuthorStyleSheets::hasPendingUpdate):
(WebCore::AuthorStyleSheets::pendingUpdateType): Deleted.
(WebCore::AuthorStyleSheets::setPendingUpdateType): Deleted.
(WebCore::AuthorStyleSheets::flushPendingUpdates): Deleted.

  • dom/Document.cpp:

(WebCore::Document::Document):
(WebCore::Document::setContentLanguage):
(WebCore::Document::needsStyleRecalc):
(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::updateLayoutIgnorePendingStylesheets):
(WebCore::Document::didRemoveAllPendingStylesheet):
(WebCore::Document::processHttpEquiv):
(WebCore::Document::setSelectedStylesheetSet):
(WebCore::Document::updateHoverActiveState):
(WebCore::Document::optimizedStyleSheetUpdateTimerFired): Deleted.
(WebCore::Document::scheduleOptimizedStyleSheetUpdate): Deleted.
(WebCore::Document::styleResolverChanged): Deleted.

  • dom/Document.h:

(WebCore::Document::needsStyleRecalc): Deleted.

  • dom/ExtensionStyleSheets.cpp:

(WebCore::ExtensionStyleSheets::clearPageUserSheet):
(WebCore::ExtensionStyleSheets::updatePageUserSheet):
(WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache):
(WebCore::ExtensionStyleSheets::addUserStyleSheet):
(WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting):
(WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired):

  • dom/InlineStyleSheetOwner.cpp:

(WebCore::InlineStyleSheetOwner::removedFromDocument):

  • dom/ProcessingInstruction.cpp:

(WebCore::ProcessingInstruction::removedFrom):

Also fix a bug that prevented document from rendering if a loading processing instruction was removed from the tree.
This is tested by fast/dom/StyleSheet/detached-style-pi-2.xhtml (after other changes in this patch).

  • dom/ShadowRoot.cpp:

(WebCore::ShadowRoot::updateStyle):

  • html/HTMLLinkElement.cpp:

(WebCore::HTMLLinkElement::setDisabledState):
(WebCore::HTMLLinkElement::parseAttribute):
(WebCore::HTMLLinkElement::process):
(WebCore::HTMLLinkElement::removedFrom):
(WebCore::HTMLLinkElement::removePendingSheet):

  • html/HTMLStyleElement.cpp:

(WebCore::HTMLStyleElement::parseAttribute):

  • inspector/InspectorCSSAgent.cpp:

(WebCore::InspectorCSSAgent::forcePseudoState):
(WebCore::InspectorCSSAgent::resetPseudoStates):

  • inspector/InspectorPageAgent.cpp:

(WebCore::InspectorPageAgent::setEmulatedMedia):

  • page/Frame.cpp:

(WebCore::Frame::setPrinting):

  • page/FrameView.cpp:

(WebCore::FrameView::layout):
(WebCore::FrameView::setPagination):
(WebCore::FrameView::setViewportSizeForCSSViewportUnits):

  • page/Page.cpp:

(WebCore::Page::setViewMode):
(WebCore::Page::setNeedsRecalcStyleInAllFrames):
(WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames):

  • svg/SVGFontFaceElement.cpp:

(WebCore::SVGFontFaceElement::rebuildFontFace):
(WebCore::SVGFontFaceElement::removedFrom):

  • xml/XMLTreeViewer.cpp:

(WebCore::XMLTreeViewer::transformDocumentToTreeView):

  • xml/parser/XMLDocumentParser.cpp:

(WebCore::XMLDocumentParser::end):

  • xml/parser/XMLDocumentParserLibxml2.cpp:

(WebCore::XMLDocumentParser::doEnd):

Location:
trunk/Source
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206310 r206311  
     12016-09-23  Antti Koivisto  <antti@apple.com>
     2
     3        Move stylesheet change logic from Document to AuthorStyleSheets
     4        https://bugs.webkit.org/show_bug.cgi?id=162488
     5
     6        Reviewed by Andreas Kling.
     7
     8        That's where it belongs.
     9
     10        * WebCore.xcodeproj/project.pbxproj:
     11        * css/CSSStyleSheet.cpp:
     12        (WebCore::CSSStyleSheet::didMutateRules):
     13        (WebCore::CSSStyleSheet::didMutate):
     14        (WebCore::CSSStyleSheet::clearOwnerNode):
     15        * dom/AuthorStyleSheets.cpp:
     16        (WebCore::AuthorStyleSheets::AuthorStyleSheets):
     17        (WebCore::AuthorStyleSheets::flushPendingUpdates):
     18        (WebCore::AuthorStyleSheets::scheduleOptimizedUpdate):
     19        (WebCore::AuthorStyleSheets::didChange):
     20        (WebCore::AuthorStyleSheets::optimizedUpdateTimerFired):
     21        * dom/AuthorStyleSheets.h:
     22        (WebCore::AuthorStyleSheets::hasPendingUpdate):
     23        (WebCore::AuthorStyleSheets::pendingUpdateType): Deleted.
     24        (WebCore::AuthorStyleSheets::setPendingUpdateType): Deleted.
     25        (WebCore::AuthorStyleSheets::flushPendingUpdates): Deleted.
     26        * dom/Document.cpp:
     27        (WebCore::Document::Document):
     28        (WebCore::Document::setContentLanguage):
     29        (WebCore::Document::needsStyleRecalc):
     30        (WebCore::Document::updateStyleIfNeeded):
     31        (WebCore::Document::updateLayoutIgnorePendingStylesheets):
     32        (WebCore::Document::didRemoveAllPendingStylesheet):
     33        (WebCore::Document::processHttpEquiv):
     34        (WebCore::Document::setSelectedStylesheetSet):
     35        (WebCore::Document::updateHoverActiveState):
     36        (WebCore::Document::optimizedStyleSheetUpdateTimerFired): Deleted.
     37        (WebCore::Document::scheduleOptimizedStyleSheetUpdate): Deleted.
     38        (WebCore::Document::styleResolverChanged): Deleted.
     39        * dom/Document.h:
     40        (WebCore::Document::needsStyleRecalc): Deleted.
     41        * dom/ExtensionStyleSheets.cpp:
     42        (WebCore::ExtensionStyleSheets::clearPageUserSheet):
     43        (WebCore::ExtensionStyleSheets::updatePageUserSheet):
     44        (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache):
     45        (WebCore::ExtensionStyleSheets::addUserStyleSheet):
     46        (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting):
     47        (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired):
     48        * dom/InlineStyleSheetOwner.cpp:
     49        (WebCore::InlineStyleSheetOwner::removedFromDocument):
     50        * dom/ProcessingInstruction.cpp:
     51        (WebCore::ProcessingInstruction::removedFrom):
     52
     53            Also fix a bug that prevented document from rendering if a loading processing instruction was removed from the tree.
     54            This is tested by fast/dom/StyleSheet/detached-style-pi-2.xhtml (after other changes in this patch).
     55
     56        * dom/ShadowRoot.cpp:
     57        (WebCore::ShadowRoot::updateStyle):
     58        * html/HTMLLinkElement.cpp:
     59        (WebCore::HTMLLinkElement::setDisabledState):
     60        (WebCore::HTMLLinkElement::parseAttribute):
     61        (WebCore::HTMLLinkElement::process):
     62        (WebCore::HTMLLinkElement::removedFrom):
     63        (WebCore::HTMLLinkElement::removePendingSheet):
     64        * html/HTMLStyleElement.cpp:
     65        (WebCore::HTMLStyleElement::parseAttribute):
     66        * inspector/InspectorCSSAgent.cpp:
     67        (WebCore::InspectorCSSAgent::forcePseudoState):
     68        (WebCore::InspectorCSSAgent::resetPseudoStates):
     69        * inspector/InspectorPageAgent.cpp:
     70        (WebCore::InspectorPageAgent::setEmulatedMedia):
     71        * page/Frame.cpp:
     72        (WebCore::Frame::setPrinting):
     73        * page/FrameView.cpp:
     74        (WebCore::FrameView::layout):
     75        (WebCore::FrameView::setPagination):
     76        (WebCore::FrameView::setViewportSizeForCSSViewportUnits):
     77        * page/Page.cpp:
     78        (WebCore::Page::setViewMode):
     79        (WebCore::Page::setNeedsRecalcStyleInAllFrames):
     80        (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames):
     81        * svg/SVGFontFaceElement.cpp:
     82        (WebCore::SVGFontFaceElement::rebuildFontFace):
     83        (WebCore::SVGFontFaceElement::removedFrom):
     84        * xml/XMLTreeViewer.cpp:
     85        (WebCore::XMLTreeViewer::transformDocumentToTreeView):
     86        * xml/parser/XMLDocumentParser.cpp:
     87        (WebCore::XMLDocumentParser::end):
     88        * xml/parser/XMLDocumentParserLibxml2.cpp:
     89        (WebCore::XMLDocumentParser::doEnd):
     90
    1912016-09-22  Sergio Villar Senin  <svillar@igalia.com>
    292
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r206252 r206311  
    61986198                E461802F1C8DD4D20026C02C /* StyleRelations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461802E1C8DD4D20026C02C /* StyleRelations.cpp */; };
    61996199                E461D65D1BB0C7F000CB5645 /* AuthorStyleSheets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461D65C1BB0C7F000CB5645 /* AuthorStyleSheets.cpp */; };
    6200                 E461D65F1BB0C80D00CB5645 /* AuthorStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = E461D65E1BB0C80D00CB5645 /* AuthorStyleSheets.h */; };
     6200                E461D65F1BB0C80D00CB5645 /* AuthorStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = E461D65E1BB0C80D00CB5645 /* AuthorStyleSheets.h */; settings = {ATTRIBUTES = (Private, ); }; };
    62016201                E462A4A1113E71BE004A4220 /* IntPointHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E462A4A0113E71BE004A4220 /* IntPointHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
    62026202                E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
  • trunk/Source/WebCore/css/CSSStyleSheet.cpp

    r205455 r206311  
    180180            return;
    181181        }
    182         owner->scheduleOptimizedStyleSheetUpdate();
    183         return;
    184     }
    185 
    186     owner->styleResolverChanged(DeferRecalcStyle);
     182        owner->authorStyleSheets().scheduleOptimizedUpdate();
     183        return;
     184    }
     185
     186    owner->authorStyleSheets().didChange(DeferRecalcStyle);
    187187
    188188    m_mutatedRules = true;
     
    194194    if (!owner)
    195195        return;
    196     owner->styleResolverChanged(DeferRecalcStyle);
     196    owner->authorStyleSheets().didChange(DeferRecalcStyle);
    197197}
    198198
     
    203203    if (!owner)
    204204        return;
    205     owner->styleResolverChanged(DeferRecalcStyleIfNeeded);
     205    owner->authorStyleSheets().didChange(DeferRecalcStyleIfNeeded);
    206206}
    207207
  • trunk/Source/WebCore/dom/AuthorStyleSheets.cpp

    r206167 r206311  
    5858AuthorStyleSheets::AuthorStyleSheets(Document& document)
    5959    : m_document(document)
     60    , m_optimizedUpdateTimer(*this, &AuthorStyleSheets::optimizedUpdateTimerFired)
    6061{
    6162}
     
    6465    : m_document(shadowRoot.documentScope())
    6566    , m_shadowRoot(&shadowRoot)
     67    , m_optimizedUpdateTimer(*this, &AuthorStyleSheets::optimizedUpdateTimerFired)
    6668{
    6769}
     
    385387}
    386388
    387 }
     389void AuthorStyleSheets::flushPendingUpdates()
     390{
     391    if (m_pendingUpdateType == NoUpdate)
     392        return;
     393    updateActiveStyleSheets(m_pendingUpdateType);
     394}
     395
     396void AuthorStyleSheets::scheduleOptimizedUpdate()
     397{
     398    if (m_optimizedUpdateTimer.isActive())
     399        return;
     400    if (m_pendingUpdateType == NoUpdate)
     401        m_pendingUpdateType = OptimizedUpdate;
     402    m_optimizedUpdateTimer.startOneShot(0);
     403}
     404
     405void AuthorStyleSheets::didChange(StyleResolverUpdateFlag updateFlag)
     406{
     407    m_optimizedUpdateTimer.stop();
     408
     409    // Don't bother updating, since we haven't loaded all our style info yet
     410    // and haven't calculated the style resolver for the first time.
     411    if (!m_document.hasLivingRenderTree() || (!m_shadowRoot && !m_didCalculateStyleResolver && m_pendingStyleSheetCount)) {
     412        m_document.clearStyleResolver();
     413        return;
     414    }
     415    m_didCalculateStyleResolver = true;
     416
     417    auto styleSheetUpdate = (updateFlag == RecalcStyleIfNeeded || updateFlag == DeferRecalcStyleIfNeeded)
     418        ? AuthorStyleSheets::OptimizedUpdate
     419        : AuthorStyleSheets::FullUpdate;
     420    bool stylesheetChangeRequiresStyleRecalc = updateActiveStyleSheets(styleSheetUpdate);
     421
     422    auto scheduleStyleRecalc = [&] {
     423        if (m_shadowRoot)
     424            m_shadowRoot->setNeedsStyleRecalc();
     425        else
     426            m_document.scheduleForcedStyleRecalc();
     427    };
     428
     429    if (updateFlag == DeferRecalcStyle) {
     430        scheduleStyleRecalc();
     431        return;
     432    }
     433
     434    if (updateFlag == DeferRecalcStyleIfNeeded) {
     435        if (stylesheetChangeRequiresStyleRecalc)
     436            scheduleStyleRecalc();
     437        return;
     438    }
     439
     440    if (stylesheetChangeRequiresStyleRecalc)
     441        m_document.recalcStyle(Style::Force);
     442}
     443
     444void AuthorStyleSheets::optimizedUpdateTimerFired()
     445{
     446    didChange(RecalcStyleIfNeeded);
     447}
     448
     449}
  • trunk/Source/WebCore/dom/AuthorStyleSheets.h

    r206167 r206311  
    4949class TreeScope;
    5050
     51enum StyleResolverUpdateFlag {
     52    RecalcStyleImmediately,
     53    DeferRecalcStyle,
     54    RecalcStyleIfNeeded,
     55    DeferRecalcStyleIfNeeded
     56};
     57
    5158class AuthorStyleSheets {
    5259    WTF_MAKE_FAST_ALLOCATED;
     
    6370    void removeStyleSheetCandidateNode(Node&);
    6471
    65     enum UpdateFlag { NoUpdate = 0, OptimizedUpdate, FullUpdate };
    66 
    67     UpdateFlag pendingUpdateType() const { return m_pendingUpdateType; }
    68     void setPendingUpdateType(UpdateFlag updateType)
    69     {
    70         if (updateType > m_pendingUpdateType)
    71             m_pendingUpdateType = updateType;
    72     }
    73 
    74     void flushPendingUpdates()
    75     {
    76         if (m_pendingUpdateType != NoUpdate)
    77             updateActiveStyleSheets(m_pendingUpdateType);
    78     }
    79 
    80     bool updateActiveStyleSheets(UpdateFlag);
     72    WEBCORE_EXPORT void didChange(StyleResolverUpdateFlag);
    8173
    8274    String preferredStylesheetSetName() const { return m_preferredStylesheetSetName; }
     
    10092    bool activeStyleSheetsContains(const CSSStyleSheet*) const;
    10193
     94    void scheduleOptimizedUpdate();
     95    bool hasPendingUpdate() const { return m_optimizedUpdateTimer.isActive(); }
     96    void flushPendingUpdates();
     97
    10298private:
     99    enum UpdateFlag { NoUpdate = 0, OptimizedUpdate, FullUpdate };
     100    bool updateActiveStyleSheets(UpdateFlag);
     101
    103102    void collectActiveStyleSheets(Vector<RefPtr<StyleSheet>>&);
     103
    104104    enum StyleResolverUpdateType {
    105105        Reconstruct,
     
    110110    void updateStyleResolver(Vector<RefPtr<CSSStyleSheet>>&, StyleResolverUpdateType);
    111111
     112    void optimizedUpdateTimerFired();
     113
    112114    Document& m_document;
    113115    ShadowRoot* m_shadowRoot { nullptr };
     
    115117    Vector<RefPtr<StyleSheet>> m_styleSheetsForStyleSheetList;
    116118    Vector<RefPtr<CSSStyleSheet>> m_activeStyleSheets;
     119
     120    Timer m_optimizedUpdateTimer;
    117121
    118122    // This is a mirror of m_activeAuthorStyleSheets that gets populated on demand for activeStyleSheetsContains().
     
    124128    // elements and when it is safe to execute scripts.
    125129    int m_pendingStyleSheetCount { 0 };
     130    bool m_didCalculateStyleResolver { false };
    126131
    127132    UpdateFlag m_pendingUpdateType { NoUpdate };
  • trunk/Source/WebCore/dom/Document.cpp

    r206309 r206311  
    436436#endif
    437437    , m_referencingNodeCount(0)
    438     , m_didCalculateStyleResolver(false)
    439438    , m_hasNodesWithPlaceholderStyle(false)
    440439    , m_needsNotifyRemoveAllPendingStylesheet(false)
     
    459458    , m_readyState(Complete)
    460459    , m_bParsing(false)
    461     , m_optimizedStyleSheetUpdateTimer(*this, &Document::optimizedStyleSheetUpdateTimerFired)
    462460    , m_styleRecalcTimer(*this, &Document::updateStyleIfNeeded)
    463461    , m_pendingStyleRecalcShouldForce(false)
     
    13581356
    13591357    // Recalculate style so language is used when selecting the initial font.
    1360     styleResolverChanged(DeferRecalcStyle);
     1358    m_authorStyleSheets->didChange(DeferRecalcStyle);
    13611359}
    13621360
     
    19461944}
    19471945
     1946bool Document::needsStyleRecalc() const
     1947{
     1948    if (pageCacheState() != NotInPageCache)
     1949        return false;
     1950
     1951    return m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || authorStyleSheets().hasPendingUpdate();
     1952}
     1953
    19481954void Document::updateStyleIfNeeded()
    19491955{
     
    19541960        return;
    19551961
    1956     if (m_optimizedStyleSheetUpdateTimer.isActive())
    1957         styleResolverChanged(RecalcStyleIfNeeded);
     1962    if (authorStyleSheets().hasPendingUpdate())
     1963        authorStyleSheets().didChange(RecalcStyleIfNeeded);
    19581964
    19591965    if (!needsStyleRecalc())
     
    20092015        if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == NoLayoutWithPendingSheets) {
    20102016            m_pendingSheetLayout = DidLayoutWithPendingSheets;
    2011             styleResolverChanged(RecalcStyleImmediately);
     2017            authorStyleSheets().didChange(RecalcStyleImmediately);
    20122018        } else if (m_hasNodesWithPlaceholderStyle)
    20132019            // If new nodes have been added or style recalc has been done with style sheets still pending, some nodes
     
    31463152    m_needsNotifyRemoveAllPendingStylesheet = false;
    31473153
    3148     styleResolverChanged(DeferRecalcStyleIfNeeded);
     3154    authorStyleSheets().didChange(DeferRecalcStyleIfNeeded);
    31493155
    31503156    if (m_pendingSheetLayout == DidLayoutWithPendingSheets) {
     
    32213227        authorStyleSheets().setSelectedStylesheetSetName(content);
    32223228        authorStyleSheets().setPreferredStylesheetSetName(content);
    3223         styleResolverChanged(DeferRecalcStyle);
     3229        authorStyleSheets().didChange(DeferRecalcStyle);
    32243230        break;
    32253231
     
    35253531{
    35263532    authorStyleSheets().setSelectedStylesheetSetName(aString);
    3527     styleResolverChanged(DeferRecalcStyle);
     3533    authorStyleSheets().didChange(DeferRecalcStyle);
    35283534}
    35293535
     
    35463552    for (auto* picture : changedPictures)
    35473553        picture->sourcesChanged();
    3548 }
    3549 
    3550 void Document::optimizedStyleSheetUpdateTimerFired()
    3551 {
    3552     styleResolverChanged(RecalcStyleIfNeeded);
    3553 }
    3554 
    3555 void Document::scheduleOptimizedStyleSheetUpdate()
    3556 {
    3557     if (m_optimizedStyleSheetUpdateTimer.isActive())
    3558         return;
    3559     authorStyleSheets().setPendingUpdateType(AuthorStyleSheets::OptimizedUpdate);
    3560     m_optimizedStyleSheetUpdateTimer.startOneShot(0);
    35613554}
    35623555
     
    36233616    for (auto* audioProducer : m_audioProducers)
    36243617        audioProducer->pageMutedStateDidChange();
    3625 }
    3626 
    3627 void Document::styleResolverChanged(StyleResolverUpdateFlag updateFlag)
    3628 {
    3629     if (m_optimizedStyleSheetUpdateTimer.isActive())
    3630         m_optimizedStyleSheetUpdateTimer.stop();
    3631 
    3632     // Don't bother updating, since we haven't loaded all our style info yet
    3633     // and haven't calculated the style selector for the first time.
    3634     if (!hasLivingRenderTree() || (!m_didCalculateStyleResolver && !haveStylesheetsLoaded())) {
    3635         m_styleResolver = nullptr;
    3636         return;
    3637     }
    3638     m_didCalculateStyleResolver = true;
    3639 
    3640     auto styleSheetUpdate = (updateFlag == RecalcStyleIfNeeded || updateFlag == DeferRecalcStyleIfNeeded)
    3641         ? AuthorStyleSheets::OptimizedUpdate
    3642         : AuthorStyleSheets::FullUpdate;
    3643     bool stylesheetChangeRequiresStyleRecalc = authorStyleSheets().updateActiveStyleSheets(styleSheetUpdate);
    3644 
    3645     if (updateFlag == DeferRecalcStyle) {
    3646         scheduleForcedStyleRecalc();
    3647         return;
    3648     }
    3649 
    3650     if (updateFlag == DeferRecalcStyleIfNeeded) {
    3651         if (stylesheetChangeRequiresStyleRecalc)
    3652             scheduleForcedStyleRecalc();
    3653         return;
    3654     }
    3655 
    3656     if (stylesheetChangeRequiresStyleRecalc)
    3657         recalcStyle(Style::Force);
    36583618}
    36593619
     
    66466606}
    66476607
    6648 void Document::updateHoverActiveState(const HitTestRequest& request, Element* innerElement, StyleResolverUpdateFlag updateFlag)
     6608void Document::updateHoverActiveState(const HitTestRequest& request, Element* innerElement)
    66496609{
    66506610    ASSERT(!request.readOnly());
     
    67636723    }
    67646724
    6765     ASSERT(updateFlag == RecalcStyleIfNeeded || updateFlag == DeferRecalcStyleIfNeeded);
    6766     if (updateFlag == RecalcStyleIfNeeded)
    6767         updateStyleIfNeeded();
     6725    updateStyleIfNeeded();
    67686726}
    67696727
  • trunk/Source/WebCore/dom/Document.h

    r206119 r206311  
    232232};
    233233
    234 enum StyleResolverUpdateFlag { RecalcStyleImmediately, DeferRecalcStyle, RecalcStyleIfNeeded, DeferRecalcStyleIfNeeded };
    235 
    236234enum NodeListInvalidationType {
    237235    DoNotInvalidateOnAttributeChanges = 0,
     
    518516    void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
    519517
    520     /**
    521      * Called when one or more stylesheets in the document may have been added, removed or changed.
    522      *
    523      * Creates a new style resolver and assign it to this document. This is done by iterating through all nodes in
    524      * document (or those before <BODY> in a HTML document), searching for stylesheets. Stylesheets can be contained in
    525      * <LINK>, <STYLE> or <BODY> elements, as well as processing instructions (XML documents only). A list is
    526      * constructed from these which is used to create the a new style selector which collates all of the stylesheets
    527      * found and is used to calculate the derived styles for all rendering objects.
    528      */
    529     WEBCORE_EXPORT void styleResolverChanged(StyleResolverUpdateFlag);
    530 
    531     void scheduleOptimizedStyleSheetUpdate();
    532 
    533518    void evaluateMediaQueryList();
    534519
     
    558543    void recalcStyle(Style::Change = Style::NoChange);
    559544    WEBCORE_EXPORT void updateStyleIfNeeded();
    560     bool needsStyleRecalc() const { return pageCacheState() == NotInPageCache && (m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || m_optimizedStyleSheetUpdateTimer.isActive()); }
     545    bool needsStyleRecalc() const;
    561546
    562547    WEBCORE_EXPORT void updateLayout();
     
    737722    void elementInActiveChainDidDetach(Element*);
    738723
    739     void updateHoverActiveState(const HitTestRequest&, Element*, StyleResolverUpdateFlag = RecalcStyleIfNeeded);
     724    void updateHoverActiveState(const HitTestRequest&, Element*);
    740725
    741726    // Updates for :target (CSS3 selector).
     
    749734    bool hasPendingStyleRecalc() const;
    750735    bool hasPendingForcedStyleRecalc() const;
    751     void optimizedStyleSheetUpdateTimerFired();
    752736
    753737    void registerNodeListForInvalidation(LiveNodeList&);
     
    14151399    std::unique_ptr<StyleResolver> m_styleResolver;
    14161400    std::unique_ptr<StyleResolver> m_userAgentShadowTreeStyleResolver;
    1417     bool m_didCalculateStyleResolver;
    14181401    bool m_hasNodesWithPlaceholderStyle;
    14191402    bool m_needsNotifyRemoveAllPendingStylesheet;
     
    15031486    bool m_bParsing;
    15041487
    1505     Timer m_optimizedStyleSheetUpdateTimer;
    15061488    Timer m_styleRecalcTimer;
    15071489    bool m_pendingStyleRecalcShouldForce;
  • trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp

    r205455 r206311  
    2929#include "ExtensionStyleSheets.h"
    3030
     31#include "AuthorStyleSheets.h"
    3132#include "CSSStyleSheet.h"
    3233#include "Element.h"
     
    8384    if (m_pageUserSheet) {
    8485        m_pageUserSheet = nullptr;
    85         m_document.styleResolverChanged(DeferRecalcStyle);
     86        m_document.authorStyleSheets().didChange(DeferRecalcStyle);
    8687    }
    8788}
     
    9192    clearPageUserSheet();
    9293    if (pageUserSheet())
    93         m_document.styleResolverChanged(RecalcStyleImmediately);
     94        m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
    9495}
    9596
     
    155156    if (m_injectedUserStyleSheets.isEmpty() && m_injectedAuthorStyleSheets.isEmpty())
    156157        return;
    157     m_document.styleResolverChanged(DeferRecalcStyle);
     158    m_document.authorStyleSheets().didChange(DeferRecalcStyle);
    158159}
    159160
     
    162163    ASSERT(userSheet.get().isUserStyleSheet());
    163164    m_userStyleSheets.append(CSSStyleSheet::create(WTFMove(userSheet), m_document));
    164     m_document.styleResolverChanged(RecalcStyleImmediately);
     165    m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
    165166}
    166167
     
    169170    ASSERT(!authorSheet.get().isUserStyleSheet());
    170171    m_authorStyleSheetsForTesting.append(CSSStyleSheet::create(WTFMove(authorSheet), m_document));
    171     m_document.styleResolverChanged(RecalcStyleImmediately);
     172    m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
    172173}
    173174
     
    201202void ExtensionStyleSheets::styleResolverChangedTimerFired()
    202203{
    203     m_document.styleResolverChanged(RecalcStyleImmediately);
     204    m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
    204205}
    205206
  • trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp

    r204466 r206311  
    7474    // If we're in document teardown, then we don't need to do any notification of our sheet's removal.
    7575    if (document.hasLivingRenderTree())
    76         document.styleResolverChanged(DeferRecalcStyle);
     76        document.authorStyleSheets().didChange(DeferRecalcStyle);
    7777}
    7878
  • trunk/Source/WebCore/dom/ProcessingInstruction.cpp

    r206203 r206311  
    269269        m_sheet->clearOwnerNode();
    270270        m_sheet = nullptr;
     271
     272    }
     273
     274    if (m_loading) {
     275        m_loading = false;
     276        document().authorStyleSheets().removePendingSheet();
    271277    }
    272278
    273279    // If we're in document teardown, then we don't need to do any notification of our sheet's removal.
    274280    if (document().hasLivingRenderTree())
    275         document().styleResolverChanged(DeferRecalcStyle);
     281        document().authorStyleSheets().didChange(DeferRecalcStyle);
    276282}
    277283
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r204543 r206311  
    109109void ShadowRoot::updateStyle()
    110110{
    111     bool shouldRecalcStyle = false;
    112 
    113     if (m_authorStyleSheets) {
    114         // FIXME: Make optimized updated work.
    115         shouldRecalcStyle = m_authorStyleSheets->updateActiveStyleSheets(AuthorStyleSheets::FullUpdate);
    116     }
    117 
    118     if (shouldRecalcStyle)
    119         setNeedsStyleRecalc();
     111    if (!m_authorStyleSheets)
     112        return;
     113    // FIXME: Make optimized updated work.
     114    m_authorStyleSheets->didChange(DeferRecalcStyle);
    120115}
    121116
  • trunk/Source/WebCore/html/HTMLLinkElement.cpp

    r206016 r206311  
    141141            process();
    142142        else
    143             document().styleResolverChanged(DeferRecalcStyle); // Update the style selector.
     143            document().authorStyleSheets().didChange(DeferRecalcStyle);
    144144    }
    145145}
     
    177177        process();
    178178        if (m_sheet && !isDisabled())
    179             document().styleResolverChanged(DeferRecalcStyle);
     179            document().authorStyleSheets().didChange(DeferRecalcStyle);
    180180        return;
    181181    }
     
    284284        // we no longer contain a stylesheet, e.g. perhaps rel or type was changed
    285285        clearSheet();
    286         document().styleResolverChanged(DeferRecalcStyle);
     286        document().authorStyleSheets().didChange(DeferRecalcStyle);
    287287    }
    288288}
     
    331331
    332332    if (document().hasLivingRenderTree())
    333         document().styleResolverChanged(DeferRecalcStyleIfNeeded);
     333        document().authorStyleSheets().didChange(DeferRecalcStyleIfNeeded);
    334334}
    335335
     
    556556    if (type == InactiveSheet) {
    557557        // Document just needs to know about the sheet for exposure through document.styleSheets
    558         document().authorStyleSheets().updateActiveStyleSheets(AuthorStyleSheets::OptimizedUpdate);
     558        document().authorStyleSheets().didChange(DeferRecalcStyleIfNeeded);
    559559        return;
    560560    }
  • trunk/Source/WebCore/html/HTMLStyleElement.cpp

    r202105 r206311  
    2525#include "HTMLStyleElement.h"
    2626
     27#include "AuthorStyleSheets.h"
    2728#include "Document.h"
    2829#include "Event.h"
     
    7879            sheet()->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(value));
    7980            if (inDocument() && document().hasLivingRenderTree())
    80                 document().styleResolverChanged(RecalcStyleImmediately);
     81                document().authorStyleSheets().didChange(RecalcStyleImmediately);
    8182        }
    8283    } else if (name == typeAttr)
  • trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp

    r203623 r206311  
    890890    else
    891891        m_nodeIdToForcedPseudoState.remove(nodeId);
    892     element->document().styleResolverChanged(RecalcStyleImmediately);
     892    element->document().authorStyleSheets().didChange(RecalcStyleImmediately);
    893893}
    894894
     
    11901190    m_nodeIdToForcedPseudoState.clear();
    11911191    for (auto& document : documentsToChange)
    1192         document->styleResolverChanged(RecalcStyleImmediately);
     1192        document->authorStyleSheets().didChange(RecalcStyleImmediately);
    11931193}
    11941194
  • trunk/Source/WebCore/inspector/InspectorPageAgent.cpp

    r205411 r206311  
    3333#include "InspectorPageAgent.h"
    3434
     35#include "AuthorStyleSheets.h"
    3536#include "CachedCSSStyleSheet.h"
    3637#include "CachedFont.h"
     
    10021003    Document* document = m_page.mainFrame().document();
    10031004    if (document) {
    1004         document->styleResolverChanged(RecalcStyleImmediately);
     1005        document->authorStyleSheets().didChange(RecalcStyleImmediately);
    10051006        document->updateLayout();
    10061007    }
  • trunk/Source/WebCore/page/Frame.cpp

    r205786 r206311  
    3333#include "AnimationController.h"
    3434#include "ApplyStyleCommand.h"
     35#include "AuthorStyleSheets.h"
    3536#include "BackForwardController.h"
    3637#include "CSSComputedStyleDeclaration.h"
     
    644645    view()->adjustMediaTypeForPrinting(printing);
    645646
    646     m_doc->styleResolverChanged(RecalcStyleImmediately);
     647    m_doc->authorStyleSheets().didChange(RecalcStyleImmediately);
    647648    if (shouldUsePrintingLayout()) {
    648649        view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShrinkRatio, shouldAdjustViewSize);
  • trunk/Source/WebCore/page/FrameView.cpp

    r206119 r206311  
    3030#include "AXObjectCache.h"
    3131#include "AnimationController.h"
     32#include "AuthorStyleSheets.h"
    3233#include "BackForwardController.h"
    3334#include "CachedImage.h"
     
    13011302        if (!styleResolver || styleResolver->hasMediaQueriesAffectedByViewportChange()) {
    13021303            LOG(Layout, "  hasMediaQueriesAffectedByViewportChange, enqueueing style recalc");
    1303             document.styleResolverChanged(DeferRecalcStyle);
     1304            document.authorStyleSheets().didChange(DeferRecalcStyle);
    13041305            // FIXME: This instrumentation event is not strictly accurate since cached media query results do not persist across StyleResolver rebuilds.
    13051306            InspectorInstrumentation::mediaQueryResultChanged(document);
     
    34963497    m_pagination = pagination;
    34973498
    3498     frame().document()->styleResolverChanged(DeferRecalcStyle);
     3499    frame().document()->authorStyleSheets().didChange(DeferRecalcStyle);
    34993500}
    35003501
     
    49654966        // FIXME: this should probably be updateViewportUnitsOnResize(), but synchronously
    49664967        // dirtying style here causes assertions on iOS (rdar://problem/19998166).
    4967         document->styleResolverChanged(DeferRecalcStyle);
     4968        document->authorStyleSheets().didChange(DeferRecalcStyle);
    49684969    }
    49694970}
  • trunk/Source/WebCore/page/Page.cpp

    r205805 r206311  
    2424#include "AnimationController.h"
    2525#include "ApplicationCacheStorage.h"
     26#include "AuthorStyleSheets.h"
    2627#include "BackForwardClient.h"
    2728#include "BackForwardController.h"
     
    423424
    424425    if (m_mainFrame->document())
    425         m_mainFrame->document()->styleResolverChanged(RecalcStyleImmediately);
     426        m_mainFrame->document()->authorStyleSheets().didChange(RecalcStyleImmediately);
    426427}
    427428#endif // ENABLE(VIEW_MODE_CSS_MEDIA)
     
    501502    for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
    502503        if (Document* document = frame->document())
    503             document->styleResolverChanged(DeferRecalcStyle);
     504            document->authorStyleSheets().didChange(DeferRecalcStyle);
    504505    }
    505506}
     
    11621163            continue;
    11631164        document->extensionStyleSheets().invalidateInjectedStyleSheetCache();
    1164         document->styleResolverChanged(DeferRecalcStyle);
     1165        document->authorStyleSheets().didChange(DeferRecalcStyle);
    11651166    }
    11661167}
  • trunk/Source/WebCore/svg/SVGFontFaceElement.cpp

    r205660 r206311  
    2525#include "SVGFontFaceElement.h"
    2626
     27#include "AuthorStyleSheets.h"
    2728#include "CSSFontFaceSrcValue.h"
    2829#include "CSSParser.h"
     
    267268    }
    268269
    269     document().styleResolverChanged(DeferRecalcStyle);
     270    document().authorStyleSheets().didChange(DeferRecalcStyle);
    270271}
    271272
     
    292293        m_fontFaceRule->mutableProperties().clear();
    293294
    294         document().styleResolverChanged(DeferRecalcStyle);
     295        document().authorStyleSheets().didChange(DeferRecalcStyle);
    295296    } else
    296297        ASSERT(!m_fontElement);
  • trunk/Source/WebCore/xml/XMLTreeViewer.cpp

    r200696 r206311  
    3333#if ENABLE(XSLT)
    3434
     35#include "AuthorStyleSheets.h"
    3536#include "Document.h"
    3637#include "Element.h"
     
    6465    auto text = m_document.createTextNode(cssString);
    6566    m_document.getElementById(String(ASCIILiteral("xml-viewer-style")))->appendChild(text, IGNORE_EXCEPTION);
    66     m_document.styleResolverChanged(RecalcStyleImmediately);
     67    m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
    6768}
    6869
  • trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp

    r200895 r206311  
    2727#include "XMLDocumentParser.h"
    2828
     29#include "AuthorStyleSheets.h"
    2930#include "CDATASection.h"
    3031#include "CachedScript.h"
     
    200201    else {
    201202        updateLeafTextNode();
    202         document()->styleResolverChanged(RecalcStyleImmediately);
     203        document()->authorStyleSheets().didChange(RecalcStyleImmediately);
    203204    }
    204205
  • trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp

    r206118 r206311  
    2929#include "XMLDocumentParser.h"
    3030
     31#include "AuthorStyleSheets.h"
    3132#include "CDATASection.h"
    3233#include "CachedScript.h"
     
    13871388
    13881389        document()->setParsing(false); // Make the document think it's done, so it will apply XSL stylesheets.
    1389         document()->styleResolverChanged(RecalcStyleImmediately);
     1390        document()->authorStyleSheets().didChange(RecalcStyleImmediately);
    13901391
    13911392        // styleResolverChanged() call can detach the parser and null out its document.
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r205858 r206311  
    7373#import "WebUIDelegatePrivate.h"
    7474#import "WebViewInternal.h"
     75#import <WebCore/AuthorStyleSheets.h>
    7576#import <WebCore/CSSStyleDeclaration.h>
    7677#import <WebCore/CachedImage.h>
     
    36123613
    36133614    if (Frame* coreFrame = core([self _frame]))
    3614         coreFrame->document()->styleResolverChanged(RecalcStyleImmediately);
     3615        coreFrame->document()->authorStyleSheets().didChange(RecalcStyleImmediately);
    36153616   
    36163617#ifdef LOG_TIMES       
     
    50055006            document->setPaginatedForScreen(_private->paginateScreenContent);
    50065007            document->setPrinting(_private->printing);
    5007             document->styleResolverChanged(RecalcStyleImmediately);
     5008            document->authorStyleSheets().didChange(RecalcStyleImmediately);
    50085009        }
    50095010    }
Note: See TracChangeset for help on using the changeset viewer.