Title: [206312] trunk/Source
Revision
206312
Author
[email protected]
Date
2016-09-23 10:15:03 -0700 (Fri, 23 Sep 2016)

Log Message

Unreviewed, rolling out r206311.
https://bugs.webkit.org/show_bug.cgi?id=162495

Broke internal iOS build (Requested by anttik on #webkit).

Reverted changeset:

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206311 => 206312)


--- trunk/Source/WebCore/ChangeLog	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/ChangeLog	2016-09-23 17:15:03 UTC (rev 206312)
@@ -1,3 +1,17 @@
+2016-09-23  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r206311.
+        https://bugs.webkit.org/show_bug.cgi?id=162495
+
+        Broke internal iOS build (Requested by anttik on #webkit).
+
+        Reverted changeset:
+
+        "Move stylesheet change logic from Document to
+        AuthorStyleSheets"
+        https://bugs.webkit.org/show_bug.cgi?id=162488
+        http://trac.webkit.org/changeset/206311
+
 2016-09-23  Antti Koivisto  <[email protected]>
 
         Move stylesheet change logic from Document to AuthorStyleSheets

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (206311 => 206312)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-09-23 17:15:03 UTC (rev 206312)
@@ -6197,7 +6197,7 @@
 		E461802D1C8DD2900026C02C /* StyleRelations.h in Headers */ = {isa = PBXBuildFile; fileRef = E461802C1C8DD2900026C02C /* StyleRelations.h */; };
 		E461802F1C8DD4D20026C02C /* StyleRelations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461802E1C8DD4D20026C02C /* StyleRelations.cpp */; };
 		E461D65D1BB0C7F000CB5645 /* AuthorStyleSheets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461D65C1BB0C7F000CB5645 /* AuthorStyleSheets.cpp */; };
