content/base/src/DOMQuad.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:90db246ebc6b
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
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/. */
5
6 #ifndef MOZILLA_DOMQUAD_H_
7 #define MOZILLA_DOMQUAD_H_
8
9 #include "nsWrapperCache.h"
10 #include "nsISupports.h"
11 #include "nsCycleCollectionParticipant.h"
12 #include "mozilla/Attributes.h"
13 #include "nsCOMPtr.h"
14 #include "nsAutoPtr.h"
15 #include "mozilla/dom/BindingDeclarations.h"
16 #include "mozilla/ErrorResult.h"
17 #include "Units.h"
18
19 namespace mozilla {
20 namespace dom {
21
22 class DOMRectReadOnly;
23 class DOMPoint;
24 struct DOMPointInit;
25
26 class DOMQuad MOZ_FINAL : public nsWrapperCache
27 {
28 public:
29 DOMQuad(nsISupports* aParent, CSSPoint aPoints[4]);
30 DOMQuad(nsISupports* aParent);
31 ~DOMQuad();
32
33 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMQuad)
34 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMQuad)
35
36 nsISupports* GetParentObject() const { return mParent; }
37 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
38
39 static already_AddRefed<DOMQuad>
40 Constructor(const GlobalObject& aGlobal,
41 const DOMPointInit& aP1,
42 const DOMPointInit& aP2,
43 const DOMPointInit& aP3,
44 const DOMPointInit& aP4,
45 ErrorResult& aRV);
46 static already_AddRefed<DOMQuad>
47 Constructor(const GlobalObject& aGlobal, const DOMRectReadOnly& aRect,
48 ErrorResult& aRV);
49
50 DOMRectReadOnly* Bounds() const;
51 DOMPoint* P1() const { return mPoints[0]; }
52 DOMPoint* P2() const { return mPoints[1]; }
53 DOMPoint* P3() const { return mPoints[2]; }
54 DOMPoint* P4() const { return mPoints[3]; }
55
56 DOMPoint* Point(uint32_t aIndex) { return mPoints[aIndex]; }
57
58 protected:
59 class QuadBounds;
60
61 nsCOMPtr<nsISupports> mParent;
62 nsRefPtr<DOMPoint> mPoints[4];
63 mutable nsRefPtr<QuadBounds> mBounds; // allocated lazily
64 };
65
66 }
67 }
68
69 #endif /*MOZILLA_DOMRECT_H_*/

mercurial