Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 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 | /* |
michael@0 | 8 | * style sheet and style rule processor representing data from presentational |
michael@0 | 9 | * HTML attributes |
michael@0 | 10 | */ |
michael@0 | 11 | |
michael@0 | 12 | #ifndef nsHTMLStyleSheet_h_ |
michael@0 | 13 | #define nsHTMLStyleSheet_h_ |
michael@0 | 14 | |
michael@0 | 15 | #include "nsAutoPtr.h" |
michael@0 | 16 | #include "nsColor.h" |
michael@0 | 17 | #include "nsCOMPtr.h" |
michael@0 | 18 | #include "nsIStyleRule.h" |
michael@0 | 19 | #include "nsIStyleRuleProcessor.h" |
michael@0 | 20 | #include "pldhash.h" |
michael@0 | 21 | #include "mozilla/Attributes.h" |
michael@0 | 22 | #include "mozilla/MemoryReporting.h" |
michael@0 | 23 | #include "nsString.h" |
michael@0 | 24 | |
michael@0 | 25 | class nsIDocument; |
michael@0 | 26 | class nsMappedAttributes; |
michael@0 | 27 | |
michael@0 | 28 | class nsHTMLStyleSheet MOZ_FINAL : public nsIStyleRuleProcessor |
michael@0 | 29 | { |
michael@0 | 30 | public: |
michael@0 | 31 | nsHTMLStyleSheet(nsIDocument* aDocument); |
michael@0 | 32 | |
michael@0 | 33 | void SetOwningDocument(nsIDocument* aDocument); |
michael@0 | 34 | |
michael@0 | 35 | NS_DECL_ISUPPORTS |
michael@0 | 36 | |
michael@0 | 37 | // nsIStyleRuleProcessor API |
michael@0 | 38 | virtual void RulesMatching(ElementRuleProcessorData* aData) MOZ_OVERRIDE; |
michael@0 | 39 | virtual void RulesMatching(PseudoElementRuleProcessorData* aData) MOZ_OVERRIDE; |
michael@0 | 40 | virtual void RulesMatching(AnonBoxRuleProcessorData* aData) MOZ_OVERRIDE; |
michael@0 | 41 | #ifdef MOZ_XUL |
michael@0 | 42 | virtual void RulesMatching(XULTreeRuleProcessorData* aData) MOZ_OVERRIDE; |
michael@0 | 43 | #endif |
michael@0 | 44 | virtual nsRestyleHint HasStateDependentStyle(StateRuleProcessorData* aData) MOZ_OVERRIDE; |
michael@0 | 45 | virtual nsRestyleHint HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData) MOZ_OVERRIDE; |
michael@0 | 46 | virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) MOZ_OVERRIDE; |
michael@0 | 47 | virtual nsRestyleHint |
michael@0 | 48 | HasAttributeDependentStyle(AttributeRuleProcessorData* aData) MOZ_OVERRIDE; |
michael@0 | 49 | virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) MOZ_OVERRIDE; |
michael@0 | 50 | virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) |
michael@0 | 51 | const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; |
michael@0 | 52 | virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) |
michael@0 | 53 | const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; |
michael@0 | 54 | size_t DOMSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; |
michael@0 | 55 | |
michael@0 | 56 | void Reset(); |
michael@0 | 57 | nsresult SetLinkColor(nscolor aColor); |
michael@0 | 58 | nsresult SetActiveLinkColor(nscolor aColor); |
michael@0 | 59 | nsresult SetVisitedLinkColor(nscolor aColor); |
michael@0 | 60 | |
michael@0 | 61 | // Mapped Attribute management methods |
michael@0 | 62 | already_AddRefed<nsMappedAttributes> |
michael@0 | 63 | UniqueMappedAttributes(nsMappedAttributes* aMapped); |
michael@0 | 64 | void DropMappedAttributes(nsMappedAttributes* aMapped); |
michael@0 | 65 | |
michael@0 | 66 | nsIStyleRule* LangRuleFor(const nsString& aLanguage); |
michael@0 | 67 | |
michael@0 | 68 | private: |
michael@0 | 69 | nsHTMLStyleSheet(const nsHTMLStyleSheet& aCopy) MOZ_DELETE; |
michael@0 | 70 | nsHTMLStyleSheet& operator=(const nsHTMLStyleSheet& aCopy) MOZ_DELETE; |
michael@0 | 71 | |
michael@0 | 72 | ~nsHTMLStyleSheet(); |
michael@0 | 73 | |
michael@0 | 74 | class HTMLColorRule; |
michael@0 | 75 | friend class HTMLColorRule; |
michael@0 | 76 | class HTMLColorRule MOZ_FINAL : public nsIStyleRule { |
michael@0 | 77 | public: |
michael@0 | 78 | HTMLColorRule() {} |
michael@0 | 79 | |
michael@0 | 80 | NS_DECL_ISUPPORTS |
michael@0 | 81 | |
michael@0 | 82 | // nsIStyleRule interface |
michael@0 | 83 | virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE; |
michael@0 | 84 | #ifdef DEBUG |
michael@0 | 85 | virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; |
michael@0 | 86 | #endif |
michael@0 | 87 | |
michael@0 | 88 | nscolor mColor; |
michael@0 | 89 | }; |
michael@0 | 90 | |
michael@0 | 91 | // Implementation of SetLink/VisitedLink/ActiveLinkColor |
michael@0 | 92 | nsresult ImplLinkColorSetter(nsRefPtr<HTMLColorRule>& aRule, nscolor aColor); |
michael@0 | 93 | |
michael@0 | 94 | class GenericTableRule; |
michael@0 | 95 | friend class GenericTableRule; |
michael@0 | 96 | class GenericTableRule : public nsIStyleRule { |
michael@0 | 97 | public: |
michael@0 | 98 | GenericTableRule() {} |
michael@0 | 99 | virtual ~GenericTableRule() {} |
michael@0 | 100 | |
michael@0 | 101 | NS_DECL_ISUPPORTS |
michael@0 | 102 | |
michael@0 | 103 | // nsIStyleRule interface |
michael@0 | 104 | virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE = 0; |
michael@0 | 105 | #ifdef DEBUG |
michael@0 | 106 | virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; |
michael@0 | 107 | #endif |
michael@0 | 108 | }; |
michael@0 | 109 | |
michael@0 | 110 | // this rule handles <th> inheritance |
michael@0 | 111 | class TableTHRule; |
michael@0 | 112 | friend class TableTHRule; |
michael@0 | 113 | class TableTHRule MOZ_FINAL : public GenericTableRule { |
michael@0 | 114 | public: |
michael@0 | 115 | TableTHRule() {} |
michael@0 | 116 | |
michael@0 | 117 | virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE; |
michael@0 | 118 | }; |
michael@0 | 119 | |
michael@0 | 120 | // Rule to handle quirk table colors |
michael@0 | 121 | class TableQuirkColorRule MOZ_FINAL : public GenericTableRule { |
michael@0 | 122 | public: |
michael@0 | 123 | TableQuirkColorRule() {} |
michael@0 | 124 | |
michael@0 | 125 | virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE; |
michael@0 | 126 | }; |
michael@0 | 127 | |
michael@0 | 128 | public: // for mLangRuleTable structures only |
michael@0 | 129 | |
michael@0 | 130 | // Rule to handle xml:lang attributes, of which we have exactly one |
michael@0 | 131 | // per language string, maintained in mLangRuleTable. |
michael@0 | 132 | class LangRule MOZ_FINAL : public nsIStyleRule { |
michael@0 | 133 | public: |
michael@0 | 134 | LangRule(const nsSubstring& aLang) : mLang(aLang) {} |
michael@0 | 135 | |
michael@0 | 136 | NS_DECL_ISUPPORTS |
michael@0 | 137 | |
michael@0 | 138 | // nsIStyleRule interface |
michael@0 | 139 | virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE; |
michael@0 | 140 | #ifdef DEBUG |
michael@0 | 141 | virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; |
michael@0 | 142 | #endif |
michael@0 | 143 | |
michael@0 | 144 | nsString mLang; |
michael@0 | 145 | }; |
michael@0 | 146 | |
michael@0 | 147 | private: |
michael@0 | 148 | nsIDocument* mDocument; |
michael@0 | 149 | nsRefPtr<HTMLColorRule> mLinkRule; |
michael@0 | 150 | nsRefPtr<HTMLColorRule> mVisitedRule; |
michael@0 | 151 | nsRefPtr<HTMLColorRule> mActiveRule; |
michael@0 | 152 | nsRefPtr<TableQuirkColorRule> mTableQuirkColorRule; |
michael@0 | 153 | nsRefPtr<TableTHRule> mTableTHRule; |
michael@0 | 154 | |
michael@0 | 155 | PLDHashTable mMappedAttrTable; |
michael@0 | 156 | PLDHashTable mLangRuleTable; |
michael@0 | 157 | }; |
michael@0 | 158 | |
michael@0 | 159 | #endif /* !defined(nsHTMLStyleSheet_h_) */ |