[New Multicolumn] Rename methods to prepare for proper pagination of columns
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2012 21:27:53 +0000 (21:27 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2012 21:27:53 +0000 (21:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=95375

Reviewed by Simon Fraser.

This patch is doing some renaming and refactoring to prepare for proper pagination of columns. Most of the renames
involve changing RenderFlowThread functions to exactly match the names of their RenderBlock callers. These names
end up being more accurate once the top of a page and remaining height on a page no longer have a 1:1 mapping to
the RenderRegion's dimensions.

The renames/additions include:
    renderRegionForLine -> regionAtBlockOffset
    Justification: The block method is already called regionAtBlockOffset. No lines are involved, so line was
    never the correct term to be passing in.

    regionLogicalXXXForLine -> pageLogicalXXXForOffset
    Justification: Matches the RenderBlock callers, and it's more accurate to talk in terms of "pages" now that
    we have RenderRegionSets that can contain multiple "pages" in a single region.

    logicalWidthForFlowThreadContent/logicalHeightForFlowThreadContent -> pageLogicalWidth/Height.
    Justification: Makes it more clear we're talking about the width and height of a single page/column rather
    than the width and height of the region itself.

    logicalHeightOfAllFlowThreadContent
    This method is new and represents the total flow thread logical height that is consumed by the region.
    It has to be distinguished from the pageLogicalHeight for a region since sets can have multiple pages/columns.

Note with this patch we're essentially adopting the convention used by all of the pagination code besides regions
of referring to anything we paginate as a "page." I continue to believe this is the simplest way to talk about
these objects in code that is generically dealing with all three (like the breaking code in RenderBlock).

Eventually we might adopt the fragment terminology in the latest CSS draft, in which case
RenderRegion would become RenderFragment, RenderFlowThread would become RenderFragmentedBlock, and uses of
the generic "page" would become "fragment" instead, but we'll wait for that draft's terminology to stabilize first
before switching away from the current names.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::hasNextPage):
(WebCore::RenderBlock::pageLogicalTopForOffset):
(WebCore::RenderBlock::pageLogicalHeightForOffset):
(WebCore::RenderBlock::pageRemainingLogicalHeightForOffset):
(WebCore::RenderBlock::regionAtBlockOffset):
* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::layout):
(WebCore::RenderFlowThread::computeLogicalWidth):
(WebCore::RenderFlowThread::computeLogicalHeight):
(WebCore::RenderFlowThread::regionAtBlockOffset):
(WebCore::RenderFlowThread::pageLogicalTopForOffset):
(WebCore::RenderFlowThread::pageLogicalWidthForOffset):
(WebCore::RenderFlowThread::pageLogicalHeightForOffset):
(WebCore::RenderFlowThread::pageRemainingLogicalHeightForOffset):
(WebCore::RenderFlowThread::mapFromFlowToRegion):
(WebCore::RenderFlowThread::setRegionRangeForBox):
* rendering/RenderFlowThread.h:
* rendering/RenderMultiColumnSet.h:
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::pageLogicalWidth):
(WebCore::RenderRegion::pageLogicalHeight):
(WebCore):
(WebCore::RenderRegion::logicalHeightOfAllFlowThreadContent):
(WebCore::RenderRegion::layout):
* rendering/RenderRegion.h:
(RenderRegion):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderFlowThread.h
Source/WebCore/rendering/RenderMultiColumnSet.h
Source/WebCore/rendering/RenderRegion.cpp
Source/WebCore/rendering/RenderRegion.h

