Reduce PassRefPtr uses in dom - 3
authorgyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Jan 2016 02:56:34 +0000 (02:56 +0000)
committergyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Jan 2016 02:56:34 +0000 (02:56 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195243 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/MutationObserverInterestGroup.cpp
Source/WebCore/dom/MutationRecord.cpp
Source/WebCore/dom/MutationRecord.h
Source/WebCore/dom/NamedFlowCollection.cpp
Source/WebCore/dom/NamedFlowCollection.h
Source/WebCore/dom/PendingScript.cpp
Source/WebCore/dom/PendingScript.h
Source/WebCore/dom/ScriptRunner.h
Source/WebCore/dom/SecurityContext.h
Source/WebCore/dom/ShadowRoot.cpp
Source/WebCore/dom/ShadowRoot.h
Source/WebCore/dom/SpaceSplitString.cpp
Source/WebCore/dom/SpaceSplitString.h
Source/WebCore/dom/TreeWalker.cpp
Source/WebCore/dom/TreeWalker.h
Source/WebCore/dom/default/PlatformMessagePortChannel.cpp
Source/WebCore/dom/default/PlatformMessagePortChannel.h

index 583d557..26d0ec1 100644 (file)
@@ -1,3 +1,44 @@
+2016-01-18  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
+
+        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:
+
 2016-01-18  Nan Wang  <n_wang@apple.com>
 
         AX: [Mac] Implement next/previous text marker functions using TextIterator
index 0799b24..7f4adc4 100644 (file)
@@ -78,7 +78,7 @@ void MutationObserverInterestGroup::enqueueMutationRecord(PassRefPtr<MutationRec
             if (mutation->oldValue().isNull())
                 mutationWithNullOldValue = mutation;
             else
-                mutationWithNullOldValue = MutationRecord::createWithNullOldValue(mutation).get();
+                mutationWithNullOldValue = MutationRecord::createWithNullOldValue(*mutation).ptr();
         }
         observer->enqueueMutationRecord(mutationWithNullOldValue);
     }
index ce41a1c..650ad92 100644 (file)
@@ -124,7 +124,7 @@ private:
 
 class MutationRecordWithNullOldValue : public MutationRecord {
 public:
-    MutationRecordWithNullOldValue(PassRefPtr<MutationRecord> record)
+    MutationRecordWithNullOldValue(MutationRecord& record)
         : m_record(record)
     {
     }
@@ -141,7 +141,7 @@ private:
 
     virtual String oldValue() override { return String(); }
 
-    RefPtr<MutationRecord> m_record;
+    Ref<MutationRecord> m_record;
 };
 
 const AtomicString& ChildListRecord::type()
@@ -164,24 +164,24 @@ const AtomicString& CharacterDataRecord::type()
 
 } // namespace
 
-PassRefPtr<MutationRecord> MutationRecord::createChildList(ContainerNode& target, PassRefPtr<NodeList> added, PassRefPtr<NodeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node> nextSibling)
+Ref<MutationRecord> MutationRecord::createChildList(ContainerNode& target, PassRefPtr<NodeList> added, PassRefPtr<NodeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node> nextSibling)
 {
-    return adoptRef(static_cast<MutationRecord*>(new ChildListRecord(target, added, removed, previousSibling, nextSibling)));
+    return adoptRef(static_cast<MutationRecord&>(*new ChildListRecord(target, added, removed, previousSibling, nextSibling)));
 }
 
-PassRefPtr<MutationRecord> MutationRecord::createAttributes(Element& target, const QualifiedName& name, const AtomicString& oldValue)
+Ref<MutationRecord> MutationRecord::createAttributes(Element& target, const QualifiedName& name, const AtomicString& oldValue)
 {
-    return adoptRef(static_cast<MutationRecord*>(new AttributesRecord(target, name, oldValue)));
+    return adoptRef(static_cast<MutationRecord&>(*new AttributesRecord(target, name, oldValue)));
 }
 
-PassRefPtr<MutationRecord> MutationRecord::createCharacterData(CharacterData& target, const String& oldValue)
+Ref<MutationRecord> MutationRecord::createCharacterData(CharacterData& target, const String& oldValue)
 {
-    return adoptRef(static_cast<MutationRecord*>(new CharacterDataRecord(target, oldValue)));
+    return adoptRef(static_cast<MutationRecord&>(*new CharacterDataRecord(target, oldValue)));
 }
 
-PassRefPtr<MutationRecord> MutationRecord::createWithNullOldValue(PassRefPtr<MutationRecord> record)
+Ref<MutationRecord> MutationRecord::createWithNullOldValue(MutationRecord& record)
 {
-    return adoptRef(static_cast<MutationRecord*>(new MutationRecordWithNullOldValue(record)));
+    return adoptRef(static_cast<MutationRecord&>(*new MutationRecordWithNullOldValue(record)));
 }
 
 MutationRecord::~MutationRecord()
