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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 void StyleEngine::pseudoStateChangedForElement(CSSSelector::PseudoType pseudoTyp
e, Element& element) | 687 void StyleEngine::pseudoStateChangedForElement(CSSSelector::PseudoType pseudoTyp
e, Element& element) |
688 { | 688 { |
689 if (shouldSkipInvalidationFor(element)) | 689 if (shouldSkipInvalidationFor(element)) |
690 return; | 690 return; |
691 | 691 |
692 InvalidationLists invalidationLists; | 692 InvalidationLists invalidationLists; |
693 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForPse
udoClass(invalidationLists, element, pseudoType); | 693 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForPse
udoClass(invalidationLists, element, pseudoType); |
694 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); | 694 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); |
695 } | 695 } |
696 | 696 |
697 void StyleEngine::scheduleSiblingInvalidationsForElement(Element& element, Conta
inerNode& schedulingParent) | 697 void StyleEngine::scheduleSiblingInvalidationsForElement(Element& element, Conta
inerNode& schedulingParent, unsigned minDirectAdjacent) |
698 { | 698 { |
| 699 DCHECK(minDirectAdjacent); |
| 700 |
699 InvalidationLists invalidationLists; | 701 InvalidationLists invalidationLists; |
700 | 702 |
701 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); | 703 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); |
702 | 704 |
703 if (element.hasID()) | 705 if (element.hasID()) |
704 ruleFeatureSet.collectSiblingInvalidationSetForId(invalidationLists, ele
ment, element.idForStyleResolution()); | 706 ruleFeatureSet.collectSiblingInvalidationSetForId(invalidationLists, ele
ment, element.idForStyleResolution(), minDirectAdjacent); |
705 | 707 |
706 if (element.hasClass()) { | 708 if (element.hasClass()) { |
707 const SpaceSplitString& classNames = element.classNames(); | 709 const SpaceSplitString& classNames = element.classNames(); |
708 for (size_t i = 0; i < classNames.size(); i++) | 710 for (size_t i = 0; i < classNames.size(); i++) |
709 ruleFeatureSet.collectSiblingInvalidationSetForClass(invalidationLis
ts, element, classNames[i]); | 711 ruleFeatureSet.collectSiblingInvalidationSetForClass(invalidationLis
ts, element, classNames[i], minDirectAdjacent); |
710 } | 712 } |
711 | 713 |
712 for (const Attribute& attribute : element.attributes()) | 714 for (const Attribute& attribute : element.attributes()) |
713 ruleFeatureSet.collectSiblingInvalidationSetForAttribute(invalidationLis
ts, element, attribute.name()); | 715 ruleFeatureSet.collectSiblingInvalidationSetForAttribute(invalidationLis
ts, element, attribute.name(), minDirectAdjacent); |
714 | 716 |
715 ruleFeatureSet.collectUniversalSiblingInvalidationSet(invalidationLists); | 717 ruleFeatureSet.collectUniversalSiblingInvalidationSet(invalidationLists, min
DirectAdjacent); |
716 | 718 |
717 m_styleInvalidator.scheduleSiblingInvalidationsAsDescendants(invalidationLis
ts, schedulingParent); | 719 m_styleInvalidator.scheduleSiblingInvalidationsAsDescendants(invalidationLis
ts, schedulingParent); |
718 } | 720 } |
719 | 721 |
720 void StyleEngine::scheduleInvalidationsForInsertedSibling(Element* beforeElement
, Element& insertedElement) | 722 void StyleEngine::scheduleInvalidationsForInsertedSibling(Element* beforeElement
, Element& insertedElement) |
721 { | 723 { |
722 unsigned affectedSiblings = insertedElement.parentNode()->childrenAffectedBy
IndirectAdjacentRules() ? UINT_MAX : m_maxDirectAdjacentSelectors; | 724 unsigned affectedSiblings = insertedElement.parentNode()->childrenAffectedBy
IndirectAdjacentRules() ? UINT_MAX : m_maxDirectAdjacentSelectors; |
723 | 725 |
724 ContainerNode* schedulingParent = insertedElement.parentElementOrShadowRoot(
); | 726 ContainerNode* schedulingParent = insertedElement.parentElementOrShadowRoot(
); |
725 if (!schedulingParent) | 727 if (!schedulingParent) |
726 return; | 728 return; |
727 | 729 |
728 scheduleSiblingInvalidationsForElement(insertedElement, *schedulingParent); | 730 scheduleSiblingInvalidationsForElement(insertedElement, *schedulingParent, 1
); |
729 | 731 |
730 for (unsigned i = 0; beforeElement && i < affectedSiblings; i++, beforeEleme
nt = ElementTraversal::previousSibling(*beforeElement)) | 732 for (unsigned i = 1; beforeElement && i <= affectedSiblings; i++, beforeElem
ent = ElementTraversal::previousSibling(*beforeElement)) |
731 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent
); | 733 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent
, i); |
732 } | 734 } |
733 | 735 |
734 void StyleEngine::scheduleInvalidationsForRemovedSibling(Element* beforeElement,
Element& removedElement, Element& afterElement) | 736 void StyleEngine::scheduleInvalidationsForRemovedSibling(Element* beforeElement,
Element& removedElement, Element& afterElement) |
735 { | 737 { |
736 unsigned affectedSiblings = afterElement.parentNode()->childrenAffectedByInd
irectAdjacentRules() ? UINT_MAX : m_maxDirectAdjacentSelectors; | 738 unsigned affectedSiblings = afterElement.parentNode()->childrenAffectedByInd
irectAdjacentRules() ? UINT_MAX : m_maxDirectAdjacentSelectors; |
737 | 739 |
738 ContainerNode* schedulingParent = afterElement.parentElementOrShadowRoot(); | 740 ContainerNode* schedulingParent = afterElement.parentElementOrShadowRoot(); |
739 if (!schedulingParent) | 741 if (!schedulingParent) |
740 return; | 742 return; |
741 | 743 |
742 scheduleSiblingInvalidationsForElement(removedElement, *schedulingParent); | 744 scheduleSiblingInvalidationsForElement(removedElement, *schedulingParent, 1)
; |
743 | 745 |
744 for (unsigned i = 1; beforeElement && i < affectedSiblings; i++, beforeEleme
nt = ElementTraversal::previousSibling(*beforeElement)) | 746 for (unsigned i = 2; beforeElement && i <= affectedSiblings; i++, beforeElem
ent = ElementTraversal::previousSibling(*beforeElement)) |
745 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent
); | 747 scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent
, i); |
746 } | 748 } |
747 | 749 |
748 void StyleEngine::setStatsEnabled(bool enabled) | 750 void StyleEngine::setStatsEnabled(bool enabled) |
749 { | 751 { |
750 if (!enabled) { | 752 if (!enabled) { |
751 m_styleResolverStats = nullptr; | 753 m_styleResolverStats = nullptr; |
752 return; | 754 return; |
753 } | 755 } |
754 if (!m_styleResolverStats) | 756 if (!m_styleResolverStats) |
755 m_styleResolverStats = StyleResolverStats::create(); | 757 m_styleResolverStats = StyleResolverStats::create(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 | 829 |
828 DEFINE_TRACE_WRAPPERS(StyleEngine) | 830 DEFINE_TRACE_WRAPPERS(StyleEngine) |
829 { | 831 { |
830 for (auto sheet : m_injectedAuthorStyleSheets) { | 832 for (auto sheet : m_injectedAuthorStyleSheets) { |
831 visitor->traceWrappers(sheet); | 833 visitor->traceWrappers(sheet); |
832 } | 834 } |
833 visitor->traceWrappers(m_documentStyleSheetCollection); | 835 visitor->traceWrappers(m_documentStyleSheetCollection); |
834 } | 836 } |
835 | 837 |
836 } // namespace blink | 838 } // namespace blink |
OLD | NEW |