diff options
Diffstat (limited to 'Source/WebCore/dom/MutationObserverInterestGroup.cpp')
-rw-r--r-- | Source/WebCore/dom/MutationObserverInterestGroup.cpp | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/Source/WebCore/dom/MutationObserverInterestGroup.cpp b/Source/WebCore/dom/MutationObserverInterestGroup.cpp index c28d2bd93..229fcb60e 100644 --- a/Source/WebCore/dom/MutationObserverInterestGroup.cpp +++ b/Source/WebCore/dom/MutationObserverInterestGroup.cpp @@ -37,50 +37,48 @@ namespace WebCore { -PassOwnPtr<MutationObserverInterestGroup> MutationObserverInterestGroup::createIfNeeded(Node& target, MutationObserver::MutationType type, MutationRecordDeliveryOptions oldValueFlag, const QualifiedName* attributeName) +inline MutationObserverInterestGroup::MutationObserverInterestGroup(HashMap<MutationObserver*, MutationRecordDeliveryOptions>&& observers, MutationRecordDeliveryOptions oldValueFlag) + : m_observers(WTFMove(observers)) + , m_oldValueFlag(oldValueFlag) +{ + ASSERT(!m_observers.isEmpty()); +} + +std::unique_ptr<MutationObserverInterestGroup> MutationObserverInterestGroup::createIfNeeded(Node& target, MutationObserver::MutationType type, MutationRecordDeliveryOptions oldValueFlag, const QualifiedName* attributeName) { ASSERT((type == MutationObserver::Attributes && attributeName) || !attributeName); - HashMap<MutationObserver*, MutationRecordDeliveryOptions> observers; - target.getRegisteredMutationObserversOfType(observers, type, attributeName); + auto observers = target.registeredMutationObservers(type, attributeName); if (observers.isEmpty()) return nullptr; - return adoptPtr(new MutationObserverInterestGroup(observers, oldValueFlag)); -} - -MutationObserverInterestGroup::MutationObserverInterestGroup(HashMap<MutationObserver*, MutationRecordDeliveryOptions>& observers, MutationRecordDeliveryOptions oldValueFlag) - : m_oldValueFlag(oldValueFlag) -{ - ASSERT(!observers.isEmpty()); - m_observers.swap(observers); + return std::make_unique<MutationObserverInterestGroup>(WTFMove(observers), oldValueFlag); } -bool MutationObserverInterestGroup::isOldValueRequested() +bool MutationObserverInterestGroup::isOldValueRequested() const { - for (HashMap<MutationObserver*, MutationRecordDeliveryOptions>::iterator iter = m_observers.begin(); iter != m_observers.end(); ++iter) { - if (hasOldValue(iter->value)) + for (auto options : m_observers.values()) { + if (hasOldValue(options)) return true; } return false; } -void MutationObserverInterestGroup::enqueueMutationRecord(PassRefPtr<MutationRecord> prpMutation) +void MutationObserverInterestGroup::enqueueMutationRecord(Ref<MutationRecord>&& mutation) { - RefPtr<MutationRecord> mutation = prpMutation; RefPtr<MutationRecord> mutationWithNullOldValue; - for (HashMap<MutationObserver*, MutationRecordDeliveryOptions>::iterator iter = m_observers.begin(); iter != m_observers.end(); ++iter) { - MutationObserver* observer = iter->key; - if (hasOldValue(iter->value)) { - observer->enqueueMutationRecord(mutation); + for (auto& observerOptionsPair : m_observers) { + MutationObserver* observer = observerOptionsPair.key; + if (hasOldValue(observerOptionsPair.value)) { + observer->enqueueMutationRecord(mutation.copyRef()); continue; } if (!mutationWithNullOldValue) { if (mutation->oldValue().isNull()) - mutationWithNullOldValue = mutation; + mutationWithNullOldValue = mutation.ptr(); else - mutationWithNullOldValue = MutationRecord::createWithNullOldValue(mutation).get(); + mutationWithNullOldValue = MutationRecord::createWithNullOldValue(mutation).ptr(); } - observer->enqueueMutationRecord(mutationWithNullOldValue); + observer->enqueueMutationRecord(*mutationWithNullOldValue); } } |