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

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

Issue 197633002: Fix dashed/dotted regression caused by multi-style text decoration patch. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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 | « no previous file | no next file » | 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 29f3200b70f10f7f0f6ca246a4c3b1a49dea286d..7b55b5fc55c662ae9ab3a7e9b769ff4178c5d5a2 100644
--- a/Source/core/rendering/InlineTextBox.cpp
+++ b/Source/core/rendering/InlineTextBox.cpp
@@ -984,7 +984,7 @@ static void adjustStepToDecorationLength(float& step, float& controlPointDistanc
* |-----------|
* step
*/
-static void strokeWavyTextDecoration(GraphicsContext* context, FloatPoint& p1, FloatPoint& p2, float strokeThickness)
+static void strokeWavyTextDecoration(GraphicsContext* context, FloatPoint p1, FloatPoint p2, float strokeThickness)
{
context->adjustLineToPixelBoundaries(p1, p2, strokeThickness, context->strokeStyle());
@@ -1071,6 +1071,28 @@ static bool shouldSetDecorationAntialias(TextDecorationStyle underline, TextDeco
return shouldSetDecorationAntialias(underline) || shouldSetDecorationAntialias(overline) || shouldSetDecorationAntialias(linethrough);
}
+static void paintAppliedDecoration(GraphicsContext* context, FloatPoint start, float width, float doubleOffset, int wavyOffsetFactor,
+ RenderObject::AppliedTextDecoration decoration, float thickness, bool antialiasDecoration, bool isPrinting)
+{
+ context->setStrokeStyle(textDecorationStyleToStrokeStyle(decoration.style));
+ context->setStrokeColor(decoration.color);
+
+ switch (decoration.style) {
+ case TextDecorationStyleWavy:
+ strokeWavyTextDecoration(context, start + FloatPoint(0, doubleOffset * wavyOffsetFactor), start + FloatPoint(width, doubleOffset * wavyOffsetFactor), thickness);
+ break;
+ case TextDecorationStyleDotted:
+ case TextDecorationStyleDashed:
+ context->setShouldAntialias(antialiasDecoration);
+ // Fall through
+ default:
+ context->drawLineForText(start, width, isPrinting);
+
+ if (decoration.style == TextDecorationStyleDouble)
+ context->drawLineForText(start + FloatPoint(0, doubleOffset), width, isPrinting);
+ }
+}
+
void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint& boxOrigin, TextDecoration deco, const ShadowList* shadowList)
{
GraphicsContextStateSaver stateSaver(*context);
@@ -1153,68 +1175,15 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint&
float doubleOffset = textDecorationThickness + 1.f;
if (deco & TextDecorationUnderline) {
- context->setStrokeStyle(textDecorationStyleToStrokeStyle(underline.style));
- context->setStrokeColor(underline.color);
const int underlineOffset = computeUnderlineOffset(styleToUse->textUnderlinePosition(), styleToUse->fontMetrics(), this, textDecorationThickness);
- switch (underline.style) {
- case TextDecorationStyleWavy: {
- FloatPoint start(localOrigin.x(), localOrigin.y() + underlineOffset + doubleOffset);
- FloatPoint end(localOrigin.x() + width, localOrigin.y() + underlineOffset + doubleOffset);
- strokeWavyTextDecoration(context, start, end, textDecorationThickness);
- break;
- }
- case TextDecorationStyleDotted:
- case TextDecorationStyleDashed:
- context->setShouldAntialias(antialiasDecoration);
- // Fall through
- case TextDecorationStyleDouble:
- context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + underlineOffset + doubleOffset), width, isPrinting);
- // Fall through
- default:
- context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + underlineOffset), width, isPrinting);
- }
+ paintAppliedDecoration(context, localOrigin + FloatPoint(0, underlineOffset), width, doubleOffset, 1, underline, textDecorationThickness, antialiasDecoration, isPrinting);
}
if (deco & TextDecorationOverline) {
- context->setStrokeStyle(textDecorationStyleToStrokeStyle(overline.style));
- context->setStrokeColor(overline.color);
- switch (overline.style) {
- case TextDecorationStyleWavy: {
- FloatPoint start(localOrigin.x(), localOrigin.y() - doubleOffset);
- FloatPoint end(localOrigin.x() + width, localOrigin.y() - doubleOffset);
- strokeWavyTextDecoration(context, start, end, textDecorationThickness);
- break;
- }
- case TextDecorationStyleDotted:
- case TextDecorationStyleDashed:
- context->setShouldAntialias(antialiasDecoration);
- // Fall through
- case TextDecorationStyleDouble:
- context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() - doubleOffset), width, isPrinting);
- // Fall through
- default:
- context->drawLineForText(localOrigin, width, isPrinting);
- }
+ paintAppliedDecoration(context, localOrigin, width, -doubleOffset, 1, overline, textDecorationThickness, antialiasDecoration, isPrinting);
}
if (deco & TextDecorationLineThrough) {
- context->setStrokeStyle(textDecorationStyleToStrokeStyle(linethrough.style));
- context->setStrokeColor(linethrough.color);
- switch (linethrough.style) {
- case TextDecorationStyleWavy: {
- FloatPoint start(localOrigin.x(), localOrigin.y() + 2 * baseline / 3);
- FloatPoint end(localOrigin.x() + width, localOrigin.y() + 2 * baseline / 3);
- strokeWavyTextDecoration(context, start, end, textDecorationThickness);
- break;
- }
- case TextDecorationStyleDotted:
- case TextDecorationStyleDashed:
- context->setShouldAntialias(antialiasDecoration);
- // Fall through
- case TextDecorationStyleDouble:
- context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + doubleOffset + 2 * baseline / 3), width, isPrinting);
- // Fall through
- default:
- context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + 2 * baseline / 3), width, isPrinting);
- }
+ const float lineThroughOffset = 2 * baseline / 3;
+ paintAppliedDecoration(context, localOrigin + FloatPoint(0, lineThroughOffset), width, doubleOffset, 0, linethrough, textDecorationThickness, antialiasDecoration, isPrinting);
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698