| 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..2bf2de0b22388b8346830216502e1f84a5f1fd88 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,25 @@ DOMQuad* DOMQuad::fromQuad(const DOMQuadInit& other) {
|
| other.hasP3() ? other.p4() : DOMPointInit());
|
| }
|
|
|
| +DOMRect* DOMQuad::getBounds() {
|
| + return DOMRect::create(m_left, m_top, m_right - m_left, m_bottom - m_top);
|
| +}
|
| +
|
| +void DOMQuad::calculateBounds() {
|
| + m_left = std::min(p1()->x(), p2()->x());
|
| + m_left = std::min(m_left, p3()->x());
|
| + m_left = std::min(m_left, p4()->x());
|
| + m_top = std::min(p1()->y(), p2()->y());
|
| + m_top = std::min(m_top, p3()->y());
|
| + m_top = std::min(m_top, p4()->y());
|
| + m_right = std::max(p1()->x(), p2()->x());
|
| + m_right = std::max(m_right, p3()->x());
|
| + m_right = std::max(m_right, p4()->x());
|
| + m_bottom = std::max(p1()->y(), p2()->y());
|
| + m_bottom = std::max(m_bottom, p3()->y());
|
| + m_bottom = std::max(m_bottom, p4()->y());
|
| +}
|
| +
|
| DOMQuad::DOMQuad(const DOMPointInit& p1,
|
| const DOMPointInit& p2,
|
| const DOMPointInit& p3,
|
| @@ -36,13 +56,17 @@ DOMQuad::DOMQuad(const DOMPointInit& p1,
|
| : m_p1(DOMPoint::fromPoint(p1)),
|
| m_p2(DOMPoint::fromPoint(p2)),
|
| m_p3(DOMPoint::fromPoint(p3)),
|
| - m_p4(DOMPoint::fromPoint(p4)) {}
|
| + m_p4(DOMPoint::fromPoint(p4)) {
|
| + calculateBounds();
|
| +}
|
|
|
| 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)) {}
|
| + m_p4(DOMPoint::create(x, y + height, 0, 1)) {
|
| + calculateBounds();
|
| +}
|
|
|
| ScriptValue DOMQuad::toJSONForBinding(ScriptState* scriptState) const {
|
| V8ObjectBuilder result(scriptState);
|
|
|