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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 class MinimalRuleData { | 54 class MinimalRuleData { |
55 ALLOW_ONLY_INLINE_ALLOCATION(); | 55 ALLOW_ONLY_INLINE_ALLOCATION(); |
56 public: | 56 public: |
57 MinimalRuleData(StyleRule* rule, unsigned selectorIndex, AddRuleFlags flags) | 57 MinimalRuleData(StyleRule* rule, unsigned selectorIndex, AddRuleFlags flags) |
58 : m_rule(rule) | 58 : m_rule(rule) |
59 , m_selectorIndex(selectorIndex) | 59 , m_selectorIndex(selectorIndex) |
60 , m_flags(flags) | 60 , m_flags(flags) |
61 { | 61 { |
62 } | 62 } |
63 | 63 |
64 void trace(Visitor*); | 64 DECLARE_TRACE(); |
65 | 65 |
66 RawPtrWillBeMember<StyleRule> m_rule; | 66 RawPtrWillBeMember<StyleRule> m_rule; |
67 unsigned m_selectorIndex; | 67 unsigned m_selectorIndex; |
68 AddRuleFlags m_flags; | 68 AddRuleFlags m_flags; |
69 }; | 69 }; |
70 | 70 |
71 class RuleData { | 71 class RuleData { |
72 ALLOW_ONLY_INLINE_ALLOCATION(); | 72 ALLOW_ONLY_INLINE_ALLOCATION(); |
73 public: | 73 public: |
74 RuleData(StyleRule*, unsigned selectorIndex, unsigned position, AddRuleFlags
); | 74 RuleData(StyleRule*, unsigned selectorIndex, unsigned position, AddRuleFlags
); |
75 | 75 |
76 unsigned position() const { return m_position; } | 76 unsigned position() const { return m_position; } |
77 StyleRule* rule() const { return m_rule; } | 77 StyleRule* rule() const { return m_rule; } |
78 const CSSSelector& selector() const { return m_rule->selectorList().selector
At(m_selectorIndex); } | 78 const CSSSelector& selector() const { return m_rule->selectorList().selector
At(m_selectorIndex); } |
79 unsigned selectorIndex() const { return m_selectorIndex; } | 79 unsigned selectorIndex() const { return m_selectorIndex; } |
80 | 80 |
81 bool isLastInArray() const { return m_isLastInArray; } | 81 bool isLastInArray() const { return m_isLastInArray; } |
82 void setLastInArray(bool flag) { m_isLastInArray = flag; } | 82 void setLastInArray(bool flag) { m_isLastInArray = flag; } |
83 | 83 |
84 bool containsUncommonAttributeSelector() const { return m_containsUncommonAt
tributeSelector; } | 84 bool containsUncommonAttributeSelector() const { return m_containsUncommonAt
tributeSelector; } |
85 unsigned specificity() const { return m_specificity; } | 85 unsigned specificity() const { return m_specificity; } |
86 unsigned linkMatchType() const { return m_linkMatchType; } | 86 unsigned linkMatchType() const { return m_linkMatchType; } |
87 bool hasDocumentSecurityOrigin() const { return m_hasDocumentSecurityOrigin;
} | 87 bool hasDocumentSecurityOrigin() const { return m_hasDocumentSecurityOrigin;
} |
88 PropertyWhitelistType propertyWhitelistType(bool isMatchingUARules = false)
const { return isMatchingUARules ? PropertyWhitelistNone : static_cast<PropertyW
hitelistType>(m_propertyWhitelistType); } | 88 PropertyWhitelistType propertyWhitelistType(bool isMatchingUARules = false)
const { return isMatchingUARules ? PropertyWhitelistNone : static_cast<PropertyW
hitelistType>(m_propertyWhitelistType); } |
89 // Try to balance between memory usage (there can be lots of RuleData object
s) and good filtering performance. | 89 // Try to balance between memory usage (there can be lots of RuleData object
s) and good filtering performance. |
90 static const unsigned maximumIdentifierCount = 4; | 90 static const unsigned maximumIdentifierCount = 4; |
91 const unsigned* descendantSelectorIdentifierHashes() const { return m_descen
dantSelectorIdentifierHashes; } | 91 const unsigned* descendantSelectorIdentifierHashes() const { return m_descen
dantSelectorIdentifierHashes; } |
92 | 92 |
93 void trace(Visitor*); | 93 DECLARE_TRACE(); |
94 | 94 |
95 private: | 95 private: |
96 RawPtrWillBeMember<StyleRule> m_rule; | 96 RawPtrWillBeMember<StyleRule> m_rule; |
97 unsigned m_selectorIndex : 12; | 97 unsigned m_selectorIndex : 12; |
98 unsigned m_isLastInArray : 1; // We store an array of RuleData objects in a
primitive array. | 98 unsigned m_isLastInArray : 1; // We store an array of RuleData objects in a
primitive array. |
99 // This number was picked fairly arbitrarily. We can probably lower it if we
need to. | 99 // This number was picked fairly arbitrarily. We can probably lower it if we
need to. |
100 // Some simple testing showed <100,000 RuleData's on large sites. | 100 // Some simple testing showed <100,000 RuleData's on large sites. |
101 unsigned m_position : 18; | 101 unsigned m_position : 18; |
102 unsigned m_specificity : 24; | 102 unsigned m_specificity : 24; |
103 unsigned m_containsUncommonAttributeSelector : 1; | 103 unsigned m_containsUncommonAttributeSelector : 1; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 { | 152 { |
153 if (!m_pendingRules) | 153 if (!m_pendingRules) |
154 return; | 154 return; |
155 compactRules(); | 155 compactRules(); |
156 } | 156 } |
157 | 157 |
158 #ifndef NDEBUG | 158 #ifndef NDEBUG |
159 void show(); | 159 void show(); |
160 #endif | 160 #endif |
161 | 161 |
162 void trace(Visitor*); | 162 DECLARE_TRACE(); |
163 | 163 |
164 private: | 164 private: |
165 typedef WillBeHeapHashMap<AtomicString, OwnPtrWillBeMember<WillBeHeapLinkedS
tack<RuleData> > > PendingRuleMap; | 165 typedef WillBeHeapHashMap<AtomicString, OwnPtrWillBeMember<WillBeHeapLinkedS
tack<RuleData> > > PendingRuleMap; |
166 typedef WillBeHeapHashMap<AtomicString, OwnPtrWillBeMember<WillBeHeapTermina
tedArray<RuleData> > > CompactRuleMap; | 166 typedef WillBeHeapHashMap<AtomicString, OwnPtrWillBeMember<WillBeHeapTermina
tedArray<RuleData> > > CompactRuleMap; |
167 | 167 |
168 RuleSet() | 168 RuleSet() |
169 : m_ruleCount(0) | 169 : m_ruleCount(0) |
170 { | 170 { |
171 } | 171 } |
172 | 172 |
(...skipping 11 matching lines...) Expand all Loading... |
184 | 184 |
185 class PendingRuleMaps : public NoBaseWillBeGarbageCollected<PendingRuleMaps>
{ | 185 class PendingRuleMaps : public NoBaseWillBeGarbageCollected<PendingRuleMaps>
{ |
186 public: | 186 public: |
187 static PassOwnPtrWillBeRawPtr<PendingRuleMaps> create() { return adoptPt
rWillBeNoop(new PendingRuleMaps); } | 187 static PassOwnPtrWillBeRawPtr<PendingRuleMaps> create() { return adoptPt
rWillBeNoop(new PendingRuleMaps); } |
188 | 188 |
189 PendingRuleMap idRules; | 189 PendingRuleMap idRules; |
190 PendingRuleMap classRules; | 190 PendingRuleMap classRules; |
191 PendingRuleMap tagRules; | 191 PendingRuleMap tagRules; |
192 PendingRuleMap shadowPseudoElementRules; | 192 PendingRuleMap shadowPseudoElementRules; |
193 | 193 |
194 void trace(Visitor*); | 194 DECLARE_TRACE(); |
195 | 195 |
196 private: | 196 private: |
197 PendingRuleMaps() { } | 197 PendingRuleMaps() { } |
198 }; | 198 }; |
199 | 199 |
200 PendingRuleMaps* ensurePendingRules() | 200 PendingRuleMaps* ensurePendingRules() |
201 { | 201 { |
202 if (!m_pendingRules) | 202 if (!m_pendingRules) |
203 m_pendingRules = PendingRuleMaps::create(); | 203 m_pendingRules = PendingRuleMaps::create(); |
204 return m_pendingRules.get(); | 204 return m_pendingRules.get(); |
(...skipping 25 matching lines...) Expand all Loading... |
230 WillBeHeapVector<RuleData> m_allRules; | 230 WillBeHeapVector<RuleData> m_allRules; |
231 #endif | 231 #endif |
232 }; | 232 }; |
233 | 233 |
234 } // namespace blink | 234 } // namespace blink |
235 | 235 |
236 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::RuleData); | 236 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::RuleData); |
237 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::MinimalRuleData); | 237 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::MinimalRuleData); |
238 | 238 |
239 #endif // RuleSet_h | 239 #endif // RuleSet_h |
OLD | NEW |