index d78cd9a..a911188 100644 (file)
@@ -1,3 +1,69 @@
+2012-08-29  David Hyatt  <hyatt@apple.com>
+
+        [New Multicolumn] Rename methods to prepare for proper pagination of columns
+        https://bugs.webkit.org/show_bug.cgi?id=95375
+
+        Reviewed by Simon Fraser.
+
+        This patch is doing some renaming and refactoring to prepare for proper pagination of columns. Most of the renames
+        involve changing RenderFlowThread functions to exactly match the names of their RenderBlock callers. These names
+        end up being more accurate once the top of a page and remaining height on a page no longer have a 1:1 mapping to
+        the RenderRegion's dimensions.
+        
+        The renames/additions include:
+            renderRegionForLine -> regionAtBlockOffset
+            Justification: The block method is already called regionAtBlockOffset. No lines are involved, so line was
+            never the correct term to be passing in.
+            
+            regionLogicalXXXForLine -> pageLogicalXXXForOffset
+            Justification: Matches the RenderBlock callers, and it's more accurate to talk in terms of "pages" now that
+            we have RenderRegionSets that can contain multiple "pages" in a single region.
+            
+            logicalWidthForFlowThreadContent/logicalHeightForFlowThreadContent -> pageLogicalWidth/Height.
+            Justification: Makes it more clear we're talking about the width and height of a single page/column rather
+            than the width and height of the region itself.
+            
+            logicalHeightOfAllFlowThreadContent
+            This method is new and represents the total flow thread logical height that is consumed by the region.
+            It has to be distinguished from the pageLogicalHeight for a region since sets can have multiple pages/columns.
+
+        Note with this patch we're essentially adopting the convention used by all of the pagination code besides regions
+        of referring to anything we paginate as a "page." I continue to believe this is the simplest way to talk about
+        these objects in code that is generically dealing with all three (like the breaking code in RenderBlock).
+        Eventually we might adopt the fragment terminology in the latest CSS draft, in which case 
+        RenderRegion would become RenderFragment, RenderFlowThread would become RenderFragmentedBlock, and uses of
+        the generic "page" would become "fragment" instead, but we'll wait for that draft's terminology to stabilize first
+        before switching away from the current names.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::hasNextPage):
+        (WebCore::RenderBlock::pageLogicalTopForOffset):
+        (WebCore::RenderBlock::pageLogicalHeightForOffset):
+        (WebCore::RenderBlock::pageRemainingLogicalHeightForOffset):
+        (WebCore::RenderBlock::regionAtBlockOffset):
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::layout):
+        (WebCore::RenderFlowThread::computeLogicalWidth):
+        (WebCore::RenderFlowThread::computeLogicalHeight):
+        (WebCore::RenderFlowThread::regionAtBlockOffset):
+        (WebCore::RenderFlowThread::pageLogicalTopForOffset):
+        (WebCore::RenderFlowThread::pageLogicalWidthForOffset):
+        (WebCore::RenderFlowThread::pageLogicalHeightForOffset):
+        (WebCore::RenderFlowThread::pageRemainingLogicalHeightForOffset):
+        (WebCore::RenderFlowThread::mapFromFlowToRegion):
+        (WebCore::RenderFlowThread::setRegionRangeForBox):
+        * rendering/RenderFlowThread.h:
+        * rendering/RenderMultiColumnSet.h:
+        * rendering/RenderRegion.cpp:
+        (WebCore::RenderRegion::pageLogicalWidth):
+        (WebCore::RenderRegion::pageLogicalHeight):
+        (WebCore):
+        (WebCore::RenderRegion::logicalHeightOfAllFlowThreadContent):
+        (WebCore::RenderRegion::layout):
+        * rendering/RenderRegion.h:
+        (RenderRegion):
+
 2012-08-29  David Grogan  <dgrogan@chromium.org>
 
         IndexedDB: Throw TypeError for invalid version parameters
index d79d1e0..a6a9f2e 100755 (executable)
@@ -6876,7 +6876,7 @@ bool RenderBlock::hasNextPage(LayoutUnit logicalOffset, PageBoundaryRule pageBou
 
     // See if we're in the last region.
     LayoutUnit pageOffset = offsetFromLogicalTopOfFirstPage() + logicalOffset;
-    RenderRegion* region = enclosingRenderFlowThread()->renderRegionForLine(pageOffset, this);
+    RenderRegion* region = enclosingRenderFlowThread()->regionAtBlockOffset(pageOffset, this);
     if (!region)
         return false;
     if (region->isLastRegion())
@@ -6963,7 +6963,7 @@ LayoutUnit RenderBlock::pageLogicalTopForOffset(LayoutUnit offset) const
             return 0;
         return cumulativeOffset - roundToInt(cumulativeOffset - firstPageLogicalTop) % roundToInt(pageLogicalHeight);
     }
