Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef MOZILLA_DOMQUAD_H_
8 : #define MOZILLA_DOMQUAD_H_
9 :
10 : #include "nsWrapperCache.h"
11 : #include "nsISupports.h"
12 : #include "nsCycleCollectionParticipant.h"
13 : #include "mozilla/Attributes.h"
14 : #include "nsCOMPtr.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 final : public nsWrapperCache
27 : {
28 : ~DOMQuad();
29 :
30 : public:
31 : DOMQuad(nsISupports* aParent, CSSPoint aPoints[4]);
32 : explicit DOMQuad(nsISupports* aParent);
33 :
34 0 : NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMQuad)
35 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMQuad)
36 :
37 0 : nsISupports* GetParentObject() const { return mParent; }
38 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
39 :
40 : static already_AddRefed<DOMQuad>
41 : Constructor(const GlobalObject& aGlobal,
42 : const DOMPointInit& aP1,
43 : const DOMPointInit& aP2,
44 : const DOMPointInit& aP3,
45 : const DOMPointInit& aP4,
46 : ErrorResult& aRV);
47 : static already_AddRefed<DOMQuad>
48 : Constructor(const GlobalObject& aGlobal, const DOMRectReadOnly& aRect,
49 : ErrorResult& aRV);
50 :
51 : DOMRectReadOnly* Bounds() const;
52 0 : DOMPoint* P1() const { return mPoints[0]; }
53 0 : DOMPoint* P2() const { return mPoints[1]; }
54 0 : DOMPoint* P3() const { return mPoints[2]; }
55 0 : DOMPoint* P4() const { return mPoints[3]; }
56 :
57 0 : DOMPoint* Point(uint32_t aIndex) { return mPoints[aIndex]; }
58 :
59 : protected:
60 : class QuadBounds;
61 :
62 : nsCOMPtr<nsISupports> mParent;
63 : RefPtr<DOMPoint> mPoints[4];
64 : mutable RefPtr<QuadBounds> mBounds; // allocated lazily
65 : };
66 :
67 : } // namespace dom
68 : } // namespace mozilla
69 :
70 : #endif /*MOZILLA_DOMRECT_H_*/
|