-		E461D65F1BB0C80D00CB5645 /* AuthorStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = E461D65E1BB0C80D00CB5645 /* AuthorStyleSheets.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		E461D65F1BB0C80D00CB5645 /* AuthorStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = E461D65E1BB0C80D00CB5645 /* AuthorStyleSheets.h */; };
 		E462A4A1113E71BE004A4220 /* IntPointHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E462A4A0113E71BE004A4220 /* IntPointHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E46A2B1E17CA76B1000DBCD8 /* ElementChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };

Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (206311 => 206312)


--- trunk/Source/WebCore/css/CSSStyleSheet.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -179,11 +179,11 @@
                 resolver->addKeyframeStyle(*insertedKeyframesRule);
             return;
         }
-        owner->authorStyleSheets().scheduleOptimizedUpdate();
+        owner->scheduleOptimizedStyleSheetUpdate();
         return;
     }
 
-    owner->authorStyleSheets().didChange(DeferRecalcStyle);
+    owner->styleResolverChanged(DeferRecalcStyle);
 
     m_mutatedRules = true;
 }
@@ -193,7 +193,7 @@
     Document* owner = ownerDocument();
     if (!owner)
         return;
-    owner->authorStyleSheets().didChange(DeferRecalcStyle);
+    owner->styleResolverChanged(DeferRecalcStyle);
 }
 
 void CSSStyleSheet::clearOwnerNode()
@@ -202,7 +202,7 @@
     m_ownerNode = 0;
     if (!owner)
         return;
-    owner->authorStyleSheets().didChange(DeferRecalcStyleIfNeeded);
+    owner->styleResolverChanged(DeferRecalcStyleIfNeeded);
 }
 
 void CSSStyleSheet::reattachChildRuleCSSOMWrappers()

Modified: trunk/Source/WebCore/dom/AuthorStyleSheets.cpp (206311 => 206312)


--- trunk/Source/WebCore/dom/AuthorStyleSheets.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -57,7 +57,6 @@
 
 AuthorStyleSheets::AuthorStyleSheets(Document& document)
     : m_document(document)
-    , m_optimizedUpdateTimer(*this, &AuthorStyleSheets::optimizedUpdateTimerFired)
 {
 }
 
@@ -64,7 +63,6 @@
 AuthorStyleSheets::AuthorStyleSheets(ShadowRoot& shadowRoot)
     : m_document(shadowRoot.documentScope())
     , m_shadowRoot(&shadowRoot)
-    , m_optimizedUpdateTimer(*this, &AuthorStyleSheets::optimizedUpdateTimerFired)
 {
 }
 
@@ -386,64 +384,4 @@
     return m_weakCopyOfActiveStyleSheetListForFastLookup->contains(sheet);
 }
 
-void AuthorStyleSheets::flushPendingUpdates()
-{
-    if (m_pendingUpdateType == NoUpdate)
-        return;
-    updateActiveStyleSheets(m_pendingUpdateType);
 }
-
-void AuthorStyleSheets::scheduleOptimizedUpdate()
-{
-    if (m_optimizedUpdateTimer.isActive())
-        return;
-    if (m_pendingUpdateType == NoUpdate)
-        m_pendingUpdateType = OptimizedUpdate;
-    m_optimizedUpdateTimer.startOneShot(0);
-}
-
-void AuthorStyleSheets::didChange(StyleResolverUpdateFlag updateFlag)
-{
-    m_optimizedUpdateTimer.stop();
-
-    // Don't bother updating, since we haven't loaded all our style info yet
-    // and haven't calculated the style resolver for the first time.
-    if (!m_document.hasLivingRenderTree() || (!m_shadowRoot && !m_didCalculateStyleResolver && m_pendingStyleSheetCount)) {
-        m_document.clearStyleResolver();
-        return;
-    }
-    m_didCalculateStyleResolver = true;
-
-    auto styleSheetUpdate = (updateFlag == RecalcStyleIfNeeded || updateFlag == DeferRecalcStyleIfNeeded)
-        ? AuthorStyleSheets::OptimizedUpdate
-        : AuthorStyleSheets::FullUpdate;
-    bool stylesheetChangeRequiresStyleRecalc = updateActiveStyleSheets(styleSheetUpdate);
-
-    auto scheduleStyleRecalc = [&] {
-        if (m_shadowRoot)
-            m_shadowRoot->setNeedsStyleRecalc();
-        else
-            m_document.scheduleForcedStyleRecalc();
-    };
-
-    if (updateFlag == DeferRecalcStyle) {
-        scheduleStyleRecalc();
-        return;
-    }
-
-    if (updateFlag == DeferRecalcStyleIfNeeded) {
-        if (stylesheetChangeRequiresStyleRecalc)
-            scheduleStyleRecalc();
-        return;
-    }
-
-    if (stylesheetChangeRequiresStyleRecalc)
-        m_document.recalcStyle(Style::Force);
-}
-
-void AuthorStyleSheets::optimizedUpdateTimerFired()
-{
-    didChange(RecalcStyleIfNeeded);
-}
-
-}

Modified: trunk/Source/WebCore/dom/AuthorStyleSheets.h (206311 => 206312)


--- trunk/Source/WebCore/dom/AuthorStyleSheets.h	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.h	2016-09-23 17:15:03 UTC (rev 206312)
@@ -48,13 +48,6 @@
 class ShadowRoot;
 class TreeScope;
 
-enum StyleResolverUpdateFlag {
-    RecalcStyleImmediately,
-    DeferRecalcStyle,
-    RecalcStyleIfNeeded,
-    DeferRecalcStyleIfNeeded
-};
-
 class AuthorStyleSheets {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -69,8 +62,23 @@
     void addStyleSheetCandidateNode(Node&, bool createdByParser);
     void removeStyleSheetCandidateNode(Node&);
 
-    WEBCORE_EXPORT void didChange(StyleResolverUpdateFlag);
+    enum UpdateFlag { NoUpdate = 0, OptimizedUpdate, FullUpdate };
 
+    UpdateFlag pendingUpdateType() const { return m_pendingUpdateType; }
+    void setPendingUpdateType(UpdateFlag updateType)
+    {
+        if (updateType > m_pendingUpdateType)
+            m_pendingUpdateType = updateType;
+    }
+
+    void flushPendingUpdates()
+    {
+        if (m_pendingUpdateType != NoUpdate)
+            updateActiveStyleSheets(m_pendingUpdateType);
+    }
+
+    bool updateActiveStyleSheets(UpdateFlag);
+
     String preferredStylesheetSetName() const { return m_preferredStylesheetSetName; }
     String selectedStylesheetSetName() const { return m_selectedStylesheetSetName; }
     void setPreferredStylesheetSetName(const String& name) { m_preferredStylesheetSetName = name; }
@@ -91,16 +99,8 @@
 
     bool activeStyleSheetsContains(const CSSStyleSheet*) const;
 
-    void scheduleOptimizedUpdate();
-    bool hasPendingUpdate() const { return m_optimizedUpdateTimer.isActive(); }
-    void flushPendingUpdates();
-
 private:
-    enum UpdateFlag { NoUpdate = 0, OptimizedUpdate, FullUpdate };
-    bool updateActiveStyleSheets(UpdateFlag);
-
     void collectActiveStyleSheets(Vector<RefPtr<StyleSheet>>&);
-
     enum StyleResolverUpdateType {
         Reconstruct,
         Reset,
@@ -109,8 +109,6 @@
     StyleResolverUpdateType analyzeStyleSheetChange(UpdateFlag, const Vector<RefPtr<CSSStyleSheet>>& newStylesheets, bool& requiresFullStyleRecalc);
     void updateStyleResolver(Vector<RefPtr<CSSStyleSheet>>&, StyleResolverUpdateType);
 
-    void optimizedUpdateTimerFired();
-
     Document& m_document;
     ShadowRoot* m_shadowRoot { nullptr };
 
@@ -117,8 +115,6 @@
     Vector<RefPtr<StyleSheet>> m_styleSheetsForStyleSheetList;
     Vector<RefPtr<CSSStyleSheet>> m_activeStyleSheets;
 
-    Timer m_optimizedUpdateTimer;
-
     // This is a mirror of m_activeAuthorStyleSheets that gets populated on demand for activeStyleSheetsContains().
     mutable std::unique_ptr<HashSet<const CSSStyleSheet*>> m_weakCopyOfActiveStyleSheetListForFastLookup;
 
@@ -127,7 +123,6 @@
     // We use this count of pending sheets to detect when we can begin attaching
     // elements and when it is safe to execute scripts.
     int m_pendingStyleSheetCount { 0 };
-    bool m_didCalculateStyleResolver { false };
 
     UpdateFlag m_pendingUpdateType { NoUpdate };
 

Modified: trunk/Source/WebCore/dom/Document.cpp (206311 => 206312)


--- trunk/Source/WebCore/dom/Document.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -435,6 +435,7 @@
     , m_touchEventsChangedTimer(*this, &Document::touchEventsChangedTimerFired)
 #endif
     , m_referencingNodeCount(0)
+    , m_didCalculateStyleResolver(false)
     , m_hasNodesWithPlaceholderStyle(false)
     , m_needsNotifyRemoveAllPendingStylesheet(false)
     , m_ignorePendingStylesheets(false)
@@ -457,6 +458,7 @@
     , m_visuallyOrdered(false)
     , m_readyState(Complete)
     , m_bParsing(false)
+    , m_optimizedStyleSheetUpdateTimer(*this, &Document::optimizedStyleSheetUpdateTimerFired)
     , m_styleRecalcTimer(*this, &Document::updateStyleIfNeeded)
     , m_pendingStyleRecalcShouldForce(false)
     , m_inStyleRecalc(false)
@@ -1355,7 +1357,7 @@
     m_contentLanguage = language;
 
     // Recalculate style so language is used when selecting the initial font.
-    m_authorStyleSheets->didChange(DeferRecalcStyle);
+    styleResolverChanged(DeferRecalcStyle);
 }
 
 void Document::setXMLVersion(const String& version, ExceptionCode& ec)
@@ -1943,14 +1945,6 @@
         frameView.frame().mainFrame().eventHandler().dispatchFakeMouseMoveEventSoon();
 }
 
-bool Document::needsStyleRecalc() const
-{
-    if (pageCacheState() != NotInPageCache)
-        return false;
-
-    return m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || authorStyleSheets().hasPendingUpdate();
-}
-
 void Document::updateStyleIfNeeded()
 {
     ASSERT(isMainThread());
@@ -1959,8 +1953,8 @@
     if (!view() || view()->isInRenderTreeLayout())
         return;
 
-    if (authorStyleSheets().hasPendingUpdate())
-        authorStyleSheets().didChange(RecalcStyleIfNeeded);
+    if (m_optimizedStyleSheetUpdateTimer.isActive())
+        styleResolverChanged(RecalcStyleIfNeeded);
 
     if (!needsStyleRecalc())
         return;
@@ -2014,7 +2008,7 @@
         HTMLElement* bodyElement = bodyOrFrameset();
         if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == NoLayoutWithPendingSheets) {
             m_pendingSheetLayout = DidLayoutWithPendingSheets;
-            authorStyleSheets().didChange(RecalcStyleImmediately);
+            styleResolverChanged(RecalcStyleImmediately);
         } else if (m_hasNodesWithPlaceholderStyle)
             // If new nodes have been added or style recalc has been done with style sheets still pending, some nodes 
             // may not have had their real style calculated yet. Normally this gets cleaned when style sheets arrive 
@@ -3151,7 +3145,7 @@
 {
     m_needsNotifyRemoveAllPendingStylesheet = false;
 
-    authorStyleSheets().didChange(DeferRecalcStyleIfNeeded);
+    styleResolverChanged(DeferRecalcStyleIfNeeded);
 
     if (m_pendingSheetLayout == DidLayoutWithPendingSheets) {
         m_pendingSheetLayout = IgnoreLayoutWithPendingSheets;
@@ -3226,7 +3220,7 @@
         // -dwh
         authorStyleSheets().setSelectedStylesheetSetName(content);
         authorStyleSheets().setPreferredStylesheetSetName(content);
-        authorStyleSheets().didChange(DeferRecalcStyle);
+        styleResolverChanged(DeferRecalcStyle);
         break;
 
     case HTTPHeaderName::Refresh: {
@@ -3530,7 +3524,7 @@
 void Document::setSelectedStylesheetSet(const String& aString)
 {
     authorStyleSheets().setSelectedStylesheetSetName(aString);
-    authorStyleSheets().didChange(DeferRecalcStyle);
+    styleResolverChanged(DeferRecalcStyle);
 }
 
 void Document::evaluateMediaQueryList()
@@ -3553,6 +3547,19 @@
         picture->sourcesChanged();
 }
 
+void Document::optimizedStyleSheetUpdateTimerFired()
+{
+    styleResolverChanged(RecalcStyleIfNeeded);
+}
+
+void Document::scheduleOptimizedStyleSheetUpdate()
+{
+    if (m_optimizedStyleSheetUpdateTimer.isActive())
+        return;
+    authorStyleSheets().setPendingUpdateType(AuthorStyleSheets::OptimizedUpdate);
+    m_optimizedStyleSheetUpdateTimer.startOneShot(0);
+}
+
 void Document::updateViewportUnitsOnResize()
 {
     if (!hasStyleWithViewportUnits())
@@ -3617,6 +3624,39 @@
         audioProducer->pageMutedStateDidChange();
 }
 
+void Document::styleResolverChanged(StyleResolverUpdateFlag updateFlag)
+{
+    if (m_optimizedStyleSheetUpdateTimer.isActive())
+        m_optimizedStyleSheetUpdateTimer.stop();
+
+    // Don't bother updating, since we haven't loaded all our style info yet
+    // and haven't calculated the style selector for the first time.
+    if (!hasLivingRenderTree() || (!m_didCalculateStyleResolver && !haveStylesheetsLoaded())) {
+        m_styleResolver = nullptr;
+        return;
+    }
+    m_didCalculateStyleResolver = true;
+
+    auto styleSheetUpdate = (updateFlag == RecalcStyleIfNeeded || updateFlag == DeferRecalcStyleIfNeeded)
+        ? AuthorStyleSheets::OptimizedUpdate
+        : AuthorStyleSheets::FullUpdate;
+    bool stylesheetChangeRequiresStyleRecalc = authorStyleSheets().updateActiveStyleSheets(styleSheetUpdate);
+
+    if (updateFlag == DeferRecalcStyle) {
+        scheduleForcedStyleRecalc();
+        return;
+    }
+
+    if (updateFlag == DeferRecalcStyleIfNeeded) {
+        if (stylesheetChangeRequiresStyleRecalc)
+            scheduleForcedStyleRecalc();
+        return;
+    }
+
+    if (stylesheetChangeRequiresStyleRecalc)
+        recalcStyle(Style::Force);
+}
+
 static bool isNodeInSubtree(Node* node, Node* container, bool amongChildrenOnly)
 {
     bool nodeInSubtree = false;
@@ -6605,7 +6645,7 @@
     return nullptr;
 }
 
-void Document::updateHoverActiveState(const HitTestRequest& request, Element* innerElement)
+void Document::updateHoverActiveState(const HitTestRequest& request, Element* innerElement, StyleResolverUpdateFlag updateFlag)
 {
     ASSERT(!request.readOnly());
 
@@ -6722,7 +6762,9 @@
         }
     }
 
-    updateStyleIfNeeded();
+    ASSERT(updateFlag == RecalcStyleIfNeeded || updateFlag == DeferRecalcStyleIfNeeded);
+    if (updateFlag == RecalcStyleIfNeeded)
+        updateStyleIfNeeded();
 }
 
 bool Document::haveStylesheetsLoaded() const

Modified: trunk/Source/WebCore/dom/Document.h (206311 => 206312)


--- trunk/Source/WebCore/dom/Document.h	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/dom/Document.h	2016-09-23 17:15:03 UTC (rev 206312)
@@ -231,6 +231,8 @@
     PageshowEventPersisted = 1
 };
 
+enum StyleResolverUpdateFlag { RecalcStyleImmediately, DeferRecalcStyle, RecalcStyleIfNeeded, DeferRecalcStyleIfNeeded };
+
 enum NodeListInvalidationType {
     DoNotInvalidateOnAttributeChanges = 0,
     InvalidateOnClassAttrChange,
@@ -515,6 +517,19 @@
     bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
     void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
 
+    /**
+     * Called when one or more stylesheets in the document may have been added, removed or changed.
+     *
+     * Creates a new style resolver and assign it to this document. This is done by iterating through all nodes in
+     * document (or those before <BODY> in a HTML document), searching for stylesheets. Stylesheets can be contained in
+     * <LINK>, <STYLE> or <BODY> elements, as well as processing instructions (XML documents only). A list is
+     * constructed from these which is used to create the a new style selector which collates all of the stylesheets
+     * found and is used to calculate the derived styles for all rendering objects.
+     */
+    WEBCORE_EXPORT void styleResolverChanged(StyleResolverUpdateFlag);
+
+    void scheduleOptimizedStyleSheetUpdate();
+
     void evaluateMediaQueryList();
 
     FormController& formController();
