[LayoutState cleanup] Add pagination parameter to subtree LayoutState
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Nov 2017 15:08:46 +0000 (15:08 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Nov 2017 15:08:46 +0000 (15:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179465
<rdar://problem/35434096>

Reviewed by Antti Koivisto.

It enables us to remove the last setters from LayoutState.

No change in functionality.

* page/LayoutContext.cpp:
(WebCore::LayoutContext::pushLayoutStateForPaginationIfNeeded):
* rendering/LayoutState.cpp:
(WebCore::LayoutState::LayoutState):
(WebCore::LayoutState::layoutDeltaMatches const):
(WebCore::LayoutState::layoutDeltaMatches): Deleted.
* rendering/LayoutState.h:
(WebCore::LayoutState::isPaginated const):
(WebCore::LayoutState::setIsPaginated): Deleted.
(WebCore::LayoutState::setPageLogicalHeight): Deleted.

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

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

index 7e92841..0a76fe8 100644 (file)
@@ -1,3 +1,26 @@
+2017-11-09  Zalan Bujtas  <zalan@apple.com>
+
+        [LayoutState cleanup] Add pagination parameter to subtree LayoutState
+        https://bugs.webkit.org/show_bug.cgi?id=179465
+        <rdar://problem/35434096>
+
+        Reviewed by Antti Koivisto.
+
+        It enables us to remove the last setters from LayoutState.
+
+        No change in functionality.
+
+        * page/LayoutContext.cpp:
+        (WebCore::LayoutContext::pushLayoutStateForPaginationIfNeeded):
+        * rendering/LayoutState.cpp:
+        (WebCore::LayoutState::LayoutState):
+        (WebCore::LayoutState::layoutDeltaMatches const):
+        (WebCore::LayoutState::layoutDeltaMatches): Deleted.
+        * rendering/LayoutState.h:
+        (WebCore::LayoutState::isPaginated const):
+        (WebCore::LayoutState::setIsPaginated): Deleted.
+        (WebCore::LayoutState::setPageLogicalHeight): Deleted.
+
 2017-11-08  Joseph Pecoraro  <pecoraro@apple.com>
 
         AVSampleBufferGenerator leaks seen on leaks bot
index 7d5832c..40ce0aa 100644 (file)
@@ -569,10 +569,7 @@ bool LayoutContext::pushLayoutStateForPaginationIfNeeded(RenderBlockFlow& layout
 {
     if (layoutState())
         return false;
-    m_layoutStateStack.append(std::make_unique<LayoutState>(layoutRoot));
-    layoutState()->setIsPaginated();
-    // This is just a flag for known page height (see RenderBlockFlow::checkForPaginationLogicalHeightChange).
-    layoutState()->setPageLogicalHeight(1);
+    m_layoutStateStack.append(std::make_unique<LayoutState>(layoutRoot, LayoutState::IsPaginated::Yes));
     return true;
 }
     
index 33d8df3..d430626 100644 (file)
@@ -34,9 +34,9 @@
 
 namespace WebCore {
 
-LayoutState::LayoutState(RenderElement& renderer)
+LayoutState::LayoutState(RenderElement& renderer, IsPaginated isPaginated)
     : m_clipped(false)
-    , m_isPaginated(false)
+    , m_isPaginated(isPaginated == IsPaginated::Yes)
     , m_pageLogicalHeightChanged(false)
 #if !ASSERT_DISABLED
     , m_layoutDeltaXSaturated(false)
@@ -57,6 +57,10 @@ LayoutState::LayoutState(RenderElement& renderer)
             m_paintOffset -= toLayoutSize(containerBox.scrollPosition());
         }
     }
+    if (m_isPaginated) {
+        // This is just a flag for known page height (see RenderBlockFlow::checkForPaginationLogicalHeightChange).
+        m_pageLogicalHeight = 1;
+    }
 }
 
 LayoutState::LayoutState(const LayoutContext::LayoutStateStack& layoutStateStack, RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged)
@@ -261,7 +265,7 @@ void LayoutState::addLayoutDelta(LayoutSize delta)
 }
 
 #if !ASSERT_DISABLED
-bool LayoutState::layoutDeltaMatches(LayoutSize delta)
+bool LayoutState::layoutDeltaMatches(LayoutSize delta) const
 {
     return (delta.width() == m_layoutDelta.width() || m_layoutDeltaXSaturated) && (delta.height() == m_layoutDelta.height() || m_layoutDeltaYSaturated);
 }
index 966b63b..6c2f84f 100644 (file)
@@ -54,16 +54,15 @@ public:
     {
     }
     LayoutState(const LayoutContext::LayoutStateStack&, RenderBox&, const LayoutSize& offset, LayoutUnit pageHeight, bool pageHeightChanged);
-    explicit LayoutState(RenderElement&);
+    enum class IsPaginated { No, Yes };
+    explicit LayoutState(RenderElement&, IsPaginated = IsPaginated::No);
 
     bool isPaginated() const { return m_isPaginated; }
-    void setIsPaginated() { m_isPaginated = true; }
 
     // The page logical offset is the object's offset from the top of the page in the page progression
     // direction (so an x-offset in vertical text and a y-offset for horizontal text).
     LayoutUnit pageLogicalOffset(RenderBox*, LayoutUnit childLogicalOffset) const;
     
-    void setPageLogicalHeight(LayoutUnit logicalHeight) { m_pageLogicalHeight = logicalHeight; }
     LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; }
     bool pageLogicalHeightChanged() const { return m_pageLogicalHeightChanged; }
 
@@ -87,7 +86,7 @@ public:
     void addLayoutDelta(LayoutSize);
     LayoutSize layoutDelta() const { return m_layoutDelta; }
 #if !ASSERT_DISABLED
-    bool layoutDeltaMatches(LayoutSize);
+    bool layoutDeltaMatches(LayoutSize) const;
 #endif
 
 private: