Changeset 96626 in webkit
- Timestamp:
- Oct 4, 2011 11:58:47 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r96625 r96626 1 2011-10-04 Young Han Lee <joybro201@gmail.com> 2 3 HTML canvas strokes with dash and dashOffset 4 https://bugs.webkit.org/show_bug.cgi?id=63933 5 6 Reviewed by Simon Fraser. 7 8 Add webkitLineDash and webkitLineDashOffset attributes to CanvasRenderingContext2D for JSC. 9 These attributes can be used to determine the dash-style of stroke in HTML Canvas. 10 11 As this kind of attributes are not specified in the HTML Canvas specification yet, 12 the 'webkit' prefix is added to its names. 13 14 Mozilla already implemented these attributes, mozDash and mozDashOffset [1], and this patch 15 is created by referring to the implementation. This patch is basically using the specified 16 behavior of stroke-dasharray and stroke-dashoffset in the SVG specification [2], except 17 that doesn't support units or percentages, just floating point numbers. 18 19 [1] https://bugzilla.mozilla.org/show_bug.cgi?id=662038 20 [2] http://www.w3.org/TR/SVG/painting.html#StrokeProperties 21 22 * fast/canvas/canvas-webkitLineDash-expected.txt: Added. 23 * fast/canvas/canvas-webkitLineDash-invalid-expected.txt: Added. 24 * fast/canvas/canvas-webkitLineDash-invalid.html: Added. 25 * fast/canvas/canvas-webkitLineDash.html: Added. 26 * fast/canvas/script-tests/canvas-webkitLineDash-invalid.js: Added. 27 (trySettingLineDash): 28 (trySettingLineDashOffset): 29 * fast/canvas/script-tests/canvas-webkitLineDash.js: Added. 30 * platform/chromium/test_expectations.txt: 31 1 32 2011-10-04 Tim Horton <timothy_horton@apple.com> 2 33 -
trunk/LayoutTests/platform/chromium/test_expectations.txt
r96593 r96626 97 97 // fails for other platforms... 98 98 BUGCR20404 : editing/execCommand/copy-without-selection.html = TEXT 99 100 // This will soon be fixed after implementing webkitLineDash for V8. 101 BUGWK63933 : fast/canvas/canvas-webkitLineDash.html = FAIL 102 BUGWK63933 : fast/canvas/canvas-webkitLineDash-invalid.html = FAIL 99 103 100 104 // ----------------------------------------------------------------- -
trunk/Source/WebCore/ChangeLog
r96624 r96626 1 2011-10-04 Young Han Lee <joybro201@gmail.com> 2 3 HTML canvas strokes with dash and dashOffset 4 https://bugs.webkit.org/show_bug.cgi?id=63933 5 6 Reviewed by Simon Fraser. 7 8 Add webkitLineDash and webkitLineDashOffset attributes to CanvasRenderingContext2D for JSC. 9 These attributes can be used to determine the dash-style of stroke in HTML Canvas. 10 11 As this kind of attributes are not specified in the HTML Canvas specification yet, 12 the 'webkit' prefix is added to its names. 13 14 Mozilla already implemented these attributes, mozDash and mozDashOffset [1], and this patch 15 is created by referring to the implementation. This patch is basically using the specified 16 behavior of stroke-dasharray and stroke-dashoffset in the SVG specification [2], except 17 that doesn't support units or percentages, just floating point numbers. 18 19 [1] https://bugzilla.mozilla.org/show_bug.cgi?id=662038 20 [2] http://www.w3.org/TR/SVG/painting.html#StrokeProperties 21 22 Tests: fast/canvas/canvas-webkitLineDash-invalid.html 23 fast/canvas/canvas-webkitLineDash.html 24 25 * bindings/js/JSCanvasRenderingContext2DCustom.cpp: 26 (WebCore::JSCanvasRenderingContext2D::webkitLineDash): 27 (WebCore::JSCanvasRenderingContext2D::setWebkitLineDash): 28 * html/canvas/CanvasRenderingContext2D.cpp: 29 (WebCore::CanvasRenderingContext2D::State::State): 30 (WebCore::CanvasRenderingContext2D::webkitLineDash): 31 (WebCore::CanvasRenderingContext2D::setWebkitLineDash): 32 (WebCore::CanvasRenderingContext2D::webkitLineDashOffset): 33 (WebCore::CanvasRenderingContext2D::setWebkitLineDashOffset): 34 * html/canvas/CanvasRenderingContext2D.h: 35 * html/canvas/CanvasRenderingContext2D.idl: 36 1 37 2011-10-04 Matthew Delaney <mdelaney@apple.com> 2 38 -
trunk/Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp
r88794 r96626 159 159 } 160 160 161 JSValue JSCanvasRenderingContext2D::webkitLineDash(ExecState* exec) const 162 { 163 CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl()); 164 const DashArray* dash = context->webkitLineDash(); 165 166 MarkedArgumentBuffer list; 167 DashArray::const_iterator end = dash->end(); 168 for (DashArray::const_iterator it = dash->begin(); it != end; ++it) 169 list.append(JSValue(*it)); 170 return constructArray(exec, globalObject(), list); 171 } 172 173 void JSCanvasRenderingContext2D::setWebkitLineDash(ExecState* exec, JSValue value) 174 { 175 if (!isJSArray(&exec->globalData(), value)) 176 return; 177 178 DashArray dash; 179 JSArray* valueArray = asArray(value); 180 for (unsigned i = 0; i < valueArray->length(); ++i) { 181 float elem = valueArray->getIndex(i).toFloat(exec); 182 if (elem <= 0 || !isfinite(elem)) 183 return; 184 185 dash.append(elem); 186 } 187 188 CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl()); 189 context->setWebkitLineDash(dash); 190 } 191 161 192 } // namespace WebCore -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r96624 r96626 193 193 , m_globalComposite(CompositeSourceOver) 194 194 , m_invertibleCTM(true) 195 , m_lineDashOffset(0) 195 196 , m_textAlign(StartTextAlign) 196 197 , m_textBaseline(AlphabeticTextBaseline) … … 497 498 } 498 499 500 const DashArray* CanvasRenderingContext2D::webkitLineDash() const 501 { 502 return &state().m_lineDash; 503 } 504 505 void CanvasRenderingContext2D::setWebkitLineDash(const DashArray& dash) 506 { 507 state().m_lineDash = dash; 508 509 GraphicsContext* c = drawingContext(); 510 if (!c) 511 return; 512 c->setLineDash(state().m_lineDash, state().m_lineDashOffset); 513 } 514 515 float CanvasRenderingContext2D::webkitLineDashOffset() const 516 { 517 return state().m_lineDashOffset; 518 } 519 520 void CanvasRenderingContext2D::setWebkitLineDashOffset(float offset) 521 { 522 if (!isfinite(offset)) 523 return; 524 525 state().m_lineDashOffset = offset; 526 527 GraphicsContext* c = drawingContext(); 528 if (!c) 529 return; 530 c->setLineDash(state().m_lineDash, state().m_lineDashOffset); 531 } 532 499 533 float CanvasRenderingContext2D::globalAlpha() const 500 534 { -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h
r93901 r96626 30 30 #include "CanvasRenderingContext.h" 31 31 #include "Color.h" 32 #include "DashArray.h" 32 33 #include "FloatSize.h" 33 34 #include "Font.h" … … 85 86 float miterLimit() const; 86 87 void setMiterLimit(float); 88 89 const DashArray* webkitLineDash() const; 90 void setWebkitLineDash(const DashArray&); 91 92 float webkitLineDashOffset() const; 93 void setWebkitLineDashOffset(float); 87 94 88 95 float shadowOffsetX() const; … … 243 250 AffineTransform m_transform; 244 251 bool m_invertibleCTM; 252 DashArray m_lineDash; 253 float m_lineDashOffset; 245 254 246 255 // Text state. -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl
r89148 r96626 60 60 attribute float shadowBlur; 61 61 attribute [ConvertNullToNullString] DOMString shadowColor; 62 63 // FIXME: These attributes should also be implemented for V8. 64 #if !(defined(V8_BINDING) && V8_BINDING) 65 attribute [Custom] Array webkitLineDash; 66 attribute float webkitLineDashOffset; 67 #endif 62 68 63 69 void clearRect(in float x, in float y, in float width, in float height);
Note: See TracChangeset
for help on using the changeset viewer.