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 r ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
(...skipping 28 matching lines...) Expand all Loading... | |
39 #include "core/dom/DocumentStyleSheetCollector.h" | 39 #include "core/dom/DocumentStyleSheetCollector.h" |
40 #include "core/dom/Element.h" | 40 #include "core/dom/Element.h" |
41 #include "core/dom/ElementTraversal.h" | 41 #include "core/dom/ElementTraversal.h" |
42 #include "core/dom/ProcessingInstruction.h" | 42 #include "core/dom/ProcessingInstruction.h" |
43 #include "core/dom/ShadowTreeStyleSheetCollection.h" | 43 #include "core/dom/ShadowTreeStyleSheetCollection.h" |
44 #include "core/dom/StyleChangeReason.h" | 44 #include "core/dom/StyleChangeReason.h" |
45 #include "core/dom/shadow/ShadowRoot.h" | 45 #include "core/dom/shadow/ShadowRoot.h" |
46 #include "core/frame/Settings.h" | 46 #include "core/frame/Settings.h" |
47 #include "core/html/HTMLIFrameElement.h" | 47 #include "core/html/HTMLIFrameElement.h" |
48 #include "core/html/HTMLLinkElement.h" | 48 #include "core/html/HTMLLinkElement.h" |
49 #include "core/html/HTMLSlotElement.h" | |
49 #include "core/html/imports/HTMLImportsController.h" | 50 #include "core/html/imports/HTMLImportsController.h" |
50 #include "core/inspector/InspectorInstrumentation.h" | 51 #include "core/inspector/InspectorInstrumentation.h" |
51 #include "core/page/Page.h" | 52 #include "core/page/Page.h" |
52 #include "core/svg/SVGStyleElement.h" | 53 #include "core/svg/SVGStyleElement.h" |
53 #include "platform/TraceEvent.h" | 54 #include "platform/TraceEvent.h" |
54 #include "platform/fonts/FontCache.h" | 55 #include "platform/fonts/FontCache.h" |
55 | 56 |
56 namespace blink { | 57 namespace blink { |
57 | 58 |
58 using namespace HTMLNames; | 59 using namespace HTMLNames; |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
752 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent , i); | 753 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent , i); |
753 } | 754 } |
754 | 755 |
755 void StyleEngine::scheduleNthPseudoInvalidations(ContainerNode& nthParent) | 756 void StyleEngine::scheduleNthPseudoInvalidations(ContainerNode& nthParent) |
756 { | 757 { |
757 InvalidationLists invalidationLists; | 758 InvalidationLists invalidationLists; |
758 ensureResolver().ensureUpdatedRuleFeatureSet().collectNthInvalidationSet(inv alidationLists); | 759 ensureResolver().ensureUpdatedRuleFeatureSet().collectNthInvalidationSet(inv alidationLists); |
759 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, nthPar ent); | 760 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, nthPar ent); |
760 } | 761 } |
761 | 762 |
763 void StyleEngine::scheduleRuleSetInvalidationsForElement(Element& element, const HeapVector<Member<const RuleSet>>& ruleSets) | |
764 { | |
765 AtomicString id; | |
766 const SpaceSplitString* classNames = nullptr; | |
767 bool typeSelectorMatch = false; | |
768 | |
769 if (element.hasID()) | |
770 id = element.idForStyleResolution(); | |
771 if (element.hasClass()) | |
772 classNames = &element.classNames(); | |
773 | |
774 InvalidationLists invalidationLists; | |
775 for (const auto& ruleSet : ruleSets) { | |
776 if (!id.isNull()) | |
777 ruleSet->features().collectInvalidationSetsForId(invalidationLists, element, id); | |
778 if (classNames) { | |
779 unsigned classNameCount = classNames->size(); | |
780 for (size_t i = 0; i < classNameCount; i++) | |
781 ruleSet->features().collectInvalidationSetsForClass(invalidation Lists, element, (*classNames)[i]); | |
782 } | |
783 for (const Attribute& attribute : element.attributes()) | |
784 ruleSet->features().collectInvalidationSetsForAttribute(invalidation Lists, element, attribute.name()); | |
785 | |
786 if (element.needsStyleRecalc()) | |
787 continue; | |
788 | |
789 if (!typeSelectorMatch && ruleSet->tagRules(element.localNameForSelector Matching())) { | |
790 typeSelectorMatch = true; | |
791 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr acing::create(StyleChangeReason::StyleSheetChange)); | |
Eric Willigers
2016/09/13 01:22:03
element.needsStyleRecalc() becomes true, so typeSe
rune
2016/09/13 13:13:53
The needsStyleRecalc() is actually wrong, since it
| |
792 } | |
793 } | |
794 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, elemen t); | |
795 } | |
796 | |
797 void StyleEngine::scheduleInvalidationsForRuleSets(TreeScope& treeScope, const H eapVector<Member<const RuleSet>>& ruleSets) | |
798 { | |
799 #if DCHECK_IS_ON() | |
800 // Full scope recalcs should be handled while collecting the ruleSets before | |
801 // calling this method. | |
802 for (auto ruleSet : ruleSets) | |
803 DCHECK(!ruleSet->features().needsFullRecalcForRuleSetInvalidation()); | |
804 #endif // DCHECK_IS_ON() | |
805 | |
806 if (treeScope.rootNode().isShadowRoot()) { | |
807 Element& host = toShadowRoot(treeScope.rootNode()).host(); | |
808 scheduleRuleSetInvalidationsForElement(host, ruleSets); | |
809 if (host.getStyleChangeType() >= SubtreeStyleChange) | |
810 return; | |
811 } | |
812 | |
813 Node* stayWithin = &treeScope.rootNode(); | |
814 Element* element = ElementTraversal::firstChild(*stayWithin); | |
815 while (element) { | |
816 scheduleRuleSetInvalidationsForElement(*element, ruleSets); | |
817 if (isHTMLSlotElement(element)) { | |
818 for (auto& node : toHTMLSlotElement(element)->getDistributedNodes()) { | |
819 if (node->isElementNode()) | |
820 scheduleRuleSetInvalidationsForElement(*toElement(node), rul eSets); | |
821 } | |
822 } | |
823 if (element->getStyleChangeType() < SubtreeStyleChange) | |
824 element = ElementTraversal::next(*element, stayWithin); | |
825 else | |
826 element = ElementTraversal::nextSkippingChildren(*element, stayWithi n); | |
827 } | |
828 } | |
829 | |
762 void StyleEngine::setStatsEnabled(bool enabled) | 830 void StyleEngine::setStatsEnabled(bool enabled) |
763 { | 831 { |
764 if (!enabled) { | 832 if (!enabled) { |
765 m_styleResolverStats = nullptr; | 833 m_styleResolverStats = nullptr; |
766 return; | 834 return; |
767 } | 835 } |
768 if (!m_styleResolverStats) | 836 if (!m_styleResolverStats) |
769 m_styleResolverStats = StyleResolverStats::create(); | 837 m_styleResolverStats = StyleResolverStats::create(); |
770 else | 838 else |
771 m_styleResolverStats->reset(); | 839 m_styleResolverStats->reset(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
842 | 910 |
843 DEFINE_TRACE_WRAPPERS(StyleEngine) | 911 DEFINE_TRACE_WRAPPERS(StyleEngine) |
844 { | 912 { |
845 for (auto sheet : m_injectedAuthorStyleSheets) { | 913 for (auto sheet : m_injectedAuthorStyleSheets) { |
846 visitor->traceWrappers(sheet); | 914 visitor->traceWrappers(sheet); |
847 } | 915 } |
848 visitor->traceWrappers(m_documentStyleSheetCollection); | 916 visitor->traceWrappers(m_documentStyleSheetCollection); |
849 } | 917 } |
850 | 918 |
851 } // namespace blink | 919 } // namespace blink |
OLD | NEW |