summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/MutationObserverInterestGroup.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/dom/MutationObserverInterestGroup.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/dom/MutationObserverInterestGroup.cpp')
-rw-r--r--Source/WebCore/dom/MutationObserverInterestGroup.cpp44
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);
}
}