Purge PassRefPtr from ArrayBuffer, ArchiveResource, Pasteboard, LegacyWebArchive...
authorjh718.park@samsung.com <jh718.park@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Mar 2016 00:22:45 +0000 (00:22 +0000)
committerjh718.park@samsung.com <jh718.park@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Mar 2016 00:22:45 +0000 (00:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150497

Reviewed by Darin Adler.

Source/JavaScriptCore:

* runtime/ArrayBuffer.h:
(JSC::ArrayBuffer::create):
(JSC::ArrayBuffer::createAdopted):
(JSC::ArrayBuffer::createFromBytes):
(JSC::ArrayBuffer::createUninitialized):
(JSC::ArrayBuffer::slice):
(JSC::ArrayBuffer::sliceImpl):

Source/WebCore:

No new tests, no new behaviours.

* Modules/indexeddb/IDBGetResult.h:
(WebCore::IDBGetResult::IDBGetResult):
* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::getIndexRecord):
* Modules/mediastream/RTCDataChannel.cpp:
(WebCore::RTCDataChannel::didReceiveRawData):
* dom/MessageEvent.cpp:
(WebCore::MessageEvent::MessageEvent):
* dom/MessageEvent.h:
* editing/Editor.cpp:
(WebCore::Editor::selectedRange):
* editing/Editor.h:
* editing/FrameSelection.h:
(WebCore::FrameSelection::toNormalizedRange):
* editing/VisiblePosition.cpp:
(WebCore::makeRange):
* editing/VisiblePosition.h:
* editing/VisibleSelection.cpp:
(WebCore::VisibleSelection::toNormalizedRange):
* editing/VisibleSelection.h:
* editing/VisibleUnits.cpp:
(WebCore::enclosingTextUnitOfGranularity):
(WebCore::wordRangeFromPosition):
(WebCore::rangeExpandedByCharactersInDirectionAtWordBoundary):
(WebCore::rangeExpandedAroundPositionByCharacters):
* editing/VisibleUnits.h:
* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_addAttachmentForElement):
(fileWrapperForURL):
* editing/efl/EditorEfl.cpp:
(WebCore::Editor::webContentFromPasteboard):
* editing/gtk/EditorGtk.cpp:
(WebCore::createFragmentFromPasteboardData):
(WebCore::Editor::webContentFromPasteboard):
* editing/ios/EditorIOS.mm:
(WebCore::dataInRTFDFormat):
(WebCore::dataInRTFFormat):
(WebCore::Editor::selectionInWebArchiveFormat):
(WebCore::Editor::WebContentReader::addFragment):
(WebCore::Editor::WebContentReader::readWebArchive):
(WebCore::Editor::WebContentReader::readRTFD):
(WebCore::Editor::WebContentReader::readRTF):
(WebCore::Editor::WebContentReader::readImage):
(WebCore::Editor::WebContentReader::readURL):
(WebCore::Editor::webContentFromPasteboard):
(WebCore::Editor::pasteWithPasteboard):
(WebCore::Editor::createFragmentAndAddResources):
(WebCore::Editor::createFragmentForImageResourceAndAddResource):
* editing/mac/EditorMac.mm:
(WebCore::Editor::selectionInWebArchiveFormat):
(WebCore::Editor::adjustedSelectionRange):
(WebCore::dataInRTFDFormat):
(WebCore::dataInRTFFormat):
(WebCore::Editor::dataSelectionForPasteboard):
(WebCore::Editor::WebContentReader::readWebArchive):
(WebCore::Editor::WebContentReader::readRTFD):
(WebCore::Editor::WebContentReader::readRTF):
(WebCore::Editor::WebContentReader::readImage):
(WebCore::Editor::WebContentReader::readURL):
(WebCore::Editor::webContentFromPasteboard):
(WebCore::Editor::createFragmentForImageResourceAndAddResource):
(WebCore::Editor::createFragmentAndAddResources):
* editing/win/EditorWin.cpp:
(WebCore::createFragmentFromPlatformData):
(WebCore::Editor::webContentFromPasteboard):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::archive):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::mainResourceData):
(WebCore::DocumentLoader::maybeCreateArchive):
(WebCore::DocumentLoader::addArchiveResource):
(WebCore::DocumentLoader::mainResource):
* loader/DocumentLoader.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadArchive):
* loader/SubstituteData.h:
(WebCore::SubstituteData::SubstituteData):
(WebCore::SubstituteData::isValid):
* loader/SubstituteResource.h:
(WebCore::SubstituteResource::data):
(WebCore::SubstituteResource::SubstituteResource):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::didReceiveResponse):
(WebCore::ApplicationCacheGroup::didReceiveData):
(WebCore::ApplicationCacheGroup::didFail):
(WebCore::ApplicationCacheGroup::didReceiveManifestData):
(WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
* loader/appcache/ApplicationCacheHost.cpp:
(WebCore::ApplicationCacheHost::maybeLoadMainResource):
(WebCore::ApplicationCacheHost::maybeLoadSynchronously):
(WebCore::ApplicationCacheHost::maybeLoadFallbackSynchronously):
* loader/appcache/ApplicationCacheResource.cpp:
(WebCore::ApplicationCacheResource::ApplicationCacheResource):
(WebCore::ApplicationCacheResource::deliver):
(WebCore::ApplicationCacheResource::estimatedSizeInStorage):
* loader/appcache/ApplicationCacheResource.h:
(WebCore::ApplicationCacheResource::create):
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::store):
(WebCore::ApplicationCacheStorage::writeDataToUniqueFileInDirectory):
* loader/appcache/ApplicationCacheStorage.h:
* loader/archive/ArchiveFactory.cpp:
(WebCore::archiveFactoryCreate):
(WebCore::ArchiveFactory::create):
* loader/archive/ArchiveFactory.h:
* loader/archive/ArchiveResource.cpp:
(WebCore::ArchiveResource::ArchiveResource):
(WebCore::ArchiveResource::create):
* loader/archive/ArchiveResource.h:
* loader/archive/ArchiveResourceCollection.cpp:
(WebCore::ArchiveResourceCollection::addResource):
* loader/archive/ArchiveResourceCollection.h:
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::createPropertyListRepresentation):
(WebCore::LegacyWebArchive::createResource):
(WebCore::LegacyWebArchive::create):
(WebCore::LegacyWebArchive::createFromSelection):
* loader/archive/cf/LegacyWebArchive.h:
* loader/archive/mhtml/MHTMLArchive.cpp:
(WebCore::MHTMLArchive::create):
* loader/archive/mhtml/MHTMLArchive.h:
* loader/archive/mhtml/MHTMLParser.cpp:
(WebCore::MHTMLParser::parseArchive):
(WebCore::MHTMLParser::parseArchiveWithHeader):
(WebCore::MHTMLParser::parseNextPart):
* loader/archive/mhtml/MHTMLParser.h:
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::didAddClient):
* loader/icon/IconDatabase.cpp:
(WebCore::loadDefaultIconRecord):
* loader/icon/IconRecord.cpp:
(WebCore::IconRecord::setImageData):
* loader/icon/IconRecord.h:
* platform/Pasteboard.h:
* platform/PasteboardStrategy.h:
* platform/PlatformPasteboard.h:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::createArrayBuffer):
(WebCore::utf8Buffer):
* platform/SharedBuffer.h:
(WebCore::SharedBuffer::create):
* platform/cf/SharedBufferCF.cpp:
(WebCore::SharedBuffer::wrapCFData):
* platform/cocoa/NetworkExtensionContentFilter.mm:
(WebCore::NetworkExtensionContentFilter::replacementData):
* platform/cocoa/ParentalControlsContentFilter.mm:
(WebCore::ParentalControlsContentFilter::replacementData):
* platform/graphics/Image.cpp:
(WebCore::Image::setData):
* platform/graphics/Image.h:
* platform/gtk/DataObjectGtk.cpp:
(WebCore::DataObjectGtk::forClipboard):
* platform/gtk/DataObjectGtk.h:
(WebCore::DataObjectGtk::create):
* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::Pasteboard):
(WebCore::Pasteboard::dataObject):
* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::read):
* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::bufferForType):
(WebCore::PlatformPasteboard::readBuffer):
* platform/mac/PasteboardMac.mm:
(WebCore::writeFileWrapperAsRTFDAttachment):
(WebCore::Pasteboard::read):
* platform/mac/PlatformPasteboardMac.mm:
(WebCore::PlatformPasteboard::bufferForType):
* platform/mac/SharedBufferMac.mm:
(WebCore::SharedBuffer::wrapNSData):
(WebCore::SharedBuffer::createFromReadingFile):
* platform/network/MIMEHeader.cpp:
(WebCore::retrieveKeyValuePairs):
(WebCore::MIMEHeader::parseHeader):
* platform/network/MIMEHeader.h:
* platform/soup/SharedBufferSoup.cpp:
(WebCore::SharedBuffer::wrapSoupBuffer):
* platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::fragmentFromFilenames):
(WebCore::fragmentFromCFHTML):
(WebCore::fragmentFromHTML):
* platform/win/ClipboardUtilitiesWin.h:
* platform/win/PasteboardWin.cpp:
(WebCore::Pasteboard::documentFragment):

Source/WebKit/mac:

* DOM/WebDOMOperations.mm:
(-[DOMNode webArchive]):
(-[DOMNode webArchiveByFilteringSubframes:]):
* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::bufferForType):
(WebPlatformStrategies::readBufferFromPasteboard):
* WebView/WebArchive.mm:
(-[WebArchive initWithData:]):
* WebView/WebDataSource.mm:
(-[WebDataSource webArchive]):
(-[WebDataSource addSubresource:]):
* WebView/WebResource.mm:
(-[WebResource encodeWithCoder:]):
(-[WebResource data]):
(-[WebResource _stringValue]):
(-[WebResource _initWithCoreResource:]): Deleted.

Source/WebKit/win:

* WebArchive.cpp:
(WebArchive::initWithNode):

Source/WebKit2:

* Shared/APIWebArchive.mm:
(API::WebArchive::WebArchive):
* Shared/APIWebArchiveResource.mm:
(API::WebArchiveResource::data):
* WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm:
(WebKit::PDFPlugin::addArchiveResource):
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::bufferForType):
(WebKit::WebPlatformStrategies::readBufferFromPasteboard):
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:
* WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
(WebKit::WebEditorClient::documentFragmentFromAttributedString):
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
(WebKit::WebDragClient::declareAndWriteDragImage):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::webArchiveData):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::resourceDataForFrame):

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

94 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/ArrayBuffer.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBGetResult.h
Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
Source/WebCore/Modules/mediastream/RTCDataChannel.cpp
Source/WebCore/dom/MessageEvent.cpp
Source/WebCore/dom/MessageEvent.h
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/Editor.h
Source/WebCore/editing/FrameSelection.h
Source/WebCore/editing/VisiblePosition.cpp
Source/WebCore/editing/VisiblePosition.h
Source/WebCore/editing/VisibleSelection.cpp
Source/WebCore/editing/VisibleSelection.h
Source/WebCore/editing/VisibleUnits.cpp
Source/WebCore/editing/VisibleUnits.h
Source/WebCore/editing/cocoa/HTMLConverter.mm
Source/WebCore/editing/efl/EditorEfl.cpp
Source/WebCore/editing/gtk/EditorGtk.cpp
Source/WebCore/editing/ios/EditorIOS.mm
Source/WebCore/editing/mac/EditorMac.mm
Source/WebCore/editing/win/EditorWin.cpp
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/DocumentLoader.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/SubstituteData.h
Source/WebCore/loader/SubstituteResource.h
Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
Source/WebCore/loader/appcache/ApplicationCacheHost.cpp
Source/WebCore/loader/appcache/ApplicationCacheResource.cpp
Source/WebCore/loader/appcache/ApplicationCacheResource.h
Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp
Source/WebCore/loader/appcache/ApplicationCacheStorage.h
Source/WebCore/loader/archive/ArchiveFactory.cpp
Source/WebCore/loader/archive/ArchiveFactory.h
Source/WebCore/loader/archive/ArchiveResource.cpp
Source/WebCore/loader/archive/ArchiveResource.h
Source/WebCore/loader/archive/ArchiveResourceCollection.cpp
Source/WebCore/loader/archive/ArchiveResourceCollection.h
Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp
Source/WebCore/loader/archive/cf/LegacyWebArchive.h
Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp
Source/WebCore/loader/archive/mhtml/MHTMLArchive.h
Source/WebCore/loader/archive/mhtml/MHTMLParser.cpp
Source/WebCore/loader/archive/mhtml/MHTMLParser.h
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/loader/icon/IconDatabase.cpp
Source/WebCore/loader/icon/IconRecord.cpp
Source/WebCore/loader/icon/IconRecord.h
Source/WebCore/platform/Pasteboard.h
Source/WebCore/platform/PasteboardStrategy.h
Source/WebCore/platform/PlatformPasteboard.h
Source/WebCore/platform/SharedBuffer.cpp
Source/WebCore/platform/SharedBuffer.h
Source/WebCore/platform/cf/SharedBufferCF.cpp
Source/WebCore/platform/cocoa/NetworkExtensionContentFilter.mm
Source/WebCore/platform/cocoa/ParentalControlsContentFilter.mm
Source/WebCore/platform/graphics/Image.cpp
Source/WebCore/platform/graphics/Image.h
Source/WebCore/platform/gtk/DataObjectGtk.cpp
Source/WebCore/platform/gtk/DataObjectGtk.h
Source/WebCore/platform/gtk/PasteboardGtk.cpp
Source/WebCore/platform/ios/PasteboardIOS.mm
Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
Source/WebCore/platform/mac/PasteboardMac.mm
Source/WebCore/platform/mac/PlatformPasteboardMac.mm
Source/WebCore/platform/mac/SharedBufferMac.mm
Source/WebCore/platform/network/MIMEHeader.cpp
Source/WebCore/platform/network/MIMEHeader.h
Source/WebCore/platform/soup/SharedBufferSoup.cpp
Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
Source/WebCore/platform/win/ClipboardUtilitiesWin.h
Source/WebCore/platform/win/PasteboardWin.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/DOM/WebDOMOperations.mm
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm
Source/WebKit/mac/WebView/WebArchive.mm
Source/WebKit/mac/WebView/WebDataSource.mm
Source/WebKit/mac/WebView/WebResource.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebArchive.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/APIWebArchive.mm
Source/WebKit2/Shared/APIWebArchiveResource.mm
Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h
Source/WebKit2/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 4252865..e193c35 100644 (file)
@@ -1,3 +1,18 @@
+2016-03-14  Joonghun Park  <jh718.park@samsung.com>
+
+        Purge PassRefPtr from ArrayBuffer, ArchiveResource, Pasteboard, LegacyWebArchive and DataObjectGtk
+        https://bugs.webkit.org/show_bug.cgi?id=150497
+
+        Reviewed by Darin Adler.
+
+        * runtime/ArrayBuffer.h:
+        (JSC::ArrayBuffer::create):
+        (JSC::ArrayBuffer::createAdopted):
+        (JSC::ArrayBuffer::createFromBytes):
+        (JSC::ArrayBuffer::createUninitialized):
+        (JSC::ArrayBuffer::slice):
+        (JSC::ArrayBuffer::sliceImpl):
+
 2016-03-14  Benjamin Poulain  <bpoulain@apple.com>
 
         Andy VanWagoner no longer has time to own Intl
index 4703302..b3d7ec6 100644 (file)
@@ -29,7 +29,6 @@
 #include "GCIncomingRefCounted.h"
 #include "Weak.h"
 #include <functional>
-#include <wtf/PassRefPtr.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/Vector.h>
 
@@ -98,15 +97,15 @@ private:
 
 class ArrayBuffer : public GCIncomingRefCounted<ArrayBuffer> {
 public:
-    static inline PassRefPtr<ArrayBuffer> create(unsigned numElements, unsigned elementByteSize);
-    static inline PassRefPtr<ArrayBuffer> create(ArrayBuffer*);
-    static inline PassRefPtr<ArrayBuffer> create(const void* source, unsigned byteLength);
-    static inline PassRefPtr<ArrayBuffer> create(ArrayBufferContents&);
-    static inline PassRefPtr<ArrayBuffer> createAdopted(const void* data, unsigned byteLength);
-    static inline PassRefPtr<ArrayBuffer> createFromBytes(const void* data, unsigned byteLength, ArrayBufferDestructorFunction&&);
+    static inline RefPtr<ArrayBuffer> create(unsigned numElements, unsigned elementByteSize);
+    static inline RefPtr<ArrayBuffer> create(ArrayBuffer*);
+    static inline RefPtr<ArrayBuffer> create(const void* source, unsigned byteLength);
+    static inline Ref<ArrayBuffer> create(ArrayBufferContents&);
+    static inline Ref<ArrayBuffer> createAdopted(const void* data, unsigned byteLength);
+    static inline Ref<ArrayBuffer> createFromBytes(const void* data, unsigned byteLength, ArrayBufferDestructorFunction&&);
 
     // Only for use by Uint8ClampedArray::createUninitialized and SharedBuffer::createArrayBuffer.
-    static inline PassRefPtr<ArrayBuffer> createUninitialized(unsigned numElements, unsigned elementByteSize);
+    static inline RefPtr<ArrayBuffer> createUninitialized(unsigned numElements, unsigned elementByteSize);
 
     inline void* data();
     inline const void* data() const;
@@ -114,8 +113,8 @@ public:
     
     inline size_t gcSizeEstimateInBytes() const;
 
-    inline PassRefPtr<ArrayBuffer> slice(int begin, int end) const;
-    inline PassRefPtr<ArrayBuffer> slice(int begin) const;
+    inline RefPtr<ArrayBuffer> slice(int begin, int end) const;
+    inline RefPtr<ArrayBuffer> slice(int begin) const;
     
     inline void pin();
     inline void unpin();
@@ -129,10 +128,10 @@ public:
     ~ArrayBuffer() { }
 
 private:
-    static inline PassRefPtr<ArrayBuffer> create(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy);
+    static inline RefPtr<ArrayBuffer> create(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy);
 
     inline ArrayBuffer(ArrayBufferContents&);
-    inline PassRefPtr<ArrayBuffer> sliceImpl(unsigned begin, unsigned end) const;
+    inline RefPtr<ArrayBuffer> sliceImpl(unsigned begin, unsigned end) const;
     inline unsigned clampIndex(int index) const;
     static inline int clampValue(int x, int left, int right);
 
@@ -154,56 +153,56 @@ int ArrayBuffer::clampValue(int x, int left, int right)
     return x;
 }
 
-PassRefPtr<ArrayBuffer> ArrayBuffer::create(unsigned numElements, unsigned elementByteSize)
+RefPtr<ArrayBuffer> ArrayBuffer::create(unsigned numElements, unsigned elementByteSize)
 {
     return create(numElements, elementByteSize, ArrayBufferContents::ZeroInitialize);
 }
 
-PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBuffer* other)
+RefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBuffer* other)
 {
     return ArrayBuffer::create(other->data(), other->byteLength());
 }
 
-PassRefPtr<ArrayBuffer> ArrayBuffer::create(const void* source, unsigned byteLength)
+RefPtr<ArrayBuffer> ArrayBuffer::create(const void* source, unsigned byteLength)
 {
     ArrayBufferContents contents;
     ArrayBufferContents::tryAllocate(byteLength, 1, ArrayBufferContents::ZeroInitialize, contents);
     if (!contents.m_data)
-        return 0;
-    RefPtr<ArrayBuffer> buffer = adoptRef(new ArrayBuffer(contents));
+        return nullptr;
+    auto buffer = adoptRef(*new ArrayBuffer(contents));
     ASSERT(!byteLength || source);
     memcpy(buffer->data(), source, byteLength);
-    return buffer.release();
+    return WTFMove(buffer);
 }
 
-PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBufferContents& contents)
+Ref<ArrayBuffer> ArrayBuffer::create(ArrayBufferContents& contents)
 {
-    return adoptRef(new ArrayBuffer(contents));
+    return adoptRef(*new ArrayBuffer(contents));
 }
 
-PassRefPtr<ArrayBuffer> ArrayBuffer::createAdopted(const void* data, unsigned byteLength)
+Ref<ArrayBuffer> ArrayBuffer::createAdopted(const void* data, unsigned byteLength)
 {
     return createFromBytes(data, byteLength, WTFMove(arrayBufferDestructorDefault));
 }
 
-PassRefPtr<ArrayBuffer> ArrayBuffer::createFromBytes(const void* data, unsigned byteLength, ArrayBufferDestructorFunction&& destructor)
+Ref<ArrayBuffer> ArrayBuffer::createFromBytes(const void* data, unsigned byteLength, ArrayBufferDestructorFunction&& destructor)
 {
     ArrayBufferContents contents(const_cast<void*>(data), byteLength, WTFMove(destructor));
     return create(contents);
 }
 
