| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 | 113 |
| 114 void RuleFeature::trace(Visitor* visitor) | 114 void RuleFeature::trace(Visitor* visitor) |
| 115 { | 115 { |
| 116 visitor->trace(rule); | 116 visitor->trace(rule); |
| 117 } | 117 } |
| 118 | 118 |
| 119 // This method is somewhat conservative in what it accepts. | 119 // This method is somewhat conservative in what it accepts. |
| 120 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect
or(const CSSSelector& selector) | 120 RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect
or(const CSSSelector& selector) |
| 121 { | 121 { |
| 122 bool foundDescendantRelation = false; | 122 bool foundCombinator = false; |
| 123 bool foundIdent = false; | 123 bool foundIdent = false; |
| 124 for (const CSSSelector* component = &selector; component; component = compon
ent->tagHistory()) { | 124 for (const CSSSelector* component = &selector; component; component = compon
ent->tagHistory()) { |
| 125 | 125 |
| 126 if (component->match() == CSSSelector::Class || component->match() == CS
SSelector::Id | 126 if (component->match() == CSSSelector::Class || component->match() == CS
SSelector::Id |
| 127 || (component->match() == CSSSelector::Tag && component->tagQName().
localName() != starAtom) | 127 || (component->match() == CSSSelector::Tag && component->tagQName().
localName() != starAtom) |
| 128 || component->isAttributeSelector() || component->isCustomPseudoElem
ent()) { | 128 || component->isAttributeSelector() || component->isCustomPseudoElem
ent()) { |
| 129 if (!foundDescendantRelation) | 129 if (!foundCombinator) |
| 130 foundIdent = true; | 130 foundIdent = true; |
| 131 } else if (component->pseudoType() == CSSSelector::PseudoHost || compone
nt->pseudoType() == CSSSelector::PseudoAny) { | 131 } else if (component->pseudoType() == CSSSelector::PseudoHost || compone
nt->pseudoType() == CSSSelector::PseudoAny) { |
| 132 if (const CSSSelectorList* selectorList = component->selectorList())
{ | 132 if (const CSSSelectorList* selectorList = component->selectorList())
{ |
| 133 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) { | 133 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) { |
| 134 InvalidationSetMode hostMode = invalidationSetModeForSelecto
r(*selector); | 134 InvalidationSetMode hostMode = invalidationSetModeForSelecto
r(*selector); |
| 135 if (hostMode == UseSubtreeStyleChange) | 135 if (hostMode == UseSubtreeStyleChange) |
| 136 return foundDescendantRelation ? UseLocalStyleChange : U
seSubtreeStyleChange; | 136 return foundCombinator ? UseLocalStyleChange : UseSubtre
eStyleChange; |
| 137 if (!foundDescendantRelation && hostMode == AddFeatures) | 137 if (!foundCombinator && hostMode == AddFeatures) |
| 138 foundIdent = true; | 138 foundIdent = true; |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 } else if (!isSkippableComponentForInvalidation(*component)) { | 141 } else if (!isSkippableComponentForInvalidation(*component)) { |
| 142 return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeSty
leChange; | 142 return foundCombinator ? UseLocalStyleChange : UseSubtreeStyleChange
; |
| 143 } | 143 } |
| 144 switch (component->relation()) { | 144 if (component->relation() != CSSSelector::SubSelector) |
| 145 case CSSSelector::Descendant: | 145 foundCombinator = true; |
| 146 case CSSSelector::Child: | |
| 147 case CSSSelector::ShadowPseudo: | |
| 148 case CSSSelector::ShadowDeep: | |
| 149 foundDescendantRelation = true; | |
| 150 // Fall through! | |
| 151 case CSSSelector::SubSelector: | |
| 152 case CSSSelector::DirectAdjacent: | |
| 153 case CSSSelector::IndirectAdjacent: | |
| 154 continue; | |
| 155 default: | |
| 156 // All combinators should be handled above. | |
| 157 ASSERT_NOT_REACHED(); | |
| 158 return UseLocalStyleChange; | |
| 159 } | |
| 160 } | 146 } |
| 161 return foundIdent ? AddFeatures : UseLocalStyleChange; | 147 return foundIdent ? AddFeatures : UseLocalStyleChange; |
| 162 } | 148 } |
| 163 | 149 |
| 164 void RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector,
InvalidationSetFeatures& features) | 150 void RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector,
InvalidationSetFeatures& features) |
| 165 { | 151 { |
| 166 if (selector.match() == CSSSelector::Tag) | 152 if (selector.match() == CSSSelector::Tag) |
| 167 features.tagName = selector.tagQName().localName(); | 153 features.tagName = selector.tagQName().localName(); |
| 168 else if (selector.match() == CSSSelector::Id) | 154 else if (selector.match() == CSSSelector::Id) |
| 169 features.id = selector.value(); | 155 features.id = selector.value(); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 visitor->trace(siblingRules); | 506 visitor->trace(siblingRules); |
| 521 visitor->trace(uncommonAttributeRules); | 507 visitor->trace(uncommonAttributeRules); |
| 522 visitor->trace(m_classInvalidationSets); | 508 visitor->trace(m_classInvalidationSets); |
| 523 visitor->trace(m_attributeInvalidationSets); | 509 visitor->trace(m_attributeInvalidationSets); |
| 524 visitor->trace(m_idInvalidationSets); | 510 visitor->trace(m_idInvalidationSets); |
| 525 visitor->trace(m_pseudoInvalidationSets); | 511 visitor->trace(m_pseudoInvalidationSets); |
| 526 visitor->trace(m_styleInvalidator); | 512 visitor->trace(m_styleInvalidator); |
| 527 } | 513 } |
| 528 | 514 |
| 529 } // namespace WebCore | 515 } // namespace WebCore |
| OLD | NEW |