[LayoutState cleanup] Remove renderer data members from state maintainers.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Nov 2017 18:50:03 +0000 (18:50 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Nov 2017 18:50:03 +0000 (18:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179483
<rdar://problem/35442548>

Reviewed by Darin Adler.

Although layout is not supposed to mutate the tree anymore, it's safer to use LayoutContext instead.

No change in functionality.

* page/LayoutContext.cpp:
* page/LayoutContext.h:
* rendering/LayoutState.cpp:
(WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer):
(WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer):
(WebCore::PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer):
(WebCore::PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer):
* rendering/LayoutState.h:

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

Source/WebCore/ChangeLog
Source/WebCore/page/LayoutContext.cpp
Source/WebCore/page/LayoutContext.h
Source/WebCore/rendering/LayoutState.cpp
Source/WebCore/rendering/LayoutState.h

index 30329ab..db5c2da 100644 (file)
@@ -1,3 +1,24 @@
+2017-11-09  Zalan Bujtas  <zalan@apple.com>
+
+        [LayoutState cleanup] Remove renderer data members from state maintainers.
+        https://bugs.webkit.org/show_bug.cgi?id=179483
+        <rdar://problem/35442548>
+
+        Reviewed by Darin Adler.
+
+        Although layout is not supposed to mutate the tree anymore, it's safer to use LayoutContext instead.
+
+        No change in functionality.
+
+        * page/LayoutContext.cpp:
+        * page/LayoutContext.h:
+        * rendering/LayoutState.cpp:
+        (WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer):
+        (WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer):
+        (WebCore::PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer):
+        (WebCore::PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer):
+        * rendering/LayoutState.h:
+
 2017-11-09  Maciej Stachowiak  <mjs@apple.com>
 
         Remove support for iOS-only softbank-sjis encoding if possible
index 40ce0aa..0cce291 100644 (file)
@@ -573,11 +573,6 @@ bool LayoutContext::pushLayoutStateForPaginationIfNeeded(RenderBlockFlow& layout
     return true;
 }
     
-void LayoutContext::popLayoutState(RenderObject&)
-{
-    return popLayoutState();
-}
-    
 bool LayoutContext::pushLayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageHeight, bool pageHeightChanged)
 {
     // We push LayoutState even if layoutState is disabled because it stores layoutDelta too.
index 78ccd0d..7034422 100644 (file)
@@ -92,10 +92,6 @@ public:
 
     void flushAsynchronousTasks();
 
-    // Subtree push/pop
-    void pushLayoutState(RenderElement&);
-    bool pushLayoutStateForPaginationIfNeeded(RenderBlockFlow&);
-    void popLayoutState(RenderObject&);
     LayoutState* layoutState() const;
     // Returns true if layoutState should be used for its cached offset and clip.
     bool isPaintOffsetCacheEnabled() const { return !m_paintOffsetCacheDisableCount && layoutState(); }
@@ -117,6 +113,7 @@ private:
     friend class LayoutStateMaintainer;
     friend class LayoutStateDisabler;
     friend class SubtreeLayoutStateMaintainer;
+    friend class PaginatedLayoutStateMaintainer;
 
     bool canPerformLayout() const;
     bool layoutDisallowed() const { return m_layoutDisallowedCount; }
@@ -138,6 +135,9 @@ private:
     void startLayoutAtMainFrameViewIfNeeded();
 
     // These functions may only be accessed by LayoutStateMaintainer.
+    // Subtree push/pop
+    void pushLayoutState(RenderElement&);
+    bool pushLayoutStateForPaginationIfNeeded(RenderBlockFlow&);
     bool pushLayoutState(RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false);
     void popLayoutState();
 
index c213ae2..534e810 100644 (file)
@@ -273,14 +273,14 @@ bool LayoutState::layoutDeltaMatches(LayoutSize delta) const
 #endif
 
 LayoutStateMaintainer::LayoutStateMaintainer(RenderBox& root, LayoutSize offset, bool disablePaintOffsetCache, LayoutUnit pageHeight, bool pageHeightChanged)
-    : m_layoutContext(root.view().frameView().layoutContext())
+    : m_context(root.view().frameView().layoutContext())
     , m_paintOffsetCacheIsDisabled(disablePaintOffsetCache)
 {
     push(root, offset, pageHeight, pageHeightChanged);
 }
 
-LayoutStateMaintainer::LayoutStateMaintainer(LayoutContext& layoutContext)
-    : m_layoutContext(layoutContext)
+LayoutStateMaintainer::LayoutStateMaintainer(LayoutContext& context)
+    : m_context(context)
 {
 }
 
@@ -297,11 +297,11 @@ void LayoutStateMaintainer::push(RenderBox& root, LayoutSize offset, LayoutUnit
     ASSERT(!m_didCallPush);
     m_didCallPush = true;
     // We push state even if disabled, because we still need to store layoutDelta
-    m_didPushLayoutState = m_layoutContext.pushLayoutState(root, offset, pageHeight, pageHeightChanged);
+    m_didPushLayoutState = m_context.pushLayoutState(root, offset, pageHeight, pageHeightChanged);
     if (!m_didPushLayoutState)
         return;
     if (m_paintOffsetCacheIsDisabled)
-        m_layoutContext.disablePaintOffsetCache();
+        m_context.disablePaintOffsetCache();
 }
 
 void LayoutStateMaintainer::pop()
@@ -312,20 +312,20 @@ void LayoutStateMaintainer::pop()
         return;
     if (!m_didPushLayoutState)
         return;
-    m_layoutContext.popLayoutState();
+    m_context.popLayoutState();
     if (m_paintOffsetCacheIsDisabled)
-        m_layoutContext.enablePaintOffsetCache();
+        m_context.enablePaintOffsetCache();
 }
 
-LayoutStateDisabler::LayoutStateDisabler(LayoutContext& layoutContext)
-    : m_layoutContext(layoutContext)
+LayoutStateDisabler::LayoutStateDisabler(LayoutContext& context)
+    : m_context(context)
 {
-    m_layoutContext.disablePaintOffsetCache();
+    m_context.disablePaintOffsetCache();
 }
 
 LayoutStateDisabler::~LayoutStateDisabler()
 {
-    m_layoutContext.enablePaintOffsetCache();
+    m_context.enablePaintOffsetCache();
 }
 
 static bool shouldDisablePaintOffsetCacheForSubtree(RenderElement& subtreeLayoutRoot)
@@ -338,13 +338,12 @@ static bool shouldDisablePaintOffsetCacheForSubtree(RenderElement& subtreeLayout
 }
 
 SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer(RenderElement* subtreeLayoutRoot)
-    : m_subtreeLayoutRoot(subtreeLayoutRoot)
 {
-    if (m_subtreeLayoutRoot) {
-        auto& layoutContext = m_subtreeLayoutRoot->view().frameView().layoutContext();
-        layoutContext.pushLayoutState(*m_subtreeLayoutRoot);
-        if (shouldDisablePaintOffsetCacheForSubtree(*m_subtreeLayoutRoot)) {
-            layoutContext.disablePaintOffsetCache();
+    if (subtreeLayoutRoot) {
+        m_context = &subtreeLayoutRoot->view().frameView().layoutContext();
+        m_context->pushLayoutState(*subtreeLayoutRoot);
+        if (shouldDisablePaintOffsetCacheForSubtree(*subtreeLayoutRoot)) {
+            m_context->disablePaintOffsetCache();
             m_didDisablePaintOffsetCache = true;
         }
     }
@@ -352,24 +351,23 @@ SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer(RenderElement* subtre
 
 SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer()
 {
-    if (m_subtreeLayoutRoot) {
-        auto& layoutContext = m_subtreeLayoutRoot->view().frameView().layoutContext();
-        layoutContext.popLayoutState(*m_subtreeLayoutRoot);
+    if (m_context) {
+        m_context->popLayoutState();
         if (m_didDisablePaintOffsetCache)
-            layoutContext.enablePaintOffsetCache();
+            m_context->enablePaintOffsetCache();
     }
 }
 
 PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer(RenderBlockFlow& flow)
-    : m_flow(flow)
-    , m_pushed(flow.view().frameView().layoutContext().pushLayoutStateForPaginationIfNeeded(flow))
+    : m_context(flow.view().frameView().layoutContext())
+    , m_pushed(m_context.pushLayoutStateForPaginationIfNeeded(flow))
 {
 }
 
 PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer()
 {
     if (m_pushed)
-        m_flow.view().frameView().layoutContext().popLayoutState(m_flow);
+        m_context.popLayoutState();
 }
 
 } // namespace WebCore
index 313084e..17862dd 100644 (file)
@@ -149,7 +149,7 @@ public:
     bool didPush() const { return m_didCallPush; }
 
 private:
-    LayoutContext& m_layoutContext;
+    LayoutContext& m_context;
     bool m_paintOffsetCacheIsDisabled { false };
     bool m_didCallPush { false };
     bool m_didCallPop { false };
@@ -162,7 +162,7 @@ public:
     ~SubtreeLayoutStateMaintainer();
 
 private:
-    RenderElement* m_subtreeLayoutRoot { nullptr };
+    LayoutContext* m_context { nullptr };
     bool m_didDisablePaintOffsetCache { false };
 };
 
@@ -173,7 +173,7 @@ public:
     ~LayoutStateDisabler();
 
 private:
-    LayoutContext& m_layoutContext;
+    LayoutContext& m_context;
 };
 
 class PaginatedLayoutStateMaintainer {
@@ -182,7 +182,7 @@ public:
     ~PaginatedLayoutStateMaintainer();
 
 private:
-    RenderBlockFlow& m_flow;
+    LayoutContext& m_context;
     bool m_pushed { false };
 };