OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 | 47 |
48 namespace WebCore { | 48 namespace WebCore { |
49 | 49 |
50 static bool isSkippableComponentForInvalidation(const CSSSelector& selector) | 50 static bool isSkippableComponentForInvalidation(const CSSSelector& selector) |
51 { | 51 { |
52 if (selector.m_match == CSSSelector::Tag | 52 if (selector.m_match == CSSSelector::Tag |
53 || selector.m_match == CSSSelector::Id | 53 || selector.m_match == CSSSelector::Id |
54 || selector.isAttributeSelector()) | 54 || selector.isAttributeSelector()) |
55 return true; | 55 return true; |
56 if (selector.m_match == CSSSelector::PseudoElement) { | 56 if (selector.m_match == CSSSelector::PseudoElement) { |
57 switch (selector.m_pseudoType) { | 57 switch (selector.pseudoType()) { |
58 case CSSSelector::PseudoBefore: | 58 case CSSSelector::PseudoBefore: |
59 case CSSSelector::PseudoAfter: | 59 case CSSSelector::PseudoAfter: |
60 case CSSSelector::PseudoBackdrop: | 60 case CSSSelector::PseudoBackdrop: |
61 return true; | 61 return true; |
62 default: | 62 default: |
63 return false; | 63 return false; |
64 } | 64 } |
65 } | 65 } |
66 if (selector.m_match != CSSSelector::PseudoClass) | 66 if (selector.m_match != CSSSelector::PseudoClass) |
67 return false; | 67 return false; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval idation(const CSSSelector& selector) | 112 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval idation(const CSSSelector& selector) |
113 { | 113 { |
114 bool foundDescendantRelation = false; | 114 bool foundDescendantRelation = false; |
115 bool foundIdent = false; | 115 bool foundIdent = false; |
116 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { | 116 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { |
117 | 117 |
118 // FIXME: next up: Tag and Id. | 118 // FIXME: next up: Tag and Id. |
119 if (component->m_match == CSSSelector::Class) { | 119 if (component->m_match == CSSSelector::Class) { |
120 if (!foundDescendantRelation) | 120 if (!foundDescendantRelation) |
121 foundIdent = true; | 121 foundIdent = true; |
122 } else if (component->pseudoType() == CSSSelector::PseudoHost) { | |
123 const CSSSelectorList* list = component->selectorList(); | |
124 if (list) { | |
ojan
2014/03/22 00:32:23
Nit: typically we write this as follows:
if (cons
| |
125 ASSERT(list->hasOneSelector()); | |
esprehn
2014/03/22 01:25:34
Why does this have to have one selector? You can w
| |
126 InvalidationSetMode hostMode = supportsClassDescendantInvalidati on(*list->first()); | |
127 if (hostMode == UseSubtreeStyleChange) | |
128 return foundDescendantRelation ? UseLocalStyleChange : UseSu btreeStyleChange; | |
129 if (hostMode == AddFeatures) | |
130 foundIdent = true; | |
131 } | |
122 } else if (!isSkippableComponentForInvalidation(*component)) { | 132 } else if (!isSkippableComponentForInvalidation(*component)) { |
123 return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeSty leChange; | 133 return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeSty leChange; |
124 } | 134 } |
125 switch (component->relation()) { | 135 switch (component->relation()) { |
126 case CSSSelector::Descendant: | 136 case CSSSelector::Descendant: |
127 case CSSSelector::Child: | 137 case CSSSelector::Child: |
128 case CSSSelector::Shadow: | 138 case CSSSelector::Shadow: |
129 case CSSSelector::ShadowDeep: | 139 case CSSSelector::ShadowDeep: |
130 foundDescendantRelation = true; | 140 foundDescendantRelation = true; |
131 // Fall through! | 141 // Fall through! |
(...skipping 24 matching lines...) Expand all Loading... | |
156 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateClassInvalidationSets( const CSSSelector& selector) | 166 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateClassInvalidationSets( const CSSSelector& selector) |
157 { | 167 { |
158 InvalidationSetMode mode = supportsClassDescendantInvalidation(selector); | 168 InvalidationSetMode mode = supportsClassDescendantInvalidation(selector); |
159 if (mode != AddFeatures) | 169 if (mode != AddFeatures) |
160 return mode; | 170 return mode; |
161 | 171 |
162 Vector<AtomicString> classes; | 172 Vector<AtomicString> classes; |
163 AtomicString id; | 173 AtomicString id; |
164 AtomicString tagName; | 174 AtomicString tagName; |
165 | 175 |
176 const CSSSelector* current = extractInvalidationSetFeatures(selector, classe s, id, tagName); | |
177 if (!current || !(current = current->tagHistory())) | |
ojan
2014/03/22 00:32:23
Nit: In contrast to the above case, I find setting
esprehn
2014/03/22 01:25:34
Don't do assignments inside || or &&
| |
178 return AddFeatures; | |
179 | |
180 addFeaturesToInvalidationSets(*current, classes, id, tagName); | |
181 return AddFeatures; | |
182 } | |
183 | |
184 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec tor& selector, Vector<AtomicString>& classes, AtomicString& id, AtomicString& ta gName) | |
185 { | |
166 const CSSSelector* lastSelector = &selector; | 186 const CSSSelector* lastSelector = &selector; |
167 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { | 187 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { |
168 extractClassIdOrTag(*lastSelector, classes, id, tagName); | 188 extractClassIdOrTag(*lastSelector, classes, id, tagName); |
169 if (lastSelector->m_match == CSSSelector::Class) | 189 if (lastSelector->m_match == CSSSelector::Class) { |
170 ensureClassInvalidationSet(lastSelector->value()); | 190 ensureClassInvalidationSet(lastSelector->value()); |
191 } else if (lastSelector->pseudoType() == CSSSelector::PseudoHost) { | |
192 const CSSSelectorList* list = lastSelector->selectorList(); | |
193 if (list) | |
ojan
2014/03/22 00:32:23
Ditto first comment.
| |
194 extractInvalidationSetFeatures(*list->first(), classes, id, tagN ame); | |
195 } | |
196 | |
171 if (lastSelector->relation() != CSSSelector::SubSelector) | 197 if (lastSelector->relation() != CSSSelector::SubSelector) |
172 break; | 198 break; |
173 } | 199 } |
200 return lastSelector; | |
201 } | |
174 | 202 |
175 if (!lastSelector) | 203 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, const Vector<AtomicString>& classes, AtomicString id, AtomicString tagName) |
176 return AddFeatures; | 204 { |
177 | 205 const CSSSelector* current = &selector; |
178 for (const CSSSelector* current = lastSelector->tagHistory(); current; curre nt = current->tagHistory()) { | 206 for (; current; current = current->tagHistory()) { |
179 if (current->m_match == CSSSelector::Class) { | 207 if (current->m_match == CSSSelector::Class) { |
180 DescendantInvalidationSet& invalidationSet = ensureClassInvalidation Set(current->value()); | 208 DescendantInvalidationSet& invalidationSet = ensureClassInvalidation Set(current->value()); |
181 if (!id.isEmpty()) | 209 if (!id.isEmpty()) |
182 invalidationSet.addId(id); | 210 invalidationSet.addId(id); |
183 if (!tagName.isEmpty()) | 211 if (!tagName.isEmpty()) |
184 invalidationSet.addTagName(tagName); | 212 invalidationSet.addTagName(tagName); |
185 for (Vector<AtomicString>::const_iterator it = classes.begin(); it ! = classes.end(); ++it) { | 213 for (Vector<AtomicString>::const_iterator it = classes.begin(); it ! = classes.end(); ++it) { |
186 invalidationSet.addClass(*it); | 214 invalidationSet.addClass(*it); |
187 } | 215 } |
216 } else if (current->pseudoType() == CSSSelector::PseudoHost) { | |
217 if (current->selectorList()) | |
ojan
2014/03/22 00:32:23
Nit: extra space after the if.
| |
218 addFeaturesToInvalidationSets(*current->selectorList()->first(), classes, id, tagName); | |
188 } | 219 } |
189 } | 220 } |
190 return AddFeatures; | |
191 } | 221 } |
192 | 222 |
193 void RuleFeatureSet::addAttributeInASelector(const AtomicString& attributeName) | 223 void RuleFeatureSet::addAttributeInASelector(const AtomicString& attributeName) |
194 { | 224 { |
195 m_metadata.attrsInRules.add(attributeName); | 225 m_metadata.attrsInRules.add(attributeName); |
196 } | 226 } |
197 | 227 |
198 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | 228 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) |
199 { | 229 { |
200 FeatureMetadata metadata; | 230 FeatureMetadata metadata; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 if (node->isElementNode()) | 405 if (node->isElementNode()) |
376 m_pendingInvalidationMap.remove(toElement(node)); | 406 m_pendingInvalidationMap.remove(toElement(node)); |
377 } | 407 } |
378 | 408 |
379 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap() | 409 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap() |
380 { | 410 { |
381 return m_pendingInvalidationMap; | 411 return m_pendingInvalidationMap; |
382 } | 412 } |
383 | 413 |
384 } // namespace WebCore | 414 } // namespace WebCore |
OLD | NEW |