| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
| 7 * rights reserved. | 7 * rights reserved. |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 DCHECK_GT(m_pendingScriptBlockingStylesheets, 0); | 182 DCHECK_GT(m_pendingScriptBlockingStylesheets, 0); |
| 183 | 183 |
| 184 m_pendingScriptBlockingStylesheets--; | 184 m_pendingScriptBlockingStylesheets--; |
| 185 if (m_pendingScriptBlockingStylesheets) | 185 if (m_pendingScriptBlockingStylesheets) |
| 186 return; | 186 return; |
| 187 | 187 |
| 188 document().didRemoveAllPendingStylesheet(); | 188 document().didRemoveAllPendingStylesheet(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void StyleEngine::setNeedsActiveStyleUpdate(TreeScope& treeScope) { | 191 void StyleEngine::setNeedsActiveStyleUpdate(TreeScope& treeScope) { |
| 192 if (!document().isActive() && isMaster()) | 192 if (document().isActive() || !isMaster()) |
| 193 return; | 193 markTreeScopeDirty(treeScope); |
| 194 | |
| 195 markTreeScopeDirty(treeScope); | |
| 196 } | 194 } |
| 197 | 195 |
| 198 void StyleEngine::addStyleSheetCandidateNode(Node& node) { | 196 void StyleEngine::addStyleSheetCandidateNode(Node& node) { |
| 199 if (!node.isConnected() || document().isDetached()) | 197 if (!node.isConnected() || document().isDetached()) |
| 200 return; | 198 return; |
| 201 | 199 |
| 202 DCHECK(!isXSLStyleSheet(node)); | 200 DCHECK(!isXSLStyleSheet(node)); |
| 203 TreeScope& treeScope = node.treeScope(); | 201 TreeScope& treeScope = node.treeScope(); |
| 204 TreeScopeStyleSheetCollection* collection = | 202 TreeScopeStyleSheetCollection* collection = |
| 205 ensureStyleSheetCollectionFor(treeScope); | 203 ensureStyleSheetCollectionFor(treeScope); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 return true; | 621 return true; |
| 624 return element.parentNode()->getStyleChangeType() >= SubtreeStyleChange; | 622 return element.parentNode()->getStyleChangeType() >= SubtreeStyleChange; |
| 625 } | 623 } |
| 626 | 624 |
| 627 void StyleEngine::classChangedForElement(const SpaceSplitString& changedClasses, | 625 void StyleEngine::classChangedForElement(const SpaceSplitString& changedClasses, |
| 628 Element& element) { | 626 Element& element) { |
| 629 if (shouldSkipInvalidationFor(element)) | 627 if (shouldSkipInvalidationFor(element)) |
| 630 return; | 628 return; |
| 631 InvalidationLists invalidationLists; | 629 InvalidationLists invalidationLists; |
| 632 unsigned changedSize = changedClasses.size(); | 630 unsigned changedSize = changedClasses.size(); |
| 633 // TODO(rune@opera.com): ensureResolver() can be removed once stylesheet | |
| 634 // updates are async. https://crbug.com/567021 | |
| 635 ensureResolver(); | |
| 636 const RuleFeatureSet& features = ruleFeatureSet(); | 631 const RuleFeatureSet& features = ruleFeatureSet(); |
| 637 for (unsigned i = 0; i < changedSize; ++i) { | 632 for (unsigned i = 0; i < changedSize; ++i) { |
| 638 features.collectInvalidationSetsForClass(invalidationLists, element, | 633 features.collectInvalidationSetsForClass(invalidationLists, element, |
| 639 changedClasses[i]); | 634 changedClasses[i]); |
| 640 } | 635 } |
| 641 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, | 636 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, |
| 642 element); | 637 element); |
| 643 } | 638 } |
| 644 | 639 |
| 645 void StyleEngine::classChangedForElement(const SpaceSplitString& oldClasses, | 640 void StyleEngine::classChangedForElement(const SpaceSplitString& oldClasses, |
| 646 const SpaceSplitString& newClasses, | 641 const SpaceSplitString& newClasses, |
| 647 Element& element) { | 642 Element& element) { |
| 648 if (shouldSkipInvalidationFor(element)) | 643 if (shouldSkipInvalidationFor(element)) |
| 649 return; | 644 return; |
| 650 | 645 |
| 651 if (!oldClasses.size()) { | 646 if (!oldClasses.size()) { |
| 652 classChangedForElement(newClasses, element); | 647 classChangedForElement(newClasses, element); |
| 653 return; | 648 return; |
| 654 } | 649 } |
| 655 | 650 |
| 656 // Class vectors tend to be very short. This is faster than using a hash | 651 // Class vectors tend to be very short. This is faster than using a hash |
| 657 // table. | 652 // table. |
| 658 BitVector remainingClassBits; | 653 BitVector remainingClassBits; |
| 659 remainingClassBits.ensureSize(oldClasses.size()); | 654 remainingClassBits.ensureSize(oldClasses.size()); |
| 660 | 655 |
| 661 InvalidationLists invalidationLists; | 656 InvalidationLists invalidationLists; |
| 662 // TODO(rune@opera.com): ensureResolver() can be removed once stylesheet | |
| 663 // updates are async. https://crbug.com/567021 | |
| 664 ensureResolver(); | |
| 665 const RuleFeatureSet& features = ruleFeatureSet(); | 657 const RuleFeatureSet& features = ruleFeatureSet(); |
| 666 | 658 |
| 667 for (unsigned i = 0; i < newClasses.size(); ++i) { | 659 for (unsigned i = 0; i < newClasses.size(); ++i) { |
| 668 bool found = false; | 660 bool found = false; |
| 669 for (unsigned j = 0; j < oldClasses.size(); ++j) { | 661 for (unsigned j = 0; j < oldClasses.size(); ++j) { |
| 670 if (newClasses[i] == oldClasses[j]) { | 662 if (newClasses[i] == oldClasses[j]) { |
| 671 // Mark each class that is still in the newClasses so we can skip doing | 663 // Mark each class that is still in the newClasses so we can skip doing |
| 672 // an n^2 search below when looking for removals. We can't break from | 664 // an n^2 search below when looking for removals. We can't break from |
| 673 // this loop early since a class can appear more than once. | 665 // this loop early since a class can appear more than once. |
| 674 remainingClassBits.quickSet(j); | 666 remainingClassBits.quickSet(j); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 693 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, | 685 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, |
| 694 element); | 686 element); |
| 695 } | 687 } |
| 696 | 688 |
| 697 void StyleEngine::attributeChangedForElement(const QualifiedName& attributeName, | 689 void StyleEngine::attributeChangedForElement(const QualifiedName& attributeName, |
| 698 Element& element) { | 690 Element& element) { |
| 699 if (shouldSkipInvalidationFor(element)) | 691 if (shouldSkipInvalidationFor(element)) |
| 700 return; | 692 return; |
| 701 | 693 |
| 702 InvalidationLists invalidationLists; | 694 InvalidationLists invalidationLists; |
| 703 // TODO(rune@opera.com): ensureResolver() can be removed once stylesheet | |
| 704 // updates are async. https://crbug.com/567021 | |
| 705 ensureResolver(); | |
| 706 ruleFeatureSet().collectInvalidationSetsForAttribute(invalidationLists, | 695 ruleFeatureSet().collectInvalidationSetsForAttribute(invalidationLists, |
| 707 element, attributeName); | 696 element, attributeName); |
| 708 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, | 697 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, |
| 709 element); | 698 element); |
| 710 } | 699 } |
| 711 | 700 |
| 712 void StyleEngine::idChangedForElement(const AtomicString& oldId, | 701 void StyleEngine::idChangedForElement(const AtomicString& oldId, |
| 713 const AtomicString& newId, | 702 const AtomicString& newId, |
| 714 Element& element) { | 703 Element& element) { |
| 715 if (shouldSkipInvalidationFor(element)) | 704 if (shouldSkipInvalidationFor(element)) |
| 716 return; | 705 return; |
| 717 | 706 |
| 718 InvalidationLists invalidationLists; | 707 InvalidationLists invalidationLists; |
| 719 // TODO(rune@opera.com): ensureResolver() can be removed once stylesheet | |
| 720 // updates are async. https://crbug.com/567021 | |
| 721 ensureResolver(); | |
| 722 const RuleFeatureSet& features = ruleFeatureSet(); | 708 const RuleFeatureSet& features = ruleFeatureSet(); |
| 723 if (!oldId.isEmpty()) | 709 if (!oldId.isEmpty()) |
| 724 features.collectInvalidationSetsForId(invalidationLists, element, oldId); | 710 features.collectInvalidationSetsForId(invalidationLists, element, oldId); |
| 725 if (!newId.isEmpty()) | 711 if (!newId.isEmpty()) |
| 726 features.collectInvalidationSetsForId(invalidationLists, element, newId); | 712 features.collectInvalidationSetsForId(invalidationLists, element, newId); |
| 727 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, | 713 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, |
| 728 element); | 714 element); |
| 729 } | 715 } |
| 730 | 716 |
| 731 void StyleEngine::pseudoStateChangedForElement( | 717 void StyleEngine::pseudoStateChangedForElement( |
| 732 CSSSelector::PseudoType pseudoType, | 718 CSSSelector::PseudoType pseudoType, |
| 733 Element& element) { | 719 Element& element) { |
| 734 if (shouldSkipInvalidationFor(element)) | 720 if (shouldSkipInvalidationFor(element)) |
| 735 return; | 721 return; |
| 736 | 722 |
| 737 InvalidationLists invalidationLists; | 723 InvalidationLists invalidationLists; |
| 738 // TODO(rune@opera.com): ensureResolver() can be removed once stylesheet | |
| 739 // updates are async. https://crbug.com/567021 | |
| 740 ensureResolver(); | |
| 741 ruleFeatureSet().collectInvalidationSetsForPseudoClass(invalidationLists, | 724 ruleFeatureSet().collectInvalidationSetsForPseudoClass(invalidationLists, |
| 742 element, pseudoType); | 725 element, pseudoType); |
| 743 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, | 726 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, |
| 744 element); | 727 element); |
| 745 } | 728 } |
| 746 | 729 |
| 747 void StyleEngine::scheduleSiblingInvalidationsForElement( | 730 void StyleEngine::scheduleSiblingInvalidationsForElement( |
| 748 Element& element, | 731 Element& element, |
| 749 ContainerNode& schedulingParent, | 732 ContainerNode& schedulingParent, |
| 750 unsigned minDirectAdjacent) { | 733 unsigned minDirectAdjacent) { |
| 751 DCHECK(minDirectAdjacent); | 734 DCHECK(minDirectAdjacent); |
| 752 | 735 |
| 753 InvalidationLists invalidationLists; | 736 InvalidationLists invalidationLists; |
| 754 | 737 |
| 755 // TODO(rune@opera.com): ensureResolver() can be removed once stylesheet | |
| 756 // updates are async. https://crbug.com/567021 | |
| 757 ensureResolver(); | |
| 758 const RuleFeatureSet& features = ruleFeatureSet(); | 738 const RuleFeatureSet& features = ruleFeatureSet(); |
| 759 | 739 |
| 760 if (element.hasID()) { | 740 if (element.hasID()) { |
| 761 features.collectSiblingInvalidationSetForId(invalidationLists, element, | 741 features.collectSiblingInvalidationSetForId(invalidationLists, element, |
| 762 element.idForStyleResolution(), | 742 element.idForStyleResolution(), |
| 763 minDirectAdjacent); | 743 minDirectAdjacent); |
| 764 } | 744 } |
| 765 | 745 |
| 766 if (element.hasClass()) { | 746 if (element.hasClass()) { |
| 767 const SpaceSplitString& classNames = element.classNames(); | 747 const SpaceSplitString& classNames = element.classNames(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 scheduleSiblingInvalidationsForElement(removedElement, *schedulingParent, 1); | 797 scheduleSiblingInvalidationsForElement(removedElement, *schedulingParent, 1); |
| 818 | 798 |
| 819 for (unsigned i = 1; beforeElement && i <= affectedSiblings; | 799 for (unsigned i = 1; beforeElement && i <= affectedSiblings; |
| 820 i++, beforeElement = ElementTraversal::previousSibling(*beforeElement)) | 800 i++, beforeElement = ElementTraversal::previousSibling(*beforeElement)) |
| 821 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent, | 801 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent, |
| 822 i); | 802 i); |
| 823 } | 803 } |
| 824 | 804 |
| 825 void StyleEngine::scheduleNthPseudoInvalidations(ContainerNode& nthParent) { | 805 void StyleEngine::scheduleNthPseudoInvalidations(ContainerNode& nthParent) { |
| 826 InvalidationLists invalidationLists; | 806 InvalidationLists invalidationLists; |
| 827 // TODO(rune@opera.com): ensureResolver() can be removed once stylesheet | |
| 828 // updates are async. https://crbug.com/567021 | |
| 829 ensureResolver(); | |
| 830 ruleFeatureSet().collectNthInvalidationSet(invalidationLists); | 807 ruleFeatureSet().collectNthInvalidationSet(invalidationLists); |
| 831 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, | 808 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, |
| 832 nthParent); | 809 nthParent); |
| 833 } | 810 } |
| 834 | 811 |
| 835 void StyleEngine::scheduleRuleSetInvalidationsForElement( | 812 void StyleEngine::scheduleRuleSetInvalidationsForElement( |
| 836 Element& element, | 813 Element& element, |
| 837 const HeapHashSet<Member<RuleSet>>& ruleSets) { | 814 const HeapHashSet<Member<RuleSet>>& ruleSets) { |
| 838 AtomicString id; | 815 AtomicString id; |
| 839 const SpaceSplitString* classNames = nullptr; | 816 const SpaceSplitString* classNames = nullptr; |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 } | 1154 } |
| 1178 | 1155 |
| 1179 DEFINE_TRACE_WRAPPERS(StyleEngine) { | 1156 DEFINE_TRACE_WRAPPERS(StyleEngine) { |
| 1180 for (auto sheet : m_injectedAuthorStyleSheets) { | 1157 for (auto sheet : m_injectedAuthorStyleSheets) { |
| 1181 visitor->traceWrappers(sheet); | 1158 visitor->traceWrappers(sheet); |
| 1182 } | 1159 } |
| 1183 visitor->traceWrappers(m_documentStyleSheetCollection); | 1160 visitor->traceWrappers(m_documentStyleSheetCollection); |
| 1184 } | 1161 } |
| 1185 | 1162 |
| 1186 } // namespace blink | 1163 } // namespace blink |
| OLD | NEW |