Chromium Code Reviews| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 | 213 |
| 228 switch (current->relation()) { | 214 switch (current->relation()) { |
| 229 case CSSSelector::SubSelector: | 215 case CSSSelector::SubSelector: |
| 230 break; | 216 break; |
| 231 case CSSSelector::ShadowPseudo: | 217 case CSSSelector::ShadowPseudo: |
| 232 case CSSSelector::ShadowDeep: | 218 case CSSSelector::ShadowDeep: |
| 233 features.treeBoundaryCrossing = true; | 219 features.treeBoundaryCrossing = true; |
| 234 return current->tagHistory(); | 220 return current->tagHistory(); |
| 235 case CSSSelector::DirectAdjacent: | 221 case CSSSelector::DirectAdjacent: |
| 236 case CSSSelector::IndirectAdjacent: | 222 case CSSSelector::IndirectAdjacent: |
| 223 // Style invalidation is currently supported for descendants only, n ot for sibling subtrees. | |
| 224 // Use wholeSubtree invalidation for adjacent combinators as Subtree StyleChange will force | |
| 225 // sibling subtree recalc in ContainerNode::checkForChildrenAdjacent RuleChanges. | |
| 237 features.wholeSubtree = true; | 226 features.wholeSubtree = true; |
| 238 return current->tagHistory(); | 227 return current->tagHistory(); |
| 239 case CSSSelector::Descendant: | 228 case CSSSelector::Descendant: |
| 240 case CSSSelector::Child: | 229 case CSSSelector::Child: |
| 241 return current->tagHistory(); | 230 return current->tagHistory(); |
| 242 } | 231 } |
| 243 } | 232 } |
| 244 return 0; | 233 return 0; |
| 245 } | 234 } |
| 246 | 235 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 271 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) | 260 for (const CSSSelector* selector = selectorList->first(); select or; selector = CSSSelectorList::next(*selector)) |
| 272 addFeaturesToInvalidationSets(*selector, features); | 261 addFeaturesToInvalidationSets(*selector, features); |
| 273 } | 262 } |
| 274 } | 263 } |
| 275 switch (current->relation()) { | 264 switch (current->relation()) { |
| 276 case CSSSelector::SubSelector: | 265 case CSSSelector::SubSelector: |
| 277 break; | 266 break; |
| 278 case CSSSelector::ShadowPseudo: | 267 case CSSSelector::ShadowPseudo: |
| 279 case CSSSelector::ShadowDeep: | 268 case CSSSelector::ShadowDeep: |
| 280 features.treeBoundaryCrossing = true; | 269 features.treeBoundaryCrossing = true; |
| 270 // If we saw an adjacent combinator, wholeSubtree would have been se t to true. A descendant | |
| 271 // type combinator cancels out the need for that. | |
| 281 features.wholeSubtree = false; | 272 features.wholeSubtree = false; |
| 282 break; | 273 break; |
| 283 case CSSSelector::Descendant: | 274 case CSSSelector::Descendant: |
| 284 case CSSSelector::Child: | 275 case CSSSelector::Child: |
| 276 // If we saw an adjacent combinator, wholeSubtree would have been se t to true. A descendant | |
| 277 // type combinator cancels out the need for that. | |
| 285 features.wholeSubtree = false; | 278 features.wholeSubtree = false; |
| 286 break; | 279 break; |
| 287 case CSSSelector::DirectAdjacent: | 280 case CSSSelector::DirectAdjacent: |
| 288 case CSSSelector::IndirectAdjacent: | 281 case CSSSelector::IndirectAdjacent: |
| 282 // Style invalidation is currently supported for descendants only, n ot for sibling subtrees. | |
| 283 // Use wholeSubtree invalidation for adjacent combinators as Subtree StyleChange will force | |
| 284 // sibling subtree recalc in ContainerNode::checkForChildrenAdjacent RuleChanges. | |
|
esprehn
2014/08/16 07:58:34
Not a fan of the copy pasta comments. Can you just
rune
2014/08/18 21:13:06
Done.
| |
| 289 features.wholeSubtree = true; | 285 features.wholeSubtree = true; |
| 290 break; | 286 break; |
| 291 } | 287 } |
| 292 } | 288 } |
| 293 } | 289 } |
| 294 | 290 |
| 295 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) | 291 void RuleFeatureSet::addContentAttr(const AtomicString& attributeName) |
| 296 { | 292 { |
| 297 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName); | 293 DescendantInvalidationSet& invalidationSet = ensureAttributeInvalidationSet( attributeName); |
| 298 invalidationSet.setWholeSubtreeInvalid(); | 294 invalidationSet.setWholeSubtreeInvalid(); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 visitor->trace(uncommonAttributeRules); | 518 visitor->trace(uncommonAttributeRules); |
| 523 visitor->trace(m_classInvalidationSets); | 519 visitor->trace(m_classInvalidationSets); |
| 524 visitor->trace(m_attributeInvalidationSets); | 520 visitor->trace(m_attributeInvalidationSets); |
| 525 visitor->trace(m_idInvalidationSets); | 521 visitor->trace(m_idInvalidationSets); |
| 526 visitor->trace(m_pseudoInvalidationSets); | 522 visitor->trace(m_pseudoInvalidationSets); |
| 527 visitor->trace(m_styleInvalidator); | 523 visitor->trace(m_styleInvalidator); |
| 528 #endif | 524 #endif |
| 529 } | 525 } |
| 530 | 526 |
| 531 } // namespace blink | 527 } // namespace blink |
| OLD | NEW |