Title: [158250] trunk/Source/WebCore
Revision
158250
Author
[email protected]
Date
2013-10-29 21:15:55 -0700 (Tue, 29 Oct 2013)

Log Message

ElementData construction helpers should return PassRef.
<https://webkit.org/b/123487>

Make functions that create new ElementData objects return appropriate
PassRef pointers instead of PassRefPtr.

Reviewed by Anders Carlsson.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (158249 => 158250)


--- trunk/Source/WebCore/ChangeLog	2013-10-30 03:57:25 UTC (rev 158249)
+++ trunk/Source/WebCore/ChangeLog	2013-10-30 04:15:55 UTC (rev 158250)
@@ -1,3 +1,13 @@
+2013-10-29  Andreas Kling  <[email protected]>
+
+        ElementData construction helpers should return PassRef.
+        <https://webkit.org/b/123487>
+
+        Make functions that create new ElementData objects return appropriate
+        PassRef pointers instead of PassRefPtr.
+
+        Reviewed by Anders Carlsson.
+
 2013-10-29  Ryosuke Niwa  <[email protected]>
 
         GTK+ build fix attempt after r158220.

Modified: trunk/Source/WebCore/dom/DocumentSharedObjectPool.cpp (158249 => 158250)


--- trunk/Source/WebCore/dom/DocumentSharedObjectPool.cpp	2013-10-30 03:57:25 UTC (rev 158249)
+++ trunk/Source/WebCore/dom/DocumentSharedObjectPool.cpp	2013-10-30 04:15:55 UTC (rev 158250)
@@ -57,16 +57,16 @@
 
 class ShareableElementDataCacheEntry {
 public:
-    ShareableElementDataCacheEntry(const ShareableElementDataCacheKey& k, PassRefPtr<ShareableElementData> v)
+    ShareableElementDataCacheEntry(const ShareableElementDataCacheKey& k, ShareableElementData& v)
         : key(k)
         , value(v)
     { }
 
     ShareableElementDataCacheKey key;
-    RefPtr<ShareableElementData> value;
+    Ref<ShareableElementData> value;
 };
 
-PassRefPtr<ShareableElementData> DocumentSharedObjectPool::cachedShareableElementDataWithAttributes(const Vector<Attribute>& attributes)
+PassRef<ShareableElementData> DocumentSharedObjectPool::cachedShareableElementDataWithAttributes(const Vector<Attribute>& attributes)
 {
     ASSERT(!attributes.isEmpty());
 
@@ -79,16 +79,16 @@
 
     RefPtr<ShareableElementData> elementData;
     if (cacheHash && cacheIterator->value)
-        elementData = cacheIterator->value->value;
+        elementData = &cacheIterator->value->value.get();
     else
         elementData = ShareableElementData::createWithAttributes(attributes);
 
     if (!cacheHash || cacheIterator->value)
-        return elementData.release();
+        return elementData.releaseNonNull();
 
-    cacheIterator->value = adoptPtr(new ShareableElementDataCacheEntry(ShareableElementDataCacheKey(elementData->m_attributeArray, elementData->length()), elementData));
+    cacheIterator->value = adoptPtr(new ShareableElementDataCacheEntry(ShareableElementDataCacheKey(elementData->m_attributeArray, elementData->length()), *elementData));
 
-    return elementData.release();
+    return elementData.releaseNonNull();
 }
 
 DocumentSharedObjectPool::DocumentSharedObjectPool()

Modified: trunk/Source/WebCore/dom/DocumentSharedObjectPool.h (158249 => 158250)


--- trunk/Source/WebCore/dom/DocumentSharedObjectPool.h	2013-10-30 03:57:25 UTC (rev 158249)
+++ trunk/Source/WebCore/dom/DocumentSharedObjectPool.h	2013-10-30 04:15:55 UTC (rev 158250)
@@ -42,7 +42,7 @@
     static PassOwnPtr<DocumentSharedObjectPool> create() { return adoptPtr(new DocumentSharedObjectPool); }
     ~DocumentSharedObjectPool();
 
-    PassRefPtr<ShareableElementData> cachedShareableElementDataWithAttributes(const Vector<Attribute>&);
+    PassRef<ShareableElementData> cachedShareableElementDataWithAttributes(const Vector<Attribute>&);
 
 private:
     DocumentSharedObjectPool();

