Skip to content
  • commit-queue@webkit.org's avatar
    HTML canvas strokes with dash and dashOffset · 6cabcb62
    commit-queue@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=63933
    
    Patch by Young Han Lee <joybro201@gmail.com> on 2011-10-04
    Reviewed by Simon Fraser.
    
    Add webkitLineDash and webkitLineDashOffset attributes to CanvasRenderingContext2D for JSC.
    These attributes can be used to determine the dash-style of stroke in HTML Canvas.
    
    As this kind of attributes are not specified in the HTML Canvas specification yet,
    the 'webkit' prefix is added to its names.
    
    Mozilla already implemented these attributes, mozDash and mozDashOffset [1], and this patch
    is created by referring to the implementation. This patch is basically using the specified
    behavior of stroke-dasharray and stroke-dashoffset in the SVG specification [2], except
    that doesn't support units or percentages, just floating point numbers.
    
    [1] https://bugzilla.mozilla.org/show_bug.cgi?id=662038
    [2] http://www.w3.org/TR/SVG/painting.html#StrokeProperties
    
    Source/WebCore:
    
    Tests: fast/canvas/canvas-webkitLineDash-invalid.html
           fast/canvas/canvas-webkitLineDash.html
    
    * bindings/js/JSCanvasRenderingContext2DCustom.cpp:
    (WebCore::JSCanvasRenderingContext2D::webkitLineDash):
    (WebCore::JSCanvasRenderingContext2D::setWebkitLineDash):
    * html/canvas/CanvasRenderingContext2D.cpp:
    (WebCore::CanvasRenderingContext2D::State::State):
    (WebCore::CanvasRenderingContext2D::webkitLineDash):
    (WebCore::CanvasRenderingContext2D::setWebkitLineDash):
    (WebCore::CanvasRenderingContext2D::webkitLineDashOffset):
    (WebCore::CanvasRenderingContext2D::setWebkitLineDashOffset):
    * html/canvas/CanvasRenderingContext2D.h:
    * html/canvas/CanvasRenderingContext2D.idl:
    
    LayoutTests:
    
    * fast/canvas/canvas-webkitLineDash-expected.txt: Added.
    * fast/canvas/canvas-webkitLineDash-invalid-expected.txt: Added.
    * fast/canvas/canvas-webkitLineDash-invalid.html: Added.
    * fast/canvas/canvas-webkitLineDash.html: Added.
    * fast/canvas/script-tests/canvas-webkitLineDash-invalid.js: Added.
    (trySettingLineDash):
    (trySettingLineDashOffset):
    * fast/canvas/script-tests/canvas-webkitLineDash.js: Added.
    * platform/chromium/test_expectations.txt:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    6cabcb62