Diff
Modified: branches/safari-611.1.4-branch/LayoutTests/ChangeLog (269004 => 269005)
--- branches/safari-611.1.4-branch/LayoutTests/ChangeLog 2020-10-27 00:50:41 UTC (rev 269004)
+++ branches/safari-611.1.4-branch/LayoutTests/ChangeLog 2020-10-27 01:12:52 UTC (rev 269005)
@@ -1,3 +1,41 @@
+2020-10-26 Alan Coon <[email protected]>
+
+ Cherry-pick r268695. rdar://problem/70702399
+
+ Unreviewed, reverting r267175 and r267779.
+ https://bugs.webkit.org/show_bug.cgi?id=217923
+
+ Regressed NYTimes's DOM content loaded time by 400%
+
+ Reverted changesets:
+
+ "MutationObserverRegistration should be ref counted"
+ https://bugs.webkit.org/show_bug.cgi?id=216528
+ https://trac.webkit.org/changeset/267175
+
+ "Crash while loading a confluence page"
+ https://bugs.webkit.org/show_bug.cgi?id=217111
+ https://trac.webkit.org/changeset/267779
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-10-19 Commit Queue <[email protected]>
+
+ Unreviewed, reverting r267175 and r267779.
+ https://bugs.webkit.org/show_bug.cgi?id=217923
+
+ Regressed NYTimes's DOM content loaded time by 400%
+
+ Reverted changesets:
+
+ "MutationObserverRegistration should be ref counted"
+ https://bugs.webkit.org/show_bug.cgi?id=216528
+ https://trac.webkit.org/changeset/267175
+
+ "Crash while loading a confluence page"
+ https://bugs.webkit.org/show_bug.cgi?id=217111
+ https://trac.webkit.org/changeset/267779
+
2020-10-22 Alan Coon <[email protected]>
Revert r268615. rdar://problem/70578639
Deleted: branches/safari-611.1.4-branch/LayoutTests/fast/dom/MutationObserver/disconnect-twice-expected.txt (269004 => 269005)
--- branches/safari-611.1.4-branch/LayoutTests/fast/dom/MutationObserver/disconnect-twice-expected.txt 2020-10-27 00:50:41 UTC (rev 269004)
+++ branches/safari-611.1.4-branch/LayoutTests/fast/dom/MutationObserver/disconnect-twice-expected.txt 2020-10-27 01:12:52 UTC (rev 269005)
@@ -1,4 +0,0 @@
-This tests disconnecting MutationObserver twice while keeping a transient observation going.
-WebKit should not crash and you should see PASS below.
-
-PASS
Deleted: branches/safari-611.1.4-branch/LayoutTests/fast/dom/MutationObserver/disconnect-twice.html (269004 => 269005)
--- branches/safari-611.1.4-branch/LayoutTests/fast/dom/MutationObserver/disconnect-twice.html 2020-10-27 00:50:41 UTC (rev 269004)
+++ branches/safari-611.1.4-branch/LayoutTests/fast/dom/MutationObserver/disconnect-twice.html 2020-10-27 01:12:52 UTC (rev 269005)
@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-<p>This tests disconnecting MutationObserver twice while keeping a transient observation going.<br>
-WebKit should not crash and you should see PASS below.</p>
-<div id="child"><div></div></div>
-<script>
-
-if (window.testRunner)
- testRunner.dumpAsText();
-
-const observer = new MutationObserver((records) => {
-});
-
-observer.observe(document.body, {childList: true, subtree: true});
-child.remove();
-observer.disconnect();
-observer.disconnect();
-
-document.write('PASS');
-
-</script>
-</body>
-</html>
Modified: branches/safari-611.1.4-branch/Source/WebCore/ChangeLog (269004 => 269005)
--- branches/safari-611.1.4-branch/Source/WebCore/ChangeLog 2020-10-27 00:50:41 UTC (rev 269004)
+++ branches/safari-611.1.4-branch/Source/WebCore/ChangeLog 2020-10-27 01:12:52 UTC (rev 269005)
@@ -1,3 +1,41 @@
+2020-10-26 Alan Coon <[email protected]>
+
+ Cherry-pick r268695. rdar://problem/70702399
+
+ Unreviewed, reverting r267175 and r267779.
+ https://bugs.webkit.org/show_bug.cgi?id=217923
+
+ Regressed NYTimes's DOM content loaded time by 400%
+
+ Reverted changesets:
+
+ "MutationObserverRegistration should be ref counted"
+ https://bugs.webkit.org/show_bug.cgi?id=216528
+ https://trac.webkit.org/changeset/267175
+
+ "Crash while loading a confluence page"
+ https://bugs.webkit.org/show_bug.cgi?id=217111
+ https://trac.webkit.org/changeset/267779
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-10-19 Commit Queue <[email protected]>
+
+ Unreviewed, reverting r267175 and r267779.
+ https://bugs.webkit.org/show_bug.cgi?id=217923
+
+ Regressed NYTimes's DOM content loaded time by 400%
+
+ Reverted changesets:
+
+ "MutationObserverRegistration should be ref counted"
+ https://bugs.webkit.org/show_bug.cgi?id=216528
+ https://trac.webkit.org/changeset/267175
+
+ "Crash while loading a confluence page"
+ https://bugs.webkit.org/show_bug.cgi?id=217111
+ https://trac.webkit.org/changeset/267779
+
2020-10-22 Alan Coon <[email protected]>
Revert r268483. rdar://problem/70578639
Modified: branches/safari-611.1.4-branch/Source/WebCore/dom/MutationObserver.cpp (269004 => 269005)
--- branches/safari-611.1.4-branch/Source/WebCore/dom/MutationObserver.cpp 2020-10-27 00:50:41 UTC (rev 269004)
+++ branches/safari-611.1.4-branch/Source/WebCore/dom/MutationObserver.cpp 2020-10-27 01:12:52 UTC (rev 269005)
@@ -120,26 +120,21 @@
{
m_pendingTargets.clear();
m_records.clear();
- auto registrationAndNodeList = WTF::compactMap(m_registrations, [](auto* registration) -> Optional<std::pair<Ref<Node>, Ref<MutationObserverRegistration>>> {
- auto node = registration->stopObserving();
- if (!node)
- return WTF::nullopt;
- return { { node.releaseNonNull(), makeRef(*registration) } };
- });
- for (auto& registrationAndNode : registrationAndNodeList)
- registrationAndNode.first->unregisterMutationObserver(registrationAndNode.second.get());
+ HashSet<MutationObserverRegistration*> registrations(m_registrations);
+ for (auto* registration : registrations)
+ registration->node().unregisterMutationObserver(*registration);
}
void MutationObserver::observationStarted(MutationObserverRegistration& registration)
{
- auto result = m_registrations.add(®istration);
- RELEASE_ASSERT(result.isNewEntry);
+ ASSERT(!m_registrations.contains(®istration));
+ m_registrations.add(®istration);
}
void MutationObserver::observationEnded(MutationObserverRegistration& registration)
{
- auto removed = m_registrations.remove(®istration);
- RELEASE_ASSERT(removed);
+ ASSERT(m_registrations.contains(®istration));
+ m_registrations.remove(®istration);
}
void MutationObserver::enqueueMutationRecord(Ref<MutationRecord>&& mutation)
@@ -191,14 +186,18 @@
{
ASSERT(canDeliver());
+ // Calling takeTransientRegistrations() can modify m_registrations, so it's necessary
+ // to make a copy of the transient registrations before operating on them.
+ Vector<MutationObserverRegistration*, 1> transientRegistrations;
Vector<std::unique_ptr<HashSet<GCReachableRef<Node>>>, 1> nodesToKeepAlive;
HashSet<GCReachableRef<Node>> pendingTargets;
pendingTargets.swap(m_pendingTargets);
- auto registrations = WTF::map(m_registrations, [](auto* registration) { return makeRef(*registration); });
- for (auto& registration : registrations) {
+ for (auto* registration : m_registrations) {
if (registration->hasTransientRegistrations())
- nodesToKeepAlive.append(registration->takeTransientRegistrations());
+ transientRegistrations.append(registration);
}
+ for (auto& registration : transientRegistrations)
+ nodesToKeepAlive.append(registration->takeTransientRegistrations());
if (m_records.isEmpty()) {
ASSERT(m_pendingTargets.isEmpty());
Modified: branches/safari-611.1.4-branch/Source/WebCore/dom/MutationObserverRegistration.cpp (269004 => 269005)
--- branches/safari-611.1.4-branch/Source/WebCore/dom/MutationObserverRegistration.cpp 2020-10-27 00:50:41 UTC (rev 269004)
+++ branches/safari-611.1.4-branch/Source/WebCore/dom/MutationObserverRegistration.cpp 2020-10-27 01:12:52 UTC (rev 269005)
@@ -37,14 +37,9 @@
namespace WebCore {
-Ref<MutationObserverRegistration> MutationObserverRegistration::create(MutationObserver& observer, Node& node, MutationObserverOptions options, const HashSet<AtomString>& attributeFilter)
-{
- return adoptRef(*new MutationObserverRegistration(observer, node, options, attributeFilter));
-}
-
MutationObserverRegistration::MutationObserverRegistration(MutationObserver& observer, Node& node, MutationObserverOptions options, const HashSet<AtomString>& attributeFilter)
: m_observer(observer)
- , m_node(makeWeakPtr(node))
+ , m_node(node)
, m_options(options)
, m_attributeFilter(attributeFilter)
{
@@ -72,21 +67,31 @@
node.registerTransientMutationObserver(*this);
m_observer->setHasTransientRegistration(node.document());
- if (!m_transientRegistrationNodes)
+ if (!m_transientRegistrationNodes) {
m_transientRegistrationNodes = makeUnique<HashSet<GCReachableRef<Node>>>();
+
+ ASSERT(!m_nodeKeptAlive);
+ m_nodeKeptAlive = &m_node; // Balanced in takeTransientRegistrations.
+ }
m_transientRegistrationNodes->add(node);
}
std::unique_ptr<HashSet<GCReachableRef<Node>>> MutationObserverRegistration::takeTransientRegistrations()
{
- if (!m_transientRegistrationNodes)
+ if (!m_transientRegistrationNodes) {
+ ASSERT(!m_nodeKeptAlive);
return nullptr;
+ }
- auto transientNodes = WTFMove(m_transientRegistrationNodes);
- for (auto& node : *transientNodes)
+ for (auto& node : *m_transientRegistrationNodes)
node->unregisterTransientMutationObserver(*this);
- return transientNodes;
+ auto returnValue = WTFMove(m_transientRegistrationNodes);
+
+ ASSERT(m_nodeKeptAlive);
+ m_nodeKeptAlive = nullptr; // Balanced in observeSubtreeNodeWillDetach.
+
+ return returnValue;
}
bool MutationObserverRegistration::shouldReceiveMutationFrom(Node& node, MutationObserver::MutationType type, const QualifiedName* attributeName) const
@@ -95,7 +100,7 @@
if (!(m_options & type))
return false;
- if (m_node.get() != &node && !isSubtree())
+ if (&m_node != &node && !isSubtree())
return false;
if (type != MutationObserver::Attributes || !(m_options & MutationObserver::AttributeFilter))
@@ -107,19 +112,9 @@
return m_attributeFilter.contains(attributeName->localName());
}
-RefPtr<Node> MutationObserverRegistration::stopObserving()
-{
- if (m_hasStoppedObservingNode)
- return nullptr;
- m_hasStoppedObservingNode = true;
- return makeRefPtr(m_node.get());
-}
-
void MutationObserverRegistration::addRegistrationNodesToSet(HashSet<Node*>& nodes) const
{
- ASSERT(m_node.get() || m_transientRegistrationNodes);
- if (auto* observedNode = m_node.get())
- nodes.add(observedNode);
+ nodes.add(&m_node);
if (!m_transientRegistrationNodes)
return;
for (auto& node : *m_transientRegistrationNodes)
Modified: branches/safari-611.1.4-branch/Source/WebCore/dom/MutationObserverRegistration.h (269004 => 269005)
--- branches/safari-611.1.4-branch/Source/WebCore/dom/MutationObserverRegistration.h 2020-10-27 00:50:41 UTC (rev 269004)
+++ branches/safari-611.1.4-branch/Source/WebCore/dom/MutationObserverRegistration.h 2020-10-27 01:12:52 UTC (rev 269005)
@@ -33,7 +33,6 @@
#include "GCReachableRef.h"
#include "MutationObserver.h"
#include <wtf/HashSet.h>
-#include <wtf/WeakPtr.h>
#include <wtf/text/AtomString.h>
#include <wtf/text/AtomStringHash.h>
@@ -41,11 +40,10 @@
class QualifiedName;
-class MutationObserverRegistration : public RefCounted<MutationObserverRegistration> {
+class MutationObserverRegistration {
WTF_MAKE_FAST_ALLOCATED;
public:
- static Ref<MutationObserverRegistration> create(MutationObserver&, Node&, MutationObserverOptions, const HashSet<AtomString>& attributeFilter);
-
+ MutationObserverRegistration(MutationObserver&, Node&, MutationObserverOptions, const HashSet<AtomString>& attributeFilter);
~MutationObserverRegistration();
void resetObservation(MutationObserverOptions, const HashSet<AtomString>& attributeFilter);
@@ -57,8 +55,7 @@
bool isSubtree() const { return m_options & MutationObserver::Subtree; }
MutationObserver& observer() { return m_observer.get(); }
- Node* node() { return m_node.get(); }
- RefPtr<Node> stopObserving();
+ Node& node() { return m_node; }
MutationRecordDeliveryOptions deliveryOptions() const { return m_options & (MutationObserver::AttributeOldValue | MutationObserver::CharacterDataOldValue); }
MutationObserverOptions mutationTypes() const { return m_options & MutationObserver::AllMutationTypes; }
@@ -65,13 +62,11 @@
void addRegistrationNodesToSet(HashSet<Node*>&) const;
private:
- MutationObserverRegistration(MutationObserver&, Node&, MutationObserverOptions, const HashSet<AtomString>& attributeFilter);
-
Ref<MutationObserver> m_observer;
- WeakPtr<Node> m_node;
- bool m_hasStoppedObservingNode { false };
+ Node& m_node;
+ RefPtr<Node> m_nodeKeptAlive;
+ std::unique_ptr<HashSet<GCReachableRef<Node>>> m_transientRegistrationNodes;
MutationObserverOptions m_options;
- std::unique_ptr<HashSet<GCReachableRef<Node>>> m_transientRegistrationNodes;
HashSet<AtomString> m_attributeFilter;
};
Modified: branches/safari-611.1.4-branch/Source/WebCore/dom/Node.cpp (269004 => 269005)
--- branches/safari-611.1.4-branch/Source/WebCore/dom/Node.cpp 2020-10-27 00:50:41 UTC (rev 269004)
+++ branches/safari-611.1.4-branch/Source/WebCore/dom/Node.cpp 2020-10-27 01:12:52 UTC (rev 269005)
@@ -429,7 +429,8 @@
void Node::clearRareData()
{
ASSERT(hasRareData());
- ASSERT(rareData()->transientMutationObserverRegistry().isEmpty());
+ ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegistry()->isEmpty());
+
m_rareDataWithBitfields.setPointer(nullptr);
}
@@ -2039,15 +2040,19 @@
oldDocument.decrementReferencingNodeCount();
if (hasRareData()) {
- auto* rareData = this->rareData();
- if (auto* nodeLists = rareData->nodeLists())
+ if (auto* nodeLists = rareData()->nodeLists())
nodeLists->adoptDocument(oldDocument, newDocument);
- if (auto* registry = rareData->mutationObserverRegistryIfExists()) {
+ if (auto* registry = mutationObserverRegistry()) {
for (auto& registration : *registry)
newDocument.addMutationObserverTypes(registration->mutationTypes());
}
- for (auto& registration : rareData->transientMutationObserverRegistry())
- newDocument.addMutationObserverTypes(registration->mutationTypes());
+ if (auto* transientRegistry = transientMutationObserverRegistry()) {
+ for (auto& registration : *transientRegistry)
+ newDocument.addMutationObserverTypes(registration->mutationTypes());
+ }
+ } else {
+ ASSERT(!mutationObserverRegistry());
+ ASSERT(!transientMutationObserverRegistry());
}
oldDocument.moveNodeIteratorsToNewDocument(*this, newDocument);
@@ -2247,9 +2252,32 @@
eventTargetDataMap().remove(this);
}
-template<typename Registry> static inline void collectMatchingObserversForMutation(HashMap<Ref<MutationObserver>, MutationRecordDeliveryOptions>& observers, Registry& registry, Node& target, MutationObserver::MutationType type, const QualifiedName* attributeName)
+Vector<std::unique_ptr<MutationObserverRegistration>>* Node::mutationObserverRegistry()
{
- for (auto& registration : registry) {
+ if (!hasRareData())
+ return nullptr;
+ auto* data = ""
+ if (!data)
+ return nullptr;
+ return &data->registry;
+}
+
+HashSet<MutationObserverRegistration*>* Node::transientMutationObserverRegistry()
+{
+ if (!hasRareData())
+ return nullptr;
+ auto* data = ""
+ if (!data)
+ return nullptr;
+ return &data->transientRegistry;
+}
+
+template<typename Registry> static inline void collectMatchingObserversForMutation(HashMap<Ref<MutationObserver>, MutationRecordDeliveryOptions>& observers, Registry* registry, Node& target, MutationObserver::MutationType type, const QualifiedName* attributeName)
+{
+ if (!registry)
+ return;
+
+ for (auto& registration : *registry) {
if (registration->shouldReceiveMutationFrom(target, type, attributeName)) {
auto deliveryOptions = registration->deliveryOptions();
auto result = observers.add(registration->observer(), deliveryOptions);
@@ -2263,13 +2291,11 @@
{
HashMap<Ref<MutationObserver>, MutationRecordDeliveryOptions> result;
ASSERT((type == MutationObserver::Attributes && attributeName) || !attributeName);
- for (auto node = makeRefPtr(this); node; node = node->parentNode()) {
- if (!node->hasRareData())
- continue;
- auto* rareData = node->rareData();
- if (auto* registry = rareData->mutationObserverRegistryIfExists())
- collectMatchingObserversForMutation(result, *registry, *this, type, attributeName);
- collectMatchingObserversForMutation(result, rareData->transientMutationObserverRegistry(), *this, type, attributeName);
+ collectMatchingObserversForMutation(result, mutationObserverRegistry(), *this, type, attributeName);
+ collectMatchingObserversForMutation(result, transientMutationObserverRegistry(), *this, type, attributeName);
+ for (Node* node = parentNode(); node; node = node->parentNode()) {
+ collectMatchingObserversForMutation(result, node->mutationObserverRegistry(), *this, type, attributeName);
+ collectMatchingObserversForMutation(result, node->transientMutationObserverRegistry(), *this, type, attributeName);
}
return result;
}
@@ -2276,40 +2302,50 @@
void Node::registerMutationObserver(MutationObserver& observer, MutationObserverOptions options, const HashSet<AtomString>& attributeFilter)
{
- auto& registry = ensureRareData().mutationObserverRegistry();
- auto index = registry.findMatching([&observer](auto& registration) { return ®istration->observer() == &observer; });
- if (index != notFound) {
- auto registration = registry[index].copyRef();
- registration->resetObservation(options, attributeFilter);
- document().addMutationObserverTypes(registration->mutationTypes());
- return;
+ MutationObserverRegistration* registration = nullptr;
+ auto& registry = ensureRareData().ensureMutationObserverData().registry;
+
+ for (auto& candidateRegistration : registry) {
+ if (&candidateRegistration->observer() == &observer) {
+ registration = candidateRegistration.get();
+ registration->resetObservation(options, attributeFilter);
+ }
}
- auto newRegistration = MutationObserverRegistration::create(observer, *this, options, attributeFilter);
- document().addMutationObserverTypes(newRegistration->mutationTypes());
- registry.append(WTFMove(newRegistration));
+
+ if (!registration) {
+ registry.append(makeUnique<MutationObserverRegistration>(observer, *this, options, attributeFilter));
+ registration = registry.last().get();
+ }
+
+ document().addMutationObserverTypes(registration->mutationTypes());
}
void Node::unregisterMutationObserver(MutationObserverRegistration& registration)
{
- ASSERT(hasRareData());
- auto* registry = rareData()->mutationObserverRegistryIfExists();
+ auto* registry = mutationObserverRegistry();
ASSERT(registry);
- auto removed = registry->removeFirstMatching([®istration] (auto& current) {
- return current.ptr() == ®istration;
+ if (!registry)
+ return;
+
+ registry->removeFirstMatching([®istration] (auto& current) {
+ return current.get() == ®istration;
});
- RELEASE_ASSERT(removed);
}
void Node::registerTransientMutationObserver(MutationObserverRegistration& registration)
{
- ensureRareData().transientMutationObserverRegistry().add(registration);
+ ensureRareData().ensureMutationObserverData().transientRegistry.add(®istration);
}
void Node::unregisterTransientMutationObserver(MutationObserverRegistration& registration)
{
- ASSERT(hasRareData());
- bool removed = rareData()->transientMutationObserverRegistry().remove(®istration);
- RELEASE_ASSERT(removed);
+ auto* transientRegistry = transientMutationObserverRegistry();
+ ASSERT(transientRegistry);
+ if (!transientRegistry)
+ return;
+
+ ASSERT(transientRegistry->contains(®istration));
+ transientRegistry->remove(®istration);
}
void Node::notifyMutationObserversNodeWillDetach()
@@ -2318,15 +2354,14 @@
return;
for (Node* node = parentNode(); node; node = node->parentNode()) {
- if (!node->hasRareData())
- continue;
- auto* rareData = node->rareData();
- if (auto* registry = rareData->mutationObserverRegistryIfExists()) {
+ if (auto* registry = node->mutationObserverRegistry()) {
for (auto& registration : *registry)
registration->observedSubtreeNodeWillDetach(*this);
}
- for (auto& registration : rareData->transientMutationObserverRegistry())
- registration->observedSubtreeNodeWillDetach(*this);
+ if (auto* transientRegistry = node->transientMutationObserverRegistry()) {
+ for (auto* registration : *transientRegistry)
+ registration->observedSubtreeNodeWillDetach(*this);
+ }
}
}
Modified: branches/safari-611.1.4-branch/Source/WebCore/dom/Node.h (269004 => 269005)
--- branches/safari-611.1.4-branch/Source/WebCore/dom/Node.h 2020-10-27 00:50:41 UTC (rev 269004)
+++ branches/safari-611.1.4-branch/Source/WebCore/dom/Node.h 2020-10-27 01:12:52 UTC (rev 269005)
@@ -700,6 +700,9 @@
void trackForDebugging();
void materializeRareData();
+ Vector<std::unique_ptr<MutationObserverRegistration>>* mutationObserverRegistry();
+ HashSet<MutationObserverRegistration*>* transientMutationObserverRegistry();
+
void adjustStyleValidity(Style::Validity, Style::InvalidationMode);
void* opaqueRootSlow() const;
Modified: branches/safari-611.1.4-branch/Source/WebCore/dom/NodeRareData.cpp (269004 => 269005)
--- branches/safari-611.1.4-branch/Source/WebCore/dom/NodeRareData.cpp 2020-10-27 00:50:41 UTC (rev 269004)
+++ branches/safari-611.1.4-branch/Source/WebCore/dom/NodeRareData.cpp 2020-10-27 01:12:52 UTC (rev 269005)
@@ -38,10 +38,7 @@
struct SameSizeAsNodeRareData {
uint32_t m_tabIndex;
uint32_t m_childIndexAndIsElementRareDataFlag;
- void* m_pointer[3];
-#if CHECK_HASHTABLE_ITERATORS
- void* m_hashTableIteratorsAndMutex[2];
-#endif
+ void* m_pointer[2];
};
COMPILE_ASSERT(sizeof(NodeRareData) == sizeof(SameSizeAsNodeRareData), NodeRareDataShouldStaySmall);
Modified: branches/safari-611.1.4-branch/Source/WebCore/dom/NodeRareData.h (269004 => 269005)
--- branches/safari-611.1.4-branch/Source/WebCore/dom/NodeRareData.h 2020-10-27 00:50:41 UTC (rev 269004)
+++ branches/safari-611.1.4-branch/Source/WebCore/dom/NodeRareData.h 2020-10-27 01:12:52 UTC (rev 269005)
@@ -229,6 +229,15 @@
CollectionCacheMap m_cachedCollections;
};
+class NodeMutationObserverData {
+ WTF_MAKE_NONCOPYABLE(NodeMutationObserverData); WTF_MAKE_FAST_ALLOCATED;
+public:
+ Vector<std::unique_ptr<MutationObserverRegistration>> registry;
+ HashSet<MutationObserverRegistration*> transientRegistry;
+
+ NodeMutationObserverData() { }
+};
+
DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(NodeRareData);
class NodeRareData {
WTF_MAKE_NONCOPYABLE(NodeRareData);
@@ -275,22 +284,13 @@
return *m_nodeLists;
}
- using MutationObserverRegistryVector = Vector<Ref<MutationObserverRegistration>, 4>;
-
- MutationObserverRegistryVector& mutationObserverRegistry()
+ NodeMutationObserverData* mutationObserverData() { return m_mutationObserverData.get(); }
+ NodeMutationObserverData& ensureMutationObserverData()
{
- if (!m_mutationObserverRegistry)
- m_mutationObserverRegistry = makeUnique<MutationObserverRegistryVector>();
- return *m_mutationObserverRegistry;
+ if (!m_mutationObserverData)
+ m_mutationObserverData = makeUnique<NodeMutationObserverData>();
+ return *m_mutationObserverData;
}
- MutationObserverRegistryVector* mutationObserverRegistryIfExists()
- {
- return m_mutationObserverRegistry.get();
- }
- HashSet<Ref<MutationObserverRegistration>>& transientMutationObserverRegistry()
- {
- return m_transientMutationObserverRegistry;
- }
#if DUMP_NODE_STATISTICS
OptionSet<UseType> useTypes() const
@@ -298,7 +298,7 @@
OptionSet<UseType> result;
if (m_nodeLists)
result.add(UseType::NodeList);
- if (m_mutationObserverRegistry || m_transientMutationObserverRegistry.capacity())
+ if (m_mutationObserverData)
result.add(UseType::MutationObserver);
return result;
}
@@ -313,8 +313,7 @@
bool m_isElementRareData;
std::unique_ptr<NodeListsNodeData> m_nodeLists;
- std::unique_ptr<MutationObserverRegistryVector> m_mutationObserverRegistry;
- HashSet<Ref<MutationObserverRegistration>> m_transientMutationObserverRegistry;
+ std::unique_ptr<NodeMutationObserverData> m_mutationObserverData;
};
template<> struct NodeListTypeIdentifier<NameNodeList> {