Rename recalcStyle to resolveStyle and clean up the signature
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Mar 2017 06:19:04 +0000 (06:19 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Mar 2017 06:19:04 +0000 (06:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169049

Reviewed by Sam Weinig.

Move to modern naming.

* dom/Document.cpp:
(WebCore::Document::resolveStyle):

    Only two of the possible values are used so pass in a two-value enum.

(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::updateLayoutIgnorePendingStylesheets):
(WebCore::Document::createRenderTree):
(WebCore::Document::finishedParsing):
(WebCore::Document::webkitWillEnterFullScreenForElement):
(WebCore::Document::recalcStyle): Deleted.
* dom/Document.h:
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::update):
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::reportDataReceived):
* page/Frame.cpp:
(WebCore::Frame::setPageAndTextZoomFactors):
* page/Page.cpp:
(WebCore::Page::setPageScaleFactor):
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::Parent::Parent):
(WebCore::Style::TreeResolver::resolve):

    Remove the argument, Document invalidates the document element if everything needs to be re-resolved.

* style/StyleTreeResolver.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213266 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/loader/DocumentWriter.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/style/StyleTreeResolver.cpp
Source/WebCore/style/StyleTreeResolver.h

index 44ed42e..dd50e66 100644 (file)
@@ -1,3 +1,40 @@
+2017-03-01  Antti Koivisto  <antti@apple.com>
+
+        Rename recalcStyle to resolveStyle and clean up the signature
+        https://bugs.webkit.org/show_bug.cgi?id=169049
+
+        Reviewed by Sam Weinig.
+
+        Move to modern naming.
+
+        * dom/Document.cpp:
+        (WebCore::Document::resolveStyle):
+
+            Only two of the possible values are used so pass in a two-value enum.
+
+        (WebCore::Document::updateStyleIfNeeded):
+        (WebCore::Document::updateLayoutIgnorePendingStylesheets):
+        (WebCore::Document::createRenderTree):
+        (WebCore::Document::finishedParsing):
+        (WebCore::Document::webkitWillEnterFullScreenForElement):
+        (WebCore::Document::recalcStyle): Deleted.
+        * dom/Document.h:
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::InspectorOverlay::update):
+        * loader/DocumentWriter.cpp:
+        (WebCore::DocumentWriter::reportDataReceived):
+        * page/Frame.cpp:
+        (WebCore::Frame::setPageAndTextZoomFactors):
+        * page/Page.cpp:
+        (WebCore::Page::setPageScaleFactor):
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::Parent::Parent):
+        (WebCore::Style::TreeResolver::resolve):
+
+            Remove the argument, Document invalidates the document element if everything needs to be re-resolved.
+
+        * style/StyleTreeResolver.h:
+
 2017-03-01  Alex Christensen  <achristensen@webkit.org>
 
         Unreviewed, rolling out r213259.
index b1e2f4a..9de7541 100644 (file)
@@ -1737,7 +1737,7 @@ bool Document::hasPendingForcedStyleRecalc() const
     return m_styleRecalcTimer.isActive() && m_pendingStyleRecalcShouldForce;
 }
 