-PassRefPtr<ArrayBuffer> ArrayBuffer::createUninitialized(unsigned numElements, unsigned elementByteSize)
+RefPtr<ArrayBuffer> ArrayBuffer::createUninitialized(unsigned numElements, unsigned elementByteSize)
 {
     return create(numElements, elementByteSize, ArrayBufferContents::DontInitialize);
 }
 
-PassRefPtr<ArrayBuffer> ArrayBuffer::create(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy policy)
+RefPtr<ArrayBuffer> ArrayBuffer::create(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy policy)
 {
     ArrayBufferContents contents;
     ArrayBufferContents::tryAllocate(numElements, elementByteSize, policy, contents);
     if (!contents.m_data)
-        return 0;
-    return adoptRef(new ArrayBuffer(contents));
+        return nullptr;
+    return adoptRef(*new ArrayBuffer(contents));
 }
 
 ArrayBuffer::ArrayBuffer(ArrayBufferContents& contents)
@@ -233,17 +232,17 @@ size_t ArrayBuffer::gcSizeEstimateInBytes() const
     return sizeof(ArrayBuffer) + static_cast<size_t>(byteLength());
 }
 
-PassRefPtr<ArrayBuffer> ArrayBuffer::slice(int begin, int end) const
+RefPtr<ArrayBuffer> ArrayBuffer::slice(int begin, int end) const
 {
     return sliceImpl(clampIndex(begin), clampIndex(end));
 }
 
-PassRefPtr<ArrayBuffer> ArrayBuffer::slice(int begin) const
+RefPtr<ArrayBuffer> ArrayBuffer::slice(int begin) const
 {
     return sliceImpl(clampIndex(begin), byteLength());
 }
 
-PassRefPtr<ArrayBuffer> ArrayBuffer::sliceImpl(unsigned begin, unsigned end) const
+RefPtr<ArrayBuffer> ArrayBuffer::sliceImpl(unsigned begin, unsigned end) const
 {
     unsigned size = begin <= end ? end - begin : 0;
     return ArrayBuffer::create(static_cast<const char*>(data()) + begin, size);
index ce1352e..61559e5 100644 (file)
@@ -1,3 +1,196 @@
+2016-03-14  Joonghun Park  <jh718.park@samsung.com>
+
+        Purge PassRefPtr from ArrayBuffer, ArchiveResource, Pasteboard, LegacyWebArchive and DataObjectGtk
+        https://bugs.webkit.org/show_bug.cgi?id=150497
+
+        Reviewed by Darin Adler.
+
+        No new tests, no new behaviours.
+
+        * Modules/indexeddb/IDBGetResult.h:
+        (WebCore::IDBGetResult::IDBGetResult):
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::getIndexRecord):
+        * Modules/mediastream/RTCDataChannel.cpp:
+        (WebCore::RTCDataChannel::didReceiveRawData):
+        * dom/MessageEvent.cpp:
+        (WebCore::MessageEvent::MessageEvent):
+        * dom/MessageEvent.h:
+        * editing/Editor.cpp:
+        (WebCore::Editor::selectedRange):
+        * editing/Editor.h:
+        * editing/FrameSelection.h:
+        (WebCore::FrameSelection::toNormalizedRange):
+        * editing/VisiblePosition.cpp:
+        (WebCore::makeRange):
+        * editing/VisiblePosition.h:
+        * editing/VisibleSelection.cpp:
+        (WebCore::VisibleSelection::toNormalizedRange):
+        * editing/VisibleSelection.h:
+        * editing/VisibleUnits.cpp:
+        (WebCore::enclosingTextUnitOfGranularity):
+        (WebCore::wordRangeFromPosition):
+        (WebCore::rangeExpandedByCharactersInDirectionAtWordBoundary):
+        (WebCore::rangeExpandedAroundPositionByCharacters):
+        * editing/VisibleUnits.h:
+        * editing/cocoa/HTMLConverter.mm:
+        (HTMLConverter::_addAttachmentForElement):
+        (fileWrapperForURL):
+        * editing/efl/EditorEfl.cpp:
+        (WebCore::Editor::webContentFromPasteboard):
+        * editing/gtk/EditorGtk.cpp:
+        (WebCore::createFragmentFromPasteboardData):
+        (WebCore::Editor::webContentFromPasteboard):
+        * editing/ios/EditorIOS.mm:
+        (WebCore::dataInRTFDFormat):
+        (WebCore::dataInRTFFormat):
+        (WebCore::Editor::selectionInWebArchiveFormat):
+        (WebCore::Editor::WebContentReader::addFragment):
+        (WebCore::Editor::WebContentReader::readWebArchive):
+        (WebCore::Editor::WebContentReader::readRTFD):
+        (WebCore::Editor::WebContentReader::readRTF):
+        (WebCore::Editor::WebContentReader::readImage):
+        (WebCore::Editor::WebContentReader::readURL):
+        (WebCore::Editor::webContentFromPasteboard):
+        (WebCore::Editor::pasteWithPasteboard):
+        (WebCore::Editor::createFragmentAndAddResources):
+        (WebCore::Editor::createFragmentForImageResourceAndAddResource):
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::selectionInWebArchiveFormat):
+        (WebCore::Editor::adjustedSelectionRange):
+        (WebCore::dataInRTFDFormat):
+        (WebCore::dataInRTFFormat):
+        (WebCore::Editor::dataSelectionForPasteboard):
+        (WebCore::Editor::WebContentReader::readWebArchive):
+        (WebCore::Editor::WebContentReader::readRTFD):
+        (WebCore::Editor::WebContentReader::readRTF):
+        (WebCore::Editor::WebContentReader::readImage):
+        (WebCore::Editor::WebContentReader::readURL):
+        (WebCore::Editor::webContentFromPasteboard):
+        (WebCore::Editor::createFragmentForImageResourceAndAddResource):
+        (WebCore::Editor::createFragmentAndAddResources):
+        * editing/win/EditorWin.cpp:
+        (WebCore::createFragmentFromPlatformData):
+        (WebCore::Editor::webContentFromPasteboard):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::archive):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::mainResourceData):
+        (WebCore::DocumentLoader::maybeCreateArchive):
+        (WebCore::DocumentLoader::addArchiveResource):
+        (WebCore::DocumentLoader::mainResource):
+        * loader/DocumentLoader.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadArchive):
+        * loader/SubstituteData.h:
+        (WebCore::SubstituteData::SubstituteData):
+        (WebCore::SubstituteData::isValid):
+        * loader/SubstituteResource.h:
+        (WebCore::SubstituteResource::data):
+        (WebCore::SubstituteResource::SubstituteResource):
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::didReceiveResponse):
+        (WebCore::ApplicationCacheGroup::didReceiveData):
+        (WebCore::ApplicationCacheGroup::didFail):
+        (WebCore::ApplicationCacheGroup::didReceiveManifestData):
+        (WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
+        * loader/appcache/ApplicationCacheHost.cpp:
+        (WebCore::ApplicationCacheHost::maybeLoadMainResource):
+        (WebCore::ApplicationCacheHost::maybeLoadSynchronously):
+        (WebCore::ApplicationCacheHost::maybeLoadFallbackSynchronously):
+        * loader/appcache/ApplicationCacheResource.cpp:
+        (WebCore::ApplicationCacheResource::ApplicationCacheResource):
+        (WebCore::ApplicationCacheResource::deliver):
+        (WebCore::ApplicationCacheResource::estimatedSizeInStorage):
+        * loader/appcache/ApplicationCacheResource.h:
+        (WebCore::ApplicationCacheResource::create):
+        * loader/appcache/ApplicationCacheStorage.cpp:
+        (WebCore::ApplicationCacheStorage::store):
+        (WebCore::ApplicationCacheStorage::writeDataToUniqueFileInDirectory):
+        * loader/appcache/ApplicationCacheStorage.h:
+        * loader/archive/ArchiveFactory.cpp:
+        (WebCore::archiveFactoryCreate):
+        (WebCore::ArchiveFactory::create):
+        * loader/archive/ArchiveFactory.h:
+        * loader/archive/ArchiveResource.cpp:
+        (WebCore::ArchiveResource::ArchiveResource):
+        (WebCore::ArchiveResource::create):
+        * loader/archive/ArchiveResource.h:
+        * loader/archive/ArchiveResourceCollection.cpp:
+        (WebCore::ArchiveResourceCollection::addResource):
+        * loader/archive/ArchiveResourceCollection.h:
+        * loader/archive/cf/LegacyWebArchive.cpp:
+        (WebCore::LegacyWebArchive::createPropertyListRepresentation):
+        (WebCore::LegacyWebArchive::createResource):
+        (WebCore::LegacyWebArchive::create):
+        (WebCore::LegacyWebArchive::createFromSelection):
+        * loader/archive/cf/LegacyWebArchive.h:
+        * loader/archive/mhtml/MHTMLArchive.cpp:
+        (WebCore::MHTMLArchive::create):
+        * loader/archive/mhtml/MHTMLArchive.h:
+        * loader/archive/mhtml/MHTMLParser.cpp:
+        (WebCore::MHTMLParser::parseArchive):
+        (WebCore::MHTMLParser::parseArchiveWithHeader):
+        (WebCore::MHTMLParser::parseNextPart):
+        * loader/archive/mhtml/MHTMLParser.h:
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::didAddClient):
+        * loader/icon/IconDatabase.cpp:
+        (WebCore::loadDefaultIconRecord):
+        * loader/icon/IconRecord.cpp:
+        (WebCore::IconRecord::setImageData):
+        * loader/icon/IconRecord.h:
+        * platform/Pasteboard.h:
+        * platform/PasteboardStrategy.h:
+        * platform/PlatformPasteboard.h:
+        * platform/SharedBuffer.cpp:
+        (WebCore::SharedBuffer::createArrayBuffer):
+        (WebCore::utf8Buffer):
+        * platform/SharedBuffer.h:
+        (WebCore::SharedBuffer::create):
+        * platform/cf/SharedBufferCF.cpp:
+        (WebCore::SharedBuffer::wrapCFData):
+        * platform/cocoa/NetworkExtensionContentFilter.mm:
+        (WebCore::NetworkExtensionContentFilter::replacementData):
+        * platform/cocoa/ParentalControlsContentFilter.mm:
+        (WebCore::ParentalControlsContentFilter::replacementData):
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::setData):
+        * platform/graphics/Image.h:
+        * platform/gtk/DataObjectGtk.cpp:
+        (WebCore::DataObjectGtk::forClipboard):
+        * platform/gtk/DataObjectGtk.h:
+        (WebCore::DataObjectGtk::create):
+        * platform/gtk/PasteboardGtk.cpp:
+        (WebCore::Pasteboard::Pasteboard):
+        (WebCore::Pasteboard::dataObject):
+        * platform/ios/PasteboardIOS.mm:
+        (WebCore::Pasteboard::read):
+        * platform/ios/PlatformPasteboardIOS.mm:
+        (WebCore::PlatformPasteboard::bufferForType):
+        (WebCore::PlatformPasteboard::readBuffer):
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::writeFileWrapperAsRTFDAttachment):
+        (WebCore::Pasteboard::read):
+        * platform/mac/PlatformPasteboardMac.mm:
+        (WebCore::PlatformPasteboard::bufferForType):
+        * platform/mac/SharedBufferMac.mm:
+        (WebCore::SharedBuffer::wrapNSData):
+        (WebCore::SharedBuffer::createFromReadingFile):
+        * platform/network/MIMEHeader.cpp:
+        (WebCore::retrieveKeyValuePairs):
+        (WebCore::MIMEHeader::parseHeader):
+        * platform/network/MIMEHeader.h:
+        * platform/soup/SharedBufferSoup.cpp:
+        (WebCore::SharedBuffer::wrapSoupBuffer):
+        * platform/win/ClipboardUtilitiesWin.cpp:
+        (WebCore::fragmentFromFilenames):
+        (WebCore::fragmentFromCFHTML):
+        (WebCore::fragmentFromHTML):
+        * platform/win/ClipboardUtilitiesWin.h:
+        * platform/win/PasteboardWin.cpp:
+        (WebCore::Pasteboard::documentFragment):
+
 2016-03-14  Oliver Hunt  <oliver@apple.com>
 
         Temporarily disable the separated heap.
index c66f6d6..3dcd7a7 100644 (file)
@@ -43,7 +43,7 @@ public:
     {
     }
 
-    IDBGetResult(PassRefPtr<SharedBuffer> buffer)
+    IDBGetResult(SharedBuffer* buffer)
     {
         if (buffer)
             dataFromBuffer(*buffer);
index 1550df4..f04480a 100644 (file)
@@ -1447,7 +1447,7 @@ IDBError SQLiteIDBBackingStore::getIndexRecord(const IDBResourceIdentifier& tran
         if (type == IndexedDB::IndexRecordType::Key)
             getResult = { cursor->currentPrimaryKey() };
         else {
-            getResult = { SharedBuffer::create(cursor->currentValueBuffer().data(), cursor->currentValueBuffer().size()) };
+            getResult = { SharedBuffer::create(cursor->currentValueBuffer().data(), cursor->currentValueBuffer().size()).ptr() };
             getResult.setKeyData(cursor->currentPrimaryKey());
         }
     }
index 4be0c58..a9a3909 100644 (file)
@@ -281,8 +281,7 @@ void RTCDataChannel::didReceiveRawData(const char* data, size_t dataLength)
     }
 
     if (m_binaryType == BinaryTypeArrayBuffer) {
-        RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(data, dataLength);
-        scheduleDispatchEvent(MessageEvent::create(buffer.release()));
+        scheduleDispatchEvent(MessageEvent::create(ArrayBuffer::create(data, dataLength)));
         return;
     }
     ASSERT_NOT_REACHED();
index 9d80bb6..de4084f 100644 (file)
@@ -102,10 +102,10 @@ MessageEvent::MessageEvent(PassRefPtr<Blob> data, const String& origin)
 {
 }
 
-MessageEvent::MessageEvent(PassRefPtr<ArrayBuffer> data, const String& origin)
+MessageEvent::MessageEvent(RefPtr<ArrayBuffer>&& data, const String& origin)
     : Event(eventNames().messageEvent, false, false)
     , m_dataType(DataTypeArrayBuffer)
-    , m_dataAsArrayBuffer(data)
+    , m_dataAsArrayBuffer(WTFMove(data))
     , m_origin(origin)
 {
 }
index 4bf52ec..c888148 100644 (file)
@@ -71,9 +71,9 @@ public:
     {
         return adoptRef(*new MessageEvent(data, origin));
     }
