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, Eleme
nt& schedulingElement, unsigned minDirectAdjacent, bool invalidateSchedulingElem
ent) |
| 695 { |
| 696 InvalidationLists invalidationLists; |
| 697 |
| 698 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); |
| 699 |
| 700 if (element.hasID()) |
| 701 ruleFeatureSet.collectSiblingInvalidationSetForId(invalidationLists, ele
ment, element.idForStyleResolution(), minDirectAdjacent); |
| 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], minDirectAdjacent); |
| 707 } |
| 708 |
| 709 for (const Attribute& attribute : element.attributes()) |
| 710 ruleFeatureSet.collectSiblingInvalidationSetForAttribute(invalidationLis
ts, element, attribute.name(), minDirectAdjacent); |
| 711 |
| 712 ruleFeatureSet.collectUniversalSiblingInvalidationSet(invalidationLists, min
DirectAdjacent); |
| 713 |
| 714 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, sch
edulingElement); |
| 715 if (invalidateSchedulingElement) |
| 716 m_styleInvalidator.scheduleDescendantsFromSiblingSets(schedulingElement,
invalidationLists.siblings); |
| 717 } |
| 718 |
| 719 void StyleEngine::scheduleInvalidationsForInsertedSibling(Element* beforeElement
, Element& insertedElement) |
| 720 { |
| 721 unsigned affectedSiblings = insertedElement.parentNode()->childrenAffectedBy
IndirectAdjacentRules() ? UINT_MAX : m_maxDirectAdjacentSelectors; |
| 722 |
| 723 scheduleSiblingInvalidationsForElement(insertedElement, insertedElement, 1,
false); |
| 724 |
| 725 Element* schedulingElement = &insertedElement; |
| 726 for (unsigned i = 1; beforeElement && i <= affectedSiblings; i++, beforeElem
ent = ElementTraversal::previousSibling(*(schedulingElement = beforeElement))) |
| 727 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingElemen
t, i, false); |
| 728 } |
| 729 |
| 730 void StyleEngine::scheduleInvalidationsForRemovedSibling(Element* beforeElement,
Element& removedElement, Element& afterElement) |
| 731 { |
| 732 unsigned affectedSiblings = afterElement.parentNode()->childrenAffectedByInd
irectAdjacentRules() ? UINT_MAX : m_maxDirectAdjacentSelectors; |
| 733 |
| 734 Element* schedulingElement = beforeElement; |
| 735 if (!schedulingElement) |
| 736 schedulingElement = &afterElement; |
| 737 |
| 738 scheduleSiblingInvalidationsForElement(removedElement, *schedulingElement, 1
, schedulingElement == &afterElement); |
| 739 |
| 740 for (unsigned i = 2; beforeElement && i <= affectedSiblings; i++, beforeElem
ent = ElementTraversal::previousSibling(*beforeElement)) |
| 741 scheduleSiblingInvalidationsForElement(*beforeElement, *beforeElement, i
, false); |
| 742 } |
| 743 |
693 void StyleEngine::setStatsEnabled(bool enabled) | 744 void StyleEngine::setStatsEnabled(bool enabled) |
694 { | 745 { |
695 if (!enabled) { | 746 if (!enabled) { |
696 m_styleResolverStats = nullptr; | 747 m_styleResolverStats = nullptr; |
697 return; | 748 return; |
698 } | 749 } |
699 if (!m_styleResolverStats) | 750 if (!m_styleResolverStats) |
700 m_styleResolverStats = StyleResolverStats::create(); | 751 m_styleResolverStats = StyleResolverStats::create(); |
701 else | 752 else |
702 m_styleResolverStats->reset(); | 753 m_styleResolverStats->reset(); |
703 } | 754 } |
704 | 755 |
| 756 void StyleEngine::willRemoveChild(Node& child) |
| 757 { |
| 758 if (!child.needsStyleInvalidation()) |
| 759 return; |
| 760 if (!child.isElementNode()) |
| 761 return; |
| 762 if (!child.inShadowIncludingDocument()) |
| 763 return; |
| 764 |
| 765 Element* elementTo = ElementTraversal::previousSibling(child); |
| 766 bool invalidateElementTo = !elementTo; |
| 767 if (!elementTo) |
| 768 elementTo = ElementTraversal::nextSibling(child); |
| 769 if (!elementTo) |
| 770 return; |
| 771 styleInvalidator().rescheduleSiblingInvalidationSetsForRemovedElement(toElem
ent(child), *elementTo, invalidateElementTo); |
| 772 } |
| 773 |
705 void StyleEngine::setPreferredStylesheetSetNameIfNotSet(const String& name) | 774 void StyleEngine::setPreferredStylesheetSetNameIfNotSet(const String& name) |
706 { | 775 { |
707 if (!m_preferredStylesheetSetName.isEmpty()) | 776 if (!m_preferredStylesheetSetName.isEmpty()) |
708 return; | 777 return; |
709 m_preferredStylesheetSetName = name; | 778 m_preferredStylesheetSetName = name; |
710 // TODO(rune@opera.com): Setting the selected set here is wrong if the set | 779 // TODO(rune@opera.com): Setting the selected set here is wrong if the set |
711 // has been previously set by through Document.selectedStylesheetSet. Our | 780 // has been previously set by through Document.selectedStylesheetSet. Our |
712 // current implementation ignores the effect of Document.selectedStylesheetS
et | 781 // current implementation ignores the effect of Document.selectedStylesheetS
et |
713 // and either only collects persistent style, or additionally preferred | 782 // and either only collects persistent style, or additionally preferred |
714 // style when present. We are currently not marking the document scope dirty | 783 // style when present. We are currently not marking the document scope dirty |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 | 830 |
762 DEFINE_TRACE_WRAPPERS(StyleEngine) | 831 DEFINE_TRACE_WRAPPERS(StyleEngine) |
763 { | 832 { |
764 for (auto sheet : m_injectedAuthorStyleSheets) { | 833 for (auto sheet : m_injectedAuthorStyleSheets) { |
765 visitor->traceWrappers(sheet); | 834 visitor->traceWrappers(sheet); |
766 } | 835 } |
767 visitor->traceWrappers(m_documentStyleSheetCollection); | 836 visitor->traceWrappers(m_documentStyleSheetCollection); |
768 } | 837 } |
769 | 838 |
770 } // namespace blink | 839 } // namespace blink |
OLD | NEW |