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"
21 class PaintRequest final
: public nsISupports
, public nsWrapperCache
{
23 explicit PaintRequest(Event
* aParent
) : mParent(aParent
) {}
25 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PaintRequest
)
28 virtual JSObject
* WrapObject(JSContext
* aCx
,
29 JS::Handle
<JSObject
*> aGivenProto
) override
;
31 Event
* GetParentObject() const { return mParent
; }
33 already_AddRefed
<DOMRect
> ClientRect();
34 void GetReason(nsAString
& aResult
) const { aResult
.AssignLiteral("repaint"); }
36 void SetRequest(const nsRect
& aRequest
) { mRequest
= aRequest
; }
39 ~PaintRequest() = default;
41 RefPtr
<Event
> mParent
;
45 class PaintRequestList final
: public nsISupports
, public nsWrapperCache
{
47 explicit PaintRequestList(Event
* aParent
) : mParent(aParent
) {}
49 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
50 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PaintRequestList
)
52 virtual JSObject
* WrapObject(JSContext
* aCx
,
53 JS::Handle
<JSObject
*> aGivenProto
) override
;
54 nsISupports
* GetParentObject() { return mParent
; }
56 void Append(PaintRequest
* aElement
) { mArray
.AppendElement(aElement
); }
58 uint32_t Length() { return mArray
.Length(); }
60 PaintRequest
* Item(uint32_t aIndex
) { return mArray
.SafeElementAt(aIndex
); }
61 PaintRequest
* IndexedGetter(uint32_t aIndex
, bool& aFound
) {
62 aFound
= aIndex
< mArray
.Length();
66 return mArray
.ElementAt(aIndex
);
70 ~PaintRequestList() = default;
72 nsTArray
<RefPtr
<PaintRequest
> > mArray
;
73 RefPtr
<Event
> mParent
;
77 } // namespace mozilla
79 #endif // mozilla_dom_PaintRequest_h_