Title: [164837] trunk/Source/WebCore
Revision
164837
Author
stav...@adobe.com
Date
2014-02-27 15:52:23 -0800 (Thu, 27 Feb 2014)

Log Message

[CSS Regions] Move named-flow specific method decorationsClipRectForBoxInRegion to RenderNamedFlowThread
https://bugs.webkit.org/show_bug.cgi?id=129428

Reviewed by Andreas Kling.

Since the decorationsClipRectForBoxInRegion method is a named flow specific method, it makes
sense to be in the named flow specific class, RenderNamedFlowThread, instead of the more
generic RenderFlowThread.

No new tests required. No new functionality.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintObject):
* rendering/RenderFlowThread.cpp:
* rendering/RenderFlowThread.h:
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::decorationsClipRectForBoxInNamedFlowFragment):
* rendering/RenderNamedFlowThread.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (164836 => 164837)


--- trunk/Source/WebCore/ChangeLog	2014-02-27 23:36:23 UTC (rev 164836)
+++ trunk/Source/WebCore/ChangeLog	2014-02-27 23:52:23 UTC (rev 164837)
@@ -1,3 +1,24 @@
+2014-02-27  Radu Stavila  <stav...@adobe.com>
+
+        [CSS Regions] Move named-flow specific method decorationsClipRectForBoxInRegion to RenderNamedFlowThread
+        https://bugs.webkit.org/show_bug.cgi?id=129428
+
+        Reviewed by Andreas Kling.
+
+        Since the decorationsClipRectForBoxInRegion method is a named flow specific method, it makes
+        sense to be in the named flow specific class, RenderNamedFlowThread, instead of the more
+        generic RenderFlowThread.
+
+        No new tests required. No new functionality.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paintObject):
+        * rendering/RenderFlowThread.cpp:
+        * rendering/RenderFlowThread.h:
+        * rendering/RenderNamedFlowThread.cpp:
+        (WebCore::RenderNamedFlowThread::decorationsClipRectForBoxInNamedFlowFragment):
+        * rendering/RenderNamedFlowThread.h:
+
 2014-02-27  Zoltan Horvath  <zol...@webkit.org>
 
         Avoid calling logicalLeftOffsetForLine 2 times in LineWidth::fitBelowFloats

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (164836 => 164837)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2014-02-27 23:36:23 UTC (rev 164836)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2014-02-27 23:52:23 UTC (rev 164837)
@@ -2301,7 +2301,7 @@
         if (hasBoxDecorations()) {
             bool didClipToRegion = false;
             
-            if (paintInfo.paintContainer && paintInfo.renderNamedFlowFragment && paintInfo.paintContainer->isRenderFlowThread()) {
+            if (paintInfo.paintContainer && paintInfo.renderNamedFlowFragment && paintInfo.paintContainer->isRenderNamedFlowThread()) {
                 // If this box goes beyond the current region, then make sure not to overflow the region.
                 // This (overflowing region X altough also fragmented to region X+1) could happen when one of this box's children
                 // overflows region X and is an unsplittable element (like an image).
@@ -2310,7 +2310,7 @@
                 paintInfo.context->save();
                 didClipToRegion = true;
 
-                paintInfo.context->clip(toRenderFlowThread(paintInfo.paintContainer)->decorationsClipRectForBoxInRegion(*this, *paintInfo.renderNamedFlowFragment));
+                paintInfo.context->clip(toRenderNamedFlowThread(paintInfo.paintContainer)->decorationsClipRectForBoxInNamedFlowFragment(*this, *paintInfo.renderNamedFlowFragment));
             }
 
             paintBoxDecorations(paintInfo, paintOffset);

Modified: trunk/Source/WebCore/rendering/RenderFlowThread.cpp (164836 => 164837)


--- trunk/Source/WebCore/rendering/RenderFlowThread.cpp	2014-02-27 23:36:23 UTC (rev 164836)
+++ trunk/Source/WebCore/rendering/RenderFlowThread.cpp	2014-02-27 23:52:23 UTC (rev 164837)
@@ -1262,76 +1262,6 @@
     return localRect;
 }
 
-LayoutRect RenderFlowThread::decorationsClipRectForBoxInRegion(const RenderBox& box, RenderRegion& region) const
-{
-    LayoutRect visualOverflowRect = region.visualOverflowRectForBox(&box);
-    LayoutUnit initialLogicalX = style().isHorizontalWritingMode() ? visualOverflowRect.x() : visualOverflowRect.y();
-
-    // The visual overflow rect returned by visualOverflowRectForBox is already flipped but the
-    // RenderRegion::rectFlowPortionForBox method expects it unflipped.
-    flipForWritingModeLocalCoordinates(visualOverflowRect);
-    visualOverflowRect = region.rectFlowPortionForBox(&box, visualOverflowRect);
-    
-    // Now flip it again.
-    flipForWritingModeLocalCoordinates(visualOverflowRect);
-    
-    // Layers are in physical coordinates so the origin must be moved to the physical top-left of the flowthread.
-    if (style().isFlippedBlocksWritingMode()) {
-        if (style().isHorizontalWritingMode())
-            visualOverflowRect.moveBy(LayoutPoint(0, height()));
-        else
-            visualOverflowRect.moveBy(LayoutPoint(width(), 0));
-    }
-
-    const RenderBox* iterBox = &box;
-    while (iterBox && iterBox != this) {
-        RenderBlock* containerBlock = iterBox->containingBlock();
-
-        // FIXME: This doesn't work properly with flipped writing modes.
-        // https://bugs.webkit.org/show_bug.cgi?id=125149
-        if (iterBox->isPositioned()) {
-            // For positioned elements, just use the layer's absolute bounding box.
-            visualOverflowRect.moveBy(iterBox->layer()->absoluteBoundingBox().location());
-            break;
-        }
-
-        LayoutRect currentBoxRect = iterBox->frameRect();
-        if (iterBox->style().isFlippedBlocksWritingMode()) {
-            if (iterBox->style().isHorizontalWritingMode())
-                currentBoxRect.setY(currentBoxRect.height() - currentBoxRect.maxY());
-            else
-                currentBoxRect.setX(currentBoxRect.width() - currentBoxRect.maxX());
-        }
-
-        if (containerBlock->style().writingMode() != iterBox->style().writingMode())
-            iterBox->flipForWritingMode(currentBoxRect);
-
-        visualOverflowRect.moveBy(currentBoxRect.location());
-        iterBox = containerBlock;
-    }
-
-    // Since the purpose of this method is to make sure the borders of a fragmented
-    // element don't overflow the region in the fragmentation direction, there's no
-    // point in restricting the clipping rect on the logical X axis. 
-    // This also saves us the trouble of handling percent-based widths and margins
-    // since the absolute bounding box of a positioned element would not contain
-    // the correct coordinates relative to the region we're interested in, but rather
-    // relative to the actual flow thread.
-    if (style().isHorizontalWritingMode()) {
-        if (initialLogicalX < visualOverflowRect.x())
-            visualOverflowRect.shiftXEdgeTo(initialLogicalX);
-        if (visualOverflowRect.width() < frameRect().width())
-            visualOverflowRect.setWidth(frameRect().width());
-    } else {
-        if (initialLogicalX < visualOverflowRect.y())
-            visualOverflowRect.shiftYEdgeTo(initialLogicalX);
-        if (visualOverflowRect.height() < frameRect().height())
-            visualOverflowRect.setHeight(frameRect().height());
-    }
-
-    return visualOverflowRect;
-}
-
 void RenderFlowThread::flipForWritingModeLocalCoordinates(LayoutRect& rect) const
 {
     if (!style().isFlippedBlocksWritingMode())

Modified: trunk/Source/WebCore/rendering/RenderFlowThread.h (164836 => 164837)


--- trunk/Source/WebCore/rendering/RenderFlowThread.h	2014-02-27 23:36:23 UTC (rev 164836)
+++ trunk/Source/WebCore/rendering/RenderFlowThread.h	2014-02-27 23:52:23 UTC (rev 164837)
@@ -199,9 +199,7 @@
 
     LayoutRect mapFromFlowThreadToLocal(const RenderBox*, const LayoutRect&) const;
     LayoutRect mapFromLocalToFlowThread(const RenderBox*, const LayoutRect&) const;
-    
-    LayoutRect decorationsClipRectForBoxInRegion(const RenderBox&, RenderRegion&) const;
-    
+
     void flipForWritingModeLocalCoordinates(LayoutRect&) const;
 
     // Used to estimate the maximum height of the flow thread.

Modified: trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp (164836 => 164837)


--- trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp	2014-02-27 23:36:23 UTC (rev 164836)
+++ trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp	2014-02-27 23:52:23 UTC (rev 164837)
@@ -35,6 +35,7 @@
 #include "Position.h"
 #include "Range.h"
 #include "RenderInline.h"
+#include "RenderLayer.h"
 #include "RenderNamedFlowFragment.h"
 #include "RenderText.h"
 #include "RenderView.h"
@@ -283,6 +284,76 @@
         updateWritingMode();
 }
 
+LayoutRect RenderNamedFlowThread::decorationsClipRectForBoxInNamedFlowFragment(const RenderBox& box, RenderNamedFlowFragment& fragment) const
+{
+    LayoutRect visualOverflowRect = fragment.visualOverflowRectForBox(&box);
+    LayoutUnit initialLogicalX = style().isHorizontalWritingMode() ? visualOverflowRect.x() : visualOverflowRect.y();
+
+    // The visual overflow rect returned by visualOverflowRectForBox is already flipped but the
+    // RenderRegion::rectFlowPortionForBox method expects it unflipped.
+    flipForWritingModeLocalCoordinates(visualOverflowRect);
+    visualOverflowRect = fragment.rectFlowPortionForBox(&box, visualOverflowRect);
+    
+    // Now flip it again.
+    flipForWritingModeLocalCoordinates(visualOverflowRect);
+    
+    // Layers are in physical coordinates so the origin must be moved to the physical top-left of the flowthread.
+    if (style().isFlippedBlocksWritingMode()) {
+        if (style().isHorizontalWritingMode())
+            visualOverflowRect.moveBy(LayoutPoint(0, height()));
+        else
+            visualOverflowRect.moveBy(LayoutPoint(width(), 0));
+    }
+
+    const RenderBox* iterBox = &box;
+    while (iterBox && iterBox != this) {
+        RenderBlock* containerBlock = iterBox->containingBlock();
+
+        // FIXME: This doesn't work properly with flipped writing modes.
+        // https://bugs.webkit.org/show_bug.cgi?id=125149
+        if (iterBox->isPositioned()) {
+            // For positioned elements, just use the layer's absolute bounding box.
+            visualOverflowRect.moveBy(iterBox->layer()->absoluteBoundingBox().location());
+            break;
+        }
+
+        LayoutRect currentBoxRect = iterBox->frameRect();
+        if (iterBox->style().isFlippedBlocksWritingMode()) {
+            if (iterBox->style().isHorizontalWritingMode())
+                currentBoxRect.setY(currentBoxRect.height() - currentBoxRect.maxY());
+            else
+                currentBoxRect.setX(currentBoxRect.width() - currentBoxRect.maxX());
+        }
+
+        if (containerBlock->style().writingMode() != iterBox->style().writingMode())
+            iterBox->flipForWritingMode(currentBoxRect);
+
+        visualOverflowRect.moveBy(currentBoxRect.location());
+        iterBox = containerBlock;
+    }
+
+    // Since the purpose of this method is to make sure the borders of a fragmented
+    // element don't overflow the region in the fragmentation direction, there's no
+    // point in restricting the clipping rect on the logical X axis. 
+    // This also saves us the trouble of handling percent-based widths and margins
+    // since the absolute bounding box of a positioned element would not contain
+    // the correct coordinates relative to the region we're interested in, but rather
+    // relative to the actual flow thread.
+    if (style().isHorizontalWritingMode()) {
+        if (initialLogicalX < visualOverflowRect.x())
+            visualOverflowRect.shiftXEdgeTo(initialLogicalX);
+        if (visualOverflowRect.width() < frameRect().width())
+            visualOverflowRect.setWidth(frameRect().width());
+    } else {
+        if (initialLogicalX < visualOverflowRect.y())
+            visualOverflowRect.shiftYEdgeTo(initialLogicalX);
+        if (visualOverflowRect.height() < frameRect().height())
+            visualOverflowRect.setHeight(frameRect().height());
+    }
+
+    return visualOverflowRect;
+}
+
 void RenderNamedFlowThread::computeOversetStateForRegions(LayoutUnit oldClientAfterEdge)
 {
     LayoutUnit height = oldClientAfterEdge;

Modified: trunk/Source/WebCore/rendering/RenderNamedFlowThread.h (164836 => 164837)


--- trunk/Source/WebCore/rendering/RenderNamedFlowThread.h	2014-02-27 23:36:23 UTC (rev 164836)
+++ trunk/Source/WebCore/rendering/RenderNamedFlowThread.h	2014-02-27 23:52:23 UTC (rev 164837)
@@ -68,6 +68,8 @@
 
     virtual void regionChangedWritingMode(RenderRegion*) override;
 
+    LayoutRect decorationsClipRectForBoxInNamedFlowFragment(const RenderBox&, RenderNamedFlowFragment&) const;
+
     bool overset() const { return m_overset; }
     void computeOversetStateForRegions(LayoutUnit oldClientAfterEdge);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to