@@ -542,7 +557,7 @@
 
     void recalcStyle(Style::Change = Style::NoChange);
     WEBCORE_EXPORT void updateStyleIfNeeded();
-    bool needsStyleRecalc() const;
+    bool needsStyleRecalc() const { return pageCacheState() == NotInPageCache && (m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || m_optimizedStyleSheetUpdateTimer.isActive()); }
 
     WEBCORE_EXPORT void updateLayout();
     
@@ -721,7 +736,7 @@
     void hoveredElementDidDetach(Element*);
     void elementInActiveChainDidDetach(Element*);
 
-    void updateHoverActiveState(const HitTestRequest&, Element*);
+    void updateHoverActiveState(const HitTestRequest&, Element*, StyleResolverUpdateFlag = RecalcStyleIfNeeded);
 
     // Updates for :target (CSS3 selector).
     void setCSSTarget(Element*);
@@ -733,6 +748,7 @@
     void unscheduleStyleRecalc();
     bool hasPendingStyleRecalc() const;
     bool hasPendingForcedStyleRecalc() const;
+    void optimizedStyleSheetUpdateTimerFired();
 
     void registerNodeListForInvalidation(LiveNodeList&);
     void unregisterNodeListForInvalidation(LiveNodeList&);
@@ -1398,6 +1414,7 @@
 
     std::unique_ptr<StyleResolver> m_styleResolver;
     std::unique_ptr<StyleResolver> m_userAgentShadowTreeStyleResolver;
