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 "mozilla/ErrorResult.h"
25 #include "nsWrapperCache.h"
26 #include "nsStringFwd.h"
40 } // namespace mozilla
42 // dbeabbfa-6cb3-4f5c-aec2-dd558d9d681f
43 #define NS_ICSSDECLARATION_IID \
45 0xdbeabbfa, 0x6cb3, 0x4f5c, { \
46 0xae, 0xc2, 0xdd, 0x55, 0x8d, 0x9d, 0x68, 0x1f \
50 class nsICSSDeclaration
: public nsISupports
, public nsWrapperCache
{
52 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSSDECLARATION_IID
)
54 virtual nsINode
* GetAssociatedNode() const = 0;
55 virtual nsISupports
* GetParentObject() const = 0;
57 mozilla::dom::DocGroup
* GetDocGroup();
59 virtual void GetPropertyValue(const nsACString
& aPropName
,
60 nsACString
& aValue
) = 0;
61 virtual void RemoveProperty(const nsACString
& aPropertyName
,
63 mozilla::ErrorResult
& aRv
) = 0;
64 virtual void SetProperty(const nsACString
& aPropertyName
,
65 const nsACString
& aValue
,
66 const nsACString
& aPriority
,
67 nsIPrincipal
* aSubjectPrincipal
,
68 mozilla::ErrorResult
& aRv
) = 0;
70 void SetProperty(const nsACString
& aPropertyName
, const nsACString
& aValue
,
71 const nsACString
& aPriority
, mozilla::ErrorResult
& aRv
) {
72 SetProperty(aPropertyName
, aValue
, aPriority
, nullptr, aRv
);
75 void Item(uint32_t aIndex
, nsACString
& aReturn
) {
77 IndexedGetter(aIndex
, found
, aReturn
);
83 virtual void GetCSSImageURLs(const nsACString
& aPropertyName
,
84 nsTArray
<nsCString
>& aImageURLs
,
85 mozilla::ErrorResult
& aRv
) {
86 aRv
.Throw(NS_ERROR_NOT_IMPLEMENTED
);
89 // WebIDL interface for CSSStyleDeclaration
90 virtual void SetCssText(const nsACString
& aString
,
91 nsIPrincipal
* aSubjectPrincipal
,
92 mozilla::ErrorResult
& rv
) = 0;
93 virtual void GetCssText(nsACString
& aString
) = 0;
94 virtual uint32_t Length() = 0;
96 // The actual implementation of the Item method and the WebIDL indexed getter
97 virtual void IndexedGetter(uint32_t aIndex
, bool& aFound
,
98 nsACString
& aPropName
) = 0;
100 virtual void GetPropertyPriority(const nsACString
& aPropName
,
101 nsACString
& aPriority
) = 0;
102 virtual mozilla::css::Rule
* GetParentRule() = 0;
108 NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSDeclaration
, NS_ICSSDECLARATION_IID
)
110 #define NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER \
111 void GetCssText(nsACString& aCssText) override; \
112 void SetCssText(const nsACString& aCssText, nsIPrincipal* aSubjectPrincipal, \
113 mozilla::ErrorResult& aRv) override; \
114 void GetPropertyValue(const nsACString& aPropertyName, nsACString& aValue) \
116 void RemoveProperty(const nsACString& aPropertyName, nsACString& aValue, \
117 mozilla::ErrorResult& aRv) override; \
118 void GetPropertyPriority(const nsACString& aPropertyName, \
119 nsACString& aPriority) override; \
120 void SetProperty(const nsACString& aPropertyName, const nsACString& aValue, \
121 const nsACString& aPriority, \
122 nsIPrincipal* aSubjectPrincipal, mozilla::ErrorResult& aRv) \
124 uint32_t Length() override; \
125 mozilla::css::Rule* GetParentRule() override;
127 #endif // nsICSSDeclaration_h__