Diff
Modified: trunk/Source/WebCore/ChangeLog (277381 => 277382)
--- trunk/Source/WebCore/ChangeLog 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/ChangeLog 2021-05-12 18:40:38 UTC (rev 277382)
@@ -1,3 +1,97 @@
+2021-05-12 Alex Christensen <[email protected]>
+
+ Use HashSet<RefPtr<Node>> instead of HashSet<Node*>
+ https://bugs.webkit.org/show_bug.cgi?id=220464
+
+ Reviewed by Chris Dumez and Ryosuke Niwa.
+
+ This makes us more resistent to lifetime bugs.
+
+ liveNodeSet() and ignoreSet() need to be WeakHashSet, and they are only used in debug builds so that's fine.
+
+ MutationObserver::observedNodes() is not called on the main thread, but it's called during garbage collection.
+ I replaced it with MutationObserver::isReachableFromOpaqueRoots which eliminates the HashSet allocation and hashing,
+ and it can return true early if it finds a contained opaque root, resulting in less work in several ways.
+ This should only increase our performance slightly while getting the same behavior.
+
+ * accessibility/AXObjectCache.cpp:
+ (WebCore::conditionallyAddNodeToFilterList):
+ (WebCore::filterVectorPairForRemoval):
+ (WebCore::filterMapForRemoval):
+ (WebCore::filterListForRemoval):
+ (WebCore::AXObjectCache::prepareForDocumentDestruction):
+ * bindings/js/JSMutationObserverCustom.cpp:
+ (WebCore::JSMutationObserverOwner::isReachableFromOpaqueRoots):
+ * dom/MutationObserver.cpp:
+ (WebCore::MutationObserver::isReachableFromOpaqueRoots const):
+ (WebCore:: const): Deleted.
+ * dom/MutationObserver.h:
+ * dom/MutationObserverRegistration.cpp:
+ (WebCore::MutationObserverRegistration::isReachableFromOpaqueRoots const):
+ (WebCore::MutationObserverRegistration::addRegistrationNodesToSet const): Deleted.
+ * dom/MutationObserverRegistration.h:
+ * dom/Node.cpp:
+ (WebCore::liveNodeSet):
+ (WebCore::stringForRareDataUseType):
+ (WebCore::Node::dumpStatistics):
+ (WebCore::ignoreSet):
+ (WebCore::Node::trackForDebugging):
+ (WebCore::Node::~Node):
+ * editing/AppendNodeCommand.cpp:
+ (WebCore::AppendNodeCommand::getNodesInCommand):
+ * editing/AppendNodeCommand.h:
+ * editing/CompositeEditCommand.cpp:
+ (WebCore::EditCommandComposition::getNodesInCommand):
+ * editing/CompositeEditCommand.h:
+ * editing/DeleteFromTextNodeCommand.cpp:
+ (WebCore::DeleteFromTextNodeCommand::getNodesInCommand):
+ * editing/DeleteFromTextNodeCommand.h:
+ * editing/EditCommand.cpp:
+ (WebCore::SimpleEditCommand::addNodeAndDescendants):
+ * editing/EditCommand.h:
+ * editing/InsertIntoTextNodeCommand.cpp:
+ (WebCore::InsertIntoTextNodeCommand::getNodesInCommand):
+ * editing/InsertIntoTextNodeCommand.h:
+ * editing/InsertNodeBeforeCommand.cpp:
+ (WebCore::InsertNodeBeforeCommand::getNodesInCommand):
+ * editing/InsertNodeBeforeCommand.h:
+ * editing/MergeIdenticalElementsCommand.cpp:
+ (WebCore::MergeIdenticalElementsCommand::getNodesInCommand):
+ * editing/MergeIdenticalElementsCommand.h:
+ * editing/RemoveNodeCommand.cpp:
+ (WebCore::RemoveNodeCommand::getNodesInCommand):
+ * editing/RemoveNodeCommand.h:
+ * editing/ReplaceNodeWithSpanCommand.cpp:
+ (WebCore::ReplaceNodeWithSpanCommand::getNodesInCommand):
+ * editing/ReplaceNodeWithSpanCommand.h:
+ * editing/SetNodeAttributeCommand.cpp:
+ (WebCore::SetNodeAttributeCommand::getNodesInCommand):
+ * editing/SetNodeAttributeCommand.h:
+ * editing/SetSelectionCommand.h:
+ * editing/SpellingCorrectionCommand.cpp:
+ * editing/SplitElementCommand.cpp:
+ (WebCore::SplitElementCommand::getNodesInCommand):
+ * editing/SplitElementCommand.h:
+ * editing/SplitTextNodeCommand.cpp:
+ (WebCore::SplitTextNodeCommand::getNodesInCommand):
+ * editing/SplitTextNodeCommand.h:
+ * editing/WrapContentsInDummySpanCommand.cpp:
+ (WebCore::WrapContentsInDummySpanCommand::getNodesInCommand):
+ * editing/WrapContentsInDummySpanCommand.h:
+ * editing/cocoa/HTMLConverter.mm:
+ (HTMLConverterCaches::cacheAncestorsOfStartToBeConverted):
+ * inspector/agents/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::highlightSelector):
+ * xml/XPathFunctions.cpp:
+ (WebCore::XPath::FunId::evaluate const):
+ * xml/XPathNodeSet.cpp:
+ (WebCore::XPath::sortBlock):
+ (WebCore::XPath::NodeSet::traversalSort const):
+ * xml/XPathPath.cpp:
+ (WebCore::XPath::LocationPath::evaluate const):
+ * xml/XPathPredicate.cpp:
+ (WebCore::XPath::Union::evaluate const):
+
2021-05-12 Jer Noble <[email protected]>
HTMLMediaElement::mediaLoadingFailedFatally() does direct dispatch of events; should enqueue
Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (277381 => 277382)
--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -3080,14 +3080,14 @@
return result;
}
-static void conditionallyAddNodeToFilterList(Node* node, const Document& document, HashSet<Node*>& nodesToRemove)
+static void conditionallyAddNodeToFilterList(Node* node, const Document& document, HashSet<Ref<Node>>& nodesToRemove)
{
if (node && (!node->isConnected() || &node->document() == &document))
- nodesToRemove.add(node);
+ nodesToRemove.add(*node);
}
template<typename T>
-static void filterVectorPairForRemoval(const Vector<std::pair<T, T>>& list, const Document& document, HashSet<Node*>& nodesToRemove)
+static void filterVectorPairForRemoval(const Vector<std::pair<T, T>>& list, const Document& document, HashSet<Ref<Node>>& nodesToRemove)
{
for (auto& entry : list) {
conditionallyAddNodeToFilterList(entry.first, document, nodesToRemove);
@@ -3096,7 +3096,7 @@
}
template<typename T, typename U>
-static void filterMapForRemoval(const HashMap<T, U>& list, const Document& document, HashSet<Node*>& nodesToRemove)
+static void filterMapForRemoval(const HashMap<T, U>& list, const Document& document, HashSet<Ref<Node>>& nodesToRemove)
{
for (auto& entry : list)
conditionallyAddNodeToFilterList(entry.key, document, nodesToRemove);
@@ -3103,7 +3103,7 @@
}
template<typename T>
-static void filterListForRemoval(const ListHashSet<T>& list, const Document& document, HashSet<Node*>& nodesToRemove)
+static void filterListForRemoval(const ListHashSet<T>& list, const Document& document, HashSet<Ref<Node>>& nodesToRemove)
{
for (auto* node : list)
conditionallyAddNodeToFilterList(node, document, nodesToRemove);
@@ -3111,7 +3111,7 @@
void AXObjectCache::prepareForDocumentDestruction(const Document& document)
{
- HashSet<Node*> nodesToRemove;
+ HashSet<Ref<Node>> nodesToRemove;
filterListForRemoval(m_textMarkerNodes, document, nodesToRemove);
filterListForRemoval(m_modalElementsSet, document, nodesToRemove);
filterListForRemoval(m_deferredTextChangedList, document, nodesToRemove);
@@ -3120,8 +3120,8 @@
filterMapForRemoval(m_deferredAttributeChange, document, nodesToRemove);
filterVectorPairForRemoval(m_deferredFocusedNodeChange, document, nodesToRemove);
- for (auto* node : nodesToRemove)
- remove(*node);
+ for (auto& node : nodesToRemove)
+ remove(node);
}
bool AXObjectCache::nodeIsTextControl(const Node* node)
Modified: trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp (277381 => 277382)
--- trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -49,12 +49,10 @@
bool JSMutationObserverOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, AbstractSlotVisitor& visitor, const char**reason)
{
- for (auto* node : jsCast<JSMutationObserver*>(handle.slot()->asCell())->wrapped().observedNodes()) {
- if (visitor.containsOpaqueRoot(root(node))) {
- if (UNLIKELY(reason))
- *reason = "Reachable from observed nodes";
- return true;
- }
+ if (jsCast<JSMutationObserver*>(handle.slot()->asCell())->wrapped().isReachableFromOpaqueRoots(visitor)) {
+ if (UNLIKELY(reason))
+ *reason = "Reachable from observed nodes";
+ return true;
}
return false;
}
Modified: trunk/Source/WebCore/dom/MutationObserver.cpp (277381 => 277382)
--- trunk/Source/WebCore/dom/MutationObserver.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/dom/MutationObserver.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -169,12 +169,13 @@
eventLoop->queueMutationObserverCompoundMicrotask();
}
-HashSet<Node*> MutationObserver::observedNodes() const
+bool MutationObserver::isReachableFromOpaqueRoots(JSC::AbstractSlotVisitor& visitor) const
{
- HashSet<Node*> observedNodes;
- for (auto* registration : m_registrations)
- registration->addRegistrationNodesToSet(observedNodes);
- return observedNodes;
+ for (auto* registration : m_registrations) {
+ if (registration->isReachableFromOpaqueRoots(visitor))
+ return true;
+ }
+ return false;
}
bool MutationObserver::canDeliver()
Modified: trunk/Source/WebCore/dom/MutationObserver.h (277381 => 277382)
--- trunk/Source/WebCore/dom/MutationObserver.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/dom/MutationObserver.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -38,6 +38,10 @@
#include <wtf/IsoMalloc.h>
#include <wtf/Vector.h>
+namespace JSC {
+class AbstractSlotVisitor;
+}
+
namespace WebCore {
class Document;
@@ -101,7 +105,7 @@
void setHasTransientRegistration(Document&);
bool canDeliver();
- HashSet<Node*> observedNodes() const;
+ bool isReachableFromOpaqueRoots(JSC::AbstractSlotVisitor&) const;
MutationCallback& callback() const { return m_callback.get(); }
Modified: trunk/Source/WebCore/dom/MutationObserverRegistration.cpp (277381 => 277382)
--- trunk/Source/WebCore/dom/MutationObserverRegistration.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/dom/MutationObserverRegistration.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -33,6 +33,7 @@
#include "MutationObserverRegistration.h"
#include "Document.h"
+#include "JSNodeCustom.h"
#include "QualifiedName.h"
namespace WebCore {
@@ -112,13 +113,20 @@
return m_attributeFilter.contains(attributeName->localName());
}
-void MutationObserverRegistration::addRegistrationNodesToSet(HashSet<Node*>& nodes) const
+bool MutationObserverRegistration::isReachableFromOpaqueRoots(JSC::AbstractSlotVisitor& visitor) const
{
- nodes.add(&m_node);
+ if (visitor.containsOpaqueRoot(root(m_node)))
+ return true;
+
if (!m_transientRegistrationNodes)
- return;
- for (auto& node : *m_transientRegistrationNodes)
- nodes.add(node.ptr());
+ return false;
+
+ for (auto& node : *m_transientRegistrationNodes) {
+ if (visitor.containsOpaqueRoot(root(node)))
+ return true;
+ }
+
+ return false;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/MutationObserverRegistration.h (277381 => 277382)
--- trunk/Source/WebCore/dom/MutationObserverRegistration.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/dom/MutationObserverRegistration.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -36,6 +36,10 @@
#include <wtf/text/AtomString.h>
#include <wtf/text/AtomStringHash.h>
+namespace JSC {
+class AbstractSlotVisitor;
+}
+
namespace WebCore {
class QualifiedName;
@@ -59,7 +63,7 @@
MutationRecordDeliveryOptions deliveryOptions() const { return m_options & (MutationObserver::AttributeOldValue | MutationObserver::CharacterDataOldValue); }
MutationObserverOptions mutationTypes() const { return m_options & MutationObserver::AllMutationTypes; }
- void addRegistrationNodesToSet(HashSet<Node*>&) const;
+ bool isReachableFromOpaqueRoots(JSC::AbstractSlotVisitor&) const;
private:
Ref<MutationObserver> m_observer;
Modified: trunk/Source/WebCore/dom/Node.cpp (277381 => 277382)
--- trunk/Source/WebCore/dom/Node.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/dom/Node.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -95,9 +95,9 @@
using namespace HTMLNames;
#if DUMP_NODE_STATISTICS
-static HashSet<Node*>& liveNodeSet()
+static WeakHashSet<Node>& liveNodeSet()
{
- static NeverDestroyed<HashSet<Node*>> liveNodes;
+ static NeverDestroyed<WeakHashSet<Node>> liveNodes;
return liveNodes;
}
@@ -104,8 +104,6 @@
static const char* stringForRareDataUseType(NodeRareData::UseType useType)
{
switch (useType) {
- case NodeRareData::UseType::ConnectedFrameCount:
- return "ConnectedFrameCount";
case NodeRareData::UseType::NodeList:
return "NodeList";
case NodeRareData::UseType::MutationObserver:
@@ -175,15 +173,15 @@
HashMap<uint16_t, size_t> rareDataSingleUseTypeCounts;
size_t mixedRareDataUseCount = 0;
- for (auto* node : liveNodeSet()) {
- if (node->hasRareData()) {
+ for (auto& node : liveNodeSet()) {
+ if (node.hasRareData()) {
++nodesWithRareData;
- if (is<Element>(*node)) {
+ if (is<Element>(node)) {
++elementsWithRareData;
- if (downcast<Element>(*node).hasNamedNodeMap())
+ if (downcast<Element>(node).hasNamedNodeMap())
++elementsWithNamedNodeMap;
}
- auto* rareData = node->rareData();
+ auto* rareData = node.rareData();
auto useTypes = is<Element>(node) ? static_cast<ElementRareData*>(rareData)->useTypes() : rareData->useTypes();
unsigned useTypeCount = 0;
for (auto type : useTypes) {
@@ -197,12 +195,12 @@
mixedRareDataUseCount++;
}
- switch (node->nodeType()) {
+ switch (node.nodeType()) {
case ELEMENT_NODE: {
++elementNodes;
// Tag stats
- Element& element = downcast<Element>(*node);
+ Element& element = downcast<Element>(node);
HashMap<String, size_t>::AddResult result = perTagCount.add(element.tagName(), 1);
if (!result.isNewEntry)
result.iterator->value++;
@@ -248,7 +246,7 @@
break;
}
case DOCUMENT_FRAGMENT_NODE: {
- if (node->isShadowRoot())
+ if (node.isShadowRoot())
++shadowRootNodes;
else
++fragmentNodes;
@@ -257,7 +255,7 @@
}
}
- printf("Number of Nodes: %d\n\n", liveNodeSet().size());
+ printf("Number of Nodes: %d\n\n", liveNodeSet().computeSize());
printf("Number of Nodes with RareData: %zu\n", nodesWithRareData);
printf(" Mixed use: %zu\n", mixedRareDataUseCount);
for (auto it : rareDataSingleUseTypeCounts)
@@ -295,10 +293,9 @@
#ifndef NDEBUG
static bool shouldIgnoreLeaks = false;
-static HashSet<Node*>& ignoreSet()
+static WeakHashSet<Node>& ignoreSet()
{
- static NeverDestroyed<HashSet<Node*>> ignore;
-
+ static NeverDestroyed<WeakHashSet<Node>> ignore;
return ignore;
}
@@ -322,13 +319,13 @@
{
#ifndef NDEBUG
if (shouldIgnoreLeaks)
- ignoreSet().add(this);
+ ignoreSet().add(*this);
else
nodeCounter.increment();
#endif
#if DUMP_NODE_STATISTICS
- liveNodeSet().add(this);
+ liveNodeSet().add(*this);
#endif
}
@@ -353,12 +350,12 @@
ASSERT(!m_adoptionIsRequired);
#ifndef NDEBUG
- if (!ignoreSet().remove(this))
+ if (!ignoreSet().remove(*this))
nodeCounter.decrement();
#endif
#if DUMP_NODE_STATISTICS
- liveNodeSet().remove(this);
+ liveNodeSet().remove(*this);
#endif
RELEASE_ASSERT(!renderer());
Modified: trunk/Source/WebCore/editing/AppendNodeCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/AppendNodeCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/AppendNodeCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -61,7 +61,7 @@
}
#ifndef NDEBUG
-void AppendNodeCommand::getNodesInCommand(HashSet<Node*>& nodes)
+void AppendNodeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
{
addNodeAndDescendants(m_parent.ptr(), nodes);
addNodeAndDescendants(m_node.ptr(), nodes);
Modified: trunk/Source/WebCore/editing/AppendNodeCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/AppendNodeCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/AppendNodeCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -43,7 +43,7 @@
void doUnapply() override;
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override;
+ void getNodesInCommand(HashSet<Ref<Node>>&) override;
#endif
Ref<ContainerNode> m_parent;
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -319,7 +319,7 @@
}
#ifndef NDEBUG
-void EditCommandComposition::getNodesInCommand(HashSet<Node*>& nodes)
+void EditCommandComposition::getNodesInCommand(HashSet<Ref<Node>>& nodes)
{
for (auto& command : m_commands)
command->getNodesInCommand(nodes);
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/CompositeEditCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -84,7 +84,7 @@
void setRangeDeletedByUnapply(const VisiblePositionIndexRange&);
#ifndef NDEBUG
- virtual void getNodesInCommand(HashSet<Node*>&);
+ virtual void getNodesInCommand(HashSet<Ref<Node>>&);
#endif
private:
Modified: trunk/Source/WebCore/editing/DeleteFromTextNodeCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/DeleteFromTextNodeCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/DeleteFromTextNodeCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -64,7 +64,7 @@
}
#ifndef NDEBUG
-void DeleteFromTextNodeCommand::getNodesInCommand(HashSet<Node*>& nodes)
+void DeleteFromTextNodeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
{
addNodeAndDescendants(m_node.ptr(), nodes);
}
Modified: trunk/Source/WebCore/editing/DeleteFromTextNodeCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/DeleteFromTextNodeCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/DeleteFromTextNodeCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -46,7 +46,7 @@
void doUnapply() override;
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override;
+ void getNodesInCommand(HashSet<Ref<Node>>&) override;
#endif
Ref<Text> m_node;
Modified: trunk/Source/WebCore/editing/EditCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/EditCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/EditCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -216,10 +216,10 @@
}
#ifndef NDEBUG
-void SimpleEditCommand::addNodeAndDescendants(Node* startNode, HashSet<Node*>& nodes)
+void SimpleEditCommand::addNodeAndDescendants(Node* startNode, HashSet<Ref<Node>>& nodes)
{
for (Node* node = startNode; node; node = NodeTraversal::next(*node, startNode))
- nodes.add(node);
+ nodes.add(*node);
}
#endif
Modified: trunk/Source/WebCore/editing/EditCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/EditCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/EditCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -94,7 +94,7 @@
virtual void doReapply(); // calls doApply()
#ifndef NDEBUG
- virtual void getNodesInCommand(HashSet<Node*>&) = 0;
+ virtual void getNodesInCommand(HashSet<Ref<Node>>&) = 0;
#endif
protected:
@@ -101,7 +101,7 @@
explicit SimpleEditCommand(Document&, EditAction = EditAction::Unspecified);
#ifndef NDEBUG
- void addNodeAndDescendants(Node*, HashSet<Node*>&);
+ void addNodeAndDescendants(Node*, HashSet<Ref<Node>>&);
#endif
private:
Modified: trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -87,7 +87,7 @@
#ifndef NDEBUG
-void InsertIntoTextNodeCommand::getNodesInCommand(HashSet<Node*>& nodes)
+void InsertIntoTextNodeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
{
addNodeAndDescendants(m_node.ptr(), nodes);
}
Modified: trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -49,7 +49,7 @@
void doReapply() override;
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override;
+ void getNodesInCommand(HashSet<Ref<Node>>&) override;
#endif
Ref<Text> m_node;
Modified: trunk/Source/WebCore/editing/InsertNodeBeforeCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/InsertNodeBeforeCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/InsertNodeBeforeCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -65,7 +65,7 @@
}
#ifndef NDEBUG
-void InsertNodeBeforeCommand::getNodesInCommand(HashSet<Node*>& nodes)
+void InsertNodeBeforeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
{
addNodeAndDescendants(m_insertChild.ptr(), nodes);
addNodeAndDescendants(m_refChild.ptr(), nodes);
Modified: trunk/Source/WebCore/editing/InsertNodeBeforeCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/InsertNodeBeforeCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/InsertNodeBeforeCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -45,7 +45,7 @@
void doUnapply() override;
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override;
+ void getNodesInCommand(HashSet<Ref<Node>>&) override;
#endif
Ref<Node> m_insertChild;
Modified: trunk/Source/WebCore/editing/MergeIdenticalElementsCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/MergeIdenticalElementsCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/MergeIdenticalElementsCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -75,7 +75,7 @@
}
#ifndef NDEBUG
-void MergeIdenticalElementsCommand::getNodesInCommand(HashSet<Node*>& nodes)
+void MergeIdenticalElementsCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
{
addNodeAndDescendants(m_element1.ptr(), nodes);
addNodeAndDescendants(m_element2.ptr(), nodes);
Modified: trunk/Source/WebCore/editing/MergeIdenticalElementsCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/MergeIdenticalElementsCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/MergeIdenticalElementsCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -43,7 +43,7 @@
void doUnapply() override;
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override;
+ void getNodesInCommand(HashSet<Ref<Node>>&) override;
#endif
Ref<Element> m_element1;
Modified: trunk/Source/WebCore/editing/RemoveNodeCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/RemoveNodeCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/RemoveNodeCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -66,7 +66,7 @@
}
#ifndef NDEBUG
-void RemoveNodeCommand::getNodesInCommand(HashSet<Node*>& nodes)
+void RemoveNodeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
{
addNodeAndDescendants(m_parent.get(), nodes);
addNodeAndDescendants(m_refChild.get(), nodes);
Modified: trunk/Source/WebCore/editing/RemoveNodeCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/RemoveNodeCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/RemoveNodeCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -43,7 +43,7 @@
void doUnapply() override;
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override;
+ void getNodesInCommand(HashSet<Ref<Node>>&) override;
#endif
Ref<Node> m_node;
Modified: trunk/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -74,7 +74,7 @@
}
#ifndef NDEBUG
-void ReplaceNodeWithSpanCommand::getNodesInCommand(HashSet<Node*>& nodes)
+void ReplaceNodeWithSpanCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
{
addNodeAndDescendants(m_elementToReplace.ptr(), nodes);
addNodeAndDescendants(m_spanElement.get(), nodes);
Modified: trunk/Source/WebCore/editing/ReplaceNodeWithSpanCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/ReplaceNodeWithSpanCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/ReplaceNodeWithSpanCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -53,7 +53,7 @@
void doUnapply() override;
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override;
+ void getNodesInCommand(HashSet<Ref<Node>>&) override;
#endif
Ref<HTMLElement> m_elementToReplace;
Modified: trunk/Source/WebCore/editing/SetNodeAttributeCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/SetNodeAttributeCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/SetNodeAttributeCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -54,7 +54,7 @@
}
#ifndef NDEBUG
-void SetNodeAttributeCommand::getNodesInCommand(HashSet<Node*>& nodes)
+void SetNodeAttributeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
{
addNodeAndDescendants(m_element.ptr(), nodes);
}
Modified: trunk/Source/WebCore/editing/SetNodeAttributeCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/SetNodeAttributeCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/SetNodeAttributeCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -44,7 +44,7 @@
void doUnapply() override;
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override;
+ void getNodesInCommand(HashSet<Ref<Node>>&) override;
#endif
Ref<Element> m_element;
Modified: trunk/Source/WebCore/editing/SetSelectionCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/SetSelectionCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/SetSelectionCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -44,7 +44,7 @@
void doUnapply() override;
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override { }
+ void getNodesInCommand(HashSet<Ref<Node>>&) override { }
#endif
OptionSet<FrameSelection::SetSelectionOption> m_options;
Modified: trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -72,7 +72,7 @@
}
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override
+ void getNodesInCommand(HashSet<Ref<Node>>&) override
{
}
#endif
Modified: trunk/Source/WebCore/editing/SplitElementCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/SplitElementCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/SplitElementCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -101,7 +101,7 @@
}
#ifndef NDEBUG
-void SplitElementCommand::getNodesInCommand(HashSet<Node*>& nodes)
+void SplitElementCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
{
addNodeAndDescendants(m_element1.get(), nodes);
addNodeAndDescendants(m_element2.ptr(), nodes);
Modified: trunk/Source/WebCore/editing/SplitElementCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/SplitElementCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/SplitElementCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -45,7 +45,7 @@
void executeApply();
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override;
+ void getNodesInCommand(HashSet<Ref<Node>>&) override;
#endif
RefPtr<Element> m_element1;
Modified: trunk/Source/WebCore/editing/SplitTextNodeCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/SplitTextNodeCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/SplitTextNodeCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -104,7 +104,7 @@
#ifndef NDEBUG
-void SplitTextNodeCommand::getNodesInCommand(HashSet<Node*>& nodes)
+void SplitTextNodeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
{
addNodeAndDescendants(m_text1.get(), nodes);
addNodeAndDescendants(m_text2.ptr(), nodes);
Modified: trunk/Source/WebCore/editing/SplitTextNodeCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/SplitTextNodeCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/SplitTextNodeCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -47,7 +47,7 @@
void insertText1AndTrimText2();
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override;
+ void getNodesInCommand(HashSet<Ref<Node>>&) override;
#endif
RefPtr<Text> m_text1;
Modified: trunk/Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp (277381 => 277382)
--- trunk/Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -79,7 +79,7 @@
}
#ifndef NDEBUG
-void WrapContentsInDummySpanCommand::getNodesInCommand(HashSet<Node*>& nodes)
+void WrapContentsInDummySpanCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
{
addNodeAndDescendants(m_element.ptr(), nodes);
addNodeAndDescendants(m_dummySpan.get(), nodes);
Modified: trunk/Source/WebCore/editing/WrapContentsInDummySpanCommand.h (277381 => 277382)
--- trunk/Source/WebCore/editing/WrapContentsInDummySpanCommand.h 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/WrapContentsInDummySpanCommand.h 2021-05-12 18:40:38 UTC (rev 277382)
@@ -47,7 +47,7 @@
void executeApply();
#ifndef NDEBUG
- void getNodesInCommand(HashSet<Node*>&) override;
+ void getNodesInCommand(HashSet<Ref<Node>>&) override;
#endif
Ref<Element> m_element;
Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm (277381 => 277382)
--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm 2021-05-12 18:40:38 UTC (rev 277382)
@@ -262,7 +262,7 @@
private:
HashMap<Element*, std::unique_ptr<ComputedStyleExtractor>> m_computedStyles;
- HashSet<Node*> m_ancestorsUnderCommonAncestor;
+ HashSet<Ref<Node>> m_ancestorsUnderCommonAncestor;
};
@interface NSTextList (WebCoreNSTextListDetails)
@@ -2284,7 +2284,7 @@
Node* ancestor = start.containerNode();
while (ancestor) {
- m_ancestorsUnderCommonAncestor.add(ancestor);
+ m_ancestorsUnderCommonAncestor.add(*ancestor);
if (ancestor == commonAncestor)
break;
ancestor = ancestor->parentInComposedTree();
Modified: trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp (277381 => 277382)
--- trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -1336,7 +1336,7 @@
SelectorChecker selectorChecker(*document);
Vector<Ref<Node>> nodeList;
- HashSet<Node*> seenNodes;
+ HashSet<Ref<Node>> seenNodes;
for (auto& descendant : composedTreeDescendants(*document)) {
if (!is<Element>(descendant))
@@ -1356,7 +1356,7 @@
context.pseudoId = pseudoId;
if (selectorChecker.match(*selector, descendantElement, context)) {
- if (seenNodes.add(&descendantElement))
+ if (seenNodes.add(descendantElement))
nodeList.append(descendantElement);
}
@@ -1366,7 +1366,7 @@
if (pseudoIDs.has(PseudoId::Before)) {
pseudoIDs.remove(PseudoId::Before);
if (auto* beforePseudoElement = descendantElement.beforePseudoElement()) {
- if (seenNodes.add(beforePseudoElement))
+ if (seenNodes.add(*beforePseudoElement))
nodeList.append(*beforePseudoElement);
}
}
@@ -1374,13 +1374,13 @@
if (pseudoIDs.has(PseudoId::After)) {
pseudoIDs.remove(PseudoId::After);
if (auto* afterPseudoElement = descendantElement.afterPseudoElement()) {
- if (seenNodes.add(afterPseudoElement))
+ if (seenNodes.add(*afterPseudoElement))
nodeList.append(*afterPseudoElement);
}
}
if (pseudoIDs) {
- if (seenNodes.add(&descendantElement))
+ if (seenNodes.add(descendantElement))
nodeList.append(descendantElement);
}
}
Modified: trunk/Source/WebCore/xml/XPathFunctions.cpp (277381 => 277382)
--- trunk/Source/WebCore/xml/XPathFunctions.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/xml/XPathFunctions.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -329,7 +329,7 @@
TreeScope& contextScope = evaluationContext().node->treeScope();
NodeSet result;
- HashSet<Node*> resultSet;
+ HashSet<Ref<Node>> resultSet;
unsigned startPos = 0;
unsigned length = idList.length();
@@ -347,7 +347,7 @@
// If there are several nodes with the same id, id() should return the first one.
// In WebKit, getElementById behaves so, too, although its behavior in this case is formally undefined.
Node* node = contextScope.getElementById(toStringView(idList).substring(startPos, endPos - startPos));
- if (node && resultSet.add(node).isNewEntry)
+ if (node && resultSet.add(*node).isNewEntry)
result.append(node);
startPos = endPos;
Modified: trunk/Source/WebCore/xml/XPathNodeSet.cpp (277381 => 277382)
--- trunk/Source/WebCore/xml/XPathNodeSet.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/xml/XPathNodeSet.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -107,7 +107,7 @@
// Children nodes of the common ancestor induce a subdivision of our node-set.
// Sort it according to this subdivision, and recursively sort each group.
- HashSet<Node*> parentNodes;
+ HashSet<RefPtr<Node>> parentNodes;
for (unsigned i = from; i < to; ++i)
parentNodes.add(parentWithDepth(commonAncestorDepth + 1, parentMatrix[i]));
@@ -192,7 +192,7 @@
void NodeSet::traversalSort() const
{
- HashSet<Node*> nodes;
+ HashSet<RefPtr<Node>> nodes;
bool containsAttributeNodes = false;
unsigned nodeCount = m_nodes.size();
Modified: trunk/Source/WebCore/xml/XPathPath.cpp (277381 => 277382)
--- trunk/Source/WebCore/xml/XPathPath.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/xml/XPathPath.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -105,7 +105,7 @@
for (auto& step : m_steps) {
NodeSet newNodes;
- HashSet<Node*> newNodesSet;
+ HashSet<RefPtr<Node>> newNodesSet;
bool needToCheckForDuplicateNodes = !nodes.subtreesAreDisjoint() || (step->axis() != Step::ChildAxis && step->axis() != Step::SelfAxis
&& step->axis() != Step::DescendantAxis && step->axis() != Step::DescendantOrSelfAxis && step->axis() != Step::AttributeAxis);
Modified: trunk/Source/WebCore/xml/XPathPredicate.cpp (277381 => 277382)
--- trunk/Source/WebCore/xml/XPathPredicate.cpp 2021-05-12 18:34:55 UTC (rev 277381)
+++ trunk/Source/WebCore/xml/XPathPredicate.cpp 2021-05-12 18:40:38 UTC (rev 277382)
@@ -241,7 +241,7 @@
NodeSet& resultSet = lhsResult.modifiableNodeSet();
const NodeSet& rhsNodes = rhs.toNodeSet();
- HashSet<Node*> nodes;
+ HashSet<RefPtr<Node>> nodes;
for (auto& result : resultSet)
nodes.add(result.get());