| 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 15 matching lines...) Expand all Loading... |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include "config.h" | 28 #include "config.h" |
| 29 #include "core/dom/StyleEngine.h" | 29 #include "core/dom/StyleEngine.h" |
| 30 | 30 |
| 31 #include "core/HTMLNames.h" | 31 #include "core/HTMLNames.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/resolver/ScopedStyleResolver.h" | 37 #include "core/css/resolver/ScopedStyleResolver.h" |
| 37 #include "core/dom/DocumentStyleSheetCollector.h" | 38 #include "core/dom/DocumentStyleSheetCollector.h" |
| 38 #include "core/dom/Element.h" | 39 #include "core/dom/Element.h" |
| 39 #include "core/dom/ProcessingInstruction.h" | 40 #include "core/dom/ProcessingInstruction.h" |
| 40 #include "core/dom/ShadowTreeStyleSheetCollection.h" | 41 #include "core/dom/ShadowTreeStyleSheetCollection.h" |
| 41 #include "core/dom/shadow/ShadowRoot.h" | 42 #include "core/dom/shadow/ShadowRoot.h" |
| 42 #include "core/frame/Settings.h" | 43 #include "core/frame/Settings.h" |
| 43 #include "core/html/HTMLIFrameElement.h" | 44 #include "core/html/HTMLIFrameElement.h" |
| 44 #include "core/html/HTMLLinkElement.h" | 45 #include "core/html/HTMLLinkElement.h" |
| 45 #include "core/html/imports/HTMLImportsController.h" | 46 #include "core/html/imports/HTMLImportsController.h" |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 void StyleEngine::platformColorsChanged() | 625 void StyleEngine::platformColorsChanged() |
| 625 { | 626 { |
| 626 if (m_resolver) | 627 if (m_resolver) |
| 627 m_resolver->invalidateMatchedPropertiesCache(); | 628 m_resolver->invalidateMatchedPropertiesCache(); |
| 628 document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci
ng::create(StyleChangeReason::PlatformColorChange)); | 629 document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTraci
ng::create(StyleChangeReason::PlatformColorChange)); |
| 629 } | 630 } |
| 630 | 631 |
| 631 void StyleEngine::classChangedForElement(const SpaceSplitString& changedClasses,
Element& element) | 632 void StyleEngine::classChangedForElement(const SpaceSplitString& changedClasses,
Element& element) |
| 632 { | 633 { |
| 633 ASSERT(isMaster()); | 634 ASSERT(isMaster()); |
| 634 InvalidationSetVector invalidationSets; | 635 InvalidationLists invalidationLists; |
| 635 unsigned changedSize = changedClasses.size(); | 636 unsigned changedSize = changedClasses.size(); |
| 636 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); | 637 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); |
| 637 for (unsigned i = 0; i < changedSize; ++i) | 638 for (unsigned i = 0; i < changedSize; ++i) |
| 638 ruleFeatureSet.collectInvalidationSetsForClass(invalidationSets, element
, changedClasses[i]); | 639 ruleFeatureSet.collectInvalidationSetsForClass(invalidationLists, elemen
t, changedClasses[i]); |
| 639 scheduleInvalidationSetsForElement(invalidationSets, element); | 640 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); |
| 640 } | 641 } |
| 641 | 642 |
| 642 void StyleEngine::classChangedForElement(const SpaceSplitString& oldClasses, con
st SpaceSplitString& newClasses, Element& element) | 643 void StyleEngine::classChangedForElement(const SpaceSplitString& oldClasses, con
st SpaceSplitString& newClasses, Element& element) |
| 643 { | 644 { |
| 644 ASSERT(isMaster()); | 645 ASSERT(isMaster()); |
| 645 InvalidationSetVector invalidationSets; | |
| 646 if (!oldClasses.size()) { | 646 if (!oldClasses.size()) { |
| 647 classChangedForElement(newClasses, element); | 647 classChangedForElement(newClasses, element); |
| 648 return; | 648 return; |
| 649 } | 649 } |
| 650 | 650 |
| 651 // Class vectors tend to be very short. This is faster than using a hash tab
le. | 651 // Class vectors tend to be very short. This is faster than using a hash tab
le. |
| 652 BitVector remainingClassBits; | 652 BitVector remainingClassBits; |
| 653 remainingClassBits.ensureSize(oldClasses.size()); | 653 remainingClassBits.ensureSize(oldClasses.size()); |
| 654 | 654 |
| 655 InvalidationLists invalidationLists; |
| 655 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); | 656 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); |
| 656 | 657 |
| 657 for (unsigned i = 0; i < newClasses.size(); ++i) { | 658 for (unsigned i = 0; i < newClasses.size(); ++i) { |
| 658 bool found = false; | 659 bool found = false; |
| 659 for (unsigned j = 0; j < oldClasses.size(); ++j) { | 660 for (unsigned j = 0; j < oldClasses.size(); ++j) { |
| 660 if (newClasses[i] == oldClasses[j]) { | 661 if (newClasses[i] == oldClasses[j]) { |
| 661 // Mark each class that is still in the newClasses so we can ski
p doing | 662 // Mark each class that is still in the newClasses so we can ski
p doing |
| 662 // an n^2 search below when looking for removals. We can't break
from | 663 // an n^2 search below when looking for removals. We can't break
from |
| 663 // this loop early since a class can appear more than once. | 664 // this loop early since a class can appear more than once. |
| 664 remainingClassBits.quickSet(j); | 665 remainingClassBits.quickSet(j); |
| 665 found = true; | 666 found = true; |
| 666 } | 667 } |
| 667 } | 668 } |
| 668 // Class was added. | 669 // Class was added. |
| 669 if (!found) | 670 if (!found) |
| 670 ruleFeatureSet.collectInvalidationSetsForClass(invalidationSets, ele
ment, newClasses[i]); | 671 ruleFeatureSet.collectInvalidationSetsForClass(invalidationLists, el
ement, newClasses[i]); |
| 671 } | 672 } |
| 672 | 673 |
| 673 for (unsigned i = 0; i < oldClasses.size(); ++i) { | 674 for (unsigned i = 0; i < oldClasses.size(); ++i) { |
| 674 if (remainingClassBits.quickGet(i)) | 675 if (remainingClassBits.quickGet(i)) |
| 675 continue; | 676 continue; |
| 676 // Class was removed. | 677 // Class was removed. |
| 677 ruleFeatureSet.collectInvalidationSetsForClass(invalidationSets, element
, oldClasses[i]); | 678 ruleFeatureSet.collectInvalidationSetsForClass(invalidationLists, elemen
t, oldClasses[i]); |
| 678 } | 679 } |
| 679 | 680 |
| 680 scheduleInvalidationSetsForElement(invalidationSets, element); | 681 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); |
| 681 } | 682 } |
| 682 | 683 |
| 683 void StyleEngine::attributeChangedForElement(const QualifiedName& attributeName,
Element& element) | 684 void StyleEngine::attributeChangedForElement(const QualifiedName& attributeName,
Element& element) |
| 684 { | 685 { |
| 685 ASSERT(isMaster()); | 686 ASSERT(isMaster()); |
| 686 InvalidationSetVector invalidationSets; | 687 InvalidationLists invalidationLists; |
| 687 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForAtt
ribute(invalidationSets, element, attributeName); | 688 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForAtt
ribute(invalidationLists, element, attributeName); |
| 688 scheduleInvalidationSetsForElement(invalidationSets, element); | 689 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); |
| 689 } | 690 } |
| 690 | 691 |
| 691 void StyleEngine::idChangedForElement(const AtomicString& oldId, const AtomicStr
ing& newId, Element& element) | 692 void StyleEngine::idChangedForElement(const AtomicString& oldId, const AtomicStr
ing& newId, Element& element) |
| 692 { | 693 { |
| 693 ASSERT(isMaster()); | 694 ASSERT(isMaster()); |
| 694 InvalidationSetVector invalidationSets; | 695 InvalidationLists invalidationLists; |
| 695 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); | 696 RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSe
t(); |
| 696 if (!oldId.isEmpty()) | 697 if (!oldId.isEmpty()) |
| 697 ruleFeatureSet.collectInvalidationSetsForId(invalidationSets, element, o
ldId); | 698 ruleFeatureSet.collectInvalidationSetsForId(invalidationLists, element,
oldId); |
| 698 if (!newId.isEmpty()) | 699 if (!newId.isEmpty()) |
| 699 ruleFeatureSet.collectInvalidationSetsForId(invalidationSets, element, n
ewId); | 700 ruleFeatureSet.collectInvalidationSetsForId(invalidationLists, element,
newId); |
| 700 scheduleInvalidationSetsForElement(invalidationSets, element); | 701 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); |
| 701 } | 702 } |
| 702 | 703 |
| 703 void StyleEngine::pseudoStateChangedForElement(CSSSelector::PseudoType pseudoTyp
e, Element& element) | 704 void StyleEngine::pseudoStateChangedForElement(CSSSelector::PseudoType pseudoTyp
e, Element& element) |
| 704 { | 705 { |
| 705 ASSERT(isMaster()); | 706 ASSERT(isMaster()); |
| 706 InvalidationSetVector invalidationSets; | 707 InvalidationLists invalidationLists; |
| 707 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForPse
udoClass(invalidationSets, element, pseudoType); | 708 ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForPse
udoClass(invalidationLists, element, pseudoType); |
| 708 scheduleInvalidationSetsForElement(invalidationSets, element); | 709 m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, ele
ment); |
| 709 } | |
| 710 | |
| 711 void StyleEngine::scheduleInvalidationSetsForElement(const InvalidationSetVector
& invalidationSets, Element& element) | |
| 712 { | |
| 713 for (auto invalidationSet : invalidationSets) | |
| 714 m_styleInvalidator.scheduleInvalidation(invalidationSet, element); | |
| 715 } | 710 } |
| 716 | 711 |
| 717 DEFINE_TRACE(StyleEngine) | 712 DEFINE_TRACE(StyleEngine) |
| 718 { | 713 { |
| 719 #if ENABLE(OILPAN) | 714 #if ENABLE(OILPAN) |
| 720 visitor->trace(m_document); | 715 visitor->trace(m_document); |
| 721 visitor->trace(m_authorStyleSheets); | 716 visitor->trace(m_authorStyleSheets); |
| 722 visitor->trace(m_documentStyleSheetCollection); | 717 visitor->trace(m_documentStyleSheetCollection); |
| 723 visitor->trace(m_styleSheetCollectionMap); | 718 visitor->trace(m_styleSheetCollectionMap); |
| 724 visitor->trace(m_resolver); | 719 visitor->trace(m_resolver); |
| 725 visitor->trace(m_styleInvalidator); | 720 visitor->trace(m_styleInvalidator); |
| 726 visitor->trace(m_dirtyTreeScopes); | 721 visitor->trace(m_dirtyTreeScopes); |
| 727 visitor->trace(m_activeTreeScopes); | 722 visitor->trace(m_activeTreeScopes); |
| 728 visitor->trace(m_fontSelector); | 723 visitor->trace(m_fontSelector); |
| 729 visitor->trace(m_textToSheetCache); | 724 visitor->trace(m_textToSheetCache); |
| 730 visitor->trace(m_sheetToTextCache); | 725 visitor->trace(m_sheetToTextCache); |
| 731 #endif | 726 #endif |
| 732 CSSFontSelectorClient::trace(visitor); | 727 CSSFontSelectorClient::trace(visitor); |
| 733 } | 728 } |
| 734 | 729 |
| 735 } | 730 } |
| OLD | NEW |