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 29 matching lines...) Expand all Loading... | |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 static bool isSkippableComponentForInvalidation(const CSSSelector& selector) | 43 static bool isSkippableComponentForInvalidation(const CSSSelector& selector) |
44 { | 44 { |
45 if (selector.m_match == CSSSelector::Tag | 45 if (selector.m_match == CSSSelector::Tag |
46 || selector.m_match == CSSSelector::Id | 46 || selector.m_match == CSSSelector::Id |
47 || selector.isAttributeSelector()) | 47 || selector.isAttributeSelector()) |
48 return true; | 48 return true; |
49 if (selector.m_match == CSSSelector::PseudoElement) { | 49 if (selector.m_match == CSSSelector::PseudoElement) { |
50 switch (selector.m_pseudoType) { | 50 switch (selector.pseudoType()) { |
51 case CSSSelector::PseudoBefore: | 51 case CSSSelector::PseudoBefore: |
52 case CSSSelector::PseudoAfter: | 52 case CSSSelector::PseudoAfter: |
53 case CSSSelector::PseudoBackdrop: | 53 case CSSSelector::PseudoBackdrop: |
54 return true; | 54 return true; |
55 default: | 55 default: |
56 return false; | 56 return false; |
57 } | 57 } |
58 } | 58 } |
59 if (selector.m_match != CSSSelector::PseudoClass) | 59 if (selector.m_match != CSSSelector::PseudoClass) |
60 return false; | 60 return false; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval idation(const CSSSelector& selector) | 105 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval idation(const CSSSelector& selector) |
106 { | 106 { |
107 bool foundDescendantRelation = false; | 107 bool foundDescendantRelation = false; |
108 bool foundIdent = false; | 108 bool foundIdent = false; |
109 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { | 109 for (const CSSSelector* component = &selector; component; component = compon ent->tagHistory()) { |
110 | 110 |
111 // FIXME: next up: Tag and Id. | 111 // FIXME: next up: Tag and Id. |
112 if (component->m_match == CSSSelector::Class || component->isAttributeSe lector()) { | 112 if (component->m_match == CSSSelector::Class || component->isAttributeSe lector()) { |
113 if (!foundDescendantRelation) | 113 if (!foundDescendantRelation) |
114 foundIdent = true; | 114 foundIdent = true; |
115 } else if (component->pseudoType() == CSSSelector::PseudoHost) { | |
116 if (const CSSSelectorList* selectorList = component->selectorList()) { | |
117 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) { | |
118 InvalidationSetMode hostMode = supportsClassDescendantInvali dation(*selector); | |
119 if (hostMode == UseSubtreeStyleChange) | |
120 return foundDescendantRelation ? UseLocalStyleChange : U seSubtreeStyleChange; | |
121 if (hostMode == AddFeatures) | |
122 foundIdent = true; | |
123 } | |
124 } | |
115 } else if (!isSkippableComponentForInvalidation(*component)) { | 125 } else if (!isSkippableComponentForInvalidation(*component)) { |
116 return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeSty leChange; | 126 return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeSty leChange; |
117 } | 127 } |
118 switch (component->relation()) { | 128 switch (component->relation()) { |
119 case CSSSelector::Descendant: | 129 case CSSSelector::Descendant: |
120 case CSSSelector::Child: | 130 case CSSSelector::Child: |
121 case CSSSelector::Shadow: | 131 case CSSSelector::Shadow: |
122 case CSSSelector::ShadowDeep: | 132 case CSSSelector::ShadowDeep: |
123 foundDescendantRelation = true; | 133 foundDescendantRelation = true; |
124 // Fall through! | 134 // Fall through! |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 { | 171 { |
162 InvalidationSetMode mode = supportsClassDescendantInvalidation(selector); | 172 InvalidationSetMode mode = supportsClassDescendantInvalidation(selector); |
163 if (mode != AddFeatures) | 173 if (mode != AddFeatures) |
164 return mode; | 174 return mode; |
165 | 175 |
166 Vector<AtomicString> classes; | 176 Vector<AtomicString> classes; |
167 AtomicString id; | 177 AtomicString id; |
168 AtomicString tagName; | 178 AtomicString tagName; |
169 Vector<AtomicString> attributes; | 179 Vector<AtomicString> attributes; |
170 | 180 |
181 const CSSSelector* current = extractInvalidationSetFeatures(selector, classe s, id, tagName, attributes); | |
182 if (current) | |
183 current = current->tagHistory(); | |
184 | |
185 if (!current) | |
186 return AddFeatures; | |
187 | |
188 addFeaturesToInvalidationSets(*current, classes, id, tagName, attributes); | |
189 return AddFeatures; | |
esprehn
2014/03/24 16:09:11
Since you're always going to return AddFeatures th
rune
2014/03/24 17:17:18
Done.
| |
190 } | |
191 | |
192 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec tor& selector, Vector<AtomicString>& classes, AtomicString& id, AtomicString& ta gName, Vector<AtomicString>& attributes) | |
193 { | |
171 const CSSSelector* lastSelector = &selector; | 194 const CSSSelector* lastSelector = &selector; |
172 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { | 195 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { |
173 extractClassIdTagOrAttribute(*lastSelector, classes, id, tagName, attrib utes); | 196 extractClassIdTagOrAttribute(*lastSelector, classes, id, tagName, attrib utes); |
174 // Initialize the entry in the invalidation set map, if supported. | 197 // Initialize the entry in the invalidation set map, if supported. |
175 invalidationSetForSelector(*lastSelector); | 198 invalidationSetForSelector(*lastSelector); |
199 if (lastSelector->pseudoType() == CSSSelector::PseudoHost) { | |
200 if (const CSSSelectorList* selectorList = lastSelector->selectorList ()) { | |
201 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) | |
202 extractInvalidationSetFeatures(*selector, classes, id, tagNa me, attributes); | |
203 } | |
204 } | |
176 | 205 |
177 if (lastSelector->relation() != CSSSelector::SubSelector) | 206 if (lastSelector->relation() != CSSSelector::SubSelector) |
178 break; | 207 break; |
179 } | 208 } |
209 return lastSelector; | |
210 } | |
180 | 211 |
181 if (!lastSelector) | 212 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector, const Vector<AtomicString>& classes, AtomicString id, AtomicString tagName, cons t Vector<AtomicString>& attributes) |
182 return AddFeatures; | 213 { |
183 for (const CSSSelector* current = lastSelector->tagHistory(); current; curre nt = current->tagHistory()) { | 214 for (const CSSSelector* current = &selector; current; current = current->tag History()) { |
184 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { | 215 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec tor(*current)) { |
185 if (!id.isEmpty()) | 216 if (!id.isEmpty()) |
186 invalidationSet->addId(id); | 217 invalidationSet->addId(id); |
187 if (!tagName.isEmpty()) | 218 if (!tagName.isEmpty()) |
188 invalidationSet->addTagName(tagName); | 219 invalidationSet->addTagName(tagName); |
189 for (Vector<AtomicString>::const_iterator it = classes.begin(); it ! = classes.end(); ++it) | 220 for (Vector<AtomicString>::const_iterator it = classes.begin(); it ! = classes.end(); ++it) |
190 invalidationSet->addClass(*it); | 221 invalidationSet->addClass(*it); |
191 for (Vector<AtomicString>::const_iterator it = attributes.begin(); i t != attributes.end(); ++it) | 222 for (Vector<AtomicString>::const_iterator it = attributes.begin(); i t != attributes.end(); ++it) |
192 invalidationSet->addAttribute(*it); | 223 invalidationSet->addAttribute(*it); |
224 } else if (current->pseudoType() == CSSSelector::PseudoHost) { | |
225 if (const CSSSelectorList* selectorList = current->selectorList()) { | |
226 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) | |
227 addFeaturesToInvalidationSets(*selector, classes, id, tagNam e, attributes); | |
228 } | |
193 } | 229 } |
194 } | 230 } |
195 return AddFeatures; | |
196 } | 231 } |
197 | 232 |
198 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) | 233 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) |
199 { | 234 { |
200 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName); | 235 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName); |
201 invalidationSet.setWholeSubtreeInvalid(); | 236 invalidationSet.setWholeSubtreeInvalid(); |
202 } | 237 } |
203 | 238 |
204 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | 239 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) |
205 { | 240 { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 if (node->isElementNode()) | 428 if (node->isElementNode()) |
394 m_pendingInvalidationMap.remove(toElement(node)); | 429 m_pendingInvalidationMap.remove(toElement(node)); |
395 } | 430 } |
396 | 431 |
397 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap() | 432 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap() |
398 { | 433 { |
399 return m_pendingInvalidationMap; | 434 return m_pendingInvalidationMap; |
400 } | 435 } |
401 | 436 |
402 } // namespace WebCore | 437 } // namespace WebCore |
OLD | NEW |