Title: [224637] trunk/Source/WebCore
Revision
224637
Author
za...@apple.com
Date
2017-11-09 10:50:03 -0800 (Thu, 09 Nov 2017)

Log Message

[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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (224636 => 224637)


--- trunk/Source/WebCore/ChangeLog	2017-11-09 18:37:09 UTC (rev 224636)
+++ trunk/Source/WebCore/ChangeLog	2017-11-09 18:50:03 UTC (rev 224637)
@@ -1,3 +1,24 @@
+2017-11-09  Zalan Bujtas  <za...@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  <m...@apple.com>
 
         Remove support for iOS-only softbank-sjis encoding if possible

Modified: trunk/Source/WebCore/page/LayoutContext.cpp (224636 => 224637)


--- trunk/Source/WebCore/page/LayoutContext.cpp	2017-11-09 18:37:09 UTC (rev 224636)
+++ trunk/Source/WebCore/page/LayoutContext.cpp	2017-11-09 18:50:03 UTC (rev 224637)
@@ -573,11 +573,6 @@
     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.

Modified: trunk/Source/WebCore/page/LayoutContext.h (224636 => 224637)


--- trunk/Source/WebCore/page/LayoutContext.h	2017-11-09 18:37:09 UTC (rev 224636)
+++ trunk/Source/WebCore/page/LayoutContext.h	2017-11-09 18:50:03 UTC (rev 224637)
@@ -92,10 +92,6 @@
 
     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 @@
     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 @@
     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();
 

Modified: trunk/Source/WebCore/rendering/LayoutState.cpp (224636 => 224637)


--- trunk/Source/WebCore/rendering/LayoutState.cpp	2017-11-09 18:37:09 UTC (rev 224636)
+++ trunk/Source/WebCore/rendering/LayoutState.cpp	2017-11-09 18:50:03 UTC (rev 224637)
@@ -273,14 +273,14 @@
 #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 @@
     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 @@
         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 @@
 }
 
 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,17 +351,16 @@
 
 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))
 {
 }
 
@@ -369,7 +367,7 @@
 PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer()
 {
     if (m_pushed)
-        m_flow.view().frameView().layoutContext().popLayoutState(m_flow);
+        m_context.popLayoutState();
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/LayoutState.h (224636 => 224637)


--- trunk/Source/WebCore/rendering/LayoutState.h	2017-11-09 18:37:09 UTC (rev 224636)
+++ trunk/Source/WebCore/rendering/LayoutState.h	2017-11-09 18:50:03 UTC (rev 224637)
@@ -149,7 +149,7 @@
     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 @@
     ~SubtreeLayoutStateMaintainer();
 
 private:
-    RenderElement* m_subtreeLayoutRoot { nullptr };
+    LayoutContext* m_context { nullptr };
     bool m_didDisablePaintOffsetCache { false };
 };
 
@@ -173,7 +173,7 @@
     ~LayoutStateDisabler();
 
 private:
-    LayoutContext& m_layoutContext;
+    LayoutContext& m_context;
 };
 
 class PaginatedLayoutStateMaintainer {
@@ -182,7 +182,7 @@
     ~PaginatedLayoutStateMaintainer();
 
 private:
-    RenderBlockFlow& m_flow;
+    LayoutContext& m_context;
     bool m_pushed { false };
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to