Modified: trunk/Source/WebCore/dom/ElementData.cpp (158249 => 158250)


--- trunk/Source/WebCore/dom/ElementData.cpp	2013-10-30 03:57:25 UTC (rev 158249)
+++ trunk/Source/WebCore/dom/ElementData.cpp	2013-10-30 04:15:55 UTC (rev 158250)
@@ -75,15 +75,15 @@
     return sizeof(ShareableElementData) + sizeof(Attribute) * count;
 }
 
-PassRefPtr<ShareableElementData> ShareableElementData::createWithAttributes(const Vector<Attribute>& attributes)
+PassRef<ShareableElementData> ShareableElementData::createWithAttributes(const Vector<Attribute>& attributes)
 {
     void* slot = WTF::fastMalloc(sizeForShareableElementDataWithAttributeCount(attributes.size()));
-    return adoptRef(new (NotNull, slot) ShareableElementData(attributes));
+    return adoptRef(*new (NotNull, slot) ShareableElementData(attributes));
 }
 
-PassRefPtr<UniqueElementData> UniqueElementData::create()
+PassRef<UniqueElementData> UniqueElementData::create()
 {
-    return adoptRef(new UniqueElementData);
+    return adoptRef(*new UniqueElementData);
 }
 
 ShareableElementData::ShareableElementData(const Vector<Attribute>& attributes)
@@ -153,17 +153,17 @@
         m_attributeVector.uncheckedAppend(other.m_attributeArray[i]);
 }
 
-PassRefPtr<UniqueElementData> ElementData::makeUniqueCopy() const
+PassRef<UniqueElementData> ElementData::makeUniqueCopy() const
 {
     if (isUnique())
-        return adoptRef(new UniqueElementData(static_cast<const UniqueElementData&>(*this)));
-    return adoptRef(new UniqueElementData(static_cast<const ShareableElementData&>(*this)));
+        return adoptRef(*new UniqueElementData(static_cast<const UniqueElementData&>(*this)));
+    return adoptRef(*new UniqueElementData(static_cast<const ShareableElementData&>(*this)));
 }
 
-PassRefPtr<ShareableElementData> UniqueElementData::makeShareableCopy() const
+PassRef<ShareableElementData> UniqueElementData::makeShareableCopy() const
 {
     void* slot = WTF::fastMalloc(sizeForShareableElementDataWithAttributeCount(m_attributeVector.size()));
-    return adoptRef(new (NotNull, slot) ShareableElementData(*this));
+    return adoptRef(*new (NotNull, slot) ShareableElementData(*this));
 }
 
 bool ElementData::isEquivalent(const ElementData* other) const

Modified: trunk/Source/WebCore/dom/ElementData.h (158249 => 158250)


--- trunk/Source/WebCore/dom/ElementData.h	2013-10-30 03:57:25 UTC (rev 158249)
+++ trunk/Source/WebCore/dom/ElementData.h	2013-10-30 04:15:55 UTC (rev 158250)
@@ -106,7 +106,7 @@
     const Attribute* findAttributeByName(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
     unsigned findAttributeIndexByNameSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
 
-    PassRefPtr<UniqueElementData> makeUniqueCopy() const;
+    PassRef<UniqueElementData> makeUniqueCopy() const;
 };
 
 #if COMPILER(MSVC)
@@ -116,7 +116,7 @@
 
 class ShareableElementData : public ElementData {
 public:
-    static PassRefPtr<ShareableElementData> createWithAttributes(const Vector<Attribute>&);
+    static PassRef<ShareableElementData> createWithAttributes(const Vector<Attribute>&);
 
     explicit ShareableElementData(const Vector<Attribute>&);
     explicit ShareableElementData(const UniqueElementData&);
@@ -131,8 +131,8 @@
 
 class UniqueElementData : public ElementData {
 public:
-    static PassRefPtr<UniqueElementData> create();
-    PassRefPtr<ShareableElementData> makeShareableCopy() const;
+    static PassRef<UniqueElementData> create();
+    PassRef<ShareableElementData> makeShareableCopy() const;
 
     // These functions do no error/duplicate checking.
     void addAttribute(const QualifiedName&, const AtomicString&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to