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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasPathMethods.cpp

Issue 1883693002: Zero-length path with round/square lineCap should paint circle on Canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebaseline outdated philip tests to match IE9 and Firefox Created 4 years, 8 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 | « third_party/WebKit/LayoutTests/fast/canvas/canvas-zero-length-lineCap-expected.txt ('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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved.
9 * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved. 9 * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved.
10 * 10 *
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 void CanvasPathMethods::lineTo(float x, float y) 64 void CanvasPathMethods::lineTo(float x, float y)
65 { 65 {
66 if (!std::isfinite(x) || !std::isfinite(y)) 66 if (!std::isfinite(x) || !std::isfinite(y))
67 return; 67 return;
68 if (!isTransformInvertible()) 68 if (!isTransformInvertible())
69 return; 69 return;
70 70
71 FloatPoint p1 = FloatPoint(x, y); 71 FloatPoint p1 = FloatPoint(x, y);
72 if (!m_path.hasCurrentPoint()) 72 if (!m_path.hasCurrentPoint())
73 m_path.moveTo(p1); 73 m_path.moveTo(p1);
74 else if (p1 != m_path.currentPoint()) 74
75 m_path.addLineTo(p1); 75 m_path.addLineTo(p1);
76 } 76 }
77 77
78 void CanvasPathMethods::quadraticCurveTo(float cpx, float cpy, float x, float y) 78 void CanvasPathMethods::quadraticCurveTo(float cpx, float cpy, float x, float y)
79 { 79 {
80 if (!std::isfinite(cpx) || !std::isfinite(cpy) || !std::isfinite(x) || !std: :isfinite(y)) 80 if (!std::isfinite(cpx) || !std::isfinite(cpy) || !std::isfinite(x) || !std: :isfinite(y))
81 return; 81 return;
82 if (!isTransformInvertible()) 82 if (!isTransformInvertible())
83 return; 83 return;
84 if (!m_path.hasCurrentPoint()) 84 if (!m_path.hasCurrentPoint())
85 m_path.moveTo(FloatPoint(cpx, cpy)); 85 m_path.moveTo(FloatPoint(cpx, cpy));
86 86
87 FloatPoint p1 = FloatPoint(x, y); 87 FloatPoint p1 = FloatPoint(x, y);
88 FloatPoint cp = FloatPoint(cpx, cpy); 88 FloatPoint cp = FloatPoint(cpx, cpy);
89 if (p1 != m_path.currentPoint() || p1 != cp) 89
90 m_path.addQuadCurveTo(cp, p1); 90 m_path.addQuadCurveTo(cp, p1);
91 } 91 }
92 92
93 void CanvasPathMethods::bezierCurveTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y) 93 void CanvasPathMethods::bezierCurveTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y)
94 { 94 {
95 if (!std::isfinite(cp1x) || !std::isfinite(cp1y) || !std::isfinite(cp2x) || !std::isfinite(cp2y) || !std::isfinite(x) || !std::isfinite(y)) 95 if (!std::isfinite(cp1x) || !std::isfinite(cp1y) || !std::isfinite(cp2x) || !std::isfinite(cp2y) || !std::isfinite(x) || !std::isfinite(y))
96 return; 96 return;
97 if (!isTransformInvertible()) 97 if (!isTransformInvertible())
98 return; 98 return;
99 if (!m_path.hasCurrentPoint()) 99 if (!m_path.hasCurrentPoint())
100 m_path.moveTo(FloatPoint(cp1x, cp1y)); 100 m_path.moveTo(FloatPoint(cp1x, cp1y));
101 101
102 FloatPoint p1 = FloatPoint(x, y); 102 FloatPoint p1 = FloatPoint(x, y);
103 FloatPoint cp1 = FloatPoint(cp1x, cp1y); 103 FloatPoint cp1 = FloatPoint(cp1x, cp1y);
104 FloatPoint cp2 = FloatPoint(cp2x, cp2y); 104 FloatPoint cp2 = FloatPoint(cp2x, cp2y);
105 if (p1 != m_path.currentPoint() || p1 != cp1 || p1 != cp2) 105
106 m_path.addBezierCurveTo(cp1, cp2, p1); 106 m_path.addBezierCurveTo(cp1, cp2, p1);
107 } 107 }
108 108
109 void CanvasPathMethods::arcTo(float x1, float y1, float x2, float y2, float r, E xceptionState& exceptionState) 109 void CanvasPathMethods::arcTo(float x1, float y1, float x2, float y2, float r, E xceptionState& exceptionState)
110 { 110 {
111 if (!std::isfinite(x1) || !std::isfinite(y1) || !std::isfinite(x2) || !std:: isfinite(y2) || !std::isfinite(r)) 111 if (!std::isfinite(x1) || !std::isfinite(y1) || !std::isfinite(x2) || !std:: isfinite(y2) || !std::isfinite(r))
112 return; 112 return;
113 113
114 if (r < 0) { 114 if (r < 0) {
115 exceptionState.throwDOMException(IndexSizeError, "The radius provided (" + String::number(r) + ") is negative."); 115 exceptionState.throwDOMException(IndexSizeError, "The radius provided (" + String::number(r) + ") is negative.");
116 return; 116 return;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 308 }
309 309
310 void CanvasPathMethods::rect(float x, float y, float width, float height) 310 void CanvasPathMethods::rect(float x, float y, float width, float height)
311 { 311 {
312 if (!isTransformInvertible()) 312 if (!isTransformInvertible())
313 return; 313 return;
314 314
315 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(width) || !std: :isfinite(height)) 315 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(width) || !std: :isfinite(height))
316 return; 316 return;
317 317
318 if (!width && !height) {
319 m_path.moveTo(FloatPoint(x, y));
320 return;
321 }
322
323 m_path.addRect(FloatRect(x, y, width, height)); 318 m_path.addRect(FloatRect(x, y, width, height));
324 } 319 }
325 } // namespace blink 320 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/canvas/canvas-zero-length-lineCap-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698