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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent
, i); | 743 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent
, i); |
743 } | 744 } |
744 | 745 |
745 void StyleEngine::scheduleNthPseudoInvalidations(ContainerNode& nthParent) | 746 void StyleEngine::scheduleNthPseudoInvalidations(ContainerNode& nthParent) |
746 { | 747 { |
747 InvalidationLists invalidationLists; | 748 InvalidationLists invalidationLists; |
748 ensureResolver().ensureUpdatedRuleFeatureSet().collectNthInvalidationSet(inv
alidationLists); | 749 ensureResolver().ensureUpdatedRuleFeatureSet().collectNthInvalidationSet(inv
alidationLists); |
749 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, nthPar
ent); | 750 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, nthPar
ent); |
750 } | 751 } |
751 | 752 |
| 753 void StyleEngine::scheduleRuleSetInvalidationsForElement(Element& element, const
HeapVector<Member<const RuleSet>>& ruleSets) |
| 754 { |
| 755 AtomicString id; |
| 756 const SpaceSplitString* classNames = nullptr; |
| 757 |
| 758 if (element.hasID()) |
| 759 id = element.idForStyleResolution(); |
| 760 if (element.hasClass()) |
| 761 classNames = &element.classNames(); |
| 762 |
| 763 InvalidationLists invalidationLists; |
| 764 for (const auto& ruleSet : ruleSets) { |
| 765 if (!id.isNull()) |
| 766 ruleSet->features().collectInvalidationSetsForId(invalidationLists,
element, id); |
| 767 if (classNames) { |
| 768 unsigned classNameCount = classNames->size(); |
| 769 for (size_t i = 0; i < classNameCount; i++) |
| 770 ruleSet->features().collectInvalidationSetsForClass(invalidation
Lists, element, (*classNames)[i]); |
| 771 } |
| 772 for (const Attribute& attribute : element.attributes()) |
| 773 ruleSet->features().collectInvalidationSetsForAttribute(invalidation
Lists, element, attribute.name()); |
| 774 if (ruleSet->tagRules(element.localNameForSelectorMatching())) |
| 775 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr
acing::create(StyleChangeReason::StyleSheetChange)); |
| 776 } |
| 777 m_styleInvalidator.scheduleInvalidationSetsForNode(invalidationLists, elemen
t); |
| 778 } |
| 779 |
| 780 void StyleEngine::invalidateSlottedElements(HTMLSlotElement& slot) |
| 781 { |
| 782 for (auto& node : slot.getDistributedNodes()) { |
| 783 if (node->isElementNode()) |
| 784 node->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTrac
ing::create(StyleChangeReason::StyleSheetChange)); |
| 785 } |
| 786 } |
| 787 |
| 788 void StyleEngine::scheduleInvalidationsForRuleSets(TreeScope& treeScope, const H
eapVector<Member<const RuleSet>>& ruleSets) |
| 789 { |
| 790 #if DCHECK_IS_ON() |
| 791 // Full scope recalcs should be handled while collecting the ruleSets before |
| 792 // calling this method. |
| 793 for (auto ruleSet : ruleSets) |
| 794 DCHECK(!ruleSet->features().needsFullRecalcForRuleSetInvalidation()); |
| 795 #endif // DCHECK_IS_ON() |
| 796 |
| 797 bool invalidateSlotted = false; |
| 798 if (treeScope.rootNode().isShadowRoot()) { |
| 799 Element& host = toShadowRoot(treeScope.rootNode()).host(); |
| 800 scheduleRuleSetInvalidationsForElement(host, ruleSets); |
| 801 if (host.getStyleChangeType() >= SubtreeStyleChange) |
| 802 return; |
| 803 for (auto ruleSet : ruleSets) { |
| 804 if (ruleSet->hasSlottedRules()) { |
| 805 invalidateSlotted = true; |
| 806 break; |
| 807 } |
| 808 } |
| 809 } |
| 810 |
| 811 Node* stayWithin = &treeScope.rootNode(); |
| 812 Element* element = ElementTraversal::firstChild(*stayWithin); |
| 813 while (element) { |
| 814 scheduleRuleSetInvalidationsForElement(*element, ruleSets); |
| 815 if (invalidateSlotted && isHTMLSlotElement(element)) |
| 816 invalidateSlottedElements(toHTMLSlotElement(*element)); |
| 817 |
| 818 if (element->getStyleChangeType() < SubtreeStyleChange) |
| 819 element = ElementTraversal::next(*element, stayWithin); |
| 820 else |
| 821 element = ElementTraversal::nextSkippingChildren(*element, stayWithi
n); |
| 822 } |
| 823 } |
| 824 |
752 void StyleEngine::setStatsEnabled(bool enabled) | 825 void StyleEngine::setStatsEnabled(bool enabled) |
753 { | 826 { |
754 if (!enabled) { | 827 if (!enabled) { |
755 m_styleResolverStats = nullptr; | 828 m_styleResolverStats = nullptr; |
756 return; | 829 return; |
757 } | 830 } |
758 if (!m_styleResolverStats) | 831 if (!m_styleResolverStats) |
759 m_styleResolverStats = StyleResolverStats::create(); | 832 m_styleResolverStats = StyleResolverStats::create(); |
760 else | 833 else |
761 m_styleResolverStats->reset(); | 834 m_styleResolverStats->reset(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 | 909 |
837 DEFINE_TRACE_WRAPPERS(StyleEngine) | 910 DEFINE_TRACE_WRAPPERS(StyleEngine) |
838 { | 911 { |
839 for (auto sheet : m_injectedAuthorStyleSheets) { | 912 for (auto sheet : m_injectedAuthorStyleSheets) { |
840 visitor->traceWrappers(sheet); | 913 visitor->traceWrappers(sheet); |
841 } | 914 } |
842 visitor->traceWrappers(m_documentStyleSheetCollection); | 915 visitor->traceWrappers(m_documentStyleSheetCollection); |
843 } | 916 } |
844 | 917 |
845 } // namespace blink | 918 } // namespace blink |
OLD | NEW |