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

Unified Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp

Issue 1381973002: Disable canvas line dashing when dash sequence is all zeros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added test for 'null' Created 5 years, 3 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 | « third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-lineDash.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
index 94b6d969cc35ec778d0894bd298375ebb4331097..6e75481849f09163c196e8f1f4d46dd3bcb383c3 100644
--- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
+++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
@@ -199,12 +199,21 @@ void CanvasRenderingContext2DState::setLineDash(const Vector<float>& dash)
m_lineDashDirty = true;
}
+static bool hasANonZeroElement(const Vector<float>& lineDash)
+{
+ for (size_t i = 0; i < lineDash.size(); i++) {
+ if (lineDash[i] != 0.0f)
+ return true;
+ }
+ return false;
+}
+
void CanvasRenderingContext2DState::updateLineDash() const
{
if (!m_lineDashDirty)
return;
- if (m_lineDash.size() == 0) {
+ if (!hasANonZeroElement(m_lineDash)) {
m_strokePaint.setPathEffect(0);
} else {
RefPtr<SkPathEffect> dashPathEffect = adoptRef(SkDashPathEffect::Create(m_lineDash.data(), m_lineDash.size(), m_lineDashOffset));
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-lineDash.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698