diff --git a/content/canvas/src/CanvasRenderingContext2D.cpp b/content/canvas/src/CanvasRenderingContext2D.cpp index 0a37f9d166ed..d231f8e689f1 100755 --- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -94,6 +94,7 @@ #include "nsGlobalWindow.h" #include "GLContext.h" #include "GLContextProvider.h" +#include "SVGContentUtils.h" #undef free // apparently defined by some windows header, clashing with a free() // method in SkTypes.h @@ -4362,6 +4363,18 @@ CanvasPath::Constructor(const GlobalObject& aGlobal, CanvasPath& aCanvasPath, Er return path.forget(); } +already_AddRefed +CanvasPath::Constructor(const GlobalObject& aGlobal, const nsAString& aPathString, ErrorResult& aRv) +{ + RefPtr tempPath = SVGContentUtils::GetPath(aPathString); + if (!tempPath) { + return Constructor(aGlobal, aRv); + } + + nsRefPtr path = new CanvasPath(aGlobal.GetAsSupports(), tempPath->CopyToBuilder()); + return path.forget(); +} + void CanvasPath::ClosePath() { diff --git a/content/canvas/src/CanvasRenderingContext2D.h b/content/canvas/src/CanvasRenderingContext2D.h index 9503884aa799..594899677ef1 100644 --- a/content/canvas/src/CanvasRenderingContext2D.h +++ b/content/canvas/src/CanvasRenderingContext2D.h @@ -61,6 +61,9 @@ public: static already_AddRefed Constructor(const GlobalObject& aGlobal, CanvasPath& aCanvasPath, ErrorResult& rv); + static already_AddRefed Constructor(const GlobalObject& aGlobal, + const nsAString& aPathString, + ErrorResult& rv); void ClosePath(); void MoveTo(double x, double y); diff --git a/content/canvas/src/moz.build b/content/canvas/src/moz.build index b5b5489b14c5..d103574501b4 100644 --- a/content/canvas/src/moz.build +++ b/content/canvas/src/moz.build @@ -97,6 +97,7 @@ FINAL_LIBRARY = 'gklayout' LOCAL_INCLUDES += [ '/content/base/src', '/content/html/content/src', + '/content/svg/content/src', '/content/xul/content/src', '/dom/base', '/image/src', diff --git a/content/canvas/test/test_canvas_path.html b/content/canvas/test/test_canvas_path.html index 52f85e06b5a4..4a34479af68a 100644 --- a/content/canvas/test/test_canvas_path.html +++ b/content/canvas/test/test_canvas_path.html @@ -315,6 +315,23 @@ function test_isPointInStroke_canvas() { } +

Canvas test: test_pathconstructor_canvas

++ + + +