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

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

Issue 2819953002: 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 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();

Powered by Google App Engine
This is Rietveld 408576698