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, |