[LayoutState cleanup] Move all LayoutState* classes to LayoutState.h/cpp
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Nov 2017 22:02:39 +0000 (22:02 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Nov 2017 22:02:39 +0000 (22:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179280
<rdar://problem/35348452>

Reviewed by Antti Koivisto.

No change in functionality.

* page/LayoutContext.cpp:
(WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer): Deleted.
(WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer): Deleted.
(WebCore::SubtreeLayoutStateMaintainer::shouldDisableLayoutStateForSubtree): Deleted.
* rendering/LayoutState.cpp:
(WebCore::LayoutStateMaintainer::LayoutStateMaintainer):
(WebCore::LayoutStateMaintainer::~LayoutStateMaintainer):
(WebCore::LayoutStateMaintainer::push):
(WebCore::LayoutStateMaintainer::pop):
(WebCore::LayoutStateDisabler::LayoutStateDisabler):
(WebCore::LayoutStateDisabler::~LayoutStateDisabler):
(WebCore::shouldDisableLayoutStateForSubtree):
(WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer):
(WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer):
(WebCore::PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer):
(WebCore::PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer):
* rendering/LayoutState.h:
(WebCore::LayoutStateMaintainer::didPush const):
* rendering/RenderBlockFlow.cpp:
(WebCore::PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer): Deleted.
(WebCore::PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer): Deleted.
(): Deleted.
* rendering/RenderView.h:
(WebCore::LayoutStateMaintainer::LayoutStateMaintainer): Deleted.
(WebCore::LayoutStateMaintainer::~LayoutStateMaintainer): Deleted.
(WebCore::LayoutStateMaintainer::push): Deleted.
(WebCore::LayoutStateMaintainer::pop): Deleted.
(WebCore::LayoutStateMaintainer::didPush const): Deleted.
(WebCore::LayoutStateDisabler::LayoutStateDisabler): Deleted.
(WebCore::LayoutStateDisabler::~LayoutStateDisabler): Deleted.

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

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

index 9ea148d..9210beb 100644 (file)
@@ -1,5 +1,46 @@
 2017-11-04  Zalan Bujtas  <zalan@apple.com>
 
+        [LayoutState cleanup] Move all LayoutState* classes to LayoutState.h/cpp
+        https://bugs.webkit.org/show_bug.cgi?id=179280
+        <rdar://problem/35348452>
+
+        Reviewed by Antti Koivisto.
+
+        No change in functionality.
+
+        * page/LayoutContext.cpp:
+        (WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer): Deleted.
+        (WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer): Deleted.
+        (WebCore::SubtreeLayoutStateMaintainer::shouldDisableLayoutStateForSubtree): Deleted.
+        * rendering/LayoutState.cpp:
+        (WebCore::LayoutStateMaintainer::LayoutStateMaintainer):
+        (WebCore::LayoutStateMaintainer::~LayoutStateMaintainer):
+        (WebCore::LayoutStateMaintainer::push):
+        (WebCore::LayoutStateMaintainer::pop):
+        (WebCore::LayoutStateDisabler::LayoutStateDisabler):
+        (WebCore::LayoutStateDisabler::~LayoutStateDisabler):
+        (WebCore::shouldDisableLayoutStateForSubtree):
+        (WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer):
+        (WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer):
+        (WebCore::PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer):
+        (WebCore::PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer):
+        * rendering/LayoutState.h:
+        (WebCore::LayoutStateMaintainer::didPush const):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer): Deleted.
+        (WebCore::PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer): Deleted.
+        (): Deleted.
+        * rendering/RenderView.h:
+        (WebCore::LayoutStateMaintainer::LayoutStateMaintainer): Deleted.
+        (WebCore::LayoutStateMaintainer::~LayoutStateMaintainer): Deleted.
+        (WebCore::LayoutStateMaintainer::push): Deleted.
+        (WebCore::LayoutStateMaintainer::pop): Deleted.
+        (WebCore::LayoutStateMaintainer::didPush const): Deleted.
+        (WebCore::LayoutStateDisabler::LayoutStateDisabler): Deleted.
+        (WebCore::LayoutStateDisabler::~LayoutStateDisabler): Deleted.
+
+2017-11-04  Zalan Bujtas  <zalan@apple.com>
+
         [LayoutState cleanup] Move offset/cliprect/pagination code to dedicate methods
         https://bugs.webkit.org/show_bug.cgi?id=179279
         <rdar://problem/35348171>
index e0002ca..a5bd996 100644 (file)
@@ -51,45 +51,6 @@ static bool isObjectAncestorContainerOf(RenderElement& ancestor, RenderElement&
     return false;
 }
 
-class SubtreeLayoutStateMaintainer {
-public:
-    SubtreeLayoutStateMaintainer(RenderElement* subtreeLayoutRoot)
-        : m_subtreeLayoutRoot(subtreeLayoutRoot)
-    {
-        if (m_subtreeLayoutRoot) {
-            RenderView& view = m_subtreeLayoutRoot->view();
-            view.pushLayoutState(*m_subtreeLayoutRoot);
-            if (shouldDisableLayoutStateForSubtree()) {
-                view.disableLayoutState();
-                m_didDisableLayoutState = true;
-            }
-        }
-    }
-
-    ~SubtreeLayoutStateMaintainer()
-    {
-        if (m_subtreeLayoutRoot) {
-            RenderView& view = m_subtreeLayoutRoot->view();
-            view.popLayoutState(*m_subtreeLayoutRoot);
-            if (m_didDisableLayoutState)
-                view.enableLayoutState();
-        }
-    }
-
-    bool shouldDisableLayoutStateForSubtree()
-    {
-        for (auto* renderer = m_subtreeLayoutRoot; renderer; renderer = renderer->container()) {
-            if (renderer->hasTransform() || renderer->hasReflection())
-                return true;
-        }
-        return false;
-    }
-    
-private:
-    RenderElement* m_subtreeLayoutRoot { nullptr };
-    bool m_didDisableLayoutState { false };
-};
-
 #ifndef NDEBUG
 class RenderTreeNeedsLayoutChecker {
 public :
index dfbde31..2928b11 100644 (file)
@@ -208,5 +208,102 @@ void LayoutState::establishLineGrid(RenderBlockFlow& renderer)
     m_lineGridOffset = m_layoutOffset;
 }
 
+LayoutStateMaintainer::LayoutStateMaintainer(RenderBox& root, LayoutSize offset, bool disableState, LayoutUnit pageHeight, bool pageHeightChanged)
+    : m_view(root.view())
+    , m_disabled(disableState)
+{
+    push(root, offset, pageHeight, pageHeightChanged);
+}
+
+LayoutStateMaintainer::LayoutStateMaintainer(RenderView& view)
+    : m_view(view)
+{
+}
+
+LayoutStateMaintainer::~LayoutStateMaintainer()
+{
+    ASSERT(!m_didCallPush || m_didCallPush == m_didCallPop);
+}
+
+void LayoutStateMaintainer::push(RenderBox& root, LayoutSize offset, LayoutUnit pageHeight, bool pageHeightChanged)
+{
+    ASSERT(!m_didCallPush);
+    m_didCallPush = true;
+    // We push state even if disabled, because we still need to store layoutDelta
+    m_didPushLayoutState = m_view.pushLayoutState(root, offset, pageHeight, pageHeightChanged);
+    if (!m_didPushLayoutState)
+        return;
+    if (m_disabled)
+        m_view.disableLayoutState();
+}
+
+void LayoutStateMaintainer::pop()
+{
+    ASSERT(!m_didCallPop);
+    m_didCallPop = true;
+    if (!m_didCallPush)
+        return;
+    if (!m_didPushLayoutState)
+        return;
+    m_view.popLayoutState();
+    if (m_disabled)
+        m_view.enableLayoutState();
+}
+
+LayoutStateDisabler::LayoutStateDisabler(RenderView& view)
+    : m_view(view)
+{
+    m_view.disableLayoutState();
+}
+
+LayoutStateDisabler::~LayoutStateDisabler()
+{
+    m_view.enableLayoutState();
+}
+
+static bool shouldDisableLayoutStateForSubtree(RenderElement& subtreeLayoutRoot)
+{
+    for (auto* renderer = &subtreeLayoutRoot; renderer; renderer = renderer->container()) {
+        if (renderer->hasTransform() || renderer->hasReflection())
+            return true;
+    }
+    return false;
+}
+
+SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer(RenderElement* subtreeLayoutRoot)
+    : m_subtreeLayoutRoot(subtreeLayoutRoot)
+{
+    if (m_subtreeLayoutRoot) {
+        RenderView& view = m_subtreeLayoutRoot->view();
+        view.pushLayoutState(*m_subtreeLayoutRoot);
+        if (shouldDisableLayoutStateForSubtree(*m_subtreeLayoutRoot)) {
+            view.disableLayoutState();
+            m_didDisableLayoutState = true;
+        }
+    }
+}
+
+SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer()
+{
+    if (m_subtreeLayoutRoot) {
+        RenderView& view = m_subtreeLayoutRoot->view();
+        view.popLayoutState(*m_subtreeLayoutRoot);
+        if (m_didDisableLayoutState)
+            view.enableLayoutState();
+    }
+}
+
+PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer(RenderBlockFlow& flow)
+    : m_flow(flow)
+    , m_pushed(flow.view().pushLayoutStateForPaginationIfNeeded(flow))
+{
+}
+
+PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer()
+{
+    if (m_pushed)
+        m_flow.view().popLayoutState(m_flow);
+}
+
 } // namespace WebCore
 