index 6cbb493..1709ab6 100644 (file)
@@ -47,11 +47,11 @@ class QualifiedName;
 
 class MutationRecord : public RefCounted<MutationRecord> {
 public:
-    static PassRefPtr<MutationRecord> createChildList(ContainerNode& target, PassRefPtr<NodeList> added, PassRefPtr<NodeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node> nextSibling);
-    static PassRefPtr<MutationRecord> createAttributes(Element& target, const QualifiedName&, const AtomicString& oldValue);
-    static PassRefPtr<MutationRecord> createCharacterData(CharacterData& target, const String& oldValue);
+    static Ref<MutationRecord> createChildList(ContainerNode& target, PassRefPtr<NodeList> added, PassRefPtr<NodeList> removed, PassRefPtr<Node> previousSibling, PassRefPtr<Node> nextSibling);
+    static Ref<MutationRecord> createAttributes(Element& target, const QualifiedName&, const AtomicString& oldValue);
+    static Ref<MutationRecord> createCharacterData(CharacterData& target, const String& oldValue);
 
-    static PassRefPtr<MutationRecord> createWithNullOldValue(PassRefPtr<MutationRecord>);
+    static Ref<MutationRecord> createWithNullOldValue(MutationRecord&);
 
     virtual ~MutationRecord();
 
index 24360dc..2a0d92c 100644 (file)
@@ -104,7 +104,7 @@ Document* NamedFlowCollection::document() const
     return downcast<Document>(context);
 }
 
-PassRefPtr<DOMNamedFlowCollection> NamedFlowCollection::createCSSOMSnapshot()
+Ref<DOMNamedFlowCollection> NamedFlowCollection::createCSSOMSnapshot()
 {
     Vector<WebKitNamedFlow*> createdFlows;
     for (auto& namedFlow : m_namedFlows) {
index 47501d7..d66810e 100644 (file)
@@ -34,7 +34,6 @@
 #include "WebKitNamedFlow.h"
 #include <wtf/Forward.h>
 #include <wtf/ListHashSet.h>
-#include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
 
@@ -57,7 +56,7 @@ public:
 
     virtual ~NamedFlowCollection() { }
 
-    PassRefPtr<DOMNamedFlowCollection> createCSSOMSnapshot();
+    Ref<DOMNamedFlowCollection> createCSSOMSnapshot();
 
 private:
     struct NamedFlowHashFunctions;
index 9b70a2a..78ff3d8 100644 (file)
@@ -37,12 +37,12 @@ PendingScript::~PendingScript()
         m_cachedScript->removeClient(this);
 }
 
-PassRefPtr<Element> PendingScript::releaseElementAndClear()
+RefPtr<Element> PendingScript::releaseElementAndClear()
 {
     setCachedScript(nullptr);
     m_watchingForLoad = false;
     m_startingPosition = TextPosition::belowRangePosition();
-    return m_element.release();
+    return WTFMove(m_element);
 }
 
 void PendingScript::setCachedScript(CachedScript* cachedScript)
index 8edad90..0236fe9 100644 (file)
@@ -89,7 +89,7 @@ public:
 
     Element* element() const { return m_element.get(); }
     void setElement(Element* element) { m_element = element; }
-    PassRefPtr<Element> releaseElementAndClear();
+    RefPtr<Element> releaseElementAndClear();
 
     CachedScript* cachedScript() const;
     void setCachedScript(CachedScript*);
index 27cdbf8..8cd332a 100644 (file)
@@ -30,7 +30,6 @@
 #include "Timer.h"
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
-#include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
index 0750db2..202bc09 100644 (file)
@@ -28,7 +28,6 @@
 #define SecurityContext_h
 
 #include <memory>
-#include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 #include <wtf/text/WTFString.h>
 
index 461e6de..47aac34 100644 (file)
@@ -123,12 +123,6 @@ void ShadowRoot::updateStyle()
         setNeedsStyleRecalc();
 }
 
-PassRefPtr<Node> ShadowRoot::cloneNode(bool, ExceptionCode& ec)
-{
-    ec = DATA_CLONE_ERR;
-    return 0;
-}
-
 String ShadowRoot::innerHTML() const
 {
     return createMarkup(*this, ChildrenOnly);
index 8a51b70..5f32e90 100644 (file)
@@ -81,8 +81,6 @@ public:
 
     Type type() const { return m_type; }
 
-    PassRefPtr<Node> cloneNode(bool, ExceptionCode&);
-
     virtual void removeAllEventListeners() override;
 
 #if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
index ec5afac..10c69ab 100644 (file)
@@ -173,7 +173,7 @@ private:
     AtomicString* m_memoryBucket;
 };
 
