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/. */
8 * interface for accessing style declarations using enums instead of strings,
12 #ifndef nsICSSDeclaration_h__
13 #define nsICSSDeclaration_h__
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.
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"
38 } // namespace mozilla
40 // dbeabbfa-6cb3-4f5c-aec2-dd558d9d681f
41 #define NS_ICSSDECLARATION_IID \
43 0xdbeabbfa, 0x6cb3, 0x4f5c, { \
44 0xae, 0xc2, 0xdd, 0x55, 0x8d, 0x9d, 0x68, 0x1f \
48 class nsICSSDeclaration
: public nsISupports
, public nsWrapperCache
{
50 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSSDECLARATION_IID
)
52 virtual nsINode
* GetParentObject() = 0;
53 mozilla::dom::DocGroup
* GetDocGroup();
55 NS_IMETHOD
GetPropertyValue(const nsACString
& aPropName
,
56 nsAString
& aValue
) = 0;
57 virtual void RemoveProperty(const nsACString
& aPropertyName
,
59 mozilla::ErrorResult
& aRv
) = 0;
60 virtual void SetProperty(const nsACString
& aPropertyName
,
61 const nsACString
& aValue
, const nsAString
& aPriority
,
62 nsIPrincipal
* aSubjectPrincipal
,
63 mozilla::ErrorResult
& aRv
) = 0;
65 void SetProperty(const nsACString
& aPropertyName
, const nsACString
& aValue
,
66 const nsAString
& aPriority
, mozilla::ErrorResult
& aRv
) {
67 SetProperty(aPropertyName
, aValue
, aPriority
, nullptr, aRv
);
70 void Item(uint32_t aIndex
, nsACString
& aReturn
) {
72 IndexedGetter(aIndex
, found
, aReturn
);
78 virtual void GetCSSImageURLs(const nsACString
& aPropertyName
,
79 nsTArray
<nsCString
>& aImageURLs
,
80 mozilla::ErrorResult
& aRv
) {
81 aRv
.Throw(NS_ERROR_NOT_IMPLEMENTED
);
84 // WebIDL interface for CSSStyleDeclaration
85 virtual void SetCssText(const nsAString
& aString
,
86 nsIPrincipal
* aSubjectPrincipal
,
87 mozilla::ErrorResult
& rv
) = 0;
88 virtual void GetCssText(nsAString
& aString
) = 0;
89 virtual uint32_t Length() = 0;
91 // The actual implementation of the Item method and the WebIDL indexed getter
92 virtual void IndexedGetter(uint32_t aIndex
, bool& aFound
,
93 nsACString
& aPropName
) = 0;
95 void GetPropertyValue(const nsACString
& aPropName
, nsString
& aValue
,
96 mozilla::ErrorResult
& rv
) {
97 rv
= GetPropertyValue(aPropName
, aValue
);
99 virtual void GetPropertyPriority(const nsACString
& aPropName
,
100 nsAString
& aPriority
) = 0;
101 virtual mozilla::css::Rule
* GetParentRule() = 0;
107 NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSDeclaration
, NS_ICSSDECLARATION_IID
)
109 #define NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER \
110 void GetCssText(nsAString& aCssText) override; \
111 void SetCssText(const nsAString& aCssText, nsIPrincipal* aSubjectPrincipal, \
112 mozilla::ErrorResult& aRv) override; \
113 NS_IMETHOD GetPropertyValue(const nsACString& propertyName, \
114 nsAString& _retval) override; \
115 void RemoveProperty(const nsACString& propertyName, nsAString& _retval, \
116 mozilla::ErrorResult& aRv) override; \
117 void GetPropertyPriority(const nsACString& propertyName, \
118 nsAString& aPriority) override; \
119 void SetProperty(const nsACString& propertyName, const nsACString& value, \
120 const nsAString& priority, nsIPrincipal* aSubjectPrincipal, \
121 mozilla::ErrorResult& aRv) override; \
122 uint32_t Length() override; \
123 mozilla::css::Rule* GetParentRule() override;
125 #endif // nsICSSDeclaration_h__