+    bool m_didCalculateStyleResolver;
     bool m_hasNodesWithPlaceholderStyle;
     bool m_needsNotifyRemoveAllPendingStylesheet;
     // But sometimes you need to ignore pending stylesheet count to
@@ -1485,6 +1502,7 @@
     ReadyState m_readyState;
     bool m_bParsing;
 
+    Timer m_optimizedStyleSheetUpdateTimer;
     Timer m_styleRecalcTimer;
     bool m_pendingStyleRecalcShouldForce;
     bool m_inStyleRecalc;

Modified: trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp (206311 => 206312)


--- trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -28,7 +28,6 @@
 #include "config.h"
 #include "ExtensionStyleSheets.h"
 
-#include "AuthorStyleSheets.h"
 #include "CSSStyleSheet.h"
 #include "Element.h"
 #include "HTMLIFrameElement.h"
@@ -83,7 +82,7 @@
 {
     if (m_pageUserSheet) {
         m_pageUserSheet = nullptr;
-        m_document.authorStyleSheets().didChange(DeferRecalcStyle);
+        m_document.styleResolverChanged(DeferRecalcStyle);
     }
 }
 
@@ -91,7 +90,7 @@
 {
     clearPageUserSheet();
     if (pageUserSheet())
-        m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
+        m_document.styleResolverChanged(RecalcStyleImmediately);
 }
 
 const Vector<RefPtr<CSSStyleSheet>>& ExtensionStyleSheets::injectedUserStyleSheets() const
