dom/events/PaintRequest.h

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

mercurial