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 c8ee986d1bc39d9233b0c3d688413ed47d79e5eb..f9b04a00f9c326148f40b829e95f4dcdec1612d3 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutText.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutText.cpp |
@@ -1976,6 +1976,24 @@ LayoutRect LayoutText::VisualOverflowRect() const { |
LayoutUnit logical_height = |
LastTextBox()->LogicalBottomVisualOverflow() - logical_top; |
+ // 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()).GetFont().PrimaryFont(); |
+ if (font_data) |
+ inflation_for_ascent = font_data->VisualOverflowInflationForAscent(); |
+ if (LastTextBox()->IsFirstLineStyle() != FirstTextBox()->IsFirstLineStyle()) { |
+ font_data = |
+ StyleRef(LastTextBox()->IsFirstLineStyle()).GetFont().PrimaryFont(); |
+ } |
+ if (font_data) |
+ inflation_for_descent = font_data->VisualOverflowInflationForDescent(); |
+ logical_top -= LayoutUnit(inflation_for_ascent); |
+ logical_height += LayoutUnit(inflation_for_ascent + inflation_for_descent); |
+ |
LayoutRect rect(logical_left_side, logical_top, logical_width, |
logical_height); |
if (!Style()->IsHorizontalWritingMode()) |