Chromium Code Reviews| Index: Source/core/dom/StyleEngine.cpp |
| diff --git a/Source/core/dom/StyleEngine.cpp b/Source/core/dom/StyleEngine.cpp |
| index d25247045e79e69558b151b2e439ffa065cc32dc..9517cd9d280f83e095b0dcf56f4651b681140426 100644 |
| --- a/Source/core/dom/StyleEngine.cpp |
| +++ b/Source/core/dom/StyleEngine.cpp |
| @@ -694,6 +694,88 @@ void StyleEngine::platformColorsChanged() |
| document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::PlatformColorChange)); |
| } |
| +void StyleEngine::classChangedForElement(const SpaceSplitString& changedClasses, Element& element) |
| +{ |
| + ASSERT(isMaster()); |
| + InvalidationSetVector invalidationSets; |
| + unsigned changedSize = changedClasses.size(); |
| + for (unsigned i = 0; i < changedSize; ++i) |
| + ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForClass(invalidationSets, element, changedClasses[i]); |
|
esprehn
2015/04/30 05:40:24
I don't think you want to call ensureUpdatedRuleFe
rune
2015/04/30 08:05:57
Done.
|
| + scheduleInvalidationSetsForElement(invalidationSets, element); |
| +} |
| + |
| +void StyleEngine::classChangedForElement(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, Element& element) |
| +{ |
| + ASSERT(isMaster()); |
| + InvalidationSetVector invalidationSets; |
| + if (!oldClasses.size()) { |
| + classChangedForElement(newClasses, element); |
| + return; |
| + } |
| + |
| + // Class vectors tend to be very short. This is faster than using a hash table. |
| + BitVector remainingClassBits; |
| + remainingClassBits.ensureSize(oldClasses.size()); |
| + |
| + for (unsigned i = 0; i < newClasses.size(); ++i) { |
| + bool found = false; |
| + for (unsigned j = 0; j < oldClasses.size(); ++j) { |
| + if (newClasses[i] == oldClasses[j]) { |
| + // Mark each class that is still in the newClasses so we can skip doing |
| + // an n^2 search below when looking for removals. We can't break from |
| + // this loop early since a class can appear more than once. |
| + remainingClassBits.quickSet(j); |
| + found = true; |
| + } |
| + } |
| + // Class was added. |
| + if (!found) |
| + ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForClass(invalidationSets, element, newClasses[i]); |
| + } |
| + |
| + for (unsigned i = 0; i < oldClasses.size(); ++i) { |
| + if (remainingClassBits.quickGet(i)) |
| + continue; |
| + // Class was removed. |
| + ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForClass(invalidationSets, element, oldClasses[i]); |
|
esprehn
2015/04/30 05:40:24
ditto. Don't want to call ensureResolver or ensure
rune
2015/04/30 08:05:57
Done.
|
| + } |
| + |
| + scheduleInvalidationSetsForElement(invalidationSets, element); |
| +} |
| + |
| +void StyleEngine::attributeChangedForElement(const QualifiedName& attributeName, Element& element) |
| +{ |
| + ASSERT(isMaster()); |
| + InvalidationSetVector invalidationSets; |
| + ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForAttribute(invalidationSets, element, attributeName); |
| + scheduleInvalidationSetsForElement(invalidationSets, element); |
| +} |
| + |
| +void StyleEngine::idChangedForElement(const AtomicString& oldId, const AtomicString& newId, Element& element) |
| +{ |
| + ASSERT(isMaster()); |
| + InvalidationSetVector invalidationSets; |
| + if (!oldId.isEmpty()) |
| + ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForId(invalidationSets, element, oldId); |
| + if (!newId.isEmpty()) |
| + ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForId(invalidationSets, element, newId); |
| + scheduleInvalidationSetsForElement(invalidationSets, element); |
| +} |
| + |
| +void StyleEngine::pseudoStateChangedForElement(CSSSelector::PseudoType pseudoType, Element& element) |
| +{ |
| + ASSERT(isMaster()); |
| + InvalidationSetVector invalidationSets; |
| + ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForPseudoClass(invalidationSets, element, pseudoType); |
| + scheduleInvalidationSetsForElement(invalidationSets, element); |
| +} |
| + |
| +void StyleEngine::scheduleInvalidationSetsForElement(const InvalidationSetVector& invalidationSets, Element& element) |
| +{ |
| + for (auto invalidationSet : invalidationSets) |
| + m_styleInvalidator.scheduleInvalidation(invalidationSet, element); |
| +} |
| + |
| DEFINE_TRACE(StyleEngine) |
| { |
| #if ENABLE(OILPAN) |
| @@ -702,6 +784,7 @@ DEFINE_TRACE(StyleEngine) |
| visitor->trace(m_documentStyleSheetCollection); |
| visitor->trace(m_styleSheetCollectionMap); |
| visitor->trace(m_resolver); |
| + visitor->trace(m_styleInvalidator); |
| visitor->trace(m_dirtyTreeScopes); |
| visitor->trace(m_activeTreeScopes); |
| visitor->trace(m_fontSelector); |