@@ -155,7 +154,7 @@
     m_injectedStyleSheetCacheValid = false;
     if (m_injectedUserStyleSheets.isEmpty() && m_injectedAuthorStyleSheets.isEmpty())
         return;
-    m_document.authorStyleSheets().didChange(DeferRecalcStyle);
+    m_document.styleResolverChanged(DeferRecalcStyle);
 }
 
 void ExtensionStyleSheets::addUserStyleSheet(Ref<StyleSheetContents>&& userSheet)
@@ -162,7 +161,7 @@
 {
     ASSERT(userSheet.get().isUserStyleSheet());
     m_userStyleSheets.append(CSSStyleSheet::create(WTFMove(userSheet), m_document));
-    m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
+    m_document.styleResolverChanged(RecalcStyleImmediately);
 }
 
 void ExtensionStyleSheets::addAuthorStyleSheetForTesting(Ref<StyleSheetContents>&& authorSheet)
@@ -169,7 +168,7 @@
 {
     ASSERT(!authorSheet.get().isUserStyleSheet());
     m_authorStyleSheetsForTesting.append(CSSStyleSheet::create(WTFMove(authorSheet), m_document));
-    m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
+    m_document.styleResolverChanged(RecalcStyleImmediately);
 }
 
 #if ENABLE(CONTENT_EXTENSIONS)
@@ -201,7 +200,7 @@
 
 void ExtensionStyleSheets::styleResolverChangedTimerFired()
 {
-    m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
+    m_document.styleResolverChanged(RecalcStyleImmediately);
 }
 
 void ExtensionStyleSheets::detachFromDocument()

Modified: trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp (206311 => 206312)


--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -73,7 +73,7 @@
 
     // If we're in document teardown, then we don't need to do any notification of our sheet's removal.
     if (document.hasLivingRenderTree())
-        document.authorStyleSheets().didChange(DeferRecalcStyle);
+        document.styleResolverChanged(DeferRecalcStyle);
 }
 
 void InlineStyleSheetOwner::clearDocumentData(Document&, Element& element)

Modified: trunk/Source/WebCore/dom/ProcessingInstruction.cpp (206311 => 206312)


--- trunk/Source/WebCore/dom/ProcessingInstruction.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/dom/ProcessingInstruction.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -268,17 +268,11 @@
         ASSERT(m_sheet->ownerNode() == this);
         m_sheet->clearOwnerNode();
         m_sheet = nullptr;
-
     }
 