-void Document::recalcStyle(Style::Change change)
+void Document::resolveStyle(ResolveStyleType type)
 {
     ASSERT(!view() || !view()->isPainting());
 
@@ -1778,9 +1778,9 @@ void Document::recalcStyle(Style::Change change)
         WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
 
         if (m_pendingStyleRecalcShouldForce)
-            change = Style::Force;
+            type = ResolveStyleType::Rebuild;
 
-        if (change == Style::Force) {
+        if (type == ResolveStyleType::Rebuild) {
             // This may get set again during style resolve.
             m_hasNodesWithPlaceholderStyle = false;
 
@@ -1794,10 +1794,13 @@ void Document::recalcStyle(Style::Change change)
             auto documentChange = Style::determineChange(documentStyle, m_renderView->style());
             if (documentChange != Style::NoChange)
                 renderView()->setStyle(WTFMove(documentStyle));
+
+            if (auto* documentElement = this->documentElement())
+                documentElement->invalidateStyleForSubtree();
         }
 
         Style::TreeResolver resolver(*this);
-        auto styleUpdate = resolver.resolve(change);
+        auto styleUpdate = resolver.resolve();
 
         m_lastStyleUpdateSizeForTesting = styleUpdate ? styleUpdate->size() : 0;
 
@@ -1867,7 +1870,7 @@ void Document::updateStyleIfNeeded()
     if (!needsStyleRecalc())
         return;
 
-    recalcStyle();
+    resolveStyle();
 }
 
 void Document::updateLayout()
@@ -1917,12 +1920,12 @@ void Document::updateLayoutIgnorePendingStylesheets(Document::RunPostLayoutTasks
         if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == NoLayoutWithPendingSheets) {
             m_pendingSheetLayout = DidLayoutWithPendingSheets;
             styleScope().didChangeActiveStyleSheetCandidates();
-            recalcStyle(Style::Force);
+            resolveStyle(ResolveStyleType::Rebuild);
         } 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 
             // but here we need up-to-date style immediately.
-            recalcStyle(Style::Force);
+            resolveStyle(ResolveStyleType::Rebuild);
     }
 
     updateLayout();
@@ -2135,7 +2138,7 @@ void Document::createRenderTree()
 
     renderView()->setIsInWindow(true);
 
-    recalcStyle(Style::Force);
+    resolveStyle(ResolveStyleType::Rebuild);
 }
 
 void Document::didBecomeCurrentDocumentInFrame()
@@ -5036,9 +5039,9 @@ void Document::finishedParsing()
     if (RefPtr<Frame> f = frame()) {
         // FrameLoader::finishedParsing() might end up calling Document::implicitClose() if all
         // resource loads are complete. HTMLObjectElements can start loading their resources from
-        // post attach callbacks triggered by recalcStyle().  This means if we parse out an <object>
+        // post attach callbacks triggered by resolveStyle(). This means if we parse out an <object>
         // tag and then reach the end of the document without updating styles, we might not have yet
-        // started the resource load and might fire the window load event too early.  To avoid this
+        // started the resource load and might fire the window load event too early. To avoid this
         // we force the styles to be up to date before calling FrameLoader::finishedParsing().
         // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around comment 35.
         updateStyleIfNeeded();
@@ -5820,7 +5823,7 @@ void Document::webkitWillEnterFullScreenForElement(Element* element)
 
     m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true);
 
-    recalcStyle(Style::Force);
+    resolveStyle(ResolveStyleType::Rebuild);
 }
 
 void Document::webkitDidEnterFullScreenForElement(Element*)
index 61de319..77e1f34 100644 (file)
@@ -45,7 +45,6 @@
 #include "RenderPtr.h"
 #include "ScriptExecutionContext.h"
 #include "StringWithDirection.h"
-#include "StyleChange.h"
 #include "Supplementable.h"
 #include "TextResourceDecoder.h"
 #include "Timer.h"
@@ -521,7 +520,8 @@ public:
     WEBCORE_EXPORT Ref<CSSStyleDeclaration> createCSSStyleDeclaration();
     Ref<Text> createEditingTextNode(const String&);
 
-    void recalcStyle(Style::Change = Style::NoChange);
+    enum class ResolveStyleType { Normal, Rebuild };
+    void resolveStyle(ResolveStyleType = ResolveStyleType::Normal);
     WEBCORE_EXPORT void updateStyleIfNeeded();
     bool needsStyleRecalc() const;
     unsigned lastStyleUpdateSizeForTesting() const { return m_lastStyleUpdateSizeForTesting; }
index 6eb3f81..5f178a7 100644 (file)
@@ -342,7 +342,7 @@ void InspectorOverlay::update()
     drawPaintRects();
 
     // Position DOM elements.
