Changeset 277382 in webkit


Ignore:
Timestamp:
May 12, 2021, 11:40:38 AM (4 years ago)
Author:
achristensen@apple.com
Message:

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):

Location:
trunk/Source/WebCore
Files:
42 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r277379 r277382  
     12021-05-12  Alex Christensen  <achristensen@webkit.org>
     2
     3        Use HashSet<RefPtr<Node>> instead of HashSet<Node*>
     4        https://bugs.webkit.org/show_bug.cgi?id=220464
     5
     6        Reviewed by Chris Dumez and Ryosuke Niwa.
     7
     8        This makes us more resistent to lifetime bugs.
     9
     10        liveNodeSet() and ignoreSet() need to be WeakHashSet, and they are only used in debug builds so that's fine.
     11
     12        MutationObserver::observedNodes() is not called on the main thread, but it's called during garbage collection.
     13        I replaced it with MutationObserver::isReachableFromOpaqueRoots which eliminates the HashSet allocation and hashing,
     14        and it can return true early if it finds a contained opaque root, resulting in less work in several ways.
     15        This should only increase our performance slightly while getting the same behavior.
     16
     17        * accessibility/AXObjectCache.cpp:
     18        (WebCore::conditionallyAddNodeToFilterList):
     19        (WebCore::filterVectorPairForRemoval):
     20        (WebCore::filterMapForRemoval):
     21        (WebCore::filterListForRemoval):
     22        (WebCore::AXObjectCache::prepareForDocumentDestruction):
     23        * bindings/js/JSMutationObserverCustom.cpp:
     24        (WebCore::JSMutationObserverOwner::isReachableFromOpaqueRoots):
     25        * dom/MutationObserver.cpp:
     26        (WebCore::MutationObserver::isReachableFromOpaqueRoots const):
     27        (WebCore:: const): Deleted.
     28        * dom/MutationObserver.h:
     29        * dom/MutationObserverRegistration.cpp:
     30        (WebCore::MutationObserverRegistration::isReachableFromOpaqueRoots const):
     31        (WebCore::MutationObserverRegistration::addRegistrationNodesToSet const): Deleted.
     32        * dom/MutationObserverRegistration.h:
     33        * dom/Node.cpp:
     34        (WebCore::liveNodeSet):
     35        (WebCore::stringForRareDataUseType):
     36        (WebCore::Node::dumpStatistics):
     37        (WebCore::ignoreSet):
     38        (WebCore::Node::trackForDebugging):
     39        (WebCore::Node::~Node):
     40        * editing/AppendNodeCommand.cpp:
     41        (WebCore::AppendNodeCommand::getNodesInCommand):
     42        * editing/AppendNodeCommand.h:
     43        * editing/CompositeEditCommand.cpp:
     44        (WebCore::EditCommandComposition::getNodesInCommand):
     45        * editing/CompositeEditCommand.h:
     46        * editing/DeleteFromTextNodeCommand.cpp:
     47        (WebCore::DeleteFromTextNodeCommand::getNodesInCommand):
     48        * editing/DeleteFromTextNodeCommand.h:
     49        * editing/EditCommand.cpp:
     50        (WebCore::SimpleEditCommand::addNodeAndDescendants):
     51        * editing/EditCommand.h:
     52        * editing/InsertIntoTextNodeCommand.cpp:
     53        (WebCore::InsertIntoTextNodeCommand::getNodesInCommand):
     54        * editing/InsertIntoTextNodeCommand.h:
     55        * editing/InsertNodeBeforeCommand.cpp:
     56        (WebCore::InsertNodeBeforeCommand::getNodesInCommand):
     57        * editing/InsertNodeBeforeCommand.h:
     58        * editing/MergeIdenticalElementsCommand.cpp:
     59        (WebCore::MergeIdenticalElementsCommand::getNodesInCommand):
     60        * editing/MergeIdenticalElementsCommand.h:
     61        * editing/RemoveNodeCommand.cpp:
     62        (WebCore::RemoveNodeCommand::getNodesInCommand):
     63        * editing/RemoveNodeCommand.h:
     64        * editing/ReplaceNodeWithSpanCommand.cpp:
     65        (WebCore::ReplaceNodeWithSpanCommand::getNodesInCommand):
     66        * editing/ReplaceNodeWithSpanCommand.h:
     67        * editing/SetNodeAttributeCommand.cpp:
     68        (WebCore::SetNodeAttributeCommand::getNodesInCommand):
     69        * editing/SetNodeAttributeCommand.h:
     70        * editing/SetSelectionCommand.h:
     71        * editing/SpellingCorrectionCommand.cpp:
     72        * editing/SplitElementCommand.cpp:
     73        (WebCore::SplitElementCommand::getNodesInCommand):
     74        * editing/SplitElementCommand.h:
     75        * editing/SplitTextNodeCommand.cpp:
     76        (WebCore::SplitTextNodeCommand::getNodesInCommand):
     77        * editing/SplitTextNodeCommand.h:
     78        * editing/WrapContentsInDummySpanCommand.cpp:
     79        (WebCore::WrapContentsInDummySpanCommand::getNodesInCommand):
     80        * editing/WrapContentsInDummySpanCommand.h:
     81        * editing/cocoa/HTMLConverter.mm:
     82        (HTMLConverterCaches::cacheAncestorsOfStartToBeConverted):
     83        * inspector/agents/InspectorDOMAgent.cpp:
     84        (WebCore::InspectorDOMAgent::highlightSelector):
     85        * xml/XPathFunctions.cpp:
     86        (WebCore::XPath::FunId::evaluate const):
     87        * xml/XPathNodeSet.cpp:
     88        (WebCore::XPath::sortBlock):
     89        (WebCore::XPath::NodeSet::traversalSort const):
     90        * xml/XPathPath.cpp:
     91        (WebCore::XPath::LocationPath::evaluate const):
     92        * xml/XPathPredicate.cpp:
     93        (WebCore::XPath::Union::evaluate const):
     94
    1952021-05-12  Jer Noble  <jer.noble@apple.com>
    296
  • trunk/Source/WebCore/accessibility/AXObjectCache.cpp

    r277307 r277382  
    30813081}
    30823082
    3083 static void conditionallyAddNodeToFilterList(Node* node, const Document& document, HashSet<Node*>& nodesToRemove)
     3083static void conditionallyAddNodeToFilterList(Node* node, const Document& document, HashSet<Ref<Node>>& nodesToRemove)
    30843084{
    30853085    if (node && (!node->isConnected() || &node->document() == &document))
    3086         nodesToRemove.add(node);
     3086        nodesToRemove.add(*node);
    30873087}
    30883088   
    30893089template<typename T>
    3090 static void filterVectorPairForRemoval(const Vector<std::pair<T, T>>& list, const Document& document, HashSet<Node*>& nodesToRemove)
     3090static void filterVectorPairForRemoval(const Vector<std::pair<T, T>>& list, const Document& document, HashSet<Ref<Node>>& nodesToRemove)
    30913091{
    30923092    for (auto& entry : list) {
     
    30973097   
    30983098template<typename T, typename U>
    3099 static void filterMapForRemoval(const HashMap<T, U>& list, const Document& document, HashSet<Node*>& nodesToRemove)
     3099static void filterMapForRemoval(const HashMap<T, U>& list, const Document& document, HashSet<Ref<Node>>& nodesToRemove)
    31003100{
    31013101    for (auto& entry : list)
     
    31043104
    31053105template<typename T>
    3106 static void filterListForRemoval(const ListHashSet<T>& list, const Document& document, HashSet<Node*>& nodesToRemove)
     3106static void filterListForRemoval(const ListHashSet<T>& list, const Document& document, HashSet<Ref<Node>>& nodesToRemove)
    31073107{
    31083108    for (auto* node : list)
     
    31123112void AXObjectCache::prepareForDocumentDestruction(const Document& document)
    31133113{
    3114     HashSet<Node*> nodesToRemove;
     3114    HashSet<Ref<Node>> nodesToRemove;
    31153115    filterListForRemoval(m_textMarkerNodes, document, nodesToRemove);
    31163116    filterListForRemoval(m_modalElementsSet, document, nodesToRemove);
     
    31213121    filterVectorPairForRemoval(m_deferredFocusedNodeChange, document, nodesToRemove);
    31223122   
    3123     for (auto* node : nodesToRemove)
    3124         remove(*node);
     3123    for (auto& node : nodesToRemove)
     3124        remove(node);
    31253125}
    31263126   
  • trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp

    r277307 r277382  
    5050bool JSMutationObserverOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, AbstractSlotVisitor& visitor, const char**reason)
    5151{
    52     for (auto* node : jsCast<JSMutationObserver*>(handle.slot()->asCell())->wrapped().observedNodes()) {
    53         if (visitor.containsOpaqueRoot(root(node))) {
    54             if (UNLIKELY(reason))
    55                 *reason = "Reachable from observed nodes";
    56             return true;
    57         }
     52    if (jsCast<JSMutationObserver*>(handle.slot()->asCell())->wrapped().isReachableFromOpaqueRoots(visitor)) {
     53        if (UNLIKELY(reason))
     54            *reason = "Reachable from observed nodes";
     55        return true;
    5856    }
    5957    return false;
  • trunk/Source/WebCore/dom/MutationObserver.cpp

    r277307 r277382  
    170170}
    171171
    172 HashSet<Node*> MutationObserver::observedNodes() const
    173 {
    174     HashSet<Node*> observedNodes;
    175     for (auto* registration : m_registrations)
    176         registration->addRegistrationNodesToSet(observedNodes);
    177     return observedNodes;
     172bool MutationObserver::isReachableFromOpaqueRoots(JSC::AbstractSlotVisitor& visitor) const
     173{
     174    for (auto* registration : m_registrations) {
     175        if (registration->isReachableFromOpaqueRoots(visitor))
     176            return true;
     177    }
     178    return false;
    178179}
    179180
  • trunk/Source/WebCore/dom/MutationObserver.h

    r277307 r277382  
    3838#include <wtf/IsoMalloc.h>
    3939#include <wtf/Vector.h>
     40
     41namespace JSC {
     42class AbstractSlotVisitor;
     43}
    4044
    4145namespace WebCore {
     
    102106    bool canDeliver();
    103107
    104     HashSet<Node*> observedNodes() const;
     108    bool isReachableFromOpaqueRoots(JSC::AbstractSlotVisitor&) const;
    105109
    106110    MutationCallback& callback() const { return m_callback.get(); }
  • trunk/Source/WebCore/dom/MutationObserverRegistration.cpp

    r277307 r277382  
    3434
    3535#include "Document.h"
     36#include "JSNodeCustom.h"
    3637#include "QualifiedName.h"
    3738
     
    113114}
    114115
    115 void MutationObserverRegistration::addRegistrationNodesToSet(HashSet<Node*>& nodes) const
     116bool MutationObserverRegistration::isReachableFromOpaqueRoots(JSC::AbstractSlotVisitor& visitor) const
    116117{
    117     nodes.add(&m_node);
     118    if (visitor.containsOpaqueRoot(root(m_node)))
     119        return true;
     120
    118121    if (!m_transientRegistrationNodes)
    119         return;
    120     for (auto& node : *m_transientRegistrationNodes)
    121         nodes.add(node.ptr());
     122        return false;
     123
     124    for (auto& node : *m_transientRegistrationNodes) {
     125        if (visitor.containsOpaqueRoot(root(node)))
     126            return true;
     127    }
     128
     129    return false;
    122130}
    123131
  • trunk/Source/WebCore/dom/MutationObserverRegistration.h

    r277307 r277382  
    3737#include <wtf/text/AtomStringHash.h>
    3838
     39namespace JSC {
     40class AbstractSlotVisitor;
     41}
     42
    3943namespace WebCore {
    4044
     
    6064    MutationObserverOptions mutationTypes() const { return m_options & MutationObserver::AllMutationTypes; }
    6165
    62     void addRegistrationNodesToSet(HashSet<Node*>&) const;
     66    bool isReachableFromOpaqueRoots(JSC::AbstractSlotVisitor&) const;
    6367
    6468private:
  • trunk/Source/WebCore/dom/Node.cpp

    r277307 r277382  
    9696
    9797#if DUMP_NODE_STATISTICS
    98 static HashSet<Node*>& liveNodeSet()
    99 {
    100     static NeverDestroyed<HashSet<Node*>> liveNodes;
     98static WeakHashSet<Node>& liveNodeSet()
     99{
     100    static NeverDestroyed<WeakHashSet<Node>> liveNodes;
    101101    return liveNodes;
    102102}
     
    105105{
    106106    switch (useType) {
    107     case NodeRareData::UseType::ConnectedFrameCount:
    108         return "ConnectedFrameCount";
    109107    case NodeRareData::UseType::NodeList:
    110108        return "NodeList";
     
    176174    size_t mixedRareDataUseCount = 0;
    177175
    178     for (auto* node : liveNodeSet()) {
    179         if (node->hasRareData()) {
     176    for (auto& node : liveNodeSet()) {
     177        if (node.hasRareData()) {
    180178            ++nodesWithRareData;
    181             if (is<Element>(*node)) {
     179            if (is<Element>(node)) {
    182180                ++elementsWithRareData;
    183                 if (downcast<Element>(*node).hasNamedNodeMap())
     181                if (downcast<Element>(node).hasNamedNodeMap())
    184182                    ++elementsWithNamedNodeMap;
    185183            }
    186             auto* rareData = node->rareData();
     184            auto* rareData = node.rareData();
    187185            auto useTypes = is<Element>(node) ? static_cast<ElementRareData*>(rareData)->useTypes() : rareData->useTypes();
    188186            unsigned useTypeCount = 0;
     
    198196        }
    199197
    200         switch (node->nodeType()) {
     198        switch (node.nodeType()) {
    201199            case ELEMENT_NODE: {
    202200                ++elementNodes;
    203201
    204202                // Tag stats
    205                 Element& element = downcast<Element>(*node);
     203                Element& element = downcast<Element>(node);
    206204                HashMap<String, size_t>::AddResult result = perTagCount.add(element.tagName(), 1);
    207205                if (!result.isNewEntry)
     
    249247            }
    250248            case DOCUMENT_FRAGMENT_NODE: {
    251                 if (node->isShadowRoot())
     249                if (node.isShadowRoot())
    252250                    ++shadowRootNodes;
    253251                else
     
    258256    }
    259257
    260     printf("Number of Nodes: %d\n\n", liveNodeSet().size());
     258    printf("Number of Nodes: %d\n\n", liveNodeSet().computeSize());
    261259    printf("Number of Nodes with RareData: %zu\n", nodesWithRareData);
    262260    printf("  Mixed use: %zu\n", mixedRareDataUseCount);
     
    296294static bool shouldIgnoreLeaks = false;
    297295
    298 static HashSet<Node*>& ignoreSet()
    299 {
    300     static NeverDestroyed<HashSet<Node*>> ignore;
    301 
     296static WeakHashSet<Node>& ignoreSet()
     297{
     298    static NeverDestroyed<WeakHashSet<Node>> ignore;
    302299    return ignore;
    303300}
     
    323320#ifndef NDEBUG
    324321    if (shouldIgnoreLeaks)
    325         ignoreSet().add(this);
     322        ignoreSet().add(*this);
    326323    else
    327324        nodeCounter.increment();
     
    329326
    330327#if DUMP_NODE_STATISTICS
    331     liveNodeSet().add(this);
     328    liveNodeSet().add(*this);
    332329#endif
    333330}
     
    354351
    355352#ifndef NDEBUG
    356     if (!ignoreSet().remove(this))
     353    if (!ignoreSet().remove(*this))
    357354        nodeCounter.decrement();
    358355#endif
    359356
    360357#if DUMP_NODE_STATISTICS
    361     liveNodeSet().remove(this);
     358    liveNodeSet().remove(*this);
    362359#endif
    363360
  • trunk/Source/WebCore/editing/AppendNodeCommand.cpp

    r277307 r277382  
    6262
    6363#ifndef NDEBUG
    64 void AppendNodeCommand::getNodesInCommand(HashSet<Node*>& nodes)
     64void AppendNodeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
    6565{
    6666    addNodeAndDescendants(m_parent.ptr(), nodes);
  • trunk/Source/WebCore/editing/AppendNodeCommand.h

    r277307 r277382  
    4444
    4545#ifndef NDEBUG
    46     void getNodesInCommand(HashSet<Node*>&) override;
     46    void getNodesInCommand(HashSet<Ref<Node>>&) override;
    4747#endif
    4848
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r277307 r277382  
    320320
    321321#ifndef NDEBUG
    322 void EditCommandComposition::getNodesInCommand(HashSet<Node*>& nodes)
     322void EditCommandComposition::getNodesInCommand(HashSet<Ref<Node>>& nodes)
    323323{
    324324    for (auto& command : m_commands)
  • trunk/Source/WebCore/editing/CompositeEditCommand.h

    r277307 r277382  
    8585
    8686#ifndef NDEBUG
    87     virtual void getNodesInCommand(HashSet<Node*>&);
     87    virtual void getNodesInCommand(HashSet<Ref<Node>>&);
    8888#endif
    8989
  • trunk/Source/WebCore/editing/DeleteFromTextNodeCommand.cpp

    r277307 r277382  
    6565
    6666#ifndef NDEBUG
    67 void DeleteFromTextNodeCommand::getNodesInCommand(HashSet<Node*>& nodes)
     67void DeleteFromTextNodeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
    6868{
    6969    addNodeAndDescendants(m_node.ptr(), nodes);
  • trunk/Source/WebCore/editing/DeleteFromTextNodeCommand.h

    r277307 r277382  
    4747   
    4848#ifndef NDEBUG
    49     void getNodesInCommand(HashSet<Node*>&) override;
     49    void getNodesInCommand(HashSet<Ref<Node>>&) override;
    5050#endif
    5151   
  • trunk/Source/WebCore/editing/EditCommand.cpp

    r277307 r277382  
    217217
    218218#ifndef NDEBUG
    219 void SimpleEditCommand::addNodeAndDescendants(Node* startNode, HashSet<Node*>& nodes)
     219void SimpleEditCommand::addNodeAndDescendants(Node* startNode, HashSet<Ref<Node>>& nodes)
    220220{
    221221    for (Node* node = startNode; node; node = NodeTraversal::next(*node, startNode))
    222         nodes.add(node);
     222        nodes.add(*node);
    223223}
    224224#endif
  • trunk/Source/WebCore/editing/EditCommand.h

    r277307 r277382  
    9595
    9696#ifndef NDEBUG
    97     virtual void getNodesInCommand(HashSet<Node*>&) = 0;
     97    virtual void getNodesInCommand(HashSet<Ref<Node>>&) = 0;
    9898#endif
    9999
     
    102102
    103103#ifndef NDEBUG
    104     void addNodeAndDescendants(Node*, HashSet<Node*>&);
     104    void addNodeAndDescendants(Node*, HashSet<Ref<Node>>&);
    105105#endif
    106106
  • trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.cpp

    r277307 r277382  
    8888#ifndef NDEBUG
    8989
    90 void InsertIntoTextNodeCommand::getNodesInCommand(HashSet<Node*>& nodes)
     90void InsertIntoTextNodeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
    9191{
    9292    addNodeAndDescendants(m_node.ptr(), nodes);
  • trunk/Source/WebCore/editing/InsertIntoTextNodeCommand.h

    r277307 r277382  
    5050   
    5151#ifndef NDEBUG
    52     void getNodesInCommand(HashSet<Node*>&) override;
     52    void getNodesInCommand(HashSet<Ref<Node>>&) override;
    5353#endif
    5454   
  • trunk/Source/WebCore/editing/InsertNodeBeforeCommand.cpp

    r277307 r277382  
    6666
    6767#ifndef NDEBUG
    68 void InsertNodeBeforeCommand::getNodesInCommand(HashSet<Node*>& nodes)
     68void InsertNodeBeforeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
    6969{
    7070    addNodeAndDescendants(m_insertChild.ptr(), nodes);
  • trunk/Source/WebCore/editing/InsertNodeBeforeCommand.h

    r277307 r277382  
    4646
    4747#ifndef NDEBUG
    48     void getNodesInCommand(HashSet<Node*>&) override;
     48    void getNodesInCommand(HashSet<Ref<Node>>&) override;
    4949#endif
    5050
  • trunk/Source/WebCore/editing/MergeIdenticalElementsCommand.cpp

    r277307 r277382  
    7676
    7777#ifndef NDEBUG
    78 void MergeIdenticalElementsCommand::getNodesInCommand(HashSet<Node*>& nodes)
     78void MergeIdenticalElementsCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
    7979{
    8080    addNodeAndDescendants(m_element1.ptr(), nodes);
  • trunk/Source/WebCore/editing/MergeIdenticalElementsCommand.h

    r277307 r277382  
    4444   
    4545#ifndef NDEBUG
    46     void getNodesInCommand(HashSet<Node*>&) override;
     46    void getNodesInCommand(HashSet<Ref<Node>>&) override;
    4747#endif
    4848   
  • trunk/Source/WebCore/editing/RemoveNodeCommand.cpp

    r277307 r277382  
    6767
    6868#ifndef NDEBUG
    69 void RemoveNodeCommand::getNodesInCommand(HashSet<Node*>& nodes)
     69void RemoveNodeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
    7070{
    7171    addNodeAndDescendants(m_parent.get(), nodes);
  • trunk/Source/WebCore/editing/RemoveNodeCommand.h

    r277307 r277382  
    4444
    4545#ifndef NDEBUG
    46     void getNodesInCommand(HashSet<Node*>&) override;
     46    void getNodesInCommand(HashSet<Ref<Node>>&) override;
    4747#endif
    4848
  • trunk/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp

    r277307 r277382  
    7575
    7676#ifndef NDEBUG
    77 void ReplaceNodeWithSpanCommand::getNodesInCommand(HashSet<Node*>& nodes)
     77void ReplaceNodeWithSpanCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
    7878{
    7979    addNodeAndDescendants(m_elementToReplace.ptr(), nodes);
  • trunk/Source/WebCore/editing/ReplaceNodeWithSpanCommand.h

    r277307 r277382  
    5454   
    5555#ifndef NDEBUG
    56     void getNodesInCommand(HashSet<Node*>&) override;
     56    void getNodesInCommand(HashSet<Ref<Node>>&) override;
    5757#endif
    5858
  • trunk/Source/WebCore/editing/SetNodeAttributeCommand.cpp

    r277307 r277382  
    5555
    5656#ifndef NDEBUG
    57 void SetNodeAttributeCommand::getNodesInCommand(HashSet<Node*>& nodes)
     57void SetNodeAttributeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
    5858{
    5959    addNodeAndDescendants(m_element.ptr(), nodes);
  • trunk/Source/WebCore/editing/SetNodeAttributeCommand.h

    r277307 r277382  
    4545
    4646#ifndef NDEBUG
    47     void getNodesInCommand(HashSet<Node*>&) override;
     47    void getNodesInCommand(HashSet<Ref<Node>>&) override;
    4848#endif
    4949
  • trunk/Source/WebCore/editing/SetSelectionCommand.h

    r277307 r277382  
    4545
    4646#ifndef NDEBUG
    47     void getNodesInCommand(HashSet<Node*>&) override { }
     47    void getNodesInCommand(HashSet<Ref<Node>>&) override { }
    4848#endif
    4949
  • trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp

    r277307 r277382  
    7373
    7474#ifndef NDEBUG
    75     void getNodesInCommand(HashSet<Node*>&) override
     75    void getNodesInCommand(HashSet<Ref<Node>>&) override
    7676    {
    7777    }
  • trunk/Source/WebCore/editing/SplitElementCommand.cpp

    r277307 r277382  
    102102
    103103#ifndef NDEBUG
    104 void SplitElementCommand::getNodesInCommand(HashSet<Node*>& nodes)
     104void SplitElementCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
    105105{
    106106    addNodeAndDescendants(m_element1.get(), nodes);
  • trunk/Source/WebCore/editing/SplitElementCommand.h

    r277307 r277382  
    4646
    4747#ifndef NDEBUG
    48     void getNodesInCommand(HashSet<Node*>&) override;
     48    void getNodesInCommand(HashSet<Ref<Node>>&) override;
    4949#endif
    5050
  • trunk/Source/WebCore/editing/SplitTextNodeCommand.cpp

    r277307 r277382  
    105105#ifndef NDEBUG
    106106
    107 void SplitTextNodeCommand::getNodesInCommand(HashSet<Node*>& nodes)
     107void SplitTextNodeCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
    108108{
    109109    addNodeAndDescendants(m_text1.get(), nodes);
  • trunk/Source/WebCore/editing/SplitTextNodeCommand.h

    r277307 r277382  
    4848   
    4949#ifndef NDEBUG
    50     void getNodesInCommand(HashSet<Node*>&) override;
     50    void getNodesInCommand(HashSet<Ref<Node>>&) override;
    5151#endif
    5252
  • trunk/Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp

    r277307 r277382  
    8080
    8181#ifndef NDEBUG
    82 void WrapContentsInDummySpanCommand::getNodesInCommand(HashSet<Node*>& nodes)
     82void WrapContentsInDummySpanCommand::getNodesInCommand(HashSet<Ref<Node>>& nodes)
    8383{
    8484    addNodeAndDescendants(m_element.ptr(), nodes);
  • trunk/Source/WebCore/editing/WrapContentsInDummySpanCommand.h

    r277307 r277382  
    4848
    4949#ifndef NDEBUG
    50     void getNodesInCommand(HashSet<Node*>&) override;
     50    void getNodesInCommand(HashSet<Ref<Node>>&) override;
    5151#endif
    5252
  • trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm

    r277307 r277382  
    263263private:
    264264    HashMap<Element*, std::unique_ptr<ComputedStyleExtractor>> m_computedStyles;
    265     HashSet<Node*> m_ancestorsUnderCommonAncestor;
     265    HashSet<Ref<Node>> m_ancestorsUnderCommonAncestor;
    266266};
    267267
     
    22852285
    22862286    while (ancestor) {
    2287         m_ancestorsUnderCommonAncestor.add(ancestor);
     2287        m_ancestorsUnderCommonAncestor.add(*ancestor);
    22882288        if (ancestor == commonAncestor)
    22892289            break;
  • trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp

    r277307 r277382  
    13371337
    13381338    Vector<Ref<Node>> nodeList;
    1339     HashSet<Node*> seenNodes;
     1339    HashSet<Ref<Node>> seenNodes;
    13401340
    13411341    for (auto& descendant : composedTreeDescendants(*document)) {
     
    13571357
    13581358            if (selectorChecker.match(*selector, descendantElement, context)) {
    1359                 if (seenNodes.add(&descendantElement))
     1359                if (seenNodes.add(descendantElement))
    13601360                    nodeList.append(descendantElement);
    13611361            }
     
    13671367                    pseudoIDs.remove(PseudoId::Before);
    13681368                    if (auto* beforePseudoElement = descendantElement.beforePseudoElement()) {
    1369                         if (seenNodes.add(beforePseudoElement))
     1369                        if (seenNodes.add(*beforePseudoElement))
    13701370                            nodeList.append(*beforePseudoElement);
    13711371                    }
     
    13751375                    pseudoIDs.remove(PseudoId::After);
    13761376                    if (auto* afterPseudoElement = descendantElement.afterPseudoElement()) {
    1377                         if (seenNodes.add(afterPseudoElement))
     1377                        if (seenNodes.add(*afterPseudoElement))
    13781378                            nodeList.append(*afterPseudoElement);
    13791379                    }
     
    13811381
    13821382                if (pseudoIDs) {
    1383                     if (seenNodes.add(&descendantElement))
     1383                    if (seenNodes.add(descendantElement))
    13841384                        nodeList.append(descendantElement);
    13851385                }
  • trunk/Source/WebCore/xml/XPathFunctions.cpp

    r277307 r277382  
    330330    TreeScope& contextScope = evaluationContext().node->treeScope();
    331331    NodeSet result;
    332     HashSet<Node*> resultSet;
     332    HashSet<Ref<Node>> resultSet;
    333333
    334334    unsigned startPos = 0;
     
    348348        // In WebKit, getElementById behaves so, too, although its behavior in this case is formally undefined.
    349349        Node* node = contextScope.getElementById(toStringView(idList).substring(startPos, endPos - startPos));
    350         if (node && resultSet.add(node).isNewEntry)
     350        if (node && resultSet.add(*node).isNewEntry)
    351351            result.append(node);
    352352       
  • trunk/Source/WebCore/xml/XPathNodeSet.cpp

    r277307 r277382  
    108108    // Children nodes of the common ancestor induce a subdivision of our node-set.
    109109    // Sort it according to this subdivision, and recursively sort each group.
    110     HashSet<Node*> parentNodes;
     110    HashSet<RefPtr<Node>> parentNodes;
    111111    for (unsigned i = from; i < to; ++i)
    112112        parentNodes.add(parentWithDepth(commonAncestorDepth + 1, parentMatrix[i]));
     
    193193void NodeSet::traversalSort() const
    194194{
    195     HashSet<Node*> nodes;
     195    HashSet<RefPtr<Node>> nodes;
    196196    bool containsAttributeNodes = false;
    197197
  • trunk/Source/WebCore/xml/XPathPath.cpp

    r277307 r277382  
    106106    for (auto& step : m_steps) {
    107107        NodeSet newNodes;
    108         HashSet<Node*> newNodesSet;
     108        HashSet<RefPtr<Node>> newNodesSet;
    109109
    110110        bool needToCheckForDuplicateNodes = !nodes.subtreesAreDisjoint() || (step->axis() != Step::ChildAxis && step->axis() != Step::SelfAxis
  • trunk/Source/WebCore/xml/XPathPredicate.cpp

    r277307 r277382  
    242242    const NodeSet& rhsNodes = rhs.toNodeSet();
    243243
    244     HashSet<Node*> nodes;
     244    HashSet<RefPtr<Node>> nodes;
    245245    for (auto& result : resultSet)
    246246        nodes.add(result.get());
Note: See TracChangeset for help on using the changeset viewer.