-    return enclosingRenderFlowThread()->regionLogicalTopForLine(cumulativeOffset);
+    return enclosingRenderFlowThread()->pageLogicalTopForOffset(cumulativeOffset);
 }
 
 LayoutUnit RenderBlock::pageLogicalHeightForOffset(LayoutUnit offset) const
@@ -6971,7 +6971,7 @@ LayoutUnit RenderBlock::pageLogicalHeightForOffset(LayoutUnit offset) const
     RenderView* renderView = view();
     if (!inRenderFlowThread())
         return renderView->layoutState()->m_pageLogicalHeight;
-    return enclosingRenderFlowThread()->regionLogicalHeightForLine(offset + offsetFromLogicalTopOfFirstPage());
+    return enclosingRenderFlowThread()->pageLogicalHeightForOffset(offset + offsetFromLogicalTopOfFirstPage());
 }
 
 LayoutUnit RenderBlock::pageRemainingLogicalHeightForOffset(LayoutUnit offset, PageBoundaryRule pageBoundaryRule) const
@@ -6990,7 +6990,7 @@ LayoutUnit RenderBlock::pageRemainingLogicalHeightForOffset(LayoutUnit offset, P
         return remainingHeight;
     }
     
-    return enclosingRenderFlowThread()->regionRemainingLogicalHeightForLine(offset, pageBoundaryRule);
+    return enclosingRenderFlowThread()->pageRemainingLogicalHeightForOffset(offset, pageBoundaryRule);
 }
 
 LayoutUnit RenderBlock::adjustForUnsplittableChild(RenderBox* child, LayoutUnit logicalOffset, bool includeMargins)
@@ -7197,7 +7197,7 @@ RenderRegion* RenderBlock::regionAtBlockOffset(LayoutUnit blockOffset) const
     if (!flowThread || !flowThread->hasValidRegionInfo())
         return 0;
 
-    return flowThread->renderRegionForLine(offsetFromLogicalTopOfFirstPage() + blockOffset, true);
+    return flowThread->regionAtBlockOffset(offsetFromLogicalTopOfFirstPage() + blockOffset, true);
 }
 
 void RenderBlock::setStaticInlinePositionForChild(RenderBox* child, LayoutUnit blockOffset, LayoutUnit inlinePosition)
index bba8bf5..fd31a0f 100644 (file)
@@ -150,8 +150,8 @@ void RenderFlowThread::layout()
                 
                 region->deleteAllRenderBoxRegionInfo();
 
-                LayoutUnit regionLogicalWidth = region->logicalWidthForFlowThreadContent();
-                LayoutUnit regionLogicalHeight = region->logicalHeightForFlowThreadContent();
+                LayoutUnit regionLogicalWidth = region->pageLogicalWidth();
+                LayoutUnit regionLogicalHeight = region->pageLogicalHeight();
 
                 if (!m_hasValidRegions)
                     m_hasValidRegions = true;
@@ -173,8 +173,8 @@ void RenderFlowThread::layout()
                 if (!region->isValid())
                     continue;
                     
-                LayoutUnit regionLogicalWidth = region->logicalWidthForFlowThreadContent();
-                LayoutUnit regionLogicalHeight = region->logicalHeightForFlowThreadContent();
+                LayoutUnit regionLogicalWidth = region->pageLogicalWidth();
+                LayoutUnit regionLogicalHeight = region->logicalHeightOfAllFlowThreadContent();
     
                 LayoutRect regionRect(style()->direction() == LTR ? ZERO_LAYOUT_UNIT : logicalWidth() - regionLogicalWidth, logicalHeight, regionLogicalWidth, regionLogicalHeight);
                 region->setFlowThreadPortionRect(isHorizontalWritingMode() ? regionRect : regionRect.transposedRect());
