Title: [224616] trunk/Source/WebCore
Revision
224616
Author
[email protected]
Date
2017-11-08 20:57:38 -0800 (Wed, 08 Nov 2017)

Log Message

[LayoutState cleanup] Move RenderMultiColumnFlow::computeLineGridPaginationOrigin to LayoutState
https://bugs.webkit.org/show_bug.cgi?id=179462

Reviewed by Antti Koivisto.

This is in preparation for having no setters on LayoutState.
Having all the related functions (pagination/line-grid) in one place also helps with moving
them to a more appropriate place later.

No change in functionality.

* rendering/LayoutState.cpp:
(WebCore::LayoutState::computePaginationInformation):
(WebCore::LayoutState::computeLineGridPaginationOrigin):
(WebCore::LayoutState::establishLineGrid):
* rendering/LayoutState.h:
(WebCore::LayoutState::setLineGridPaginationOrigin): Deleted.
(WebCore::LayoutState::currentRenderFragmentedFlow const): Deleted.
(WebCore::LayoutState::setCurrentRenderFragmentedFlow): Deleted.
* rendering/RenderMultiColumnFlow.cpp:
(WebCore::RenderMultiColumnFlow::computeLineGridPaginationOrigin const): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (224615 => 224616)


--- trunk/Source/WebCore/ChangeLog	2017-11-09 03:55:05 UTC (rev 224615)
+++ trunk/Source/WebCore/ChangeLog	2017-11-09 04:57:38 UTC (rev 224616)
@@ -1,3 +1,27 @@
+2017-11-08  Zalan Bujtas  <[email protected]>
+
+        [LayoutState cleanup] Move RenderMultiColumnFlow::computeLineGridPaginationOrigin to LayoutState
+        https://bugs.webkit.org/show_bug.cgi?id=179462
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for having no setters on LayoutState.
+        Having all the related functions (pagination/line-grid) in one place also helps with moving
+        them to a more appropriate place later.
+
+        No change in functionality.
+
+        * rendering/LayoutState.cpp:
+        (WebCore::LayoutState::computePaginationInformation):
+        (WebCore::LayoutState::computeLineGridPaginationOrigin):
+        (WebCore::LayoutState::establishLineGrid):
+        * rendering/LayoutState.h:
+        (WebCore::LayoutState::setLineGridPaginationOrigin): Deleted.
+        (WebCore::LayoutState::currentRenderFragmentedFlow const): Deleted.
+        (WebCore::LayoutState::setCurrentRenderFragmentedFlow): Deleted.
+        * rendering/RenderMultiColumnFlow.cpp:
+        (WebCore::RenderMultiColumnFlow::computeLineGridPaginationOrigin const): Deleted.
+
 2017-11-08  Jiewen Tan  <[email protected]>
 
         Replace some stack raw pointers with RefPtrs within WebCore/svg

Modified: trunk/Source/WebCore/rendering/LayoutState.cpp (224615 => 224616)


--- trunk/Source/WebCore/rendering/LayoutState.cpp	2017-11-09 03:55:05 UTC (rev 224615)
+++ trunk/Source/WebCore/rendering/LayoutState.cpp	2017-11-09 04:57:38 UTC (rev 224616)
@@ -157,7 +157,7 @@
         propagateLineGridInfo(*ancestor, renderer);
 
     if (lineGrid() && (lineGrid()->style().writingMode() == renderer.style().writingMode()) && is<RenderMultiColumnFlow>(renderer))
-        downcast<RenderMultiColumnFlow>(renderer).computeLineGridPaginationOrigin(*this);
+        computeLineGridPaginationOrigin(downcast<RenderMultiColumnFlow>(renderer));
 
     // If we have a new grid to track, then add it to our set.
     if (renderer.style().lineGrid() != RenderStyle::initialLineGrid() && is<RenderBlockFlow>(renderer))
@@ -171,6 +171,47 @@
     return m_layoutOffset.width() + childLogicalOffset - m_pageOffset.width();
 }
 
