[FrameView::layout cleanup] Replace m_nestedLayoutCount with isLayoutNested()
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Oct 2017 15:52:37 +0000 (15:52 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Oct 2017 15:52:37 +0000 (15:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178503
<rdar://problem/35066561>

Reviewed by Antti Koivisto.

Covered by existing tests.

* page/FrameView.cpp:
(WebCore::FrameView::reset):
(WebCore::FrameView::layout):
(WebCore::FrameView::updateLayerPositionsAfterScrolling):
(WebCore::FrameView::updateCompositingLayersAfterScrolling):
(WebCore::FrameView::updateEmbeddedObjects):
(WebCore::FrameView::flushPostLayoutTasksQueue):
(WebCore::FrameView::performPostLayoutTasks):
(WebCore::FrameView::startLayoutAtMainFrameViewIfNeeded):
* page/FrameView.h:

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

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

index bfc459a..b9287d5 100644 (file)
@@ -1,3 +1,24 @@
+2017-10-19  Zalan Bujtas  <zalan@apple.com>
+
+        [FrameView::layout cleanup] Replace m_nestedLayoutCount with isLayoutNested()
+        https://bugs.webkit.org/show_bug.cgi?id=178503
+        <rdar://problem/35066561>
+
+        Reviewed by Antti Koivisto.
+
+        Covered by existing tests.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::reset):
+        (WebCore::FrameView::layout):
+        (WebCore::FrameView::updateLayerPositionsAfterScrolling):
+        (WebCore::FrameView::updateCompositingLayersAfterScrolling):
+        (WebCore::FrameView::updateEmbeddedObjects):
+        (WebCore::FrameView::flushPostLayoutTasksQueue):
+        (WebCore::FrameView::performPostLayoutTasks):
+        (WebCore::FrameView::startLayoutAtMainFrameViewIfNeeded):
+        * page/FrameView.h:
+
 2017-10-19  Antti Koivisto  <antti@apple.com>
 
         Overlapping text on all CSS fonts specs
index dac87a6..d89d898 100644 (file)
@@ -343,7 +343,6 @@ void FrameView::reset()
     m_layoutPhase = OutsideLayout;
     m_inSynchronousPostLayout = false;
     m_layoutCount = 0;
-    m_nestedLayoutCount = 0;
     m_postLayoutTasksTimer.stop();
     m_updateEmbeddedObjectsTimer.stop();
     m_firstLayout = true;
@@ -1362,7 +1361,6 @@ void FrameView::layout(bool allowSubtreeLayout)
         LOG(Layout, "  in painting, bailing");
         return;
     }
-
     ASSERT(frame().view() == this);
     ASSERT(frame().document());
     ASSERT(frame().document()->pageCacheState() == Document::NotInPageCache);
@@ -1372,6 +1370,7 @@ void FrameView::layout(bool allowSubtreeLayout)
     InspectorInstrumentationCookie cookie = InspectorInstrumentation::willLayout(frame());
     AnimationUpdateBlock animationUpdateBlock(&frame().animation());
 
+    SetForScope<LayoutNestedState> nestedState(m_layoutNestedState, m_layoutNestedState == LayoutNestedState::NotInLayout ? LayoutNestedState::NotNested : LayoutNestedState::Nested);
     // Many of the tasks performed during layout can cause this function to be re-entered,
     // so save the layout phase now and restore it on exit.
     SetForScope<LayoutPhase> layoutPhaseRestorer(m_layoutPhase, InPreLayout);
@@ -1397,7 +1396,7 @@ void FrameView::layout(bool allowSubtreeLayout)
     {
         SetForScope<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, false);
 
-        if (!m_nestedLayoutCount && !m_inSynchronousPostLayout && m_postLayoutTasksTimer.isActive() && !isInChildFrameWithFrameFlattening()) {
+        if (!isLayoutNested() && !m_inSynchronousPostLayout && m_postLayoutTasksTimer.isActive() && !isInChildFrameWithFrameFlattening()) {
             // This is a new top-level layout. If there are any remaining tasks from the previous
             // layout, finish them now.
             SetForScope<bool> inSynchronousPostLayoutChange(m_inSynchronousPostLayout, true);
@@ -1426,8 +1425,6 @@ void FrameView::layout(bool allowSubtreeLayout)
 
         m_layoutPhase = InPreLayout;
 
-        ++m_nestedLayoutCount;
-
         autoSizeIfEnabled();
 
         layoutRoot = m_subtreeLayoutRoot ? m_subtreeLayoutRoot : document.renderView();
@@ -1578,8 +1575,6 @@ void FrameView::layout(bool allowSubtreeLayout)
 
     InspectorInstrumentation::didLayout(cookie, *layoutRoot);
     DebugPageOverlays::didLayout(frame());
-
-    --m_nestedLayoutCount;
 }
 
 bool FrameView::shouldDeferScrollUpdateAfterContentSizeChange()
@@ -2630,7 +2625,7 @@ void FrameView::updateLayerPositionsAfterScrolling()
     if (m_layoutPhase == InViewSizeAdjust)
         return;
 
-    if (m_nestedLayoutCount <= 1 && hasViewportConstrainedObjects()) {
+    if (!isLayoutNested() && hasViewportConstrainedObjects()) {
         if (RenderView* renderView = this->renderView()) {
             updateWidgetPositions();
             renderView->layer()->updateLayerPositionsAfterDocumentScroll();
@@ -2672,7 +2667,7 @@ void FrameView::updateCompositingLayersAfterScrolling()
     if (!shouldUpdateCompositingLayersAfterScrolling())
         return;
 
-    if (m_nestedLayoutCount <= 1 && hasViewportConstrainedObjects()) {
+    if (!isLayoutNested() && hasViewportConstrainedObjects()) {
         if (RenderView* renderView = this->renderView())
             renderView->compositor().updateCompositingLayers(CompositingUpdateType::OnScroll);
     }
@@ -3449,7 +3444,7 @@ void FrameView::updateEmbeddedObject(RenderEmbeddedObject& embeddedObject)
 
 bool FrameView::updateEmbeddedObjects()
 {
-    if (m_nestedLayoutCount > 1 || !m_embeddedObjectsToUpdate || m_embeddedObjectsToUpdate->isEmpty())
+    if (isLayoutNested() || !m_embeddedObjectsToUpdate || m_embeddedObjectsToUpdate->isEmpty())
         return true;
 
     WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
@@ -3493,7 +3488,7 @@ void FrameView::queuePostLayoutCallback(Function<void()>&& callback)
 
 void FrameView::flushPostLayoutTasksQueue()
 {
-    if (m_nestedLayoutCount > 1)
+    if (isLayoutNested())
         return;
 
     if (!m_postLayoutCallbackQueue.size())
@@ -3515,7 +3510,7 @@ void FrameView::performPostLayoutTasks()
 
     flushPostLayoutTasksQueue();
 
-    if (m_nestedLayoutCount <= 1 && frame().document()->documentElement())
+    if (!isLayoutNested() && frame().document()->documentElement())
         fireLayoutRelatedMilestonesIfNeeded();
 
 #if PLATFORM(IOS)
@@ -4280,7 +4275,7 @@ void FrameView::startLayoutAtMainFrameViewIfNeeded(bool allowSubtreeLayout)
         return;
 
     // In the middle of parent layout, no need to restart from topmost.
-    if (parentView->m_nestedLayoutCount)
+    if (parentView->isInLayout())
         return;
 
     // Parent tree is clean. Starting layout from it would have no effect.
index ef55304..2b8d6de 100644 (file)
@@ -777,6 +777,8 @@ private:
     void convertSubtreeLayoutToFullLayout();
 
     RenderElement* viewportRenderer() const;
+    
+    bool isLayoutNested() const { return m_layoutNestedState == LayoutNestedState::Nested; }
 
     HashSet<Widget*> m_widgetsInRenderTree;
 
@@ -805,7 +807,8 @@ private:
     bool m_layoutSchedulingEnabled;
     bool m_inSynchronousPostLayout;
     int m_layoutCount;
-    unsigned m_nestedLayoutCount;
+    enum class LayoutNestedState { NotInLayout, NotNested, Nested };
+    LayoutNestedState m_layoutNestedState { LayoutNestedState::NotInLayout };
     Timer m_postLayoutTasksTimer;
     Timer m_updateEmbeddedObjectsTimer;
     bool m_firstLayoutCallbackPending;