Changeset 195243 in webkit


Ignore:
Timestamp:
Jan 18, 2016 6:56:34 PM (8 years ago)
Author:
Gyuyoung Kim
Message:

Reduce PassRefPtr uses in dom - 3
https://bugs.webkit.org/show_bug.cgi?id=153055

Reviewed by Darin Adler.

Third patch to reduce uses of PassRefPtr in WebCore/dom.

  • dom/MutationObserverInterestGroup.cpp:

(WebCore::MutationObserverInterestGroup::enqueueMutationRecord):

  • dom/MutationRecord.cpp:

(WebCore::MutationRecord::createChildList):
(WebCore::MutationRecord::createAttributes):
(WebCore::MutationRecord::createCharacterData):
(WebCore::MutationRecord::createWithNullOldValue):

  • dom/MutationRecord.h:
  • dom/NamedFlowCollection.cpp:

(WebCore::NamedFlowCollection::createCSSOMSnapshot):

  • dom/NamedFlowCollection.h:
  • dom/PendingScript.cpp:

(WebCore::PendingScript::releaseElementAndClear):

  • dom/PendingScript.h:
  • dom/ScriptRunner.h:
  • dom/SecurityContext.h:
  • dom/ShadowRoot.cpp:

(WebCore::ShadowRoot::cloneNode):

  • dom/ShadowRoot.h:
  • dom/SpaceSplitString.cpp:

(WebCore::SpaceSplitStringData::create):

  • dom/SpaceSplitString.h:
  • dom/TreeWalker.cpp:

(WebCore::TreeWalker::setCurrent):
(WebCore::TreeWalker::parentNode):
(WebCore::TreeWalker::previousNode):
(WebCore::TreeWalker::nextNode):

  • dom/TreeWalker.h:
  • dom/default/PlatformMessagePortChannel.cpp:

(WebCore::PlatformMessagePortChannel::entangledChannel):

  • dom/default/PlatformMessagePortChannel.h:
Location:
trunk/Source/WebCore
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r195240 r195243  
     12016-01-18  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
     2
     3        Reduce PassRefPtr uses in dom - 3
     4        https://bugs.webkit.org/show_bug.cgi?id=153055
     5
     6        Reviewed by Darin Adler.
     7
     8        Third patch to reduce uses of PassRefPtr in WebCore/dom.
     9
     10        * dom/MutationObserverInterestGroup.cpp:
     11        (WebCore::MutationObserverInterestGroup::enqueueMutationRecord):
     12        * dom/MutationRecord.cpp:
     13        (WebCore::MutationRecord::createChildList):
     14        (WebCore::MutationRecord::createAttributes):
     15        (WebCore::MutationRecord::createCharacterData):
     16        (WebCore::MutationRecord::createWithNullOldValue):
     17        * dom/MutationRecord.h:
     18        * dom/NamedFlowCollection.cpp:
     19        (WebCore::NamedFlowCollection::createCSSOMSnapshot):
     20        * dom/NamedFlowCollection.h:
     21        * dom/PendingScript.cpp:
     22        (WebCore::PendingScript::releaseElementAndClear):
     23        * dom/PendingScript.h:
     24        * dom/ScriptRunner.h:
     25        * dom/SecurityContext.h:
     26        * dom/ShadowRoot.cpp:
     27        (WebCore::ShadowRoot::cloneNode):
     28        * dom/ShadowRoot.h:
     29        * dom/SpaceSplitString.cpp:
     30        (WebCore::SpaceSplitStringData::create):
     31        * dom/SpaceSplitString.h:
     32        * dom/TreeWalker.cpp:
     33        (WebCore::TreeWalker::setCurrent):
     34        (WebCore::TreeWalker::parentNode):
     35        (WebCore::TreeWalker::previousNode):
     36        (WebCore::TreeWalker::nextNode):
     37        * dom/TreeWalker.h:
     38        * dom/default/PlatformMessagePortChannel.cpp:
     39        (WebCore::PlatformMessagePortChannel::entangledChannel):
     40        * dom/default/PlatformMessagePortChannel.h:
     41
    1422016-01-18  Nan Wang  <n_wang@apple.com>
    243
  • trunk/Source/WebCore/dom/MutationObserverInterestGroup.cpp

    r185994 r195243  
    7979                mutationWithNullOldValue = mutation;
    8080            else
    81                 mutationWithNullOldValue = MutationRecord::createWithNullOldValue(mutation).get();
     81                mutationWithNullOldValue = MutationRecord::createWithNullOldValue(*mutation).ptr();
    8282        }
    8383        observer->enqueueMutationRecord(mutationWithNullOldValue);
  • trunk/Source/WebCore/dom/MutationRecord.cpp

    r194819 r195243  
    125125class MutationRecordWithNullOldValue : public MutationRecord {
    126126public:
    127     MutationRecordWithNullOldValue(PassRefPtr<MutationRecord> record)
     127    MutationRecordWithNullOldValue(MutationRecord& record)
    128128        : m_record(record)
    129129    {
     
    142142    virtual String oldValue() override { return String(); }
    143143
    144     RefPtr<MutationRecord> m_record;
     144    Ref<MutationRecord> m_record;
    145145};
    146146
     
    165165} // namespace
    166166
    167 PassRefPtr<MutationRecord> MutationRecord::createChildList(ContainerNode& target, PassRefPtr<NodeList> added, PassRefPtr<NodeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node> nextSibling)
     167Ref<MutationRecord> MutationRecord::createChildList(ContainerNode& target, PassRefPtr<NodeList> added, PassRefPtr<NodeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node> nextSibling)
    168168{
    169     return adoptRef(static_cast<MutationRecord*>(new ChildListRecord(target, added, removed, previousSibling, nextSibling)));
     169    return adoptRef(static_cast<MutationRecord&>(*new ChildListRecord(target, added, removed, previousSibling, nextSibling)));
    170170}
    171171
    172 PassRefPtr<MutationRecord> MutationRecord::createAttributes(Element& target, const QualifiedName& name, const AtomicString& oldValue)
     172Ref<MutationRecord> MutationRecord::createAttributes(Element& target, const QualifiedName& name, const AtomicString& oldValue)
    173173{
    174     return adoptRef(static_cast<MutationRecord*>(new AttributesRecord(target, name, oldValue)));
     174    return adoptRef(static_cast<MutationRecord&>(*new AttributesRecord(target, name, oldValue)));
    175175}
    176176
    177 PassRefPtr<MutationRecord> MutationRecord::createCharacterData(CharacterData& target, const String& oldValue)
     177Ref<MutationRecord> MutationRecord::createCharacterData(CharacterData& target, const String& oldValue)
    178178{
    179     return adoptRef(static_cast<MutationRecord*>(new CharacterDataRecord(target, oldValue)));
     179    return adoptRef(static_cast<MutationRecord&>(*new CharacterDataRecord(target, oldValue)));
    180180}
    181181
    182 PassRefPtr<MutationRecord> MutationRecord::createWithNullOldValue(PassRefPtr<MutationRecord> record)
     182Ref<MutationRecord> MutationRecord::createWithNullOldValue(MutationRecord& record)
    183183{
    184     return adoptRef(static_cast<MutationRecord*>(new MutationRecordWithNullOldValue(record)));
     184    return adoptRef(static_cast<MutationRecord&>(*new MutationRecordWithNullOldValue(record)));
    185185}
    186186
  • trunk/Source/WebCore/dom/MutationRecord.h

    r156256 r195243  
    4848class MutationRecord : public RefCounted<MutationRecord> {
    4949public:
    50     static PassRefPtr<MutationRecord> createChildList(ContainerNode& target, PassRefPtr<NodeList> added, PassRefPtr<NodeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node> nextSibling);
    51     static PassRefPtr<MutationRecord> createAttributes(Element& target, const QualifiedName&, const AtomicString& oldValue);
    52     static PassRefPtr<MutationRecord> createCharacterData(CharacterData& target, const String& oldValue);
     50    static Ref<MutationRecord> createChildList(ContainerNode& target, PassRefPtr<NodeList> added, PassRefPtr<NodeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node> nextSibling);
     51    static Ref<MutationRecord> createAttributes(Element& target, const QualifiedName&, const AtomicString& oldValue);
     52    static Ref<MutationRecord> createCharacterData(CharacterData& target, const String& oldValue);
    5353
    54     static PassRefPtr<MutationRecord> createWithNullOldValue(PassRefPtr<MutationRecord>);
     54    static Ref<MutationRecord> createWithNullOldValue(MutationRecord&);
    5555
    5656    virtual ~MutationRecord();
  • trunk/Source/WebCore/dom/NamedFlowCollection.cpp

    r194324 r195243  
    105105}
    106106
    107 PassRefPtr<DOMNamedFlowCollection> NamedFlowCollection::createCSSOMSnapshot()
     107Ref<DOMNamedFlowCollection> NamedFlowCollection::createCSSOMSnapshot()
    108108{
    109109    Vector<WebKitNamedFlow*> createdFlows;
  • trunk/Source/WebCore/dom/NamedFlowCollection.h

    r184225 r195243  
    3535#include <wtf/Forward.h>
    3636#include <wtf/ListHashSet.h>
    37 #include <wtf/PassRefPtr.h>
    3837#include <wtf/RefCounted.h>
    3938#include <wtf/Vector.h>
     
    5857    virtual ~NamedFlowCollection() { }
    5958
    60     PassRefPtr<DOMNamedFlowCollection> createCSSOMSnapshot();
     59    Ref<DOMNamedFlowCollection> createCSSOMSnapshot();
    6160
    6261private:
  • trunk/Source/WebCore/dom/PendingScript.cpp

    r191955 r195243  
    3838}
    3939
    40 PassRefPtr<Element> PendingScript::releaseElementAndClear()
     40RefPtr<Element> PendingScript::releaseElementAndClear()
    4141{
    4242    setCachedScript(nullptr);
    4343    m_watchingForLoad = false;
    4444    m_startingPosition = TextPosition::belowRangePosition();
    45     return m_element.release();
     45    return WTFMove(m_element);
    4646}
    4747
  • trunk/Source/WebCore/dom/PendingScript.h

    r175148 r195243  
    9090    Element* element() const { return m_element.get(); }
    9191    void setElement(Element* element) { m_element = element; }
    92     PassRefPtr<Element> releaseElementAndClear();
     92    RefPtr<Element> releaseElementAndClear();
    9393
    9494    CachedScript* cachedScript() const;
  • trunk/Source/WebCore/dom/ScriptRunner.h

    r176459 r195243  
    3131#include <wtf/HashMap.h>
    3232#include <wtf/Noncopyable.h>
    33 #include <wtf/PassRefPtr.h>
    3433#include <wtf/Vector.h>
    3534
  • trunk/Source/WebCore/dom/SecurityContext.h

    r177739 r195243  
    2929
    3030#include <memory>
    31 #include <wtf/PassRefPtr.h>
    3231#include <wtf/RefPtr.h>
    3332#include <wtf/text/WTFString.h>
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r194496 r195243  
    124124}
    125125
    126 PassRefPtr<Node> ShadowRoot::cloneNode(bool, ExceptionCode& ec)
    127 {
    128     ec = DATA_CLONE_ERR;
    129     return 0;
    130 }
    131 
    132126String ShadowRoot::innerHTML() const
    133127{
  • trunk/Source/WebCore/dom/ShadowRoot.h

    r194496 r195243  
    8282    Type type() const { return m_type; }
    8383
    84     PassRefPtr<Node> cloneNode(bool, ExceptionCode&);
    85 
    8684    virtual void removeAllEventListeners() override;
    8785
  • trunk/Source/WebCore/dom/SpaceSplitString.cpp

    r175602 r195243  
    174174};
    175175
    176 inline PassRefPtr<SpaceSplitStringData> SpaceSplitStringData::create(const AtomicString& keyString, unsigned tokenCount)
     176inline Ref<SpaceSplitStringData> SpaceSplitStringData::create(const AtomicString& keyString, unsigned tokenCount)
    177177{
    178178    ASSERT(tokenCount);
     
    189189    ASSERT(reinterpret_cast<const char*>(tokenInitializer.nextMemoryBucket()) == reinterpret_cast<const char*>(spaceSplitStringData) + sizeToAllocate);
    190190
    191     return adoptRef(spaceSplitStringData);
    192 }
    193 
    194 PassRefPtr<SpaceSplitStringData> SpaceSplitStringData::create(const AtomicString& keyString)
     191    return adoptRef(*spaceSplitStringData);
     192}
     193
     194RefPtr<SpaceSplitStringData> SpaceSplitStringData::create(const AtomicString& keyString)
    195195{
    196196    ASSERT(isMainThread());
     
    212212    RefPtr<SpaceSplitStringData> spaceSplitStringData = create(keyString, tokenCount);
    213213    addResult.iterator->value = spaceSplitStringData.get();
    214     return spaceSplitStringData.release();
     214    return spaceSplitStringData;
    215215}
    216216
  • trunk/Source/WebCore/dom/SpaceSplitString.h

    r186279 r195243  
    3131    WTF_MAKE_FAST_ALLOCATED;
    3232public:
    33     static PassRefPtr<SpaceSplitStringData> create(const AtomicString&);
     33    static RefPtr<SpaceSplitStringData> create(const AtomicString&);
    3434
    3535    bool contains(const AtomicString& string)
     
    7878
    7979private:
    80     static PassRefPtr<SpaceSplitStringData> create(const AtomicString&, unsigned tokenCount);
     80    static Ref<SpaceSplitStringData> create(const AtomicString&, unsigned tokenCount);
    8181    SpaceSplitStringData(const AtomicString& string, unsigned size)
    8282        : m_keyString(string)
  • trunk/Source/WebCore/dom/TreeWalker.cpp

    r194496 r195243  
    4949}
    5050
    51 inline Node* TreeWalker::setCurrent(PassRefPtr<Node> node)
     51inline Node* TreeWalker::setCurrent(RefPtr<Node>&& node)
    5252{
    5353    m_current = node;
     
    6464        short acceptNodeResult = acceptNode(node.get());
    6565        if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
    66             return setCurrent(node.release());
     66            return setCurrent(WTFMove(node));
    6767    }
    6868    return nullptr;
     
    197197        short acceptNodeResult = acceptNode(node.get());
    198198        if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
    199             return setCurrent(node.release());
     199            return setCurrent(WTFMove(node));
    200200    }
    201201    return nullptr;
     
    210210        short acceptNodeResult = acceptNode(node.get());
    211211        if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
    212             return setCurrent(node.release());
     212            return setCurrent(WTFMove(node));
    213213        if (acceptNodeResult == NodeFilter::FILTER_REJECT)
    214214            break;
     
    218218        short acceptNodeResult = acceptNode(node.get());
    219219        if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
    220             return setCurrent(node.release());
     220            return setCurrent(WTFMove(node));
    221221        if (acceptNodeResult == NodeFilter::FILTER_SKIP)
    222222            goto Children;
  • trunk/Source/WebCore/dom/TreeWalker.h

    r194496 r195243  
    2929#include "ScriptWrappable.h"
    3030#include "Traversal.h"
    31 #include <wtf/PassRefPtr.h>
    3231#include <wtf/RefCounted.h>
    3332
     
    5958        template<SiblingTraversalType> Node* traverseSiblings();
    6059       
    61         Node* setCurrent(PassRefPtr<Node>);
     60        Node* setCurrent(RefPtr<Node>&&);
    6261
    6362        RefPtr<Node> m_current;
  • trunk/Source/WebCore/dom/default/PlatformMessagePortChannel.cpp

    r194496 r195243  
    170170}
    171171
    172 PassRefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::entangledChannel()
     172RefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::entangledChannel()
    173173{
    174174    // FIXME: What guarantees that the result remains the same after we release the lock?
  • trunk/Source/WebCore/dom/default/PlatformMessagePortChannel.h

    r194496 r195243  
    9191        PlatformMessagePortChannel(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing);
    9292
    93         PassRefPtr<PlatformMessagePortChannel> entangledChannel();
     93        RefPtr<PlatformMessagePortChannel> entangledChannel();
    9494
    9595        void setRemotePort(MessagePort*);
Note: See TracChangeset for help on using the changeset viewer.