Title: [110070] trunk/Source/WebCore
Revision
110070
Author
le...@chromium.org
Date
2012-03-07 10:59:46 -0800 (Wed, 07 Mar 2012)

Log Message

Update usage of LayoutUnits in InlineBox and InlineFlowBox
https://bugs.webkit.org/show_bug.cgi?id=80051

Reviewed by Eric Seidel.

Updating LayoutUnit vs Integer usage in InlineBox and InlineFlowBox. While the
line box tree remains floating point, margins are now subpixel, and rects from
the render tree use LayoutUnits. For more information, see the LayoutUnit wiki
page: https://trac.webkit.org/wiki/LayoutUnit

No new tests. No change in behavior.

* rendering/InlineBox.cpp:
(WebCore::InlineBox::flipForWritingMode): Changing over to LayoutUnits.
* rendering/InlineBox.h:
(InlineBox):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::getFlowSpacingLogicalWidth): Returning a LayoutUnit
instead of an integer, as it uses margin which is a LayoutUnit.
(WebCore::InlineFlowBox::placeBoxesInInlineDirection): Using a LayoutUnit for
margin.
(WebCore::InlineFlowBox::placeBoxesInBlockDirection): Build fixes for when
LayoutUnits are subpixel.
(WebCore::InlineFlowBox::paintFillLayer): Ditto.
* rendering/InlineFlowBox.h:
(WebCore::InlineFlowBox::marginBorderPaddingLogicalLeft): Returning a LayoutUnit
instead of an integer since margin is a LayoutUnit.
(WebCore::InlineFlowBox::marginBorderPaddingLogicalRight): Ditto.
(InlineFlowBox):
(WebCore::InlineFlowBox::logicalLeftLayoutOverflow): Adding a static_cast that's
redundant now, but required when we switch to subpixel LayoutUnits.
(WebCore::InlineFlowBox::logicalRightLayoutOverflow): Ditto.
(WebCore::InlineFlowBox::logicalLeftVisualOverflow): Ditto.
(WebCore::InlineFlowBox::logicalRightVisualOverflow): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (110069 => 110070)


--- trunk/Source/WebCore/ChangeLog	2012-03-07 18:40:23 UTC (rev 110069)
+++ trunk/Source/WebCore/ChangeLog	2012-03-07 18:59:46 UTC (rev 110070)
@@ -1,3 +1,40 @@
+2012-03-07  Levi Weintraub  <le...@chromium.org>
+
+        Update usage of LayoutUnits in InlineBox and InlineFlowBox
+        https://bugs.webkit.org/show_bug.cgi?id=80051
+
+        Reviewed by Eric Seidel.
+
+        Updating LayoutUnit vs Integer usage in InlineBox and InlineFlowBox. While the
+        line box tree remains floating point, margins are now subpixel, and rects from
+        the render tree use LayoutUnits. For more information, see the LayoutUnit wiki
+        page: https://trac.webkit.org/wiki/LayoutUnit
+
+        No new tests. No change in behavior.
+
+        * rendering/InlineBox.cpp:
+        (WebCore::InlineBox::flipForWritingMode): Changing over to LayoutUnits.
+        * rendering/InlineBox.h:
+        (InlineBox):
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::getFlowSpacingLogicalWidth): Returning a LayoutUnit
+        instead of an integer, as it uses margin which is a LayoutUnit.
+        (WebCore::InlineFlowBox::placeBoxesInInlineDirection): Using a LayoutUnit for
+        margin.
+        (WebCore::InlineFlowBox::placeBoxesInBlockDirection): Build fixes for when
+        LayoutUnits are subpixel.
+        (WebCore::InlineFlowBox::paintFillLayer): Ditto.
+        * rendering/InlineFlowBox.h:
+        (WebCore::InlineFlowBox::marginBorderPaddingLogicalLeft): Returning a LayoutUnit
+        instead of an integer since margin is a LayoutUnit.
+        (WebCore::InlineFlowBox::marginBorderPaddingLogicalRight): Ditto.
+        (InlineFlowBox):
+        (WebCore::InlineFlowBox::logicalLeftLayoutOverflow): Adding a static_cast that's
+        redundant now, but required when we switch to subpixel LayoutUnits.
+        (WebCore::InlineFlowBox::logicalRightLayoutOverflow): Ditto.
+        (WebCore::InlineFlowBox::logicalLeftVisualOverflow): Ditto.
+        (WebCore::InlineFlowBox::logicalRightVisualOverflow): Ditto.
+
 2012-03-07  Qi Zhang  <qi.2.zh...@nokia.com>
 
         [Qt] Unskip http/tests/websocket/tests/hixie76/long-invalid-header.html

