| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeSty
leChange; | 128 return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeSty
leChange; |
| 129 } | 129 } |
| 130 switch (component->relation()) { | 130 switch (component->relation()) { |
| 131 case CSSSelector::Descendant: | 131 case CSSSelector::Descendant: |
| 132 case CSSSelector::Child: | 132 case CSSSelector::Child: |
| 133 case CSSSelector::ShadowPseudo: | 133 case CSSSelector::ShadowPseudo: |
| 134 case CSSSelector::ShadowDeep: | 134 case CSSSelector::ShadowDeep: |
| 135 foundDescendantRelation = true; | 135 foundDescendantRelation = true; |
| 136 // Fall through! | 136 // Fall through! |
| 137 case CSSSelector::SubSelector: | 137 case CSSSelector::SubSelector: |
| 138 case CSSSelector::DirectAdjacent: |
| 139 case CSSSelector::IndirectAdjacent: |
| 138 continue; | 140 continue; |
| 139 default: | 141 default: |
| 142 // All combinators should be handled above. |
| 143 ASSERT_NOT_REACHED(); |
| 140 return UseLocalStyleChange; | 144 return UseLocalStyleChange; |
| 141 } | 145 } |
| 142 } | 146 } |
| 143 return foundIdent ? AddFeatures : UseLocalStyleChange; | 147 return foundIdent ? AddFeatures : UseLocalStyleChange; |
| 144 } | 148 } |
| 145 | 149 |
| 146 void RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector,
InvalidationSetFeatures& features) | 150 void RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector,
InvalidationSetFeatures& features) |
| 147 { | 151 { |
| 148 if (selector.m_match == CSSSelector::Tag) | 152 if (selector.m_match == CSSSelector::Tag) |
| 149 features.tagName = selector.tagQName().localName(); | 153 features.tagName = selector.tagQName().localName(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 174 } | 178 } |
| 175 | 179 |
| 176 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const
CSSSelector& selector) | 180 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const
CSSSelector& selector) |
| 177 { | 181 { |
| 178 InvalidationSetMode mode = invalidationSetModeForSelector(selector); | 182 InvalidationSetMode mode = invalidationSetModeForSelector(selector); |
| 179 if (mode != AddFeatures) | 183 if (mode != AddFeatures) |
| 180 return mode; | 184 return mode; |
| 181 | 185 |
| 182 InvalidationSetFeatures features; | 186 InvalidationSetFeatures features; |
| 183 const CSSSelector* current = extractInvalidationSetFeatures(selector, featur
es); | 187 const CSSSelector* current = extractInvalidationSetFeatures(selector, featur
es); |
| 184 if (current) | 188 if (current) { |
| 189 bool wholeSubtree = current->relation() == CSSSelector::DirectAdjacent |
| current->relation() == CSSSelector::IndirectAdjacent; |
| 185 current = current->tagHistory(); | 190 current = current->tagHistory(); |
| 186 | 191 if (current) |
| 187 if (current) | 192 addFeaturesToInvalidationSets(*current, features, wholeSubtree); |
| 188 addFeaturesToInvalidationSets(*current, features); | 193 } |
| 189 return AddFeatures; | 194 return AddFeatures; |
| 190 } | 195 } |
| 191 | 196 |
| 192 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec
tor& selector, InvalidationSetFeatures& features) | 197 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec
tor& selector, InvalidationSetFeatures& features) |
| 193 { | 198 { |
| 194 const CSSSelector* lastSelector = &selector; | 199 const CSSSelector* lastSelector = &selector; |
| 195 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { | 200 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { |
| 196 extractInvalidationSetFeature(*lastSelector, features); | 201 extractInvalidationSetFeature(*lastSelector, features); |
| 197 // Initialize the entry in the invalidation set map, if supported. | 202 // Initialize the entry in the invalidation set map, if supported. |
| 198 invalidationSetForSelector(*lastSelector); | 203 invalidationSetForSelector(*lastSelector); |
| 199 if (lastSelector->pseudoType() == CSSSelector::PseudoHost || lastSelecto
r->pseudoType() == CSSSelector::PseudoAny) { | 204 if (lastSelector->pseudoType() == CSSSelector::PseudoHost || lastSelecto
r->pseudoType() == CSSSelector::PseudoAny) { |
| 200 if (const CSSSelectorList* selectorList = lastSelector->selectorList
()) { | 205 if (const CSSSelectorList* selectorList = lastSelector->selectorList
()) { |
| 201 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) | 206 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) |
| 202 extractInvalidationSetFeatures(*selector, features); | 207 extractInvalidationSetFeatures(*selector, features); |
| 203 } | 208 } |
| 204 } | 209 } |
| 205 | 210 |
| 206 if (lastSelector->relation() != CSSSelector::SubSelector) | 211 if (lastSelector->relation() != CSSSelector::SubSelector) |
| 207 break; | 212 break; |
| 208 } | 213 } |
| 209 return lastSelector; | 214 return lastSelector; |
| 210 } | 215 } |
| 211 | 216 |
| 212 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector,
const InvalidationSetFeatures& features) | 217 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector,
const InvalidationSetFeatures& features, bool wholeSubtree) |
| 213 { | 218 { |
| 214 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { | 219 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { |
| 215 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current)) { | 220 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current)) { |
| 216 if (!features.id.isEmpty()) | 221 if (wholeSubtree) { |
| 217 invalidationSet->addId(features.id); | 222 invalidationSet->setWholeSubtreeInvalid(); |
| 218 if (!features.tagName.isEmpty()) | 223 } else { |
| 219 invalidationSet->addTagName(features.tagName); | 224 if (!features.id.isEmpty()) |
| 220 for (Vector<AtomicString>::const_iterator it = features.classes.begi
n(); it != features.classes.end(); ++it) | 225 invalidationSet->addId(features.id); |
| 221 invalidationSet->addClass(*it); | 226 if (!features.tagName.isEmpty()) |
| 222 for (Vector<AtomicString>::const_iterator it = features.attributes.b
egin(); it != features.attributes.end(); ++it) | 227 invalidationSet->addTagName(features.tagName); |
| 223 invalidationSet->addAttribute(*it); | 228 for (Vector<AtomicString>::const_iterator it = features.classes.
begin(); it != features.classes.end(); ++it) |
| 224 if (features.customPseudoElement) | 229 invalidationSet->addClass(*it); |
| 225 invalidationSet->setCustomPseudoInvalid(); | 230 for (Vector<AtomicString>::const_iterator it = features.attribut
es.begin(); it != features.attributes.end(); ++it) |
| 231 invalidationSet->addAttribute(*it); |
| 232 if (features.customPseudoElement) |
| 233 invalidationSet->setCustomPseudoInvalid(); |
| 234 } |
| 226 } else if (current->pseudoType() == CSSSelector::PseudoHost || current->
pseudoType() == CSSSelector::PseudoAny) { | 235 } else if (current->pseudoType() == CSSSelector::PseudoHost || current->
pseudoType() == CSSSelector::PseudoAny) { |
| 227 if (const CSSSelectorList* selectorList = current->selectorList()) { | 236 if (const CSSSelectorList* selectorList = current->selectorList()) { |
| 228 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) | 237 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) |
| 229 addFeaturesToInvalidationSets(*selector, features); | 238 addFeaturesToInvalidationSets(*selector, features, wholeSubt
ree); |
| 230 } | 239 } |
| 231 } | 240 } |
| 241 switch (current->relation()) { |
| 242 case CSSSelector::Descendant: |
| 243 case CSSSelector::Child: |
| 244 case CSSSelector::ShadowPseudo: |
| 245 case CSSSelector::ShadowDeep: |
| 246 wholeSubtree = false; |
| 247 break; |
| 248 case CSSSelector::DirectAdjacent: |
| 249 case CSSSelector::IndirectAdjacent: |
| 250 wholeSubtree = true; |
| 251 break; |
| 252 case CSSSelector::SubSelector: |
| 253 break; |
| 254 default: |
| 255 // All combinators should be handled above. |
| 256 ASSERT_NOT_REACHED(); |
| 257 break; |
| 258 } |
| 232 } | 259 } |
| 233 } | 260 } |
| 234 | 261 |
| 235 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) | 262 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) |
| 236 { | 263 { |
| 237 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet(
attributeName); | 264 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet(
attributeName); |
| 238 invalidationSet.setWholeSubtreeInvalid(); | 265 invalidationSet.setWholeSubtreeInvalid(); |
| 239 } | 266 } |
| 240 | 267 |
| 241 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | 268 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_classInvalidationS
ets.get(className)) | 454 if (RefPtr<DescendantInvalidationSet> invalidationSet = m_classInvalidationS
ets.get(className)) |
| 428 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); | 455 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); |
| 429 } | 456 } |
| 430 | 457 |
| 431 StyleInvalidator& RuleFeatureSet::styleInvalidator() | 458 StyleInvalidator& RuleFeatureSet::styleInvalidator() |
| 432 { | 459 { |
| 433 return m_styleInvalidator; | 460 return m_styleInvalidator; |
| 434 } | 461 } |
| 435 | 462 |
| 436 } // namespace WebCore | 463 } // namespace WebCore |
| OLD | NEW |