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/. */
7 #ifndef mozilla_dom_PaintRequest_h_
8 #define mozilla_dom_PaintRequest_h_
10 #include "nsPresContext.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/RefPtr.h"
13 #include "mozilla/dom/Event.h"
14 #include "nsWrapperCache.h"
16 namespace mozilla::dom
{
20 class PaintRequest final
: public nsISupports
, public nsWrapperCache
{
22 explicit PaintRequest(Event
* aParent
) : mParent(aParent
) {}
24 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
25 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(PaintRequest
)
27 virtual JSObject
* WrapObject(JSContext
* aCx
,
28 JS::Handle
<JSObject
*> aGivenProto
) override
;
30 Event
* GetParentObject() const { return mParent
; }
32 already_AddRefed
<DOMRect
> ClientRect();
33 void GetReason(nsAString
& aResult
) const { aResult
.AssignLiteral("repaint"); }
35 void SetRequest(const nsRect
& aRequest
) { mRequest
= aRequest
; }
38 ~PaintRequest() = default;
40 RefPtr
<Event
> mParent
;
44 class PaintRequestList final
: public nsISupports
, public nsWrapperCache
{
46 explicit PaintRequestList(Event
* aParent
) : mParent(aParent
) {}
48 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
49 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(PaintRequestList
)
51 virtual JSObject
* WrapObject(JSContext
* aCx
,
52 JS::Handle
<JSObject
*> aGivenProto
) override
;
53 nsISupports
* GetParentObject() { return mParent
; }
55 void Append(PaintRequest
* aElement
) { mArray
.AppendElement(aElement
); }
57 uint32_t Length() { return mArray
.Length(); }
59 PaintRequest
* Item(uint32_t aIndex
) { return mArray
.SafeElementAt(aIndex
); }
60 PaintRequest
* IndexedGetter(uint32_t aIndex
, bool& aFound
) {
61 aFound
= aIndex
< mArray
.Length();
65 return mArray
.ElementAt(aIndex
);
69 ~PaintRequestList() = default;
71 nsTArray
<RefPtr
<PaintRequest
> > mArray
;
72 RefPtr
<Event
> mParent
;
75 } // namespace mozilla::dom
77 #endif // mozilla_dom_PaintRequest_h_