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 34394d9fefa93349d81016ebb644b680f17f947e..86b52918281aae069a2f47b0b87c5f53ffb537c2 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp |
@@ -2529,7 +2529,9 @@ int LayoutBlockFlow::lineCount(const RootInlineBox* stopRootInlineBox) const { |
} |
int LayoutBlockFlow::firstLineBoxBaseline() const { |
- if (isWritingModeRoot() && !isRubyRun()) |
+ // Orthogonal grid items can participante in baseline alignment along column |
+ // axis. |
+ if (isWritingModeRoot() && !isRubyRun() && !isGridItem()) |
return -1; |
if (!childrenInline()) |
return LayoutBlock::firstLineBoxBaseline(); |
@@ -2538,7 +2540,14 @@ int LayoutBlockFlow::firstLineBoxBaseline() const { |
DCHECK(fontData); |
if (!fontData) |
return -1; |
- return (firstLineBox()->logicalTop() + |
+ // logicalTop() gives the distance to 'over-edge', 'top' for horizontal and |
+ // 'right' for vertical-lr and vertical-rl. However, as it happens in |
+ // inlineBlockBaseline we will flip lines to compute the baseline in case of |
+ // vertical-lr mode, hence we want the distance to 'left' edge. |
+ // We perform the same operatio in LayoutBlockFlow::inlineBlockBaseline. |
+ return ((styleRef().isFlippedLinesWritingMode() |
+ ? logicalHeight() - firstLineBox()->logicalBottom() |
+ : firstLineBox()->logicalTop()) + |
fontData->getFontMetrics().ascent(firstRootBox()->baselineType())) |
.toInt(); |
} |