| 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.adjacent ? &feature
s : nullptr, 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 // selector is the selector immediately to the left of the rightmost selector. |
| 408 // siblingFeatures is null if selector is not immediately to the left of a sibli
ng combinator. |
| 409 // descendantFeatures has the features of the rightmost selector. |
| 410 void RuleFeatureSet::addFeaturesToInvalidationSets(const CSSSelector* selector,
InvalidationSetFeatures* siblingFeatures, InvalidationSetFeatures& descendantFea
tures) |
| 402 { | 411 { |
| 403 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { | 412 // We set siblingFeatures to &localFeatures if we find a rightmost sibling c
ombinator. |
| 404 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current)) { | 413 InvalidationSetFeatures localFeatures; |
| 405 addFeaturesToInvalidationSet(*invalidationSet, features); | 414 |
| 415 for (const CSSSelector* current = selector; current; current = current->tagH
istory()) { |
| 416 InvalidateType type = siblingFeatures ? InvalidateSiblings : InvalidateD
escendants; |
| 417 if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelec
tor(*current, type)) { |
| 418 addFeaturesToInvalidationSet(*invalidationSet, siblingFeatures ? *si
blingFeatures : descendantFeatures); |
| 419 |
| 420 if (siblingFeatures && !invalidationSet->wholeSubtreeInvalid()) { |
| 421 if (siblingFeatures == &descendantFeatures) |
| 422 invalidationSet->setSiblingInvalid(); |
| 423 else if (descendantFeatures.forceSubtree) |
| 424 invalidationSet->setWholeSubtreeInvalid(); |
| 425 else |
| 426 addFeaturesToInvalidationSet(invalidationSet->ensureDescenda
ntInvalidationSet(), descendantFeatures); |
| 427 } |
| 406 } else { | 428 } else { |
| 407 if (current->isTreeBoundaryCrossing()) | 429 if (current->isTreeBoundaryCrossing()) |
| 408 features.treeBoundaryCrossing = true; | 430 descendantFeatures.treeBoundaryCrossing = true; |
| 409 if (current->isInsertionPointCrossing()) | 431 if (current->isInsertionPointCrossing()) |
| 410 features.insertionPointCrossing = true; | 432 descendantFeatures.insertionPointCrossing = true; |
| 411 if (const CSSSelectorList* selectorList = current->selectorList()) { | 433 if (const CSSSelectorList* selectorList = current->selectorList()) { |
| 412 ASSERT(supportsInvalidationWithSelectorList(current->pseudoType(
))); | 434 ASSERT(supportsInvalidationWithSelectorList(current->pseudoType(
))); |
| 413 for (const CSSSelector* selector = selectorList->first(); select
or; selector = CSSSelectorList::next(*selector)) | 435 for (const CSSSelector* subSelector = selectorList->first(); sub
Selector; subSelector = CSSSelectorList::next(*subSelector)) |
| 414 addFeaturesToInvalidationSets(*selector, features); | 436 addFeaturesToInvalidationSets(subSelector, siblingFeatures,
descendantFeatures); |
| 415 } | 437 } |
| 416 } | 438 } |
| 417 | 439 |
| 418 if (current->relation() == CSSSelector::SubSelector) | 440 if (current->relation() == CSSSelector::SubSelector) |
| 419 continue; | 441 continue; |
| 420 | 442 |
| 421 if (current->isShadowSelector()) | 443 if (current->isShadowSelector()) |
| 422 features.treeBoundaryCrossing = true; | 444 descendantFeatures.treeBoundaryCrossing = true; |
| 423 | 445 |
| 424 features.adjacent = current->isAdjacentSelector(); | 446 if (!current->isAdjacentSelector()) { |
| 447 selector = current->tagHistory(); |
| 448 siblingFeatures = nullptr; |
| 449 continue; |
| 450 } |
| 451 |
| 452 if (siblingFeatures) { |
| 453 if (siblingFeatures->maxDirectAdjacentSelectors != std::numeric_limi
ts<unsigned>::max()) { |
| 454 if (current->relation() == CSSSelector::DirectAdjacent) |
| 455 siblingFeatures->maxDirectAdjacentSelectors++; |
| 456 else |
| 457 siblingFeatures->maxDirectAdjacentSelectors = std::numeric_l
imits<unsigned>::max(); |
| 458 } |
| 459 } else { |
| 460 localFeatures = InvalidationSetFeatures(); |
| 461 auto result = extractInvalidationSetFeatures(*selector, localFeature
s, false); |
| 462 if (result.first) |
| 463 localFeatures.forceSubtree = result.second == ForceSubtree; |
| 464 |
| 465 siblingFeatures = &localFeatures; |
| 466 } |
| 425 } | 467 } |
| 426 } | 468 } |
| 427 | 469 |
| 428 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) | 470 void RuleFeatureSet::collectFeaturesFromRuleData(const RuleData& ruleData) |
| 429 { | 471 { |
| 430 updateInvalidationSets(ruleData); | 472 updateInvalidationSets(ruleData); |
| 431 | 473 |
| 432 FeatureMetadata metadata; | 474 FeatureMetadata metadata; |
| 433 collectFeaturesFromSelector(ruleData.selector(), metadata); | 475 collectFeaturesFromSelector(ruleData.selector(), metadata); |
| 434 m_metadata.add(metadata); | 476 m_metadata.add(metadata); |
| 435 | 477 |
| 436 if (metadata.foundSiblingSelector) | 478 if (metadata.foundSiblingSelector) |
| 437 siblingRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex(
), ruleData.hasDocumentSecurityOrigin())); | 479 siblingRules.append(RuleFeature(ruleData.rule(), ruleData.selectorIndex(
), ruleData.hasDocumentSecurityOrigin())); |
| 438 if (ruleData.containsUncommonAttributeSelector()) | 480 if (ruleData.containsUncommonAttributeSelector()) |
| 439 uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.sele
ctorIndex(), ruleData.hasDocumentSecurityOrigin())); | 481 uncommonAttributeRules.append(RuleFeature(ruleData.rule(), ruleData.sele
ctorIndex(), ruleData.hasDocumentSecurityOrigin())); |
| 440 } | 482 } |
| 441 | 483 |
| 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) | 484 void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector, Ru
leFeatureSet::FeatureMetadata& metadata) |
| 475 { | 485 { |
| 476 unsigned maxDirectAdjacentSelectors = 0; | 486 unsigned maxDirectAdjacentSelectors = 0; |
| 477 | 487 |
| 478 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { | 488 for (const CSSSelector* current = &selector; current; current = current->tag
History()) { |
| 479 if (current->pseudoType() == CSSSelector::PseudoFirstLine) | 489 if (current->pseudoType() == CSSSelector::PseudoFirstLine) |
| 480 metadata.usesFirstLineRules = true; | 490 metadata.usesFirstLineRules = true; |
| 481 if (current->pseudoType() == CSSSelector::PseudoWindowInactive) | 491 if (current->pseudoType() == CSSSelector::PseudoWindowInactive) |
| 482 metadata.usesWindowInactiveSelector = true; | 492 metadata.usesWindowInactiveSelector = true; |
| 483 if (current->relation() == CSSSelector::DirectAdjacent) { | 493 if (current->relation() == CSSSelector::DirectAdjacent) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 512 void RuleFeatureSet::FeatureMetadata::clear() | 522 void RuleFeatureSet::FeatureMetadata::clear() |
| 513 { | 523 { |
| 514 usesFirstLineRules = false; | 524 usesFirstLineRules = false; |
| 515 usesWindowInactiveSelector = false; | 525 usesWindowInactiveSelector = false; |
| 516 foundSiblingSelector = false; | 526 foundSiblingSelector = false; |
| 517 maxDirectAdjacentSelectors = 0; | 527 maxDirectAdjacentSelectors = 0; |
| 518 } | 528 } |
| 519 | 529 |
| 520 void RuleFeatureSet::add(const RuleFeatureSet& other) | 530 void RuleFeatureSet::add(const RuleFeatureSet& other) |
| 521 { | 531 { |
| 522 for (const auto& invalidationSet : other.m_classInvalidationSets) | 532 for (const auto& entry : other.m_classInvalidationSets) |
| 523 ensureClassInvalidationSet(invalidationSet.key).combine(*invalidationSet
.value); | 533 ensureClassInvalidationData(entry.key).combine(*entry.value); |
| 524 for (const auto& invalidationSet : other.m_attributeInvalidationSets) | 534 for (const auto& entry : other.m_attributeInvalidationSets) |
| 525 ensureAttributeInvalidationSet(invalidationSet.key).combine(*invalidatio
nSet.value); | 535 ensureAttributeInvalidationData(entry.key).combine(*entry.value); |
| 526 for (const auto& invalidationSet : other.m_idInvalidationSets) | 536 for (const auto& entry : other.m_idInvalidationSets) |
| 527 ensureIdInvalidationSet(invalidationSet.key).combine(*invalidationSet.va
lue); | 537 ensureIdInvalidationData(entry.key).combine(*entry.value); |
| 528 for (const auto& invalidationSet : other.m_pseudoInvalidationSets) | 538 for (const auto& entry : other.m_pseudoInvalidationSets) |
| 529 ensurePseudoInvalidationSet(static_cast<CSSSelector::PseudoType>(invalid
ationSet.key)).combine(*invalidationSet.value); | 539 ensurePseudoInvalidationData(static_cast<CSSSelector::PseudoType>(entry.
key)).combine(*entry.value); |
| 530 | 540 |
| 531 m_metadata.add(other.m_metadata); | 541 m_metadata.add(other.m_metadata); |
| 532 | 542 |
| 533 siblingRules.appendVector(other.siblingRules); | 543 siblingRules.appendVector(other.siblingRules); |
| 534 uncommonAttributeRules.appendVector(other.uncommonAttributeRules); | 544 uncommonAttributeRules.appendVector(other.uncommonAttributeRules); |
| 535 } | 545 } |
| 536 | 546 |
| 537 void RuleFeatureSet::clear() | 547 void RuleFeatureSet::clear() |
| 538 { | 548 { |
| 539 siblingRules.clear(); | 549 siblingRules.clear(); |
| 540 uncommonAttributeRules.clear(); | 550 uncommonAttributeRules.clear(); |
| 541 m_metadata.clear(); | 551 m_metadata.clear(); |
| 542 m_classInvalidationSets.clear(); | 552 m_classInvalidationSets.clear(); |
| 543 m_attributeInvalidationSets.clear(); | 553 m_attributeInvalidationSets.clear(); |
| 544 m_idInvalidationSets.clear(); | 554 m_idInvalidationSets.clear(); |
| 545 } | 555 } |
| 546 | 556 |
| 547 void RuleFeatureSet::collectInvalidationSetsForClass(InvalidationSetVector& inva
lidationSets, Element& element, const AtomicString& className) const | 557 void RuleFeatureSet::collectInvalidationSetsForClass(InvalidationSetVector& desc
endant, InvalidationSetVector& sibling, Element& element, const AtomicString& cl
assName) const |
| 548 { | 558 { |
| 549 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_classI
nvalidationSets.get(className)) { | 559 if (RefPtrWillBeRawPtr<InvalidationData> invalidationData = m_classInvalidat
ionSets.get(className)) { |
| 550 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, classChange
, className); | 560 if (invalidationData->descendants()) { |
| 551 invalidationSets.append(invalidationSet); | 561 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationData->descen
dants(), classChange, className); |
| 562 descendant.append(invalidationData->descendants()); |
| 563 } |
| 564 if (invalidationData->siblings()) { |
| 565 if (element.parentElement()) |
| 566 TRACE_SCHEDULE_STYLE_INVALIDATION(*element.parentElement(), *inv
alidationData->siblings(), classChange, className); |
| 567 sibling.append(invalidationData->siblings()); |
| 568 } |
| 552 } | 569 } |
| 553 } | 570 } |
| 554 | 571 |
| 555 void RuleFeatureSet::collectInvalidationSetsForId(InvalidationSetVector& invalid
ationSets, Element& element, const AtomicString& id) const | 572 void RuleFeatureSet::collectInvalidationSetsForId(InvalidationSetVector& descend
ant, InvalidationSetVector& sibling, Element& element, const AtomicString& id) c
onst |
| 556 { | 573 { |
| 557 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_idInva
lidationSets.get(id)) { | 574 if (RefPtrWillBeRawPtr<InvalidationData> invalidationData = m_idInvalidation
Sets.get(id)) { |
| 558 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, idChange, i
d); | 575 if (invalidationData->descendants()) { |
| 559 invalidationSets.append(invalidationSet); | 576 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationData->descen
dants(), idChange, id); |
| 577 descendant.append(invalidationData->descendants()); |
| 578 } |
| 579 if (invalidationData->siblings()) { |
| 580 if (element.parentElement()) |
| 581 TRACE_SCHEDULE_STYLE_INVALIDATION(*element.parentElement(), *inv
alidationData->siblings(), idChange, id); |
| 582 sibling.append(invalidationData->siblings()); |
| 583 } |
| 560 } | 584 } |
| 561 } | 585 } |
| 562 | 586 |
| 563 void RuleFeatureSet::collectInvalidationSetsForAttribute(InvalidationSetVector&
invalidationSets, Element& element, const QualifiedName& attributeName) const | 587 void RuleFeatureSet::collectInvalidationSetsForAttribute(InvalidationSetVector&
descendant, InvalidationSetVector& sibling, Element& element, const QualifiedNam
e& attributeName) const |
| 564 { | 588 { |
| 565 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_attrib
uteInvalidationSets.get(attributeName.localName())) { | 589 if (RefPtrWillBeRawPtr<InvalidationData> invalidationData = m_attributeInval
idationSets.get(attributeName.localName())) { |
| 566 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, attributeCh
ange, attributeName); | 590 if (invalidationData->descendants()) { |
| 567 invalidationSets.append(invalidationSet); | 591 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationData->descen
dants(), attributeChange, attributeName); |
| 592 descendant.append(invalidationData->descendants()); |
| 593 } |
| 594 if (invalidationData->siblings()) { |
| 595 if (element.parentElement()) |
| 596 TRACE_SCHEDULE_STYLE_INVALIDATION(*element.parentElement(), *inv
alidationData->siblings(), attributeChange, attributeName); |
| 597 sibling.append(invalidationData->siblings()); |
| 598 } |
| 568 } | 599 } |
| 569 } | 600 } |
| 570 | 601 |
| 571 void RuleFeatureSet::collectInvalidationSetsForPseudoClass(InvalidationSetVector
& invalidationSets, Element& element, CSSSelector::PseudoType pseudo) const | 602 void RuleFeatureSet::collectInvalidationSetsForPseudoClass(InvalidationSetVector
& descendant, InvalidationSetVector& sibling, Element& element, CSSSelector::Pse
udoType pseudo) const |
| 572 { | 603 { |
| 573 if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_pseudo
InvalidationSets.get(pseudo)) { | 604 if (RefPtrWillBeRawPtr<InvalidationData> invalidationData = m_pseudoInvalida
tionSets.get(pseudo)) { |
| 574 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, pseudoChang
e, pseudo); | 605 if (invalidationData->descendants()) { |
| 575 invalidationSets.append(invalidationSet); | 606 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationData->descen
dants(), pseudoChange, pseudo); |
| 607 descendant.append(invalidationData->descendants()); |
| 608 } |
| 609 if (invalidationData->siblings()) { |
| 610 if (element.parentElement()) |
| 611 TRACE_SCHEDULE_STYLE_INVALIDATION(*element.parentElement(), *inv
alidationData->siblings(), pseudoChange, pseudo); |
| 612 sibling.append(invalidationData->siblings()); |
| 613 } |
| 576 } | 614 } |
| 577 } | 615 } |
| 578 | 616 |
| 579 DEFINE_TRACE(RuleFeatureSet) | 617 DEFINE_TRACE(RuleFeatureSet) |
| 580 { | 618 { |
| 581 #if ENABLE(OILPAN) | 619 #if ENABLE(OILPAN) |
| 582 visitor->trace(siblingRules); | 620 visitor->trace(siblingRules); |
| 583 visitor->trace(uncommonAttributeRules); | 621 visitor->trace(uncommonAttributeRules); |
| 584 visitor->trace(m_classInvalidationSets); | 622 visitor->trace(m_classInvalidationSets); |
| 585 visitor->trace(m_attributeInvalidationSets); | 623 visitor->trace(m_attributeInvalidationSets); |
| 586 visitor->trace(m_idInvalidationSets); | 624 visitor->trace(m_idInvalidationSets); |
| 587 visitor->trace(m_pseudoInvalidationSets); | 625 visitor->trace(m_pseudoInvalidationSets); |
| 588 #endif | 626 #endif |
| 589 } | 627 } |
| 590 | 628 |
| 591 } // namespace blink | 629 } // namespace blink |
| OLD | NEW |