| 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 addFeaturesToInvalidationSets(*current, classes, id, tagName, attributes
); |
| 187 return AddFeatures; |
| 188 } |
| 189 |
| 190 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelec
tor& selector, Vector<AtomicString>& classes, AtomicString& id, AtomicString& ta
gName, Vector<AtomicString>& attributes) |
| 191 { |
| 171 const CSSSelector* lastSelector = &selector; | 192 const CSSSelector* lastSelector = &selector; |
| 172 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { | 193 for (; lastSelector; lastSelector = lastSelector->tagHistory()) { |
| 173 extractClassIdTagOrAttribute(*lastSelector, classes, id, tagName, attrib
utes); | 194 extractClassIdTagOrAttribute(*lastSelector, classes, id, tagName, attrib
utes); |
| 174 // Initialize the entry in the invalidation set map, if supported. | 195 // Initialize the entry in the invalidation set map, if supported. |
| 175 invalidationSetForSelector(*lastSelector); | 196 invalidationSetForSelector(*lastSelector); |
| 197 if (lastSelector->pseudoType() == CSSSelector::PseudoHost) { |
| 198 if (const CSSSelectorList* selectorList = lastSelector->selectorList
()) { |
| 199 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) |
| 200 extractInvalidationSetFeatures(*selector, classes, id, tagNa
me, attributes); |
| 201 } |
| 202 } |
| 176 | 203 |
| 177 if (lastSelector->relation() != CSSSelector::SubSelector) | 204 if (lastSelector->relation() != CSSSelector::SubSelector) |
| 178 break; | 205 break; |
| 179 } | 206 } |
| 207 return lastSelector; |
| 208 } |
| 180 | 209 |
| 181 if (!lastSelector) | 210 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector,
const Vector<AtomicString>& classes, AtomicString id, AtomicString tagName, cons
t Vector<AtomicString>& attributes) |
| 182 return AddFeatures; | 211 { |
| 183 for (const CSSSelector* current = lastSelector->tagHistory(); current; curre
nt = current->tagHistory()) { | 212 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { |
| 184 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current)) { | 213 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current)) { |
| 185 if (!id.isEmpty()) | 214 if (!id.isEmpty()) |
| 186 invalidationSet->addId(id); | 215 invalidationSet->addId(id); |
| 187 if (!tagName.isEmpty()) | 216 if (!tagName.isEmpty()) |
| 188 invalidationSet->addTagName(tagName); | 217 invalidationSet->addTagName(tagName); |
| 189 for (Vector<AtomicString>::const_iterator it = classes.begin(); it !
= classes.end(); ++it) | 218 for (Vector<AtomicString>::const_iterator it = classes.begin(); it !
= classes.end(); ++it) |
| 190 invalidationSet->addClass(*it); | 219 invalidationSet->addClass(*it); |
| 191 for (Vector<AtomicString>::const_iterator it = attributes.begin(); i
t != attributes.end(); ++it) | 220 for (Vector<AtomicString>::const_iterator it = attributes.begin(); i
t != attributes.end(); ++it) |
| 192 invalidationSet->addAttribute(*it); | 221 invalidationSet->addAttribute(*it); |
| 222 } else if (current->pseudoType() == CSSSelector::PseudoHost) { |
| 223 if (const CSSSelectorList* selectorList = current->selectorList()) { |
| 224 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) |
| 225 addFeaturesToInvalidationSets(*selector, classes, id, tagNam
e, attributes); |
| 226 } |
| 193 } | 227 } |
| 194 } | 228 } |
| 195 return AddFeatures; | |
| 196 } | 229 } |
| 197 | 230 |
| 198 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) | 231 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) |
| 199 { | 232 { |
| 200 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet(
attributeName); | 233 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet(
attributeName); |
| 201 invalidationSet.setWholeSubtreeInvalid(); | 234 invalidationSet.setWholeSubtreeInvalid(); |
| 202 } | 235 } |
| 203 | 236 |
| 204 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | 237 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) |
| 205 { | 238 { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 if (node->isElementNode()) | 426 if (node->isElementNode()) |
| 394 m_pendingInvalidationMap.remove(toElement(node)); | 427 m_pendingInvalidationMap.remove(toElement(node)); |
| 395 } | 428 } |
| 396 | 429 |
| 397 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap() | 430 RuleFeatureSet::PendingInvalidationMap& RuleFeatureSet::pendingInvalidationMap() |
| 398 { | 431 { |
| 399 return m_pendingInvalidationMap; | 432 return m_pendingInvalidationMap; |
| 400 } | 433 } |
| 401 | 434 |
| 402 } // namespace WebCore | 435 } // namespace WebCore |
| OLD | NEW |