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 19 matching lines...) Expand all Loading... |
30 #include "core/HTMLNames.h" | 30 #include "core/HTMLNames.h" |
31 #include "core/css/CSSDefaultStyleSheets.h" | 31 #include "core/css/CSSDefaultStyleSheets.h" |
32 #include "core/css/CSSFontSelector.h" | 32 #include "core/css/CSSFontSelector.h" |
33 #include "core/css/CSSStyleSheet.h" | 33 #include "core/css/CSSStyleSheet.h" |
34 #include "core/css/FontFaceCache.h" | 34 #include "core/css/FontFaceCache.h" |
35 #include "core/css/StyleSheetContents.h" | 35 #include "core/css/StyleSheetContents.h" |
36 #include "core/css/invalidation/InvalidationSet.h" | 36 #include "core/css/invalidation/InvalidationSet.h" |
37 #include "core/css/resolver/ScopedStyleResolver.h" | 37 #include "core/css/resolver/ScopedStyleResolver.h" |
38 #include "core/dom/DocumentStyleSheetCollector.h" | 38 #include "core/dom/DocumentStyleSheetCollector.h" |
39 #include "core/dom/Element.h" | 39 #include "core/dom/Element.h" |
| 40 #include "core/dom/ElementTraversal.h" |
40 #include "core/dom/ProcessingInstruction.h" | 41 #include "core/dom/ProcessingInstruction.h" |
41 #include "core/dom/ShadowTreeStyleSheetCollection.h" | 42 #include "core/dom/ShadowTreeStyleSheetCollection.h" |
42 #include "core/dom/StyleChangeReason.h" | 43 #include "core/dom/StyleChangeReason.h" |
43 #include "core/dom/shadow/ShadowRoot.h" | 44 #include "core/dom/shadow/ShadowRoot.h" |
44 #include "core/frame/Settings.h" | 45 #include "core/frame/Settings.h" |
45 #include "core/html/HTMLIFrameElement.h" | 46 #include "core/html/HTMLIFrameElement.h" |
46 #include "core/html/HTMLLinkElement.h" | 47 #include "core/html/HTMLLinkElement.h" |
47 #include "core/html/imports/HTMLImportsController.h" | 48 #include "core/html/imports/HTMLImportsController.h" |
48 #include "core/inspector/InspectorInstrumentation.h" | 49 #include "core/inspector/InspectorInstrumentation.h" |
49 #include "core/page/Page.h" | 50 #include "core/page/Page.h" |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 void StyleEngine::pseudoStateChangedForElement(CSSSelector::PseudoType pseudoTyp
e, Element& element) | 684 void StyleEngine::pseudoStateChangedForElement(CSSSelector::PseudoType pseudoTyp
e, Element& element) |
684 { | 685 { |
685 if (shouldSkipInvalidationFor(element)) | 686 if (shouldSkipInvalidationFor(element)) |
686 return; | 687 return; |
687 | 688 |
688 InvalidationLists invalidationLists; | 689 InvalidationLists invalidationLists; |
689 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForPse
udoClass(invalidationLists, element, pseudoType); | 690 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForPse
udoClass(invalidationLists, element, pseudoType); |
690 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); | 691 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); |
691 } | 692 } |
692 | 693 |
| 694 void StyleEngine::scheduleSiblingInvalidationsForElement(Element& element, Conta
inerNode& schedulingParent) |
| 695 { |
| 696 InvalidationLists invalidationLists; |
| 697 |
| 698 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); |
| 699 |
| 700 if (element.hasID()) |
| 701 ruleFeatureSet.collectSiblingInvalidationSetForId(invalidationLists, ele
ment, element.idForStyleResolution()); |
| 702 |
| 703 if (element.hasClass()) { |
| 704 const SpaceSplitString& classNames = element.classNames(); |
| 705 for (size_t i = 0; i < classNames.size(); i++) |
| 706 ruleFeatureSet.collectSiblingInvalidationSetForClass(invalidationLis
ts, element, classNames[i]); |
| 707 } |
| 708 |
| 709 for (const Attribute& attribute : element.attributes()) |
| 710 ruleFeatureSet.collectSiblingInvalidationSetForAttribute(invalidationLis
ts, element, attribute.name()); |
| 711 |
| 712 ruleFeatureSet.collectUniversalSiblingInvalidationSet(invalidationLists); |
| 713 |
| 714 m_styleInvalidator.scheduleSiblingInvalidationsAsDescendants(invalidationLis
ts, schedulingParent); |
| 715 } |
| 716 |
| 717 void StyleEngine::scheduleInvalidationsForInsertedSibling(Element* beforeElement
, Element& insertedElement) |
| 718 { |
| 719 unsigned affectedSiblings = insertedElement.parentNode()->childrenAffectedBy
IndirectAdjacentRules() ? UINT_MAX : m_maxDirectAdjacentSelectors; |
| 720 |
| 721 ContainerNode* schedulingParent = insertedElement.parentElementOrShadowRoot(
); |
| 722 if (!schedulingParent) |
| 723 return; |
| 724 |
| 725 scheduleSiblingInvalidationsForElement(insertedElement, *schedulingParent); |
| 726 |
| 727 for (unsigned i = 0; beforeElement && i < affectedSiblings; i++, beforeEleme
nt = ElementTraversal::previousSibling(*beforeElement)) |
| 728 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent
); |
| 729 } |
| 730 |
| 731 void StyleEngine::scheduleInvalidationsForRemovedSibling(Element* beforeElement,
Element& removedElement, Element& afterElement) |
| 732 { |
| 733 unsigned affectedSiblings = afterElement.parentNode()->childrenAffectedByInd
irectAdjacentRules() ? UINT_MAX : m_maxDirectAdjacentSelectors; |
| 734 |
| 735 ContainerNode* schedulingParent = afterElement.parentElementOrShadowRoot(); |
| 736 if (!schedulingParent) |
| 737 return; |
| 738 |
| 739 scheduleSiblingInvalidationsForElement(removedElement, *schedulingParent); |
| 740 |
| 741 for (unsigned i = 1; beforeElement && i < affectedSiblings; i++, beforeEleme
nt = ElementTraversal::previousSibling(*beforeElement)) |
| 742 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent
); |
| 743 } |
| 744 |
693 void StyleEngine::setStatsEnabled(bool enabled) | 745 void StyleEngine::setStatsEnabled(bool enabled) |
694 { | 746 { |
695 if (!enabled) { | 747 if (!enabled) { |
696 m_styleResolverStats = nullptr; | 748 m_styleResolverStats = nullptr; |
697 return; | 749 return; |
698 } | 750 } |
699 if (!m_styleResolverStats) | 751 if (!m_styleResolverStats) |
700 m_styleResolverStats = StyleResolverStats::create(); | 752 m_styleResolverStats = StyleResolverStats::create(); |
701 else | 753 else |
702 m_styleResolverStats->reset(); | 754 m_styleResolverStats->reset(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 | 813 |
762 DEFINE_TRACE_WRAPPERS(StyleEngine) | 814 DEFINE_TRACE_WRAPPERS(StyleEngine) |
763 { | 815 { |
764 for (auto sheet : m_injectedAuthorStyleSheets) { | 816 for (auto sheet : m_injectedAuthorStyleSheets) { |
765 visitor->traceWrappers(sheet); | 817 visitor->traceWrappers(sheet); |
766 } | 818 } |
767 visitor->traceWrappers(m_documentStyleSheetCollection); | 819 visitor->traceWrappers(m_documentStyleSheetCollection); |
768 } | 820 } |
769 | 821 |
770 } // namespace blink | 822 } // namespace blink |
OLD | NEW |