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

Unified Diff: Source/platform/graphics/GraphicsContext.cpp

Issue 185683003: Draw a single underline for text-decoration-style: [dashed, dotted]. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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: Source/platform/graphics/GraphicsContext.cpp
diff --git a/Source/platform/graphics/GraphicsContext.cpp b/Source/platform/graphics/GraphicsContext.cpp
index 94c921c84c89aa8f4ee082bf24142f36ebb92095..17ad09ddb8bcb046651fe95724a825c25f78e275 100644
--- a/Source/platform/graphics/GraphicsContext.cpp
+++ b/Source/platform/graphics/GraphicsContext.cpp
@@ -767,7 +767,6 @@ void GraphicsContext::drawInnerShadow(const RoundedRect& rect, const Color& shad
clearDrawLooper();
}
-// This is only used to draw borders.
void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
{
if (paintingDisabled())
@@ -955,32 +954,35 @@ void GraphicsContext::drawLineForText(const FloatPoint& pt, float width, bool pr
if (width <= 0)
return;
- int thickness = SkMax32(static_cast<int>(strokeThickness()), 1);
- SkRect r;
- r.fLeft = WebCoreFloatToSkScalar(pt.x());
- // Avoid anti-aliasing lines. Currently, these are always horizontal.
- // Round to nearest pixel to match text and other content.
- r.fTop = WebCoreFloatToSkScalar(floorf(pt.y() + 0.5f));
- r.fRight = r.fLeft + WebCoreFloatToSkScalar(width);
- r.fBottom = r.fTop + SkIntToScalar(thickness);
-
SkPaint paint;
switch (strokeStyle()) {
case NoStroke:
case SolidStroke:
case DoubleStroke:
- case WavyStroke:
+ case WavyStroke: {
+ int thickness = SkMax32(static_cast<int>(strokeThickness()), 1);
+ SkRect r;
+ r.fLeft = WebCoreFloatToSkScalar(pt.x());
+ // Avoid anti-aliasing lines. Currently, these are always horizontal.
+ // Round to nearest pixel to match text and other content.
+ r.fTop = WebCoreFloatToSkScalar(floorf(pt.y() + 0.5f));
+ r.fRight = r.fLeft + WebCoreFloatToSkScalar(width);
+ r.fBottom = r.fTop + SkIntToScalar(thickness);
setupPaintForFilling(&paint);
- break;
+ // Text lines are drawn using the stroke color.
+ paint.setColor(effectiveStrokeColor());
+ drawRect(r, paint);
+ return;
+ }
case DottedStroke:
- case DashedStroke:
- setupPaintForStroking(&paint);
- break;
+ case DashedStroke: {
+ int y = floorf(pt.y() + std::max<float>(strokeThickness() / 2.0f, 0.5f));
+ drawLine(IntPoint(pt.x(), y), IntPoint(pt.x() + width, y));
+ return;
+ }
}
- // Text lines are drawn using the stroke color.
- paint.setColor(effectiveStrokeColor());
- drawRect(r, paint);
+ ASSERT_NOT_REACHED();
}
// Draws a filled rectangle with a stroked border.
« Source/core/rendering/RenderBoxModelObject.h ('K') | « Source/core/rendering/RenderBoxModelObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698