index 27afd47..a7e0f64 100644 (file)
 
 namespace WebCore {
 
-class RenderBlock;
 class RenderBlockFlow;
 class RenderBox;
 class RenderElement;
 class RenderFragmentedFlow;
 class RenderObject;
-class ShapeInsideInfo;
+class RenderView;
 
 class LayoutState {
     WTF_MAKE_NONCOPYABLE(LayoutState); WTF_MAKE_FAST_ALLOCATED;
@@ -128,4 +127,56 @@ public:
 #endif
 };
 
+// Stack-based class to assist with LayoutState push/pop
+class LayoutStateMaintainer {
+    WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer);
+public:
+    // Constructor to push now.
+    explicit LayoutStateMaintainer(RenderBox&, LayoutSize offset, bool disableState = false, LayoutUnit pageHeight = 0, bool pageHeightChanged = false);
+    // Constructor to maybe push later.
+    explicit LayoutStateMaintainer(RenderView&);
+    ~LayoutStateMaintainer();
+
+    void push(RenderBox& root, LayoutSize offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false);
+    void pop();
+    bool didPush() const { return m_didCallPush; }
+
+private:
+    RenderView& m_view;
+    bool m_disabled { false };
+    bool m_didCallPush { false };
+    bool m_didCallPop { false };
+    bool m_didPushLayoutState { false };
+};
+
+class SubtreeLayoutStateMaintainer {
+public:
+    SubtreeLayoutStateMaintainer(RenderElement* subtreeLayoutRoot);
+    ~SubtreeLayoutStateMaintainer();
+
+private:
+    RenderElement* m_subtreeLayoutRoot { nullptr };
+    bool m_didDisableLayoutState { false };
+};
+
+class LayoutStateDisabler {
+    WTF_MAKE_NONCOPYABLE(LayoutStateDisabler);
+public:
+    LayoutStateDisabler(RenderView&);
+    ~LayoutStateDisabler();
+
+private:
+    RenderView& m_view;
+};
+
+class PaginatedLayoutStateMaintainer {
+public:
+    PaginatedLayoutStateMaintainer(RenderBlockFlow&);
+    ~PaginatedLayoutStateMaintainer();
+
+private:
+    RenderBlockFlow& m_flow;
+    bool m_pushed { false };
+};
+
 } // namespace WebCore
