Line data Source code
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_CSSRuleList_h
7 : #define mozilla_dom_CSSRuleList_h
8 :
9 : #include "mozilla/StyleSheetInlines.h"
10 : #include "mozilla/css/Rule.h"
11 : #include "nsIDOMCSSRule.h"
12 : #include "nsIDOMCSSRuleList.h"
13 : #include "nsWrapperCache.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : // IID for the CSSRuleList interface
19 : #define NS_ICSSRULELIST_IID \
20 : { 0x56ac8d1c, 0xc1ed, 0x45fe, \
21 : { 0x9a, 0x4d, 0x3a, 0xdc, 0xf9, 0xd1, 0xb9, 0x3f } }
22 :
23 0 : class CSSRuleList : public nsIDOMCSSRuleList
24 : , public nsWrapperCache
25 : {
26 : public:
27 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSSRULELIST_IID)
28 :
29 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
30 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CSSRuleList)
31 :
32 : virtual StyleSheet* GetParentObject() = 0;
33 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override final;
34 :
35 : NS_IMETHOD
36 0 : GetLength(uint32_t* aLength) override final
37 : {
38 0 : *aLength = Length();
39 0 : return NS_OK;
40 : }
41 : NS_IMETHOD
42 0 : Item(uint32_t aIndex, nsIDOMCSSRule** aReturn) override final
43 : {
44 0 : NS_IF_ADDREF(*aReturn = Item(aIndex));
45 0 : return NS_OK;
46 : }
47 :
48 : // WebIDL API
49 0 : css::Rule* Item(uint32_t aIndex)
50 : {
51 : bool unused;
52 0 : return IndexedGetter(aIndex, unused);
53 : }
54 :
55 : virtual css::Rule* IndexedGetter(uint32_t aIndex, bool& aFound) = 0;
56 : virtual uint32_t Length() = 0;
57 :
58 : protected:
59 0 : virtual ~CSSRuleList() {}
60 : };
61 :
62 : NS_DEFINE_STATIC_IID_ACCESSOR(CSSRuleList, NS_ICSSRULELIST_IID)
63 :
64 : } // namespace dom
65 : } // namespace mozilla
66 :
67 : #endif /* mozilla_dom_CSSRuleList_h */
|