-    if (m_loading) {
-        m_loading = false;
-        document().authorStyleSheets().removePendingSheet();
-    }
-
     // If we're in document teardown, then we don't need to do any notification of our sheet's removal.
     if (document().hasLivingRenderTree())
-        document().authorStyleSheets().didChange(DeferRecalcStyle);
+        document().styleResolverChanged(DeferRecalcStyle);
 }
 
 void ProcessingInstruction::finishParsingChildren()

Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (206311 => 206312)


--- trunk/Source/WebCore/dom/ShadowRoot.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -108,10 +108,15 @@
 
 void ShadowRoot::updateStyle()
 {
-    if (!m_authorStyleSheets)
-        return;
-    // FIXME: Make optimized updated work.
-    m_authorStyleSheets->didChange(DeferRecalcStyle);
+    bool shouldRecalcStyle = false;
+
+    if (m_authorStyleSheets) {
+        // FIXME: Make optimized updated work.
+        shouldRecalcStyle = m_authorStyleSheets->updateActiveStyleSheets(AuthorStyleSheets::FullUpdate);
+    }
+
+    if (shouldRecalcStyle)
+        setNeedsStyleRecalc();
 }
 
 String ShadowRoot::innerHTML() const

Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (206311 => 206312)


--- trunk/Source/WebCore/html/HTMLLinkElement.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -140,7 +140,7 @@
         if (!m_sheet && m_disabledState == EnabledViaScript)
             process();
         else
-            document().authorStyleSheets().didChange(DeferRecalcStyle);
+            document().styleResolverChanged(DeferRecalcStyle); // Update the style selector.
     }
 }
 
@@ -176,7 +176,7 @@
         m_media = value.string().convertToASCIILowercase();
         process();
         if (m_sheet && !isDisabled())
-            document().authorStyleSheets().didChange(DeferRecalcStyle);
+            document().styleResolverChanged(DeferRecalcStyle);
         return;
     }
     if (name == disabledAttr) {
@@ -283,7 +283,7 @@
     } else if (m_sheet) {
         // we no longer contain a stylesheet, e.g. perhaps rel or type was changed
         clearSheet();
-        document().authorStyleSheets().didChange(DeferRecalcStyle);
+        document().styleResolverChanged(DeferRecalcStyle);
     }
 }
 
@@ -330,7 +330,7 @@
         removePendingSheet(RemovePendingSheetNotifyLater);
 
     if (document().hasLivingRenderTree())
-        document().authorStyleSheets().didChange(DeferRecalcStyleIfNeeded);
+        document().styleResolverChanged(DeferRecalcStyleIfNeeded);
 }
 
 void HTMLLinkElement::finishParsingChildren()
@@ -555,7 +555,7 @@
 
     if (type == InactiveSheet) {
         // Document just needs to know about the sheet for exposure through document.styleSheets
-        document().authorStyleSheets().didChange(DeferRecalcStyleIfNeeded);
+        document().authorStyleSheets().updateActiveStyleSheets(AuthorStyleSheets::OptimizedUpdate);
         return;
     }
 

Modified: trunk/Source/WebCore/html/HTMLStyleElement.cpp (206311 => 206312)


--- trunk/Source/WebCore/html/HTMLStyleElement.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/html/HTMLStyleElement.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -24,7 +24,6 @@
 #include "config.h"
 #include "HTMLStyleElement.h"
 
-#include "AuthorStyleSheets.h"
 #include "Document.h"
 #include "Event.h"
 #include "EventNames.h"
@@ -78,7 +77,7 @@
         if (sheet()) {
             sheet()->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(value));
             if (inDocument() && document().hasLivingRenderTree())
-                document().authorStyleSheets().didChange(RecalcStyleImmediately);
+                document().styleResolverChanged(RecalcStyleImmediately);
         }
     } else if (name == typeAttr)
         m_styleSheetOwner.setContentType(value);

Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (206311 => 206312)


--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -889,7 +889,7 @@
         m_nodeIdToForcedPseudoState.set(nodeId, forcedPseudoState);
     else
         m_nodeIdToForcedPseudoState.remove(nodeId);
-    element->document().authorStyleSheets().didChange(RecalcStyleImmediately);
+    element->document().styleResolverChanged(RecalcStyleImmediately);
 }
 
 void InspectorCSSAgent::getNamedFlowCollection(ErrorString& errorString, int documentNodeId, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::NamedFlow>>& result)
@@ -1189,7 +1189,7 @@
 
     m_nodeIdToForcedPseudoState.clear();
     for (auto& document : documentsToChange)
-        document->authorStyleSheets().didChange(RecalcStyleImmediately);
+        document->styleResolverChanged(RecalcStyleImmediately);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (206311 => 206312)


--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -32,7 +32,6 @@
 #include "config.h"
 #include "InspectorPageAgent.h"
 
-#include "AuthorStyleSheets.h"
 #include "CachedCSSStyleSheet.h"
 #include "CachedFont.h"
 #include "CachedImage.h"