-inline PassRefPtr<SpaceSplitStringData> SpaceSplitStringData::create(const AtomicString& keyString, unsigned tokenCount)
+inline Ref<SpaceSplitStringData> SpaceSplitStringData::create(const AtomicString& keyString, unsigned tokenCount)
 {
     ASSERT(tokenCount);
 
@@ -188,10 +188,10 @@ inline PassRefPtr<SpaceSplitStringData> SpaceSplitStringData::create(const Atomi
     ASSERT(static_cast<unsigned>(tokenInitializer.nextMemoryBucket() - tokenArrayStart) == tokenCount);
     ASSERT(reinterpret_cast<const char*>(tokenInitializer.nextMemoryBucket()) == reinterpret_cast<const char*>(spaceSplitStringData) + sizeToAllocate);
 
-    return adoptRef(spaceSplitStringData);
+    return adoptRef(*spaceSplitStringData);
 }
 
-PassRefPtr<SpaceSplitStringData> SpaceSplitStringData::create(const AtomicString& keyString)
+RefPtr<SpaceSplitStringData> SpaceSplitStringData::create(const AtomicString& keyString)
 {
     ASSERT(isMainThread());
     ASSERT(!keyString.isNull());
@@ -211,7 +211,7 @@ PassRefPtr<SpaceSplitStringData> SpaceSplitStringData::create(const AtomicString
 
     RefPtr<SpaceSplitStringData> spaceSplitStringData = create(keyString, tokenCount);
     addResult.iterator->value = spaceSplitStringData.get();
-    return spaceSplitStringData.release();
+    return spaceSplitStringData;
 }
 
 
index f85b964..48edda6 100644 (file)
@@ -30,7 +30,7 @@ class SpaceSplitStringData {
     WTF_MAKE_NONCOPYABLE(SpaceSplitStringData);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static PassRefPtr<SpaceSplitStringData> create(const AtomicString&);
+    static RefPtr<SpaceSplitStringData> create(const AtomicString&);
 
     bool contains(const AtomicString& string)
     {
@@ -77,7 +77,7 @@ public:
     static ptrdiff_t tokensMemoryOffset() { return sizeof(SpaceSplitStringData); }
 
 private:
-    static PassRefPtr<SpaceSplitStringData> create(const AtomicString&, unsigned tokenCount);
+    static Ref<SpaceSplitStringData> create(const AtomicString&, unsigned tokenCount);
     SpaceSplitStringData(const AtomicString& string, unsigned size)
         : m_keyString(string)
         , m_refCount(1)
index ccbe092..ab86d59 100644 (file)
@@ -48,7 +48,7 @@ void TreeWalker::setCurrentNode(Node* node, ExceptionCode& ec)
     m_current = node;
 }
 
-inline Node* TreeWalker::setCurrent(PassRefPtr<Node> node)
+inline Node* TreeWalker::setCurrent(RefPtr<Node>&& node)
 {
     m_current = node;
     return m_current.get();
@@ -63,7 +63,7 @@ Node* TreeWalker::parentNode()
             return nullptr;
         short acceptNodeResult = acceptNode(node.get());
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
-            return setCurrent(node.release());
+            return setCurrent(WTFMove(node));
     }
     return nullptr;
 }
@@ -196,7 +196,7 @@ Node* TreeWalker::previousNode()
         node = parent;
         short acceptNodeResult = acceptNode(node.get());
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
-            return setCurrent(node.release());
+            return setCurrent(WTFMove(node));
     }
     return nullptr;
 }
@@ -209,7 +209,7 @@ Children:
         node = firstChild;
         short acceptNodeResult = acceptNode(node.get());
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
-            return setCurrent(node.release());
+            return setCurrent(WTFMove(node));
         if (acceptNodeResult == NodeFilter::FILTER_REJECT)
             break;
     }
@@ -217,7 +217,7 @@ Children:
         node = nextSibling;
         short acceptNodeResult = acceptNode(node.get());
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
-            return setCurrent(node.release());
+            return setCurrent(WTFMove(node));
         if (acceptNodeResult == NodeFilter::FILTER_SKIP)
             goto Children;
     }
index 8e81508..1b5be1c 100644 (file)
@@ -28,7 +28,6 @@
 #include "NodeFilter.h"
 #include "ScriptWrappable.h"
 #include "Traversal.h"
-#include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
@@ -58,7 +57,7 @@ namespace WebCore {
         enum class SiblingTraversalType { Previous, Next };
         template<SiblingTraversalType> Node* traverseSiblings();
         
-        Node* setCurrent(PassRefPtr<Node>);
+        Node* setCurrent(RefPtr<Node>&&);
 
         RefPtr<Node> m_current;
     };
index 9633795..eee2577 100644 (file)
@@ -169,7 +169,7 @@ void PlatformMessagePortChannel::setRemotePort(MessagePort* port)
     m_remotePort = port;
 }
 
-PassRefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::entangledChannel()
+RefPtr<PlatformMessagePortChannel> PlatformMessagePortChannel::entangledChannel()
 {
     // FIXME: What guarantees that the result remains the same after we release the lock?
     // This lock only guarantees that the returned pointer will not be pointing to released memory,
index 7104492..f45ff22 100644 (file)
@@ -90,7 +90,7 @@ namespace WebCore {
         static Ref<PlatformMessagePortChannel> create(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing);
         PlatformMessagePortChannel(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing);
 
-        PassRefPtr<PlatformMessagePortChannel> entangledChannel();
+        RefPtr<PlatformMessagePortChannel> entangledChannel();
 
         void setRemotePort(MessagePort*);
         void closeInternal();