@@ -203,7 +203,7 @@ void RenderFlowThread::computeLogicalWidth()
         if (!region->isValid())
             continue;
         ASSERT(!region->needsLayout());
-        logicalWidth = max(region->logicalWidthForFlowThreadContent(), logicalWidth);
+        logicalWidth = max(region->pageLogicalWidth(), logicalWidth);
     }
     setLogicalWidth(logicalWidth);
 
@@ -213,7 +213,7 @@ void RenderFlowThread::computeLogicalWidth()
         if (!region->isValid())
             continue;
         
-        LayoutUnit regionLogicalWidth = region->logicalWidthForFlowThreadContent();
+        LayoutUnit regionLogicalWidth = region->pageLogicalWidth();
         if (regionLogicalWidth != logicalWidth) {
             LayoutUnit logicalLeft = style()->direction() == LTR ? ZERO_LAYOUT_UNIT : logicalWidth - regionLogicalWidth;
             region->setRenderBoxRegionInfo(this, logicalLeft, regionLogicalWidth, false);
@@ -230,7 +230,7 @@ void RenderFlowThread::computeLogicalHeight()
         if (!region->isValid())
             continue;
         ASSERT(!region->needsLayout());
-        logicalHeight += region->logicalHeightForFlowThreadContent();
+        logicalHeight += region->logicalHeightOfAllFlowThreadContent();
     }
 
     setLogicalHeight(logicalHeight);
@@ -346,7 +346,7 @@ void RenderFlowThread::repaintRectangleInRegions(const LayoutRect& repaintRect,
     }
 }
 
