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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 m_fontSelector->registerForInvalidationCallbacks(this); | 619 m_fontSelector->registerForInvalidationCallbacks(this); |
620 } | 620 } |
621 | 621 |
622 void StyleEngine::platformColorsChanged() | 622 void StyleEngine::platformColorsChanged() |
623 { | 623 { |
624 if (m_resolver) | 624 if (m_resolver) |
625 m_resolver->invalidateMatchedPropertiesCache(); | 625 m_resolver->invalidateMatchedPropertiesCache(); |
626 document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci
ng::create(StyleChangeReason::PlatformColorChange)); | 626 document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci
ng::create(StyleChangeReason::PlatformColorChange)); |
627 } | 627 } |
628 | 628 |
| 629 bool StyleEngine::shouldSkipInvalidationFor(const Element& element) const |
| 630 { |
| 631 if (!resolver()) |
| 632 return true; |
| 633 if (!element.inActiveDocument()) |
| 634 return true; |
| 635 if (!element.parentNode()) |
| 636 return true; |
| 637 return element.parentNode()->styleChangeType() >= SubtreeStyleChange; |
| 638 } |
| 639 |
629 void StyleEngine::classChangedForElement(const SpaceSplitString& changedClasses,
Element& element) | 640 void StyleEngine::classChangedForElement(const SpaceSplitString& changedClasses,
Element& element) |
630 { | 641 { |
631 ASSERT(isMaster()); | 642 if (shouldSkipInvalidationFor(element)) |
| 643 return; |
632 InvalidationLists invalidationLists; | 644 InvalidationLists invalidationLists; |
633 unsigned changedSize = changedClasses.size(); | 645 unsigned changedSize = changedClasses.size(); |
634 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); | 646 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); |
635 for (unsigned i = 0; i < changedSize; ++i) | 647 for (unsigned i = 0; i < changedSize; ++i) |
636 ruleFeatureSet.collectInvalidationSetsForClass(invalidationLists, elemen
t, changedClasses[i]); | 648 ruleFeatureSet.collectInvalidationSetsForClass(invalidationLists, elemen
t, changedClasses[i]); |
637 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); | 649 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); |
638 } | 650 } |
639 | 651 |
640 void StyleEngine::classChangedForElement(const SpaceSplitString& oldClasses, con
st SpaceSplitString& newClasses, Element& element) | 652 void StyleEngine::classChangedForElement(const SpaceSplitString& oldClasses, con
st SpaceSplitString& newClasses, Element& element) |
641 { | 653 { |
642 ASSERT(isMaster()); | 654 if (shouldSkipInvalidationFor(element)) |
| 655 return; |
| 656 |
643 if (!oldClasses.size()) { | 657 if (!oldClasses.size()) { |
644 classChangedForElement(newClasses, element); | 658 classChangedForElement(newClasses, element); |
645 return; | 659 return; |
646 } | 660 } |
647 | 661 |
648 // Class vectors tend to be very short. This is faster than using a hash tab
le. | 662 // Class vectors tend to be very short. This is faster than using a hash tab
le. |
649 BitVector remainingClassBits; | 663 BitVector remainingClassBits; |
650 remainingClassBits.ensureSize(oldClasses.size()); | 664 remainingClassBits.ensureSize(oldClasses.size()); |
651 | 665 |
652 InvalidationLists invalidationLists; | 666 InvalidationLists invalidationLists; |
(...skipping 20 matching lines...) Expand all Loading... |
673 continue; | 687 continue; |
674 // Class was removed. | 688 // Class was removed. |
675 ruleFeatureSet.collectInvalidationSetsForClass(invalidationLists, elemen
t, oldClasses[i]); | 689 ruleFeatureSet.collectInvalidationSetsForClass(invalidationLists, elemen
t, oldClasses[i]); |
676 } | 690 } |
677 | 691 |
678 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); | 692 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); |
679 } | 693 } |
680 | 694 |
681 void StyleEngine::attributeChangedForElement(const QualifiedName& attributeName,
Element& element) | 695 void StyleEngine::attributeChangedForElement(const QualifiedName& attributeName,
Element& element) |
682 { | 696 { |
683 ASSERT(isMaster()); | 697 if (shouldSkipInvalidationFor(element)) |
| 698 return; |
| 699 |
684 InvalidationLists invalidationLists; | 700 InvalidationLists invalidationLists; |
685 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForAtt
ribute(invalidationLists, element, attributeName); | 701 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForAtt
ribute(invalidationLists, element, attributeName); |
686 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); | 702 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); |
687 } | 703 } |
688 | 704 |
689 void StyleEngine::idChangedForElement(const AtomicString& oldId, const AtomicStr
ing& newId, Element& element) | 705 void StyleEngine::idChangedForElement(const AtomicString& oldId, const AtomicStr
ing& newId, Element& element) |
690 { | 706 { |
691 ASSERT(isMaster()); | 707 if (shouldSkipInvalidationFor(element)) |
| 708 return; |
| 709 |
692 InvalidationLists invalidationLists; | 710 InvalidationLists invalidationLists; |
693 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); | 711 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); |
694 if (!oldId.isEmpty()) | 712 if (!oldId.isEmpty()) |
695 ruleFeatureSet.collectInvalidationSetsForId(invalidationLists, element,
oldId); | 713 ruleFeatureSet.collectInvalidationSetsForId(invalidationLists, element,
oldId); |
696 if (!newId.isEmpty()) | 714 if (!newId.isEmpty()) |
697 ruleFeatureSet.collectInvalidationSetsForId(invalidationLists, element,
newId); | 715 ruleFeatureSet.collectInvalidationSetsForId(invalidationLists, element,
newId); |
698 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); | 716 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); |
699 } | 717 } |
700 | 718 |
701 void StyleEngine::pseudoStateChangedForElement(CSSSelector::PseudoType pseudoTyp
e, Element& element) | 719 void StyleEngine::pseudoStateChangedForElement(CSSSelector::PseudoType pseudoTyp
e, Element& element) |
702 { | 720 { |
703 ASSERT(isMaster()); | 721 if (shouldSkipInvalidationFor(element)) |
| 722 return; |
| 723 |
704 InvalidationLists invalidationLists; | 724 InvalidationLists invalidationLists; |
705 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForPse
udoClass(invalidationLists, element, pseudoType); | 725 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForPse
udoClass(invalidationLists, element, pseudoType); |
706 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); | 726 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); |
707 } | 727 } |
708 | 728 |
709 DEFINE_TRACE(StyleEngine) | 729 DEFINE_TRACE(StyleEngine) |
710 { | 730 { |
711 #if ENABLE(OILPAN) | 731 #if ENABLE(OILPAN) |
712 visitor->trace(m_document); | 732 visitor->trace(m_document); |
713 visitor->trace(m_injectedAuthorStyleSheets); | 733 visitor->trace(m_injectedAuthorStyleSheets); |
714 visitor->trace(m_documentStyleSheetCollection); | 734 visitor->trace(m_documentStyleSheetCollection); |
715 visitor->trace(m_styleSheetCollectionMap); | 735 visitor->trace(m_styleSheetCollectionMap); |
716 visitor->trace(m_resolver); | 736 visitor->trace(m_resolver); |
717 visitor->trace(m_styleInvalidator); | 737 visitor->trace(m_styleInvalidator); |
718 visitor->trace(m_dirtyTreeScopes); | 738 visitor->trace(m_dirtyTreeScopes); |
719 visitor->trace(m_activeTreeScopes); | 739 visitor->trace(m_activeTreeScopes); |
720 visitor->trace(m_fontSelector); | 740 visitor->trace(m_fontSelector); |
721 visitor->trace(m_textToSheetCache); | 741 visitor->trace(m_textToSheetCache); |
722 visitor->trace(m_sheetToTextCache); | 742 visitor->trace(m_sheetToTextCache); |
723 #endif | 743 #endif |
724 CSSFontSelectorClient::trace(visitor); | 744 CSSFontSelectorClient::trace(visitor); |
725 } | 745 } |
726 | 746 |
727 } | 747 } |
OLD | NEW |