-    overlayPage()->mainFrame().document()->recalcStyle(Style::Force);
+    overlayPage()->mainFrame().document()->resolveStyle(Document::ResolveStyleType::Rebuild);
     if (overlayView->needsLayout())
         overlayView->layout();
 
index 24b214c..005be4d 100644 (file)
@@ -236,7 +236,7 @@ void DocumentWriter::reportDataReceived()
     m_hasReceivedSomeData = true;
     if (m_decoder->encoding().usesVisualOrdering())
         m_frame->document()->setVisuallyOrdered();
-    m_frame->document()->recalcStyle(Style::Force);
+    m_frame->document()->resolveStyle(Document::ResolveStyleType::Rebuild);
 }
 
 void DocumentWriter::addData(const char* bytes, size_t length)
index 9908850..1091b80 100644 (file)
@@ -979,7 +979,7 @@ void Frame::setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor
     m_pageZoomFactor = pageZoomFactor;
     m_textZoomFactor = textZoomFactor;
 
-    document->recalcStyle(Style::Force);
+    document->resolveStyle(Document::ResolveStyleType::Rebuild);
 
     for (RefPtr<Frame> child = tree().firstChild(); child; child = child->tree().nextSibling())
         child->setPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor);
index 131b098..1ec1dec 100644 (file)
@@ -858,7 +858,7 @@ void Page::setPageScaleFactor(float scale, const IntPoint& origin, bool inStable
         if (document->renderView())
             document->renderView()->setNeedsLayout();
 
-        document->recalcStyle(Style::Force);
+        document->resolveStyle(Document::ResolveStyleType::Rebuild);
 
         // Transform change on RenderView doesn't trigger repaint on non-composited contents.
         mainFrame().view()->invalidateRect(IntRect(LayoutRect::infiniteRect()));
index 07ca9c3..d0fd059 100644 (file)
@@ -92,10 +92,9 @@ TreeResolver::Scope::Scope(ShadowRoot& shadowRoot, Scope& enclosingScope)
 {
 }
 
-TreeResolver::Parent::Parent(Document& document, Change change)
+TreeResolver::Parent::Parent(Document& document)
     : element(nullptr)
     , style(*document.renderStyle())
-    , change(change)
 {
 }
 
@@ -452,7 +451,7 @@ void TreeResolver::resolveComposedTree()
     popParentsToDepth(1);
 }
 
-std::unique_ptr<Update> TreeResolver::resolve(Change change)
+std::unique_ptr<Update> TreeResolver::resolve()
 {
     auto& renderView = *m_document.renderView();
 
@@ -461,12 +460,12 @@ std::unique_ptr<Update> TreeResolver::resolve(Change change)
         m_document.styleScope().resolver();
         return nullptr;
     }
-    if (change != Force && !documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc())
+    if (!documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc())
         return nullptr;
 
     m_update = std::make_unique<Update>(m_document);
     m_scopeStack.append(adoptRef(*new Scope(m_document)));
-    m_parentStack.append(Parent(m_document, change));
+    m_parentStack.append(Parent(m_document));
 
     // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
     renderView.setUsesFirstLineRules(renderView.usesFirstLineRules() || scope().styleResolver.usesFirstLineRules());
index df5f861..331c50b 100644 (file)
@@ -52,7 +52,7 @@ public:
     TreeResolver(Document&);
     ~TreeResolver();
 
-    std::unique_ptr<Update> resolve(Change);
+    std::unique_ptr<Update> resolve();
 
     static ElementUpdate createAnimatedElementUpdate(std::unique_ptr<RenderStyle>, Element&, Change parentChange);
 
@@ -76,11 +76,11 @@ private:
     struct Parent {
         Element* element;
         const RenderStyle& style;
-        Change change;
+        Change change { NoChange };
         bool didPushScope { false };
         bool elementNeedingStyleRecalcAffectsNextSiblingElementStyle { false };
 
-        Parent(Document&, Change);
+        Parent(Document&);
         Parent(Element&, const RenderStyle&, Change);
     };