Index: third_party/WebKit/Source/core/layout/LayoutText.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutText.cpp b/third_party/WebKit/Source/core/layout/LayoutText.cpp |
index 045f3370d9a36781089d41a7963a2acbd1274f32..f7f610dbe4a86c1306b65b76fce7ae1a15609096 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutText.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutText.cpp |
@@ -1919,6 +1919,24 @@ LayoutRect LayoutText::visualOverflowRect() const { |
LayoutUnit logicalHeight = |
lastTextBox()->logicalBottomVisualOverflow() - logicalTop; |
+ // Inflate visual overflow if we have adjusted ascent/descent causing the |
+ // painted glyphs to overflow the layout geometries based on the adjusted |
+ // ascent/descent. |
+ unsigned inflation_for_ascent = 0; |
+ unsigned inflation_for_descent = 0; |
+ const auto* font_data = |
+ styleRef(firstTextBox()->isFirstLineStyle()).font().primaryFont(); |
+ if (font_data) |
+ inflation_for_ascent = font_data->VisualOverflowInflationForAscent(); |
+ if (lastTextBox()->isFirstLineStyle() != firstTextBox()->isFirstLineStyle()) { |
+ font_data = |
+ styleRef(lastTextBox()->isFirstLineStyle()).font().primaryFont(); |
+ } |
+ if (font_data) |
+ inflation_for_descent = font_data->VisualOverflowInflationForDescent(); |
+ logicalTop -= LayoutUnit(inflation_for_ascent); |
+ logicalHeight += LayoutUnit(inflation_for_ascent + inflation_for_descent); |
+ |
LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight); |
if (!style()->isHorizontalWritingMode()) |
rect = rect.transposedRect(); |