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