Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | // vim:cindent:ts=2:et:sw=2: |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | /* rules in a CSS stylesheet other than style rules (e.g., @import rules) */ |
michael@0 | 8 | |
michael@0 | 9 | #ifndef nsCSSRules_h_ |
michael@0 | 10 | #define nsCSSRules_h_ |
michael@0 | 11 | |
michael@0 | 12 | #include "mozilla/Attributes.h" |
michael@0 | 13 | |
michael@0 | 14 | #include "mozilla/MemoryReporting.h" |
michael@0 | 15 | #include "mozilla/css/GroupRule.h" |
michael@0 | 16 | #include "mozilla/Preferences.h" |
michael@0 | 17 | #include "nsIDOMCSSConditionRule.h" |
michael@0 | 18 | #include "nsIDOMCSSFontFaceRule.h" |
michael@0 | 19 | #include "nsIDOMCSSFontFeatureValuesRule.h" |
michael@0 | 20 | #include "nsIDOMCSSGroupingRule.h" |
michael@0 | 21 | #include "nsIDOMCSSMediaRule.h" |
michael@0 | 22 | #include "nsIDOMCSSMozDocumentRule.h" |
michael@0 | 23 | #include "nsIDOMCSSSupportsRule.h" |
michael@0 | 24 | #include "nsIDOMMozCSSKeyframeRule.h" |
michael@0 | 25 | #include "nsIDOMMozCSSKeyframesRule.h" |
michael@0 | 26 | #include "nsAutoPtr.h" |
michael@0 | 27 | #include "nsCSSProperty.h" |
michael@0 | 28 | #include "nsCSSValue.h" |
michael@0 | 29 | #include "nsIDOMCSSCharsetRule.h" |
michael@0 | 30 | #include "nsTArray.h" |
michael@0 | 31 | #include "nsDOMCSSDeclaration.h" |
michael@0 | 32 | #include "Declaration.h" |
michael@0 | 33 | #include "nsIDOMCSSPageRule.h" |
michael@0 | 34 | #include "StyleRule.h" |
michael@0 | 35 | #include "gfxFontFeatures.h" |
michael@0 | 36 | |
michael@0 | 37 | class nsMediaList; |
michael@0 | 38 | |
michael@0 | 39 | namespace mozilla { |
michael@0 | 40 | |
michael@0 | 41 | class ErrorResult; |
michael@0 | 42 | |
michael@0 | 43 | namespace css { |
michael@0 | 44 | |
michael@0 | 45 | class MediaRule MOZ_FINAL : public GroupRule, |
michael@0 | 46 | public nsIDOMCSSMediaRule |
michael@0 | 47 | { |
michael@0 | 48 | public: |
michael@0 | 49 | MediaRule(); |
michael@0 | 50 | private: |
michael@0 | 51 | MediaRule(const MediaRule& aCopy); |
michael@0 | 52 | ~MediaRule(); |
michael@0 | 53 | public: |
michael@0 | 54 | |
michael@0 | 55 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 56 | |
michael@0 | 57 | // nsIStyleRule methods |
michael@0 | 58 | #ifdef DEBUG |
michael@0 | 59 | virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; |
michael@0 | 60 | #endif |
michael@0 | 61 | |
michael@0 | 62 | // Rule methods |
michael@0 | 63 | virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); //override GroupRule |
michael@0 | 64 | virtual int32_t GetType() const; |
michael@0 | 65 | virtual already_AddRefed<Rule> Clone() const; |
michael@0 | 66 | virtual nsIDOMCSSRule* GetDOMRule() |
michael@0 | 67 | { |
michael@0 | 68 | return this; |
michael@0 | 69 | } |
michael@0 | 70 | virtual nsIDOMCSSRule* GetExistingDOMRule() |
michael@0 | 71 | { |
michael@0 | 72 | return this; |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | // nsIDOMCSSRule interface |
michael@0 | 76 | NS_DECL_NSIDOMCSSRULE |
michael@0 | 77 | |
michael@0 | 78 | // nsIDOMCSSGroupingRule interface |
michael@0 | 79 | NS_DECL_NSIDOMCSSGROUPINGRULE |
michael@0 | 80 | |
michael@0 | 81 | // nsIDOMCSSConditionRule interface |
michael@0 | 82 | NS_DECL_NSIDOMCSSCONDITIONRULE |
michael@0 | 83 | |
michael@0 | 84 | // nsIDOMCSSMediaRule interface |
michael@0 | 85 | NS_DECL_NSIDOMCSSMEDIARULE |
michael@0 | 86 | |
michael@0 | 87 | // rest of GroupRule |
michael@0 | 88 | virtual bool UseForPresentation(nsPresContext* aPresContext, |
michael@0 | 89 | nsMediaQueryResultCacheKey& aKey); |
michael@0 | 90 | |
michael@0 | 91 | // @media rule methods |
michael@0 | 92 | nsresult SetMedia(nsMediaList* aMedia); |
michael@0 | 93 | |
michael@0 | 94 | virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) |
michael@0 | 95 | const MOZ_MUST_OVERRIDE; |
michael@0 | 96 | |
michael@0 | 97 | protected: |
michael@0 | 98 | void AppendConditionText(nsAString& aOutput); |
michael@0 | 99 | |
michael@0 | 100 | nsRefPtr<nsMediaList> mMedia; |
michael@0 | 101 | }; |
michael@0 | 102 | |
michael@0 | 103 | class DocumentRule MOZ_FINAL : public GroupRule, |
michael@0 | 104 | public nsIDOMCSSMozDocumentRule |
michael@0 | 105 | { |
michael@0 | 106 | public: |
michael@0 | 107 | DocumentRule(); |
michael@0 | 108 | private: |
michael@0 | 109 | DocumentRule(const DocumentRule& aCopy); |
michael@0 | 110 | ~DocumentRule(); |
michael@0 | 111 | public: |
michael@0 | 112 | |
michael@0 | 113 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 114 | |
michael@0 | 115 | // nsIStyleRule methods |
michael@0 | 116 | #ifdef DEBUG |
michael@0 | 117 | virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; |
michael@0 | 118 | #endif |
michael@0 | 119 | |
michael@0 | 120 | // Rule methods |
michael@0 | 121 | virtual int32_t GetType() const; |
michael@0 | 122 | virtual already_AddRefed<Rule> Clone() const; |
michael@0 | 123 | virtual nsIDOMCSSRule* GetDOMRule() |
michael@0 | 124 | { |
michael@0 | 125 | return this; |
michael@0 | 126 | } |
michael@0 | 127 | virtual nsIDOMCSSRule* GetExistingDOMRule() |
michael@0 | 128 | { |
michael@0 | 129 | return this; |
michael@0 | 130 | } |
michael@0 | 131 | |
michael@0 | 132 | // nsIDOMCSSRule interface |
michael@0 | 133 | NS_DECL_NSIDOMCSSRULE |
michael@0 | 134 | |
michael@0 | 135 | // nsIDOMCSSGroupingRule interface |
michael@0 | 136 | NS_DECL_NSIDOMCSSGROUPINGRULE |
michael@0 | 137 | |
michael@0 | 138 | // nsIDOMCSSConditionRule interface |
michael@0 | 139 | NS_DECL_NSIDOMCSSCONDITIONRULE |
michael@0 | 140 | |
michael@0 | 141 | // nsIDOMCSSMozDocumentRule interface |
michael@0 | 142 | NS_DECL_NSIDOMCSSMOZDOCUMENTRULE |
michael@0 | 143 | |
michael@0 | 144 | // rest of GroupRule |
michael@0 | 145 | virtual bool UseForPresentation(nsPresContext* aPresContext, |
michael@0 | 146 | nsMediaQueryResultCacheKey& aKey); |
michael@0 | 147 | |
michael@0 | 148 | enum Function { |
michael@0 | 149 | eURL, |
michael@0 | 150 | eURLPrefix, |
michael@0 | 151 | eDomain, |
michael@0 | 152 | eRegExp |
michael@0 | 153 | }; |
michael@0 | 154 | |
michael@0 | 155 | struct URL { |
michael@0 | 156 | Function func; |
michael@0 | 157 | nsCString url; |
michael@0 | 158 | URL *next; |
michael@0 | 159 | |
michael@0 | 160 | URL() : next(nullptr) {} |
michael@0 | 161 | URL(const URL& aOther) |
michael@0 | 162 | : func(aOther.func) |
michael@0 | 163 | , url(aOther.url) |
michael@0 | 164 | , next(aOther.next ? new URL(*aOther.next) : nullptr) |
michael@0 | 165 | { |
michael@0 | 166 | } |
michael@0 | 167 | ~URL(); |
michael@0 | 168 | }; |
michael@0 | 169 | |
michael@0 | 170 | void SetURLs(URL *aURLs) { mURLs = aURLs; } |
michael@0 | 171 | |
michael@0 | 172 | virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) |
michael@0 | 173 | const MOZ_MUST_OVERRIDE; |
michael@0 | 174 | |
michael@0 | 175 | protected: |
michael@0 | 176 | void AppendConditionText(nsAString& aOutput); |
michael@0 | 177 | |
michael@0 | 178 | nsAutoPtr<URL> mURLs; // linked list of |struct URL| above. |
michael@0 | 179 | }; |
michael@0 | 180 | |
michael@0 | 181 | } // namespace css |
michael@0 | 182 | } // namespace mozilla |
michael@0 | 183 | |
michael@0 | 184 | // A nsCSSFontFaceStyleDecl is always embedded in a nsCSSFontFaceRule. |
michael@0 | 185 | class nsCSSFontFaceRule; |
michael@0 | 186 | class nsCSSFontFaceStyleDecl : public nsICSSDeclaration |
michael@0 | 187 | { |
michael@0 | 188 | public: |
michael@0 | 189 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 190 | NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER |
michael@0 | 191 | NS_DECL_NSICSSDECLARATION |
michael@0 | 192 | virtual already_AddRefed<mozilla::dom::CSSValue> |
michael@0 | 193 | GetPropertyCSSValue(const nsAString& aProp, mozilla::ErrorResult& aRv) |
michael@0 | 194 | MOZ_OVERRIDE; |
michael@0 | 195 | using nsICSSDeclaration::GetPropertyCSSValue; |
michael@0 | 196 | |
michael@0 | 197 | nsCSSFontFaceStyleDecl() |
michael@0 | 198 | { |
michael@0 | 199 | SetIsDOMBinding(); |
michael@0 | 200 | } |
michael@0 | 201 | |
michael@0 | 202 | virtual nsINode *GetParentObject() MOZ_OVERRIDE; |
michael@0 | 203 | virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) MOZ_OVERRIDE; |
michael@0 | 204 | |
michael@0 | 205 | nsresult GetPropertyValue(nsCSSFontDesc aFontDescID, |
michael@0 | 206 | nsAString & aResult) const; |
michael@0 | 207 | |
michael@0 | 208 | virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; |
michael@0 | 209 | |
michael@0 | 210 | protected: |
michael@0 | 211 | friend class nsCSSFontFaceRule; |
michael@0 | 212 | #define CSS_FONT_DESC(name_, method_) nsCSSValue m##method_; |
michael@0 | 213 | #include "nsCSSFontDescList.h" |
michael@0 | 214 | #undef CSS_FONT_DESC |
michael@0 | 215 | |
michael@0 | 216 | static nsCSSValue nsCSSFontFaceStyleDecl::* const Fields[]; |
michael@0 | 217 | inline nsCSSFontFaceRule* ContainingRule(); |
michael@0 | 218 | inline const nsCSSFontFaceRule* ContainingRule() const; |
michael@0 | 219 | |
michael@0 | 220 | private: |
michael@0 | 221 | // NOT TO BE IMPLEMENTED |
michael@0 | 222 | // This object cannot be allocated on its own, only as part of |
michael@0 | 223 | // nsCSSFontFaceRule. |
michael@0 | 224 | void* operator new(size_t size) CPP_THROW_NEW; |
michael@0 | 225 | }; |
michael@0 | 226 | |
michael@0 | 227 | class nsCSSFontFaceRule MOZ_FINAL : public mozilla::css::Rule, |
michael@0 | 228 | public nsIDOMCSSFontFaceRule |
michael@0 | 229 | { |
michael@0 | 230 | public: |
michael@0 | 231 | nsCSSFontFaceRule() {} |
michael@0 | 232 | |
michael@0 | 233 | nsCSSFontFaceRule(const nsCSSFontFaceRule& aCopy) |
michael@0 | 234 | // copy everything except our reference count |
michael@0 | 235 | : mozilla::css::Rule(aCopy), mDecl(aCopy.mDecl) {} |
michael@0 | 236 | |
michael@0 | 237 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 238 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSFontFaceRule, |
michael@0 | 239 | mozilla::css::Rule) |
michael@0 | 240 | |
michael@0 | 241 | // nsIStyleRule methods |
michael@0 | 242 | #ifdef DEBUG |
michael@0 | 243 | virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; |
michael@0 | 244 | #endif |
michael@0 | 245 | |
michael@0 | 246 | // Rule methods |
michael@0 | 247 | DECL_STYLE_RULE_INHERIT |
michael@0 | 248 | |
michael@0 | 249 | virtual int32_t GetType() const MOZ_OVERRIDE; |
michael@0 | 250 | virtual already_AddRefed<mozilla::css::Rule> Clone() const; |
michael@0 | 251 | |
michael@0 | 252 | // nsIDOMCSSRule interface |
michael@0 | 253 | NS_DECL_NSIDOMCSSRULE |
michael@0 | 254 | |
michael@0 | 255 | // nsIDOMCSSFontFaceRule interface |
michael@0 | 256 | NS_DECL_NSIDOMCSSFONTFACERULE |
michael@0 | 257 | |
michael@0 | 258 | void SetDesc(nsCSSFontDesc aDescID, nsCSSValue const & aValue); |
michael@0 | 259 | void GetDesc(nsCSSFontDesc aDescID, nsCSSValue & aValue); |
michael@0 | 260 | |
michael@0 | 261 | virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; |
michael@0 | 262 | |
michael@0 | 263 | protected: |
michael@0 | 264 | friend class nsCSSFontFaceStyleDecl; |
michael@0 | 265 | nsCSSFontFaceStyleDecl mDecl; |
michael@0 | 266 | }; |
michael@0 | 267 | |
michael@0 | 268 | // nsFontFaceRuleContainer - used for associating sheet type with |
michael@0 | 269 | // specific @font-face rules |
michael@0 | 270 | struct nsFontFaceRuleContainer { |
michael@0 | 271 | nsRefPtr<nsCSSFontFaceRule> mRule; |
michael@0 | 272 | uint8_t mSheetType; |
michael@0 | 273 | }; |
michael@0 | 274 | |
michael@0 | 275 | inline nsCSSFontFaceRule* |
michael@0 | 276 | nsCSSFontFaceStyleDecl::ContainingRule() |
michael@0 | 277 | { |
michael@0 | 278 | return reinterpret_cast<nsCSSFontFaceRule*> |
michael@0 | 279 | (reinterpret_cast<char*>(this) - offsetof(nsCSSFontFaceRule, mDecl)); |
michael@0 | 280 | } |
michael@0 | 281 | |
michael@0 | 282 | inline const nsCSSFontFaceRule* |
michael@0 | 283 | nsCSSFontFaceStyleDecl::ContainingRule() const |
michael@0 | 284 | { |
michael@0 | 285 | return reinterpret_cast<const nsCSSFontFaceRule*> |
michael@0 | 286 | (reinterpret_cast<const char*>(this) - offsetof(nsCSSFontFaceRule, mDecl)); |
michael@0 | 287 | } |
michael@0 | 288 | |
michael@0 | 289 | class nsCSSFontFeatureValuesRule MOZ_FINAL : |
michael@0 | 290 | public mozilla::css::Rule, |
michael@0 | 291 | public nsIDOMCSSFontFeatureValuesRule |
michael@0 | 292 | { |
michael@0 | 293 | public: |
michael@0 | 294 | nsCSSFontFeatureValuesRule() {} |
michael@0 | 295 | |
michael@0 | 296 | nsCSSFontFeatureValuesRule(const nsCSSFontFeatureValuesRule& aCopy) |
michael@0 | 297 | // copy everything except our reference count |
michael@0 | 298 | : mozilla::css::Rule(aCopy), |
michael@0 | 299 | mFamilyList(aCopy.mFamilyList), |
michael@0 | 300 | mFeatureValues(aCopy.mFeatureValues) {} |
michael@0 | 301 | |
michael@0 | 302 | NS_DECL_ISUPPORTS |
michael@0 | 303 | |
michael@0 | 304 | // nsIStyleRule methods |
michael@0 | 305 | #ifdef DEBUG |
michael@0 | 306 | virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; |
michael@0 | 307 | #endif |
michael@0 | 308 | |
michael@0 | 309 | // Rule methods |
michael@0 | 310 | DECL_STYLE_RULE_INHERIT |
michael@0 | 311 | |
michael@0 | 312 | virtual int32_t GetType() const MOZ_OVERRIDE; |
michael@0 | 313 | virtual already_AddRefed<mozilla::css::Rule> Clone() const MOZ_OVERRIDE; |
michael@0 | 314 | |
michael@0 | 315 | // nsIDOMCSSRule interface |
michael@0 | 316 | NS_DECL_NSIDOMCSSRULE |
michael@0 | 317 | |
michael@0 | 318 | // nsIDOMCSSFontFaceRule interface |
michael@0 | 319 | NS_DECL_NSIDOMCSSFONTFEATUREVALUESRULE |
michael@0 | 320 | |
michael@0 | 321 | const nsTArray<nsString>& GetFamilyList() { return mFamilyList; } |
michael@0 | 322 | void SetFamilyList(const nsAString& aFamilyList, bool& aContainsGeneric); |
michael@0 | 323 | |
michael@0 | 324 | void AddValueList(int32_t aVariantAlternate, |
michael@0 | 325 | nsTArray<gfxFontFeatureValueSet::ValueList>& aValueList); |
michael@0 | 326 | |
michael@0 | 327 | const nsTArray<gfxFontFeatureValueSet::FeatureValues>& GetFeatureValues() |
michael@0 | 328 | { |
michael@0 | 329 | return mFeatureValues; |
michael@0 | 330 | } |
michael@0 | 331 | |
michael@0 | 332 | virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; |
michael@0 | 333 | |
michael@0 | 334 | static bool PrefEnabled() |
michael@0 | 335 | { |
michael@0 | 336 | // font-variant-alternates enabled ==> layout.css.font-features.enabled is true |
michael@0 | 337 | bool fontFeaturesEnabled = |
michael@0 | 338 | nsCSSProps::IsEnabled(eCSSProperty_font_variant_alternates); |
michael@0 | 339 | |
michael@0 | 340 | return fontFeaturesEnabled; |
michael@0 | 341 | } |
michael@0 | 342 | |
michael@0 | 343 | protected: |
michael@0 | 344 | nsTArray<nsString> mFamilyList; |
michael@0 | 345 | nsTArray<gfxFontFeatureValueSet::FeatureValues> mFeatureValues; |
michael@0 | 346 | }; |
michael@0 | 347 | |
michael@0 | 348 | namespace mozilla { |
michael@0 | 349 | namespace css { |
michael@0 | 350 | |
michael@0 | 351 | class CharsetRule MOZ_FINAL : public Rule, |
michael@0 | 352 | public nsIDOMCSSCharsetRule |
michael@0 | 353 | { |
michael@0 | 354 | public: |
michael@0 | 355 | CharsetRule(const nsAString& aEncoding); |
michael@0 | 356 | private: |
michael@0 | 357 | // For |Clone| |
michael@0 | 358 | CharsetRule(const CharsetRule& aCopy); |
michael@0 | 359 | ~CharsetRule() {} |
michael@0 | 360 | |
michael@0 | 361 | public: |
michael@0 | 362 | NS_DECL_ISUPPORTS |
michael@0 | 363 | |
michael@0 | 364 | DECL_STYLE_RULE_INHERIT |
michael@0 | 365 | |
michael@0 | 366 | // nsIStyleRule methods |
michael@0 | 367 | #ifdef DEBUG |
michael@0 | 368 | virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; |
michael@0 | 369 | #endif |
michael@0 | 370 | |
michael@0 | 371 | // Rule methods |
michael@0 | 372 | virtual int32_t GetType() const; |
michael@0 | 373 | virtual already_AddRefed<Rule> Clone() const; |
michael@0 | 374 | |
michael@0 | 375 | // nsIDOMCSSRule interface |
michael@0 | 376 | NS_DECL_NSIDOMCSSRULE |
michael@0 | 377 | |
michael@0 | 378 | // nsIDOMCSSCharsetRule methods |
michael@0 | 379 | NS_IMETHOD GetEncoding(nsAString& aEncoding) MOZ_OVERRIDE; |
michael@0 | 380 | NS_IMETHOD SetEncoding(const nsAString& aEncoding) MOZ_OVERRIDE; |
michael@0 | 381 | |
michael@0 | 382 | virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 383 | |
michael@0 | 384 | private: |
michael@0 | 385 | nsString mEncoding; |
michael@0 | 386 | }; |
michael@0 | 387 | |
michael@0 | 388 | } // namespace css |
michael@0 | 389 | } // namespace mozilla |
michael@0 | 390 | |
michael@0 | 391 | class nsCSSKeyframeRule; |
michael@0 | 392 | |
michael@0 | 393 | class nsCSSKeyframeStyleDeclaration MOZ_FINAL : public nsDOMCSSDeclaration |
michael@0 | 394 | { |
michael@0 | 395 | public: |
michael@0 | 396 | nsCSSKeyframeStyleDeclaration(nsCSSKeyframeRule *aRule); |
michael@0 | 397 | virtual ~nsCSSKeyframeStyleDeclaration(); |
michael@0 | 398 | |
michael@0 | 399 | NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) MOZ_OVERRIDE; |
michael@0 | 400 | void DropReference() { mRule = nullptr; } |
michael@0 | 401 | virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate) MOZ_OVERRIDE; |
michael@0 | 402 | virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) MOZ_OVERRIDE; |
michael@0 | 403 | virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) MOZ_OVERRIDE; |
michael@0 | 404 | virtual nsIDocument* DocToUpdate() MOZ_OVERRIDE; |
michael@0 | 405 | |
michael@0 | 406 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 407 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSKeyframeStyleDeclaration, |
michael@0 | 408 | nsICSSDeclaration) |
michael@0 | 409 | |
michael@0 | 410 | virtual nsINode* GetParentObject() MOZ_OVERRIDE; |
michael@0 | 411 | |
michael@0 | 412 | protected: |
michael@0 | 413 | // This reference is not reference-counted. The rule object tells us |
michael@0 | 414 | // when it's about to go away. |
michael@0 | 415 | nsCSSKeyframeRule *mRule; |
michael@0 | 416 | }; |
michael@0 | 417 | |
michael@0 | 418 | class nsCSSKeyframeRule MOZ_FINAL : public mozilla::css::Rule, |
michael@0 | 419 | public nsIDOMMozCSSKeyframeRule |
michael@0 | 420 | { |
michael@0 | 421 | public: |
michael@0 | 422 | // WARNING: Steals the contents of aKeys *and* aDeclaration |
michael@0 | 423 | nsCSSKeyframeRule(InfallibleTArray<float>& aKeys, |
michael@0 | 424 | nsAutoPtr<mozilla::css::Declaration> aDeclaration) |
michael@0 | 425 | : mDeclaration(aDeclaration) |
michael@0 | 426 | { |
michael@0 | 427 | mKeys.SwapElements(aKeys); |
michael@0 | 428 | } |
michael@0 | 429 | private: |
michael@0 | 430 | nsCSSKeyframeRule(const nsCSSKeyframeRule& aCopy); |
michael@0 | 431 | ~nsCSSKeyframeRule(); |
michael@0 | 432 | public: |
michael@0 | 433 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 434 | NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsCSSKeyframeRule, nsIStyleRule) |
michael@0 | 435 | |
michael@0 | 436 | // nsIStyleRule methods |
michael@0 | 437 | #ifdef DEBUG |
michael@0 | 438 | virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; |
michael@0 | 439 | #endif |
michael@0 | 440 | |
michael@0 | 441 | // Rule methods |
michael@0 | 442 | DECL_STYLE_RULE_INHERIT |
michael@0 | 443 | virtual int32_t GetType() const MOZ_OVERRIDE; |
michael@0 | 444 | virtual already_AddRefed<mozilla::css::Rule> Clone() const; |
michael@0 | 445 | |
michael@0 | 446 | // nsIDOMCSSRule interface |
michael@0 | 447 | NS_DECL_NSIDOMCSSRULE |
michael@0 | 448 | |
michael@0 | 449 | // nsIDOMMozCSSKeyframeRule interface |
michael@0 | 450 | NS_DECL_NSIDOMMOZCSSKEYFRAMERULE |
michael@0 | 451 | |
michael@0 | 452 | const nsTArray<float>& GetKeys() const { return mKeys; } |
michael@0 | 453 | mozilla::css::Declaration* Declaration() { return mDeclaration; } |
michael@0 | 454 | |
michael@0 | 455 | void ChangeDeclaration(mozilla::css::Declaration* aDeclaration); |
michael@0 | 456 | |
michael@0 | 457 | virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; |
michael@0 | 458 | |
michael@0 | 459 | void DoGetKeyText(nsAString &aKeyText) const; |
michael@0 | 460 | |
michael@0 | 461 | private: |
michael@0 | 462 | nsTArray<float> mKeys; |
michael@0 | 463 | nsAutoPtr<mozilla::css::Declaration> mDeclaration; |
michael@0 | 464 | // lazily created when needed: |
michael@0 | 465 | nsRefPtr<nsCSSKeyframeStyleDeclaration> mDOMDeclaration; |
michael@0 | 466 | }; |
michael@0 | 467 | |
michael@0 | 468 | class nsCSSKeyframesRule MOZ_FINAL : public mozilla::css::GroupRule, |
michael@0 | 469 | public nsIDOMMozCSSKeyframesRule |
michael@0 | 470 | { |
michael@0 | 471 | public: |
michael@0 | 472 | nsCSSKeyframesRule(const nsSubstring& aName) |
michael@0 | 473 | : mName(aName) |
michael@0 | 474 | { |
michael@0 | 475 | } |
michael@0 | 476 | private: |
michael@0 | 477 | nsCSSKeyframesRule(const nsCSSKeyframesRule& aCopy); |
michael@0 | 478 | ~nsCSSKeyframesRule(); |
michael@0 | 479 | public: |
michael@0 | 480 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 481 | |
michael@0 | 482 | // nsIStyleRule methods |
michael@0 | 483 | #ifdef DEBUG |
michael@0 | 484 | virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; |
michael@0 | 485 | #endif |
michael@0 | 486 | |
michael@0 | 487 | // Rule methods |
michael@0 | 488 | virtual int32_t GetType() const; |
michael@0 | 489 | virtual already_AddRefed<mozilla::css::Rule> Clone() const; |
michael@0 | 490 | virtual nsIDOMCSSRule* GetDOMRule() |
michael@0 | 491 | { |
michael@0 | 492 | return this; |
michael@0 | 493 | } |
michael@0 | 494 | virtual nsIDOMCSSRule* GetExistingDOMRule() |
michael@0 | 495 | { |
michael@0 | 496 | return this; |
michael@0 | 497 | } |
michael@0 | 498 | |
michael@0 | 499 | // nsIDOMCSSRule interface |
michael@0 | 500 | NS_DECL_NSIDOMCSSRULE |
michael@0 | 501 | |
michael@0 | 502 | // nsIDOMMozCSSKeyframesRule interface |
michael@0 | 503 | NS_DECL_NSIDOMMOZCSSKEYFRAMESRULE |
michael@0 | 504 | |
michael@0 | 505 | // rest of GroupRule |
michael@0 | 506 | virtual bool UseForPresentation(nsPresContext* aPresContext, |
michael@0 | 507 | nsMediaQueryResultCacheKey& aKey) MOZ_OVERRIDE; |
michael@0 | 508 | |
michael@0 | 509 | const nsString& GetName() { return mName; } |
michael@0 | 510 | |
michael@0 | 511 | virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; |
michael@0 | 512 | |
michael@0 | 513 | private: |
michael@0 | 514 | uint32_t FindRuleIndexForKey(const nsAString& aKey); |
michael@0 | 515 | |
michael@0 | 516 | nsString mName; |
michael@0 | 517 | }; |
michael@0 | 518 | |
michael@0 | 519 | class nsCSSPageRule; |
michael@0 | 520 | |
michael@0 | 521 | class nsCSSPageStyleDeclaration MOZ_FINAL : public nsDOMCSSDeclaration |
michael@0 | 522 | { |
michael@0 | 523 | public: |
michael@0 | 524 | nsCSSPageStyleDeclaration(nsCSSPageRule *aRule); |
michael@0 | 525 | virtual ~nsCSSPageStyleDeclaration(); |
michael@0 | 526 | |
michael@0 | 527 | NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) MOZ_OVERRIDE; |
michael@0 | 528 | void DropReference() { mRule = nullptr; } |
michael@0 | 529 | virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate) MOZ_OVERRIDE; |
michael@0 | 530 | virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) MOZ_OVERRIDE; |
michael@0 | 531 | virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) MOZ_OVERRIDE; |
michael@0 | 532 | virtual nsIDocument* DocToUpdate() MOZ_OVERRIDE; |
michael@0 | 533 | |
michael@0 | 534 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 535 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSPageStyleDeclaration, |
michael@0 | 536 | nsICSSDeclaration) |
michael@0 | 537 | |
michael@0 | 538 | virtual nsINode *GetParentObject() MOZ_OVERRIDE; |
michael@0 | 539 | |
michael@0 | 540 | protected: |
michael@0 | 541 | // This reference is not reference-counted. The rule object tells us |
michael@0 | 542 | // when it's about to go away. |
michael@0 | 543 | nsCSSPageRule *mRule; |
michael@0 | 544 | }; |
michael@0 | 545 | |
michael@0 | 546 | class nsCSSPageRule MOZ_FINAL : public mozilla::css::Rule, |
michael@0 | 547 | public nsIDOMCSSPageRule |
michael@0 | 548 | { |
michael@0 | 549 | public: |
michael@0 | 550 | // WARNING: Steals the contents of aDeclaration |
michael@0 | 551 | nsCSSPageRule(nsAutoPtr<mozilla::css::Declaration> aDeclaration) |
michael@0 | 552 | : mDeclaration(aDeclaration), |
michael@0 | 553 | mImportantRule(nullptr) |
michael@0 | 554 | { |
michael@0 | 555 | } |
michael@0 | 556 | private: |
michael@0 | 557 | nsCSSPageRule(const nsCSSPageRule& aCopy); |
michael@0 | 558 | ~nsCSSPageRule(); |
michael@0 | 559 | public: |
michael@0 | 560 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 561 | NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsCSSPageRule, nsIDOMCSSPageRule) |
michael@0 | 562 | |
michael@0 | 563 | // nsIStyleRule methods |
michael@0 | 564 | #ifdef DEBUG |
michael@0 | 565 | virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; |
michael@0 | 566 | #endif |
michael@0 | 567 | |
michael@0 | 568 | // Rule methods |
michael@0 | 569 | DECL_STYLE_RULE_INHERIT |
michael@0 | 570 | virtual int32_t GetType() const MOZ_OVERRIDE; |
michael@0 | 571 | virtual already_AddRefed<mozilla::css::Rule> Clone() const; |
michael@0 | 572 | |
michael@0 | 573 | // nsIDOMCSSRule interface |
michael@0 | 574 | NS_DECL_NSIDOMCSSRULE |
michael@0 | 575 | |
michael@0 | 576 | // nsIDOMCSSPageRule interface |
michael@0 | 577 | NS_DECL_NSIDOMCSSPAGERULE |
michael@0 | 578 | |
michael@0 | 579 | mozilla::css::Declaration* Declaration() { return mDeclaration; } |
michael@0 | 580 | |
michael@0 | 581 | void ChangeDeclaration(mozilla::css::Declaration* aDeclaration); |
michael@0 | 582 | |
michael@0 | 583 | mozilla::css::ImportantRule* GetImportantRule(); |
michael@0 | 584 | |
michael@0 | 585 | virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; |
michael@0 | 586 | private: |
michael@0 | 587 | nsAutoPtr<mozilla::css::Declaration> mDeclaration; |
michael@0 | 588 | // lazily created when needed: |
michael@0 | 589 | nsRefPtr<nsCSSPageStyleDeclaration> mDOMDeclaration; |
michael@0 | 590 | nsRefPtr<mozilla::css::ImportantRule> mImportantRule; |
michael@0 | 591 | }; |
michael@0 | 592 | |
michael@0 | 593 | namespace mozilla { |
michael@0 | 594 | |
michael@0 | 595 | class CSSSupportsRule : public css::GroupRule, |
michael@0 | 596 | public nsIDOMCSSSupportsRule |
michael@0 | 597 | { |
michael@0 | 598 | public: |
michael@0 | 599 | CSSSupportsRule(bool aConditionMet, const nsString& aCondition); |
michael@0 | 600 | CSSSupportsRule(const CSSSupportsRule& aCopy); |
michael@0 | 601 | |
michael@0 | 602 | // nsIStyleRule methods |
michael@0 | 603 | #ifdef DEBUG |
michael@0 | 604 | virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; |
michael@0 | 605 | #endif |
michael@0 | 606 | |
michael@0 | 607 | // Rule methods |
michael@0 | 608 | virtual int32_t GetType() const; |
michael@0 | 609 | virtual already_AddRefed<mozilla::css::Rule> Clone() const; |
michael@0 | 610 | virtual bool UseForPresentation(nsPresContext* aPresContext, |
michael@0 | 611 | nsMediaQueryResultCacheKey& aKey); |
michael@0 | 612 | virtual nsIDOMCSSRule* GetDOMRule() |
michael@0 | 613 | { |
michael@0 | 614 | return this; |
michael@0 | 615 | } |
michael@0 | 616 | virtual nsIDOMCSSRule* GetExistingDOMRule() |
michael@0 | 617 | { |
michael@0 | 618 | return this; |
michael@0 | 619 | } |
michael@0 | 620 | |
michael@0 | 621 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 622 | |
michael@0 | 623 | // nsIDOMCSSRule interface |
michael@0 | 624 | NS_DECL_NSIDOMCSSRULE |
michael@0 | 625 | |
michael@0 | 626 | // nsIDOMCSSGroupingRule interface |
michael@0 | 627 | NS_DECL_NSIDOMCSSGROUPINGRULE |
michael@0 | 628 | |
michael@0 | 629 | // nsIDOMCSSConditionRule interface |
michael@0 | 630 | NS_DECL_NSIDOMCSSCONDITIONRULE |
michael@0 | 631 | |
michael@0 | 632 | // nsIDOMCSSSupportsRule interface |
michael@0 | 633 | NS_DECL_NSIDOMCSSSUPPORTSRULE |
michael@0 | 634 | |
michael@0 | 635 | virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 636 | |
michael@0 | 637 | static bool PrefEnabled() |
michael@0 | 638 | { |
michael@0 | 639 | return Preferences::GetBool("layout.css.supports-rule.enabled"); |
michael@0 | 640 | } |
michael@0 | 641 | |
michael@0 | 642 | protected: |
michael@0 | 643 | bool mUseGroup; |
michael@0 | 644 | nsString mCondition; |
michael@0 | 645 | }; |
michael@0 | 646 | |
michael@0 | 647 | } // namespace mozilla |
michael@0 | 648 | |
michael@0 | 649 | #endif /* !defined(nsCSSRules_h_) */ |