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