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

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: Don't modify rendering behavior of old decorations. 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 | « Source/core/rendering/RenderBoxModelObject.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/GraphicsContext.cpp
diff --git a/Source/platform/graphics/GraphicsContext.cpp b/Source/platform/graphics/GraphicsContext.cpp
index e835e54391595b90bc087ab7258d04f26c46b5ce..58c24d36345bec45acd3fc2bfd3c97ca3dd23225 100644
--- a/Source/platform/graphics/GraphicsContext.cpp
+++ b/Source/platform/graphics/GraphicsContext.cpp
@@ -719,7 +719,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())
@@ -907,32 +906,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);
paint = immutableState()->fillPaint();
- break;
+ // Text lines are drawn using the stroke color.
+ paint.setColor(effectiveStrokeColor());
+ drawRect(r, paint);
+ return;
+ }
case DottedStroke:
- case DashedStroke:
- paint = immutableState()->strokePaint();
- 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.
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698