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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/DOMQuad.cpp
diff --git a/third_party/WebKit/Source/core/dom/DOMQuad.cpp b/third_party/WebKit/Source/core/dom/DOMQuad.cpp
index e93bce2293dbe2b0997b063edb1a09dad994b112..1b87a2196f8f044c3a77f6ccbf8b4da5a1cf691a 100644
--- a/third_party/WebKit/Source/core/dom/DOMQuad.cpp
+++ b/third_party/WebKit/Source/core/dom/DOMQuad.cpp
@@ -6,6 +6,7 @@
#include "bindings/core/v8/V8ObjectBuilder.h"
#include "core/dom/DOMPoint.h"
+#include "core/dom/DOMRectInit.h"
namespace blink {
@@ -16,6 +17,10 @@ DOMQuad* DOMQuad::create(const DOMPointInit& p1,
return new DOMQuad(p1, p2, p3, p4);
}
+DOMQuad* DOMQuad::fromRect(const DOMRectInit& other) {
+ return new DOMQuad(other.x(), other.y(), other.width(), other.height());
+}
+
DOMQuad::DOMQuad(const DOMPointInit& p1,
const DOMPointInit& p2,
const DOMPointInit& p3,
@@ -25,6 +30,12 @@ DOMQuad::DOMQuad(const DOMPointInit& p1,
m_p3(DOMPoint::fromPoint(p3)),
m_p4(DOMPoint::fromPoint(p4)) {}
+DOMQuad::DOMQuad(double x, double y, double width, double height)
+ : m_p1(DOMPoint::create(x, y, 0, 1)),
+ m_p2(DOMPoint::create(x + width, y, 0, 1)),
+ m_p3(DOMPoint::create(x + width, y + height, 0, 1)),
+ m_p4(DOMPoint::create(x, y + height, 0, 1)) {}
+
ScriptValue DOMQuad::toJSONForBinding(ScriptState* scriptState) const {
V8ObjectBuilder result(scriptState);
result.add("p1", p1());
« 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