index f47a6d6..1b13595 100644 (file)
@@ -67,25 +67,6 @@ struct SameSizeAsMarginInfo {
 COMPILE_ASSERT(sizeof(RenderBlockFlow::MarginValues) == sizeof(LayoutUnit[4]), MarginValues_should_stay_small);
 COMPILE_ASSERT(sizeof(RenderBlockFlow::MarginInfo) == sizeof(SameSizeAsMarginInfo), MarginInfo_should_stay_small);
 
-class PaginatedLayoutStateMaintainer {
-public:
-    PaginatedLayoutStateMaintainer(RenderBlockFlow& flow)
-        : m_flow(flow)
-        , m_pushed(flow.view().pushLayoutStateForPaginationIfNeeded(flow))
-    {
-    }
-
-    ~PaginatedLayoutStateMaintainer()
-    {
-        if (m_pushed)
-            m_flow.view().popLayoutState(m_flow);
-    }
-
-private:
-    RenderBlockFlow& m_flow;
-    bool m_pushed { false };
-};
-
 // Our MarginInfo state used when laying out block children.
 RenderBlockFlow::MarginInfo::MarginInfo(const RenderBlockFlow& block, LayoutUnit beforeBorderPadding, LayoutUnit afterBorderPadding)
     : m_atBeforeSideOfBlock(true)
index 9f29cb3..20ac5d3 100644 (file)
@@ -341,82 +341,6 @@ private:
 #endif
 };
 
