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