/src/mozilla-central/layout/style/nsICSSDeclaration.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | /* |
8 | | * interface for accessing style declarations using enums instead of strings, |
9 | | * for internal use |
10 | | */ |
11 | | |
12 | | #ifndef nsICSSDeclaration_h__ |
13 | | #define nsICSSDeclaration_h__ |
14 | | |
15 | | /** |
16 | | * This interface provides access to methods analogous to those of |
17 | | * CSSStyleDeclaration; the difference is that these use nsCSSPropertyID |
18 | | * enums for the prop names instead of using strings. |
19 | | */ |
20 | | |
21 | | #include "mozilla/Attributes.h" |
22 | | #include "nsCSSPropertyID.h" |
23 | | #include "mozilla/dom/CSSValue.h" |
24 | | #include "nsWrapperCache.h" |
25 | | #include "nsStringFwd.h" |
26 | | #include "mozilla/ErrorResult.h" |
27 | | #include "nsCOMPtr.h" |
28 | | |
29 | | class nsINode; |
30 | | class nsIPrincipal; |
31 | | namespace mozilla { |
32 | | namespace css { |
33 | | class Rule; |
34 | | } // namespace css |
35 | | namespace dom { |
36 | | class DocGroup; |
37 | | } // namespace dom |
38 | | } // namespace mozilla |
39 | | |
40 | | // dbeabbfa-6cb3-4f5c-aec2-dd558d9d681f |
41 | | #define NS_ICSSDECLARATION_IID \ |
42 | | { 0xdbeabbfa, 0x6cb3, 0x4f5c, \ |
43 | | { 0xae, 0xc2, 0xdd, 0x55, 0x8d, 0x9d, 0x68, 0x1f } } |
44 | | |
45 | | class nsICSSDeclaration : public nsISupports |
46 | | , public nsWrapperCache |
47 | | { |
48 | | public: |
49 | | NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSSDECLARATION_IID) |
50 | | |
51 | | virtual nsINode *GetParentObject() = 0; |
52 | | mozilla::dom::DocGroup* GetDocGroup(); |
53 | | |
54 | | NS_IMETHOD GetPropertyValue(const nsAString& aPropName, |
55 | | nsAString& aValue) = 0; |
56 | | NS_IMETHOD RemoveProperty(const nsAString& aPropertyName, |
57 | | nsAString& aReturn) = 0; |
58 | | NS_IMETHOD SetProperty(const nsAString& aPropertyName, |
59 | | const nsAString& aValue, |
60 | | const nsAString& aPriority, |
61 | | nsIPrincipal* aSubjectPrincipal = nullptr) = 0; |
62 | | void Item(uint32_t aIndex, nsAString& aReturn) |
63 | 0 | { |
64 | 0 | bool found; |
65 | 0 | IndexedGetter(aIndex, found, aReturn); |
66 | 0 | if (!found) { |
67 | 0 | aReturn.Truncate(); |
68 | 0 | } |
69 | 0 | } |
70 | | |
71 | | virtual void |
72 | | GetCSSImageURLs(const nsAString& aPropertyName, |
73 | | nsTArray<nsString>& aImageURLs, |
74 | | mozilla::ErrorResult& aRv) |
75 | 0 | { |
76 | 0 | aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); |
77 | 0 | } |
78 | | |
79 | | // WebIDL interface for CSSStyleDeclaration |
80 | | virtual void SetCssText(const nsAString& aString, |
81 | | nsIPrincipal* aSubjectPrincipal, |
82 | | mozilla::ErrorResult& rv) = 0; |
83 | | virtual void GetCssText(nsAString& aString) = 0; |
84 | | virtual uint32_t Length() = 0; |
85 | | |
86 | | // The actual implementation of the Item method and the WebIDL indexed getter |
87 | | virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) = 0; |
88 | | |
89 | | void GetPropertyValue(const nsAString& aPropName, nsString& aValue, |
90 | 0 | mozilla::ErrorResult& rv) { |
91 | 0 | rv = GetPropertyValue(aPropName, aValue); |
92 | 0 | } |
93 | | virtual void GetPropertyPriority(const nsAString& aPropName, |
94 | | nsAString& aPriority) = 0; |
95 | | void SetProperty(const nsAString& aPropName, const nsAString& aValue, |
96 | | const nsAString& aPriority, nsIPrincipal* aSubjectPrincipal, |
97 | 0 | mozilla::ErrorResult& rv) { |
98 | 0 | rv = SetProperty(aPropName, aValue, aPriority, aSubjectPrincipal); |
99 | 0 | } |
100 | | void RemoveProperty(const nsAString& aPropName, nsString& aRetval, |
101 | 0 | mozilla::ErrorResult& rv) { |
102 | 0 | rv = RemoveProperty(aPropName, aRetval); |
103 | 0 | } |
104 | | virtual mozilla::css::Rule* GetParentRule() = 0; |
105 | | }; |
106 | | |
107 | | NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSDeclaration, NS_ICSSDECLARATION_IID) |
108 | | |
109 | | #define NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER \ |
110 | | void GetCssText(nsAString& aCssText) override; \ |
111 | | void SetCssText(const nsAString& aCssText, \ |
112 | | nsIPrincipal* aSubjectPrincipal, \ |
113 | | mozilla::ErrorResult& aRv) override; \ |
114 | | NS_IMETHOD GetPropertyValue(const nsAString & propertyName, nsAString & _retval) override; \ |
115 | | NS_IMETHOD RemoveProperty(const nsAString & propertyName, nsAString & _retval) override; \ |
116 | | void GetPropertyPriority(const nsAString & propertyName, \ |
117 | | nsAString & aPriority) override; \ |
118 | | NS_IMETHOD SetProperty(const nsAString& propertyName, \ |
119 | | const nsAString& value, \ |
120 | | const nsAString& priority, \ |
121 | | nsIPrincipal* aSubjectPrincipal = nullptr) override; \ |
122 | | uint32_t Length() override; \ |
123 | | mozilla::css::Rule* GetParentRule() override; |
124 | | |
125 | | #endif // nsICSSDeclaration_h__ |