Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: Source/core/html/canvas/DOMPath.h

Issue 170503002: Implement addPath() method for Path object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/canvas/CanvasPathMethods.h ('k') | Source/core/html/canvas/Path.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved. 2 * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 12 matching lines...) Expand all
23 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 23 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
24 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE. 25 * SUCH DAMAGE.
26 */ 26 */
27 27
28 #ifndef DOMPath_h 28 #ifndef DOMPath_h
29 #define DOMPath_h 29 #define DOMPath_h
30 30
31 #include "bindings/v8/ScriptWrappable.h" 31 #include "bindings/v8/ScriptWrappable.h"
32 #include "core/html/canvas/CanvasPathMethods.h" 32 #include "core/html/canvas/CanvasPathMethods.h"
33 #include "core/svg/SVGMatrixTearOff.h"
33 #include "core/svg/SVGPathUtilities.h" 34 #include "core/svg/SVGPathUtilities.h"
35 #include "platform/transforms/AffineTransform.h"
34 #include "wtf/PassRefPtr.h" 36 #include "wtf/PassRefPtr.h"
35 #include "wtf/RefCounted.h" 37 #include "wtf/RefCounted.h"
36 38
37 namespace WebCore { 39 namespace WebCore {
38 40
39 class DOMPath FINAL : public RefCounted<DOMPath>, public CanvasPathMethods, publ ic ScriptWrappable { 41 class DOMPath FINAL : public RefCounted<DOMPath>, public CanvasPathMethods, publ ic ScriptWrappable {
40 WTF_MAKE_NONCOPYABLE(DOMPath); WTF_MAKE_FAST_ALLOCATED; 42 WTF_MAKE_NONCOPYABLE(DOMPath); WTF_MAKE_FAST_ALLOCATED;
41 public: 43 public:
42 static PassRefPtr<DOMPath> create() { return adoptRef(new DOMPath); } 44 static PassRefPtr<DOMPath> create() { return adoptRef(new DOMPath); }
43 static PassRefPtr<DOMPath> create(const String& pathData) { return adoptRef( new DOMPath(pathData)); } 45 static PassRefPtr<DOMPath> create(const String& pathData) { return adoptRef( new DOMPath(pathData)); }
44 static PassRefPtr<DOMPath> create(DOMPath* path) { return adoptRef(new DOMPa th(path)); } 46 static PassRefPtr<DOMPath> create(DOMPath* path) { return adoptRef(new DOMPa th(path)); }
45 47
46 static PassRefPtr<DOMPath> create(const Path& path) { return adoptRef(new DO MPath(path)); } 48 static PassRefPtr<DOMPath> create(const Path& path) { return adoptRef(new DO MPath(path)); }
47 49
48 const Path& path() const { return m_path; } 50 const Path& path() const { return m_path; }
49 51
50 virtual ~DOMPath() { } 52 virtual ~DOMPath() { }
53
54 void addPath(DOMPath* path, SVGMatrixTearOff* transform, ExceptionState& exc eptionState)
55 {
56 if (!path) {
57 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessage s::argumentNullOrIncorrectType(1, "Path"));
58 return;
59 }
60 Path src = path->path();
61 m_path.addPath(src, transform ? transform->value() : AffineTransform(1, 0, 0, 1, 0, 0));
62 }
51 private: 63 private:
52 DOMPath() : CanvasPathMethods() 64 DOMPath() : CanvasPathMethods()
53 { 65 {
54 ScriptWrappable::init(this); 66 ScriptWrappable::init(this);
55 } 67 }
56 68
57 DOMPath(const Path& path) 69 DOMPath(const Path& path)
58 : CanvasPathMethods() 70 : CanvasPathMethods(path)
59 { 71 {
60 ScriptWrappable::init(this); 72 ScriptWrappable::init(this);
61 m_path = path;
62 } 73 }
63 74
64 DOMPath(DOMPath* path) 75 DOMPath(DOMPath* path)
65 : CanvasPathMethods() 76 : CanvasPathMethods(path->path())
66 { 77 {
67 ScriptWrappable::init(this); 78 ScriptWrappable::init(this);
68 m_path = path->path();
69 } 79 }
70 80
71 DOMPath(const String& pathData) 81 DOMPath(const String& pathData)
72 : CanvasPathMethods() 82 : CanvasPathMethods()
73 { 83 {
74 ScriptWrappable::init(this); 84 ScriptWrappable::init(this);
75 buildPathFromString(pathData, m_path); 85 buildPathFromString(pathData, m_path);
76 } 86 }
77 }; 87 };
78 88
79 } 89 }
80 #endif 90 #endif
OLDNEW
« no previous file with comments | « Source/core/html/canvas/CanvasPathMethods.h ('k') | Source/core/html/canvas/Path.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698