OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 bool hasRightmostSelectorMatchingHTMLBasedOnRuleHash() const { return m_hasR
ightmostSelectorMatchingHTMLBasedOnRuleHash; } | 65 bool hasRightmostSelectorMatchingHTMLBasedOnRuleHash() const { return m_hasR
ightmostSelectorMatchingHTMLBasedOnRuleHash; } |
66 bool containsUncommonAttributeSelector() const { return m_containsUncommonAt
tributeSelector; } | 66 bool containsUncommonAttributeSelector() const { return m_containsUncommonAt
tributeSelector; } |
67 unsigned specificity() const { return m_specificity; } | 67 unsigned specificity() const { return m_specificity; } |
68 unsigned linkMatchType() const { return m_linkMatchType; } | 68 unsigned linkMatchType() const { return m_linkMatchType; } |
69 bool hasDocumentSecurityOrigin() const { return m_hasDocumentSecurityOrigin;
} | 69 bool hasDocumentSecurityOrigin() const { return m_hasDocumentSecurityOrigin;
} |
70 PropertyWhitelistType propertyWhitelistType(bool isMatchingUARules = false)
const { return isMatchingUARules ? PropertyWhitelistNone : static_cast<PropertyW
hitelistType>(m_propertyWhitelistType); } | 70 PropertyWhitelistType propertyWhitelistType(bool isMatchingUARules = false)
const { return isMatchingUARules ? PropertyWhitelistNone : static_cast<PropertyW
hitelistType>(m_propertyWhitelistType); } |
71 // Try to balance between memory usage (there can be lots of RuleData object
s) and good filtering performance. | 71 // Try to balance between memory usage (there can be lots of RuleData object
s) and good filtering performance. |
72 static const unsigned maximumIdentifierCount = 4; | 72 static const unsigned maximumIdentifierCount = 4; |
73 const unsigned* descendantSelectorIdentifierHashes() const { return m_descen
dantSelectorIdentifierHashes; } | 73 const unsigned* descendantSelectorIdentifierHashes() const { return m_descen
dantSelectorIdentifierHashes; } |
74 | 74 |
75 void reportMemoryUsage(MemoryObjectInfo*) const; | |
76 | |
77 private: | 75 private: |
78 StyleRule* m_rule; | 76 StyleRule* m_rule; |
79 unsigned m_selectorIndex : 13; | 77 unsigned m_selectorIndex : 13; |
80 // This number was picked fairly arbitrarily. We can probably lower it if we
need to. | 78 // This number was picked fairly arbitrarily. We can probably lower it if we
need to. |
81 // Some simple testing showed <100,000 RuleData's on large sites. | 79 // Some simple testing showed <100,000 RuleData's on large sites. |
82 unsigned m_position : 18; | 80 unsigned m_position : 18; |
83 unsigned m_hasFastCheckableSelector : 1; | 81 unsigned m_hasFastCheckableSelector : 1; |
84 unsigned m_specificity : 24; | 82 unsigned m_specificity : 24; |
85 unsigned m_hasMultipartSelector : 1; | 83 unsigned m_hasMultipartSelector : 1; |
86 unsigned m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash : 1; | 84 unsigned m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash : 1; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 const Vector<RuleData>* idRules(AtomicStringImpl* key) const { return m_idRu
les.get(key); } | 121 const Vector<RuleData>* idRules(AtomicStringImpl* key) const { return m_idRu
les.get(key); } |
124 const Vector<RuleData>* classRules(AtomicStringImpl* key) const { return m_c
lassRules.get(key); } | 122 const Vector<RuleData>* classRules(AtomicStringImpl* key) const { return m_c
lassRules.get(key); } |
125 const Vector<RuleData>* tagRules(AtomicStringImpl* key) const { return m_tag
Rules.get(key); } | 123 const Vector<RuleData>* tagRules(AtomicStringImpl* key) const { return m_tag
Rules.get(key); } |
126 const Vector<RuleData>* shadowPseudoElementRules(AtomicStringImpl* key) cons
t { return m_shadowPseudoElementRules.get(key); } | 124 const Vector<RuleData>* shadowPseudoElementRules(AtomicStringImpl* key) cons
t { return m_shadowPseudoElementRules.get(key); } |
127 const Vector<RuleData>* linkPseudoClassRules() const { return &m_linkPseudoC
lassRules; } | 125 const Vector<RuleData>* linkPseudoClassRules() const { return &m_linkPseudoC
lassRules; } |
128 const Vector<RuleData>* cuePseudoRules() const { return &m_cuePseudoRules; } | 126 const Vector<RuleData>* cuePseudoRules() const { return &m_cuePseudoRules; } |
129 const Vector<RuleData>* focusPseudoClassRules() const { return &m_focusPseud
oClassRules; } | 127 const Vector<RuleData>* focusPseudoClassRules() const { return &m_focusPseud
oClassRules; } |
130 const Vector<RuleData>* universalRules() const { return &m_universalRules; } | 128 const Vector<RuleData>* universalRules() const { return &m_universalRules; } |
131 const Vector<StyleRulePage*>& pageRules() const { return m_pageRules; } | 129 const Vector<StyleRulePage*>& pageRules() const { return m_pageRules; } |
132 | 130 |
133 void reportMemoryUsage(MemoryObjectInfo*) const; | |
134 | |
135 private: | 131 private: |
136 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv
aluator& medium, StyleResolver*, const ContainerNode* scope, bool hasDocumentSec
urityOrigin, AddRuleFlags); | 132 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv
aluator& medium, StyleResolver*, const ContainerNode* scope, bool hasDocumentSec
urityOrigin, AddRuleFlags); |
137 bool findBestRuleSetAndAdd(const CSSSelector*, RuleData&); | 133 bool findBestRuleSetAndAdd(const CSSSelector*, RuleData&); |
138 | 134 |
139 public: | 135 public: |
140 RuleSet(); | 136 RuleSet(); |
141 | 137 |
142 AtomRuleMap m_idRules; | 138 AtomRuleMap m_idRules; |
143 AtomRuleMap m_classRules; | 139 AtomRuleMap m_classRules; |
144 AtomRuleMap m_tagRules; | 140 AtomRuleMap m_tagRules; |
145 AtomRuleMap m_shadowPseudoElementRules; | 141 AtomRuleMap m_shadowPseudoElementRules; |
146 Vector<RuleData> m_linkPseudoClassRules; | 142 Vector<RuleData> m_linkPseudoClassRules; |
147 Vector<RuleData> m_cuePseudoRules; | 143 Vector<RuleData> m_cuePseudoRules; |
148 Vector<RuleData> m_focusPseudoClassRules; | 144 Vector<RuleData> m_focusPseudoClassRules; |
149 Vector<RuleData> m_universalRules; | 145 Vector<RuleData> m_universalRules; |
150 Vector<StyleRulePage*> m_pageRules; | 146 Vector<StyleRulePage*> m_pageRules; |
151 unsigned m_ruleCount; | 147 unsigned m_ruleCount; |
152 bool m_autoShrinkToFitEnabled; | 148 bool m_autoShrinkToFitEnabled; |
153 RuleFeatureSet m_features; | 149 RuleFeatureSet m_features; |
154 | 150 |
155 struct RuleSetSelectorPair { | 151 struct RuleSetSelectorPair { |
156 RuleSetSelectorPair(const CSSSelector* selector, PassOwnPtr<RuleSet> rul
eSet) : selector(selector), ruleSet(ruleSet) { } | 152 RuleSetSelectorPair(const CSSSelector* selector, PassOwnPtr<RuleSet> rul
eSet) : selector(selector), ruleSet(ruleSet) { } |
157 RuleSetSelectorPair(const RuleSetSelectorPair& rs) : selector(rs.selecto
r), ruleSet(const_cast<RuleSetSelectorPair*>(&rs)->ruleSet.release()) { } | 153 RuleSetSelectorPair(const RuleSetSelectorPair& rs) : selector(rs.selecto
r), ruleSet(const_cast<RuleSetSelectorPair*>(&rs)->ruleSet.release()) { } |
158 void reportMemoryUsage(MemoryObjectInfo*) const; | |
159 | 154 |
160 const CSSSelector* selector; | 155 const CSSSelector* selector; |
161 OwnPtr<RuleSet> ruleSet; | 156 OwnPtr<RuleSet> ruleSet; |
162 }; | 157 }; |
163 | 158 |
164 Vector<RuleSetSelectorPair> m_regionSelectorsAndRuleSets; | 159 Vector<RuleSetSelectorPair> m_regionSelectorsAndRuleSets; |
165 }; | 160 }; |
166 | 161 |
167 inline RuleSet::RuleSet() | 162 inline RuleSet::RuleSet() |
168 : m_ruleCount(0) | 163 : m_ruleCount(0) |
169 , m_autoShrinkToFitEnabled(true) | 164 , m_autoShrinkToFitEnabled(true) |
170 { | 165 { |
171 } | 166 } |
172 | 167 |
173 } // namespace WebCore | 168 } // namespace WebCore |
174 | 169 |
175 #endif // RuleSet_h | 170 #endif // RuleSet_h |
OLD | NEW |