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_StyleSheetList_h
8 #define mozilla_dom_StyleSheetList_h
10 #include "nsContentUtils.h"
11 #include "mozilla/dom/DocumentOrShadowRoot.h"
12 #include "nsStubMutationObserver.h"
13 #include "nsWrapperCache.h"
22 class StyleSheetList final
: public nsStubMutationObserver
,
23 public nsWrapperCache
{
25 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
26 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(StyleSheetList
)
28 NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
30 explicit StyleSheetList(DocumentOrShadowRoot
& aScope
);
32 JSObject
* WrapObject(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) final
;
34 nsINode
* GetParentObject() const {
35 return mDocumentOrShadowRoot
? &mDocumentOrShadowRoot
->AsNode() : nullptr;
38 uint32_t Length() const {
39 return mDocumentOrShadowRoot
? mDocumentOrShadowRoot
->SheetCount() : 0;
42 StyleSheet
* IndexedGetter(uint32_t aIndex
, bool& aFound
) const {
43 if (!mDocumentOrShadowRoot
) {
48 StyleSheet
* sheet
= mDocumentOrShadowRoot
->SheetAt(aIndex
);
53 StyleSheet
* Item(uint32_t aIndex
) const {
55 return IndexedGetter(aIndex
, dummy
);
59 virtual ~StyleSheetList();
62 mDocumentOrShadowRoot
; // Weak, cleared on "NodeWillBeDestroyed".
66 } // namespace mozilla
68 #endif // mozilla_dom_StyleSheetList_h