michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: // vim:cindent:ts=2:et:sw=2: michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* rules in a CSS stylesheet other than style rules (e.g., @import rules) */ michael@0: michael@0: #ifndef nsCSSRules_h_ michael@0: #define nsCSSRules_h_ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: #include "mozilla/MemoryReporting.h" michael@0: #include "mozilla/css/GroupRule.h" michael@0: #include "mozilla/Preferences.h" michael@0: #include "nsIDOMCSSConditionRule.h" michael@0: #include "nsIDOMCSSFontFaceRule.h" michael@0: #include "nsIDOMCSSFontFeatureValuesRule.h" michael@0: #include "nsIDOMCSSGroupingRule.h" michael@0: #include "nsIDOMCSSMediaRule.h" michael@0: #include "nsIDOMCSSMozDocumentRule.h" michael@0: #include "nsIDOMCSSSupportsRule.h" michael@0: #include "nsIDOMMozCSSKeyframeRule.h" michael@0: #include "nsIDOMMozCSSKeyframesRule.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsCSSProperty.h" michael@0: #include "nsCSSValue.h" michael@0: #include "nsIDOMCSSCharsetRule.h" michael@0: #include "nsTArray.h" michael@0: #include "nsDOMCSSDeclaration.h" michael@0: #include "Declaration.h" michael@0: #include "nsIDOMCSSPageRule.h" michael@0: #include "StyleRule.h" michael@0: #include "gfxFontFeatures.h" michael@0: michael@0: class nsMediaList; michael@0: michael@0: namespace mozilla { michael@0: michael@0: class ErrorResult; michael@0: michael@0: namespace css { michael@0: michael@0: class MediaRule MOZ_FINAL : public GroupRule, michael@0: public nsIDOMCSSMediaRule michael@0: { michael@0: public: michael@0: MediaRule(); michael@0: private: michael@0: MediaRule(const MediaRule& aCopy); michael@0: ~MediaRule(); michael@0: public: michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // nsIStyleRule methods michael@0: #ifdef DEBUG michael@0: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: // Rule methods michael@0: virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); //override GroupRule michael@0: virtual int32_t GetType() const; michael@0: virtual already_AddRefed Clone() const; michael@0: virtual nsIDOMCSSRule* GetDOMRule() michael@0: { michael@0: return this; michael@0: } michael@0: virtual nsIDOMCSSRule* GetExistingDOMRule() michael@0: { michael@0: return this; michael@0: } michael@0: michael@0: // nsIDOMCSSRule interface michael@0: NS_DECL_NSIDOMCSSRULE michael@0: michael@0: // nsIDOMCSSGroupingRule interface michael@0: NS_DECL_NSIDOMCSSGROUPINGRULE michael@0: michael@0: // nsIDOMCSSConditionRule interface michael@0: NS_DECL_NSIDOMCSSCONDITIONRULE michael@0: michael@0: // nsIDOMCSSMediaRule interface michael@0: NS_DECL_NSIDOMCSSMEDIARULE michael@0: michael@0: // rest of GroupRule michael@0: virtual bool UseForPresentation(nsPresContext* aPresContext, michael@0: nsMediaQueryResultCacheKey& aKey); michael@0: michael@0: // @media rule methods michael@0: nsresult SetMedia(nsMediaList* aMedia); michael@0: michael@0: virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) michael@0: const MOZ_MUST_OVERRIDE; michael@0: michael@0: protected: michael@0: void AppendConditionText(nsAString& aOutput); michael@0: michael@0: nsRefPtr mMedia; michael@0: }; michael@0: michael@0: class DocumentRule MOZ_FINAL : public GroupRule, michael@0: public nsIDOMCSSMozDocumentRule michael@0: { michael@0: public: michael@0: DocumentRule(); michael@0: private: michael@0: DocumentRule(const DocumentRule& aCopy); michael@0: ~DocumentRule(); michael@0: public: michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // nsIStyleRule methods michael@0: #ifdef DEBUG michael@0: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: // Rule methods michael@0: virtual int32_t GetType() const; michael@0: virtual already_AddRefed Clone() const; michael@0: virtual nsIDOMCSSRule* GetDOMRule() michael@0: { michael@0: return this; michael@0: } michael@0: virtual nsIDOMCSSRule* GetExistingDOMRule() michael@0: { michael@0: return this; michael@0: } michael@0: michael@0: // nsIDOMCSSRule interface michael@0: NS_DECL_NSIDOMCSSRULE michael@0: michael@0: // nsIDOMCSSGroupingRule interface michael@0: NS_DECL_NSIDOMCSSGROUPINGRULE michael@0: michael@0: // nsIDOMCSSConditionRule interface michael@0: NS_DECL_NSIDOMCSSCONDITIONRULE michael@0: michael@0: // nsIDOMCSSMozDocumentRule interface michael@0: NS_DECL_NSIDOMCSSMOZDOCUMENTRULE michael@0: michael@0: // rest of GroupRule michael@0: virtual bool UseForPresentation(nsPresContext* aPresContext, michael@0: nsMediaQueryResultCacheKey& aKey); michael@0: michael@0: enum Function { michael@0: eURL, michael@0: eURLPrefix, michael@0: eDomain, michael@0: eRegExp michael@0: }; michael@0: michael@0: struct URL { michael@0: Function func; michael@0: nsCString url; michael@0: URL *next; michael@0: michael@0: URL() : next(nullptr) {} michael@0: URL(const URL& aOther) michael@0: : func(aOther.func) michael@0: , url(aOther.url) michael@0: , next(aOther.next ? new URL(*aOther.next) : nullptr) michael@0: { michael@0: } michael@0: ~URL(); michael@0: }; michael@0: michael@0: void SetURLs(URL *aURLs) { mURLs = aURLs; } michael@0: michael@0: virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) michael@0: const MOZ_MUST_OVERRIDE; michael@0: michael@0: protected: michael@0: void AppendConditionText(nsAString& aOutput); michael@0: michael@0: nsAutoPtr mURLs; // linked list of |struct URL| above. michael@0: }; michael@0: michael@0: } // namespace css michael@0: } // namespace mozilla michael@0: michael@0: // A nsCSSFontFaceStyleDecl is always embedded in a nsCSSFontFaceRule. michael@0: class nsCSSFontFaceRule; michael@0: class nsCSSFontFaceStyleDecl : public nsICSSDeclaration michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER michael@0: NS_DECL_NSICSSDECLARATION michael@0: virtual already_AddRefed michael@0: GetPropertyCSSValue(const nsAString& aProp, mozilla::ErrorResult& aRv) michael@0: MOZ_OVERRIDE; michael@0: using nsICSSDeclaration::GetPropertyCSSValue; michael@0: michael@0: nsCSSFontFaceStyleDecl() michael@0: { michael@0: SetIsDOMBinding(); michael@0: } michael@0: michael@0: virtual nsINode *GetParentObject() MOZ_OVERRIDE; michael@0: virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) MOZ_OVERRIDE; michael@0: michael@0: nsresult GetPropertyValue(nsCSSFontDesc aFontDescID, michael@0: nsAString & aResult) const; michael@0: michael@0: virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: friend class nsCSSFontFaceRule; michael@0: #define CSS_FONT_DESC(name_, method_) nsCSSValue m##method_; michael@0: #include "nsCSSFontDescList.h" michael@0: #undef CSS_FONT_DESC michael@0: michael@0: static nsCSSValue nsCSSFontFaceStyleDecl::* const Fields[]; michael@0: inline nsCSSFontFaceRule* ContainingRule(); michael@0: inline const nsCSSFontFaceRule* ContainingRule() const; michael@0: michael@0: private: michael@0: // NOT TO BE IMPLEMENTED michael@0: // This object cannot be allocated on its own, only as part of michael@0: // nsCSSFontFaceRule. michael@0: void* operator new(size_t size) CPP_THROW_NEW; michael@0: }; michael@0: michael@0: class nsCSSFontFaceRule MOZ_FINAL : public mozilla::css::Rule, michael@0: public nsIDOMCSSFontFaceRule michael@0: { michael@0: public: michael@0: nsCSSFontFaceRule() {} michael@0: michael@0: nsCSSFontFaceRule(const nsCSSFontFaceRule& aCopy) michael@0: // copy everything except our reference count michael@0: : mozilla::css::Rule(aCopy), mDecl(aCopy.mDecl) {} michael@0: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSFontFaceRule, michael@0: mozilla::css::Rule) michael@0: michael@0: // nsIStyleRule methods michael@0: #ifdef DEBUG michael@0: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: // Rule methods michael@0: DECL_STYLE_RULE_INHERIT michael@0: michael@0: virtual int32_t GetType() const MOZ_OVERRIDE; michael@0: virtual already_AddRefed Clone() const; michael@0: michael@0: // nsIDOMCSSRule interface michael@0: NS_DECL_NSIDOMCSSRULE michael@0: michael@0: // nsIDOMCSSFontFaceRule interface michael@0: NS_DECL_NSIDOMCSSFONTFACERULE michael@0: michael@0: void SetDesc(nsCSSFontDesc aDescID, nsCSSValue const & aValue); michael@0: void GetDesc(nsCSSFontDesc aDescID, nsCSSValue & aValue); michael@0: michael@0: virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: friend class nsCSSFontFaceStyleDecl; michael@0: nsCSSFontFaceStyleDecl mDecl; michael@0: }; michael@0: michael@0: // nsFontFaceRuleContainer - used for associating sheet type with michael@0: // specific @font-face rules michael@0: struct nsFontFaceRuleContainer { michael@0: nsRefPtr mRule; michael@0: uint8_t mSheetType; michael@0: }; michael@0: michael@0: inline nsCSSFontFaceRule* michael@0: nsCSSFontFaceStyleDecl::ContainingRule() michael@0: { michael@0: return reinterpret_cast michael@0: (reinterpret_cast(this) - offsetof(nsCSSFontFaceRule, mDecl)); michael@0: } michael@0: michael@0: inline const nsCSSFontFaceRule* michael@0: nsCSSFontFaceStyleDecl::ContainingRule() const michael@0: { michael@0: return reinterpret_cast michael@0: (reinterpret_cast(this) - offsetof(nsCSSFontFaceRule, mDecl)); michael@0: } michael@0: michael@0: class nsCSSFontFeatureValuesRule MOZ_FINAL : michael@0: public mozilla::css::Rule, michael@0: public nsIDOMCSSFontFeatureValuesRule michael@0: { michael@0: public: michael@0: nsCSSFontFeatureValuesRule() {} michael@0: michael@0: nsCSSFontFeatureValuesRule(const nsCSSFontFeatureValuesRule& aCopy) michael@0: // copy everything except our reference count michael@0: : mozilla::css::Rule(aCopy), michael@0: mFamilyList(aCopy.mFamilyList), michael@0: mFeatureValues(aCopy.mFeatureValues) {} michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: // nsIStyleRule methods michael@0: #ifdef DEBUG michael@0: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: // Rule methods michael@0: DECL_STYLE_RULE_INHERIT michael@0: michael@0: virtual int32_t GetType() const MOZ_OVERRIDE; michael@0: virtual already_AddRefed Clone() const MOZ_OVERRIDE; michael@0: michael@0: // nsIDOMCSSRule interface michael@0: NS_DECL_NSIDOMCSSRULE michael@0: michael@0: // nsIDOMCSSFontFaceRule interface michael@0: NS_DECL_NSIDOMCSSFONTFEATUREVALUESRULE michael@0: michael@0: const nsTArray& GetFamilyList() { return mFamilyList; } michael@0: void SetFamilyList(const nsAString& aFamilyList, bool& aContainsGeneric); michael@0: michael@0: void AddValueList(int32_t aVariantAlternate, michael@0: nsTArray& aValueList); michael@0: michael@0: const nsTArray& GetFeatureValues() michael@0: { michael@0: return mFeatureValues; michael@0: } michael@0: michael@0: virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; michael@0: michael@0: static bool PrefEnabled() michael@0: { michael@0: // font-variant-alternates enabled ==> layout.css.font-features.enabled is true michael@0: bool fontFeaturesEnabled = michael@0: nsCSSProps::IsEnabled(eCSSProperty_font_variant_alternates); michael@0: michael@0: return fontFeaturesEnabled; michael@0: } michael@0: michael@0: protected: michael@0: nsTArray mFamilyList; michael@0: nsTArray mFeatureValues; michael@0: }; michael@0: michael@0: namespace mozilla { michael@0: namespace css { michael@0: michael@0: class CharsetRule MOZ_FINAL : public Rule, michael@0: public nsIDOMCSSCharsetRule michael@0: { michael@0: public: michael@0: CharsetRule(const nsAString& aEncoding); michael@0: private: michael@0: // For |Clone| michael@0: CharsetRule(const CharsetRule& aCopy); michael@0: ~CharsetRule() {} michael@0: michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: DECL_STYLE_RULE_INHERIT michael@0: michael@0: // nsIStyleRule methods michael@0: #ifdef DEBUG michael@0: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: // Rule methods michael@0: virtual int32_t GetType() const; michael@0: virtual already_AddRefed Clone() const; michael@0: michael@0: // nsIDOMCSSRule interface michael@0: NS_DECL_NSIDOMCSSRULE michael@0: michael@0: // nsIDOMCSSCharsetRule methods michael@0: NS_IMETHOD GetEncoding(nsAString& aEncoding) MOZ_OVERRIDE; michael@0: NS_IMETHOD SetEncoding(const nsAString& aEncoding) MOZ_OVERRIDE; michael@0: michael@0: virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; michael@0: michael@0: private: michael@0: nsString mEncoding; michael@0: }; michael@0: michael@0: } // namespace css michael@0: } // namespace mozilla michael@0: michael@0: class nsCSSKeyframeRule; michael@0: michael@0: class nsCSSKeyframeStyleDeclaration MOZ_FINAL : public nsDOMCSSDeclaration michael@0: { michael@0: public: michael@0: nsCSSKeyframeStyleDeclaration(nsCSSKeyframeRule *aRule); michael@0: virtual ~nsCSSKeyframeStyleDeclaration(); michael@0: michael@0: NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) MOZ_OVERRIDE; michael@0: void DropReference() { mRule = nullptr; } michael@0: virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate) MOZ_OVERRIDE; michael@0: virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) MOZ_OVERRIDE; michael@0: virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) MOZ_OVERRIDE; michael@0: virtual nsIDocument* DocToUpdate() MOZ_OVERRIDE; michael@0: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSKeyframeStyleDeclaration, michael@0: nsICSSDeclaration) michael@0: michael@0: virtual nsINode* GetParentObject() MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: // This reference is not reference-counted. The rule object tells us michael@0: // when it's about to go away. michael@0: nsCSSKeyframeRule *mRule; michael@0: }; michael@0: michael@0: class nsCSSKeyframeRule MOZ_FINAL : public mozilla::css::Rule, michael@0: public nsIDOMMozCSSKeyframeRule michael@0: { michael@0: public: michael@0: // WARNING: Steals the contents of aKeys *and* aDeclaration michael@0: nsCSSKeyframeRule(InfallibleTArray& aKeys, michael@0: nsAutoPtr aDeclaration) michael@0: : mDeclaration(aDeclaration) michael@0: { michael@0: mKeys.SwapElements(aKeys); michael@0: } michael@0: private: michael@0: nsCSSKeyframeRule(const nsCSSKeyframeRule& aCopy); michael@0: ~nsCSSKeyframeRule(); michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsCSSKeyframeRule, nsIStyleRule) michael@0: michael@0: // nsIStyleRule methods michael@0: #ifdef DEBUG michael@0: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: // Rule methods michael@0: DECL_STYLE_RULE_INHERIT michael@0: virtual int32_t GetType() const MOZ_OVERRIDE; michael@0: virtual already_AddRefed Clone() const; michael@0: michael@0: // nsIDOMCSSRule interface michael@0: NS_DECL_NSIDOMCSSRULE michael@0: michael@0: // nsIDOMMozCSSKeyframeRule interface michael@0: NS_DECL_NSIDOMMOZCSSKEYFRAMERULE michael@0: michael@0: const nsTArray& GetKeys() const { return mKeys; } michael@0: mozilla::css::Declaration* Declaration() { return mDeclaration; } michael@0: michael@0: void ChangeDeclaration(mozilla::css::Declaration* aDeclaration); michael@0: michael@0: virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; michael@0: michael@0: void DoGetKeyText(nsAString &aKeyText) const; michael@0: michael@0: private: michael@0: nsTArray mKeys; michael@0: nsAutoPtr mDeclaration; michael@0: // lazily created when needed: michael@0: nsRefPtr mDOMDeclaration; michael@0: }; michael@0: michael@0: class nsCSSKeyframesRule MOZ_FINAL : public mozilla::css::GroupRule, michael@0: public nsIDOMMozCSSKeyframesRule michael@0: { michael@0: public: michael@0: nsCSSKeyframesRule(const nsSubstring& aName) michael@0: : mName(aName) michael@0: { michael@0: } michael@0: private: michael@0: nsCSSKeyframesRule(const nsCSSKeyframesRule& aCopy); michael@0: ~nsCSSKeyframesRule(); michael@0: public: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // nsIStyleRule methods michael@0: #ifdef DEBUG michael@0: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: // Rule methods michael@0: virtual int32_t GetType() const; michael@0: virtual already_AddRefed Clone() const; michael@0: virtual nsIDOMCSSRule* GetDOMRule() michael@0: { michael@0: return this; michael@0: } michael@0: virtual nsIDOMCSSRule* GetExistingDOMRule() michael@0: { michael@0: return this; michael@0: } michael@0: michael@0: // nsIDOMCSSRule interface michael@0: NS_DECL_NSIDOMCSSRULE michael@0: michael@0: // nsIDOMMozCSSKeyframesRule interface michael@0: NS_DECL_NSIDOMMOZCSSKEYFRAMESRULE michael@0: michael@0: // rest of GroupRule michael@0: virtual bool UseForPresentation(nsPresContext* aPresContext, michael@0: nsMediaQueryResultCacheKey& aKey) MOZ_OVERRIDE; michael@0: michael@0: const nsString& GetName() { return mName; } michael@0: michael@0: virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: uint32_t FindRuleIndexForKey(const nsAString& aKey); michael@0: michael@0: nsString mName; michael@0: }; michael@0: michael@0: class nsCSSPageRule; michael@0: michael@0: class nsCSSPageStyleDeclaration MOZ_FINAL : public nsDOMCSSDeclaration michael@0: { michael@0: public: michael@0: nsCSSPageStyleDeclaration(nsCSSPageRule *aRule); michael@0: virtual ~nsCSSPageStyleDeclaration(); michael@0: michael@0: NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) MOZ_OVERRIDE; michael@0: void DropReference() { mRule = nullptr; } michael@0: virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate) MOZ_OVERRIDE; michael@0: virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) MOZ_OVERRIDE; michael@0: virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) MOZ_OVERRIDE; michael@0: virtual nsIDocument* DocToUpdate() MOZ_OVERRIDE; michael@0: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsCSSPageStyleDeclaration, michael@0: nsICSSDeclaration) michael@0: michael@0: virtual nsINode *GetParentObject() MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: // This reference is not reference-counted. The rule object tells us michael@0: // when it's about to go away. michael@0: nsCSSPageRule *mRule; michael@0: }; michael@0: michael@0: class nsCSSPageRule MOZ_FINAL : public mozilla::css::Rule, michael@0: public nsIDOMCSSPageRule michael@0: { michael@0: public: michael@0: // WARNING: Steals the contents of aDeclaration michael@0: nsCSSPageRule(nsAutoPtr aDeclaration) michael@0: : mDeclaration(aDeclaration), michael@0: mImportantRule(nullptr) michael@0: { michael@0: } michael@0: private: michael@0: nsCSSPageRule(const nsCSSPageRule& aCopy); michael@0: ~nsCSSPageRule(); michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsCSSPageRule, nsIDOMCSSPageRule) michael@0: michael@0: // nsIStyleRule methods michael@0: #ifdef DEBUG michael@0: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: // Rule methods michael@0: DECL_STYLE_RULE_INHERIT michael@0: virtual int32_t GetType() const MOZ_OVERRIDE; michael@0: virtual already_AddRefed Clone() const; michael@0: michael@0: // nsIDOMCSSRule interface michael@0: NS_DECL_NSIDOMCSSRULE michael@0: michael@0: // nsIDOMCSSPageRule interface michael@0: NS_DECL_NSIDOMCSSPAGERULE michael@0: michael@0: mozilla::css::Declaration* Declaration() { return mDeclaration; } michael@0: michael@0: void ChangeDeclaration(mozilla::css::Declaration* aDeclaration); michael@0: michael@0: mozilla::css::ImportantRule* GetImportantRule(); michael@0: michael@0: virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; michael@0: private: michael@0: nsAutoPtr mDeclaration; michael@0: // lazily created when needed: michael@0: nsRefPtr mDOMDeclaration; michael@0: nsRefPtr mImportantRule; michael@0: }; michael@0: michael@0: namespace mozilla { michael@0: michael@0: class CSSSupportsRule : public css::GroupRule, michael@0: public nsIDOMCSSSupportsRule michael@0: { michael@0: public: michael@0: CSSSupportsRule(bool aConditionMet, const nsString& aCondition); michael@0: CSSSupportsRule(const CSSSupportsRule& aCopy); michael@0: michael@0: // nsIStyleRule methods michael@0: #ifdef DEBUG michael@0: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: // Rule methods michael@0: virtual int32_t GetType() const; michael@0: virtual already_AddRefed Clone() const; michael@0: virtual bool UseForPresentation(nsPresContext* aPresContext, michael@0: nsMediaQueryResultCacheKey& aKey); michael@0: virtual nsIDOMCSSRule* GetDOMRule() michael@0: { michael@0: return this; michael@0: } michael@0: virtual nsIDOMCSSRule* GetExistingDOMRule() michael@0: { michael@0: return this; michael@0: } michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // nsIDOMCSSRule interface michael@0: NS_DECL_NSIDOMCSSRULE michael@0: michael@0: // nsIDOMCSSGroupingRule interface michael@0: NS_DECL_NSIDOMCSSGROUPINGRULE michael@0: michael@0: // nsIDOMCSSConditionRule interface michael@0: NS_DECL_NSIDOMCSSCONDITIONRULE michael@0: michael@0: // nsIDOMCSSSupportsRule interface michael@0: NS_DECL_NSIDOMCSSSUPPORTSRULE michael@0: michael@0: virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; michael@0: michael@0: static bool PrefEnabled() michael@0: { michael@0: return Preferences::GetBool("layout.css.supports-rule.enabled"); michael@0: } michael@0: michael@0: protected: michael@0: bool mUseGroup; michael@0: nsString mCondition; michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: michael@0: #endif /* !defined(nsCSSRules_h_) */