Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutText.cpp

Issue 2816243004: Adjust visual overflow rect for rounded/shifted ascent/descent (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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())

Powered by Google App Engine
This is Rietveld 408576698