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
);
90 // Used font-size (taking account of the min-font-size prefs), if available;
91 // returns -1.0 on failure to retrieve a value.
92 virtual float UsedFontSize() { return -1.0; }
94 // WebIDL interface for CSSStyleDeclaration
95 virtual void SetCssText(const nsACString
& aString
,
96 nsIPrincipal
* aSubjectPrincipal
,
97 mozilla::ErrorResult
& rv
) = 0;
98 virtual void GetCssText(nsACString
& aString
) = 0;
99 virtual uint32_t Length() = 0;
101 // The actual implementation of the Item method and the WebIDL indexed getter
102 virtual void IndexedGetter(uint32_t aIndex
, bool& aFound
,
103 nsACString
& aPropName
) = 0;
105 virtual void GetPropertyPriority(const nsACString
& aPropName
,
106 nsACString
& aPriority
) = 0;
107 virtual mozilla::css::Rule
* GetParentRule() = 0;
113 NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSDeclaration
, NS_ICSSDECLARATION_IID
)
115 #define NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER \
116 void GetCssText(nsACString& aCssText) override; \
117 void SetCssText(const nsACString& aCssText, nsIPrincipal* aSubjectPrincipal, \
118 mozilla::ErrorResult& aRv) override; \
119 void GetPropertyValue(const nsACString& aPropertyName, nsACString& aValue) \
121 void RemoveProperty(const nsACString& aPropertyName, nsACString& aValue, \
122 mozilla::ErrorResult& aRv) override; \
123 void GetPropertyPriority(const nsACString& aPropertyName, \
124 nsACString& aPriority) override; \
125 void SetProperty(const nsACString& aPropertyName, const nsACString& aValue, \
126 const nsACString& aPriority, \
127 nsIPrincipal* aSubjectPrincipal, mozilla::ErrorResult& aRv) \
129 uint32_t Length() override; \
130 mozilla::css::Rule* GetParentRule() override;
132 #endif // nsICSSDeclaration_h__