Bug 1698786: part 2) Change some compile-time dependent `printf`s to `MOZ_LOG` in...
[gecko.git] / layout / style / nsICSSDeclaration.h
blobfd86fe8135bb9a2dee2e1e3bc48afc7a2a66fd5f
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/. */
7 /*
8 * interface for accessing style declarations using enums instead of strings,
9 * for internal use
12 #ifndef nsICSSDeclaration_h__
13 #define nsICSSDeclaration_h__
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.
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"
27 #include "nsCOMPtr.h"
29 class nsINode;
30 class nsIPrincipal;
31 namespace mozilla {
32 class ErrorResult;
34 namespace css {
35 class Rule;
36 } // namespace css
37 namespace dom {
38 class DocGroup;
39 } // namespace dom
40 } // namespace mozilla
42 // dbeabbfa-6cb3-4f5c-aec2-dd558d9d681f
43 #define NS_ICSSDECLARATION_IID \
44 { \
45 0xdbeabbfa, 0x6cb3, 0x4f5c, { \
46 0xae, 0xc2, 0xdd, 0x55, 0x8d, 0x9d, 0x68, 0x1f \
47 } \
50 class nsICSSDeclaration : public nsISupports, public nsWrapperCache {
51 public:
52 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSSDECLARATION_IID)
54 virtual nsINode* GetParentObject() = 0;
55 mozilla::dom::DocGroup* GetDocGroup();
57 NS_IMETHOD GetPropertyValue(const nsACString& aPropName,
58 nsACString& aValue) = 0;
59 virtual void RemoveProperty(const nsACString& aPropertyName,
60 nsACString& aReturn,
61 mozilla::ErrorResult& aRv) = 0;
62 virtual void SetProperty(const nsACString& aPropertyName,
63 const nsACString& aValue,
64 const nsACString& aPriority,
65 nsIPrincipal* aSubjectPrincipal,
66 mozilla::ErrorResult& aRv) = 0;
67 // For C++ callers.
68 void SetProperty(const nsACString& aPropertyName, const nsACString& aValue,
69 const nsACString& aPriority, mozilla::ErrorResult& aRv) {
70 SetProperty(aPropertyName, aValue, aPriority, nullptr, aRv);
73 void Item(uint32_t aIndex, nsACString& aReturn) {
74 bool found;
75 IndexedGetter(aIndex, found, aReturn);
76 if (!found) {
77 aReturn.Truncate();
81 virtual void GetCSSImageURLs(const nsACString& aPropertyName,
82 nsTArray<nsCString>& aImageURLs,
83 mozilla::ErrorResult& aRv) {
84 aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
87 // WebIDL interface for CSSStyleDeclaration
88 virtual void SetCssText(const nsACString& aString,
89 nsIPrincipal* aSubjectPrincipal,
90 mozilla::ErrorResult& rv) = 0;
91 virtual void GetCssText(nsACString& aString) = 0;
92 virtual uint32_t Length() = 0;
94 // The actual implementation of the Item method and the WebIDL indexed getter
95 virtual void IndexedGetter(uint32_t aIndex, bool& aFound,
96 nsACString& aPropName) = 0;
98 void GetPropertyValue(const nsACString& aPropName, nsACString& aValue,
99 mozilla::ErrorResult& rv) {
100 rv = GetPropertyValue(aPropName, aValue);
102 virtual void GetPropertyPriority(const nsACString& aPropName,
103 nsACString& aPriority) = 0;
104 virtual mozilla::css::Rule* GetParentRule() = 0;
106 protected:
107 bool IsReadOnly();
110 NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSDeclaration, NS_ICSSDECLARATION_IID)
112 #define NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER \
113 void GetCssText(nsACString& aCssText) override; \
114 void SetCssText(const nsACString& aCssText, nsIPrincipal* aSubjectPrincipal, \
115 mozilla::ErrorResult& aRv) override; \
116 NS_IMETHOD GetPropertyValue(const nsACString& propertyName, \
117 nsACString& _retval) override; \
118 void RemoveProperty(const nsACString& propertyName, nsACString& _retval, \
119 mozilla::ErrorResult& aRv) override; \
120 void GetPropertyPriority(const nsACString& propertyName, \
121 nsACString& aPriority) override; \
122 void SetProperty(const nsACString& propertyName, const nsACString& value, \
123 const nsACString& priority, \
124 nsIPrincipal* aSubjectPrincipal, mozilla::ErrorResult& aRv) \
125 override; \
126 uint32_t Length() override; \
127 mozilla::css::Rule* GetParentRule() override;
129 #endif // nsICSSDeclaration_h__