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

Unified Diff: third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp

Issue 2643293004: Fix gap for "text-underline-position:under" (Closed)
Patch Set: Resolved merge conflict Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp b/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
index 8c70b95917bb916ec38519d7cb0dd72303491171..0f183ce21a86cce5e2fc5fb95d25d107d2060891 100644
--- a/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
@@ -77,42 +77,47 @@ static LayoutUnit computeUnderlineOffsetForUnder(
}
}
-static int computeUnderlineOffset(const ComputedStyle& style,
- const FontMetrics& fontMetrics,
- const InlineTextBox* inlineTextBox,
- const float textDecorationThickness) {
+static int computeUnderlineOffsetForRoman(const FontMetrics& fontMetrics,
+ const float textDecorationThickness) {
// Compute the gap between the font and the underline. Use at least one
// pixel gap, if underline is thick then use a bigger gap.
int gap = 0;
// Underline position of zero means draw underline on Baseline Position,
// in Blink we need at least 1-pixel gap to adding following check.
- // Positive underline Position means underline should be drawn above baselin e
+ // Positive underline Position means underline should be drawn above baseline
// and negative value means drawing below baseline, negating the value as in
- // Blink
- // downward Y-increases.
+ // Blink downward Y-increases.
if (fontMetrics.underlinePosition())
gap = -fontMetrics.underlinePosition();
else
gap = std::max<int>(1, ceilf(textDecorationThickness / 2.f));
+ // Position underline near the alphabetic baseline.
+ return fontMetrics.ascent() + gap;
+}
+
+static int computeUnderlineOffset(const ComputedStyle& style,
+ const FontMetrics& fontMetrics,
+ const InlineTextBox* inlineTextBox,
+ const float textDecorationThickness) {
// FIXME: We support only horizontal text for now.
switch (style.getTextUnderlinePosition()) {
+ default:
+ NOTREACHED();
+ // Fall through.
case TextUnderlinePositionAuto:
- return fontMetrics.ascent() +
- gap; // Position underline near the alphabetic baseline.
+ return computeUnderlineOffsetForRoman(fontMetrics,
+ textDecorationThickness);
case TextUnderlinePositionUnder: {
- // Position underline relative to the under edge of the lowest element's
+ // Position underline at the under edge of the lowest element's
// content box.
LayoutUnit offset = computeUnderlineOffsetForUnder(style, inlineTextBox);
offset = inlineTextBox->logicalHeight() + std::max(offset, LayoutUnit());
- return offset.toInt() + gap;
+ return offset.toInt();
}
}
-
- NOTREACHED();
- return fontMetrics.ascent() + gap;
}
static bool shouldSetDecorationAntialias(
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698