-// Stack-based class to assist with LayoutState push/pop
-class LayoutStateMaintainer {
-    WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer);
-public:
-    // Constructor to push now.
-    explicit LayoutStateMaintainer(RenderBox& root, LayoutSize offset, bool disableState = false, LayoutUnit pageHeight = 0, bool pageHeightChanged = false)
-        : m_view(root.view())
-        , m_disabled(disableState)
-    {
-        push(root, offset, pageHeight, pageHeightChanged);
-    }
-
-    // Constructor to maybe push later.
-    explicit LayoutStateMaintainer(RenderView& view)
-        : m_view(view)
-    {
-    }
-
-    ~LayoutStateMaintainer()
-    {
-        ASSERT(!m_didCallPush || m_didCallPush == m_didCallPop);
-    }
-
-    void push(RenderBox& root, LayoutSize offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false)
-    {
-        ASSERT(!m_didCallPush);
-        m_didCallPush = true;
-        // We push state even if disabled, because we still need to store layoutDelta
-        m_didPushLayoutState = m_view.pushLayoutState(root, offset, pageHeight, pageHeightChanged);
-        if (!m_didPushLayoutState)
-            return;
-        if (m_disabled)
-            m_view.disableLayoutState();
-    }
-
-    void pop()
-    {
-        ASSERT(!m_didCallPop);
-        m_didCallPop = true;
-        if (!m_didCallPush)
-            return;
-        if (!m_didPushLayoutState)
-            return;
-        m_view.popLayoutState();
-        if (m_disabled)
-            m_view.enableLayoutState();
-    }
-
-    bool didPush() const { return m_didCallPush; }
-
-private:
-    RenderView& m_view;
-    bool m_disabled { false };
-    bool m_didCallPush { false };
-    bool m_didCallPop { false };
-    bool m_didPushLayoutState { false };
-};
-
-class LayoutStateDisabler {
-    WTF_MAKE_NONCOPYABLE(LayoutStateDisabler);
-public:
-    LayoutStateDisabler(RenderView& view)
-        : m_view(view)
-    {
-        m_view.disableLayoutState();
-    }
-
-    ~LayoutStateDisabler()
-    {
-        m_view.enableLayoutState();
-    }
-
-private:
-    RenderView& m_view;
-};
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderView, isRenderView())