Move logicalHeightForLine out of LineWidth.h
authorzoltan@webkit.org <zoltan@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Sep 2013 20:53:44 +0000 (20:53 +0000)
committerzoltan@webkit.org <zoltan@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Sep 2013 20:53:44 +0000 (20:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121575

Reviewed by David Hyatt.

In bug #121107 (r155565), I moved logicalHeightForLine into LineWidth.h as part of LineWidth
refactoring. LogicalHeightForLine without passing the second parameter uses RenderBlock::lineHeight
anyway, except it doesn't take -line-box-contain CSS property into account. For Shapes we don't
have implementation for variable-height lines (https://bugs.webkit.org/show_bug.cgi?id=95361) yet, so
so I modified the affected functions to call lineHeight directly. I renamed logicalHeightForLine
to minLineHeightForReplacedRenderer, and I made the second parameter a mandatory for that function.

No new tests, no behavior change.

* rendering/LineWidth.cpp:
(WebCore::LineWidth::updateAvailableWidth):
(WebCore::LineWidth::shrinkAvailableWidthForNewFloatIfNeeded):
* rendering/LineWidth.h:
* rendering/RenderBlock.cpp: Move the definition here.
(WebCore::RenderBlock::minLineHeightForReplacedRenderer):
* rendering/RenderBlock.h: Move the function here and rename it.
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::layoutShapeInsideInfo):
(WebCore::updateLogicalInlinePositions):
(WebCore::updateSegmentsForShapes):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/LineWidth.cpp
Source/WebCore/rendering/LineWidth.h
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp

index 85d0ed4..690717a 100644 (file)
@@ -1,3 +1,31 @@
+2013-09-20  Zoltan Horvath  <zoltan@webkit.org>
+
+        Move logicalHeightForLine out of LineWidth.h
+        https://bugs.webkit.org/show_bug.cgi?id=121575
+
+        Reviewed by David Hyatt.
+
+        In bug #121107 (r155565), I moved logicalHeightForLine into LineWidth.h as part of LineWidth
+        refactoring. LogicalHeightForLine without passing the second parameter uses RenderBlock::lineHeight
+        anyway, except it doesn't take -line-box-contain CSS property into account. For Shapes we don't
+        have implementation for variable-height lines (https://bugs.webkit.org/show_bug.cgi?id=95361) yet, so
+        so I modified the affected functions to call lineHeight directly. I renamed logicalHeightForLine
+        to minLineHeightForReplacedRenderer, and I made the second parameter a mandatory for that function.
+
+        No new tests, no behavior change.
+
+        * rendering/LineWidth.cpp:
+        (WebCore::LineWidth::updateAvailableWidth):
+        (WebCore::LineWidth::shrinkAvailableWidthForNewFloatIfNeeded):
+        * rendering/LineWidth.h:
+        * rendering/RenderBlock.cpp: Move the definition here.
+        (WebCore::RenderBlock::minLineHeightForReplacedRenderer):
+        * rendering/RenderBlock.h: Move the function here and rename it.
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlock::layoutShapeInsideInfo):
+        (WebCore::updateLogicalInlinePositions):
+        (WebCore::updateSegmentsForShapes):
+
 2013-09-20  Alexey Proskuryakov  <ap@apple.com>
 
         -[WebHTMLConveter _getFloat:forNode:property:] leaks
index b396e04..2f7d6b4 100644 (file)
@@ -72,7 +72,7 @@ bool LineWidth::fitsOnLineExcludingTrailingWhitespace(float extra) const
 void LineWidth::updateAvailableWidth(LayoutUnit replacedHeight)
 {
     LayoutUnit height = m_block.logicalHeight();
-    LayoutUnit logicalHeight = logicalHeightForLine(&m_block, m_isFirstLine, replacedHeight);
+    LayoutUnit logicalHeight = m_block.minLineHeightForReplacedRenderer(m_isFirstLine, replacedHeight);
     m_left = m_block.logicalLeftOffsetForLine(height, shouldIndentText(), logicalHeight);
     m_right = m_block.logicalRightOffsetForLine(height, shouldIndentText(), logicalHeight);
 
@@ -102,19 +102,20 @@ void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject* newFloat
     const FloatingObjectSet& floatingObjectSet = m_block.m_floatingObjects->set();
     FloatingObjectSetIterator it = floatingObjectSet.end();
     FloatingObjectSetIterator begin = floatingObjectSet.begin();
+    LayoutUnit lineHeight = m_block.lineHeight(m_isFirstLine, m_block.isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
     for (--it; it != begin; --it) {
         FloatingObject* previousFloat = *it;
         if (previousFloat != newFloat && previousFloat->type() == newFloat->type()) {
             previousShapeOutsideInfo = previousFloat->renderer()->shapeOutsideInfo();
             if (previousShapeOutsideInfo)
-                previousShapeOutsideInfo->updateDeltasForContainingBlockLine(&m_block, previousFloat, m_block.logicalHeight(), logicalHeightForLine(&m_block, m_isFirstLine));
+                previousShapeOutsideInfo->updateDeltasForContainingBlockLine(&m_block, previousFloat, m_block.logicalHeight(), lineHeight);
             break;
         }
     }
 
     ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->shapeOutsideInfo();
     if (shapeOutsideInfo)
-        shapeOutsideInfo->updateDeltasForContainingBlockLine(&m_block, newFloat, m_block.logicalHeight(), logicalHeightForLine(&m_block, m_isFirstLine));
+        shapeOutsideInfo->updateDeltasForContainingBlockLine(&m_block, newFloat, m_block.logicalHeight(), lineHeight);
 #endif
 
     if (newFloat->type() == FloatingObject::FloatLeft) {
index 8e1d0fe..2e3232f 100644 (file)
@@ -37,17 +37,6 @@ namespace WebCore {
 
 enum IndentTextOrNot { DoNotIndentText, IndentText };
 
-inline LayoutUnit logicalHeightForLine(const RenderBlock* block, bool isFirstLine, LayoutUnit replacedHeight = 0)
-{
-    if (!block->document().inNoQuirksMode() && replacedHeight)
-        return replacedHeight;
-
-    if (!(block->style(isFirstLine)->lineBoxContain() & LineBoxContainBlock))
-        return 0;
-
-    return std::max<LayoutUnit>(replacedHeight, block->lineHeight(isFirstLine, block->isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes));
-}
-
 class LineWidth {
 public:
     LineWidth(RenderBlock&, bool isFirstLine, IndentTextOrNot shouldIndentText);
index e1e6e7c..5bdf138 100644 (file)
@@ -5642,6 +5642,17 @@ int RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLine, Lin
     return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2;
 }
 
+LayoutUnit RenderBlock::minLineHeightForReplacedRenderer(bool isFirstLine, LayoutUnit replacedHeight) const
+{
+    if (!document().inNoQuirksMode() && replacedHeight)
+        return replacedHeight;
+
+    if (!(style(isFirstLine)->lineBoxContain() & LineBoxContainBlock))
+        return 0;
+
+    return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes));
+}
+
 int RenderBlock::firstLineBoxBaseline() const
 {
     if (isWritingModeRoot() && !isRubyRun())
index 5c68d5a..45b0f47 100644 (file)
@@ -115,6 +115,8 @@ public:
     virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE FINAL;
     virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE;
 
+    LayoutUnit minLineHeightForReplacedRenderer(bool isFirstLine, LayoutUnit replacedHeight) const;
+
     RenderLineBoxList& lineBoxes() { return m_lineBoxes; }
     const RenderLineBoxList& lineBoxes() const { return m_lineBoxes; }
 
index 85d91ff..49666d8 100644 (file)
@@ -75,8 +75,9 @@ ShapeInsideInfo* RenderBlock::layoutShapeInsideInfo() const
     ShapeInsideInfo* shapeInsideInfo = view().layoutState()->shapeInsideInfo();
 
     if (!shapeInsideInfo && flowThreadContainingBlock() && allowsShapeInsideInfoSharing()) {
+        LayoutUnit lineHeight = this->lineHeight(false, isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
         // regionAtBlockOffset returns regions like an array first={0,N-1}, second={N,M-1}, ...
-        LayoutUnit offset = logicalHeight() + logicalHeightForLine(this, false) - LayoutUnit(1);
+        LayoutUnit offset = logicalHeight() + lineHeight - LayoutUnit(1);
         RenderRegion* region = regionAtBlockOffset(offset);
         if (region)
             shapeInsideInfo = region->shapeInsideInfo();
@@ -768,7 +769,7 @@ static IndentTextOrNot requiresIndent(bool isFirstLine, bool isAfterHardLineBrea
 
 static void updateLogicalInlinePositions(RenderBlock* block, float& lineLogicalLeft, float& lineLogicalRight, float& availableLogicalWidth, bool firstLine, IndentTextOrNot shouldIndentText, LayoutUnit boxLogicalHeight)
 {
-    LayoutUnit lineLogicalHeight = logicalHeightForLine(block, firstLine, boxLogicalHeight);
+    LayoutUnit lineLogicalHeight = block->minLineHeightForReplacedRenderer(firstLine, boxLogicalHeight);
     lineLogicalLeft = block->pixelSnappedLogicalLeftOffsetForLine(block->logicalHeight(), shouldIndentText == IndentText, lineLogicalHeight);
     lineLogicalRight = block->pixelSnappedLogicalRightOffsetForLine(block->logicalHeight(), shouldIndentText == IndentText, lineLogicalHeight);
     availableLogicalWidth = lineLogicalRight - lineLogicalLeft;
@@ -2593,7 +2594,7 @@ static void updateSegmentsForShapes(RenderBlock* block, const FloatingObject* la
     ASSERT(lastFloatFromPreviousLine);
 
     ShapeInsideInfo* shapeInsideInfo = block->layoutShapeInsideInfo();
-    LayoutUnit lineLogicalHeight = logicalHeightForLine(block, isFirstLine);
+    LayoutUnit lineLogicalHeight = block->lineHeight(isFirstLine, block->isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
     LayoutUnit lineLogicalBottom = block->logicalHeight() + lineLogicalHeight;
     bool lineOverlapsWithFloat = (lastFloatFromPreviousLine->y() < lineLogicalBottom) && (block->logicalHeight() < lastFloatFromPreviousLine->maxY());