@@ -1002,7 +1001,7 @@
     m_emulatedMedia = media;
     Document* document = m_page.mainFrame().document();
     if (document) {
-        document->authorStyleSheets().didChange(RecalcStyleImmediately);
+        document->styleResolverChanged(RecalcStyleImmediately);
         document->updateLayout();
     }
 }

Modified: trunk/Source/WebCore/page/Frame.cpp (206311 => 206312)


--- trunk/Source/WebCore/page/Frame.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/page/Frame.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -32,7 +32,6 @@
 
 #include "AnimationController.h"
 #include "ApplyStyleCommand.h"
-#include "AuthorStyleSheets.h"
 #include "BackForwardController.h"
 #include "CSSComputedStyleDeclaration.h"
 #include "CSSPropertyNames.h"
@@ -644,7 +643,7 @@
     m_doc->setPrinting(printing);
     view()->adjustMediaTypeForPrinting(printing);
 
-    m_doc->authorStyleSheets().didChange(RecalcStyleImmediately);
+    m_doc->styleResolverChanged(RecalcStyleImmediately);
     if (shouldUsePrintingLayout()) {
         view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShrinkRatio, shouldAdjustViewSize);
     } else {

Modified: trunk/Source/WebCore/page/FrameView.cpp (206311 => 206312)


--- trunk/Source/WebCore/page/FrameView.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/page/FrameView.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -29,7 +29,6 @@
 
 #include "AXObjectCache.h"
 #include "AnimationController.h"
-#include "AuthorStyleSheets.h"
 #include "BackForwardController.h"
 #include "CachedImage.h"
 #include "CachedResourceLoader.h"
@@ -1301,7 +1300,7 @@
         StyleResolver* styleResolver = document.styleResolverIfExists();
         if (!styleResolver || styleResolver->hasMediaQueriesAffectedByViewportChange()) {
             LOG(Layout, "  hasMediaQueriesAffectedByViewportChange, enqueueing style recalc");
-            document.authorStyleSheets().didChange(DeferRecalcStyle);
+            document.styleResolverChanged(DeferRecalcStyle);
             // FIXME: This instrumentation event is not strictly accurate since cached media query results do not persist across StyleResolver rebuilds.
             InspectorInstrumentation::mediaQueryResultChanged(document);
         } else
@@ -3496,7 +3495,7 @@
 
     m_pagination = pagination;
 
-    frame().document()->authorStyleSheets().didChange(DeferRecalcStyle);
+    frame().document()->styleResolverChanged(DeferRecalcStyle);
 }
 
 IntRect FrameView::windowClipRect() const
@@ -4965,7 +4964,7 @@
     if (Document* document = frame().document()) {
         // FIXME: this should probably be updateViewportUnitsOnResize(), but synchronously
         // dirtying style here causes assertions on iOS (rdar://problem/19998166).
-        document->authorStyleSheets().didChange(DeferRecalcStyle);
+        document->styleResolverChanged(DeferRecalcStyle);
     }
 }
     

Modified: trunk/Source/WebCore/page/Page.cpp (206311 => 206312)


--- trunk/Source/WebCore/page/Page.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/page/Page.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -23,7 +23,6 @@
 #include "AlternativeTextClient.h"
 #include "AnimationController.h"
 #include "ApplicationCacheStorage.h"
-#include "AuthorStyleSheets.h"
 #include "BackForwardClient.h"
 #include "BackForwardController.h"
 #include "Chrome.h"
@@ -423,7 +422,7 @@
         m_mainFrame->view()->forceLayout();
 
     if (m_mainFrame->document())
-        m_mainFrame->document()->authorStyleSheets().didChange(RecalcStyleImmediately);
+        m_mainFrame->document()->styleResolverChanged(RecalcStyleImmediately);
 }
 #endif // ENABLE(VIEW_MODE_CSS_MEDIA)
 
@@ -501,7 +500,7 @@
 {
     for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
         if (Document* document = frame->document())
-            document->authorStyleSheets().didChange(DeferRecalcStyle);
+            document->styleResolverChanged(DeferRecalcStyle);
     }
 }
 
@@ -1162,7 +1161,7 @@
         if (!document)
             continue;
         document->extensionStyleSheets().invalidateInjectedStyleSheetCache();
-        document->authorStyleSheets().didChange(DeferRecalcStyle);
+        document->styleResolverChanged(DeferRecalcStyle);
     }
 }
 

Modified: trunk/Source/WebCore/svg/SVGFontFaceElement.cpp (206311 => 206312)


--- trunk/Source/WebCore/svg/SVGFontFaceElement.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/svg/SVGFontFaceElement.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -24,7 +24,6 @@
 #if ENABLE(SVG_FONTS)
 #include "SVGFontFaceElement.h"
 
-#include "AuthorStyleSheets.h"
 #include "CSSFontFaceSrcValue.h"
 #include "CSSParser.h"
 #include "CSSPropertyNames.h"
@@ -267,7 +266,7 @@
         }
     }
 