-    static Ref<MessageEvent> create(PassRefPtr<ArrayBuffer> data, const String& origin = String())
+    static Ref<MessageEvent> create(RefPtr<ArrayBuffer>&& data, const String& origin = String())
     {
-        return adoptRef(*new MessageEvent(data, origin));
+        return adoptRef(*new MessageEvent(WTFMove(data), origin));
     }
     static Ref<MessageEvent> createForBindings()
     {
@@ -127,7 +127,7 @@ private:
 
     explicit MessageEvent(const String& data, const String& origin);
     explicit MessageEvent(PassRefPtr<Blob> data, const String& origin);
-    explicit MessageEvent(PassRefPtr<ArrayBuffer> data, const String& origin);
+    explicit MessageEvent(RefPtr<ArrayBuffer>&& data, const String& origin);
 
     DataType m_dataType;
     Deprecated::ScriptValue m_dataAsScriptValue;
index 339736a..995f492 100644 (file)
@@ -558,7 +558,7 @@ void Editor::replaceSelectionWithText(const String& text, bool selectReplacement
     replaceSelectionWithFragment(createFragmentFromText(*range, text), selectReplacement, smartReplace, true, editingAction);
 }
 
-PassRefPtr<Range> Editor::selectedRange()
+RefPtr<Range> Editor::selectedRange()
 {
     return m_frame.selection().toNormalizedRange();
 }
index 3be1472..44b2872 100644 (file)
@@ -328,7 +328,7 @@ public:
 
     EditingBehavior behavior() const;
 
-    PassRefPtr<Range> selectedRange();
+    RefPtr<Range> selectedRange();
 
 #if PLATFORM(IOS)
     WEBCORE_EXPORT void confirmMarkedText();
@@ -426,7 +426,7 @@ public:
     WEBCORE_EXPORT void toggleAutomaticSpellingCorrection();
 #endif
 
-    PassRefPtr<DocumentFragment> webContentFromPasteboard(Pasteboard&, Range& context, bool allowPlainText, bool& chosePlainText);
+    RefPtr<DocumentFragment> webContentFromPasteboard(Pasteboard&, Range& context, bool allowPlainText, bool& chosePlainText);
 
 #if PLATFORM(COCOA)
     WEBCORE_EXPORT static RenderStyle* styleForSelectionStart(Frame* , Node *&nodeToRemove);
@@ -440,7 +440,7 @@ public:
     void takeFindStringFromSelection();
     WEBCORE_EXPORT void readSelectionFromPasteboard(const String& pasteboardName, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
     WEBCORE_EXPORT void replaceNodeFromPasteboard(Node*, const String& pasteboardName);
-    WEBCORE_EXPORT PassRefPtr<SharedBuffer> dataSelectionForPasteboard(const String& pasteboardName);
+    WEBCORE_EXPORT RefPtr<SharedBuffer> dataSelectionForPasteboard(const String& pasteboardName);
     WEBCORE_EXPORT void applyFontStyles(const String& fontFamily, double fontSize, unsigned fontTraits);
 #endif // !PLATFORM(IOS)
     WEBCORE_EXPORT void replaceSelectionWithAttributedString(NSAttributedString *, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
@@ -493,10 +493,10 @@ private:
     bool unifiedTextCheckerEnabled() const;
 
 #if PLATFORM(COCOA)
-    PassRefPtr<SharedBuffer> selectionInWebArchiveFormat();
-    PassRefPtr<Range> adjustedSelectionRange();
-    PassRefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(PassRefPtr<ArchiveResource>);
-    PassRefPtr<DocumentFragment> createFragmentAndAddResources(NSAttributedString *);
+    RefPtr<SharedBuffer> selectionInWebArchiveFormat();
+    RefPtr<Range> adjustedSelectionRange();
+    RefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&&);
+    RefPtr<DocumentFragment> createFragmentAndAddResources(NSAttributedString *);
     void fillInUserVisibleForm(PasteboardURL&);
 #endif
 
index 57ac1e2..69b5c9f 100644 (file)
@@ -185,7 +185,7 @@ public:
     bool isCaretOrRange() const { return m_selection.isCaretOrRange(); }
     bool isAll(EditingBoundaryCrossingRule rule = CannotCrossEditingBoundary) const { return m_selection.isAll(rule); }
     
-    PassRefPtr<Range> toNormalizedRange() const { return m_selection.toNormalizedRange(); }
+    RefPtr<Range> toNormalizedRange() const { return m_selection.toNormalizedRange(); }
 
     void debugRenderer(RenderObject*, bool selected) const;
 
index cb40515..2fe26d7 100644 (file)
@@ -707,7 +707,7 @@ void VisiblePosition::showTreeForThis() const
 
 #endif
 
-PassRefPtr<Range> makeRange(const VisiblePosition &start, const VisiblePosition &end)
+RefPtr<Range> makeRange(const VisiblePosition& start, const VisiblePosition& end)
 {
     if (start.isNull() || end.isNull())
         return nullptr;
index 34f1eac..eab93a0 100644 (file)
@@ -153,7 +153,7 @@ inline bool operator>=(const VisiblePosition& a, const VisiblePosition& b)
     return a.deepEquivalent() >= b.deepEquivalent();
 }    
 
-WEBCORE_EXPORT PassRefPtr<Range> makeRange(const VisiblePosition&, const VisiblePosition&);
+WEBCORE_EXPORT RefPtr<Range> makeRange(const VisiblePosition&, const VisiblePosition&);
 bool setStart(Range*, const VisiblePosition&);
 bool setEnd(Range*, const VisiblePosition&);
 VisiblePosition startVisiblePosition(const Range*, EAffinity);
index ef78c88..b794506 100644 (file)
@@ -132,10 +132,10 @@ PassRefPtr<Range> VisibleSelection::firstRange() const
     return Range::create(start.anchorNode()->document(), start, end);
 }
 
-PassRefPtr<Range> VisibleSelection::toNormalizedRange() const
+RefPtr<Range> VisibleSelection::toNormalizedRange() const
 {
     if (isNone())
-        return 0;
+        return nullptr;
 
     // Make sure we have an updated layout since this function is called
     // in the course of running edit commands which modify the DOM.
@@ -145,7 +145,7 @@ PassRefPtr<Range> VisibleSelection::toNormalizedRange() const
 
     // Check again, because updating layout can clear the selection.
     if (isNone())
-        return 0;
+        return nullptr;
 
     Position s, e;
     if (isCaret()) {
@@ -181,7 +181,7 @@ PassRefPtr<Range> VisibleSelection::toNormalizedRange() const
     }
 
     if (!s.containerNode() || !e.containerNode())
-        return 0;
+        return nullptr;
 
     // VisibleSelections are supposed to always be valid.  This constructor will ASSERT
     // if a valid range could not be created, which is fine for this callsite.
index 7b93614..fcce1e9 100644 (file)
@@ -95,7 +95,7 @@ public:
     // FIXME: Most callers probably don't want this function, but are using it
     // for historical reasons.  toNormalizedRange contracts the range around
     // text, and moves the caret upstream before returning the range.
-    WEBCORE_EXPORT PassRefPtr<Range> toNormalizedRange() const;
+    WEBCORE_EXPORT RefPtr<Range> toNormalizedRange() const;
     
     WEBCORE_EXPORT Element* rootEditableElement() const;
     WEBCORE_EXPORT bool isContentEditable() const;
index 4e93b9e..deb40fd 100644 (file)
@@ -1789,11 +1789,11 @@ VisiblePosition positionOfNextBoundaryOfGranularity(const VisiblePosition& vp, T
     }
 }
 
-PassRefPtr<Range> enclosingTextUnitOfGranularity(const VisiblePosition& vp, TextGranularity granularity, SelectionDirection direction)
+RefPtr<Range> enclosingTextUnitOfGranularity(const VisiblePosition& vp, TextGranularity granularity, SelectionDirection direction)
 {
     // This is particularly inefficient.  We could easily obtain the answer with the boundaries computed below.
     if (!withinTextUnitOfGranularity(vp, granularity, direction))
-        return 0;
+        return nullptr;
 
     VisiblePosition prevBoundary;
     VisiblePosition nextBoundary;
@@ -1845,18 +1845,16 @@ PassRefPtr<Range> enclosingTextUnitOfGranularity(const VisiblePosition& vp, Text
 
         default:
             ASSERT_NOT_REACHED();
-            return 0;
+            return nullptr;
     }
 
     if (prevBoundary.isNull() || nextBoundary.isNull())
-        return 0;
+        return nullptr;
 
     if (vp < prevBoundary || vp > nextBoundary)
-        return 0;
-
-    RefPtr<Range> range = Range::create(prevBoundary.deepEquivalent().deprecatedNode()->document(), prevBoundary, nextBoundary);
+        return nullptr;
 
-    return range;
+    return Range::create(prevBoundary.deepEquivalent().deprecatedNode()->document(), prevBoundary, nextBoundary);
 }
 
 int distanceBetweenPositions(const VisiblePosition& vp, const VisiblePosition& other)
@@ -1911,7 +1909,7 @@ void charactersAroundPosition(const VisiblePosition& position, UChar32& oneAfter
     twoBefore = characters[2];
 }
 
-PassRefPtr<Range> wordRangeFromPosition(const VisiblePosition& position)
+RefPtr<Range> wordRangeFromPosition(const VisiblePosition& position)
 {
     // The selection could be in a non visible element and we don't have a VisiblePosition.
     if (position.isNull())
@@ -1983,7 +1981,7 @@ VisiblePosition closestWordBoundaryForPosition(const VisiblePosition& position)
     return result;
 }
 
-PassRefPtr<Range> rangeExpandedByCharactersInDirectionAtWordBoundary(const VisiblePosition& position, int numberOfCharactersToExpand, SelectionDirection direction)
+RefPtr<Range> rangeExpandedByCharactersInDirectionAtWordBoundary(const VisiblePosition& position, int numberOfCharactersToExpand, SelectionDirection direction)
 {
     Position start = position.deepEquivalent();
     Position end = position.deepEquivalent();
@@ -2002,7 +2000,7 @@ PassRefPtr<Range> rangeExpandedByCharactersInDirectionAtWordBoundary(const Visib
     return makeRange(start, end);
 }    
 
-PassRefPtr<Range> rangeExpandedAroundPositionByCharacters(const VisiblePosition& position, int numberOfCharactersToExpand)
+RefPtr<Range> rangeExpandedAroundPositionByCharacters(const VisiblePosition& position, int numberOfCharactersToExpand)
 {
     Position start = position.deepEquivalent();
     Position end = position.deepEquivalent();
index 516c5db..eaaf539 100644 (file)
@@ -102,13 +102,13 @@ WEBCORE_EXPORT bool isEndOfEditableOrNonEditableContent(const VisiblePosition&);
 WEBCORE_EXPORT bool atBoundaryOfGranularity(const VisiblePosition&, TextGranularity, SelectionDirection);
 WEBCORE_EXPORT bool withinTextUnitOfGranularity(const VisiblePosition&, TextGranularity, SelectionDirection);
 WEBCORE_EXPORT VisiblePosition positionOfNextBoundaryOfGranularity(const VisiblePosition&, TextGranularity, SelectionDirection);
-WEBCORE_EXPORT PassRefPtr<Range> enclosingTextUnitOfGranularity(const VisiblePosition&, TextGranularity, SelectionDirection);
+WEBCORE_EXPORT RefPtr<Range> enclosingTextUnitOfGranularity(const VisiblePosition&, TextGranularity, SelectionDirection);
 WEBCORE_EXPORT int distanceBetweenPositions(const VisiblePosition&, const VisiblePosition&);
-WEBCORE_EXPORT PassRefPtr<Range> wordRangeFromPosition(const VisiblePosition& position);
+WEBCORE_EXPORT RefPtr<Range> wordRangeFromPosition(const VisiblePosition&);
 WEBCORE_EXPORT VisiblePosition closestWordBoundaryForPosition(const VisiblePosition& position);
 WEBCORE_EXPORT void charactersAroundPosition(const VisiblePosition&, UChar32& oneAfter, UChar32& oneBefore, UChar32& twoBefore);
-WEBCORE_EXPORT PassRefPtr<Range> rangeExpandedAroundPositionByCharacters(const VisiblePosition&, int numberOfCharactersToExpand);
-WEBCORE_EXPORT PassRefPtr<Range> rangeExpandedByCharactersInDirectionAtWordBoundary(const VisiblePosition&, int numberOfCharactersToExpand, SelectionDirection);
+WEBCORE_EXPORT RefPtr<Range> rangeExpandedAroundPositionByCharacters(const VisiblePosition&, int numberOfCharactersToExpand);
+WEBCORE_EXPORT RefPtr<Range> rangeExpandedByCharactersInDirectionAtWordBoundary(const VisiblePosition&, int numberOfCharactersToExpand, SelectionDirection);
 
 // helper function
 enum BoundarySearchContextAvailability { DontHaveMoreContext, MayHaveMoreContext };
index 2ced88f..5fa44a6 100644 (file)
@@ -1411,7 +1411,7 @@ BOOL HTMLConverter::_addAttachmentForElement(Element& element, NSURL *url, BOOL
         if (usePlaceholder && resource && mimeType == "text/html")
             notFound = YES;
         if (resource && !notFound) {
-            fileWrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:resource->data()->createNSData().get()] autorelease];
+            fileWrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:resource->data().createNSData().get()] autorelease];
             [fileWrapper setPreferredFilename:suggestedFilenameWithMIMEType(url, mimeType)];
         }
     }
@@ -2439,7 +2439,7 @@ static NSFileWrapper *fileWrapperForURL(DocumentLoader *dataSource, NSURL *URL)
 
     RefPtr<ArchiveResource> resource = dataSource->subresource(URL);
     if (resource) {
-        NSFileWrapper *wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:resource->data()->createNSData().get()] autorelease];
+        NSFileWrapper *wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:resource->data().createNSData().get()] autorelease];
         NSString *filename = resource->response().suggestedFilename();
         if (!filename || ![filename length])
             filename = suggestedFilenameWithMIMEType(resource->url(), resource->mimeType());
index 06bd5ec..7181338 100644 (file)
@@ -30,7 +30,6 @@
 #include "DocumentFragment.h"
 #include "NotImplemented.h"
 #include "Pasteboard.h"
-#include <wtf/PassRefPtr.h>
 
 namespace WebCore {
 
@@ -49,7 +48,7 @@ void Editor::pasteWithPasteboard(Pasteboard*, bool, MailBlockquoteHandling)
     notImplemented();
 }
 
-PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard&, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
+RefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard&, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
 {
     return nullptr;
 }
index 64e6f51..8a798cb 100644 (file)
 
 namespace WebCore {
 
-static PassRefPtr<DocumentFragment> createFragmentFromPasteboardData(Pasteboard& pasteboard, Frame& frame, Range& range, bool allowPlainText, bool& chosePlainText)
+static RefPtr<DocumentFragment> createFragmentFromPasteboardData(Pasteboard& pasteboard, Frame& frame, Range& range, bool allowPlainText, bool& chosePlainText)
 {
     chosePlainText = false;
 
     if (!pasteboard.hasData())
         return nullptr;
 
-    RefPtr<DataObjectGtk> dataObject = pasteboard.dataObject();
-    if (dataObject->hasMarkup() && frame.document()) {
-        if (RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(*frame.document(), dataObject->markup(), emptyString(), DisallowScriptingAndPluginContent))
-            return fragment.release();
-    }
+    DataObjectGtk* dataObject = pasteboard.dataObject();
+    if (dataObject->hasMarkup() && frame.document())
+        return createFragmentFromMarkup(*frame.document(), dataObject->markup(), emptyString(), DisallowScriptingAndPluginContent);
 
     if (!allowPlainText)
         return nullptr;
 
     if (dataObject->hasText()) {
         chosePlainText = true;
-        if (RefPtr<DocumentFragment> fragment = createFragmentFromText(range, dataObject->text()))
-            return fragment.release();
+        return createFragmentFromText(range, dataObject->text());
     }
 
     return nullptr;
@@ -129,7 +126,7 @@ void Editor::writeSelectionToPasteboard(Pasteboard& pasteboard)
     pasteboard.write(pasteboardContent);
 }
 
-PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range& context, bool allowPlainText, bool& chosePlainText)
+RefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range& context, bool allowPlainText, bool& chosePlainText)
 {
     return createFragmentFromPasteboardData(pasteboard, m_frame, context, allowPlainText, chosePlainText);
 }
index 96be87d..166faeb 100644 (file)
@@ -262,7 +262,7 @@ void Editor::removeUnchangeableStyles()
     applyStyleToSelection(defaultStyle.get(), EditActionChangeAttributes);
 }
 
-static PassRefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string)
+static RefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string)
 {
     NSUInteger length = string.length;
     if (!length)
@@ -275,7 +275,7 @@ static PassRefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string)
     return nullptr;
 }
 
-static PassRefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *string)
+static RefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *string)
 {
     NSUInteger length = string.length;
     if (!length)
@@ -295,10 +295,12 @@ String Editor::stringSelectionForPasteboardWithImageAltText()
     return text;
 }
 
-PassRefPtr<SharedBuffer> Editor::selectionInWebArchiveFormat()
+RefPtr<SharedBuffer> Editor::selectionInWebArchiveFormat()
 {
     RefPtr<LegacyWebArchive> archive = LegacyWebArchive::createFromSelection(&m_frame);
-    return archive ? SharedBuffer::wrapCFData(archive->rawDataRepresentation().get()) : nullptr;
+    if (!archive)
+        return nullptr;
+    return SharedBuffer::wrapCFData(archive->rawDataRepresentation().get());
 }
 
 void Editor::writeSelectionToPasteboard(Pasteboard& pasteboard)
@@ -361,7 +363,7 @@ public:
     {
     }
 
-    void addFragment(PassRefPtr<DocumentFragment>);
+    void addFragment(RefPtr<DocumentFragment>&&);
 
     Frame& frame;
     Range& context;
@@ -371,17 +373,17 @@ public:
     bool madeFragmentFromPlainText;
 
 private:
-    bool readWebArchive(PassRefPtr<SharedBuffer>) override;
+    bool readWebArchive(SharedBuffer*) override;
     bool readFilenames(const Vector<String>&) override;
     bool readHTML(const String&) override;
-    bool readRTFD(PassRefPtr<SharedBuffer>) override;
-    bool readRTF(PassRefPtr<SharedBuffer>) override;
-    bool readImage(PassRefPtr<SharedBuffer>, const String& type) override;
+    bool readRTFD(SharedBuffer&) override;
+    bool readRTF(SharedBuffer&) override;
+    bool readImage(Ref<SharedBuffer>&&, const String& type) override;
     bool readURL(const URL&, const String& title) override;
     bool readPlainText(const String&) override;
 };
 
-void Editor::WebContentReader::addFragment(PassRefPtr<DocumentFragment> newFragment)
+void Editor::WebContentReader::addFragment(RefPtr<DocumentFragment>&& newFragment)
 {
     if (fragment) {
         if (newFragment && newFragment->firstChild()) {
@@ -389,15 +391,18 @@ void Editor::WebContentReader::addFragment(PassRefPtr<DocumentFragment> newFragm
             fragment->appendChild(*newFragment->firstChild(), ec);
         }
     } else
-        fragment = newFragment;
+        fragment = WTFMove(newFragment);
 }
 
-bool Editor::WebContentReader::readWebArchive(PassRefPtr<SharedBuffer> buffer)
+bool Editor::WebContentReader::readWebArchive(SharedBuffer* buffer)
 {
     if (!frame.document())
         return false;
 
-    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(URL(), buffer.get());
+    if (!buffer)
+        return false;
+
+    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(URL(), *buffer);
     if (!archive)
         return false;
 
@@ -412,7 +417,7 @@ bool Editor::WebContentReader::readWebArchive(PassRefPtr<SharedBuffer> buffer)
         if (DocumentLoader* loader = frame.loader().documentLoader())
             loader->addAllArchiveResources(archive.get());
 
-        String markupString = String::fromUTF8(mainResource->data()->data(), mainResource->data()->size());
+        String markupString = String::fromUTF8(mainResource->data().data(), mainResource->data().size());
         addFragment(createFragmentFromMarkup(*frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent));
         return true;
     }
@@ -434,26 +439,26 @@ bool Editor::WebContentReader::readHTML(const String& string)
     return true;
 }
 
-bool Editor::WebContentReader::readRTFD(PassRefPtr<SharedBuffer> buffer)
+bool Editor::WebContentReader::readRTFD(SharedBuffer& buffer)
 {
-    addFragment(frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTFD:buffer->createNSData().get() documentAttributes:nullptr]).get()));
+    addFragment(frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTFD:buffer.createNSData().get() documentAttributes:nullptr]).get()));
     return fragment;
 }
 
-bool Editor::WebContentReader::readRTF(PassRefPtr<SharedBuffer> buffer)
+bool Editor::WebContentReader::readRTF(SharedBuffer& buffer)
 {
-    addFragment(frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTF:buffer->createNSData().get() documentAttributes:nullptr]).get()));
+    addFragment(frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTF:buffer.createNSData().get() documentAttributes:nullptr]).get()));
     return fragment;
 }
 
-bool Editor::WebContentReader::readImage(PassRefPtr<SharedBuffer> buffer, const String& type)
+bool Editor::WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type)
 {
     RetainPtr<CFStringRef> stringType = type.createCFString();
     RetainPtr<NSString> filenameExtension = adoptNS((NSString *)UTTypeCopyPreferredTagWithClass(stringType.get(), kUTTagClassFilenameExtension));
     NSString *relativeURLPart = [@"image" stringByAppendingString:filenameExtension.get()];
     RetainPtr<NSString> mimeType = adoptNS((NSString *)UTTypeCopyPreferredTagWithClass(stringType.get(), kUTTagClassMIMEType));
 
-    addFragment(frame.editor().createFragmentForImageResourceAndAddResource(ArchiveResource::create(buffer, URL::fakeURLWithRelativePart(relativeURLPart), mimeType.get(), emptyString(), emptyString())));
+    addFragment(frame.editor().createFragmentForImageResourceAndAddResource(ArchiveResource::create(WTFMove(buffer), URL::fakeURLWithRelativePart(relativeURLPart), mimeType.get(), emptyString(), emptyString())));
     return fragment;
 }
 
@@ -483,13 +488,13 @@ bool Editor::WebContentReader::readURL(const URL& url, const String&)
             return fragment;
         }
     } else {
-        Ref<Element> anchor = frame.document()->createElement(HTMLNames::aTag, false);
+        auto anchor = frame.document()->createElement(HTMLNames::aTag, false);
         anchor->setAttribute(HTMLNames::hrefAttr, url.string());
         anchor->appendChild(frame.document()->createTextNode([[(NSURL *)url absoluteString] precomposedStringWithCanonicalMapping]));
 
-        RefPtr<DocumentFragment> newFragment = frame.document()->createDocumentFragment();
+        auto newFragment = frame.document()->createDocumentFragment();
         newFragment->appendChild(WTFMove(anchor));
-        addFragment(newFragment);
+        addFragment(WTFMove(newFragment));
         return true;
     }
     return false;
@@ -510,12 +515,12 @@ bool Editor::WebContentReader::readPlainText(const String& text)
 
 // FIXME: Should give this function a name that makes it clear it adds resources to the document loader as a side effect.
 // Or refactor so it does not do that.
-PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range& context, bool allowPlainText, bool& chosePlainText)
+RefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range& context, bool allowPlainText, bool& chosePlainText)
 {
     WebContentReader reader(m_frame, context, allowPlainText);
     pasteboard.read(reader);
     chosePlainText = reader.madeFragmentFromPlainText;
-    return reader.fragment.release();
+    return WTFMove(reader.fragment);
 }
 
 void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, MailBlockquoteHandling mailBlockquoteHandling)
@@ -528,7 +533,7 @@ void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, Ma
         if (!fragment)
             continue;
 
-        reader.addFragment(fragment);
+        reader.addFragment(WTFMove(fragment));
     }
 
     RefPtr<DocumentFragment> fragment = reader.fragment;
@@ -541,7 +546,7 @@ void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, Ma
         pasteAsFragment(fragment.releaseNonNull(), canSmartReplaceWithPasteboard(*pasteboard), false, mailBlockquoteHandling);
 }
 
-PassRefPtr<DocumentFragment> Editor::createFragmentAndAddResources(NSAttributedString *string)
+RefPtr<DocumentFragment> Editor::createFragmentAndAddResources(NSAttributedString *string)
 {
     if (!m_frame.page() || !m_frame.document() || !m_frame.document()->isHTMLDocument())
         return nullptr;
@@ -557,33 +562,36 @@ PassRefPtr<DocumentFragment> Editor::createFragmentAndAddResources(NSAttributedS
     RefPtr<DocumentFragment> fragment = client()->documentFragmentFromAttributedString(string, resources);
 
     if (DocumentLoader* loader = m_frame.loader().documentLoader()) {
-        for (auto& resource : resources)
-            loader->addArchiveResource(resource);
+        for (auto& resource : resources) {
+            if (resource)
+                loader->addArchiveResource(resource.releaseNonNull());
+        }
     }
 
     if (!wasDeferringCallbacks)
         m_frame.page()->setDefersLoading(false);
     
-    return fragment.release();
+    return fragment;
 }
 
-PassRefPtr<DocumentFragment> Editor::createFragmentForImageResourceAndAddResource(PassRefPtr<ArchiveResource> resource)
+RefPtr<DocumentFragment> Editor::createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&& resource)
 {
     if (!resource)
         return nullptr;
 
     Ref<Element> imageElement = m_frame.document()->createElement(HTMLNames::imgTag, false);
-    // FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here?
-    if (DocumentLoader* loader = m_frame.loader().documentLoader())
-        loader->addArchiveResource(resource.get());
 
     NSURL *URL = resource->url();
     imageElement->setAttribute(HTMLNames::srcAttr, [URL isFileURL] ? [URL absoluteString] : resource->url());
 
-    RefPtr<DocumentFragment> fragment = m_frame.document()->createDocumentFragment();
+    // FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here?
+    if (DocumentLoader* loader = m_frame.loader().documentLoader())
+        loader->addArchiveResource(resource.releaseNonNull());
+
+    auto fragment = m_frame.document()->createDocumentFragment();
     fragment->appendChild(WTFMove(imageElement));
 
-    return fragment.release();
+    return WTFMove(fragment);
 }
 
 void Editor::replaceSelectionWithAttributedString(NSAttributedString *attributedString, MailBlockquoteHandling mailBlockquoteHandling)
index cfe9c39..125c5a9 100644 (file)
@@ -301,13 +301,15 @@ String Editor::stringSelectionForPasteboardWithImageAltText()
     return text;
 }
 
-PassRefPtr<SharedBuffer> Editor::selectionInWebArchiveFormat()
+RefPtr<SharedBuffer> Editor::selectionInWebArchiveFormat()
 {
     RefPtr<LegacyWebArchive> archive = LegacyWebArchive::createFromSelection(&m_frame);
-    return archive ? SharedBuffer::wrapCFData(archive->rawDataRepresentation().get()) : 0;
+    if (!archive)
+        return nullptr;
+    return SharedBuffer::wrapCFData(archive->rawDataRepresentation().get());
 }
 