Modified: trunk/Source/WebCore/rendering/InlineBox.cpp (110069 => 110070)


--- trunk/Source/WebCore/rendering/InlineBox.cpp	2012-03-07 18:40:23 UTC (rev 110069)
+++ trunk/Source/WebCore/rendering/InlineBox.cpp	2012-03-07 18:59:46 UTC (rev 110070)
@@ -365,14 +365,14 @@
     return root()->block()->flipForWritingMode(point);
 }
 
-void InlineBox::flipForWritingMode(IntRect& rect)
+void InlineBox::flipForWritingMode(LayoutRect& rect)
 {
     if (!renderer()->style()->isFlippedBlocksWritingMode())
         return;
     root()->block()->flipForWritingMode(rect);
 }
 
-IntPoint InlineBox::flipForWritingMode(const IntPoint& point)
+LayoutPoint InlineBox::flipForWritingMode(const LayoutPoint& point)
 {
     if (!renderer()->style()->isFlippedBlocksWritingMode())
         return point;

Modified: trunk/Source/WebCore/rendering/InlineBox.h (110069 => 110070)


--- trunk/Source/WebCore/rendering/InlineBox.h	2012-03-07 18:40:23 UTC (rev 110069)
+++ trunk/Source/WebCore/rendering/InlineBox.h	2012-03-07 18:59:46 UTC (rev 110070)
@@ -317,8 +317,8 @@
     FloatPoint locationIncludingFlipping();
     void flipForWritingMode(FloatRect&);
     FloatPoint flipForWritingMode(const FloatPoint&);
-    void flipForWritingMode(IntRect&);
-    IntPoint flipForWritingMode(const IntPoint&);
+    void flipForWritingMode(LayoutRect&);
+    LayoutPoint flipForWritingMode(const LayoutPoint&);
 
     bool knownToHaveNoOverflow() const { return m_knownToHaveNoOverflow; }
     void clearKnownToHaveNoOverflow();

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (110069 => 110070)


--- trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2012-03-07 18:40:23 UTC (rev 110069)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2012-03-07 18:59:46 UTC (rev 110070)
@@ -56,9 +56,9 @@
 
 #endif
 
-int InlineFlowBox::getFlowSpacingLogicalWidth()
+LayoutUnit InlineFlowBox::getFlowSpacingLogicalWidth()
 {
-    int totWidth = marginBorderPaddingLogicalLeft() + marginBorderPaddingLogicalRight();
+    LayoutUnit totWidth = marginBorderPaddingLogicalLeft() + marginBorderPaddingLogicalRight();
     for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
         if (curr->isInlineFlowBox())
             totWidth += toInlineFlowBox(curr)->getFlowSpacingLogicalWidth();
@@ -397,8 +397,8 @@
             } else if (!curr->renderer()->isListMarker() || toRenderListMarker(curr->renderer())->isInside()) {
                 // The box can have a different writing-mode than the overall line, so this is a bit complicated.
                 // Just get all the physical margin and overflow values by hand based off |isVertical|.
-                int logicalLeftMargin = isHorizontal() ? curr->boxModelObject()->marginLeft() : curr->boxModelObject()->marginTop();
-                int logicalRightMargin = isHorizontal() ? curr->boxModelObject()->marginRight() : curr->boxModelObject()->marginBottom();
+                LayoutUnit logicalLeftMargin = isHorizontal() ? curr->boxModelObject()->marginLeft() : curr->boxModelObject()->marginTop();
+                LayoutUnit logicalRightMargin = isHorizontal() ? curr->boxModelObject()->marginRight() : curr->boxModelObject()->marginBottom();
                 
                 logicalLeft += logicalLeftMargin;
                 curr->setLogicalLeft(logicalLeft);
@@ -700,10 +700,10 @@
                 lineTop = pixelSnappedLogicalTop();
                 lineTopIncludingMargins = lineTop;
             } else {
-                lineTop = min(lineTop, pixelSnappedLogicalTop());
+                lineTop = min<LayoutUnit>(lineTop, pixelSnappedLogicalTop());
                 lineTopIncludingMargins = min(lineTop, lineTopIncludingMargins);
             }
-            lineBottom = max(lineBottom, pixelSnappedLogicalBottom());
+            lineBottom = max<LayoutUnit>(lineBottom, pixelSnappedLogicalBottom());
             lineBottomIncludingMargins = max(lineBottom, lineBottomIncludingMargins);
         }
         
@@ -1118,8 +1118,8 @@
         }
         LayoutUnit stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : zeroLayoutUnit);
         LayoutUnit stripY = rect.y() - (isHorizontal() ? zeroLayoutUnit : logicalOffsetOnLine);
-        LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : width();
-        LayoutUnit stripHeight = isHorizontal() ? height() : totalLogicalWidth;
+        LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : static_cast<LayoutUnit>(width());
+        LayoutUnit stripHeight = isHorizontal() ? static_cast<LayoutUnit>(height()) : totalLogicalWidth;
 
         GraphicsContextStateSaver stateSaver(*paintInfo.context);
         paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height()));

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.h (110069 => 110070)


--- trunk/Source/WebCore/rendering/InlineFlowBox.h	2012-03-07 18:40:23 UTC (rev 110069)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.h	2012-03-07 18:59:46 UTC (rev 110070)
@@ -119,8 +119,8 @@
     virtual RenderLineBoxList* rendererLineBoxes() const;
 
     // logicalLeft = left in a horizontal line and top in a vertical line.
-    int marginBorderPaddingLogicalLeft() const { return marginLogicalLeft() + borderLogicalLeft() + paddingLogicalLeft(); }
-    int marginBorderPaddingLogicalRight() const { return marginLogicalRight() + borderLogicalRight() + paddingLogicalRight(); }
+    LayoutUnit marginBorderPaddingLogicalLeft() const { return marginLogicalLeft() + borderLogicalLeft() + paddingLogicalLeft(); }
+    LayoutUnit marginBorderPaddingLogicalRight() const { return marginLogicalRight() + borderLogicalRight() + paddingLogicalRight(); }
     LayoutUnit marginLogicalLeft() const
     {
         if (!includeLogicalLeftEdge())
@@ -168,7 +168,7 @@
 
     // Helper functions used during line construction and placement.
     void determineSpacingForFlowBoxes(bool lastLine, bool isLogicallyLastRunWrapped, RenderObject* logicallyLastRunRenderer);
-    int getFlowSpacingLogicalWidth();
+    LayoutUnit getFlowSpacingLogicalWidth();
     float placeBoxesInInlineDirection(float logicalLeft, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap&);
     void computeLogicalBoxHeights(RootInlineBox*, LayoutUnit& maxPositionTop, LayoutUnit& maxPositionBottom,
                                   LayoutUnit& maxAscent, LayoutUnit& maxDescent, bool& setMaxAscent, bool& setMaxDescent,
@@ -207,8 +207,8 @@
     { 
         return m_overflow ? m_overflow->layoutOverflowRect() : enclosingLayoutRect(frameRectIncludingLineHeight(lineTop, lineBottom));
     }
-    LayoutUnit logicalLeftLayoutOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->minXLayoutOverflow() : m_overflow->minYLayoutOverflow()) : logicalLeft(); }
-    LayoutUnit logicalRightLayoutOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->maxXLayoutOverflow() : m_overflow->maxYLayoutOverflow()) : ceilf(logicalRight()); }
+    LayoutUnit logicalLeftLayoutOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->minXLayoutOverflow() : m_overflow->minYLayoutOverflow()) : static_cast<LayoutUnit>(logicalLeft()); }
+    LayoutUnit logicalRightLayoutOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->maxXLayoutOverflow() : m_overflow->maxYLayoutOverflow()) : static_cast<LayoutUnit>(ceilf(logicalRight())); }
     LayoutUnit logicalTopLayoutOverflow(LayoutUnit lineTop) const
     {
         if (m_overflow)
@@ -233,8 +233,8 @@
     { 
         return m_overflow ? m_overflow->visualOverflowRect() : enclosingLayoutRect(frameRectIncludingLineHeight(lineTop, lineBottom));
     }
-    LayoutUnit logicalLeftVisualOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->minXVisualOverflow() : m_overflow->minYVisualOverflow()) : logicalLeft(); }
-    LayoutUnit logicalRightVisualOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->maxXVisualOverflow() : m_overflow->maxYVisualOverflow()) : ceilf(logicalRight()); }
+    LayoutUnit logicalLeftVisualOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->minXVisualOverflow() : m_overflow->minYVisualOverflow()) : static_cast<LayoutUnit>(logicalLeft()); }
+    LayoutUnit logicalRightVisualOverflow() const { return m_overflow ? (isHorizontal() ? m_overflow->maxXVisualOverflow() : m_overflow->maxYVisualOverflow()) : static_cast<LayoutUnit>(ceilf(logicalRight())); }
     LayoutUnit logicalTopVisualOverflow(LayoutUnit lineTop) const
     {
         if (m_overflow)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to