Skip to content
  • krit@webkit.org's avatar
    Implement Canvas Path object · 34fc6dae
    krit@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=97333
    
    Reviewed by Dean Jackson.
    
    Source/WebCore:
    
    The Canvas part of the WHATWG specification defines a Path object. This Path object
    shares several path segment functions (path methods) with the CanvasRenderingContext2D
    interface. This patch introduces the Path object and shares the path segment functions
    in the class CanvasPathMethods.
    This patch does just implement the basic path functions that have a general agreement on
    the WHAT WG and W3C mailing lists.
    This feature is behind a flag and won't be activated by default.
    
    http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#path-objects
    
    Test: fast/canvas/canvas-path-object.html
    
    * CMakeLists.txt: Add DOMPath and CanvasPathMedthods to build system.
    * DerivedSources.cpp: Ditto.
    * DerivedSources.make: Ditto.
    * DerivedSources.pri: Ditto.
    * GNUmakefile.list.am: Ditto.
    * Target.pri: Ditto.
    * WebCore.gypi: Ditto.
    * WebCore.vcproj/WebCore.vcproj: Ditto.
    * WebCore.xcodeproj/project.pbxproj: Ditto.
    * html/canvas/CanvasPathMethods.cpp: Added.
    (WebCore): This class shares the path segment functions (moveTo, lineTo, ...) between
        DOMPath (the Path object) and CanvasRenderingContext2D.
    (WebCore::CanvasPathMethods::closePath):
    (WebCore::CanvasPathMethods::moveTo):
    (WebCore::CanvasPathMethods::lineTo):
    (WebCore::CanvasPathMethods::quadraticCurveTo):
    (WebCore::CanvasPathMethods::bezierCurveTo):
    (WebCore::CanvasPathMethods::arcTo):
    (WebCore::CanvasPathMethods::arc):
    (WebCore::CanvasPathMethods::rect):
    * html/canvas/CanvasPathMethods.h: Added.
    (WebCore):
    (CanvasPathMethods):
    (WebCore::CanvasPathMethods::~CanvasPathMethods):
    (WebCore::CanvasPathMethods::transformIsInvertible):
    (WebCore::CanvasPathMethods::CanvasPathMethods):
    * html/canvas/CanvasRenderingContext2D.cpp:
    * html/canvas/CanvasRenderingContext2D.h: Remove the path segment functions here.
    (CanvasRenderingContext2D):
    (WebCore::CanvasRenderingContext2D::transformIsInvertible): This checks if the CTM
        of the context is still invertible. Drawing should stop if it is not.
    * html/canvas/CanvasRenderingContext2D.idl:
    * html/canvas/DOMPath.h: Added.
    (WebCore):
    (DOMPath):
    (WebCore::DOMPath::create):
    (WebCore::DOMPath::~DOMPath):
    (WebCore::DOMPath::DOMPath):
    * html/canvas/DOMPath.idl: Added.
    * page/DOMWindow.idl: Added CTOR for Path.
    
    LayoutTests:
    
    Add a test for checking existence of Path object and dependent functions.
    The test is supposed to fail if canvas-path is not activated on compile time.
    
    * fast/canvas/canvas-path-object-expected.txt: Added.
    * fast/canvas/canvas-path-object.html: Added.
    * fast/canvas/script-tests/canvas-path-object.js: Added.
    * platform/chromium/TestExpectations: Different error handling on Chromium. Needs rebaseline.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140604 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    34fc6dae