Simplify LineWidth::wrapNextToShapeOutside()
authorbjonesbe@adobe.com <bjonesbe@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jan 2015 21:25:08 +0000 (21:25 +0000)
committerbjonesbe@adobe.com <bjonesbe@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jan 2015 21:25:08 +0000 (21:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140304

Reviewed by Zoltan Horvath.

This function used to manually check to see if the entire height of
the line would have enough space next to the float. However, the code
to compute the offsets will do this automatically (and probably a lot
faster), if the line height is passed in. This patch does just that.

No new tests, no behavior change.

* rendering/line/LineWidth.cpp:
(WebCore::availableWidthAtOffset): Remove now unused override, allow
    passing in lineHeight.
(WebCore::LineWidth::wrapNextToShapeOutside): Pass the lineHeight
    when computing the available width, so we don't need to check
    isWholeLineFit anymore.
(WebCore::isWholeLineFit): Deleted.

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/line/LineWidth.cpp

index b301b83..32df19f 100644 (file)
@@ -1,5 +1,27 @@
 2015-01-09  Bem Jones-Bey  <bjonesbe@adobe.com>
 
+        Simplify LineWidth::wrapNextToShapeOutside()
+        https://bugs.webkit.org/show_bug.cgi?id=140304
+
+        Reviewed by Zoltan Horvath.
+
+        This function used to manually check to see if the entire height of
+        the line would have enough space next to the float. However, the code
+        to compute the offsets will do this automatically (and probably a lot
+        faster), if the line height is passed in. This patch does just that.
+
+        No new tests, no behavior change.
+
+        * rendering/line/LineWidth.cpp:
+        (WebCore::availableWidthAtOffset): Remove now unused override, allow
+            passing in lineHeight.
+        (WebCore::LineWidth::wrapNextToShapeOutside): Pass the lineHeight
+            when computing the available width, so we don't need to check
+            isWholeLineFit anymore.
+        (WebCore::isWholeLineFit): Deleted.
+
+2015-01-09  Bem Jones-Bey  <bjonesbe@adobe.com>
+
         [CSS Shapes] content inside second shape area when two floats interact
         https://bugs.webkit.org/show_bug.cgi?id=137702
 
index a601f9a..0b17d18 100644 (file)
@@ -141,20 +141,13 @@ void LineWidth::applyOverhang(RenderRubyRun* rubyRun, RenderObject* startRendere
     m_overhangWidth += startOverhang + endOverhang;
 }
 
-inline static float availableWidthAtOffset(const RenderBlockFlow& block, const LayoutUnit& offset, bool shouldIndentText, float& newLineLeft, float& newLineRight)
+inline static float availableWidthAtOffset(const RenderBlockFlow& block, const LayoutUnit& offset, bool shouldIndentText, float& newLineLeft, float& newLineRight, const LayoutUnit& lineHeight = 0)
 {
-    newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText);
-    newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText);
+    newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText, lineHeight);
+    newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText, lineHeight);
     return std::max(0.0f, newLineRight - newLineLeft);
 }
 
-inline static float availableWidthAtOffset(const RenderBlockFlow& block, const LayoutUnit& offset, bool shouldIndentText)
-{
-    float newLineLeft = 0;
-    float newLineRight = 0;
-    return availableWidthAtOffset(block, offset, shouldIndentText, newLineLeft, newLineRight);
-}
-
 void LineWidth::updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWidth, float newLineLeft, float newLineRight)
 {
     if (newLineWidth <= m_availableWidth)
@@ -167,16 +160,6 @@ void LineWidth::updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWid
 }
 
 #if ENABLE(CSS_SHAPES)
-inline static bool isWholeLineFit(const RenderBlockFlow& block, const LayoutUnit& lineTop, LayoutUnit lineHeight, float uncommittedWidth, bool shouldIndentText)
-{
-    for (LayoutUnit lineBottom = lineTop; lineBottom <= lineTop + lineHeight; ++lineBottom) {
-        LayoutUnit availableWidthAtBottom = availableWidthAtOffset(block, lineBottom, shouldIndentText);
-        if (availableWidthAtBottom < uncommittedWidth)
-            return false;
-    }
-    return true;
-}
-
 void LineWidth::wrapNextToShapeOutside(bool isFirstLine)
 {
     LayoutUnit lineHeight = m_block.lineHeight(isFirstLine, m_block.isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
@@ -188,8 +171,8 @@ void LineWidth::wrapNextToShapeOutside(bool isFirstLine)
     float newLineLeft = m_left;
     float newLineRight = m_right;
     while (true) {
-        newLineWidth = availableWidthAtOffset(m_block, newLineTop, shouldIndentText(), newLineLeft, newLineRight);
-        if (newLineWidth >= m_uncommittedWidth && isWholeLineFit(m_block, newLineTop, lineHeight, m_uncommittedWidth, shouldIndentText()))
+        newLineWidth = availableWidthAtOffset(m_block, newLineTop, shouldIndentText(), newLineLeft, newLineRight, lineHeight);
+        if (newLineWidth >= m_uncommittedWidth)
             break;
 
         if (newLineTop >= floatLogicalBottom)