-RenderRegion* RenderFlowThread::renderRegionForLine(LayoutUnit position, bool extendLastRegion) const
+RenderRegion* RenderFlowThread::regionAtBlockOffset(LayoutUnit offset, bool extendLastRegion) const
 {
     ASSERT(!m_regionsInvalidated);
 
@@ -361,12 +361,12 @@ RenderRegion* RenderFlowThread::renderRegionForLine(LayoutUnit position, bool ex
         if (!region->isValid())
             continue;
 
-        if (position <= 0)
+        if (offset <= 0)
             return region;
 
         LayoutRect regionRect = region->flowThreadPortionRect();
 
-        if ((useHorizontalWritingMode && position < regionRect.maxY()) || (!useHorizontalWritingMode && position < regionRect.maxX()))
+        if ((useHorizontalWritingMode && offset < regionRect.maxY()) || (!useHorizontalWritingMode && offset < regionRect.maxX()))
             return region;
 
         if (extendLastRegion)
@@ -376,38 +376,34 @@ RenderRegion* RenderFlowThread::renderRegionForLine(LayoutUnit position, bool ex
     return lastValidRegion;
 }
 
-LayoutUnit RenderFlowThread::regionLogicalTopForLine(LayoutUnit position) const
+LayoutUnit RenderFlowThread::pageLogicalTopForOffset(LayoutUnit offset) const
 {
-    RenderRegion* region = renderRegionForLine(position);
+    RenderRegion* region = regionAtBlockOffset(offset);
     if (!region)
-        return 0;
+        return ZERO_LAYOUT_UNIT;
     return isHorizontalWritingMode() ? region->flowThreadPortionRect().y() : region->flowThreadPortionRect().x();
 }
 
-LayoutUnit RenderFlowThread::regionLogicalWidthForLine(LayoutUnit position) const
+LayoutUnit RenderFlowThread::pageLogicalWidthForOffset(LayoutUnit offset) const
 {
-    RenderRegion* region = renderRegionForLine(position, true);
-    if (!region)
-        return contentLogicalWidth();
-    return isHorizontalWritingMode() ? region->flowThreadPortionRect().width() : region->flowThreadPortionRect().height();
+    RenderRegion* region = regionAtBlockOffset(offset, true);
+    return region ? region->pageLogicalWidth() : contentLogicalWidth();
 }
 
-LayoutUnit RenderFlowThread::regionLogicalHeightForLine(LayoutUnit position) const
+LayoutUnit RenderFlowThread::pageLogicalHeightForOffset(LayoutUnit offset) const
 {
-    RenderRegion* region = renderRegionForLine(position);
-    if (!region)
-        return 0;
-    return isHorizontalWritingMode() ? region->flowThreadPortionRect().height() : region->flowThreadPortionRect().width();
+    RenderRegion* region = regionAtBlockOffset(offset);
+    return region ? region->pageLogicalHeight() : ZERO_LAYOUT_UNIT;
 }
 
-LayoutUnit RenderFlowThread::regionRemainingLogicalHeightForLine(LayoutUnit position, PageBoundaryRule pageBoundaryRule) const
+LayoutUnit RenderFlowThread::pageRemainingLogicalHeightForOffset(LayoutUnit offset, PageBoundaryRule pageBoundaryRule) const
 {
-    RenderRegion* region = renderRegionForLine(position);
+    RenderRegion* region = regionAtBlockOffset(offset);
     if (!region)
-        return 0;
+        return ZERO_LAYOUT_UNIT;
 
     LayoutUnit regionLogicalBottom = isHorizontalWritingMode() ? region->flowThreadPortionRect().maxY() : region->flowThreadPortionRect().maxX();
-    LayoutUnit remainingHeight = regionLogicalBottom - position;
+    LayoutUnit remainingHeight = regionLogicalBottom - offset;
     if (pageBoundaryRule == IncludePageBoundary) {
         // If IncludePageBoundary is set, the line exactly on the top edge of a
         // region will act as being part of the previous region.
@@ -430,7 +426,7 @@ RenderRegion* RenderFlowThread::mapFromFlowToRegion(TransformState& transformSta
     // Note: Using the center in order to avoid rounding errors.
 
     LayoutPoint center = boxRect.center();
-    RenderRegion* renderRegion = renderRegionForLine(isHorizontalWritingMode() ? center.y() : center.x(), true);
+    RenderRegion* renderRegion = regionAtBlockOffset(isHorizontalWritingMode() ? center.y() : center.x(), true);
     if (!renderRegion)
         return 0;
 
@@ -606,8 +602,8 @@ void RenderFlowThread::setRegionRangeForBox(const RenderBox* box, LayoutUnit off
         return;
 
     // FIXME: Not right for differing writing-modes.
-    RenderRegion* startRegion = renderRegionForLine(offsetFromLogicalTopOfFirstPage, true);
-    RenderRegion* endRegion = renderRegionForLine(offsetFromLogicalTopOfFirstPage + box->logicalHeight(), true);
+    RenderRegion* startRegion = regionAtBlockOffset(offsetFromLogicalTopOfFirstPage, true);
+    RenderRegion* endRegion = regionAtBlockOffset(offsetFromLogicalTopOfFirstPage + box->logicalHeight(), true);
     RenderRegionRangeMap::iterator it = m_regionRangeMap.find(box);
     if (it == m_regionRangeMap.end()) {
         m_regionRangeMap.set(box, RenderRegionRange(startRegion, endRegion));
index 6ded942..b7db834 100644 (file)
@@ -94,11 +94,11 @@ public:
 
     void repaintRectangleInRegions(const LayoutRect&, bool immediate);
 
-    LayoutUnit regionLogicalTopForLine(LayoutUnit position) const;
-    LayoutUnit regionLogicalWidthForLine(LayoutUnit position) const;
-    LayoutUnit regionLogicalHeightForLine(LayoutUnit position) const;
-    LayoutUnit regionRemainingLogicalHeightForLine(LayoutUnit position, PageBoundaryRule = IncludePageBoundary) const;
-    RenderRegion* renderRegionForLine(LayoutUnit position, bool extendLastRegion = false) const;
+    LayoutUnit pageLogicalTopForOffset(LayoutUnit) const;
+    LayoutUnit pageLogicalWidthForOffset(LayoutUnit) const;
+    LayoutUnit pageLogicalHeightForOffset(LayoutUnit) const;
+    LayoutUnit pageRemainingLogicalHeightForOffset(LayoutUnit, PageBoundaryRule = IncludePageBoundary) const;
+    RenderRegion* regionAtBlockOffset(LayoutUnit, bool extendLastRegion = false) const;
 
     bool regionsHaveUniformLogicalWidth() const { return m_regionsHaveUniformLogicalWidth; }
     bool regionsHaveUniformLogicalHeight() const { return m_regionsHaveUniformLogicalHeight; }
index bb3b0e3..58e2d53 100644 (file)
@@ -68,9 +68,12 @@ private:
     virtual void paintReplaced(PaintInfo&, const LayoutPoint& paintOffset) OVERRIDE;
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
 
-    virtual LayoutUnit logicalWidthForFlowThreadContent() const OVERRIDE { return m_computedColumnWidth; }
-    virtual LayoutUnit logicalHeightForFlowThreadContent() const OVERRIDE { return m_computedColumnHeight; } // FIXME: Will be wrong once we have multiple sets.
+    virtual LayoutUnit pageLogicalWidth() const OVERRIDE { return m_computedColumnWidth; }
+    virtual LayoutUnit pageLogicalHeight() const OVERRIDE { return m_computedColumnHeight; }
 
+    // FIXME: This will change once we have column sets constrained by enclosing pages, etc.
+    virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const OVERRIDE { return m_computedColumnHeight; }
+    
     virtual const char* renderName() const;
     
     void paintColumnRules(PaintInfo&, const LayoutPoint& paintOffset);
index 13299ec..e22f199 100644 (file)
@@ -52,12 +52,17 @@ RenderRegion::RenderRegion(Node* node, RenderFlowThread* flowThread)
 {
 }
 
-LayoutUnit RenderRegion::logicalWidthForFlowThreadContent() const
+LayoutUnit RenderRegion::pageLogicalWidth() const
 {
     return m_flowThread->isHorizontalWritingMode() ? contentWidth() : contentHeight();
 }
 
-LayoutUnit RenderRegion::logicalHeightForFlowThreadContent() const
+LayoutUnit RenderRegion::pageLogicalHeight() const
+{
+    return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
+}
+
+LayoutUnit RenderRegion::logicalHeightOfAllFlowThreadContent() const
 {
     return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
 }
@@ -181,7 +186,7 @@ void RenderRegion::layout()
         LayoutRect oldRegionRect(flowThreadPortionRect());
         if (!isHorizontalWritingMode())
             oldRegionRect = oldRegionRect.transposedRect();
-        if (oldRegionRect.width() != logicalWidthForFlowThreadContent() || oldRegionRect.height() != logicalHeightForFlowThreadContent())
+        if (oldRegionRect.width() != pageLogicalWidth() || oldRegionRect.height() != logicalHeightOfAllFlowThreadContent())
             m_flowThread->invalidateRegions();
     }
 
index ff1820b..1275917 100644 (file)
@@ -95,9 +95,17 @@ public:
     RegionState regionState() const { return isValid() ? m_regionState : RegionUndefined; }
     void setRegionState(RegionState regionState) { m_regionState = regionState; }
     
-    virtual LayoutUnit logicalWidthForFlowThreadContent() const;
-    virtual LayoutUnit logicalHeightForFlowThreadContent() const;
-        
+    // These methods represent the width and height of a "page" and for a RenderRegion they are just the
+    // content width and content height of a region. For RenderRegionSets, however, they will be the width and
+    // height of a single column or page in the set.
+    virtual LayoutUnit pageLogicalWidth() const;
+    virtual LayoutUnit pageLogicalHeight() const;
+    
+    // This method represents the logical height of the entire flow thread portion used by the region or set.
+    // For RenderRegions it matches logicalPaginationHeight(), but for sets it is the height of all the pages
+    // or columns added together.
+    virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const;
+
     virtual void expandToEncompassFlowThreadContentsIfNeeded() {};
 
 protected: