Commit 52aca360 authored by Aaron Krajeski's avatar Aaron Krajeski Committed by Commit Bot

Change Path2D interface to take string or path

Bug: 806581
Change-Id: I26467c5fc2c9fc9ecf918a5229a97650bd29a5e5
Reviewed-on: https://chromium-review.googlesource.com/1185370Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586113}
parent aed5ae4a
...@@ -54,6 +54,8 @@ bindings_modules_generated_union_type_files = [ ...@@ -54,6 +54,8 @@ bindings_modules_generated_union_type_files = [
"$bindings_modules_v8_output_dir/media_stream_track_or_string.h", "$bindings_modules_v8_output_dir/media_stream_track_or_string.h",
"$bindings_modules_v8_output_dir/offscreen_rendering_context.cc", "$bindings_modules_v8_output_dir/offscreen_rendering_context.cc",
"$bindings_modules_v8_output_dir/offscreen_rendering_context.h", "$bindings_modules_v8_output_dir/offscreen_rendering_context.h",
"$bindings_modules_v8_output_dir/path_2d_or_string.cc",
"$bindings_modules_v8_output_dir/path_2d_or_string.h",
"$bindings_modules_v8_output_dir/password_credential_data_or_html_form_element.cc", "$bindings_modules_v8_output_dir/password_credential_data_or_html_form_element.cc",
"$bindings_modules_v8_output_dir/password_credential_data_or_html_form_element.h", "$bindings_modules_v8_output_dir/password_credential_data_or_html_form_element.h",
"$bindings_modules_v8_output_dir/point_2d_sequence_or_constrain_point_2d_parameters.cc", "$bindings_modules_v8_output_dir/point_2d_sequence_or_constrain_point_2d_parameters.cc",
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_CANVAS_CANVAS2D_PATH_2D_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_CANVAS_CANVAS2D_PATH_2D_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_CANVAS_CANVAS2D_PATH_2D_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_CANVAS_CANVAS2D_PATH_2D_H_
#include "third_party/blink/renderer/bindings/modules/v8/path_2d_or_string.h"
#include "third_party/blink/renderer/core/geometry/dom_matrix.h" #include "third_party/blink/renderer/core/geometry/dom_matrix.h"
#include "third_party/blink/renderer/core/geometry/dom_matrix_2d_init.h" #include "third_party/blink/renderer/core/geometry/dom_matrix_2d_init.h"
#include "third_party/blink/renderer/core/svg/svg_matrix_tear_off.h" #include "third_party/blink/renderer/core/svg/svg_matrix_tear_off.h"
...@@ -44,11 +45,16 @@ class MODULES_EXPORT Path2D final : public ScriptWrappable, public CanvasPath { ...@@ -44,11 +45,16 @@ class MODULES_EXPORT Path2D final : public ScriptWrappable, public CanvasPath {
WTF_MAKE_NONCOPYABLE(Path2D); WTF_MAKE_NONCOPYABLE(Path2D);
public: public:
static Path2D* Create() { return new Path2D; } static Path2D* Create(Path2DOrString pathorstring) {
static Path2D* Create(const String& path_data) { DCHECK(!pathorstring.IsNull());
return new Path2D(path_data); if (pathorstring.IsPath2D())
return new Path2D(pathorstring.GetAsPath2D());
if (pathorstring.IsString())
return new Path2D(pathorstring.GetAsString());
NOTREACHED();
return nullptr;
} }
static Path2D* Create(Path2D* path) { return new Path2D(path); } static Path2D* Create() { return new Path2D; }
static Path2D* Create(const Path& path) { return new Path2D(path); } static Path2D* Create(const Path& path) { return new Path2D(path); }
const Path& GetPath() const { return path_; } const Path& GetPath() const { return path_; }
......
...@@ -29,9 +29,7 @@ ...@@ -29,9 +29,7 @@
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#path2d // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#path2d
[ [
Constructor, Constructor(optional (Path2D or DOMString) path),
Constructor(Path2D path),
Constructor(DOMString text),
Exposed(Worker OffscreenCanvas, Window StableBlinkFeatures, PaintWorklet StableBlinkFeatures) Exposed(Worker OffscreenCanvas, Window StableBlinkFeatures, PaintWorklet StableBlinkFeatures)
] interface Path2D { ] interface Path2D {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment