nsICSSDeclaration.h (5061B)
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 NonCustomCSSPropertyId 18 * enums for the prop names instead of using strings. 19 */ 20 21 #include "NonCustomCSSPropertyId.h" 22 #include "mozilla/ErrorResult.h" 23 #include "mozilla/dom/CSSValue.h" 24 #include "nsCOMPtr.h" 25 #include "nsStringFwd.h" 26 #include "nsWrapperCache.h" 27 28 class nsINode; 29 class nsIPrincipal; 30 namespace mozilla { 31 class ErrorResult; 32 33 namespace css { 34 class Rule; 35 } // namespace css 36 namespace dom { 37 class DocGroup; 38 } // namespace dom 39 } // namespace mozilla 40 41 // dbeabbfa-6cb3-4f5c-aec2-dd558d9d681f 42 #define NS_ICSSDECLARATION_IID \ 43 {0xdbeabbfa, 0x6cb3, 0x4f5c, {0xae, 0xc2, 0xdd, 0x55, 0x8d, 0x9d, 0x68, 0x1f}} 44 45 class nsICSSDeclaration : public nsISupports, public nsWrapperCache { 46 public: 47 NS_INLINE_DECL_STATIC_IID(NS_ICSSDECLARATION_IID) 48 49 virtual nsINode* GetAssociatedNode() const = 0; 50 virtual nsISupports* GetParentObject() const = 0; 51 52 mozilla::dom::DocGroup* GetDocGroup(); 53 54 virtual void GetPropertyValue(const nsACString& aPropName, 55 nsACString& aValue) = 0; 56 virtual void RemoveProperty(const nsACString& aPropertyName, 57 nsACString& aValue, 58 mozilla::ErrorResult& aRv) = 0; 59 virtual void SetProperty(const nsACString& aPropertyName, 60 const nsACString& aValue, 61 const nsACString& aPriority, 62 nsIPrincipal* aSubjectPrincipal, 63 mozilla::ErrorResult& aRv) = 0; 64 // For C++ callers. 65 void SetProperty(const nsACString& aPropertyName, const nsACString& aValue, 66 const nsACString& aPriority, mozilla::ErrorResult& aRv) { 67 SetProperty(aPropertyName, aValue, aPriority, nullptr, aRv); 68 } 69 70 void Item(uint32_t aIndex, nsACString& aReturn) { 71 bool found; 72 IndexedGetter(aIndex, found, aReturn); 73 if (!found) { 74 aReturn.Truncate(); 75 } 76 } 77 78 virtual void GetCSSImageURLs(const nsACString& aPropertyName, 79 nsTArray<nsCString>& aImageURLs, 80 mozilla::ErrorResult& aRv) { 81 aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); 82 } 83 84 // [Chrome only] 85 // Used font-size (taking account of the min-font-size prefs), if available; 86 // returns -1.0 on failure to retrieve a value. 87 virtual float UsedFontSize() { return -1.0; } 88 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; 95 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; 99 100 virtual void GetPropertyPriority(const nsACString& aPropName, 101 nsACString& aPriority) = 0; 102 virtual mozilla::css::Rule* GetParentRule() = 0; 103 104 // [Chrome only] 105 virtual bool HasLonghandProperty(const nsACString& aPropName) { 106 return false; 107 }; 108 109 protected: 110 bool IsReadOnly(); 111 }; 112 113 #define NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER \ 114 void GetCssText(nsACString& aCssText) override; \ 115 void SetCssText(const nsACString& aCssText, nsIPrincipal* aSubjectPrincipal, \ 116 mozilla::ErrorResult& aRv) override; \ 117 void GetPropertyValue(const nsACString& aPropertyName, nsACString& aValue) \ 118 override; \ 119 void RemoveProperty(const nsACString& aPropertyName, nsACString& aValue, \ 120 mozilla::ErrorResult& aRv) override; \ 121 void GetPropertyPriority(const nsACString& aPropertyName, \ 122 nsACString& aPriority) override; \ 123 void SetProperty(const nsACString& aPropertyName, const nsACString& aValue, \ 124 const nsACString& aPriority, \ 125 nsIPrincipal* aSubjectPrincipal, mozilla::ErrorResult& aRv) \ 126 override; \ 127 uint32_t Length() override; \ 128 mozilla::css::Rule* GetParentRule() override; 129 130 #endif // nsICSSDeclaration_h__