| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 | 230 |
| 231 RuleFeatureSet::RuleFeatureSet() | 231 RuleFeatureSet::RuleFeatureSet() |
| 232 { | 232 { |
| 233 } | 233 } |
| 234 | 234 |
| 235 RuleFeatureSet::~RuleFeatureSet() | 235 RuleFeatureSet::~RuleFeatureSet() |
| 236 { | 236 { |
| 237 } | 237 } |
| 238 | 238 |
| 239 DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS
elector& selector) | 239 DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS
elector& selector, InvalidateType type) |
| 240 { | 240 { |
| 241 if (selector.match() == CSSSelector::Class) | 241 if (selector.match() == CSSSelector::Class) |
| 242 return &ensureClassInvalidationSet(selector.value()); | 242 return &ensureClassInvalidationSet(selector.value(), type); |
| 243 if (selector.isAttributeSelector()) | 243 if (selector.isAttributeSelector()) |
| 244 return &ensureAttributeInvalidationSet(selector.attribute().localName())
; | 244 return &ensureAttributeInvalidationSet(selector.attribute().localName(),
type); |
| 245 if (selector.match() == CSSSelector::Id) | 245 if (selector.match() == CSSSelector::Id) |
| 246 return &ensureIdInvalidationSet(selector.value()); | 246 return &ensureIdInvalidationSet(selector.value(), type); |
| 247 if (selector.match() == CSSSelector::PseudoClass) { | 247 if (selector.match() == CSSSelector::PseudoClass) { |
| 248 switch (selector.pseudoType()) { | 248 switch (selector.pseudoType()) { |
| 249 case CSSSelector::PseudoEmpty: | 249 case CSSSelector::PseudoEmpty: |
| 250 case CSSSelector::PseudoLink: | 250 case CSSSelector::PseudoLink: |
| 251 case CSSSelector::PseudoVisited: | 251 case CSSSelector::PseudoVisited: |
| 252 case CSSSelector::PseudoAnyLink: | 252 case CSSSelector::PseudoAnyLink: |
| 253 case CSSSelector::PseudoAutofill: | 253 case CSSSelector::PseudoAutofill: |
| 254 case CSSSelector::PseudoHover: | 254 case CSSSelector::PseudoHover: |
| 255 case CSSSelector::PseudoFocus: | 255 case CSSSelector::PseudoFocus: |
| 256 case CSSSelector::PseudoActive: | 256 case CSSSelector::PseudoActive: |
| 257 case CSSSelector::PseudoChecked: | 257 case CSSSelector::PseudoChecked: |
| 258 case CSSSelector::PseudoEnabled: | 258 case CSSSelector::PseudoEnabled: |
| 259 case CSSSelector::PseudoDisabled: | 259 case CSSSelector::PseudoDisabled: |
| 260 case CSSSelector::PseudoOptional: | 260 case CSSSelector::PseudoOptional: |
| 261 case CSSSelector::PseudoRequired: | 261 case CSSSelector::PseudoRequired: |
| 262 case CSSSelector::PseudoValid: | 262 case CSSSelector::PseudoValid: |
| 263 case CSSSelector::PseudoInvalid: | 263 case CSSSelector::PseudoInvalid: |
| 264 case CSSSelector::PseudoIndeterminate: | 264 case CSSSelector::PseudoIndeterminate: |
| 265 case CSSSelector::PseudoTarget: | 265 case CSSSelector::PseudoTarget: |
| 266 return &ensurePseudoInvalidationSet(selector.pseudoType()); | 266 return &ensurePseudoInvalidationSet(selector.pseudoType(), type); |
| 267 default: | 267 default: |
| 268 break; | 268 break; |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 return nullptr; | 271 return nullptr; |
| 272 } | 272 } |
| 273 | 273 |
| 274 // Given a rule, update the descendant invalidation sets for the features found | 274 // Given a rule, update the descendant invalidation sets for the features found |
| 275 // in its selector. The first step is to extract the features from the rightmost | 275 // in its selector. The first step is to extract the features from the rightmost |
| 276 // compound selector (extractInvalidationSetFeatures). Secondly, add those featu
res | 276 // compound selector (extractInvalidationSetFeatures). |
| 277 // to the invalidation sets for the features found in the other compound selecto
rs | 277 // If we find a feature in the right-most compound selector that requires a |
| 278 // (addFeaturesToInvalidationSets). If we find a feature in the right-most compo
und | 278 // subtree recalc, we addFeaturesToInvalidationSets for the rightmost compound |
| 279 // selector that requires a subtree recalc, we addFeaturesToInvalidationSets for
the | 279 // selector as well. |
| 280 // rightmost compound selector as well. | 280 // Finally, add those features to the invalidation sets for the features found |
| 281 // in the other compound selectors (addFeaturesToInvalidationSets). |
| 281 | 282 |
| 282 void RuleFeatureSet::updateInvalidationSets(const RuleData& ruleData) | 283 void RuleFeatureSet::updateInvalidationSets(const RuleData& ruleData) |
| 283 { | 284 { |
| 284 InvalidationSetFeatures features; | 285 InvalidationSetFeatures features; |
| 285 auto result = extractInvalidationSetFeatures(ruleData.selector(), features,
false); | 286 auto result = extractInvalidationSetFeatures(ruleData.selector(), features,
false); |
| 286 if (result.first) { | |
| 287 features.forceSubtree = result.second == ForceSubtree; | |
| 288 addFeaturesToInvalidationSets(*result.first, features); | |
| 289 } | |
| 290 | 287 |
| 291 // If any ::before and ::after rules specify 'content: attr(...)', we | 288 // If any ::before and ::after rules specify 'content: attr(...)', we |
| 292 // need to create invalidation sets for those attributes. | 289 // need to create invalidation sets for those attributes. |
| 293 if (features.hasBeforeOrAfter) | 290 if (features.hasBeforeOrAfter) |
| 294 updateInvalidationSetsForContentAttribute(ruleData); | 291 updateInvalidationSetsForContentAttribute(ruleData); |
| 292 |
| 293 if (result.first) { |
| 294 features.forceSubtree = result.second == ForceSubtree; |
| 295 addFeaturesToInvalidationSets(result.first, features); |
| 296 } |
| 295 } | 297 } |
| 296 | 298 |
| 297 void RuleFeatureSet::updateInvalidationSetsForContentAttribute(const RuleData& r
uleData) | 299 void RuleFeatureSet::updateInvalidationSetsForContentAttribute(const RuleData& r
uleData) |
| 298 { | 300 { |
| 299 const StylePropertySet& propertySet = ruleData.rule()->properties(); | 301 const StylePropertySet& propertySet = ruleData.rule()->properties(); |
| 300 | 302 |
| 301 int propertyIndex = propertySet.findPropertyIndex(CSSPropertyContent); | 303 int propertyIndex = propertySet.findPropertyIndex(CSSPropertyContent); |
| 302 | 304 |
| 303 if (propertyIndex == -1) | 305 if (propertyIndex == -1) |
| 304 return; | 306 return; |
| 305 | 307 |
| 306 StylePropertySet::PropertyReference contentProperty = propertySet.propertyAt
(propertyIndex); | 308 StylePropertySet::PropertyReference contentProperty = propertySet.propertyAt
(propertyIndex); |
| 307 CSSValue* contentValue = contentProperty.value(); | 309 CSSValue* contentValue = contentProperty.value(); |
| 308 | 310 |
| 309 if (!contentValue->isValueList()) | 311 if (!contentValue->isValueList()) |
| 310 return; | 312 return; |
| 311 | 313 |
| 312 for (auto& item : toCSSValueList(*contentValue)) { | 314 for (auto& item : toCSSValueList(*contentValue)) { |
| 313 if (!item->isPrimitiveValue()) | 315 if (!item->isPrimitiveValue()) |
| 314 continue; | 316 continue; |
| 315 CSSPrimitiveValue* primitiveItem = toCSSPrimitiveValue(item.get()); | 317 CSSPrimitiveValue* primitiveItem = toCSSPrimitiveValue(item.get()); |
| 316 if (!primitiveItem->isAttr()) | 318 if (!primitiveItem->isAttr()) |
| 317 continue; | 319 continue; |
| 318 ensureAttributeInvalidationSet(AtomicString(primitiveItem->getStringValu
e())); | 320 ensureAttributeInvalidationSet(AtomicString(primitiveItem->getStringValu
e()), InvalidateDescendants); |
| 319 } | 321 } |
| 320 } | 322 } |
| 321 | 323 |
| 322 std::pair<const CSSSelector*, RuleFeatureSet::UseFeaturesType> | 324 std::pair<const CSSSelector*, RuleFeatureSet::UseFeaturesType> |
| 323 RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelector& selector, Inva
lidationSetFeatures& features, bool negated) | 325 RuleFeatureSet::extractInvalidationSetFeatures(const CSSSelector& selector, Inva
lidationSetFeatures& features, bool negated) |
| 324 { | 326 { |
| 325 bool foundFeatures = false; | 327 bool foundFeatures = false; |
| 326 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { | 328 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { |
| 327 if (!negated) | 329 if (!negated) |
| 328 foundFeatures |= extractInvalidationSetFeature(*current, features); | 330 foundFeatures |= extractInvalidationSetFeature(*current, features); |
| 329 // Initialize the entry in the invalidation set map, if supported. | 331 // Initialize the entry in the invalidation set map, if supported. |
| 330 if (!invalidationSetForSelector(*current)) { | 332 if (!invalidationSetForSelector(*current, InvalidateDescendants)) { |
| 331 if (requiresSubtreeInvalidation(*current)) { | 333 if (requiresSubtreeInvalidation(*current)) { |
| 332 // Fall back to use subtree invalidations, even for features in
the | 334 // Fall back to use subtree invalidations, even for features in
the |
| 333 // rightmost compound selector. Returning the start &selector he
re | 335 // rightmost compound selector. Returning the start &selector he
re |
| 334 // will make addFeaturesToInvalidationSets start marking invalid
ation | 336 // will make addFeaturesToInvalidationSets start marking invalid
ation |
| 335 // sets for subtree recalc for features in the rightmost compoun
d | 337 // sets for subtree recalc for features in the rightmost compoun
d |
| 336 // selector. | 338 // selector. |
| 337 return std::make_pair(&selector, ForceSubtree); | 339 return std::make_pair(&selector, ForceSubtree); |
| 338 } | 340 } |
| 339 if (const CSSSelectorList* selectorList = current->selectorList()) { | 341 if (const CSSSelectorList* selectorList = current->selectorList()) { |
| 340 ASSERT(supportsInvalidationWithSelectorList(current->pseudoType(
))); | 342 ASSERT(supportsInvalidationWithSelectorList(current->pseudoType(
))); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 352 } | 354 } |
| 353 foundFeatures |= allSubSelectorsHaveFeatures; | 355 foundFeatures |= allSubSelectorsHaveFeatures; |
| 354 } | 356 } |
| 355 } | 357 } |
| 356 | 358 |
| 357 if (current->relation() == CSSSelector::SubSelector) | 359 if (current->relation() == CSSSelector::SubSelector) |
| 358 continue; | 360 continue; |
| 359 | 361 |
| 360 features.treeBoundaryCrossing = current->isShadowSelector(); | 362 features.treeBoundaryCrossing = current->isShadowSelector(); |
| 361 features.adjacent = current->isAdjacentSelector(); | 363 features.adjacent = current->isAdjacentSelector(); |
| 364 if (current->relation() == CSSSelector::DirectAdjacent) |
| 365 features.maxDirectAdjacentSelectors = 1; |
| 362 return std::make_pair(current->tagHistory(), foundFeatures ? UseFeatures
: ForceSubtree); | 366 return std::make_pair(current->tagHistory(), foundFeatures ? UseFeatures
: ForceSubtree); |
| 363 } | 367 } |
| 364 return std::make_pair(nullptr, foundFeatures ? UseFeatures : ForceSubtree); | 368 return std::make_pair(nullptr, foundFeatures ? UseFeatures : ForceSubtree); |
| 365 } | 369 } |
| 366 | 370 |
| 367 // Add features extracted from the rightmost compound selector to descendant inv
alidation | 371 // Add features extracted from the rightmost compound selector to descendant inv
alidation |
| 368 // sets for features found in other compound selectors. | 372 // sets for features found in other compound selectors. |
| 369 // | 373 // |
| 370 // Style invalidation is currently supported for descendants only, not for sibli
ng subtrees. | 374 // Style invalidation is currently supported for descendants only, not for sibli
ng subtrees. |
| 371 // We use wholeSubtree invalidation for features found left of adjacent combinat
ors as | 375 // We use wholeSubtree invalidation for features found left of adjacent combinat
ors as |
| 372 // SubtreeStyleChange will force sibling subtree recalc in | 376 // SubtreeStyleChange will force sibling subtree recalc in |
| 373 // ContainerNode::checkForChildrenAdjacentRuleChanges. | 377 // ContainerNode::checkForChildrenAdjacentRuleChanges. |
| 374 // | 378 // |
| 375 // As we encounter a descendant type of combinator, the features only need to be
checked | 379 // As we encounter a descendant type of combinator, the features only need to be
checked |
| 376 // against descendants in the same subtree only. features.adjacent is set to fal
se, and | 380 // against descendants in the same subtree only. features.adjacent is set to fal
se, and |
| 377 // we start adding features instead of calling setWholeSubtreeInvalid. | 381 // we start adding features instead of calling setWholeSubtreeInvalid. |
| 378 | 382 |
| 379 void RuleFeatureSet::addFeaturesToInvalidationSet(DescendantInvalidationSet& inv
alidationSet, const InvalidationSetFeatures& features) | 383 void RuleFeatureSet::addFeaturesToInvalidationSet(DescendantInvalidationSet& inv
alidationSet, const InvalidationSetFeatures& features) |
| 380 { | 384 { |
| 385 invalidationSet.setMaxDirectAdjacentSelectors(features.maxDirectAdjacentSele
ctors); |
| 386 |
| 381 if (features.treeBoundaryCrossing) | 387 if (features.treeBoundaryCrossing) |
| 382 invalidationSet.setTreeBoundaryCrossing(); | 388 invalidationSet.setTreeBoundaryCrossing(); |
| 383 if (features.insertionPointCrossing) | 389 if (features.insertionPointCrossing) |
| 384 invalidationSet.setInsertionPointCrossing(); | 390 invalidationSet.setInsertionPointCrossing(); |
| 385 if (features.useSubtreeInvalidation()) { | 391 if (features.forceSubtree) { |
| 386 invalidationSet.setWholeSubtreeInvalid(); | 392 invalidationSet.setWholeSubtreeInvalid(); |
| 387 return; | 393 return; |
| 388 } | 394 } |
| 389 if (!features.id.isEmpty()) | 395 if (!features.id.isEmpty()) |
| 390 invalidationSet.addId(features.id); | 396 invalidationSet.addId(features.id); |
| 391 if (!features.tagName.isEmpty()) | 397 if (!features.tagName.isEmpty()) |
| 392 invalidationSet.addTagName(features.tagName); | 398 invalidationSet.addTagName(features.tagName); |
| 393 for (const auto& className : features.classes) | 399 for (const auto& className : features.classes) |
| 394 invalidationSet.addClass(className); | 400 invalidationSet.addClass(className); |
| 395 for (const auto& attribute : features.attributes) | 401 for (const auto& attribute : features.attributes) |
| 396 invalidationSet.addAttribute(attribute); | 402 invalidationSet.addAttribute(attribute); |
| 397 if (features.customPseudoElement) | 403 if (features.customPseudoElement) |
| 398 invalidationSet.setCustomPseudoInvalid(); | 404 invalidationSet.setCustomPseudoInvalid(); |
| 399 } | 405 } |
| 400 | 406 |
| 401 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector& selector,
InvalidationSetFeatures& features) | 407 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector* selector,
InvalidationSetFeatures& features) |
| 402 { | 408 { |
| 403 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { | 409 InvalidateType type = features.adjacent ? InvalidateSiblings : InvalidateDes
cendants; |
| 404 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current)) { | 410 InvalidationSetFeatures* activeFeatures = &features; |
| 405 addFeaturesToInvalidationSet(*invalidationSet, features); | 411 |
| 412 InvalidationSetFeatures siblingFeatures; |
| 413 |
| 414 for (const CSSSelector* current = selector; current; current = current->tagH
istory()) { |
| 415 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current, type)) { |
| 416 addFeaturesToInvalidationSet(*invalidationSet, *activeFeatures); |
| 406 } else { | 417 } else { |
| 407 if (current->isTreeBoundaryCrossing()) | 418 if (current->isTreeBoundaryCrossing()) |
| 408 features.treeBoundaryCrossing = true; | 419 features.treeBoundaryCrossing = true; |
| 409 if (current->isInsertionPointCrossing()) | 420 if (current->isInsertionPointCrossing()) |
| 410 features.insertionPointCrossing = true; | 421 features.insertionPointCrossing = true; |
| 411 if (const CSSSelectorList* selectorList = current->selectorList()) { | 422 if (const CSSSelectorList* selectorList = current->selectorList()) { |
| 412 ASSERT(supportsInvalidationWithSelectorList(current->pseudoType(
))); | 423 ASSERT(supportsInvalidationWithSelectorList(current->pseudoType(
))); |
| 413 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) | 424 for (const CSSSelector* subSelector = selectorList->first(); sub
Selector; subSelector = CSSSelectorList::next(*subSelector)) |
| 414 addFeaturesToInvalidationSets(*selector, features); | 425 addFeaturesToInvalidationSets(subSelector, *activeFeatures); |
| 415 } | 426 } |
| 416 } | 427 } |
| 417 | 428 |
| 418 if (current->relation() == CSSSelector::SubSelector) | 429 if (current->relation() == CSSSelector::SubSelector) |
| 419 continue; | 430 continue; |
| 420 | 431 |
| 421 if (current->isShadowSelector()) | 432 if (current->isShadowSelector()) |
| 422 features.treeBoundaryCrossing = true; | 433 activeFeatures->treeBoundaryCrossing = true; |
| 423 | 434 |
| 424 features.adjacent = current->isAdjacentSelector(); | 435 if (current->isAdjacentSelector()) { |
| 436 if (type == InvalidateDescendants) { |
| 437 siblingFeatures = InvalidationSetFeatures(); |
| 438 extractInvalidationSetFeatures(*selector, siblingFeatures, false
); |
| 439 if (current->relation() == CSSSelector::DirectAdjacent) |
| 440 siblingFeatures.maxDirectAdjacentSelectors = 1; |
| 441 type = InvalidateSiblings; |
| 442 activeFeatures = &siblingFeatures; |
| 443 } else if (activeFeatures->maxDirectAdjacentSelectors != std::numeri
c_limits<unsigned>::max()) { |
| 444 if (current->relation() == CSSSelector::DirectAdjacent) |
| 445 activeFeatures->maxDirectAdjacentSelectors++; |
| 446 else |
| 447 activeFeatures->maxDirectAdjacentSelectors = std::numeric_li
mits<unsigned>::max(); |
| 448 } |
| 449 } else { |
| 450 selector = current->tagHistory(); |
| 451 type = InvalidateDescendants; |
| 452 features.maxDirectAdjacentSelectors = std::numeric_limits<unsigned>:
:max(); |
| 453 activeFeatures = &features; |
| 454 } |
| 425 } | 455 } |
| 426 } | 456 } |
| 427 | 457 |
| 428 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | 458 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) |
| 429 { | 459 { |
| 430 updateInvalidationSets(ruleData); | 460 updateInvalidationSets(ruleData); |
| 431 | 461 |
| 432 FeatureMetadata metadata; | 462 FeatureMetadata metadata; |
| 433 collectFeaturesFromSelector(ruleData.selector(), metadata); | 463 collectFeaturesFromSelector(ruleData.selector(), metadata); |
| 434 m_metadata.add(metadata); | 464 m_metadata.add(metadata); |
| 435 | 465 |
| 436 if (metadata.foundSiblingSelector) | 466 if (metadata.foundSiblingSelector) |
| 437 siblingRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex(
), ruleData.hasDocumentSecurityOrigin())); | 467 siblingRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex(
), ruleData.hasDocumentSecurityOrigin())); |
| 438 if (ruleData.containsUncommonAttributeSelector()) | 468 if (ruleData.containsUncommonAttributeSelector()) |
| 439 uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.sele
ctorIndex(), ruleData.hasDocumentSecurityOrigin())); | 469 uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.sele
ctorIndex(), ruleData.hasDocumentSecurityOrigin())); |
| 440 } | 470 } |
| 441 | 471 |
| 442 DescendantInvalidationSet& RuleFeatureSet::ensureClassInvalidationSet(const Atom
icString& className) | |
| 443 { | |
| 444 InvalidationSetMap::AddResult addResult = m_classInvalidationSets.add(classN
ame, nullptr); | |
| 445 if (addResult.isNewEntry) | |
| 446 addResult.storedValue->value = DescendantInvalidationSet::create(); | |
| 447 return *addResult.storedValue->value; | |
| 448 } | |
| 449 | |
| 450 DescendantInvalidationSet& RuleFeatureSet::ensureAttributeInvalidationSet(const
AtomicString& attributeName) | |
| 451 { | |
| 452 InvalidationSetMap::AddResult addResult = m_attributeInvalidationSets.add(at
tributeName, nullptr); | |
| 453 if (addResult.isNewEntry) | |
| 454 addResult.storedValue->value = DescendantInvalidationSet::create(); | |
| 455 return *addResult.storedValue->value; | |
| 456 } | |
| 457 | |
| 458 DescendantInvalidationSet& RuleFeatureSet::ensureIdInvalidationSet(const AtomicS
tring& id) | |
| 459 { | |
| 460 InvalidationSetMap::AddResult addResult = m_idInvalidationSets.add(id, nullp
tr); | |
| 461 if (addResult.isNewEntry) | |
| 462 addResult.storedValue->value = DescendantInvalidationSet::create(); | |
| 463 return *addResult.storedValue->value; | |
| 464 } | |
| 465 | |
| 466 DescendantInvalidationSet& RuleFeatureSet::ensurePseudoInvalidationSet(CSSSelect
or::PseudoType pseudoType) | |
| 467 { | |
| 468 PseudoTypeInvalidationSetMap::AddResult addResult = m_pseudoInvalidationSets
.add(pseudoType, nullptr); | |
| 469 if (addResult.isNewEntry) | |
| 470 addResult.storedValue->value = DescendantInvalidationSet::create(); | |
| 471 return *addResult.storedValue->value; | |
| 472 } | |
| 473 | |
| 474 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector, Ru
leFeatureSet::FeatureMetadata& metadata) | 472 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector, Ru
leFeatureSet::FeatureMetadata& metadata) |
| 475 { | 473 { |
| 476 unsigned maxDirectAdjacentSelectors = 0; | 474 unsigned maxDirectAdjacentSelectors = 0; |
| 477 | 475 |
| 478 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { | 476 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { |
| 479 if (current->pseudoType() == CSSSelector::PseudoFirstLine) | 477 if (current->pseudoType() == CSSSelector::PseudoFirstLine) |
| 480 metadata.usesFirstLineRules = true; | 478 metadata.usesFirstLineRules = true; |
| 481 if (current->pseudoType() == CSSSelector::PseudoWindowInactive) | 479 if (current->pseudoType() == CSSSelector::PseudoWindowInactive) |
| 482 metadata.usesWindowInactiveSelector = true; | 480 metadata.usesWindowInactiveSelector = true; |
| 483 if (current->relation() == CSSSelector::DirectAdjacent) { | 481 if (current->relation() == CSSSelector::DirectAdjacent) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 512 void RuleFeatureSet::FeatureMetadata::clear() | 510 void RuleFeatureSet::FeatureMetadata::clear() |
| 513 { | 511 { |
| 514 usesFirstLineRules = false; | 512 usesFirstLineRules = false; |
| 515 usesWindowInactiveSelector = false; | 513 usesWindowInactiveSelector = false; |
| 516 foundSiblingSelector = false; | 514 foundSiblingSelector = false; |
| 517 maxDirectAdjacentSelectors = 0; | 515 maxDirectAdjacentSelectors = 0; |
| 518 } | 516 } |
| 519 | 517 |
| 520 void RuleFeatureSet::add(const RuleFeatureSet& other) | 518 void RuleFeatureSet::add(const RuleFeatureSet& other) |
| 521 { | 519 { |
| 522 for (const auto& invalidationSet : other.m_classInvalidationSets) | 520 for (const auto& entry : other.m_classInvalidationSets) |
| 523 ensureClassInvalidationSet(invalidationSet.key).combine(*invalidationSet
.value); | 521 ensureClassInvalidationData(entry.key).combine(*entry.value); |
| 524 for (const auto& invalidationSet : other.m_attributeInvalidationSets) | 522 for (const auto& entry : other.m_attributeInvalidationSets) |
| 525 ensureAttributeInvalidationSet(invalidationSet.key).combine(*invalidatio
nSet.value); | 523 ensureAttributeInvalidationData(entry.key).combine(*entry.value); |
| 526 for (const auto& invalidationSet : other.m_idInvalidationSets) | 524 for (const auto& entry : other.m_idInvalidationSets) |
| 527 ensureIdInvalidationSet(invalidationSet.key).combine(*invalidationSet.va
lue); | 525 ensureIdInvalidationData(entry.key).combine(*entry.value); |
| 528 for (const auto& invalidationSet : other.m_pseudoInvalidationSets) | 526 for (const auto& entry : other.m_pseudoInvalidationSets) |
| 529 ensurePseudoInvalidationSet(static_cast<CSSSelector::PseudoType>(invalid
ationSet.key)).combine(*invalidationSet.value); | 527 ensurePseudoInvalidationData(static_cast<CSSSelector::PseudoType>(entry.
key)).combine(*entry.value); |
| 530 | 528 |
| 531 m_metadata.add(other.m_metadata); | 529 m_metadata.add(other.m_metadata); |
| 532 | 530 |
| 533 siblingRules.appendVector(other.siblingRules); | 531 siblingRules.appendVector(other.siblingRules); |
| 534 uncommonAttributeRules.appendVector(other.uncommonAttributeRules); | 532 uncommonAttributeRules.appendVector(other.uncommonAttributeRules); |
| 535 } | 533 } |
| 536 | 534 |
| 537 void RuleFeatureSet::clear() | 535 void RuleFeatureSet::clear() |
| 538 { | 536 { |
| 539 siblingRules.clear(); | 537 siblingRules.clear(); |
| 540 uncommonAttributeRules.clear(); | 538 uncommonAttributeRules.clear(); |
| 541 m_metadata.clear(); | 539 m_metadata.clear(); |
| 542 m_classInvalidationSets.clear(); | 540 m_classInvalidationSets.clear(); |
| 543 m_attributeInvalidationSets.clear(); | 541 m_attributeInvalidationSets.clear(); |
| 544 m_idInvalidationSets.clear(); | 542 m_idInvalidationSets.clear(); |
| 545 } | 543 } |
| 546 | 544 |
| 547 void RuleFeatureSet::collectInvalidationSetsForClass(InvalidationSetVector& inva
lidationSets, Element& element, const AtomicString& className) const | 545 void RuleFeatureSet::collectInvalidationSetsForClass(InvalidationSetVector& desc
endant, InvalidationSetVector& sibling, Element& element, const AtomicString& cl
assName) const |
| 548 { | 546 { |
| 549 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_classI
nvalidationSets.get(className)) { | 547 if (RefPtrWillBeRawPtr<InvalidationData> invalidationData = m_classInvalidat
ionSets.get(className)) { |
| 550 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, classChange
, className); | 548 if (invalidationData->descendants()) { |
| 551 invalidationSets.append(invalidationSet); | 549 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationData->descen
dants(), classChange, className); |
| 550 descendant.append(invalidationData->descendants()); |
| 551 } |
| 552 if (invalidationData->siblings()) { |
| 553 if (element.parentElement()) |
| 554 TRACE_SCHEDULE_STYLE_INVALIDATION(*element.parentElement(), *inv
alidationData->siblings(), classChange, className); |
| 555 sibling.append(invalidationData->siblings()); |
| 556 } |
| 552 } | 557 } |
| 553 } | 558 } |
| 554 | 559 |
| 555 void RuleFeatureSet::collectInvalidationSetsForId(InvalidationSetVector& invalid
ationSets, Element& element, const AtomicString& id) const | 560 void RuleFeatureSet::collectInvalidationSetsForId(InvalidationSetVector& descend
ant, InvalidationSetVector& sibling, Element& element, const AtomicString& id) c
onst |
| 556 { | 561 { |
| 557 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_idInva
lidationSets.get(id)) { | 562 if (RefPtrWillBeRawPtr<InvalidationData> invalidationData = m_idInvalidation
Sets.get(id)) { |
| 558 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, idChange, i
d); | 563 if (invalidationData->descendants()) { |
| 559 invalidationSets.append(invalidationSet); | 564 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationData->descen
dants(), idChange, id); |
| 565 descendant.append(invalidationData->descendants()); |
| 566 } |
| 567 if (invalidationData->siblings()) { |
| 568 if (element.parentElement()) |
| 569 TRACE_SCHEDULE_STYLE_INVALIDATION(*element.parentElement(), *inv
alidationData->siblings(), idChange, id); |
| 570 sibling.append(invalidationData->siblings()); |
| 571 } |
| 560 } | 572 } |
| 561 } | 573 } |
| 562 | 574 |
| 563 void RuleFeatureSet::collectInvalidationSetsForAttribute(InvalidationSetVector&
invalidationSets, Element& element, const QualifiedName& attributeName) const | 575 void RuleFeatureSet::collectInvalidationSetsForAttribute(InvalidationSetVector&
descendant, InvalidationSetVector& sibling, Element& element, const QualifiedNam
e& attributeName) const |
| 564 { | 576 { |
| 565 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_attrib
uteInvalidationSets.get(attributeName.localName())) { | 577 if (RefPtrWillBeRawPtr<InvalidationData> invalidationData = m_attributeInval
idationSets.get(attributeName.localName())) { |
| 566 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, attributeCh
ange, attributeName); | 578 if (invalidationData->descendants()) { |
| 567 invalidationSets.append(invalidationSet); | 579 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationData->descen
dants(), attributeChange, attributeName); |
| 580 descendant.append(invalidationData->descendants()); |
| 581 } |
| 582 if (invalidationData->siblings()) { |
| 583 if (element.parentElement()) |
| 584 TRACE_SCHEDULE_STYLE_INVALIDATION(*element.parentElement(), *inv
alidationData->siblings(), attributeChange, attributeName); |
| 585 sibling.append(invalidationData->siblings()); |
| 586 } |
| 568 } | 587 } |
| 569 } | 588 } |
| 570 | 589 |
| 571 void RuleFeatureSet::collectInvalidationSetsForPseudoClass(InvalidationSetVector
& invalidationSets, Element& element, CSSSelector::PseudoType pseudo) const | 590 void RuleFeatureSet::collectInvalidationSetsForPseudoClass(InvalidationSetVector
& descendant, InvalidationSetVector& sibling, Element& element, CSSSelector::Pse
udoType pseudo) const |
| 572 { | 591 { |
| 573 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_pseudo
InvalidationSets.get(pseudo)) { | 592 if (RefPtrWillBeRawPtr<InvalidationData> invalidationData = m_pseudoInvalida
tionSets.get(pseudo)) { |
| 574 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, pseudoChang
e, pseudo); | 593 if (invalidationData->descendants()) { |
| 575 invalidationSets.append(invalidationSet); | 594 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationData->descen
dants(), pseudoChange, pseudo); |
| 595 descendant.append(invalidationData->descendants()); |
| 596 } |
| 597 if (invalidationData->siblings()) { |
| 598 if (element.parentElement()) |
| 599 TRACE_SCHEDULE_STYLE_INVALIDATION(*element.parentElement(), *inv
alidationData->siblings(), pseudoChange, pseudo); |
| 600 sibling.append(invalidationData->siblings()); |
| 601 } |
| 576 } | 602 } |
| 577 } | 603 } |
| 578 | 604 |
| 579 DEFINE_TRACE(RuleFeatureSet) | 605 DEFINE_TRACE(RuleFeatureSet) |
| 580 { | 606 { |
| 581 #if ENABLE(OILPAN) | 607 #if ENABLE(OILPAN) |
| 582 visitor->trace(siblingRules); | 608 visitor->trace(siblingRules); |
| 583 visitor->trace(uncommonAttributeRules); | 609 visitor->trace(uncommonAttributeRules); |
| 584 visitor->trace(m_classInvalidationSets); | 610 visitor->trace(m_classInvalidationSets); |
| 585 visitor->trace(m_attributeInvalidationSets); | 611 visitor->trace(m_attributeInvalidationSets); |
| 586 visitor->trace(m_idInvalidationSets); | 612 visitor->trace(m_idInvalidationSets); |
| 587 visitor->trace(m_pseudoInvalidationSets); | 613 visitor->trace(m_pseudoInvalidationSets); |
| 588 #endif | 614 #endif |
| 589 } | 615 } |
| 590 | 616 |
| 591 } // namespace blink | 617 } // namespace blink |
| OLD | NEW |