-PassRefPtr<Range> Editor::adjustedSelectionRange()
+RefPtr<Range> Editor::adjustedSelectionRange()
 {
     // FIXME: Why do we need to adjust the selection to include the anchor tag it's in?
     // Whoever wrote this code originally forgot to leave us a comment explaining the rationale.
@@ -320,7 +322,7 @@ PassRefPtr<Range> Editor::adjustedSelectionRange()
     return range;
 }
     
-static PassRefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string)
+static RefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string)
 {
     NSUInteger length = string.length;
     if (!length)
@@ -333,7 +335,7 @@ static PassRefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string)
     return nullptr;
 }
 
-static PassRefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *string)
+static RefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *string)
 {
     NSUInteger length = string.length;
     if (!length)
@@ -346,7 +348,7 @@ static PassRefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *string)
     return nullptr;
 }
 
-PassRefPtr<SharedBuffer> Editor::dataSelectionForPasteboard(const String& pasteboardType)
+RefPtr<SharedBuffer> Editor::dataSelectionForPasteboard(const String& pasteboardType)
 {
     // FIXME: The interface to this function is awkward. We'd probably be better off with three separate functions.
     // As of this writing, this is only used in WebKit2 to implement the method -[WKView writeSelectionToPasteboard:types:],
@@ -370,7 +372,7 @@ PassRefPtr<SharedBuffer> Editor::dataSelectionForPasteboard(const String& pasteb
         return dataInRTFFormat(attributedString);
     }
 
-    return 0;
+    return nullptr;
 }
 
 void Editor::writeSelectionToPasteboard(Pasteboard& pasteboard)
@@ -460,22 +462,25 @@ public:
     }
 
 private:
-    bool readWebArchive(PassRefPtr<SharedBuffer>) override;
+    bool readWebArchive(SharedBuffer*) override;
     bool readFilenames(const Vector<String>&) override;
     bool readHTML(const String&) override;
-    bool readRTFD(PassRefPtr<SharedBuffer>) override;
-    bool readRTF(PassRefPtr<SharedBuffer>) override;
-    bool readImage(PassRefPtr<SharedBuffer>, const String& type) override;
+    bool readRTFD(SharedBuffer&) override;
+    bool readRTF(SharedBuffer&) override;
+    bool readImage(Ref<SharedBuffer>&&, const String& type) override;
     bool readURL(const URL&, const String& title) override;
     bool readPlainText(const String&) override;
 };
 
-bool Editor::WebContentReader::readWebArchive(PassRefPtr<SharedBuffer> buffer)
+bool Editor::WebContentReader::readWebArchive(SharedBuffer* buffer)
 {
     if (!frame.document())
         return false;
 
-    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(URL(), buffer.get());
+    if (!buffer)
+        return false;
+
+    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(URL(), *buffer);
     if (!archive)
         return false;
 
@@ -490,13 +495,13 @@ bool Editor::WebContentReader::readWebArchive(PassRefPtr<SharedBuffer> buffer)
         if (DocumentLoader* loader = frame.loader().documentLoader())
             loader->addAllArchiveResources(archive.get());
 
-        String markupString = String::fromUTF8(mainResource->data()->data(), mainResource->data()->size());
+        String markupString = String::fromUTF8(mainResource->data().data(), mainResource->data().size());
         fragment = createFragmentFromMarkup(*frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent);
         return true;
     }
 
     if (MIMETypeRegistry::isSupportedImageMIMEType(type)) {
-        fragment = frame.editor().createFragmentForImageResourceAndAddResource(mainResource.release());
+        fragment = frame.editor().createFragmentForImageResourceAndAddResource(WTFMove(mainResource));
         return true;
     }
 
@@ -553,26 +558,26 @@ bool Editor::WebContentReader::readHTML(const String& string)
     return fragment;
 }
 
-bool Editor::WebContentReader::readRTFD(PassRefPtr<SharedBuffer> buffer)
+bool Editor::WebContentReader::readRTFD(SharedBuffer& buffer)
 {
-    fragment = frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTFD:buffer->createNSData().get() documentAttributes:nullptr]).get());
+    fragment = frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTFD:buffer.createNSData().get() documentAttributes:nullptr]).get());
     return fragment;
 }
 
-bool Editor::WebContentReader::readRTF(PassRefPtr<SharedBuffer> buffer)
+bool Editor::WebContentReader::readRTF(SharedBuffer& buffer)
 {
-    fragment = frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTF:buffer->createNSData().get() documentAttributes:nullptr]).get());
+    fragment = frame.editor().createFragmentAndAddResources(adoptNS([[NSAttributedString alloc] initWithRTF:buffer.createNSData().get() documentAttributes:nullptr]).get());
     return fragment;
 }
 
-bool Editor::WebContentReader::readImage(PassRefPtr<SharedBuffer> buffer, const String& type)
+bool Editor::WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type)
 {
     ASSERT(type.contains('/'));
     String typeAsFilenameWithExtension = type;
     typeAsFilenameWithExtension.replace('/', '.');
     URL imageURL = URL::fakeURLWithRelativePart(typeAsFilenameWithExtension);
 
-    fragment = frame.editor().createFragmentForImageResourceAndAddResource(ArchiveResource::create(buffer, imageURL, type, emptyString(), emptyString()));
+    fragment = frame.editor().createFragmentForImageResourceAndAddResource(ArchiveResource::create(WTFMove(buffer), imageURL, type, emptyString(), emptyString()));
     return fragment;
 }
 
@@ -581,7 +586,7 @@ bool Editor::WebContentReader::readURL(const URL& url, const String& title)
     if (url.string().isEmpty())
         return false;
 
-    Ref<Element> anchor = frame.document()->createElement(HTMLNames::aTag, false);
+    auto anchor = frame.document()->createElement(HTMLNames::aTag, false);
     anchor->setAttribute(HTMLNames::hrefAttr, url.string());
     anchor->appendChild(frame.document()->createTextNode([title precomposedStringWithCanonicalMapping]));
 
@@ -605,33 +610,33 @@ bool Editor::WebContentReader::readPlainText(const String& text)
 
 // FIXME: Should give this function a name that makes it clear it adds resources to the document loader as a side effect.
 // Or refactor so it does not do that.
-PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range& context, bool allowPlainText, bool& chosePlainText)
+RefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range& context, bool allowPlainText, bool& chosePlainText)
 {
     WebContentReader reader(m_frame, context, allowPlainText);
     pasteboard.read(reader);
     chosePlainText = reader.madeFragmentFromPlainText;
-    return reader.fragment.release();
+    return WTFMove(reader.fragment);
 }
 
-PassRefPtr<DocumentFragment> Editor::createFragmentForImageResourceAndAddResource(PassRefPtr<ArchiveResource> resource)
+RefPtr<DocumentFragment> Editor::createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&& resource)
 {
     if (!resource)
         return nullptr;
 
+    auto imageElement = document().createElement(HTMLNames::imgTag, false);
+    imageElement->setAttribute(HTMLNames::srcAttr, resource->url().string());
+
     // FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here?
     if (DocumentLoader* loader = m_frame.loader().documentLoader())
-        loader->addArchiveResource(resource.get());
-
-    Ref<Element> imageElement = document().createElement(HTMLNames::imgTag, false);
-    imageElement->setAttribute(HTMLNames::srcAttr, resource->url().string());
+        loader->addArchiveResource(resource.releaseNonNull());
 
-    RefPtr<DocumentFragment> fragment = document().createDocumentFragment();
+    auto fragment = document().createDocumentFragment();
     fragment->appendChild(WTFMove(imageElement));
 
-    return fragment.release();
+    return WTFMove(fragment);
 }
 
-PassRefPtr<DocumentFragment> Editor::createFragmentAndAddResources(NSAttributedString *string)
+RefPtr<DocumentFragment> Editor::createFragmentAndAddResources(NSAttributedString *string)
 {
     if (!m_frame.page() || !document().isHTMLDocument())
         return nullptr;
@@ -647,14 +652,16 @@ PassRefPtr<DocumentFragment> Editor::createFragmentAndAddResources(NSAttributedS
     RefPtr<DocumentFragment> fragment = client()->documentFragmentFromAttributedString(string, resources);
 
     if (DocumentLoader* loader = m_frame.loader().documentLoader()) {
-        for (auto& resource : resources)
-            loader->addArchiveResource(resource);
+        for (auto& resource : resources) {
+            if (resource)
+                loader->addArchiveResource(resource.releaseNonNull());
+        }
     }
 
     if (!wasDeferringCallbacks)
         m_frame.page()->setDefersLoading(false);
 
-    return fragment.release();
+    return fragment;
 }
 
 void Editor::replaceSelectionWithAttributedString(NSAttributedString *attributedString, MailBlockquoteHandling mailBlockquoteHandling)
index 215d6f8..df0f235 100644 (file)
@@ -48,7 +48,7 @@ void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, Ma
 }
 
 template <typename PlatformDragData>
-static PassRefPtr<DocumentFragment> createFragmentFromPlatformData(PlatformDragData& platformDragData, Frame& frame)
+static RefPtr<DocumentFragment> createFragmentFromPlatformData(PlatformDragData& platformDragData, Frame& frame)
 {
     if (containsFilenames(&platformDragData)) {
         if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(frame.document(), &platformDragData))
@@ -56,13 +56,13 @@ static PassRefPtr<DocumentFragment> createFragmentFromPlatformData(PlatformDragD
     }
 
     if (containsHTML(&platformDragData)) {
-        if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(frame.document(), &platformDragData))
+        if (RefPtr<DocumentFragment> fragment = fragmentFromHTML(frame.document(), &platformDragData))
             return fragment;
     }
     return nullptr;
 }
 
-PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
+RefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
 {
     if (COMPtr<IDataObject> platformDragData = pasteboard.dataObject())
         return createFragmentFromPlatformData(*platformDragData, m_frame);
index 80ae7f2..7234c84 100644 (file)
@@ -1045,7 +1045,7 @@ void InspectorPageAgent::archive(ErrorString& errorString, String* data)
 {
 #if ENABLE(WEB_ARCHIVE) && USE(CF)
     Frame& frame = mainFrame();
-    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(&frame);
+    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(frame);
     if (!archive) {
         errorString = ASCIILiteral("Could not create web archive for main frame");
         return;
index 7017ea3..f3833c6 100644 (file)
@@ -173,7 +173,7 @@ DocumentLoader::~DocumentLoader()
     clearMainResource();
 }
 
-PassRefPtr<SharedBuffer> DocumentLoader::mainResourceData() const
+RefPtr<SharedBuffer> DocumentLoader::mainResourceData() const
 {
     if (m_substituteData.isValid())
         return m_substituteData.content()->copy();
@@ -1067,11 +1067,11 @@ bool DocumentLoader::maybeCreateArchive()
     
     addAllArchiveResources(m_archive.get());
     ArchiveResource* mainResource = m_archive->mainResource();
-    m_parsedArchiveData = mainResource->data();
+    m_parsedArchiveData = &mainResource->data();
     m_writer.setMIMEType(mainResource->mimeType());
     
     ASSERT(m_frame->document());
-    commitData(mainResource->data()->data(), mainResource->data()->size());
+    commitData(mainResource->data().data(), mainResource->data().size());
     return true;
 #endif // !ENABLE(WEB_ARCHIVE) && !ENABLE(MHTML)
 }
@@ -1098,16 +1098,12 @@ void DocumentLoader::addAllArchiveResources(Archive* archive)
 
 // FIXME: Adding a resource directly to a DocumentLoader/ArchiveResourceCollection seems like bad design, but is API some apps rely on.
 // Can we change the design in a manner that will let us deprecate that API without reducing functionality of those apps?
-void DocumentLoader::addArchiveResource(PassRefPtr<ArchiveResource> resource)
+void DocumentLoader::addArchiveResource(Ref<ArchiveResource>&& resource)
 {
     if (!m_archiveResourceCollection)
         m_archiveResourceCollection = std::make_unique<ArchiveResourceCollection>();
         
-    ASSERT(resource);
-    if (!resource)
-        return;
-        
-    m_archiveResourceCollection->addResource(resource);
+    m_archiveResourceCollection->addResource(WTFMove(resource));
 }
 
 PassRefPtr<Archive> DocumentLoader::popArchiveForSubframe(const String& frameName, const URL& url)
@@ -1138,14 +1134,14 @@ ArchiveResource* DocumentLoader::archiveResourceForURL(const URL& url) const
     return resource;
 }
 
-PassRefPtr<ArchiveResource> DocumentLoader::mainResource() const
+RefPtr<ArchiveResource> DocumentLoader::mainResource() const
 {
     RefPtr<SharedBuffer> data = mainResourceData();
     if (!data)
         data = SharedBuffer::create();
         
     auto& response = this->response();
-    return ArchiveResource::create(data, response.url(), response.mimeType(), response.textEncodingName(), frame()->tree().uniqueName());
+    return ArchiveResource::create(WTFMove(data), response.url(), response.mimeType(), response.textEncodingName(), frame()->tree().uniqueName());
 }
 
 PassRefPtr<ArchiveResource> DocumentLoader::subresource(const URL& url) const
index 19caeb3..6b14c5f 100644 (file)
@@ -100,7 +100,7 @@ namespace WebCore {
 
         WEBCORE_EXPORT FrameLoader* frameLoader() const;
         WEBCORE_EXPORT SubresourceLoader* mainResourceLoader() const;
-        WEBCORE_EXPORT PassRefPtr<SharedBuffer> mainResourceData() const;
+        WEBCORE_EXPORT RefPtr<SharedBuffer> mainResourceData() const;
         
         DocumentWriter& writer() const { return m_writer; }
 
@@ -156,7 +156,7 @@ namespace WebCore {
 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
         void setArchive(PassRefPtr<Archive>);
         WEBCORE_EXPORT void addAllArchiveResources(Archive*);
-        WEBCORE_EXPORT void addArchiveResource(PassRefPtr<ArchiveResource>);
+        WEBCORE_EXPORT void addArchiveResource(Ref<ArchiveResource>&&);
         PassRefPtr<Archive> popArchiveForSubframe(const String& frameName, const URL&);
         WEBCORE_EXPORT SharedBuffer* parsedArchiveData() const;
 
@@ -167,7 +167,7 @@ namespace WebCore {
         // Return the ArchiveResource for the URL only when loading an Archive
         WEBCORE_EXPORT ArchiveResource* archiveResourceForURL(const URL&) const;
 
-        WEBCORE_EXPORT PassRefPtr<ArchiveResource> mainResource() const;
+        WEBCORE_EXPORT RefPtr<ArchiveResource> mainResource() const;
 
         // Return an ArchiveResource for the URL, either creating from live data or
         // pulling from the ArchiveResourceCollection
index 14e3087..b5b51e2 100644 (file)
@@ -892,8 +892,8 @@ void FrameLoader::loadArchive(PassRefPtr<Archive> archive)
     if (!mainResource)
         return;
 
-    ResourceResponse response(URL(), mainResource->mimeType(), mainResource->data()->size(), mainResource->textEncoding());
-    SubstituteData substituteData(mainResource->data(), URL(), response, SubstituteData::SessionHistoryVisibility::Hidden);
+    ResourceResponse response(URL(), mainResource->mimeType(), mainResource->data().size(), mainResource->textEncoding());
+    SubstituteData substituteData(&mainResource->data(), URL(), response, SubstituteData::SessionHistoryVisibility::Hidden);
     
     ResourceRequest request(mainResource->url());
 #if PLATFORM(MAC)
index 99c46e0..5c9850c 100644 (file)
@@ -45,15 +45,15 @@ namespace WebCore {
         {
         }
 
-        SubstituteData(PassRefPtr<SharedBuffer> content, const URL& failingURL, const ResourceResponse& response, SessionHistoryVisibility shouldRevealToSessionHistory)
-            : m_content(content)
+        SubstituteData(RefPtr<SharedBuffer>&& content, const URL& failingURL, const ResourceResponse& response, SessionHistoryVisibility shouldRevealToSessionHistory)
+            : m_content(WTFMove(content))
             , m_failingURL(failingURL)
             , m_response(response)
             , m_shouldRevealToSessionHistory(shouldRevealToSessionHistory)
         {
         }
 
-        bool isValid() const { return m_content != 0; }
+        bool isValid() const { return m_content != nullptr; }
         bool shouldRevealToSessionHistory() const { return m_shouldRevealToSessionHistory == SessionHistoryVisibility::Visible; }
 
         const SharedBuffer* content() const { return m_content.get(); }
index 3e2b01d..292c15f 100644 (file)
@@ -38,23 +38,22 @@ public:
 
     const URL& url() const { return m_url; }
     const ResourceResponse& response() const { return m_response; }
-    SharedBuffer* data() const { return m_data.get(); }
+    SharedBuffer& data() const { return static_reference_cast<SharedBuffer>(m_data); }
 
     virtual void deliver(ResourceLoader& loader) { loader.deliverResponseAndData(m_response, m_data->copy()); }
 
 protected:
-    SubstituteResource(const URL& url, const ResourceResponse& response, PassRefPtr<SharedBuffer> data)
+    SubstituteResource(const URL& url, const ResourceResponse& response, Ref<SharedBuffer>&& data)
         : m_url(url)
         , m_response(response)
-        , m_data(data)
+        , m_data(WTFMove(data))
     {
-        ASSERT(m_data);
     }
 
 private:
     URL m_url;
     ResourceResponse m_response;
-    RefPtr<SharedBuffer> m_data;
+    Ref<SharedBuffer> m_data;
 };
 
 }
index 41b634d..cd38a01 100644 (file)
@@ -518,7 +518,7 @@ void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, const Res
     if (m_newestCache && response.httpStatusCode() == 304) { // Not modified.
         ApplicationCacheResource* newestCachedResource = m_newestCache->resourceForURL(url);
         if (newestCachedResource) {
-            m_cacheBeingUpdated->addResource(ApplicationCacheResource::create(url, newestCachedResource->response(), type, newestCachedResource->data(), newestCachedResource->path()));
+            m_cacheBeingUpdated->addResource(ApplicationCacheResource::create(url, newestCachedResource->response(), type, &newestCachedResource->data(), newestCachedResource->path()));
             m_pendingEntries.remove(m_currentHandle->firstRequest().url());
             m_currentHandle->cancel();
             m_currentHandle = nullptr;
@@ -548,7 +548,7 @@ void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, const Res
             ASSERT(m_newestCache);
             ApplicationCacheResource* newestCachedResource = m_newestCache->resourceForURL(handle->firstRequest().url());
             ASSERT(newestCachedResource);
-            m_cacheBeingUpdated->addResource(ApplicationCacheResource::create(url, newestCachedResource->response(), type, newestCachedResource->data(), newestCachedResource->path()));
+            m_cacheBeingUpdated->addResource(ApplicationCacheResource::create(url, newestCachedResource->response(), type, &newestCachedResource->data(), newestCachedResource->path()));
             m_pendingEntries.remove(m_currentHandle->firstRequest().url());
             m_currentHandle->cancel();
             m_currentHandle = nullptr;
@@ -575,7 +575,7 @@ void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* d
     ASSERT(handle == m_currentHandle);
     
     ASSERT(m_currentResource);
-    m_currentResource->data()->append(data, length);
+    m_currentResource->data().append(data, length);
 }
 
 void ApplicationCacheGroup::didFinishLoading(ResourceHandle* handle, double finishTime)
@@ -644,7 +644,7 @@ void ApplicationCacheGroup::didFail(ResourceHandle* handle, const ResourceError&
         ASSERT(m_newestCache);
         ApplicationCacheResource* newestCachedResource = m_newestCache->resourceForURL(url);
         ASSERT(newestCachedResource);
-        m_cacheBeingUpdated->addResource(ApplicationCacheResource::create(url, newestCachedResource->response(), type, newestCachedResource->data(), newestCachedResource->path()));
+        m_cacheBeingUpdated->addResource(ApplicationCacheResource::create(url, newestCachedResource->response(), type, &newestCachedResource->data(), newestCachedResource->path()));
         // Load the next resource, if any.
         startLoadingEntry();
     }
@@ -685,7 +685,7 @@ void ApplicationCacheGroup::didReceiveManifestResponse(const ResourceResponse& r
 void ApplicationCacheGroup::didReceiveManifestData(const char* data, int length)
 {
     if (m_manifestResource)
-        m_manifestResource->data()->append(data, length);
+        m_manifestResource->data().append(data, length);
 }
 
 void ApplicationCacheGroup::didFinishLoadingManifest()
@@ -707,7 +707,7 @@ void ApplicationCacheGroup::didFinishLoadingManifest()
         ASSERT(newestManifest);
     
         if (!m_manifestResource || // The resource will be null if HTTP response was 304 Not Modified.
-            (newestManifest->data()->size() == m_manifestResource->data()->size() && !memcmp(newestManifest->data()->data(), m_manifestResource->data()->data(), newestManifest->data()->size()))) {
+            (newestManifest->data().size() == m_manifestResource->data().size() && !memcmp(newestManifest->data().data(), m_manifestResource->data().data(), newestManifest->data().size()))) {
 
             m_completionType = NoUpdate;
             m_manifestResource = nullptr;
@@ -718,7 +718,7 @@ void ApplicationCacheGroup::didFinishLoadingManifest()
     }
     
     Manifest manifest;
-    if (!parseManifest(m_manifestURL, m_manifestResource->data()->data(), m_manifestResource->data()->size(), manifest)) {
+    if (!parseManifest(m_manifestURL, m_manifestResource->data().data(), m_manifestResource->data().size(), manifest)) {
         // At the time of this writing, lack of "CACHE MANIFEST" signature is the only reason for parseManifest to fail.
         m_frame->document()->addConsoleMessage(MessageSource::AppCache, MessageLevel::Error, ASCIILiteral("Application Cache manifest could not be parsed. Does it start with CACHE MANIFEST?"));
         cacheUpdateFailed();
index 847b071..55a24cf 100644 (file)
@@ -94,7 +94,7 @@ void ApplicationCacheHost::maybeLoadMainResource(ResourceRequest& request, Subst
                 responseToUse.setURL(url);
             }
 
-            substituteData = SubstituteData(resource->data(),
+            substituteData = SubstituteData(&resource->data(),
                                             URL(),
                                             responseToUse,
                                             SubstituteData::SessionHistoryVisibility::Visible);
@@ -237,7 +237,7 @@ bool ApplicationCacheHost::maybeLoadSynchronously(ResourceRequest& request, Reso
             // FIXME: Clients proably do not need a copy of the SharedBuffer.
             // Remove the call to copy() once we ensure SharedBuffer will not be modified.
             if (resource->path().isEmpty())
-                data = resource->data()->copy();
+                data = resource->data().copy();
             else
                 data = SharedBuffer::createWithContentsOfFile(resource->path());
         }
@@ -263,7 +263,7 @@ void ApplicationCacheHost::maybeLoadFallbackSynchronously(const ResourceRequest&
             response = resource->response();
             // FIXME: Clients proably do not need a copy of the SharedBuffer.
             // Remove the call to copy() once we ensure SharedBuffer will not be modified.
-            data = resource->data()->copy();
+            data = resource->data().copy();
         }
     }
 }
index bf06408..f854a72 100644 (file)
@@ -29,8 +29,8 @@
 
 namespace WebCore {
 
-ApplicationCacheResource::ApplicationCacheResource(const URL& url, const ResourceResponse& response, unsigned type, PassRefPtr<SharedBuffer> data, const String& path)
-    : SubstituteResource(url, response, data)
+ApplicationCacheResource::ApplicationCacheResource(const URL& url, const ResourceResponse& response, unsigned type, Ref<SharedBuffer>&& data, const String& path)
+    : SubstituteResource(url, response, WTFMove(data))
     , m_type(type)
     , m_storageID(0)
     , m_estimatedSizeInStorage(0)
@@ -40,7 +40,7 @@ ApplicationCacheResource::ApplicationCacheResource(const URL& url, const Resourc
 
 void ApplicationCacheResource::deliver(ResourceLoader& loader)
 {
-    loader.deliverResponseAndData(response(), m_path.isEmpty() ? data()->copy() : SharedBuffer::createWithContentsOfFile(m_path));
+    loader.deliverResponseAndData(response(), m_path.isEmpty() ? data().copy() : SharedBuffer::createWithContentsOfFile(m_path));
 }
 
 void ApplicationCacheResource::addType(unsigned type) 
@@ -54,8 +54,7 @@ int64_t ApplicationCacheResource::estimatedSizeInStorage()
     if (m_estimatedSizeInStorage)
       return m_estimatedSizeInStorage;
 
-    if (data())
-        m_estimatedSizeInStorage = data()->size();
+    m_estimatedSizeInStorage = data().size();
 
     for (const auto& headerField : response().httpHeaderFields())
         m_estimatedSizeInStorage += (headerField.key.length() + headerField.value.length() + 2) * sizeof(UChar);
index 9a23cd7..d7947b5 100644 (file)
@@ -40,10 +40,12 @@ public:
         Fallback = 1 << 4
     };
         
-    static Ref<ApplicationCacheResource> create(const URL& url, const ResourceResponse& response, unsigned type, PassRefPtr<SharedBuffer> buffer = SharedBuffer::create(), const String& path = String())
+    static Ref<ApplicationCacheResource> create(const URL& url, const ResourceResponse& response, unsigned type, RefPtr<SharedBuffer> buffer = SharedBuffer::create(), const String& path = String())
     {
         ASSERT(!url.hasFragmentIdentifier());
-        return adoptRef(*new ApplicationCacheResource(url, response, type, buffer, path));
+        if (!buffer)
+            buffer = SharedBuffer::create();
+        return adoptRef(*new ApplicationCacheResource(url, response, type, buffer.releaseNonNull(), path));
     }
 
     unsigned type() const { return m_type; }
@@ -62,7 +64,7 @@ public:
 #endif
     
 private:
-    ApplicationCacheResource(const URL&, const ResourceResponse&, unsigned type, PassRefPtr<SharedBuffer>, const String& path);
+    ApplicationCacheResource(const URL&, const ResourceResponse&, unsigned type, Ref<SharedBuffer>&&, const String& path);
 
     void deliver(ResourceLoader&) override;
 
index 9d27b32..2c6cee9 100644 (file)
@@ -818,7 +818,7 @@ bool ApplicationCacheStorage::store(ApplicationCacheResource* resource, unsigned
     else if (shouldStoreResourceAsFlatFile(resource)) {
         // First, check to see if creating the flat file would violate the maximum total quota. We don't need
         // to check the per-origin quota here, as it was already checked in storeNewestCache().
-        if (m_database.totalSize() + flatFileAreaSize() + resource->data()->size() > m_maximumSize) {
+        if (m_database.totalSize() + flatFileAreaSize() + resource->data().size() > m_maximumSize) {
             m_isMaximumSizeReached = true;
             return false;
         }
@@ -841,8 +841,8 @@ bool ApplicationCacheStorage::store(ApplicationCacheResource* resource, unsigned
         resource->setPath(fullPath);
         dataStatement.bindText(2, path);
     } else {
-        if (resource->data()->size())
-            dataStatement.bindBlob(1, resource->data()->data(), resource->data()->size());
+        if (resource->data().size())
+            dataStatement.bindBlob(1, resource->data().data(), resource->data().size());
     }
     
     if (!dataStatement.executeCommand()) {
@@ -905,7 +905,7 @@ bool ApplicationCacheStorage::store(ApplicationCacheResource* resource, unsigned
     // release the resource's data and free up a potentially large amount
     // of memory:
     if (!fullPath.isEmpty())
-        resource->data()->clear();
+        resource->data().clear();
 
     resource->setStorageID(resourceId);
     return true;
@@ -1302,7 +1302,7 @@ bool ApplicationCacheStorage::shouldStoreResourceAsFlatFile(ApplicationCacheReso
         || resource->response().mimeType().startsWith("video/", false);
 }
     
-bool ApplicationCacheStorage::writeDataToUniqueFileInDirectory(SharedBuffer* data, const String& directory, String& path, const String& fileExtension)
+bool ApplicationCacheStorage::writeDataToUniqueFileInDirectory(SharedBuffer& data, const String& directory, String& path, const String& fileExtension)
 {
     String fullPath;
     
@@ -1321,10 +1321,10 @@ bool ApplicationCacheStorage::writeDataToUniqueFileInDirectory(SharedBuffer* dat
     if (!handle)
         return false;
     
-    int64_t writtenBytes = writeToFile(handle, data->data(), data->size());
+    int64_t writtenBytes = writeToFile(handle, data.data(), data.size());
     closeFile(handle);
     
-    if (writtenBytes != static_cast<int64_t>(data->size())) {
+    if (writtenBytes != static_cast<int64_t>(data.size())) {
         deleteFile(fullPath);
         return false;
     }
index 63f10a0..5e906be 100644 (file)
@@ -127,7 +127,7 @@ private:
     bool ensureOriginRecord(const SecurityOrigin*);
     bool shouldStoreResourceAsFlatFile(ApplicationCacheResource*);
     void deleteTables();
-    bool writeDataToUniqueFileInDirectory(SharedBuffer*, const String& directory, String& outFilename, const String& fileExtension);
+    bool writeDataToUniqueFileInDirectory(SharedBuffer&, const String& directory, String& outFilename, const String& fileExtension);
 
     void loadManifestHostHashes();
     
index 2672bd2..cf6ad11 100644 (file)
 
 namespace WebCore {
 
-typedef PassRefPtr<Archive> RawDataCreationFunction(const URL&, SharedBuffer*);
+typedef RefPtr<Archive> RawDataCreationFunction(const URL&, SharedBuffer&);
 typedef HashMap<String, RawDataCreationFunction*, ASCIICaseInsensitiveHash> ArchiveMIMETypesMap;
 
 // The create functions in the archive classes return PassRefPtr to concrete subclasses
 // of Archive. This adaptor makes the functions have a uniform return type.
-template <typename ArchiveClass> static PassRefPtr<Archive> archiveFactoryCreate(const URL& url, SharedBuffer* buffer)
+template <typename ArchiveClass> static RefPtr<Archive> archiveFactoryCreate(const URL& url, SharedBuffer& buffer)
 {
     return ArchiveClass::create(url, buffer);
 }
@@ -83,10 +83,12 @@ bool ArchiveFactory::isArchiveMimeType(const String& mimeType)
     return !mimeType.isEmpty() && archiveMIMETypes().contains(mimeType);
 }
 
-PassRefPtr<Archive> ArchiveFactory::create(const URL& url, SharedBuffer* data, const String& mimeType)
+RefPtr<Archive> ArchiveFactory::create(const URL& url, SharedBuffer* data, const String& mimeType)
 {
     RawDataCreationFunction* function = mimeType.isEmpty() ? 0 : archiveMIMETypes().get(mimeType);
-    return function ? function(url, data) : PassRefPtr<Archive>(nullptr);
+    if (!data)
+        return nullptr;
+    return function ? function(url, *data) : RefPtr<Archive>(nullptr);
 }
 
 void ArchiveFactory::registerKnownArchiveMIMETypes()
index 76488df..fc016b7 100644 (file)
@@ -32,7 +32,6 @@
 #include "Archive.h"
 
 #include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
 
 namespace WebCore {
 
@@ -41,7 +40,7 @@ class SharedBuffer;
 class ArchiveFactory {
 public:
     static bool isArchiveMimeType(const String&);
-    static PassRefPtr<Archive> create(const URL&, SharedBuffer* data, const String& mimeType);
+    static RefPtr<Archive> create(const URL&, SharedBuffer* data, const String& mimeType);
     static void registerKnownArchiveMIMETypes();
 };
 
index e0205a3..bf1e846 100644 (file)
@@ -33,8 +33,8 @@
 
 namespace WebCore {
 
-inline ArchiveResource::ArchiveResource(PassRefPtr<SharedBuffer> data, const URL& url, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse& response)
-    : SubstituteResource(url, response, data)
+inline ArchiveResource::ArchiveResource(Ref<SharedBuffer>&& data, const URL& url, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse& response)
+    : SubstituteResource(url, response, WTFMove(data))
     , m_mimeType(mimeType)
     , m_textEncoding(textEncoding)
     , m_frameName(frameName)
@@ -42,21 +42,21 @@ inline ArchiveResource::ArchiveResource(PassRefPtr<SharedBuffer> data, const URL
 {
 }
 
-RefPtr<ArchiveResource> ArchiveResource::create(PassRefPtr<SharedBuffer> data, const URL& url, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse& response)
+RefPtr<ArchiveResource> ArchiveResource::create(RefPtr<SharedBuffer>&& data, const URL& url, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse& response)
 {
     if (!data)
         return nullptr;
     if (response.isNull()) {
         unsigned dataSize = data->size();
-        return adoptRef(*new ArchiveResource(data, url, mimeType, textEncoding, frameName,
+        return adoptRef(*new ArchiveResource(data.releaseNonNull(), url, mimeType, textEncoding, frameName,
             ResourceResponse(url, mimeType, dataSize, textEncoding)));
     }
-    return adoptRef(*new ArchiveResource(data, url, mimeType, textEncoding, frameName, response));
+    return adoptRef(*new ArchiveResource(data.releaseNonNull(), url, mimeType, textEncoding, frameName, response));
 }
 
-RefPtr<ArchiveResource> ArchiveResource::create(PassRefPtr<SharedBuffer> data, const URL& url, const ResourceResponse& response)
+RefPtr<ArchiveResource> ArchiveResource::create(RefPtr<SharedBuffer>&& data, const URL& url, const ResourceResponse& response)
 {
-    return create(data, url, response.mimeType(), response.textEncodingName(), String(), response);
+    return create(WTFMove(data), url, response.mimeType(), response.textEncodingName(), String(), response);
 }
 
 }
index 25bd5c1..b927501 100644 (file)
@@ -35,8 +35,8 @@ namespace WebCore {
 
 class ArchiveResource : public SubstituteResource {
 public:
-    static RefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const URL&, const ResourceResponse&);
-    WEBCORE_EXPORT static RefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const URL&,
+    static RefPtr<ArchiveResource> create(RefPtr<SharedBuffer>&&, const URL&, const ResourceResponse&);
+    WEBCORE_EXPORT static RefPtr<ArchiveResource> create(RefPtr<SharedBuffer>&&, const URL&,
         const String& mimeType, const String& textEncoding, const String& frameName,
         const ResourceResponse& = ResourceResponse());
 
@@ -48,7 +48,7 @@ public:
     bool shouldIgnoreWhenUnarchiving() const { return m_shouldIgnoreWhenUnarchiving; }
 
 private:
-    ArchiveResource(PassRefPtr<SharedBuffer>, const URL&, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse&);
+    ArchiveResource(Ref<SharedBuffer>&&, const URL&, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse&);
 
     String m_mimeType;
     String m_textEncoding;
index ec7a770..7eee783 100644 (file)
@@ -59,14 +59,10 @@ void ArchiveResourceCollection::addAllResources(Archive* archive)
 
 // FIXME: Adding a resource directly to a DocumentLoader/ArchiveResourceCollection seems like bad design, but is API some apps rely on.
 // Can we change the design in a manner that will let us deprecate that API without reducing functionality of those apps?
-void ArchiveResourceCollection::addResource(PassRefPtr<ArchiveResource> resource)
+void ArchiveResourceCollection::addResource(Ref<ArchiveResource>&& resource)
 {
-    ASSERT(resource);
-    if (!resource)
-        return;
-
-    const URL& url = resource->url(); // get before passing PassRefPtr (which sets it to 0)
-    m_subresources.set(url, resource);
+    const URL& url = resource->url();
+    m_subresources.set(url, WTFMove(resource));
 }
 
 ArchiveResource* ArchiveResourceCollection::archiveResourceForURL(const URL& url)
index a601126..556eec3 100644 (file)
@@ -44,7 +44,7 @@ class ArchiveResourceCollection {
 public:
     ArchiveResourceCollection();
 
-    void addResource(PassRefPtr<ArchiveResource>);
+    void addResource(Ref<ArchiveResource>&&);
     void addAllResources(Archive*);
     
     WEBCORE_EXPORT ArchiveResource* archiveResourceForURL(const URL&);
index 6c6ace1..efb5866 100644 (file)
@@ -82,12 +82,10 @@ RetainPtr<CFDictionaryRef> LegacyWebArchive::createPropertyListRepresentation(Ar
     RetainPtr<CFMutableDictionaryRef> propertyList = adoptCF(CFDictionaryCreateMutable(0, 6, 0, &kCFTypeDictionaryValueCallBacks));
     
     // Resource data can be empty, but must be represented by an empty CFDataRef
-    SharedBuffer* data = resource->data();
+    SharedBuffer& data = resource->data();
     RetainPtr<CFDataRef> cfData;
-    if (data)
-        cfData = data->createCFData();
-    else
-        cfData = adoptCF(CFDataCreate(0, 0, 0));
+    cfData = data.createCFData();
+
     CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceDataKey, cfData.get());
     
     // Resource URL cannot be null
@@ -171,7 +169,7 @@ ResourceResponse LegacyWebArchive::createResourceResponseFromPropertyListData(CF
     return ResourceResponse();
 }
 
-PassRefPtr<ArchiveResource> LegacyWebArchive::createResource(CFDictionaryRef dictionary)
+RefPtr<ArchiveResource> LegacyWebArchive::createResource(CFDictionaryRef dictionary)
 {
     ASSERT(dictionary);
     if (!dictionary)
@@ -228,19 +226,18 @@ PassRefPtr<ArchiveResource> LegacyWebArchive::createResource(CFDictionaryRef dic
     return ArchiveResource::create(SharedBuffer::wrapCFData(resourceData), URL(URL(), url), mimeType, textEncoding, frameName, response);
 }
 
-PassRefPtr<LegacyWebArchive> LegacyWebArchive::create()
+Ref<LegacyWebArchive> LegacyWebArchive::create()
 {
-    return adoptRef(new LegacyWebArchive);
+    return adoptRef(*new LegacyWebArchive);
 }
 
-PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(PassRefPtr<ArchiveResource> mainResource, Vector<RefPtr<ArchiveResource>> subresources, Vector<RefPtr<LegacyWebArchive>> subframeArchives)
+RefPtr<LegacyWebArchive> LegacyWebArchive::create(RefPtr<ArchiveResource>&& mainResource, Vector<RefPtr<ArchiveResource>>&& subresources, Vector<RefPtr<LegacyWebArchive>>&& subframeArchives)
 {
-    ASSERT(mainResource);
     if (!mainResource)
         return nullptr;
-    
-    RefPtr<LegacyWebArchive> archive = create();
-    archive->setMainResource(mainResource);
+
+    auto archive = create();
+    archive->setMainResource(WTFMove(mainResource));
     
     for (auto& subresource : subresources)
         archive->addSubresource(WTFMove(subresource));
@@ -248,25 +245,21 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(PassRefPtr<ArchiveResource
     for (auto& subframeArchive : subframeArchives)
         archive->addSubframeArchive(WTFMove(subframeArchive));
 
-    return archive.release();
+    return WTFMove(archive);
 }
 
-PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(SharedBuffer* data)
+RefPtr<LegacyWebArchive> LegacyWebArchive::create(SharedBuffer& data)
 {
     return create(URL(), data);
 }
 
-PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const URL&, SharedBuffer* data)
+RefPtr<LegacyWebArchive> LegacyWebArchive::create(const URL&, SharedBuffer& data)
 {
     LOG(Archives, "LegacyWebArchive - Creating from raw data");
     
-    RefPtr<LegacyWebArchive> archive = create();
-        
-    ASSERT(data);
-    if (!data)
-        return nullptr;
+    Ref<LegacyWebArchive> archive = create();
         
-    RetainPtr<CFDataRef> cfData = data->createCFData();
+    RetainPtr<CFDataRef> cfData = data.createCFData();
     if (!cfData)
         return nullptr;
         
@@ -292,7 +285,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const URL&, SharedBuffer*
     if (!archive->extract(plist.get()))
         return nullptr;
 
-    return archive.release();
+    return WTFMove(archive);
 }
 
 bool LegacyWebArchive::extract(CFDictionaryRef dictionary)
@@ -420,13 +413,9 @@ RetainPtr<CFDataRef> LegacyWebArchive::createPropertyListRepresentation(const Re
 
 #endif
 
-PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Node* node, std::function<bool (Frame&)> frameFilter)
+RefPtr<LegacyWebArchive> LegacyWebArchive::create(Node& node, std::function<bool (Frame&)> frameFilter)
 {
-    ASSERT(node);
-    if (!node)
-        return create();
-
-    Frame* frame = node->document().frame();
+    Frame* frame = node.document().frame();
     if (!frame)
         return create();
 
@@ -440,27 +429,25 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Node* node, std::function<
     }
 
     Vector<Node*> nodeList;
-    String markupString = createMarkup(*node, IncludeNode, &nodeList, DoNotResolveURLs, tagNamesToFilter.get());
-    Node::NodeType nodeType = node->nodeType();
+    String markupString = createMarkup(node, IncludeNode, &nodeList, DoNotResolveURLs, tagNamesToFilter.get());
+    Node::NodeType nodeType = node.nodeType();
     if (nodeType != Node::DOCUMENT_NODE && nodeType != Node::DOCUMENT_TYPE_NODE)
-        markupString = documentTypeString(node->document()) + markupString;
+        markupString = documentTypeString(node.document()) + markupString;
 
-    return create(markupString, frame, nodeList, WTFMove(frameFilter));
+    return create(markupString, *frame, nodeList, WTFMove(frameFilter));
 }
 
-PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Frame* frame)
+RefPtr<LegacyWebArchive> LegacyWebArchive::create(Frame& frame)
 {
-    ASSERT(frame);
-    
-    DocumentLoader* documentLoader = frame->loader().documentLoader();
+    DocumentLoader* documentLoader = frame.loader().documentLoader();
 
     if (!documentLoader)
         return nullptr;
         
     Vector<RefPtr<LegacyWebArchive>> subframeArchives;
     
-    for (unsigned i = 0; i < frame->tree().childCount(); ++i) {
-        if (RefPtr<LegacyWebArchive> childFrameArchive = create(frame->tree().child(i)))
+    for (unsigned i = 0; i < frame.tree().childCount(); ++i) {
+        if (RefPtr<LegacyWebArchive> childFrameArchive = create(*frame.tree().child(i)))
             subframeArchives.append(WTFMove(childFrameArchive));
     }
 
@@ -468,7 +455,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Frame* frame)
     return create(documentLoader->mainResource(), WTFMove(subresources), WTFMove(subframeArchives));
 }
 
-PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Range* range)
+RefPtr<LegacyWebArchive> LegacyWebArchive::create(Range* range)
 {
     if (!range)
         return nullptr;
@@ -483,22 +470,22 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Range* range)
     Vector<Node*> nodeList;
     String markupString = documentTypeString(document) + createMarkup(*range, &nodeList, AnnotateForInterchange);
 
-    return create(markupString, frame, nodeList, nullptr);
+    return create(markupString, *frame, nodeList, nullptr);
 }
 
-PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString, Frame* frame, const Vector<Node*>& nodes, std::function<bool (Frame&)> frameFilter)
+RefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString, Frame& frame, const Vector<Node*>& nodes, std::function<bool (Frame&)> frameFilter)
 {
-    ASSERT(frame);
-    
-    const ResourceResponse& response = frame->loader().documentLoader()->response();
+    const ResourceResponse& response = frame.loader().documentLoader()->response();
     URL responseURL = response.url();
     
     // it's possible to have a response without a URL here
     // <rdar://problem/5454935>
     if (responseURL.isNull())
         responseURL = URL(ParsedURLString, emptyString());
-        
-    RefPtr<ArchiveResource> mainResource = ArchiveResource::create(utf8Buffer(markupString), responseURL, response.mimeType(), "UTF-8", frame->tree().uniqueName());
+
+    RefPtr<ArchiveResource> mainResource = ArchiveResource::create(utf8Buffer(markupString), responseURL, response.mimeType(), "UTF-8", frame.tree().uniqueName());
+    if (!mainResource)
+        return nullptr;
 
     Vector<RefPtr<LegacyWebArchive>> subframeArchives;
     Vector<RefPtr<ArchiveResource>> subresources;
@@ -513,7 +500,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString
             if (frameFilter && !frameFilter(*childFrame))
                 continue;
                 
-            if (RefPtr<LegacyWebArchive> subframeArchive = create(childFrame->document(), frameFilter))
+            if (RefPtr<LegacyWebArchive> subframeArchive = create(*childFrame->document(), frameFilter))
                 subframeArchives.append(WTFMove(subframeArchive));
             else
                 LOG_ERROR("Unabled to archive subframe %s", childFrame->tree().uniqueName().string().utf8().data());
@@ -522,7 +509,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString
             ListHashSet<URL> subresourceURLs;
             node.getSubresourceURLs(subresourceURLs);
             
-            DocumentLoader* documentLoader = frame->loader().documentLoader();
+            DocumentLoader* documentLoader = frame.loader().documentLoader();
 
             for (const auto& subresourceURL : subresourceURLs) {
                 if (uniqueSubresources.contains(subresourceURL))
@@ -537,9 +524,9 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString
 
                 ResourceRequest request(subresourceURL);
 #if ENABLE(CACHE_PARTITIONING)
-                request.setDomainForCachePartition(frame->document()->topOrigin()->domainForCachePartition());
+                request.setDomainForCachePartition(frame.document()->topOrigin()->domainForCachePartition());
 #endif
-                CachedResource* cachedResource = MemoryCache::singleton().resourceForRequest(request, frame->page()->sessionID());
+                CachedResource* cachedResource = MemoryCache::singleton().resourceForRequest(request, frame.page()->sessionID());
                 if (cachedResource) {
                     if (RefPtr<ArchiveResource> resource = ArchiveResource::create(cachedResource->resourceBuffer(), subresourceURL, cachedResource->response())) {
                         subresources.append(WTFMove(resource));
@@ -564,10 +551,10 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString
         }
     }
 
-    return create(mainResource.release(), subresources, WTFMove(subframeArchives));
+    return create(WTFMove(mainResource), WTFMove(subresources), WTFMove(subframeArchives));
 }
 
-PassRefPtr<LegacyWebArchive> LegacyWebArchive::createFromSelection(Frame* frame)
+RefPtr<LegacyWebArchive> LegacyWebArchive::createFromSelection(Frame* frame)
 {
     if (!frame)
         return nullptr;
@@ -585,10 +572,10 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::createFromSelection(Frame* frame)
         builder.append(createMarkup(*selectionRange, &nodeList, AnnotateForInterchange));
 
     String markupString = builder.toString();
-    RefPtr<LegacyWebArchive> archive = create(markupString, frame, nodeList, nullptr);
+    RefPtr<LegacyWebArchive> archive = create(markupString, *frame, nodeList, nullptr);
     
     if (!document->isFrameSet())
-        return archive.release();
+        return archive;
         
     // Wrap the frameset document in an iframe so it can be pasted into
     // another document (which will have a body or frameset of its own). 
index a2f3b0a..e1e9dc0 100644 (file)
@@ -40,14 +40,14 @@ class Range;
 
 class LegacyWebArchive : public Archive {
 public:
-    WEBCORE_EXPORT static PassRefPtr<LegacyWebArchive> create();
-    WEBCORE_EXPORT static PassRefPtr<LegacyWebArchive> create(SharedBuffer*);
-    WEBCORE_EXPORT static PassRefPtr<LegacyWebArchive> create(const URL&, SharedBuffer*);
-    WEBCORE_EXPORT static PassRefPtr<LegacyWebArchive> create(PassRefPtr<ArchiveResource> mainResource, Vector<RefPtr<ArchiveResource>> subresources, Vector<RefPtr<LegacyWebArchive>> subframeArchives);
-    WEBCORE_EXPORT static PassRefPtr<LegacyWebArchive> create(Node*, std::function<bool(Frame&)> frameFilter = nullptr);
-    WEBCORE_EXPORT static PassRefPtr<LegacyWebArchive> create(Frame*);
-    WEBCORE_EXPORT static PassRefPtr<LegacyWebArchive> createFromSelection(Frame*);
-    WEBCORE_EXPORT static PassRefPtr<LegacyWebArchive> create(Range*);
+    WEBCORE_EXPORT static Ref<LegacyWebArchive> create();
+    WEBCORE_EXPORT static RefPtr<LegacyWebArchive> create(SharedBuffer&);
+    WEBCORE_EXPORT static RefPtr<LegacyWebArchive> create(const URL&, SharedBuffer&);
+    WEBCORE_EXPORT static RefPtr<LegacyWebArchive> create(RefPtr<ArchiveResource>&& mainResource, Vector<RefPtr<ArchiveResource>>&& subresources, Vector<RefPtr<LegacyWebArchive>>&& subframeArchives);
+    WEBCORE_EXPORT static RefPtr<LegacyWebArchive> create(Node&, std::function<bool(Frame&)> frameFilter = nullptr);
+    WEBCORE_EXPORT static RefPtr<LegacyWebArchive> create(Frame&);
+    WEBCORE_EXPORT static RefPtr<LegacyWebArchive> createFromSelection(Frame*);
+    WEBCORE_EXPORT static RefPtr<LegacyWebArchive> create(Range*);
 
     Type type() const override;
 
@@ -58,8 +58,8 @@ private:
 
     enum MainResourceStatus { Subresource, MainResource };
 
-    static PassRefPtr<LegacyWebArchive> create(const String& markupString, Frame*, const Vector<Node*>& nodes, std::function<bool (Frame&)> frameFilter);
-    static PassRefPtr<ArchiveResource> createResource(CFDictionaryRef);
+    static RefPtr<LegacyWebArchive> create(const String& markupString, Frame&, const Vector<Node*>& nodes, std::function<bool (Frame&)> frameFilter);
+    static RefPtr<ArchiveResource> createResource(CFDictionaryRef);
     static ResourceResponse createResourceResponseFromMacArchivedData(CFDataRef);
     static ResourceResponse createResourceResponseFromPropertyListData(CFDataRef, CFStringRef responseDataType);
     static RetainPtr<CFDataRef> createPropertyListRepresentation(const ResourceResponse&);
index c3af562..b0e4fb8 100644 (file)
@@ -101,18 +101,18 @@ MHTMLArchive::~MHTMLArchive()
     clearAllSubframeArchives();
 }
 
-PassRefPtr<MHTMLArchive> MHTMLArchive::create()
+Ref<MHTMLArchive> MHTMLArchive::create()
 {
-    return adoptRef(new MHTMLArchive);
+    return adoptRef(*new MHTMLArchive);
 }
 
-PassRefPtr<MHTMLArchive> MHTMLArchive::create(const URL& url, SharedBuffer* data)
+RefPtr<MHTMLArchive> MHTMLArchive::create(const URL& url, SharedBuffer& data)
 {
     // For security reasons we only load MHTML pages from local URLs.
     if (!SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol()))
         return nullptr;
 
-    MHTMLParser parser(data);
+    MHTMLParser parser(&data);
     RefPtr<MHTMLArchive> mainArchive = parser.parseArchive();
     if (!mainArchive)
         return nullptr; // Invalid MHTML file.
@@ -127,7 +127,7 @@ PassRefPtr<MHTMLArchive> MHTMLArchive::create(const URL& url, SharedBuffer* data
         for (size_t j = 0; j < parser.subResourceCount(); ++j)
             archive->addSubresource(parser.subResourceAt(j));
     }
-    return mainArchive.release();
+    return mainArchive;
 }
 
 PassRefPtr<SharedBuffer> MHTMLArchive::generateMHTMLData(Page* page)
index 6decd4a..87ddffe 100644 (file)
@@ -45,8 +45,8 @@ class MHTMLArchive : public Archive {
 public:
     virtual Type type() const { return MHTML; }
 
-    static PassRefPtr<MHTMLArchive> create();
-    static PassRefPtr<MHTMLArchive> create(const URL&, SharedBuffer*);
+    static Ref<MHTMLArchive> create();
+    static RefPtr<MHTMLArchive> create(const URL&, SharedBuffer&);
 
     static PassRefPtr<SharedBuffer> generateMHTMLData(Page*);
 
index d2c5e56..9f44a6e 100644 (file)
@@ -57,13 +57,12 @@ MHTMLParser::MHTMLParser(SharedBuffer* data)
 {
 }
 
-PassRefPtr<MHTMLArchive> MHTMLParser::parseArchive()
+RefPtr<MHTMLArchive> MHTMLParser::parseArchive()
 {
-    RefPtr<MIMEHeader> header = MIMEHeader::parseHeader(&m_lineReader);
-    return parseArchiveWithHeader(header.get());
+    return parseArchiveWithHeader(MIMEHeader::parseHeader(m_lineReader).get());
 }
 
-PassRefPtr<MHTMLArchive> MHTMLParser::parseArchiveWithHeader(MIMEHeader* header)
+RefPtr<MHTMLArchive> MHTMLParser::parseArchiveWithHeader(MIMEHeader* header)
 {
     if (!header) {
         LOG_ERROR("Failed to parse MHTML part: no header.");
@@ -86,7 +85,7 @@ PassRefPtr<MHTMLArchive> MHTMLParser::parseArchiveWithHeader(MIMEHeader* header)
 
     bool endOfArchive = false;
     while (!endOfArchive) {
-        RefPtr<MIMEHeader> resourceHeader = MIMEHeader::parseHeader(&m_lineReader);
+        RefPtr<MIMEHeader> resourceHeader = MIMEHeader::parseHeader(m_lineReader);
         if (!resourceHeader) {
             LOG_ERROR("Failed to parse MHTML, invalid MIME header.");
             return nullptr;
@@ -138,7 +137,7 @@ void MHTMLParser::addResourceToArchive(ArchiveResource* resource, MHTMLArchive*
     m_frames.append(subframe);
 }
 
-PassRefPtr<ArchiveResource> MHTMLParser::parseNextPart(const MIMEHeader& mimeHeader, const String& endOfPartBoundary, const String& endOfDocumentBoundary, bool& endOfArchiveReached)
+RefPtr<ArchiveResource> MHTMLParser::parseNextPart(const MIMEHeader& mimeHeader, const String& endOfPartBoundary, const String& endOfDocumentBoundary, bool& endOfArchiveReached)
 {
     ASSERT(endOfPartBoundary.isEmpty() == endOfDocumentBoundary.isEmpty());
 
@@ -218,7 +217,7 @@ PassRefPtr<ArchiveResource> MHTMLParser::parseNextPart(const MIMEHeader& mimeHea
     // The specs mentions 5 ways to resolve a URL: http://tools.ietf.org/html/rfc2557#section-5
     // IE and Firefox (UNMht) seem to generate only absolute URLs.
     URL location = URL(URL(), mimeHeader.contentLocation());
-    return ArchiveResource::create(contentBuffer, location, mimeHeader.contentType(), mimeHeader.charset(), String());
+    return ArchiveResource::create(WTFMove(contentBuffer), location, mimeHeader.contentType(), mimeHeader.charset(), String());
 }
 
 size_t MHTMLParser::frameCount() const
index 4f1b126..a7dd2db 100644 (file)
@@ -48,7 +48,7 @@ class MHTMLParser {
 public:
     explicit MHTMLParser(SharedBuffer*);
 
-    PassRefPtr<MHTMLArchive> parseArchive();
+    RefPtr<MHTMLArchive> parseArchive();
 
     size_t frameCount() const;
     MHTMLArchive* frameAt(size_t) const;
@@ -57,8 +57,8 @@ public:
     ArchiveResource* subResourceAt(size_t) const;
 
 private:
-    PassRefPtr<MHTMLArchive> parseArchiveWithHeader(MIMEHeader*);
-    PassRefPtr<ArchiveResource> parseNextPart(const MIMEHeader&, const String& endOfPartBoundary, const String& endOfDocumentBoundary, bool& endOfArchiveReached);
+    RefPtr<MHTMLArchive> parseArchiveWithHeader(MIMEHeader*);
+    RefPtr<ArchiveResource> parseNextPart(const MIMEHeader&, const String& endOfPartBoundary, const String& endOfDocumentBoundary, bool& endOfArchiveReached);
 
     void addResourceToArchive(ArchiveResource*, MHTMLArchive*);
 
index f378752..16dd65c 100644 (file)
@@ -119,7 +119,7 @@ void CachedImage::didAddClient(CachedResourceClient* client)
 {
     if (m_data && !m_image && !errorOccurred()) {
         createImage();
-        m_image->setData(m_data, true);
+        m_image->setData(m_data.copyRef(), true);
     }
     
     ASSERT(client->resourceClientType() == CachedImageClient::expectedType());
index b3d7fe2..dcca88e 100644 (file)
@@ -390,8 +390,8 @@ static inline void loadDefaultIconRecord(IconRecord* defaultIconRecord)
         0x00, 0x00, 0x01, 0x52, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x0A, 
         0xFC, 0x80, 0x00, 0x00, 0x27, 0x10, 0x00, 0x0A, 0xFC, 0x80, 0x00, 0x00, 0x27, 0x10 };
         
-    static SharedBuffer* defaultIconBuffer = SharedBuffer::create(defaultIconData, sizeof(defaultIconData)).leakRef();
-    defaultIconRecord->setImageData(defaultIconBuffer);
+    static auto& defaultIconBuffer = SharedBuffer::create(defaultIconData, sizeof(defaultIconData)).leakRef();
+    defaultIconRecord->setImageData(&defaultIconBuffer);
 }
 #endif
 
index e7f1d4b..b20c26a 100644 (file)
@@ -62,14 +62,14 @@ Image* IconRecord::image(const IntSize&)
     return m_image.get();
 }
 
-void IconRecord::setImageData(PassRefPtr<SharedBuffer> data)
+void IconRecord::setImageData(RefPtr<SharedBuffer>&& data)
 {
     // It's okay to delete the raw image here. Any existing clients using this icon will be
     // managing an image that was created with a copy of this raw image data.
     m_image = BitmapImage::create();
 
     // Copy the provided data into the buffer of the new Image object.
-    if (!m_image->setData(data, true)) {
+    if (!m_image->setData(WTFMove(data), true)) {
         LOG(IconDatabase, "Manual image data for iconURL '%s' FAILED - it was probably invalid image data", m_iconURL.ascii().data());
         m_image = nullptr;
     }
index e5eb12e..ba1bdb5 100644 (file)
@@ -83,7 +83,7 @@ public:
     time_t getTimestamp() { return m_stamp; }
     void setTimestamp(time_t stamp) { m_stamp = stamp; }
         
-    void setImageData(PassRefPtr<SharedBuffer> data);
+    void setImageData(RefPtr<SharedBuffer>&&);
     Image* image(const IntSize&);    
     
     String iconURL() { return m_iconURL; }
index 72b0254..4733b35 100644 (file)
@@ -118,12 +118,12 @@ public:
     virtual ~PasteboardWebContentReader() { }
 
 #if !(PLATFORM(EFL) || PLATFORM(GTK) || PLATFORM(WIN))
-    virtual bool readWebArchive(PassRefPtr<SharedBuffer>) = 0;
+    virtual bool readWebArchive(SharedBuffer*) = 0;
     virtual bool readFilenames(const Vector<String>&) = 0;
     virtual bool readHTML(const String&) = 0;
-    virtual bool readRTFD(PassRefPtr<SharedBuffer>) = 0;
-    virtual bool readRTF(PassRefPtr<SharedBuffer>) = 0;
-    virtual bool readImage(PassRefPtr<SharedBuffer>, const String& type) = 0;
+    virtual bool readRTFD(SharedBuffer&) = 0;
+    virtual bool readRTF(SharedBuffer&) = 0;
+    virtual bool readImage(Ref<SharedBuffer>&&, const String& type) = 0;
     virtual bool readURL(const URL&, const String& title) = 0;
 #endif
     virtual bool readPlainText(const String&) = 0;
@@ -143,7 +143,7 @@ public:
     ~Pasteboard();
 
 #if PLATFORM(GTK)
-    explicit Pasteboard(PassRefPtr<DataObjectGtk>);
+    explicit Pasteboard(RefPtr<DataObjectGtk>&&);
     explicit Pasteboard(GtkClipboard*);
 #endif
 
@@ -187,13 +187,13 @@ public:
 #endif
 
 #if PLATFORM(WIN)
-    PassRefPtr<DocumentFragment> documentFragment(Frame&, Range&, bool allowPlainText, bool& chosePlainText); // FIXME: Layering violation.
+    RefPtr<DocumentFragment> documentFragment(Frame&, Range&, bool allowPlainText, bool& chosePlainText); // FIXME: Layering violation.
     void writeImage(Element&, const URL&, const String& title); // FIXME: Layering violation.
     void writeSelection(Range&, bool canSmartCopyOrDelete, Frame&, ShouldSerializeSelectedTextForDataTransfer = DefaultSelectedTextType); // FIXME: Layering violation.
 #endif
 
 #if PLATFORM(GTK)
-    PassRefPtr<DataObjectGtk> dataObject() const;
+    DataObjectGtk* dataObject() const;
     static std::unique_ptr<Pasteboard> createForGlobalSelection();
 #endif
 
index f5e9552..4b6cae4 100644 (file)
@@ -47,13 +47,13 @@ public:
     virtual void writeToPasteboard(const String& pasteboardType, const String&) = 0;
     virtual int getPasteboardItemsCount() = 0;
     virtual String readStringFromPasteboard(int index, const String& pasteboardType) = 0;
-    virtual PassRefPtr<SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType) = 0;
+    virtual RefPtr<SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType) = 0;
     virtual URL readURLFromPasteboard(int index, const String& pasteboardType) = 0;
     virtual long changeCount() = 0;
 #endif // PLATFORM(IOS)
 #if PLATFORM(COCOA)
     virtual void getTypes(Vector<String>& types, const String& pasteboardName) = 0;
-    virtual PassRefPtr<SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) = 0;
+    virtual RefPtr<SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) = 0;
     virtual void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) = 0;
     virtual String stringForType(const String& pasteboardType, const String& pasteboardName) = 0;
     virtual long changeCount(const String& pasteboardName) = 0;
index 4856d13..2912858 100644 (file)
@@ -57,7 +57,7 @@ public:
     WEBCORE_EXPORT static String uniqueName();
     
     WEBCORE_EXPORT void getTypes(Vector<String>& types);
-    WEBCORE_EXPORT PassRefPtr<SharedBuffer> bufferForType(const String& pasteboardType);
+    WEBCORE_EXPORT RefPtr<SharedBuffer> bufferForType(const String& pasteboardType);
     WEBCORE_EXPORT void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType);
     WEBCORE_EXPORT String stringForType(const String& pasteboardType);
     WEBCORE_EXPORT long changeCount() const;
@@ -76,7 +76,7 @@ public:
     WEBCORE_EXPORT void write(const PasteboardWebContent&);
     WEBCORE_EXPORT void write(const PasteboardImage&);
     WEBCORE_EXPORT void write(const String& pasteboardType, const String&);
-    WEBCORE_EXPORT PassRefPtr<SharedBuffer> readBuffer(int index, const String& pasteboardType);
+    WEBCORE_EXPORT RefPtr<SharedBuffer> readBuffer(int index, const String& pasteboardType);
     WEBCORE_EXPORT String readString(int index, const String& pasteboardType);
     WEBCORE_EXPORT URL readURL(int index, const String& pasteboardType);
     WEBCORE_EXPORT int count();
index 259779d..7d23990 100644 (file)
@@ -141,7 +141,7 @@ const char* SharedBuffer::data() const
     return this->buffer().data();
 }
 
-PassRefPtr<ArrayBuffer> SharedBuffer::createArrayBuffer() const
+RefPtr<ArrayBuffer> SharedBuffer::createArrayBuffer() const
 {
     RefPtr<ArrayBuffer> arrayBuffer = ArrayBuffer::createUninitialized(static_cast<unsigned>(size()), sizeof(char));
 
@@ -155,10 +155,10 @@ PassRefPtr<ArrayBuffer> SharedBuffer::createArrayBuffer() const
     if (position != arrayBuffer->byteLength()) {
         ASSERT_NOT_REACHED();
         // Don't return the incomplete ArrayBuffer.
-        return 0;
+        return nullptr;
     }
 
-    return arrayBuffer.release();
+    return arrayBuffer;
 }
 
 void SharedBuffer::append(SharedBuffer* data)
@@ -420,7 +420,7 @@ inline bool SharedBuffer::maybeAppendPlatformData(SharedBuffer*)
 
 #endif
 
-PassRefPtr<SharedBuffer> utf8Buffer(const String& string)
+RefPtr<SharedBuffer> utf8Buffer(const String& string)
 {
     // Allocate a buffer big enough to hold all the characters.
     const int length = string.length();
index 4561e98..68d4e8b 100644 (file)
@@ -55,7 +55,7 @@ public:
     static PassRefPtr<SharedBuffer> create() { return adoptRef(new SharedBuffer); }
     static PassRefPtr<SharedBuffer> create(unsigned size) { return adoptRef(new SharedBuffer(size)); }
     static PassRefPtr<SharedBuffer> create(const char* c, unsigned i) { return adoptRef(new SharedBuffer(c, i)); }
-    static PassRefPtr<SharedBuffer> create(const unsigned char* c, unsigned i) { return adoptRef(new SharedBuffer(c, i)); }
+    static Ref<SharedBuffer> create(const unsigned char* data, unsigned size) { return adoptRef(*new SharedBuffer(data, size)); }
 
     WEBCORE_EXPORT static RefPtr<SharedBuffer> createWithContentsOfFile(const String& filePath);
 
@@ -65,16 +65,16 @@ public:
     
 #if USE(FOUNDATION)
     WEBCORE_EXPORT RetainPtr<NSData> createNSData();
-    WEBCORE_EXPORT static PassRefPtr<SharedBuffer> wrapNSData(NSData *data);
+    WEBCORE_EXPORT static Ref<SharedBuffer> wrapNSData(NSData *);
 #endif
 #if USE(CF)
     WEBCORE_EXPORT RetainPtr<CFDataRef> createCFData();
     WEBCORE_EXPORT CFDataRef existingCFData();
-    WEBCORE_EXPORT static PassRefPtr<SharedBuffer> wrapCFData(CFDataRef);
+    WEBCORE_EXPORT static Ref<SharedBuffer> wrapCFData(CFDataRef);
 #endif
 
 #if USE(SOUP)
-    static PassRefPtr<SharedBuffer> wrapSoupBuffer(SoupBuffer*);
+    static Ref<SharedBuffer> wrapSoupBuffer(SoupBuffer*);
 #endif
 
     // Calling this function will force internal segmented buffers
@@ -83,7 +83,7 @@ public:
     WEBCORE_EXPORT const char* data() const;
     // Creates an ArrayBuffer and copies this SharedBuffer's contents to that
     // ArrayBuffer without merging segmented buffers into a flat buffer.
-    PassRefPtr<ArrayBuffer> createArrayBuffer() const;
+    RefPtr<ArrayBuffer> createArrayBuffer() const;
 
     WEBCORE_EXPORT unsigned size() const;
 
@@ -181,7 +181,7 @@ private:
     MappedFileData m_fileData;
 };
 
-PassRefPtr<SharedBuffer> utf8Buffer(const String&);
+RefPtr<SharedBuffer> utf8Buffer(const String&);
 
 } // namespace WebCore
 
index 21af320..e6c5cc3 100644 (file)
@@ -54,9 +54,9 @@ RetainPtr<CFDataRef> SharedBuffer::createCFData()
 }
 #endif
 
-PassRefPtr<SharedBuffer> SharedBuffer::wrapCFData(CFDataRef data)
+Ref<SharedBuffer> SharedBuffer::wrapCFData(CFDataRef data)
 {
-    return adoptRef(new SharedBuffer(data));
+    return adoptRef(*new SharedBuffer(data));
 }
 
 bool SharedBuffer::hasPlatformData() const
index 0420fea..04d5412 100644 (file)
@@ -193,7 +193,7 @@ void NetworkExtensionContentFilter::finishedAddingData()
 Ref<SharedBuffer> NetworkExtensionContentFilter::replacementData() const
 {
     ASSERT(didBlockData());
-    return adoptRef(*SharedBuffer::wrapNSData(m_replacementData.get()).leakRef());
+    return SharedBuffer::wrapNSData(m_replacementData.get());
 }
 
 ContentFilterUnblockHandler NetworkExtensionContentFilter::unblockHandler() const
index e897624..1e4637b 100644 (file)
@@ -93,7 +93,7 @@ void ParentalControlsContentFilter::finishedAddingData()
 Ref<SharedBuffer> ParentalControlsContentFilter::replacementData() const
 {
     ASSERT(didBlockData());
-    return adoptRef(*SharedBuffer::wrapNSData(m_replacementData.get()).leakRef());
+    return SharedBuffer::wrapNSData(m_replacementData.get());
 }
 
 ContentFilterUnblockHandler ParentalControlsContentFilter::unblockHandler() const
index 81fbb0f..9963c5a 100644 (file)
@@ -66,9 +66,9 @@ bool Image::supportsType(const String& type)
     return MIMETypeRegistry::isSupportedImageResourceMIMEType(type); 
 } 
 
-bool Image::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived)
+bool Image::setData(RefPtr<SharedBuffer>&& data, bool allDataReceived)
 {
-    m_encodedImageData = data;
+    m_encodedImageData = WTFMove(data);
     if (!m_encodedImageData.get())
         return true;
 
index 41fef2a..4ed6e35 100644 (file)
@@ -113,7 +113,7 @@ public:
     virtual FloatSize originalSize() const { return size(); }
 #endif
 
-    WEBCORE_EXPORT bool setData(PassRefPtr<SharedBuffer> data, bool allDataReceived);
+    WEBCORE_EXPORT bool setData(RefPtr<SharedBuffer>&& data, bool allDataReceived);
     virtual bool dataChanged(bool /*allDataReceived*/) { return false; }
     
     virtual String filenameExtension() const { return String(); } // null string if unknown
index e02ad33..0698abe 100644 (file)
@@ -152,9 +152,9 @@ DataObjectGtk* DataObjectGtk::forClipboard(GtkClipboard* clipboard)
     static HashMap<GtkClipboard*, RefPtr<DataObjectGtk> > objectMap;
 
     if (!objectMap.contains(clipboard)) {
-        RefPtr<DataObjectGtk> dataObject = DataObjectGtk::create();
-        objectMap.set(clipboard, dataObject);
-        return dataObject.get();
+        Ref<DataObjectGtk> dataObject = DataObjectGtk::create();
+        objectMap.set(clipboard, dataObject.copyRef());
+        return dataObject.ptr();
     }
 
     HashMap<GtkClipboard*, RefPtr<DataObjectGtk> >::iterator it = objectMap.find(clipboard);
index ac8577b..3277b3b 100644 (file)
@@ -29,9 +29,9 @@ namespace WebCore {
 
 class DataObjectGtk : public RefCounted<DataObjectGtk> {
 public:
-    static PassRefPtr<DataObjectGtk> create()
+    static Ref<DataObjectGtk> create()
     {
-        return adoptRef(new DataObjectGtk());
+        return adoptRef(*new DataObjectGtk);
     }
 
     const URL& url() const { return m_url; }
index 8ce7117..13c0dd0 100644 (file)
@@ -74,8 +74,8 @@ PasteboardImage::~PasteboardImage()
 {
 }
 
-Pasteboard::Pasteboard(PassRefPtr<DataObjectGtk> dataObject)
-    : m_dataObject(dataObject)
+Pasteboard::Pasteboard(RefPtr<DataObjectGtk>&& dataObject)
+    : m_dataObject(WTFMove(dataObject))
     , m_gtkClipboard(nullptr)
 {
     ASSERT(m_dataObject);
@@ -93,9 +93,9 @@ Pasteboard::~Pasteboard()
 {
 }
 
-PassRefPtr<DataObjectGtk> Pasteboard::dataObject() const
+DataObjectGtk* Pasteboard::dataObject() const
 {
-    return m_dataObject;
+    return m_dataObject.get();
 }
 
 static ClipboardDataType dataObjectTypeFromHTMLClipboardType(const String& rawType)
index 89cb0d6..fdcc3b3 100644 (file)
@@ -196,7 +196,7 @@ void Pasteboard::read(PasteboardWebContentReader& reader)
 
             if ([type isEqualToString:WebArchivePboardType]) {
                 if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, WebArchivePboardType)) {
-                    if (reader.readWebArchive(buffer.release()))
+                    if (reader.readWebArchive(buffer.get()))
                         break;
                 }
             }
@@ -209,21 +209,21 @@ void Pasteboard::read(PasteboardWebContentReader& reader)
 
              if ([type isEqualToString:(NSString *)kUTTypeRTFD]) {
                 if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, kUTTypeRTFD)) {
-                    if (reader.readRTFD(buffer.release()))
+                    if (reader.readRTFD(*buffer))
                         break;
                 }
             }
 
             if ([type isEqualToString:(NSString *)kUTTypeRTF]) {
                 if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, kUTTypeRTF)) {
-                    if (reader.readRTF(buffer.release()))
+                    if (reader.readRTF(*buffer))
                         break;
                 }
             }
 
             if ([supportedImageTypes() containsObject:type]) {
                 if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, type)) {
-                    if (reader.readImage(buffer.release(), type))
+                    if (reader.readImage(buffer.releaseNonNull(), type))
                         break;
                 }
         }
index fa256e6..8a5d55f 100644 (file)
@@ -86,7 +86,7 @@ void PlatformPasteboard::getTypes(Vector<String>&)
 {
 }
 
-PassRefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String&)
+RefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String&)
 {
     return nullptr;
 }
@@ -196,7 +196,7 @@ int PlatformPasteboard::count()
     return [m_pasteboard numberOfItems];
 }
 
-PassRefPtr<SharedBuffer> PlatformPasteboard::readBuffer(int index, const String& type)
+RefPtr<SharedBuffer> PlatformPasteboard::readBuffer(int index, const String& type)
 {
     NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:index];
 
index da74db3..76a7841 100644 (file)
@@ -250,7 +250,7 @@ static void writeFileWrapperAsRTFDAttachment(NSFileWrapper *wrapper, const Strin
     if (!RTFDData)
         return;
 
-    newChangeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapNSData(RTFDData).get(), NSRTFDPboardType, pasteboardName);
+    newChangeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(SharedBuffer::wrapNSData(RTFDData).ptr(), NSRTFDPboardType, pasteboardName);
 }
 
 void Pasteboard::write(const PasteboardImage& pasteboardImage)
@@ -340,7 +340,7 @@ void Pasteboard::read(PasteboardWebContentReader& reader)
 
     if (types.contains(WebArchivePboardType)) {
         if (RefPtr<SharedBuffer> buffer = strategy.bufferForType(WebArchivePboardType, m_pasteboardName)) {
-            if (reader.readWebArchive(buffer.release()))
+            if (reader.readWebArchive(buffer.get()))
                 return;
         }
     }
@@ -360,35 +360,35 @@ void Pasteboard::read(PasteboardWebContentReader& reader)
 
     if (types.contains(String(NSRTFDPboardType))) {
         if (RefPtr<SharedBuffer> buffer = strategy.bufferForType(NSRTFDPboardType, m_pasteboardName)) {
-            if (reader.readRTFD(buffer.release()))
+            if (reader.readRTFD(*buffer))
                 return;
         }
     }
 
     if (types.contains(String(NSRTFPboardType))) {
         if (RefPtr<SharedBuffer> buffer = strategy.bufferForType(NSRTFPboardType, m_pasteboardName)) {
-            if (reader.readRTF(buffer.release()))
+            if (reader.readRTF(*buffer))
                 return;
         }
     }
 
     if (types.contains(String(NSTIFFPboardType))) {
         if (RefPtr<SharedBuffer> buffer = strategy.bufferForType(NSTIFFPboardType, m_pasteboardName)) {
-            if (reader.readImage(buffer.release(), ASCIILiteral("image/tiff")))
+            if (reader.readImage(buffer.releaseNonNull(), ASCIILiteral("image/tiff")))
                 return;
         }
     }
 
     if (types.contains(String(NSPDFPboardType))) {
         if (RefPtr<SharedBuffer> buffer = strategy.bufferForType(NSPDFPboardType, m_pasteboardName)) {
-            if (reader.readImage(buffer.release(), ASCIILiteral("application/pdf")))
+            if (reader.readImage(buffer.releaseNonNull(), ASCIILiteral("application/pdf")))
                 return;
         }
     }
 
     if (types.contains(String(kUTTypePNG))) {
         if (RefPtr<SharedBuffer> buffer = strategy.bufferForType(kUTTypePNG, m_pasteboardName)) {
-            if (reader.readImage(buffer.release(), ASCIILiteral("image/png")))
+            if (reader.readImage(buffer.releaseNonNull(), ASCIILiteral("image/png")))
                 return;
         }
     }
index e82299f..aec4a69 100644 (file)
@@ -45,11 +45,11 @@ void PlatformPasteboard::getTypes(Vector<String>& types)
         types.append([pasteboardTypes objectAtIndex:i]);
 }
 
-PassRefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String& pasteboardType)
+RefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String& pasteboardType)
 {
     NSData *data = [m_pasteboard.get() dataForType:pasteboardType];
     if (!data)
-        return 0;
+        return nullptr;
     return SharedBuffer::wrapNSData([[data copy] autorelease]);
 }
 
index b11d089..6a7f45b 100644 (file)
@@ -30,7 +30,6 @@
 #include <runtime/InitializeThreading.h>
 #include <string.h>
 #include <wtf/MainThread.h>
-#include <wtf/PassRefPtr.h>
 
 using namespace WebCore;
 
@@ -84,9 +83,9 @@ using namespace WebCore;
 
 namespace WebCore {
 
-PassRefPtr<SharedBuffer> SharedBuffer::wrapNSData(NSData *nsData)
+Ref<SharedBuffer> SharedBuffer::wrapNSData(NSData *nsData)
 {
-    return adoptRef(new SharedBuffer((CFDataRef)nsData));
+    return adoptRef(*new SharedBuffer((CFDataRef)nsData));
 }
 
 RetainPtr<NSData> SharedBuffer::createNSData()
@@ -121,7 +120,7 @@ RefPtr<SharedBuffer> SharedBuffer::createFromReadingFile(const String& filePath)
     NSData *resourceData = [NSData dataWithContentsOfFile:filePath];
     if (resourceData) 
         return SharedBuffer::wrapNSData(resourceData);
-    return 0;
+    return nullptr;
 }
 
 }
index 3a598cc..267b597 100644 (file)
@@ -43,13 +43,13 @@ namespace WebCore {
 
 typedef HashMap<String, String> KeyValueMap;
 
-static KeyValueMap retrieveKeyValuePairs(WebCore::SharedBufferChunkReader* buffer)
+static KeyValueMap retrieveKeyValuePairs(WebCore::SharedBufferChunkReader& buffer)
 {
     KeyValueMap keyValuePairs;
     String line;
     String key;
     StringBuilder value;
-    while (!(line = buffer->nextChunkAsUTF8StringWithLatin1Fallback()).isNull()) {
+    while (!(line = buffer.nextChunkAsUTF8StringWithLatin1Fallback()).isNull()) {
         if (line.isEmpty())
             break; // Empty line means end of key/value section.
         if (line[0] == '\t') {
@@ -79,9 +79,9 @@ static KeyValueMap retrieveKeyValuePairs(WebCore::SharedBufferChunkReader* buffe
     return keyValuePairs;
 }
 
-PassRefPtr<MIMEHeader> MIMEHeader::parseHeader(SharedBufferChunkReader* buffer)
+RefPtr<MIMEHeader> MIMEHeader::parseHeader(SharedBufferChunkReader& buffer)
 {
-    RefPtr<MIMEHeader> mimeHeader = adoptRef(new MIMEHeader);
+    auto mimeHeader = adoptRef(*new MIMEHeader);
     KeyValueMap keyValuePairs = retrieveKeyValuePairs(buffer);
     KeyValueMap::iterator mimeParametersIterator = keyValuePairs.find("content-type");
     if (mimeParametersIterator != keyValuePairs.end()) {
@@ -94,7 +94,7 @@ PassRefPtr<MIMEHeader> MIMEHeader::parseHeader(SharedBufferChunkReader* buffer)
             mimeHeader->m_endOfPartBoundary = parsedContentType.parameterValueForName("boundary");
             if (mimeHeader->m_endOfPartBoundary.isNull()) {
                 LOG_ERROR("No boundary found in multipart MIME header.");
-                return 0;
+                return nullptr;
             }
             mimeHeader->m_endOfPartBoundary = "--" + mimeHeader->m_endOfPartBoundary;
             mimeHeader->m_endOfDocumentBoundary = mimeHeader->m_endOfPartBoundary + "--";
@@ -109,7 +109,7 @@ PassRefPtr<MIMEHeader> MIMEHeader::parseHeader(SharedBufferChunkReader* buffer)
     if (mimeParametersIterator != keyValuePairs.end())
         mimeHeader->m_contentLocation = mimeParametersIterator->value;
 
-    return mimeHeader.release();
+    return WTFMove(mimeHeader);
 }
 
 MIMEHeader::Encoding MIMEHeader::parseContentTransferEncoding(const String& text)
index d22d551..a113a9b 100644 (file)
@@ -51,7 +51,7 @@ public:
         Unknown
     };
 
-    static PassRefPtr<MIMEHeader> parseHeader(SharedBufferChunkReader* crLFLineReader);
+    static RefPtr<MIMEHeader> parseHeader(SharedBufferChunkReader& crLFLineReader);
 
     bool isMultipart() const { return m_contentType.startsWith("multipart/"); }
 
index ec1debf..6dd4c9f 100644 (file)
@@ -33,9 +33,9 @@ SharedBuffer::SharedBuffer(SoupBuffer* soupBuffer)
     ASSERT(soupBuffer);
 }
 
-PassRefPtr<SharedBuffer> SharedBuffer::wrapSoupBuffer(SoupBuffer* soupBuffer)
+Ref<SharedBuffer> SharedBuffer::wrapSoupBuffer(SoupBuffer* soupBuffer)
 {
-    return adoptRef(new SharedBuffer(soupBuffer));
+    return adoptRef(*new SharedBuffer(soupBuffer));
 }
 
 void SharedBuffer::clearPlatformData()
index 7fdc6b8..f8e56b6 100644 (file)
@@ -598,16 +598,16 @@ String getCFHTML(const DragDataMap* dataMap)
     return extractMarkupFromCFHTML(cfhtml);
 }
 
-PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*)
+RefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*)
 {
     // FIXME: We should be able to create fragments from files
-    return 0;
+    return nullptr;
 }
 
-PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const DragDataMap*)
+RefPtr<DocumentFragment> fragmentFromFilenames(Document*, const DragDataMap*)
 {
     // FIXME: We should be able to create fragments from files
-    return 0;
+    return nullptr;
 }
 
 bool containsFilenames(const IDataObject*)
@@ -623,7 +623,7 @@ bool containsFilenames(const DragDataMap*)
 }
 
 // Convert a String containing CF_HTML formatted text to a DocumentFragment
-PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document* doc, const String& cfhtml)
+Ref<DocumentFragment> fragmentFromCFHTML(Document* doc, const String& cfhtml)
 {
     // obtain baseURL if present
     String srcURLStr("sourceURL:");
@@ -641,41 +641,37 @@ PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document* doc, const String& cfh
     return createFragmentFromMarkup(*doc, markup, srcURL, DisallowScriptingAndPluginContent);
 }
 
-PassRefPtr<DocumentFragment> fragmentFromHTML(Document* doc, IDataObject* data) 
+RefPtr<DocumentFragment> fragmentFromHTML(Document* doc, IDataObject* data)
 {
     if (!doc || !data)
-        return 0;
+        return nullptr;
 
     String cfhtml = getFullCFHTML(data);
-    if (!cfhtml.isEmpty()) {
-        if (RefPtr<DocumentFragment> fragment = fragmentFromCFHTML(doc, cfhtml))
-            return fragment.release();
-    }
+    if (!cfhtml.isEmpty())
+        return fragmentFromCFHTML(doc, cfhtml);
 
     String html = getTextHTML(data);
     String srcURL;
     if (!html.isEmpty())
         return createFragmentFromMarkup(*doc, html, srcURL, DisallowScriptingAndPluginContent);
 
-    return 0;
+    return nullptr;
 }
 