-    document().authorStyleSheets().didChange(DeferRecalcStyle);
+    document().styleResolverChanged(DeferRecalcStyle);
 }
 
 Node::InsertionNotificationRequest SVGFontFaceElement::insertedInto(ContainerNode& rootParent)
@@ -292,7 +291,7 @@
         document().accessSVGExtensions().unregisterSVGFontFaceElement(this);
         m_fontFaceRule->mutableProperties().clear();
 
-        document().authorStyleSheets().didChange(DeferRecalcStyle);
+        document().styleResolverChanged(DeferRecalcStyle);
     } else
         ASSERT(!m_fontElement);
 }

Modified: trunk/Source/WebCore/xml/XMLTreeViewer.cpp (206311 => 206312)


--- trunk/Source/WebCore/xml/XMLTreeViewer.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/xml/XMLTreeViewer.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -32,7 +32,6 @@
 
 #if ENABLE(XSLT)
 
-#include "AuthorStyleSheets.h"
 #include "Document.h"
 #include "Element.h"
 #include "ExceptionCodePlaceholder.h"
@@ -64,7 +63,7 @@
     String cssString = StringImpl::createWithoutCopying(XMLViewer_css, sizeof(XMLViewer_css));
     auto text = m_document.createTextNode(cssString);
     m_document.getElementById(String(ASCIILiteral("xml-viewer-style")))->appendChild(text, IGNORE_EXCEPTION);
-    m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
+    m_document.styleResolverChanged(RecalcStyleImmediately);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp (206311 => 206312)


--- trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -26,7 +26,6 @@
 #include "config.h"
 #include "XMLDocumentParser.h"
 
-#include "AuthorStyleSheets.h"
 #include "CDATASection.h"
 #include "CachedScript.h"
 #include "Comment.h"
@@ -200,7 +199,7 @@
         insertErrorMessageBlock();
     else {
         updateLeafTextNode();
-        document()->authorStyleSheets().didChange(RecalcStyleImmediately);
+        document()->styleResolverChanged(RecalcStyleImmediately);
     }
 
     if (isParsing())

Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (206311 => 206312)


--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp	2016-09-23 17:15:03 UTC (rev 206312)
@@ -28,7 +28,6 @@
 #include "config.h"
 #include "XMLDocumentParser.h"
 
-#include "AuthorStyleSheets.h"
 #include "CDATASection.h"
 #include "CachedScript.h"
 #include "Comment.h"
@@ -1387,7 +1386,7 @@
         document()->setTransformSource(std::make_unique<TransformSource>(doc));
 
         document()->setParsing(false); // Make the document think it's done, so it will apply XSL stylesheets.
-        document()->authorStyleSheets().didChange(RecalcStyleImmediately);
+        document()->styleResolverChanged(RecalcStyleImmediately);
 
         // styleResolverChanged() call can detach the parser and null out its document.
         // In that case, we just bail out.

Modified: trunk/Source/WebKit/mac/ChangeLog (206311 => 206312)


--- trunk/Source/WebKit/mac/ChangeLog	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-09-23 17:15:03 UTC (rev 206312)
@@ -1,3 +1,17 @@
+2016-09-23  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r206311.
+        https://bugs.webkit.org/show_bug.cgi?id=162495
+
+        Broke internal iOS build (Requested by anttik on #webkit).
+
+        Reverted changeset:
+
+        "Move stylesheet change logic from Document to
+        AuthorStyleSheets"
+        https://bugs.webkit.org/show_bug.cgi?id=162488
+        http://trac.webkit.org/changeset/206311
+
 2016-09-23  Antoine Quint  <[email protected]>
 
         Add a new runtime flag for work on modern media controls (off by default)

Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (206311 => 206312)


--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2016-09-23 16:35:04 UTC (rev 206311)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2016-09-23 17:15:03 UTC (rev 206312)
@@ -72,7 +72,6 @@
 #import "WebTypesInternal.h"
 #import "WebUIDelegatePrivate.h"
 #import "WebViewInternal.h"
-#import <WebCore/AuthorStyleSheets.h>
 #import <WebCore/CSSStyleDeclaration.h>
 #import <WebCore/CachedImage.h>
 #import <WebCore/CachedResourceClient.h>
@@ -3612,7 +3611,7 @@
 #endif
 
     if (Frame* coreFrame = core([self _frame]))
-        coreFrame->document()->authorStyleSheets().didChange(RecalcStyleImmediately);
+        coreFrame->document()->styleResolverChanged(RecalcStyleImmediately);
     
 #ifdef LOG_TIMES        
     double thisTime = CFAbsoluteTimeGetCurrent() - start;
@@ -5005,7 +5004,7 @@
 
             document->setPaginatedForScreen(_private->paginateScreenContent);
             document->setPrinting(_private->printing);
-            document->authorStyleSheets().didChange(RecalcStyleImmediately);
+            document->styleResolverChanged(RecalcStyleImmediately);
         }
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to