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

Unified Diff: Source/core/rendering/InlineTextBox.cpp

Issue 40733004: Replace compile flag with runtime check for text-underline-position (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Julien's review #2 (rebased) Created 7 years, 1 month 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 | « Source/core/rendering/InlineFlowBox.cpp ('k') | Source/core/rendering/RootInlineBox.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/InlineTextBox.cpp
diff --git a/Source/core/rendering/InlineTextBox.cpp b/Source/core/rendering/InlineTextBox.cpp
index c5eff52094f0522dfb3d31262b97788995e9e592..f9082487d529c95ed2706aa2e3838e306f012d84 100644
--- a/Source/core/rendering/InlineTextBox.cpp
+++ b/Source/core/rendering/InlineTextBox.cpp
@@ -916,12 +916,11 @@ static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorati
return strokeStyle;
}
-#if ENABLE(CSS3_TEXT)
-static int computeUnderlineOffset(const TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, const int textDecorationThickness)
+static int computeUnderlineOffset(const TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, 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.
- const int gap = max<int>(1, ceilf(textDecorationThickness / 2.0));
+ const int gap = std::max<int>(1, ceilf(textDecorationThickness / 2.f));
// According to the specification TextUnderlinePositionAuto should default to 'alphabetic' for horizontal text
// and to 'under Left' for vertical text (e.g. japanese). We support only horizontal text for now.
@@ -941,7 +940,6 @@ static int computeUnderlineOffset(const TextUnderlinePosition underlinePosition,
ASSERT_NOT_REACHED();
return fontMetrics.ascent() + gap;
}
-#endif // CSS3_TEXT
static void adjustStepToDecorationLength(float& step, float& controlPointDistance, float length)
{
@@ -1069,8 +1067,6 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint&
{
GraphicsContextStateSaver stateSaver(*context);
- float textDecorationThickness = 1.f;
-
if (m_truncation == cFullTruncation)
return;
@@ -1100,7 +1096,7 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint&
size_t shadowCount = shadowList ? shadowList->shadows().size() : 0;
// Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px.
// Using computedFontSize should take care of zoom as well.
- textDecorationThickness = max(textDecorationThickness, styleToUse->computedFontSize() / 10.0f);
+ const float textDecorationThickness = std::max(1.f, styleToUse->computedFontSize() / 10.f);
context->setStrokeThickness(textDecorationThickness);
int extraOffset = 0;
@@ -1140,13 +1136,7 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint&
context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle));
if (deco & TextDecorationUnderline) {
context->setStrokeColor(underline);
-#if ENABLE(CSS3_TEXT)
- TextUnderlinePosition underlinePosition = styleToUse->textUnderlinePosition();
- const int underlineOffset = computeUnderlineOffset(underlinePosition, styleToUse->fontMetrics(), this, textDecorationThickness);
-#else
- const int underlineOffset = styleToUse->fontMetrics().ascent() + max<int>(1, ceilf(textDecorationThickness / 2.0));
-#endif // CSS3_TEXT
-
+ const int underlineOffset = computeUnderlineOffset(styleToUse->textUnderlinePosition(), styleToUse->fontMetrics(), this, textDecorationThickness);
switch (decorationStyle) {
case TextDecorationStyleWavy: {
FloatPoint start(localOrigin.x(), localOrigin.y() + underlineOffset + doubleOffset);
« no previous file with comments | « Source/core/rendering/InlineFlowBox.cpp ('k') | Source/core/rendering/RootInlineBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698