-PassRefPtr<DocumentFragment> fragmentFromHTML(Document* document, const DragDataMap* data) 
+RefPtr<DocumentFragment> fragmentFromHTML(Document* document, const DragDataMap* data)
 {
     if (!document || !data || data->isEmpty())
-        return 0;
+        return nullptr;
 
     String stringData;
-    if (getDataMapItem(data, htmlFormat(), stringData)) {
-        if (RefPtr<DocumentFragment> fragment = fragmentFromCFHTML(document, stringData))
-            return fragment.release();
-    }
+    if (getDataMapItem(data, htmlFormat(), stringData))
+        return fragmentFromCFHTML(document, stringData);
 
     String srcURL;
     if (getDataMapItem(data, texthtmlFormat(), stringData))
         return createFragmentFromMarkup(*document, stringData, srcURL, DisallowScriptingAndPluginContent);
 
-    return 0;
+    return nullptr;
 }
 
 bool containsHTML(IDataObject* data)
index c2f16d7..5cd9e0e 100644 (file)
@@ -62,11 +62,11 @@ bool containsFilenames(const DragDataMap*);
 bool containsHTML(IDataObject*);
 bool containsHTML(const DragDataMap*);
 
-PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*);
-PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const DragDataMap*);
-PassRefPtr<DocumentFragment> fragmentFromHTML(Document*, IDataObject*);
-PassRefPtr<DocumentFragment> fragmentFromHTML(Document*, const DragDataMap*);
-PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document*, const String& cfhtml);
+RefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*);
+RefPtr<DocumentFragment> fragmentFromFilenames(Document*, const DragDataMap*);
+RefPtr<DocumentFragment> fragmentFromHTML(Document*, IDataObject*);
+RefPtr<DocumentFragment> fragmentFromHTML(Document*, const DragDataMap*);
+Ref<DocumentFragment> fragmentFromCFHTML(Document*, const String& cfhtml);
 
 String getURL(IDataObject*, DragData::FilenameConversionPolicy, String* title = 0);
 String getURL(const DragDataMap*, DragData::FilenameConversionPolicy, String* title = 0);
