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

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

Issue 2803483002: Adjust visual overflow rect for rounded/shifted ascent/descent (Closed)
Patch Set: Rebaseline-cl 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 d34eda4f1c0fff3c89964ec7c5b100b0120097ca..3ddf8da83962d55dbc6cf2278acb6df99943fb0e 100644
--- a/third_party/WebKit/Source/core/layout/LayoutText.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutText.cpp
@@ -1939,6 +1939,20 @@ LayoutRect LayoutText::linesBoundingBox() const {
return result;
}
+static int visualOverflowAdjustmentForAscent(const ComputedStyle& style) {
+ return style.font()
+ .primaryFont()
+ ->getFontMetrics()
+ .visualOverflowAdjustmentForAscent();
+}
+
+static int visualOverflowAdjustmentForDescent(const ComputedStyle& style) {
+ return style.font()
+ .primaryFont()
+ ->getFontMetrics()
+ .visualOverflowAdjustmentForDescent();
+}
+
LayoutRect LayoutText::visualOverflowRect() const {
if (!firstTextBox())
return LayoutRect();
@@ -1957,6 +1971,19 @@ LayoutRect LayoutText::visualOverflowRect() const {
LayoutUnit logicalHeight =
lastTextBox()->logicalBottomVisualOverflow() - logicalTop;
+ const auto& firstStyle = styleRef(firstTextBox()->isFirstLineStyle());
eae 2017/04/07 16:34:56 If I understand the logic right you are inflating
Xianzhu 2017/04/07 17:27:11 This won't work because 1. in many cases floatAsce
+ int ascentAdjustment = visualOverflowAdjustmentForAscent(firstStyle);
+ int descentAdjustment = visualOverflowAdjustmentForDescent(firstStyle);
+ if (lastTextBox()->isFirstLineStyle() != firstTextBox()->isFirstLineStyle()) {
+ const auto& lastStyle = styleRef(lastTextBox()->isFirstLineStyle());
eae 2017/04/07 16:34:56 The names here are bad. It's not really an ascentA
Xianzhu 2017/04/07 17:27:11 Renamed visualOverflowAdjustmentXxx to visualOverf
+ ascentAdjustment = std::max(ascentAdjustment,
+ visualOverflowAdjustmentForAscent(lastStyle));
+ descentAdjustment = std::max(descentAdjustment,
+ visualOverflowAdjustmentForDescent(lastStyle));
+ }
+ logicalTop -= ascentAdjustment;
+ logicalHeight += ascentAdjustment + descentAdjustment;
+
LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight);
if (!style()->isHorizontalWritingMode())
rect = rect.transposedRect();

Powered by Google App Engine
This is Rietveld 408576698