|
|
|
|
| 3 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
3 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 5 |
|
5 |
|
| 6 |
#include "mozilla/dom/DOMQuad.h" |
6 |
#include "mozilla/dom/DOMQuad.h" |
| 7 |
|
7 |
|
| 8 |
#include "mozilla/dom/DOMQuadBinding.h" |
8 |
#include "mozilla/dom/DOMQuadBinding.h" |
| 9 |
#include "mozilla/dom/DOMPoint.h" |
9 |
#include "mozilla/dom/DOMPoint.h" |
| 10 |
#include "mozilla/dom/DOMRect.h" |
10 |
#include "mozilla/dom/DOMRect.h" |
|
|
11 |
#include "mozilla/dom/BindingDeclarations.h" |
| 11 |
#include "gfxPoint.h" |
12 |
#include "gfxPoint.h" |
| 12 |
#include <algorithm> |
13 |
#include <algorithm> |
| 13 |
|
14 |
|
| 14 |
using namespace mozilla; |
15 |
using namespace mozilla; |
| 15 |
using namespace mozilla::dom; |
16 |
using namespace mozilla::dom; |
| 16 |
|
17 |
|
| 17 |
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_6(DOMQuad, mParent, mBounds, mPoints[0], |
18 |
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_6(DOMQuad, mParent, mBounds, mPoints[0], |
| 18 |
mPoints[1], mPoints[2], mPoints[3]) |
19 |
mPoints[1], mPoints[2], mPoints[3]) |
|
Lines 34-49
DOMQuad::~DOMQuad()
|
Link Here
|
|---|
|
| 34 |
} |
35 |
} |
| 35 |
|
36 |
|
| 36 |
JSObject* |
37 |
JSObject* |
| 37 |
DOMQuad::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) |
38 |
DOMQuad::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) |
| 38 |
{ |
39 |
{ |
| 39 |
return DOMQuadBinding::Wrap(aCx, aScope, this); |
40 |
return DOMQuadBinding::Wrap(aCx, aScope, this); |
| 40 |
} |
41 |
} |
| 41 |
|
42 |
|
|
|
43 |
already_AddRefed<DOMQuad> |
| 44 |
DOMQuad::Constructor(const GlobalObject& aGlobal, DOMRect& aRect, ErrorResult& aRV) |
| 45 |
{ |
| 46 |
gfxPoint points[4] = { |
| 47 |
gfxPoint(aRect.Left(), aRect.Top()), |
| 48 |
gfxPoint(aRect.Right(), aRect.Top()), |
| 49 |
gfxPoint(aRect.Right(), aRect.Bottom()), |
| 50 |
gfxPoint(aRect.Left(), aRect.Bottom()) |
| 51 |
}; |
| 52 |
nsRefPtr<DOMQuad> obj = new DOMQuad(aGlobal.GetAsSupports(), points); |
| 53 |
return obj.forget(); |
| 54 |
} |
| 55 |
|
| 56 |
already_AddRefed<DOMQuad> |
| 57 |
DOMQuad::Constructor(const GlobalObject& aGlobal, DOMPoint& aPoint1, DOMPoint& aPoint2, |
| 58 |
DOMPoint& aPoint3, DOMPoint& aPoint4, ErrorResult& aRV) |
| 59 |
{ |
| 60 |
gfxPoint points[4] = { |
| 61 |
aPoint1.ToGfxPoint(), |
| 62 |
aPoint2.ToGfxPoint(), |
| 63 |
aPoint3.ToGfxPoint(), |
| 64 |
aPoint4.ToGfxPoint() |
| 65 |
}; |
| 66 |
nsRefPtr<DOMQuad> obj = new DOMQuad(aGlobal.GetAsSupports(), points); |
| 67 |
return obj.forget(); |
| 68 |
} |
| 69 |
|
| 42 |
DOMRect* |
70 |
DOMRect* |
| 43 |
DOMQuad::Bounds() const |
71 |
DOMQuad::Bounds() const |
| 44 |
{ |
72 |
{ |
| 45 |
if (!mBounds) { |
73 |
if (!mBounds) { |
| 46 |
double minX = mPoints[0]->X(); |
74 |
double minX = mPoints[0]->X(); |
| 47 |
double minY = mPoints[0]->Y(); |
75 |
double minY = mPoints[0]->Y(); |
| 48 |
double maxX = minX; |
76 |
double maxX = minX; |
| 49 |
double maxY = minY; |
77 |
double maxY = minY; |