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