index 031bfd2..64ea665 100644 (file)
@@ -792,7 +792,7 @@ void Pasteboard::read(PasteboardPlainText& text)
     }
 }
 
-PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
+RefPtr<DocumentFragment> Pasteboard::documentFragment(Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
 {
     chosePlainText = false;
     
@@ -805,9 +805,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame& frame, Range& c
             GlobalUnlock(cbData);
             ::CloseClipboard();
 
-            RefPtr<DocumentFragment> fragment = fragmentFromCFHTML(frame.document(), cfhtml);
-            if (fragment)
-                return fragment.release();
+            return fragmentFromCFHTML(frame.document(), cfhtml);
         } else 
             ::CloseClipboard();
     }
@@ -821,9 +819,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame& frame, Range& c
                 String str(buffer);
                 GlobalUnlock(cbData);
                 ::CloseClipboard();
-                RefPtr<DocumentFragment> fragment = createFragmentFromText(context, str);
-                if (fragment)
-                    return fragment.release();
+                return createFragmentFromText(context, str);
             } else 
                 ::CloseClipboard();
         }
@@ -838,15 +834,13 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame& frame, Range& c
                 String str(buffer);
                 GlobalUnlock(cbData);
                 ::CloseClipboard();
-                RefPtr<DocumentFragment> fragment = createFragmentFromText(context, str);
-                if (fragment)
-                    return fragment.release();
+                return createFragmentFromText(context, str);
             } else
                 ::CloseClipboard();
         }
     }
     
-    return 0;
+    return nullptr;
 }
 
 void Pasteboard::setExternalDataObject(IDataObject *dataObject)
index 5e76a73..135939c 100644 (file)
@@ -1,3 +1,28 @@
+2016-03-14  Joonghun Park  <jh718.park@samsung.com>
+
+        Purge PassRefPtr from ArrayBuffer, ArchiveResource, Pasteboard, LegacyWebArchive and DataObjectGtk
+        https://bugs.webkit.org/show_bug.cgi?id=150497
+
+        Reviewed by Darin Adler.
+
+        * DOM/WebDOMOperations.mm:
+        (-[DOMNode webArchive]):
+        (-[DOMNode webArchiveByFilteringSubframes:]):
+        * WebCoreSupport/WebPlatformStrategies.h:
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::bufferForType):
+        (WebPlatformStrategies::readBufferFromPasteboard):
+        * WebView/WebArchive.mm:
+        (-[WebArchive initWithData:]):
+        * WebView/WebDataSource.mm:
+        (-[WebDataSource webArchive]):
+        (-[WebDataSource addSubresource:]):
+        * WebView/WebResource.mm:
+        (-[WebResource encodeWithCoder:]):
+        (-[WebResource data]):
+        (-[WebResource _stringValue]):
+        (-[WebResource _initWithCoreResource:]): Deleted.
+
 2016-03-14  Oliver Hunt  <oliver@apple.com>
 
         Temporarily disable the separated heap.
index f44ccd9..6afbb8f 100644 (file)
@@ -83,12 +83,12 @@ using namespace JSC;
 
 - (WebArchive *)webArchive
 {
-    return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(core(self))] autorelease];
+    return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(*core(self))] autorelease];
 }
 
 - (WebArchive *)webArchiveByFilteringSubframes:(WebArchiveSubframeFilter)webArchiveSubframeFilter
 {
-    WebArchive *webArchive = [[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(core(self), [webArchiveSubframeFilter](Frame& subframe) -> bool {
+    WebArchive *webArchive = [[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(*core(self), [webArchiveSubframeFilter](Frame& subframe) -> bool {
         return webArchiveSubframeFilter(kit(&subframe));
     })];
 
index 029b95b..e1f66da 100644 (file)
@@ -74,12 +74,12 @@ private:
     void writeToPasteboard(const String& pasteboardType, const String&) override;
     int getPasteboardItemsCount() override;
     String readStringFromPasteboard(int index, const String& pasteboardType) override;
-    PassRefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType) override;
+    RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType) override;
     WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType) override;
     long changeCount() override;
 #endif
     void getTypes(Vector<String>& types, const String& pasteboardName) override;
-    PassRefPtr<WebCore::SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) override;
+    RefPtr<WebCore::SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) override;
     void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) override;
     String stringForType(const String& pasteboardType, const String& pasteboardName) override;
     long changeCount(const String& pasteboardName) override;
index cb69a1b..6fdf270 100644 (file)
@@ -155,7 +155,7 @@ void WebPlatformStrategies::getTypes(Vector<String>& types, const String& pasteb
     PlatformPasteboard(pasteboardName).getTypes(types);
 }
 
-PassRefPtr<SharedBuffer> WebPlatformStrategies::bufferForType(const String& pasteboardType, const String& pasteboardName)
+RefPtr<SharedBuffer> WebPlatformStrategies::bufferForType(const String& pasteboardType, const String& pasteboardName)
 {
     return PlatformPasteboard(pasteboardName).bufferForType(pasteboardType);
 }
@@ -241,7 +241,7 @@ int WebPlatformStrategies::getPasteboardItemsCount()
     return PlatformPasteboard().count();
 }
 
-PassRefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(int index, const String& type)
+RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(int index, const String& type)
 {
     return PlatformPasteboard().readBuffer(index, type);
 }
index 158e6fa..348e8f0 100644 (file)
@@ -209,7 +209,7 @@ static BOOL isArrayOfClass(id object, Class elementClass)
 #endif
 
     _private = [[WebArchivePrivate alloc] init];
-    RefPtr<LegacyWebArchive> coreArchive = LegacyWebArchive::create(SharedBuffer::wrapNSData(data).get());
+    RefPtr<LegacyWebArchive> coreArchive = LegacyWebArchive::create(SharedBuffer::wrapNSData(data));
     if (!coreArchive) {
         [self release];
         return nil;
index 2a146de..803d3a8 100644 (file)
@@ -513,7 +513,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     if (!toPrivate(_private)->loader->isCommitted())
         return nil;
         
-    return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(core([self webFrame]))] autorelease];
+    return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(*core([self webFrame]))] autorelease];
 }
 
 - (WebResource *)mainResource
@@ -544,7 +544,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
 
 - (void)addSubresource:(WebResource *)subresource
 {    
-    toPrivate(_private)->loader->addArchiveResource([subresource _coreResource]);
+    toPrivate(_private)->loader->addArchiveResource(*[subresource _coreResource]);
 }
 
 @end
index 3569042..e5d8fd4 100644 (file)
@@ -168,8 +168,7 @@ static NSString * const WebResourceResponseKey =          @"WebResourceResponse"
     NSURLResponse *response = nil;
     
     if (resource) {
-        if (resource->data())
-            data = resource->data()->createNSData().get();
+        data = resource->data().createNSData().get();
         url = resource->url();
         mimeType = resource->mimeType();
         textEncoding = resource->textEncoding();
@@ -201,9 +200,7 @@ static NSString * const WebResourceResponseKey =          @"WebResourceResponse"
 
     if (!_private->coreResource)
         return nil;
-    if (!_private->coreResource->data())
-        return nil;
-    return _private->coreResource->data()->createNSData().autorelease();
+    return _private->coreResource->data().createNSData().autorelease();
 }
 
 - (NSURL *)URL
@@ -263,13 +260,6 @@ static NSString * const WebResourceResponseKey =          @"WebResourceResponse"
             
     ASSERT(coreResource);
     
-    // WebResources should not be init'ed with nil data, and doing so breaks certain uses of NSHTMLReader
-    // See <rdar://problem/5820157> for more info
-    if (!coreResource->data()) {
-        [self release];
-        return nil;
-    }
-    
     _private = [[WebResourcePrivate alloc] initWithCoreResource:coreResource];
             
     return self;
@@ -374,8 +364,8 @@ static NSString * const WebResourceResponseKey =          @"WebResourceResponse"
     if (!encoding.isValid())
         encoding = WindowsLatin1Encoding();
     
-    SharedBuffer* coreData = _private->coreResource ? _private->coreResource->data() : 0;
-    return encoding.decode(reinterpret_cast<const char*>(coreData ? coreData->data() : 0), coreData ? coreData->size() : 0);
+    SharedBuffer* coreData = _private->coreResource ? &_private->coreResource->data() : nullptr;
+    return encoding.decode(reinterpret_cast<const char*>(coreData ? coreData->data() : nullptr), coreData ? coreData->size() : 0);
 }
 
 @end
index 0eb4397..756550b 100644 (file)
@@ -1,3 +1,13 @@
+2016-03-14  Joonghun Park  <jh718.park@samsung.com>
+
+        Purge PassRefPtr from ArrayBuffer, ArchiveResource, Pasteboard, LegacyWebArchive and DataObjectGtk
+        https://bugs.webkit.org/show_bug.cgi?id=150497
+
+        Reviewed by Darin Adler.
+
+        * WebArchive.cpp:
+        (WebArchive::initWithNode):
+
 2016-03-12  Sam Weinig  <sam@webkit.org>
 
         WebKit can easily crash below NetworkSession::dataTaskForIdentifier() with NSURLSession enabled
index 74f3fdb..ad0c986 100644 (file)
@@ -113,7 +113,7 @@ HRESULT WebArchive::initWithNode(_In_opt_ IDOMNode* node)
     if (!domNode)
         return E_NOINTERFACE;
 
-    m_archive = LegacyWebArchive::create(domNode->node());
+    m_archive = LegacyWebArchive::create(*domNode->node());
     
     return S_OK;
 }
index eb7a1a6..18a1342 100644 (file)
@@ -1,3 +1,29 @@
+2016-03-14  Joonghun Park  <jh718.park@samsung.com>
+
+        Purge PassRefPtr from ArrayBuffer, ArchiveResource, Pasteboard, LegacyWebArchive and DataObjectGtk
+        https://bugs.webkit.org/show_bug.cgi?id=150497
+
+        Reviewed by Darin Adler.
+
+        * Shared/APIWebArchive.mm:
+        (API::WebArchive::WebArchive):
+        * Shared/APIWebArchiveResource.mm:
+        (API::WebArchiveResource::data):
+        * WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm:
+        (WebKit::PDFPlugin::addArchiveResource):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::bufferForType):
+        (WebKit::WebPlatformStrategies::readBufferFromPasteboard):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+        * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm:
+        (WebKit::WebEditorClient::documentFragmentFromAttributedString):
+        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+        (WebKit::WebDragClient::declareAndWriteDragImage):
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::webArchiveData):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::resourceDataForFrame):
+
 2016-03-14  Oliver Hunt  <oliver@apple.com>
 
         Temporarily disable the separated heap.
index 891e751..8e17e5b 100644 (file)
@@ -87,8 +87,7 @@ WebArchive::WebArchive(WebArchiveResource* mainResource, PassRefPtr<API::Array>
 
 WebArchive::WebArchive(API::Data* data)
 {
-    RefPtr<SharedBuffer> buffer = SharedBuffer::create(data->bytes(), data->size());
-    m_legacyWebArchive = LegacyWebArchive::create(buffer.get());
+    m_legacyWebArchive = LegacyWebArchive::create(SharedBuffer::create(data->bytes(), data->size()).get());
 }
 
 WebArchive::WebArchive(PassRefPtr<LegacyWebArchive> legacyWebArchive)
index 9e383e1..9a459b6 100644 (file)
@@ -69,7 +69,7 @@ static void releaseCFData(unsigned char*, const void* data)
 
 Ref<API::Data> WebArchiveResource::data()
 {
-    RetainPtr<CFDataRef> cfData = m_archiveResource->data()->createCFData();
+    RetainPtr<CFDataRef> cfData = m_archiveResource->data().createCFData();
 
     // Balanced by CFRelease in releaseCFData.
     CFRetain(cfData.get());
index 0ed9ee2..d4d9e84 100644 (file)
@@ -828,7 +828,7 @@ void PDFPlugin::addArchiveResource()
     ResourceResponse synthesizedResponse(response.get());
 
     RefPtr<ArchiveResource> resource = ArchiveResource::create(SharedBuffer::wrapCFData(m_data.get()), m_sourceURL, "application/pdf", String(), String(), synthesizedResponse);
-    pluginView()->frame()->document()->loader()->addArchiveResource(resource.release());
+    pluginView()->frame()->document()->loader()->addArchiveResource(resource.releaseNonNull());
 }
 
 static void jsPDFDocInitialize(JSContextRef ctx, JSObjectRef object)
index 2df45c3..21da021 100644 (file)
@@ -364,7 +364,7 @@ void WebPlatformStrategies::getTypes(Vector<String>& types, const String& pasteb
     WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardTypes(pasteboardName), Messages::WebPasteboardProxy::GetPasteboardTypes::Reply(types), 0);
 }
 
-PassRefPtr<WebCore::SharedBuffer> WebPlatformStrategies::bufferForType(const String& pasteboardType, const String& pasteboardName)
+RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::bufferForType(const String& pasteboardType, const String& pasteboardName)
 {
     // First check the overrides.
     Vector<char> overrideBuffer;
@@ -376,7 +376,7 @@ PassRefPtr<WebCore::SharedBuffer> WebPlatformStrategies::bufferForType(const Str
     uint64_t size = 0;
     WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::GetPasteboardBufferForType(pasteboardName, pasteboardType), Messages::WebPasteboardProxy::GetPasteboardBufferForType::Reply(handle, size), 0);
     if (handle.isNull())
-        return 0;
+        return nullptr;
     RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
     return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), size);
 }
@@ -496,13 +496,13 @@ int WebPlatformStrategies::getPasteboardItemsCount()
     return itemsCount;
 }
 
-PassRefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(int index, const String& pasteboardType)
+RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(int index, const String& pasteboardType)
 {
     SharedMemory::Handle handle;
     uint64_t size = 0;
     WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadBufferFromPasteboard(index, pasteboardType), Messages::WebPasteboardProxy::ReadBufferFromPasteboard::Reply(handle, size), 0);
     if (handle.isNull())
-        return 0;
+        return nullptr;
     RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
     return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), size);
 }
index 5fda34b..0eaef9b 100644 (file)
@@ -79,13 +79,13 @@ private:
     void writeToPasteboard(const String& pasteboardType, const String&) override;
     int getPasteboardItemsCount() override;
     String readStringFromPasteboard(int index, const String& pasteboardType) override;
-    PassRefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType) override;
+    RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(int index, const String& pasteboardType) override;
     WebCore::URL readURLFromPasteboard(int index, const String& pasteboardType) override;
     long changeCount() override;
 #endif
 #if PLATFORM(COCOA)
     void getTypes(Vector<String>& types, const String& pasteboardName) override;
-    PassRefPtr<WebCore::SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) override;
+    RefPtr<WebCore::SharedBuffer> bufferForType(const String& pasteboardType, const String& pasteboardName) override;
     void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) override;
     String stringForType(const String& pasteboardType, const String& pasteboardName) override;
     long changeCount(const String& pasteboardName) override;
index e27c2c1..ee4f90c 100644 (file)
@@ -68,7 +68,7 @@ NSURL *WebEditorClient::canonicalizeURLString(NSString *)
 DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString *, Vector<RefPtr<ArchiveResource> >&)
 {
     notImplemented();
-    return 0;
+    return nullptr;
 }
 
 void WebEditorClient::setInsertionPasteboard(const String&)
index 25c369c..5a03859 100644 (file)
@@ -130,7 +130,7 @@ void WebDragClient::declareAndWriteDragImage(const String& pasteboardName, Eleme
             title = userVisibleString((NSURL *)url);
     }
 
-    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(&element);
+    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(element);
 
     NSURLResponse *response = image->response().nsURLResponse();
     
index a22192d..48b0c5f 100644 (file)
@@ -794,7 +794,7 @@ void WebFrame::documentLoaderDetached(uint64_t navigationID)
 #if PLATFORM(COCOA)
 RetainPtr<CFDataRef> WebFrame::webArchiveData(FrameFilterFunction callback, void* context)
 {
-    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(coreFrame()->document(), [this, callback, context](Frame& frame) -> bool {
+    RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(*coreFrame()->document(), [this, callback, context](Frame& frame) -> bool {
         if (!callback)
             return true;
 
index 03150c7..efca370 100644 (file)
@@ -2729,17 +2729,17 @@ void WebPage::getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID)
     send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
 }
 
-static PassRefPtr<SharedBuffer> resourceDataForFrame(Frame* frame, const URL& resourceURL)
+static RefPtr<SharedBuffer> resourceDataForFrame(Frame* frame, const URL& resourceURL)
 {
     DocumentLoader* loader = frame->loader().documentLoader();
     if (!loader)
-        return 0;
+        return nullptr;
 
     RefPtr<ArchiveResource> subresource = loader->subresource(resourceURL);
     if (!subresource)
-        return 0;
+        return nullptr;
 
-    return subresource->data();
+    return &subresource->data();
 }
 
 void WebPage::getResourceDataFromFrame(uint64_t frameID, const String& resourceURLString, uint64_t callbackID)