summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/ChildListMutationScope.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/ChildListMutationScope.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/dom/ChildListMutationScope.cpp')
-rw-r--r--Source/WebCore/dom/ChildListMutationScope.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/Source/WebCore/dom/ChildListMutationScope.cpp b/Source/WebCore/dom/ChildListMutationScope.cpp
index 2c5071649..0fee84cd7 100644
--- a/Source/WebCore/dom/ChildListMutationScope.cpp
+++ b/Source/WebCore/dom/ChildListMutationScope.cpp
@@ -29,13 +29,12 @@
*/
#include "config.h"
-
#include "ChildListMutationScope.h"
-#include "DocumentFragment.h"
#include "MutationObserverInterestGroup.h"
#include "MutationRecord.h"
#include "StaticNodeList.h"
+#include <wtf/NeverDestroyed.h>
#include <wtf/StdLibExtras.h>
namespace WebCore {
@@ -43,14 +42,14 @@ namespace WebCore {
typedef HashMap<ContainerNode*, ChildListMutationAccumulator*> AccumulatorMap;
static AccumulatorMap& accumulatorMap()
{
- DEFINE_STATIC_LOCAL(AccumulatorMap, map, ());
+ static NeverDestroyed<AccumulatorMap> map;
return map;
}
-ChildListMutationAccumulator::ChildListMutationAccumulator(ContainerNode& target, PassOwnPtr<MutationObserverInterestGroup> observers)
+ChildListMutationAccumulator::ChildListMutationAccumulator(ContainerNode& target, std::unique_ptr<MutationObserverInterestGroup> observers)
: m_target(target)
- , m_lastAdded(0)
- , m_observers(observers)
+ , m_lastAdded(nullptr)
+ , m_observers(WTFMove(observers))
{
}
@@ -58,10 +57,10 @@ ChildListMutationAccumulator::~ChildListMutationAccumulator()
{
if (!isEmpty())
enqueueMutationRecord();
- accumulatorMap().remove(&m_target.get());
+ accumulatorMap().remove(m_target.ptr());
}
-PassRefPtr<ChildListMutationAccumulator> ChildListMutationAccumulator::getOrCreate(ContainerNode& target)
+RefPtr<ChildListMutationAccumulator> ChildListMutationAccumulator::getOrCreate(ContainerNode& target)
{
AccumulatorMap::AddResult result = accumulatorMap().add(&target, nullptr);
RefPtr<ChildListMutationAccumulator> accumulator;
@@ -71,7 +70,7 @@ PassRefPtr<ChildListMutationAccumulator> ChildListMutationAccumulator::getOrCrea
accumulator = adoptRef(new ChildListMutationAccumulator(target, MutationObserverInterestGroup::createForChildListMutation(target)));
result.iterator->value = accumulator.get();
}
- return accumulator.release();
+ return accumulator;
}
inline bool ChildListMutationAccumulator::isAddedNodeInOrder(Node& child)
@@ -85,7 +84,7 @@ void ChildListMutationAccumulator::childAdded(Node& childRef)
Ref<Node> child(childRef);
- if (!isAddedNodeInOrder(child.get()))
+ if (!isAddedNodeInOrder(child))
enqueueMutationRecord();
if (isEmpty()) {
@@ -93,7 +92,7 @@ void ChildListMutationAccumulator::childAdded(Node& childRef)
m_nextSibling = child->nextSibling();
}
- m_lastAdded = &child.get();
+ m_lastAdded = child.ptr();
m_addedNodes.append(child.get());
}
@@ -108,7 +107,7 @@ void ChildListMutationAccumulator::willRemoveChild(Node& childRef)
Ref<Node> child(childRef);
- if (!m_addedNodes.isEmpty() || !isRemovedNodeInOrder(child.get()))
+ if (!m_addedNodes.isEmpty() || !isRemovedNodeInOrder(child))
enqueueMutationRecord();
if (isEmpty()) {
@@ -126,11 +125,9 @@ void ChildListMutationAccumulator::enqueueMutationRecord()
ASSERT(hasObservers());
ASSERT(!isEmpty());
- RefPtr<NodeList> addedNodes = StaticNodeList::adopt(m_addedNodes);
- RefPtr<NodeList> removedNodes = StaticNodeList::adopt(m_removedNodes);
- RefPtr<MutationRecord> record = MutationRecord::createChildList(m_target.get(), addedNodes.release(), removedNodes.release(), m_previousSibling.release(), m_nextSibling.release());
- m_observers->enqueueMutationRecord(record.release());
- m_lastAdded = 0;
+ auto record = MutationRecord::createChildList(m_target, StaticNodeList::create(WTFMove(m_addedNodes)), StaticNodeList::create(WTFMove(m_removedNodes)), WTFMove(m_previousSibling), WTFMove(m_nextSibling));
+ m_observers->enqueueMutationRecord(WTFMove(record));
+ m_lastAdded = nullptr;
ASSERT(isEmpty());
}