| 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 | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All |
| 6 * rights reserved. | 6 * rights reserved. |
| 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 if (lastInCompound.relationIsAffectedByPseudoContent()) | 340 if (lastInCompound.relationIsAffectedByPseudoContent()) |
| 341 descendantFeatures.contentPseudoCrossing = true; | 341 descendantFeatures.contentPseudoCrossing = true; |
| 342 } | 342 } |
| 343 | 343 |
| 344 void RuleFeatureSet::extractInvalidationSetFeaturesFromSimpleSelector( | 344 void RuleFeatureSet::extractInvalidationSetFeaturesFromSimpleSelector( |
| 345 const CSSSelector& selector, | 345 const CSSSelector& selector, |
| 346 InvalidationSetFeatures& features) { | 346 InvalidationSetFeatures& features) { |
| 347 if (selector.match() == CSSSelector::Tag && | 347 if (selector.match() == CSSSelector::Tag && |
| 348 selector.tagQName().localName() != starAtom) { | 348 selector.tagQName().localName() != starAtom) { |
| 349 features.tagNames.push_back(selector.tagQName().localName()); | 349 features.tagNames.push_back(selector.tagQName().localName()); |
| 350 features.setRuleSetInvalidationFeature( |
| 351 selector.tagQName().localName(), |
| 352 InvalidationSetFeatures::RuleSetFeatureType::Tag); |
| 350 return; | 353 return; |
| 351 } | 354 } |
| 352 if (selector.match() == CSSSelector::Id) { | 355 if (selector.match() == CSSSelector::Id) { |
| 353 features.ids.push_back(selector.value()); | 356 features.ids.push_back(selector.value()); |
| 357 features.setRuleSetInvalidationFeature( |
| 358 selector.value(), InvalidationSetFeatures::RuleSetFeatureType::Id); |
| 354 return; | 359 return; |
| 355 } | 360 } |
| 356 if (selector.match() == CSSSelector::Class) { | 361 if (selector.match() == CSSSelector::Class) { |
| 357 features.classes.push_back(selector.value()); | 362 features.classes.push_back(selector.value()); |
| 363 features.setRuleSetInvalidationFeature( |
| 364 selector.value(), InvalidationSetFeatures::RuleSetFeatureType::Class); |
| 358 return; | 365 return; |
| 359 } | 366 } |
| 360 if (selector.isAttributeSelector()) { | 367 if (selector.isAttributeSelector()) { |
| 361 features.attributes.push_back(selector.attribute().localName()); | 368 features.attributes.push_back(selector.attribute().localName()); |
| 369 features.setRuleSetInvalidationFeature( |
| 370 selector.attribute().localName(), |
| 371 InvalidationSetFeatures::RuleSetFeatureType::Attribute); |
| 362 return; | 372 return; |
| 363 } | 373 } |
| 364 switch (selector.getPseudoType()) { | 374 switch (selector.getPseudoType()) { |
| 365 case CSSSelector::PseudoWebKitCustomElement: | 375 case CSSSelector::PseudoWebKitCustomElement: |
| 366 case CSSSelector::PseudoBlinkInternalElement: | 376 case CSSSelector::PseudoBlinkInternalElement: |
| 367 features.customPseudoElement = true; | 377 features.customPseudoElement = true; |
| 368 return; | 378 return; |
| 369 case CSSSelector::PseudoBefore: | 379 case CSSSelector::PseudoBefore: |
| 370 case CSSSelector::PseudoAfter: | 380 case CSSSelector::PseudoAfter: |
| 371 features.hasBeforeOrAfter = true; | 381 features.hasBeforeOrAfter = true; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 // addFeaturesToInvalidationSets for that one as well. | 459 // addFeaturesToInvalidationSets for that one as well. |
| 450 | 460 |
| 451 InvalidationSetFeatures features; | 461 InvalidationSetFeatures features; |
| 452 InvalidationSetFeatures* siblingFeatures = nullptr; | 462 InvalidationSetFeatures* siblingFeatures = nullptr; |
| 453 | 463 |
| 454 const CSSSelector* lastInCompound = | 464 const CSSSelector* lastInCompound = |
| 455 extractInvalidationSetFeaturesFromCompound(ruleData.selector(), features, | 465 extractInvalidationSetFeaturesFromCompound(ruleData.selector(), features, |
| 456 Subject); | 466 Subject); |
| 457 | 467 |
| 458 if (features.forceSubtree) | 468 if (features.forceSubtree) |
| 459 features.hasFeaturesForRuleSetInvalidation = false; | 469 features.clearRuleSetInvalidationFeature(); |
| 460 else if (!features.hasFeatures()) | 470 else if (!features.hasFeatures()) |
| 461 features.forceSubtree = true; | 471 features.forceSubtree = true; |
| 462 if (features.hasNthPseudo) | 472 if (features.hasNthPseudo) |
| 463 addFeaturesToInvalidationSet(ensureNthInvalidationSet(), features); | 473 addFeaturesToInvalidationSet(ensureNthInvalidationSet(), features); |
| 464 if (features.hasBeforeOrAfter) | 474 if (features.hasBeforeOrAfter) |
| 465 updateInvalidationSetsForContentAttribute(ruleData); | 475 updateInvalidationSetsForContentAttribute(ruleData); |
| 466 | 476 |
| 467 const CSSSelector* nextCompound = | 477 const CSSSelector* nextCompound = |
| 468 lastInCompound ? lastInCompound->tagHistory() : &ruleData.selector(); | 478 lastInCompound ? lastInCompound->tagHistory() : &ruleData.selector(); |
| 469 if (!nextCompound) { | 479 if (!nextCompound) { |
| 470 if (!features.hasFeaturesForRuleSetInvalidation) | 480 processRuleSetInvalidationFeature(features); |
| 471 m_metadata.needsFullRecalcForRuleSetInvalidation = true; | |
| 472 return; | 481 return; |
| 473 } | 482 } |
| 474 if (lastInCompound) | 483 if (lastInCompound) |
| 475 updateFeaturesFromCombinator(*lastInCompound, nullptr, features, | 484 updateFeaturesFromCombinator(*lastInCompound, nullptr, features, |
| 476 siblingFeatures, features); | 485 siblingFeatures, features); |
| 477 | 486 |
| 478 addFeaturesToInvalidationSets(*nextCompound, siblingFeatures, features); | 487 addFeaturesToInvalidationSets(*nextCompound, siblingFeatures, features); |
| 488 processRuleSetInvalidationFeature(features); |
| 489 } |
| 479 | 490 |
| 480 if (!features.hasFeaturesForRuleSetInvalidation) | 491 void RuleFeatureSet::processRuleSetInvalidationFeature( |
| 481 m_metadata.needsFullRecalcForRuleSetInvalidation = true; | 492 const InvalidationSetFeatures& features) { |
| 493 InvalidationSetMap* map = nullptr; |
| 494 switch (features.ruleSetInvalidationFeatureType) { |
| 495 case InvalidationSetFeatures::RuleSetFeatureType::None: |
| 496 m_metadata.needsFullRecalcForRuleSetInvalidation = true; |
| 497 return; |
| 498 case InvalidationSetFeatures::RuleSetFeatureType::Tag: { |
| 499 DescendantInvalidationSet& typeSet = ensureTypeRuleInvalidationSet(); |
| 500 typeSet.addTagName(features.ruleSetInvalidationFeature); |
| 501 return; |
| 502 } |
| 503 case InvalidationSetFeatures::RuleSetFeatureType::Attribute: |
| 504 map = &m_attributeInvalidationSets; |
| 505 break; |
| 506 case InvalidationSetFeatures::RuleSetFeatureType::Class: |
| 507 map = &m_classInvalidationSets; |
| 508 break; |
| 509 case InvalidationSetFeatures::RuleSetFeatureType::Id: |
| 510 map = &m_idInvalidationSets; |
| 511 break; |
| 512 } |
| 513 |
| 514 DCHECK(map); |
| 515 InvalidationSetMap::const_iterator it = |
| 516 map->find(features.ruleSetInvalidationFeature); |
| 517 if (it == map->end()) |
| 518 return; |
| 519 |
| 520 DescendantInvalidationSet* descendants; |
| 521 SiblingInvalidationSet* siblings; |
| 522 extractInvalidationSets(it->value.get(), descendants, siblings); |
| 523 if (descendants) |
| 524 descendants->setAppliesToRuleSetInvalidations(); |
| 525 if (siblings) |
| 526 siblings->setAppliesToRuleSetInvalidations(); |
| 482 } | 527 } |
| 483 | 528 |
| 484 void RuleFeatureSet::updateInvalidationSetsForContentAttribute( | 529 void RuleFeatureSet::updateInvalidationSetsForContentAttribute( |
| 485 const RuleData& ruleData) { | 530 const RuleData& ruleData) { |
| 486 // If any ::before and ::after rules specify 'content: attr(...)', we | 531 // If any ::before and ::after rules specify 'content: attr(...)', we |
| 487 // need to create invalidation sets for those attributes to have content | 532 // need to create invalidation sets for those attributes to have content |
| 488 // changes applied through style recalc. | 533 // changes applied through style recalc. |
| 489 | 534 |
| 490 const StylePropertySet& propertySet = ruleData.rule()->properties(); | 535 const StylePropertySet& propertySet = ruleData.rule()->properties(); |
| 491 | 536 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 } | 588 } |
| 544 if (compoundFeatures.hasNthPseudo) | 589 if (compoundFeatures.hasNthPseudo) |
| 545 features.hasNthPseudo = true; | 590 features.hasNthPseudo = true; |
| 546 if (!allSubSelectorsHaveFeatures) | 591 if (!allSubSelectorsHaveFeatures) |
| 547 continue; | 592 continue; |
| 548 if (compoundFeatures.hasFeatures()) | 593 if (compoundFeatures.hasFeatures()) |
| 549 anyFeatures.add(compoundFeatures); | 594 anyFeatures.add(compoundFeatures); |
| 550 else | 595 else |
| 551 allSubSelectorsHaveFeatures = false; | 596 allSubSelectorsHaveFeatures = false; |
| 552 } | 597 } |
| 553 // Don't add any features if one of the sub-selectors of does not contain | 598 if (!selectorList->hasOneSelector()) |
| 599 anyFeatures.clearRuleSetInvalidationFeature(); |
| 600 // Don't add any features if one of the sub-selectors does not contain |
| 554 // any invalidation set features. E.g. :-webkit-any(*, span). | 601 // any invalidation set features. E.g. :-webkit-any(*, span). |
| 555 if (allSubSelectorsHaveFeatures) | 602 if (allSubSelectorsHaveFeatures) |
| 556 features.add(anyFeatures); | 603 features.add(anyFeatures); |
| 557 return NormalInvalidation; | 604 return NormalInvalidation; |
| 558 } | 605 } |
| 559 | 606 |
| 560 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeaturesFromCompound( | 607 const CSSSelector* RuleFeatureSet::extractInvalidationSetFeaturesFromCompound( |
| 561 const CSSSelector& compound, | 608 const CSSSelector& compound, |
| 562 InvalidationSetFeatures& features, | 609 InvalidationSetFeatures& features, |
| 563 PositionType position, | 610 PositionType position, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 | 647 |
| 601 if (extractInvalidationSetFeaturesFromSelectorList(*simpleSelector, | 648 if (extractInvalidationSetFeaturesFromSelectorList(*simpleSelector, |
| 602 features, position) == | 649 features, position) == |
| 603 RequiresSubtreeInvalidation) { | 650 RequiresSubtreeInvalidation) { |
| 604 DCHECK(features.forceSubtree); | 651 DCHECK(features.forceSubtree); |
| 605 return nullptr; | 652 return nullptr; |
| 606 } | 653 } |
| 607 | 654 |
| 608 if (!simpleSelector->tagHistory() || | 655 if (!simpleSelector->tagHistory() || |
| 609 simpleSelector->relation() != CSSSelector::SubSelector) { | 656 simpleSelector->relation() != CSSSelector::SubSelector) { |
| 610 features.hasFeaturesForRuleSetInvalidation = | |
| 611 features.hasTagIdClassOrAttribute(); | |
| 612 return simpleSelector; | 657 return simpleSelector; |
| 613 } | 658 } |
| 614 } | 659 } |
| 615 } | 660 } |
| 616 | 661 |
| 617 // Add features extracted from the rightmost compound selector to descendant | 662 // Add features extracted from the rightmost compound selector to descendant |
| 618 // invalidation sets for features found in other compound selectors. | 663 // invalidation sets for features found in other compound selectors. |
| 619 // | 664 // |
| 620 // We use descendant invalidation for descendants, sibling invalidation for | 665 // We use descendant invalidation for descendants, sibling invalidation for |
| 621 // siblings and their subtrees. | 666 // siblings and their subtrees. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 698 |
| 654 void RuleFeatureSet::addFeaturesToInvalidationSetsForSelectorList( | 699 void RuleFeatureSet::addFeaturesToInvalidationSetsForSelectorList( |
| 655 const CSSSelector& simpleSelector, | 700 const CSSSelector& simpleSelector, |
| 656 InvalidationSetFeatures* siblingFeatures, | 701 InvalidationSetFeatures* siblingFeatures, |
| 657 InvalidationSetFeatures& descendantFeatures) { | 702 InvalidationSetFeatures& descendantFeatures) { |
| 658 if (!simpleSelector.selectorList()) | 703 if (!simpleSelector.selectorList()) |
| 659 return; | 704 return; |
| 660 | 705 |
| 661 DCHECK(supportsInvalidationWithSelectorList(simpleSelector.getPseudoType())); | 706 DCHECK(supportsInvalidationWithSelectorList(simpleSelector.getPseudoType())); |
| 662 | 707 |
| 663 bool hadFeaturesForRuleSetInvalidation = | 708 AtomicString prevRuleSetFeature = |
| 664 descendantFeatures.hasFeaturesForRuleSetInvalidation; | 709 descendantFeatures.ruleSetInvalidationFeature; |
| 665 bool selectorListContainsUniversal = | 710 InvalidationSetFeatures::RuleSetFeatureType prevRuleSetFeatureType = |
| 666 simpleSelector.getPseudoType() == CSSSelector::PseudoNot || | 711 descendantFeatures.ruleSetInvalidationFeatureType; |
| 667 simpleSelector.getPseudoType() == CSSSelector::PseudoHostContext; | |
| 668 | 712 |
| 669 for (const CSSSelector* subSelector = simpleSelector.selectorList()->first(); | 713 for (const CSSSelector* subSelector = simpleSelector.selectorList()->first(); |
| 670 subSelector; subSelector = CSSSelectorList::next(*subSelector)) { | 714 subSelector; subSelector = CSSSelectorList::next(*subSelector)) { |
| 671 descendantFeatures.hasFeaturesForRuleSetInvalidation = false; | |
| 672 | |
| 673 addFeaturesToInvalidationSetsForCompoundSelector( | 715 addFeaturesToInvalidationSetsForCompoundSelector( |
| 674 *subSelector, siblingFeatures, descendantFeatures); | 716 *subSelector, siblingFeatures, descendantFeatures); |
| 675 | |
| 676 if (!descendantFeatures.hasFeaturesForRuleSetInvalidation) | |
| 677 selectorListContainsUniversal = true; | |
| 678 } | 717 } |
| 679 | 718 |
| 680 descendantFeatures.hasFeaturesForRuleSetInvalidation = | 719 if (simpleSelector.getPseudoType() == CSSSelector::PseudoNot || |
| 681 hadFeaturesForRuleSetInvalidation || !selectorListContainsUniversal; | 720 simpleSelector.getPseudoType() == CSSSelector::PseudoHostContext || |
| 721 !simpleSelector.selectorList()->hasOneSelector()) { |
| 722 descendantFeatures.clearRuleSetInvalidationFeature(); |
| 723 descendantFeatures.setRuleSetInvalidationFeature(prevRuleSetFeature, |
| 724 prevRuleSetFeatureType); |
| 725 } |
| 682 } | 726 } |
| 683 | 727 |
| 684 void RuleFeatureSet::addFeaturesToInvalidationSetsForSimpleSelector( | 728 void RuleFeatureSet::addFeaturesToInvalidationSetsForSimpleSelector( |
| 685 const CSSSelector& simpleSelector, | 729 const CSSSelector& simpleSelector, |
| 686 InvalidationSetFeatures* siblingFeatures, | 730 InvalidationSetFeatures* siblingFeatures, |
| 687 InvalidationSetFeatures& descendantFeatures) { | 731 InvalidationSetFeatures& descendantFeatures) { |
| 688 if (InvalidationSet* invalidationSet = invalidationSetForSimpleSelector( | 732 if (InvalidationSet* invalidationSet = invalidationSetForSimpleSelector( |
| 689 simpleSelector, | 733 simpleSelector, |
| 690 siblingFeatures ? InvalidateSiblings : InvalidateDescendants)) { | 734 siblingFeatures ? InvalidateSiblings : InvalidateDescendants)) { |
| 691 if (!siblingFeatures || invalidationSet == m_nthInvalidationSet) { | 735 if (!siblingFeatures || invalidationSet == m_nthInvalidationSet) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 719 const CSSSelector* | 763 const CSSSelector* |
| 720 RuleFeatureSet::addFeaturesToInvalidationSetsForCompoundSelector( | 764 RuleFeatureSet::addFeaturesToInvalidationSetsForCompoundSelector( |
| 721 const CSSSelector& compound, | 765 const CSSSelector& compound, |
| 722 InvalidationSetFeatures* siblingFeatures, | 766 InvalidationSetFeatures* siblingFeatures, |
| 723 InvalidationSetFeatures& descendantFeatures) { | 767 InvalidationSetFeatures& descendantFeatures) { |
| 724 bool compoundHasIdClassOrAttribute = false; | 768 bool compoundHasIdClassOrAttribute = false; |
| 725 const CSSSelector* simpleSelector = &compound; | 769 const CSSSelector* simpleSelector = &compound; |
| 726 for (; simpleSelector; simpleSelector = simpleSelector->tagHistory()) { | 770 for (; simpleSelector; simpleSelector = simpleSelector->tagHistory()) { |
| 727 addFeaturesToInvalidationSetsForSimpleSelector( | 771 addFeaturesToInvalidationSetsForSimpleSelector( |
| 728 *simpleSelector, siblingFeatures, descendantFeatures); | 772 *simpleSelector, siblingFeatures, descendantFeatures); |
| 729 if (simpleSelector->isIdClassOrAttributeSelector()) | 773 if (simpleSelector->isIdClassOrAttributeSelector()) { |
| 774 descendantFeatures.setRuleSetFeatureFromSimpleSelector(*simpleSelector); |
| 730 compoundHasIdClassOrAttribute = true; | 775 compoundHasIdClassOrAttribute = true; |
| 776 } |
| 731 if (simpleSelector->relation() != CSSSelector::SubSelector) | 777 if (simpleSelector->relation() != CSSSelector::SubSelector) |
| 732 break; | 778 break; |
| 733 if (!simpleSelector->tagHistory()) | 779 if (!simpleSelector->tagHistory()) |
| 734 break; | 780 break; |
| 735 } | 781 } |
| 736 | 782 |
| 737 if (compoundHasIdClassOrAttribute) | 783 if (!compoundHasIdClassOrAttribute && siblingFeatures) |
| 738 descendantFeatures.hasFeaturesForRuleSetInvalidation = true; | |
| 739 else if (siblingFeatures) | |
| 740 addFeaturesToUniversalSiblingInvalidationSet(*siblingFeatures, | 784 addFeaturesToUniversalSiblingInvalidationSet(*siblingFeatures, |
| 741 descendantFeatures); | 785 descendantFeatures); |
| 742 | 786 |
| 743 return simpleSelector; | 787 return simpleSelector; |
| 744 } | 788 } |
| 745 | 789 |
| 746 void RuleFeatureSet::addFeaturesToInvalidationSets( | 790 void RuleFeatureSet::addFeaturesToInvalidationSets( |
| 747 const CSSSelector& selector, | 791 const CSSSelector& selector, |
| 748 InvalidationSetFeatures* siblingFeatures, | 792 InvalidationSetFeatures* siblingFeatures, |
| 749 InvalidationSetFeatures& descendantFeatures) { | 793 InvalidationSetFeatures& descendantFeatures) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 m_pseudoInvalidationSets.clear(); | 970 m_pseudoInvalidationSets.clear(); |
| 927 m_universalSiblingInvalidationSet.clear(); | 971 m_universalSiblingInvalidationSet.clear(); |
| 928 m_nthInvalidationSet.clear(); | 972 m_nthInvalidationSet.clear(); |
| 929 m_viewportDependentMediaQueryResults.clear(); | 973 m_viewportDependentMediaQueryResults.clear(); |
| 930 m_deviceDependentMediaQueryResults.clear(); | 974 m_deviceDependentMediaQueryResults.clear(); |
| 931 } | 975 } |
| 932 | 976 |
| 933 void RuleFeatureSet::collectInvalidationSetsForClass( | 977 void RuleFeatureSet::collectInvalidationSetsForClass( |
| 934 InvalidationLists& invalidationLists, | 978 InvalidationLists& invalidationLists, |
| 935 Element& element, | 979 Element& element, |
| 936 const AtomicString& className) const { | 980 const AtomicString& className, |
| 981 InvalidationSetFilter filter) const { |
| 937 InvalidationSetMap::const_iterator it = | 982 InvalidationSetMap::const_iterator it = |
| 938 m_classInvalidationSets.find(className); | 983 m_classInvalidationSets.find(className); |
| 939 if (it == m_classInvalidationSets.end()) | 984 if (it == m_classInvalidationSets.end()) |
| 940 return; | 985 return; |
| 941 | 986 |
| 942 DescendantInvalidationSet* descendants; | 987 DescendantInvalidationSet* descendants; |
| 943 SiblingInvalidationSet* siblings; | 988 SiblingInvalidationSet* siblings; |
| 944 extractInvalidationSets(it->value.get(), descendants, siblings); | 989 extractInvalidationSets(it->value.get(), descendants, siblings); |
| 945 | 990 |
| 946 if (descendants) { | 991 if (descendants && (filter == InvalidationSetFilter::None || |
| 992 descendants->appliesToRuleSetInvalidations())) { |
| 947 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *descendants, classChange, | 993 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *descendants, classChange, |
| 948 className); | 994 className); |
| 949 invalidationLists.descendants.push_back(descendants); | 995 invalidationLists.descendants.push_back(descendants); |
| 950 } | 996 } |
| 951 | 997 |
| 952 if (siblings) { | 998 if (siblings && (filter == InvalidationSetFilter::None || |
| 999 siblings->appliesToRuleSetInvalidations())) { |
| 953 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *siblings, classChange, | 1000 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *siblings, classChange, |
| 954 className); | 1001 className); |
| 955 invalidationLists.siblings.push_back(siblings); | 1002 invalidationLists.siblings.push_back(siblings); |
| 956 } | 1003 } |
| 957 } | 1004 } |
| 958 | 1005 |
| 959 void RuleFeatureSet::collectSiblingInvalidationSetForClass( | 1006 void RuleFeatureSet::collectSiblingInvalidationSetForClass( |
| 960 InvalidationLists& invalidationLists, | 1007 InvalidationLists& invalidationLists, |
| 961 Element& element, | 1008 Element& element, |
| 962 const AtomicString& className, | 1009 const AtomicString& className, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 976 return; | 1023 return; |
| 977 | 1024 |
| 978 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *siblingSet, classChange, | 1025 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *siblingSet, classChange, |
| 979 className); | 1026 className); |
| 980 invalidationLists.siblings.push_back(siblingSet); | 1027 invalidationLists.siblings.push_back(siblingSet); |
| 981 } | 1028 } |
| 982 | 1029 |
| 983 void RuleFeatureSet::collectInvalidationSetsForId( | 1030 void RuleFeatureSet::collectInvalidationSetsForId( |
| 984 InvalidationLists& invalidationLists, | 1031 InvalidationLists& invalidationLists, |
| 985 Element& element, | 1032 Element& element, |
| 986 const AtomicString& id) const { | 1033 const AtomicString& id, |
| 1034 InvalidationSetFilter filter) const { |
| 987 InvalidationSetMap::const_iterator it = m_idInvalidationSets.find(id); | 1035 InvalidationSetMap::const_iterator it = m_idInvalidationSets.find(id); |
| 988 if (it == m_idInvalidationSets.end()) | 1036 if (it == m_idInvalidationSets.end()) |
| 989 return; | 1037 return; |
| 990 | 1038 |
| 991 DescendantInvalidationSet* descendants; | 1039 DescendantInvalidationSet* descendants; |
| 992 SiblingInvalidationSet* siblings; | 1040 SiblingInvalidationSet* siblings; |
| 993 extractInvalidationSets(it->value.get(), descendants, siblings); | 1041 extractInvalidationSets(it->value.get(), descendants, siblings); |
| 994 | 1042 |
| 995 if (descendants) { | 1043 if (descendants && (filter == InvalidationSetFilter::None || |
| 1044 descendants->appliesToRuleSetInvalidations())) { |
| 996 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *descendants, idChange, id); | 1045 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *descendants, idChange, id); |
| 997 invalidationLists.descendants.push_back(descendants); | 1046 invalidationLists.descendants.push_back(descendants); |
| 998 } | 1047 } |
| 999 | 1048 |
| 1000 if (siblings) { | 1049 if (siblings && (filter == InvalidationSetFilter::None || |
| 1050 siblings->appliesToRuleSetInvalidations())) { |
| 1001 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *siblings, idChange, id); | 1051 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *siblings, idChange, id); |
| 1002 invalidationLists.siblings.push_back(siblings); | 1052 invalidationLists.siblings.push_back(siblings); |
| 1003 } | 1053 } |
| 1004 } | 1054 } |
| 1005 | 1055 |
| 1006 void RuleFeatureSet::collectSiblingInvalidationSetForId( | 1056 void RuleFeatureSet::collectSiblingInvalidationSetForId( |
| 1007 InvalidationLists& invalidationLists, | 1057 InvalidationLists& invalidationLists, |
| 1008 Element& element, | 1058 Element& element, |
| 1009 const AtomicString& id, | 1059 const AtomicString& id, |
| 1010 unsigned minDirectAdjacent) const { | 1060 unsigned minDirectAdjacent) const { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1021 if (siblingSet->maxDirectAdjacentSelectors() < minDirectAdjacent) | 1071 if (siblingSet->maxDirectAdjacentSelectors() < minDirectAdjacent) |
| 1022 return; | 1072 return; |
| 1023 | 1073 |
| 1024 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *siblingSet, idChange, id); | 1074 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *siblingSet, idChange, id); |
| 1025 invalidationLists.siblings.push_back(siblingSet); | 1075 invalidationLists.siblings.push_back(siblingSet); |
| 1026 } | 1076 } |
| 1027 | 1077 |
| 1028 void RuleFeatureSet::collectInvalidationSetsForAttribute( | 1078 void RuleFeatureSet::collectInvalidationSetsForAttribute( |
| 1029 InvalidationLists& invalidationLists, | 1079 InvalidationLists& invalidationLists, |
| 1030 Element& element, | 1080 Element& element, |
| 1031 const QualifiedName& attributeName) const { | 1081 const QualifiedName& attributeName, |
| 1082 InvalidationSetFilter filter) const { |
| 1032 InvalidationSetMap::const_iterator it = | 1083 InvalidationSetMap::const_iterator it = |
| 1033 m_attributeInvalidationSets.find(attributeName.localName()); | 1084 m_attributeInvalidationSets.find(attributeName.localName()); |
| 1034 if (it == m_attributeInvalidationSets.end()) | 1085 if (it == m_attributeInvalidationSets.end()) |
| 1035 return; | 1086 return; |
| 1036 | 1087 |
| 1037 DescendantInvalidationSet* descendants; | 1088 DescendantInvalidationSet* descendants; |
| 1038 SiblingInvalidationSet* siblings; | 1089 SiblingInvalidationSet* siblings; |
| 1039 extractInvalidationSets(it->value.get(), descendants, siblings); | 1090 extractInvalidationSets(it->value.get(), descendants, siblings); |
| 1040 | 1091 |
| 1041 if (descendants) { | 1092 if (descendants && (filter == InvalidationSetFilter::None || |
| 1093 descendants->appliesToRuleSetInvalidations())) { |
| 1042 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *descendants, attributeChange, | 1094 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *descendants, attributeChange, |
| 1043 attributeName); | 1095 attributeName); |
| 1044 invalidationLists.descendants.push_back(descendants); | 1096 invalidationLists.descendants.push_back(descendants); |
| 1045 } | 1097 } |
| 1046 | 1098 |
| 1047 if (siblings) { | 1099 if (siblings && (filter == InvalidationSetFilter::None || |
| 1100 siblings->appliesToRuleSetInvalidations())) { |
| 1048 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *siblings, attributeChange, | 1101 TRACE_SCHEDULE_STYLE_INVALIDATION(element, *siblings, attributeChange, |
| 1049 attributeName); | 1102 attributeName); |
| 1050 invalidationLists.siblings.push_back(siblings); | 1103 invalidationLists.siblings.push_back(siblings); |
| 1051 } | 1104 } |
| 1052 } | 1105 } |
| 1053 | 1106 |
| 1054 void RuleFeatureSet::collectSiblingInvalidationSetForAttribute( | 1107 void RuleFeatureSet::collectSiblingInvalidationSetForAttribute( |
| 1055 InvalidationLists& invalidationLists, | 1108 InvalidationLists& invalidationLists, |
| 1056 Element& element, | 1109 Element& element, |
| 1057 const QualifiedName& attributeName, | 1110 const QualifiedName& attributeName, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 if (m_nthInvalidationSet) | 1174 if (m_nthInvalidationSet) |
| 1122 invalidationLists.descendants.push_back(m_nthInvalidationSet); | 1175 invalidationLists.descendants.push_back(m_nthInvalidationSet); |
| 1123 } | 1176 } |
| 1124 | 1177 |
| 1125 DescendantInvalidationSet& RuleFeatureSet::ensureNthInvalidationSet() { | 1178 DescendantInvalidationSet& RuleFeatureSet::ensureNthInvalidationSet() { |
| 1126 if (!m_nthInvalidationSet) | 1179 if (!m_nthInvalidationSet) |
| 1127 m_nthInvalidationSet = DescendantInvalidationSet::create(); | 1180 m_nthInvalidationSet = DescendantInvalidationSet::create(); |
| 1128 return *m_nthInvalidationSet; | 1181 return *m_nthInvalidationSet; |
| 1129 } | 1182 } |
| 1130 | 1183 |
| 1184 void RuleFeatureSet::collectTypeRuleInvalidationSet( |
| 1185 InvalidationLists& invalidationLists, |
| 1186 ContainerNode& rootNode) const { |
| 1187 if (m_typeRuleInvalidationSet) { |
| 1188 invalidationLists.descendants.push_back(m_typeRuleInvalidationSet); |
| 1189 TRACE_SCHEDULE_STYLE_INVALIDATION(rootNode, *m_typeRuleInvalidationSet, |
| 1190 typeInvalidation); |
| 1191 } |
| 1192 } |
| 1193 |
| 1194 DescendantInvalidationSet& RuleFeatureSet::ensureTypeRuleInvalidationSet() { |
| 1195 if (!m_typeRuleInvalidationSet) { |
| 1196 m_typeRuleInvalidationSet = DescendantInvalidationSet::create(); |
| 1197 m_typeRuleInvalidationSet->setAppliesToRuleSetInvalidations(); |
| 1198 } |
| 1199 return *m_typeRuleInvalidationSet; |
| 1200 } |
| 1201 |
| 1131 void RuleFeatureSet::addFeaturesToUniversalSiblingInvalidationSet( | 1202 void RuleFeatureSet::addFeaturesToUniversalSiblingInvalidationSet( |
| 1132 const InvalidationSetFeatures& siblingFeatures, | 1203 const InvalidationSetFeatures& siblingFeatures, |
| 1133 const InvalidationSetFeatures& descendantFeatures) { | 1204 const InvalidationSetFeatures& descendantFeatures) { |
| 1134 SiblingInvalidationSet& universalSet = | 1205 SiblingInvalidationSet& universalSet = |
| 1135 ensureUniversalSiblingInvalidationSet(); | 1206 ensureUniversalSiblingInvalidationSet(); |
| 1136 addFeaturesToInvalidationSet(universalSet, siblingFeatures); | 1207 addFeaturesToInvalidationSet(universalSet, siblingFeatures); |
| 1137 universalSet.updateMaxDirectAdjacentSelectors( | 1208 universalSet.updateMaxDirectAdjacentSelectors( |
| 1138 siblingFeatures.maxDirectAdjacentSelectors); | 1209 siblingFeatures.maxDirectAdjacentSelectors); |
| 1139 | 1210 |
| 1140 if (&siblingFeatures == &descendantFeatures) | 1211 if (&siblingFeatures == &descendantFeatures) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1160 maxDirectAdjacentSelectors = | 1231 maxDirectAdjacentSelectors = |
| 1161 std::max(maxDirectAdjacentSelectors, other.maxDirectAdjacentSelectors); | 1232 std::max(maxDirectAdjacentSelectors, other.maxDirectAdjacentSelectors); |
| 1162 customPseudoElement |= other.customPseudoElement; | 1233 customPseudoElement |= other.customPseudoElement; |
| 1163 hasBeforeOrAfter |= other.hasBeforeOrAfter; | 1234 hasBeforeOrAfter |= other.hasBeforeOrAfter; |
| 1164 treeBoundaryCrossing |= other.treeBoundaryCrossing; | 1235 treeBoundaryCrossing |= other.treeBoundaryCrossing; |
| 1165 insertionPointCrossing |= other.insertionPointCrossing; | 1236 insertionPointCrossing |= other.insertionPointCrossing; |
| 1166 forceSubtree |= other.forceSubtree; | 1237 forceSubtree |= other.forceSubtree; |
| 1167 contentPseudoCrossing |= other.contentPseudoCrossing; | 1238 contentPseudoCrossing |= other.contentPseudoCrossing; |
| 1168 invalidatesSlotted |= other.invalidatesSlotted; | 1239 invalidatesSlotted |= other.invalidatesSlotted; |
| 1169 hasNthPseudo |= other.hasNthPseudo; | 1240 hasNthPseudo |= other.hasNthPseudo; |
| 1241 setRuleSetInvalidationFeature(other.ruleSetInvalidationFeature, |
| 1242 other.ruleSetInvalidationFeatureType); |
| 1170 } | 1243 } |
| 1171 | 1244 |
| 1172 bool RuleFeatureSet::InvalidationSetFeatures::hasFeatures() const { | 1245 bool RuleFeatureSet::InvalidationSetFeatures::hasFeatures() const { |
| 1173 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty() || | 1246 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty() || |
| 1174 !tagNames.isEmpty() || customPseudoElement; | 1247 !tagNames.isEmpty() || customPseudoElement; |
| 1175 } | 1248 } |
| 1176 | 1249 |
| 1177 bool RuleFeatureSet::InvalidationSetFeatures::hasTagIdClassOrAttribute() const { | 1250 void RuleFeatureSet::InvalidationSetFeatures:: |
| 1178 return !classes.isEmpty() || !attributes.isEmpty() || !ids.isEmpty() || | 1251 setRuleSetFeatureFromSimpleSelector(const CSSSelector& selector) { |
| 1179 !tagNames.isEmpty(); | 1252 if (selector.match() == CSSSelector::Id) { |
| 1253 setRuleSetInvalidationFeature(selector.value(), RuleSetFeatureType::Id); |
| 1254 return; |
| 1255 } |
| 1256 if (selector.match() == CSSSelector::Class) { |
| 1257 setRuleSetInvalidationFeature(selector.value(), RuleSetFeatureType::Class); |
| 1258 return; |
| 1259 } |
| 1260 DCHECK(selector.isAttributeSelector()); |
| 1261 setRuleSetInvalidationFeature(selector.attribute().localName(), |
| 1262 RuleSetFeatureType::Attribute); |
| 1180 } | 1263 } |
| 1181 | 1264 |
| 1182 } // namespace blink | 1265 } // namespace blink |
| OLD | NEW |