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
+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
#include "GCIncomingRefCounted.h"
#include "Weak.h"
#include <functional>
-#include <wtf/PassRefPtr.h>
#include <wtf/StdLibExtras.h>
#include <wtf/Vector.h>
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;
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();
~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);
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)
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);
+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.
{
}
- IDBGetResult(PassRefPtr<SharedBuffer> buffer)
+ IDBGetResult(SharedBuffer* buffer)
{
if (buffer)
dataFromBuffer(*buffer);
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());
}
}
}
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();
{
}
-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)
{
}
{
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()
{
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;
replaceSelectionWithFragment(createFragmentFromText(*range, text), selectReplacement, smartReplace, true, editingAction);
}
-PassRefPtr<Range> Editor::selectedRange()
+RefPtr<Range> Editor::selectedRange()
{
return m_frame.selection().toNormalizedRange();
}
EditingBehavior behavior() const;
- PassRefPtr<Range> selectedRange();
+ RefPtr<Range> selectedRange();
#if PLATFORM(IOS)
WEBCORE_EXPORT void confirmMarkedText();
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);
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);
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
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;
#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;
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);
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.
// Check again, because updating layout can clear the selection.
if (isNone())
- return 0;
+ return nullptr;
Position s, e;
if (isCaret()) {
}
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.
// 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;
}
}
-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;
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)
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())
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();
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();
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 };
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)];
}
}
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());
#include "DocumentFragment.h"
#include "NotImplemented.h"
#include "Pasteboard.h"
-#include <wtf/PassRefPtr.h>
namespace WebCore {
notImplemented();
}
-PassRefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard&, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
+RefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard&, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
{
return nullptr;
}
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;
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);
}
applyStyleToSelection(defaultStyle.get(), EditActionChangeAttributes);
}
-static PassRefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string)
+static RefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string)
{
NSUInteger length = string.length;
if (!length)
return nullptr;
}
-static PassRefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *string)
+static RefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *string)
{
NSUInteger length = string.length;
if (!length)
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)
{
}
- void addFragment(PassRefPtr<DocumentFragment>);
+ void addFragment(RefPtr<DocumentFragment>&&);
Frame& frame;
Range& context;
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()) {
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;
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;
}
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;
}
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;
// 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)
if (!fragment)
continue;
- reader.addFragment(fragment);
+ reader.addFragment(WTFMove(fragment));
}
RefPtr<DocumentFragment> fragment = reader.fragment;
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;
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)
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.
return range;
}
-static PassRefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string)
+static RefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string)
{
NSUInteger length = string.length;
if (!length)
return nullptr;
}
-static PassRefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *string)
+static RefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *string)
{
NSUInteger length = string.length;
if (!length)
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:],
return dataInRTFFormat(attributedString);
}
- return 0;
+ return nullptr;
}
void Editor::writeSelectionToPasteboard(Pasteboard& pasteboard)
}
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;
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;
}
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;
}
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]));
// 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;
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)
}
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))
}
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);
{
#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;
clearMainResource();
}
-PassRefPtr<SharedBuffer> DocumentLoader::mainResourceData() const
+RefPtr<SharedBuffer> DocumentLoader::mainResourceData() const
{
if (m_substituteData.isValid())
return m_substituteData.content()->copy();
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)
}
// 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)
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
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; }
#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;
// 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
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)
{
}
- 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(); }
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;
};
}
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;
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;
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)
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();
}
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()
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;
}
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();
responseToUse.setURL(url);
}
- substituteData = SubstituteData(resource->data(),
+ substituteData = SubstituteData(&resource->data(),
URL(),
responseToUse,
SubstituteData::SessionHistoryVisibility::Visible);
// 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());
}
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();
}
}
}
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)
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)
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);
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; }
#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;
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;
}
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()) {
// 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;
|| 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;
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;
}
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();
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);
}
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()
#include "Archive.h"
#include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
namespace WebCore {
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();
};
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)
{
}
-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);
}
}
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());
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;
// 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)
public:
ArchiveResourceCollection();
- void addResource(PassRefPtr<ArchiveResource>);
+ void addResource(Ref<ArchiveResource>&&);
void addAllResources(Archive*);
WEBCORE_EXPORT ArchiveResource* archiveResourceForURL(const URL&);
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
return ResourceResponse();
}
-PassRefPtr<ArchiveResource> LegacyWebArchive::createResource(CFDictionaryRef dictionary)
+RefPtr<ArchiveResource> LegacyWebArchive::createResource(CFDictionaryRef dictionary)
{
ASSERT(dictionary);
if (!dictionary)
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));
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;
if (!archive->extract(plist.get()))
return nullptr;
- return archive.release();
+ return WTFMove(archive);
}
bool LegacyWebArchive::extract(CFDictionaryRef dictionary)
#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();
}
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));
}
return create(documentLoader->mainResource(), WTFMove(subresources), WTFMove(subframeArchives));
}
-PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Range* range)
+RefPtr<LegacyWebArchive> LegacyWebArchive::create(Range* range)
{
if (!range)
return nullptr;
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;
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());
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))
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));
}
}
- 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;
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).
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;
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&);
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.
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)
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*);
{
}
-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.");
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;
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());
// 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
public:
explicit MHTMLParser(SharedBuffer*);
- PassRefPtr<MHTMLArchive> parseArchive();
+ RefPtr<MHTMLArchive> parseArchive();
size_t frameCount() const;
MHTMLArchive* frameAt(size_t) const;
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*);
{
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());
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
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;
}
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; }
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;
~Pasteboard();
#if PLATFORM(GTK)
- explicit Pasteboard(PassRefPtr<DataObjectGtk>);
+ explicit Pasteboard(RefPtr<DataObjectGtk>&&);
explicit Pasteboard(GtkClipboard*);
#endif
#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
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;
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;
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();
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));
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)
#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();
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);
#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
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;
MappedFileData m_fileData;
};
-PassRefPtr<SharedBuffer> utf8Buffer(const String&);
+RefPtr<SharedBuffer> utf8Buffer(const String&);
} // namespace WebCore
}
#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
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
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
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;
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
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);
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; }
{
}
-Pasteboard::Pasteboard(PassRefPtr<DataObjectGtk> dataObject)
- : m_dataObject(dataObject)
+Pasteboard::Pasteboard(RefPtr<DataObjectGtk>&& dataObject)
+ : m_dataObject(WTFMove(dataObject))
, m_gtkClipboard(nullptr)
{
ASSERT(m_dataObject);
{
}
-PassRefPtr<DataObjectGtk> Pasteboard::dataObject() const
+DataObjectGtk* Pasteboard::dataObject() const
{
- return m_dataObject;
+ return m_dataObject.get();
}
static ClipboardDataType dataObjectTypeFromHTMLClipboardType(const String& rawType)
if ([type isEqualToString:WebArchivePboardType]) {
if (RefPtr<SharedBuffer> buffer = strategy.readBufferFromPasteboard(i, WebArchivePboardType)) {
- if (reader.readWebArchive(buffer.release()))
+ if (reader.readWebArchive(buffer.get()))
break;
}
}
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;
}
}
{
}
-PassRefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String&)
+RefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String&)
{
return nullptr;
}
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];
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)
if (types.contains(WebArchivePboardType)) {
if (RefPtr<SharedBuffer> buffer = strategy.bufferForType(WebArchivePboardType, m_pasteboardName)) {
- if (reader.readWebArchive(buffer.release()))
+ if (reader.readWebArchive(buffer.get()))
return;
}
}
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;
}
}
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]);
}
#include <runtime/InitializeThreading.h>
#include <string.h>
#include <wtf/MainThread.h>
-#include <wtf/PassRefPtr.h>
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()
NSData *resourceData = [NSData dataWithContentsOfFile:filePath];
if (resourceData)
return SharedBuffer::wrapNSData(resourceData);
- return 0;
+ return nullptr;
}
}
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') {
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()) {
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 + "--";
if (mimeParametersIterator != keyValuePairs.end())
mimeHeader->m_contentLocation = mimeParametersIterator->value;
- return mimeHeader.release();
+ return WTFMove(mimeHeader);
}
MIMEHeader::Encoding MIMEHeader::parseContentTransferEncoding(const String& text)
Unknown
};
- static PassRefPtr<MIMEHeader> parseHeader(SharedBufferChunkReader* crLFLineReader);
+ static RefPtr<MIMEHeader> parseHeader(SharedBufferChunkReader& crLFLineReader);
bool isMultipart() const { return m_contentType.startsWith("multipart/"); }
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()
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*)
}
// 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:");
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)
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);
}
}
-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;
GlobalUnlock(cbData);
::CloseClipboard();
- RefPtr<DocumentFragment> fragment = fragmentFromCFHTML(frame.document(), cfhtml);
- if (fragment)
- return fragment.release();
+ return fragmentFromCFHTML(frame.document(), cfhtml);
} else
::CloseClipboard();
}
String str(buffer);
GlobalUnlock(cbData);
::CloseClipboard();
- RefPtr<DocumentFragment> fragment = createFragmentFromText(context, str);
- if (fragment)
- return fragment.release();
+ return createFragmentFromText(context, str);
} else
::CloseClipboard();
}
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)
+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.
- (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));
})];
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;
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);
}
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);
}
#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;
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
- (void)addSubresource:(WebResource *)subresource
{
- toPrivate(_private)->loader->addArchiveResource([subresource _coreResource]);
+ toPrivate(_private)->loader->addArchiveResource(*[subresource _coreResource]);
}
@end
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();
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
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;
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
+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
if (!domNode)
return E_NOINTERFACE;
- m_archive = LegacyWebArchive::create(domNode->node());
+ m_archive = LegacyWebArchive::create(*domNode->node());
return S_OK;
}
+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.
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)
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());
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)
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;
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);
}
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);
}
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;
DocumentFragment* WebEditorClient::documentFragmentFromAttributedString(NSAttributedString *, Vector<RefPtr<ArchiveResource> >&)
{
notImplemented();
- return 0;
+ return nullptr;
}
void WebEditorClient::setInsertionPasteboard(const String&)
title = userVisibleString((NSURL *)url);
}
- RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(&element);
+ RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(element);
NSURLResponse *response = image->response().nsURLResponse();
#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;
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)