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

Side by Side Diff: third_party/WebKit/Source/core/dom/DOMQuad.cpp

Issue 2639983002: [GeometryInterface] add fromRect function in DOMQuad. (Closed)
Patch Set: [GeometryInterface] add fromRect function in DOMQuad. Created 3 years, 11 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/DOMQuad.h" 5 #include "core/dom/DOMQuad.h"
6 6
7 #include "bindings/core/v8/V8ObjectBuilder.h" 7 #include "bindings/core/v8/V8ObjectBuilder.h"
8 #include "core/dom/DOMPoint.h" 8 #include "core/dom/DOMPoint.h"
9 #include "core/dom/DOMRectInit.h"
9 10
10 namespace blink { 11 namespace blink {
11 12
12 DOMQuad* DOMQuad::create(const DOMPointInit& p1, 13 DOMQuad* DOMQuad::create(const DOMPointInit& p1,
13 const DOMPointInit& p2, 14 const DOMPointInit& p2,
14 const DOMPointInit& p3, 15 const DOMPointInit& p3,
15 const DOMPointInit& p4) { 16 const DOMPointInit& p4) {
16 return new DOMQuad(p1, p2, p3, p4); 17 return new DOMQuad(p1, p2, p3, p4);
17 } 18 }
18 19
20 DOMQuad* DOMQuad::fromRect(const DOMRectInit& other) {
21 return new DOMQuad(other.x(), other.y(), other.width(), other.height());
22 }
23
19 DOMQuad::DOMQuad(const DOMPointInit& p1, 24 DOMQuad::DOMQuad(const DOMPointInit& p1,
20 const DOMPointInit& p2, 25 const DOMPointInit& p2,
21 const DOMPointInit& p3, 26 const DOMPointInit& p3,
22 const DOMPointInit& p4) 27 const DOMPointInit& p4)
23 : m_p1(DOMPoint::fromPoint(p1)), 28 : m_p1(DOMPoint::fromPoint(p1)),
24 m_p2(DOMPoint::fromPoint(p2)), 29 m_p2(DOMPoint::fromPoint(p2)),
25 m_p3(DOMPoint::fromPoint(p3)), 30 m_p3(DOMPoint::fromPoint(p3)),
26 m_p4(DOMPoint::fromPoint(p4)) {} 31 m_p4(DOMPoint::fromPoint(p4)) {}
27 32
33 DOMQuad::DOMQuad(double x, double y, double width, double height)
34 : m_p1(DOMPoint::create(x, y, 0, 1)),
35 m_p2(DOMPoint::create(x + width, y, 0, 1)),
36 m_p3(DOMPoint::create(x + width, y + height, 0, 1)),
37 m_p4(DOMPoint::create(x, y + height, 0, 1)) {}
38
28 ScriptValue DOMQuad::toJSONForBinding(ScriptState* scriptState) const { 39 ScriptValue DOMQuad::toJSONForBinding(ScriptState* scriptState) const {
29 V8ObjectBuilder result(scriptState); 40 V8ObjectBuilder result(scriptState);
30 result.add("p1", p1()); 41 result.add("p1", p1());
31 result.add("p2", p2()); 42 result.add("p2", p2());
32 result.add("p3", p3()); 43 result.add("p3", p3());
33 result.add("p4", p4()); 44 result.add("p4", p4());
34 return result.scriptValue(); 45 return result.scriptValue();
35 } 46 }
36 47
37 } // namespace blink 48 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMQuad.h ('k') | third_party/WebKit/Source/core/dom/DOMQuad.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698