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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 712
713 DrawLooper drawLooper; 713 DrawLooper drawLooper;
714 drawLooper.addShadow(shadowOffset, shadowBlur, shadowColor, 714 drawLooper.addShadow(shadowOffset, shadowBlur, shadowColor,
715 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha); 715 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha);
716 setDrawLooper(drawLooper); 716 setDrawLooper(drawLooper);
717 fillRectWithRoundedHole(outerRect, roundedHole, fillColor); 717 fillRectWithRoundedHole(outerRect, roundedHole, fillColor);
718 restore(); 718 restore();
719 clearDrawLooper(); 719 clearDrawLooper();
720 } 720 }
721 721
722 // This is only used to draw borders.
723 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) 722 void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
724 { 723 {
725 if (paintingDisabled()) 724 if (paintingDisabled())
726 return; 725 return;
727 726
728 StrokeStyle penStyle = strokeStyle(); 727 StrokeStyle penStyle = strokeStyle();
729 if (penStyle == NoStroke) 728 if (penStyle == NoStroke)
730 return; 729 return;
731 730
732 FloatPoint p1 = point1; 731 FloatPoint p1 = point1;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 } 899 }
901 900
902 void GraphicsContext::drawLineForText(const FloatPoint& pt, float width, bool pr inting) 901 void GraphicsContext::drawLineForText(const FloatPoint& pt, float width, bool pr inting)
903 { 902 {
904 if (paintingDisabled()) 903 if (paintingDisabled())
905 return; 904 return;
906 905
907 if (width <= 0) 906 if (width <= 0)
908 return; 907 return;
909 908
910 int thickness = SkMax32(static_cast<int>(strokeThickness()), 1);
911 SkRect r;
912 r.fLeft = WebCoreFloatToSkScalar(pt.x());
913 // Avoid anti-aliasing lines. Currently, these are always horizontal.
914 // Round to nearest pixel to match text and other content.
915 r.fTop = WebCoreFloatToSkScalar(floorf(pt.y() + 0.5f));
916 r.fRight = r.fLeft + WebCoreFloatToSkScalar(width);
917 r.fBottom = r.fTop + SkIntToScalar(thickness);
918
919 SkPaint paint; 909 SkPaint paint;
920 switch (strokeStyle()) { 910 switch (strokeStyle()) {
921 case NoStroke: 911 case NoStroke:
922 case SolidStroke: 912 case SolidStroke:
923 case DoubleStroke: 913 case DoubleStroke:
924 case WavyStroke: 914 case WavyStroke: {
915 int thickness = SkMax32(static_cast<int>(strokeThickness()), 1);
916 SkRect r;
917 r.fLeft = WebCoreFloatToSkScalar(pt.x());
918 // Avoid anti-aliasing lines. Currently, these are always horizontal.
919 // Round to nearest pixel to match text and other content.
920 r.fTop = WebCoreFloatToSkScalar(floorf(pt.y() + 0.5f));
921 r.fRight = r.fLeft + WebCoreFloatToSkScalar(width);
922 r.fBottom = r.fTop + SkIntToScalar(thickness);
925 paint = immutableState()->fillPaint(); 923 paint = immutableState()->fillPaint();
926 break; 924 // Text lines are drawn using the stroke color.
925 paint.setColor(effectiveStrokeColor());
926 drawRect(r, paint);
927 return;
928 }
927 case DottedStroke: 929 case DottedStroke:
928 case DashedStroke: 930 case DashedStroke: {
929 paint = immutableState()->strokePaint(); 931 int y = floorf(pt.y() + std::max<float>(strokeThickness() / 2.0f, 0.5f)) ;
930 break; 932 drawLine(IntPoint(pt.x(), y), IntPoint(pt.x() + width, y));
933 return;
934 }
931 } 935 }
932 936
933 // Text lines are drawn using the stroke color. 937 ASSERT_NOT_REACHED();
934 paint.setColor(effectiveStrokeColor());
935 drawRect(r, paint);
936 } 938 }
937 939
938 // Draws a filled rectangle with a stroked border. 940 // Draws a filled rectangle with a stroked border.
939 void GraphicsContext::drawRect(const IntRect& rect) 941 void GraphicsContext::drawRect(const IntRect& rect)
940 { 942 {
941 if (paintingDisabled()) 943 if (paintingDisabled())
942 return; 944 return;
943 945
944 ASSERT(!rect.isEmpty()); 946 ASSERT(!rect.isEmpty());
945 if (rect.isEmpty()) 947 if (rect.isEmpty())
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 1910
1909 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) 1911 void GraphicsContext::didDrawTextInRect(const SkRect& textRect)
1910 { 1912 {
1911 if (m_trackTextRegion) { 1913 if (m_trackTextRegion) {
1912 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); 1914 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion");
1913 m_textRegion.join(textRect); 1915 m_textRegion.join(textRect);
1914 } 1916 }
1915 } 1917 }
1916 1918
1917 } 1919 }
OLDNEW
« 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