[FrameView::layout cleanup] Move root/body marking dirty logic to a separate function
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Oct 2017 19:19:38 +0000 (19:19 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Oct 2017 19:19:38 +0000 (19:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178477
<rdar://problem/35056478>

Reviewed by Simon Fraser.

No change in functionality.

* page/FrameView.cpp:
(WebCore::FrameView::markRootOrBodyRendererDirty const):
(WebCore::FrameView::layout):
* page/FrameView.h:

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

Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h

index dfd2384..a559f6b 100644 (file)
@@ -1,3 +1,18 @@
+2017-10-18  Zalan Bujtas  <zalan@apple.com>
+
+        [FrameView::layout cleanup] Move root/body marking dirty logic to a separate function
+        https://bugs.webkit.org/show_bug.cgi?id=178477
+        <rdar://problem/35056478>
+
+        Reviewed by Simon Fraser.
+
+        No change in functionality.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::markRootOrBodyRendererDirty const):
+        (WebCore::FrameView::layout):
+        * page/FrameView.h:
+
 2017-10-18  Keith Miller  <keith_miller@apple.com>
 
         Setup WebCore build to start using unified sources.
index bd76174..c51560d 100644 (file)
@@ -1336,6 +1336,18 @@ bool FrameView::handleLayoutWithFrameFlatteningIfNeeded(bool allowSubtreeLayout)
     return !layoutRoot || !layoutRoot->needsLayout();
 }
 
+void FrameView::markRootOrBodyRendererDirty() const
+{
+    auto& document = *frame().document();
+    RenderBox* rootRenderer = document.documentElement() ? document.documentElement()->renderBox() : nullptr;
+    auto* body = document.bodyOrFrameset();
+    RenderBox* bodyRenderer = rootRenderer && body ? body->renderBox() : nullptr;
+    if (bodyRenderer && bodyRenderer->stretchesToViewport())
+        bodyRenderer->setChildNeedsLayout();
+    else if (rootRenderer && rootRenderer->stretchesToViewport())
+        rootRenderer->setChildNeedsLayout();
+}
+
 void FrameView::layout(bool allowSubtreeLayout)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(!frame().document()->inRenderTreeUpdate());
@@ -1476,23 +1488,14 @@ void FrameView::layout(bool allowSubtreeLayout)
                     setScrollbarModes(hMode, vMode);
             }
 
-            LayoutSize oldSize = m_size;
+            auto oldSize = m_size;
             m_size = layoutSize();
-
             if (oldSize != m_size) {
                 LOG(Layout, "  layout size changed from %.3fx%.3f to %.3fx%.3f", oldSize.width().toFloat(), oldSize.height().toFloat(), m_size.width().toFloat(), m_size.height().toFloat());
                 m_needsFullRepaint = true;
-                if (!m_firstLayout) {
-                    RenderBox* rootRenderer = document.documentElement() ? document.documentElement()->renderBox() : nullptr;
-                    auto* body = document.bodyOrFrameset();
-                    RenderBox* bodyRenderer = rootRenderer && body ? body->renderBox() : nullptr;
-                    if (bodyRenderer && bodyRenderer->stretchesToViewport())
-                        bodyRenderer->setChildNeedsLayout();
-                    else if (rootRenderer && rootRenderer->stretchesToViewport())
-                        rootRenderer->setChildNeedsLayout();
-                }
+                if (!m_firstLayout)
+                    markRootOrBodyRendererDirty();
             }
-
             m_layoutPhase = InPreLayout;
         }
 
index 9836145..ec38d03 100644 (file)
@@ -766,6 +766,8 @@ private:
     void startLayoutAtMainFrameViewIfNeeded(bool allowSubtreeLayout);
     bool frameFlatteningEnabled() const;
     bool isFrameFlatteningValidForThisFrame() const;
+    
+    void markRootOrBodyRendererDirty() const;
 
     bool qualifiesAsVisuallyNonEmpty() const;
     bool isViewForDocumentInFrame() const;