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_dom_PaintRequest_h_
8 : #define mozilla_dom_PaintRequest_h_
9 :
10 : #include "nsIDOMPaintRequest.h"
11 : #include "nsPresContext.h"
12 : #include "nsIDOMEvent.h"
13 : #include "mozilla/Attributes.h"
14 : #include "nsWrapperCache.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : class DOMRect;
20 :
21 : class PaintRequest final : public nsIDOMPaintRequest
22 : , public nsWrapperCache
23 : {
24 : public:
25 0 : explicit PaintRequest(nsIDOMEvent* aParent)
26 0 : : mParent(aParent)
27 : {
28 0 : }
29 :
30 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
31 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PaintRequest)
32 : NS_DECL_NSIDOMPAINTREQUEST
33 :
34 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
35 :
36 0 : nsIDOMEvent* GetParentObject() const
37 : {
38 0 : return mParent;
39 : }
40 :
41 : already_AddRefed<DOMRect> ClientRect();
42 0 : void GetReason(nsAString& aResult) const
43 : {
44 0 : aResult.AssignLiteral("repaint");
45 0 : }
46 :
47 0 : void SetRequest(const nsRect& aRequest)
48 0 : { mRequest = aRequest; }
49 :
50 : private:
51 0 : ~PaintRequest() {}
52 :
53 : nsCOMPtr<nsIDOMEvent> mParent;
54 : nsRect mRequest;
55 : };
56 :
57 : class PaintRequestList final : public nsISupports,
58 : public nsWrapperCache
59 : {
60 : public:
61 0 : explicit PaintRequestList(nsIDOMEvent *aParent) : mParent(aParent)
62 : {
63 0 : }
64 :
65 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
66 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PaintRequestList)
67 :
68 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
69 0 : nsISupports* GetParentObject()
70 : {
71 0 : return mParent;
72 : }
73 :
74 0 : void Append(PaintRequest* aElement)
75 : {
76 0 : mArray.AppendElement(aElement);
77 0 : }
78 :
79 0 : uint32_t Length()
80 : {
81 0 : return mArray.Length();
82 : }
83 :
84 0 : PaintRequest* Item(uint32_t aIndex)
85 : {
86 0 : return mArray.SafeElementAt(aIndex);
87 : }
88 0 : PaintRequest* IndexedGetter(uint32_t aIndex, bool& aFound)
89 : {
90 0 : aFound = aIndex < mArray.Length();
91 0 : if (!aFound) {
92 0 : return nullptr;
93 : }
94 0 : return mArray.ElementAt(aIndex);
95 : }
96 :
97 : private:
98 0 : ~PaintRequestList() {}
99 :
100 : nsTArray< RefPtr<PaintRequest> > mArray;
101 : nsCOMPtr<nsIDOMEvent> mParent;
102 : };
103 :
104 : } // namespace dom
105 : } // namespace mozilla
106 :
107 : #endif // mozilla_dom_PaintRequest_h_
|