+void LayoutState::computeLineGridPaginationOrigin(const RenderMultiColumnFlow& multicol)
+{
+    if (!isPaginated() || !pageLogicalHeight())
+        return;
+
+    if (!multicol.progressionIsInline())
+        return;
+    // We need to cache a line grid pagination origin so that we understand how to reset the line grid
+    // at the top of each column.
+    // Get the current line grid and offset.
+    ASSERT(m_lineGrid);
+    // Get the hypothetical line box used to establish the grid.
+    auto* lineGridBox = m_lineGrid->lineGridBox();
+    if (!lineGridBox)
+        return;
+
+    // Now determine our position on the grid. Our baseline needs to be adjusted to the nearest baseline multiple
+    // as established by the line box.
+    // FIXME: Need to handle crazy line-box-contain values that cause the root line box to not be considered. I assume
+    // the grid should honor line-box-contain.
+    LayoutUnit gridLineHeight = lineGridBox->lineBottomWithLeading() - lineGridBox->lineTopWithLeading();
+    if (!gridLineHeight)
+        return;
+
+    bool isHorizontalWritingMode = m_lineGrid->isHorizontalWritingMode();
+    LayoutUnit lineGridBlockOffset = isHorizontalWritingMode ? m_lineGridOffset.height() : m_lineGridOffset.width();
+    LayoutUnit firstLineTopWithLeading = lineGridBlockOffset + lineGridBox->lineTopWithLeading();
+    LayoutUnit pageLogicalTop = isHorizontalWritingMode ? m_pageOffset.height() : m_pageOffset.width();
+    if (pageLogicalTop <= firstLineTopWithLeading)
+        return;
+
+    // Shift to the next highest line grid multiple past the page logical top. Cache the delta
+    // between this new value and the page logical top as the pagination origin.
+    LayoutUnit remainder = roundToInt(pageLogicalTop - firstLineTopWithLeading) % roundToInt(gridLineHeight);
+    LayoutUnit paginationDelta = gridLineHeight - remainder;
+    if (isHorizontalWritingMode)
+        m_lineGridPaginationOrigin.setHeight(paginationDelta);
+    else
+        m_lineGridPaginationOrigin.setWidth(paginationDelta);
+}
+
 void LayoutState::propagateLineGridInfo(const LayoutState& ancestor, RenderBox& renderer)
 {
     // Disable line grids for objects we don't support. For now this includes overflow:scroll/auto, inline blocks and
@@ -185,7 +226,6 @@
 
 void LayoutState::establishLineGrid(const LayoutContext::LayoutStateStack& layoutStateStack, RenderBlockFlow& renderer)
 {
-    // FIXME: webkit.org/b/179440 This logic should be part of the LayoutContext.
     // First check to see if this grid has been established already.
     if (m_lineGrid) {
         if (m_lineGrid->style().lineGrid() == renderer.style().lineGrid())

Modified: trunk/Source/WebCore/rendering/LayoutState.h (224615 => 224616)


--- trunk/Source/WebCore/rendering/LayoutState.h	2017-11-09 03:55:05 UTC (rev 224615)
+++ trunk/Source/WebCore/rendering/LayoutState.h	2017-11-09 04:57:38 UTC (rev 224616)
@@ -36,6 +36,7 @@
 class RenderBox;
 class RenderElement;
 class RenderFragmentedFlow;
+class RenderMultiColumnFlow;
 class RenderObject;
 
 class LayoutState {
@@ -74,12 +75,9 @@
     LayoutSize layoutOffset() const { return m_layoutOffset; }
 
     LayoutSize pageOffset() const { return m_pageOffset; }
-    void setLineGridPaginationOrigin(const LayoutSize& origin) { m_lineGridPaginationOrigin = origin; }
-    
+
     bool needsBlockDirectionLocationSetBeforeLayout() const { return m_lineGrid || (m_isPaginated && m_pageLogicalHeight); }
 
-    RenderFragmentedFlow* currentRenderFragmentedFlow() const { return m_currentRenderFragmentedFlow; }
-    void setCurrentRenderFragmentedFlow(RenderFragmentedFlow* fragmentedFlow) { m_currentRenderFragmentedFlow = fragmentedFlow; }
 #ifndef NDEBUG
     RenderElement* renderer() const { return m_renderer; }
 #endif
@@ -95,9 +93,11 @@
 private:
     void computeOffsets(const LayoutState& ancestor, RenderBox&, LayoutSize offset);
     void computeClipRect(const LayoutState& ancestor, RenderBox&);
+    // FIXME: webkit.org/b/179440 these functions should be part of the pagination code/LayoutContext.
     void computePaginationInformation(const LayoutContext::LayoutStateStack&, RenderBox&, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged);
     void propagateLineGridInfo(const LayoutState& ancestor, RenderBox&);
     void establishLineGrid(const LayoutContext::LayoutStateStack&, RenderBlockFlow&);
+    void computeLineGridPaginationOrigin(const RenderMultiColumnFlow&);
 
     // Do not add anything apart from bitfields. See https://bugs.webkit.org/show_bug.cgi?id=100173
     bool m_clipped : 1;
@@ -130,8 +130,6 @@
     LayoutSize m_pageOffset;
     LayoutSize m_lineGridOffset;
     LayoutSize m_lineGridPaginationOrigin;
-
-    RenderFragmentedFlow* m_currentRenderFragmentedFlow { nullptr };
 #ifndef NDEBUG
     RenderElement* m_renderer { nullptr };
 #endif

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlow.cpp (224615 => 224616)


--- trunk/Source/WebCore/rendering/RenderMultiColumnFlow.cpp	2017-11-09 03:55:05 UTC (rev 224615)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnFlow.cpp	2017-11-09 04:57:38 UTC (rev 224616)
@@ -543,52 +543,6 @@
     return false;
 }
 
-void RenderMultiColumnFlow::computeLineGridPaginationOrigin(LayoutState& layoutState) const
-{
-    if (!progressionIsInline())
-        return;
-    
-    // We need to cache a line grid pagination origin so that we understand how to reset the line grid
-    // at the top of each column.
-    // Get the current line grid and offset.
-    const auto lineGrid = layoutState.lineGrid();
-    if (!lineGrid)
-        return;
-
-    // Get the hypothetical line box used to establish the grid.
-    auto lineGridBox = lineGrid->lineGridBox();
-    if (!lineGridBox)
-        return;
-    
-    bool isHorizontalWritingMode = lineGrid->isHorizontalWritingMode();
-
-    LayoutUnit lineGridBlockOffset = isHorizontalWritingMode ? layoutState.lineGridOffset().height() : layoutState.lineGridOffset().width();
-
-    // Now determine our position on the grid. Our baseline needs to be adjusted to the nearest baseline multiple
-    // as established by the line box.
-    // FIXME: Need to handle crazy line-box-contain values that cause the root line box to not be considered. I assume
-    // the grid should honor line-box-contain.
-    LayoutUnit gridLineHeight = lineGridBox->lineBottomWithLeading() - lineGridBox->lineTopWithLeading();
-    if (!gridLineHeight)
-        return;
-
-    LayoutUnit firstLineTopWithLeading = lineGridBlockOffset + lineGridBox->lineTopWithLeading();
-    
-    if (layoutState.isPaginated() && layoutState.pageLogicalHeight()) {
-        LayoutUnit pageLogicalTop = isHorizontalWritingMode ? layoutState.pageOffset().height() : layoutState.pageOffset().width();
-        if (pageLogicalTop > firstLineTopWithLeading) {
-            // Shift to the next highest line grid multiple past the page logical top. Cache the delta
-            // between this new value and the page logical top as the pagination origin.
-            LayoutUnit remainder = roundToInt(pageLogicalTop - firstLineTopWithLeading) % roundToInt(gridLineHeight);
-            LayoutUnit paginationDelta = gridLineHeight - remainder;
-            if (isHorizontalWritingMode)
-                layoutState.setLineGridPaginationOrigin(LayoutSize(layoutState.lineGridPaginationOrigin().width(), paginationDelta));
-            else
-                layoutState.setLineGridPaginationOrigin(LayoutSize(paginationDelta, layoutState.lineGridPaginationOrigin().height()));
-        }
-    }
-}
-
 LayoutSize RenderMultiColumnFlow::offsetFromContainer(RenderElement& enclosingContainer, const LayoutPoint& physicalPoint, bool* offsetDependsOnPoint) const
 {
     ASSERT(&enclosingContainer == container());

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnFlow.h (224615 => 224616)


--- trunk/Source/WebCore/rendering/RenderMultiColumnFlow.h	2017-11-09 03:55:05 UTC (rev 224615)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnFlow.h	2017-11-09 04:57:38 UTC (rev 224616)
@@ -75,8 +75,6 @@
     bool progressionIsReversed() const { return m_progressionIsReversed; }
     void setProgressionIsReversed(bool reversed) { m_progressionIsReversed = reversed; }
     
-    void computeLineGridPaginationOrigin(LayoutState&) const;
-    
     RenderFragmentContainer* mapFromFlowToFragment(TransformState&) const override;
     
     // This method takes a logical offset and returns a physical translation that can be applied to map
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to