Index: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp |
index 86c89055bb7ce6623f6cc00e09fdd72669e442c7..b1865cf71958b75fc6183e693d72eb23345aadc5 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp |
@@ -1951,6 +1951,46 @@ int LayoutBlockFlow::lineCount(const RootInlineBox* stopRootInlineBox) const |
return count; |
} |
+int LayoutBlockFlow::firstLineBoxBaseline() const |
+{ |
+ if (isWritingModeRoot() && !isRubyRun()) |
+ return -1; |
+ if (!childrenInline()) |
+ return LayoutBlock::firstLineBoxBaseline(); |
+ if (firstLineBox()) |
+ return firstLineBox()->logicalTop() + style(true)->getFontMetrics().ascent(firstRootBox()->baselineType()); |
+ return -1; |
+} |
+ |
+int LayoutBlockFlow::inlineBlockBaseline(LineDirectionMode lineDirection) const |
+{ |
+ // CSS2.1 states that the baseline of an 'inline-block' is: |
+ // the baseline of the last line box in the normal flow, unless it has |
+ // either no in-flow line boxes or if its 'overflow' property has a computed |
+ // value other than 'visible', in which case the baseline is the bottom |
+ // margin edge. |
+ // We likewise avoid using the last line box in the case of size containment, |
+ // where the block's contents shouldn't be considered when laying out its |
+ // ancestors or siblings. |
+ |
+ if ((!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInlineBlockBaseline()) || style()->containsSize()) { |
+ // We are not calling baselinePosition here because the caller should add the margin-top/margin-right, not us. |
+ return lineDirection == HorizontalLine ? size().height() + marginBottom() : size().width() + marginLeft(); |
+ } |
+ if (isWritingModeRoot() && !isRubyRun()) |
+ return -1; |
+ if (!childrenInline()) |
+ return LayoutBlock::inlineBlockBaseline(lineDirection); |
+ if (lastLineBox()) |
+ return lastLineBox()->logicalTop() + style(lastLineBox() == firstLineBox())->getFontMetrics().ascent(lastRootBox()->baselineType()); |
+ if (!hasLineIfEmpty()) |
+ return -1; |
+ const FontMetrics& fontMetrics = firstLineStyle()->getFontMetrics(); |
+ return fontMetrics.ascent() |
+ + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2 |
+ + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()); |
+} |
+ |
void LayoutBlockFlow::removeFloatingObjectsFromDescendants() |
{ |
if (!containsFloats()) |