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

Unified Diff: third_party/WebKit/Source/core/dom/DOMQuad.cpp

Issue 2680023003: [GeometryInterface] add getBounds function in DOMQaud. (Closed)
Patch Set: [GeometryInterface] add getBounds function in DOMQaud. Created 3 years, 10 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 853e0740e2a90328592cd8861bfa1fd13b31987e..d380b3f13892e91a2412bba18f46f9bec931f747 100644
--- a/third_party/WebKit/Source/core/dom/DOMQuad.cpp
+++ b/third_party/WebKit/Source/core/dom/DOMQuad.cpp
@@ -7,6 +7,7 @@
#include "bindings/core/v8/V8ObjectBuilder.h"
#include "core/dom/DOMPoint.h"
#include "core/dom/DOMQuadInit.h"
+#include "core/dom/DOMRect.h"
#include "core/dom/DOMRectInit.h"
namespace blink {
@@ -29,6 +30,22 @@ DOMQuad* DOMQuad::fromQuad(const DOMQuadInit& other) {
other.hasP3() ? other.p4() : DOMPointInit());
}
+DOMRect* DOMQuad::getBounds() {
+ double left = std::min(p1()->x(), p2()->x());
zino 2017/02/13 15:23:18 This might be inefficiency. We should cache the bo
+ left = std::min(left, p3()->x());
+ left = std::min(left, p4()->x());
+ double top = std::min(p1()->y(), p2()->y());
+ top = std::min(top, p3()->y());
+ top = std::min(top, p4()->y());
+ double right = std::max(p1()->x(), p2()->x());
+ right = std::max(right, p3()->x());
+ right = std::max(right, p4()->x());
+ double bottom = std::max(p1()->y(), p2()->y());
+ bottom = std::max(bottom, p3()->y());
+ bottom = std::max(bottom, p4()->y());
+ return DOMRect::create(left, top, right - left, bottom - top);
+}
+
DOMQuad::DOMQuad(const DOMPointInit& p1,
const DOMPointInit& p2,
const DOMPointInit& p3,
« 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