Changeset 248503 in webkit
- Timestamp:
- Aug 10, 2019 3:50:19 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r248502 r248503 1 2019-08-10 Youenn Fablet <youenn@apple.com> 2 3 Blob should store its session ID 4 https://bugs.webkit.org/show_bug.cgi?id=200572 5 6 Reviewed by Darin Adler. 7 8 Blob at creation time now initializes its session ID. 9 This will allow in the future to call blob registry routines with it. 10 Update all call sites to provide the session ID. 11 12 No observable change. 13 14 * Modules/entriesapi/DOMFileSystem.cpp: 15 (WebCore::DOMFileSystem::getFile): 16 * Modules/fetch/FetchBody.cpp: 17 (WebCore::FetchBody::fromFormData): 18 * Modules/fetch/FetchBody.h: 19 * Modules/fetch/FetchBodyConsumer.cpp: 20 (WebCore::blobFromData): 21 (WebCore::resolveWithTypeAndData): 22 (WebCore::FetchBodyConsumer::resolve): 23 (WebCore::FetchBodyConsumer::takeAsBlob): 24 * Modules/fetch/FetchBodyConsumer.h: 25 * Modules/fetch/FetchBodyOwner.cpp: 26 (WebCore::FetchBodyOwner::blob): 27 * Modules/mediarecorder/MediaRecorder.cpp: 28 (WebCore::MediaRecorder::createRecordingDataBlob): 29 * Modules/mediastream/RTCDataChannel.cpp: 30 (WebCore::RTCDataChannel::didReceiveRawData): 31 * Modules/websockets/WebSocket.cpp: 32 (WebCore::WebSocket::didReceiveBinaryData): 33 * Modules/websockets/WorkerThreadableWebSocketChannel.cpp: 34 (WebCore::WorkerThreadableWebSocketChannel::Bridge::send): 35 * bindings/js/JSDOMPromiseDeferred.h: 36 (WebCore::DeferredPromise::sessionID const): 37 * bindings/js/SerializedScriptValue.cpp: 38 (WebCore::CloneDeserializer::readFile): 39 (WebCore::CloneDeserializer::readTerminal): 40 * dom/DataTransfer.cpp: 41 (WebCore::DataTransfer::DataTransfer): 42 (WebCore::DataTransfer::createForCopyAndPaste): 43 (WebCore::DataTransfer::filesFromPasteboardAndItemList const): 44 (WebCore::DataTransfer::createForInputEvent): 45 (WebCore::DataTransfer::createForDrag): 46 (WebCore::DataTransfer::createForDragStartEvent): 47 (WebCore::DataTransfer::createForDrop): 48 (WebCore::DataTransfer::createForUpdatingDropTarget): 49 * dom/DataTransfer.h: 50 * dom/Document.cpp: 51 (WebCore::Document::originIdentifierForPasteboard const): 52 * dom/Document.h: 53 * editing/ReplaceRangeWithTextCommand.cpp: 54 (WebCore::ReplaceRangeWithTextCommand::inputEventDataTransfer const): 55 * editing/ReplaceSelectionCommand.cpp: 56 (WebCore::ReplaceSelectionCommand::inputEventDataTransfer const): 57 * editing/SpellingCorrectionCommand.cpp: 58 (WebCore::SpellingCorrectionCommand::inputEventDataTransfer const): 59 * editing/TypingCommand.cpp: 60 (WebCore::TypingCommand::inputEventDataTransfer const): 61 * editing/WebCorePasteboardFileReader.cpp: 62 (WebCore::WebCorePasteboardFileReader::readFilename): 63 (WebCore::WebCorePasteboardFileReader::readBuffer): 64 * editing/WebCorePasteboardFileReader.h: 65 * editing/cocoa/WebContentReaderCocoa.mm: 66 (WebCore::createFragmentForImageAttachment): 67 (WebCore::replaceRichContentWithAttachments): 68 (WebCore::createFragmentAndAddResources): 69 (WebCore::sanitizeMarkupWithArchive): 70 (WebCore::WebContentReader::readImage): 71 (WebCore::attachmentForFilePath): 72 (WebCore::attachmentForData): 73 * editing/markup.cpp: 74 (WebCore::restoreAttachmentElementsInFragment): 75 * fileapi/Blob.cpp: 76 (WebCore::Blob::Blob): 77 * fileapi/Blob.h: 78 (WebCore::Blob::create): 79 (WebCore::Blob::deserialize): 80 (WebCore::Blob::slice const): 81 * fileapi/Blob.idl: 82 * fileapi/File.cpp: 83 (WebCore::File::createWithRelativePath): 84 (WebCore::File::File): 85 * fileapi/File.h: 86 * fileapi/File.idl: 87 * html/FileInputType.cpp: 88 (WebCore::FileInputType::appendFormData const): 89 (WebCore::FileInputType::filesChosen): 90 * html/FileListCreator.cpp: 91 (WebCore::appendDirectoryFiles): 92 (WebCore::FileListCreator::FileListCreator): 93 (WebCore::FileListCreator::createFileList): 94 * html/FileListCreator.h: 95 (WebCore::FileListCreator::create): 96 * html/HTMLAttachmentElement.cpp: 97 (WebCore::HTMLAttachmentElement::updateEnclosingImageWithData): 98 * html/HTMLCanvasElement.cpp: 99 (WebCore::HTMLCanvasElement::toBlob): 100 * page/EventHandler.cpp: 101 (WebCore::EventHandler::handleDrag): 102 * testing/Internals.cpp: 103 (WebCore::Internals::createFile): 104 * testing/ServiceWorkerInternals.cpp: 105 (WebCore::ServiceWorkerInternals::createOpaqueWithBlobBodyResponse): 106 * workers/service/context/ServiceWorkerFetch.cpp: 107 (WebCore::ServiceWorkerFetch::dispatchFetchEvent): 108 * xml/XMLHttpRequest.cpp: 109 (WebCore::XMLHttpRequest::createResponseBlob): 110 1 111 2019-08-10 Alex Christensen <achristensen@webkit.org> 2 112 -
trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp
r243887 r248503 344 344 completionCallback(validatedVirtualPath.releaseException()); 345 345 else 346 completionCallback(File::create( fullPath));346 completionCallback(File::create(context->sessionID(), fullPath)); 347 347 }); 348 348 }); -
trunk/Source/WebCore/Modules/fetch/FetchBody.cpp
r248283 r248503 76 76 } 77 77 78 Optional<FetchBody> FetchBody::fromFormData( FormData& formData)78 Optional<FetchBody> FetchBody::fromFormData(PAL::SessionID sessionID, FormData& formData) 79 79 { 80 80 ASSERT(!formData.isEmpty()); … … 89 89 if (!url.isNull()) { 90 90 // FIXME: Properly set mime type and size of the blob. 91 Ref<const Blob> blob = Blob::deserialize( url, { }, 0, { });91 Ref<const Blob> blob = Blob::deserialize(sessionID, url, { }, 0, { }); 92 92 return FetchBody { WTFMove(blob) }; 93 93 } -
trunk/Source/WebCore/Modules/fetch/FetchBody.h
r248283 r248503 60 60 FetchBody() = default; 61 61 62 WEBCORE_EXPORT static Optional<FetchBody> fromFormData( FormData&);62 WEBCORE_EXPORT static Optional<FetchBody> fromFormData(PAL::SessionID, FormData&); 63 63 64 64 void loadingFailed(const Exception&); -
trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp
r239644 r248503 36 36 namespace WebCore { 37 37 38 static inline Ref<Blob> blobFromData( const unsigned char* data, unsigned length, const String& contentType)38 static inline Ref<Blob> blobFromData(PAL::SessionID sessionID, const unsigned char* data, unsigned length, const String& contentType) 39 39 { 40 40 Vector<uint8_t> value(length); 41 41 memcpy(value.data(), data, length); 42 return Blob::create( WTFMove(value), contentType);42 return Blob::create(sessionID, WTFMove(value), contentType); 43 43 } 44 44 … … 65 65 return; 66 66 case FetchBodyConsumer::Type::Blob: 67 promise->resolveWithNewlyCreated<IDLInterface<Blob>>(blobFromData( data, length, contentType).get());67 promise->resolveWithNewlyCreated<IDLInterface<Blob>>(blobFromData(promise->sessionID(), data, length, contentType).get()); 68 68 return; 69 69 case FetchBodyConsumer::Type::JSON: … … 131 131 return; 132 132 case Type::Blob: 133 promise->resolveWithNewlyCreated<IDLInterface<Blob>>(takeAsBlob( ).get());133 promise->resolveWithNewlyCreated<IDLInterface<Blob>>(takeAsBlob(promise->sessionID()).get()); 134 134 return; 135 135 case Type::JSON: … … 178 178 } 179 179 180 Ref<Blob> FetchBodyConsumer::takeAsBlob( )180 Ref<Blob> FetchBodyConsumer::takeAsBlob(PAL::SessionID sessionID) 181 181 { 182 182 if (!m_buffer) 183 return Blob::create( Vector<uint8_t>(), m_contentType);183 return Blob::create(sessionID, Vector<uint8_t>(), m_contentType); 184 184 185 185 // FIXME: We should try to move m_buffer to Blob without doing extra copy. 186 return blobFromData( reinterpret_cast<const unsigned char*>(m_buffer->data()), m_buffer->size(), m_contentType);186 return blobFromData(sessionID, reinterpret_cast<const unsigned char*>(m_buffer->data()), m_buffer->size(), m_contentType); 187 187 } 188 188 -
trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h
r239644 r248503 55 55 RefPtr<SharedBuffer> takeData(); 56 56 RefPtr<JSC::ArrayBuffer> takeAsArrayBuffer(); 57 Ref<Blob> takeAsBlob();58 57 String takeAsText(); 59 58 … … 76 75 77 76 private: 77 Ref<Blob> takeAsBlob(PAL::SessionID); 78 78 79 Type m_type; 79 80 String m_contentType; -
trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp
r248283 r248503 125 125 126 126 if (isBodyNullOrOpaque()) { 127 promise->resolve<IDLInterface<Blob>>(Blob::create( Vector<uint8_t> { }, Blob::normalizedContentType(extractMIMETypeFromMediaType(m_contentType))));127 promise->resolve<IDLInterface<Blob>>(Blob::create(promise->sessionID(), Vector<uint8_t> { }, Blob::normalizedContentType(extractMIMETypeFromMediaType(m_contentType)))); 128 128 return; 129 129 } -
trunk/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp
r243887 r248503 158 158 auto data = m_private->fetchData(); 159 159 if (!data) 160 return Blob::create( );161 return Blob::create( *data, m_private->mimeType());160 return Blob::create(scriptExecutionContext()->sessionID()); 161 return Blob::create(scriptExecutionContext()->sessionID(), *data, m_private->mimeType()); 162 162 } 163 163 -
trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp
r246490 r248503 203 203 switch (m_binaryType) { 204 204 case BinaryType::Blob: 205 scheduleDispatchEvent(MessageEvent::create(Blob::create( SharedBuffer::create(data, dataLength), emptyString()), { }));205 scheduleDispatchEvent(MessageEvent::create(Blob::create(scriptExecutionContext()->sessionID(), SharedBuffer::create(data, dataLength), emptyString()), { })); 206 206 return; 207 207 case BinaryType::ArrayBuffer: -
trunk/Source/WebCore/Modules/websockets/WebSocket.cpp
r246388 r248503 585 585 case BinaryType::Blob: 586 586 // FIXME: We just received the data from NetworkProcess, and are sending it back. This is inefficient. 587 dispatchEvent(MessageEvent::create(Blob::create( WTFMove(binaryData), emptyString()), SecurityOrigin::create(m_url)->toString()));587 dispatchEvent(MessageEvent::create(Blob::create(scriptExecutionContext()->sessionID(), WTFMove(binaryData), emptyString()), SecurityOrigin::create(m_url)->toString())); 588 588 break; 589 589 case BinaryType::ArrayBuffer: -
trunk/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp
r247902 r248503 466 466 ASSERT(peer); 467 467 468 peer->send(Blob::deserialize( url, type, size, { }));468 peer->send(Blob::deserialize(context.sessionID(), url, type, size, { })); 469 469 }); 470 470 -
trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h
r244312 r248503 29 29 #include "JSDOMConvert.h" 30 30 #include "JSDOMGuardedObject.h" 31 #include "ScriptExecutionContext.h" 31 32 #include <JavaScriptCore/CatchScope.h> 32 33 #include <JavaScriptCore/JSPromiseDeferred.h> 34 #include <pal/SessionID.h> 33 35 34 36 namespace WebCore { … … 136 138 137 139 void whenSettled(std::function<void()>&&); 140 141 PAL::SessionID sessionID() const { return globalObject()->scriptExecutionContext()->sessionID(); } 138 142 139 143 private: -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp
r246770 r248503 2096 2096 2097 2097 if (m_isDOMGlobalObject) 2098 file = File::deserialize( filePath, URL(URL(), url->string()), type->string(), name->string(), optionalLastModified);2098 file = File::deserialize(jsCast<JSDOMGlobalObject*>(m_globalObject)->scriptExecutionContext()->sessionID(), filePath, URL(URL(), url->string()), type->string(), name->string(), optionalLastModified); 2099 2099 return true; 2100 2100 } … … 2862 2862 if (!m_isDOMGlobalObject) 2863 2863 return jsNull(); 2864 return getJSValue(Blob::deserialize( URL(URL(), url->string()), type->string(), size, blobFilePathForBlobURL(url->string())).get());2864 return getJSValue(Blob::deserialize(jsCast<JSDOMGlobalObject*>(m_globalObject)->scriptExecutionContext()->sessionID(), URL(URL(), url->string()), type->string(), size, blobFilePathForBlobURL(url->string())).get()); 2865 2865 } 2866 2866 case StringTag: { -
trunk/Source/WebCore/dom/DataTransfer.cpp
r246285 r248503 69 69 #endif 70 70 71 DataTransfer::DataTransfer(StoreMode mode, std::unique_ptr<Pasteboard> pasteboard, Type type) 72 : m_storeMode(mode) 71 DataTransfer::DataTransfer(const Document& document, StoreMode mode, std::unique_ptr<Pasteboard> pasteboard, Type type) 72 : m_sessionID(document.sessionID()) 73 , m_storeMode(mode) 73 74 , m_pasteboard(WTFMove(pasteboard)) 74 75 #if ENABLE(DRAG_SUPPORT) … … 84 85 } 85 86 86 Ref<DataTransfer> DataTransfer::createForCopyAndPaste( Document& document, StoreMode storeMode, std::unique_ptr<Pasteboard>&& pasteboard)87 { 88 auto dataTransfer = adoptRef(*new DataTransfer( storeMode, WTFMove(pasteboard)));87 Ref<DataTransfer> DataTransfer::createForCopyAndPaste(const Document& document, StoreMode storeMode, std::unique_ptr<Pasteboard>&& pasteboard) 88 { 89 auto dataTransfer = adoptRef(*new DataTransfer(document, storeMode, WTFMove(pasteboard))); 89 90 dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard(); 90 91 return dataTransfer; … … 349 350 Vector<Ref<File>> files; 350 351 if ((!forDrag() || forFileDrag()) && m_pasteboard->fileContentState() != Pasteboard::FileContentState::NoFileOrImageData) { 351 WebCorePasteboardFileReader reader ;352 WebCorePasteboardFileReader reader { m_sessionID }; 352 353 m_pasteboard->read(reader); 353 354 files = WTFMove(reader.files); … … 414 415 } 415 416 416 Ref<DataTransfer> DataTransfer::createForInputEvent(const String& plainText, const String& htmlText)417 Ref<DataTransfer> DataTransfer::createForInputEvent(const Document& document, const String& plainText, const String& htmlText) 417 418 { 418 419 auto pasteboard = std::make_unique<StaticPasteboard>(); 419 420 pasteboard->writeString("text/plain"_s, plainText); 420 421 pasteboard->writeString("text/html"_s, htmlText); 421 return adoptRef(*new DataTransfer( StoreMode::Readonly, WTFMove(pasteboard), Type::InputEvent));422 return adoptRef(*new DataTransfer(document, StoreMode::Readonly, WTFMove(pasteboard), Type::InputEvent)); 422 423 } 423 424 … … 464 465 #else 465 466 466 Ref<DataTransfer> DataTransfer::createForDrag( )467 { 468 return adoptRef(*new DataTransfer( StoreMode::ReadWrite, Pasteboard::createForDragAndDrop(), Type::DragAndDropData));469 } 470 471 Ref<DataTransfer> DataTransfer::createForDragStartEvent( Document& document)472 { 473 auto dataTransfer = adoptRef(*new DataTransfer( StoreMode::ReadWrite, std::make_unique<StaticPasteboard>(), Type::DragAndDropData));467 Ref<DataTransfer> DataTransfer::createForDrag(const Document& document) 468 { 469 return adoptRef(*new DataTransfer(document, StoreMode::ReadWrite, Pasteboard::createForDragAndDrop(), Type::DragAndDropData)); 470 } 471 472 Ref<DataTransfer> DataTransfer::createForDragStartEvent(const Document& document) 473 { 474 auto dataTransfer = adoptRef(*new DataTransfer(document, StoreMode::ReadWrite, std::make_unique<StaticPasteboard>(), Type::DragAndDropData)); 474 475 dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard(); 475 476 return dataTransfer; 476 477 } 477 478 478 Ref<DataTransfer> DataTransfer::createForDrop( Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)479 { 480 auto dataTransfer = adoptRef(*new DataTransfer( DataTransfer::StoreMode::Readonly, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData));479 Ref<DataTransfer> DataTransfer::createForDrop(const Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles) 480 { 481 auto dataTransfer = adoptRef(*new DataTransfer(document, DataTransfer::StoreMode::Readonly, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData)); 481 482 dataTransfer->setSourceOperation(sourceOperation); 482 483 dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard(); … … 484 485 } 485 486 486 Ref<DataTransfer> DataTransfer::createForUpdatingDropTarget( Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)487 { 488 auto dataTransfer = adoptRef(*new DataTransfer( DataTransfer::StoreMode::Protected, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData));487 Ref<DataTransfer> DataTransfer::createForUpdatingDropTarget(const Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles) 488 { 489 auto dataTransfer = adoptRef(*new DataTransfer(document, DataTransfer::StoreMode::Protected, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData)); 489 490 dataTransfer->setSourceOperation(sourceOperation); 490 491 dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard(); -
trunk/Source/WebCore/dom/DataTransfer.h
r228340 r248503 27 27 #include "DragActions.h" 28 28 #include "DragImage.h" 29 #include <pal/SessionID.h> 29 30 #include <wtf/text/WTFString.h> 30 31 … … 47 48 enum class StoreMode { Invalid, ReadWrite, Readonly, Protected }; 48 49 49 static Ref<DataTransfer> createForCopyAndPaste( Document&, StoreMode, std::unique_ptr<Pasteboard>&&);50 static Ref<DataTransfer> createForInputEvent(const String& plainText, const String& htmlText);50 static Ref<DataTransfer> createForCopyAndPaste(const Document&, StoreMode, std::unique_ptr<Pasteboard>&&); 51 static Ref<DataTransfer> createForInputEvent(const Document&, const String& plainText, const String& htmlText); 51 52 52 53 WEBCORE_EXPORT ~DataTransfer(); … … 87 88 88 89 #if ENABLE(DRAG_SUPPORT) 89 static Ref<DataTransfer> createForDrag( );90 static Ref<DataTransfer> createForDragStartEvent( Document&);91 static Ref<DataTransfer> createForDrop( Document&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);92 static Ref<DataTransfer> createForUpdatingDropTarget( Document&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);90 static Ref<DataTransfer> createForDrag(const Document&); 91 static Ref<DataTransfer> createForDragStartEvent(const Document&); 92 static Ref<DataTransfer> createForDrop(const Document&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles); 93 static Ref<DataTransfer> createForUpdatingDropTarget(const Document&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles); 93 94 94 95 bool dropEffectIsUninitialized() const { return m_dropEffect == "uninitialized"; } … … 113 114 private: 114 115 enum class Type { CopyAndPaste, DragAndDropData, DragAndDropFiles, InputEvent }; 115 DataTransfer( StoreMode, std::unique_ptr<Pasteboard>, Type = Type::CopyAndPaste);116 DataTransfer(const Document&, StoreMode, std::unique_ptr<Pasteboard>, Type = Type::CopyAndPaste); 116 117 117 118 #if ENABLE(DRAG_SUPPORT) … … 130 131 Vector<Ref<File>> filesFromPasteboardAndItemList() const; 131 132 133 PAL::SessionID m_sessionID; 132 134 String m_originIdentifier; 133 135 StoreMode m_storeMode; -
trunk/Source/WebCore/dom/Document.cpp
r248467 r248503 5729 5729 #endif 5730 5730 5731 String Document::originIdentifierForPasteboard() 5731 String Document::originIdentifierForPasteboard() const 5732 5732 { 5733 5733 auto origin = securityOrigin().toString(); -
trunk/Source/WebCore/dom/Document.h
r247530 r248503 1034 1034 uint64_t domTreeVersion() const { return m_domTreeVersion; } 1035 1035 1036 WEBCORE_EXPORT String originIdentifierForPasteboard() ;1036 WEBCORE_EXPORT String originIdentifierForPasteboard() const; 1037 1037 1038 1038 // XPathEvaluator methods … … 1689 1689 static uint64_t s_globalTreeVersion; 1690 1690 1691 String m_uniqueIdentifier;1691 mutable String m_uniqueIdentifier; 1692 1692 1693 1693 HashSet<NodeIterator*> m_nodeIterators; -
trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp
r239535 r248503 83 83 { 84 84 if (!isEditingTextAreaOrTextInput()) 85 return DataTransfer::createForInputEvent( m_text, serializeFragment(*m_textFragment, SerializedNodes::SubtreeIncludingNode));85 return DataTransfer::createForInputEvent(document(), m_text, serializeFragment(*m_textFragment, SerializedNodes::SubtreeIncludingNode)); 86 86 87 87 return CompositeEditCommand::inputEventDataTransfer(); -
trunk/Source/WebCore/editing/ReplaceSelectionCommand.cpp
r246868 r248503 1327 1327 return CompositeEditCommand::inputEventDataTransfer(); 1328 1328 1329 return DataTransfer::createForInputEvent( m_documentFragmentPlainText, m_documentFragmentHTMLMarkup);1329 return DataTransfer::createForInputEvent(document(), m_documentFragmentPlainText, m_documentFragmentHTMLMarkup); 1330 1330 } 1331 1331 -
trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp
r239535 r248503 131 131 { 132 132 if (!isEditingTextAreaOrTextInput()) 133 return DataTransfer::createForInputEvent( m_correction, serializeFragment(*m_correctionFragment, SerializedNodes::SubtreeIncludingNode));133 return DataTransfer::createForInputEvent(document(), m_correction, serializeFragment(*m_correctionFragment, SerializedNodes::SubtreeIncludingNode)); 134 134 135 135 return CompositeEditCommand::inputEventDataTransfer(); -
trunk/Source/WebCore/editing/TypingCommand.cpp
r245823 r248503 426 426 StringBuilder htmlText; 427 427 MarkupAccumulator::appendCharactersReplacingEntities(htmlText, m_currentTextToInsert, 0, m_currentTextToInsert.length(), EntityMaskInHTMLPCDATA); 428 return DataTransfer::createForInputEvent( m_currentTextToInsert, htmlText.toString());428 return DataTransfer::createForInputEvent(document(), m_currentTextToInsert, htmlText.toString()); 429 429 } 430 430 -
trunk/Source/WebCore/editing/WebCorePasteboardFileReader.cpp
r222839 r248503 36 36 void WebCorePasteboardFileReader::readFilename(const String& filename) 37 37 { 38 files.append(File::create( filename));38 files.append(File::create(sessionID, filename)); 39 39 } 40 40 41 41 void WebCorePasteboardFileReader::readBuffer(const String& filename, const String& type, Ref<SharedBuffer>&& buffer) 42 42 { 43 files.append(File::create(Blob::create( buffer.get(), type), filename));43 files.append(File::create(Blob::create(sessionID, buffer.get(), type), filename)); 44 44 } 45 45 -
trunk/Source/WebCore/editing/WebCorePasteboardFileReader.h
r222699 r248503 33 33 34 34 struct WebCorePasteboardFileReader final : PasteboardFileReader { 35 explicit WebCorePasteboardFileReader(PAL::SessionID sessionID) 36 : sessionID(sessionID) 37 { 38 } 39 35 40 ~WebCorePasteboardFileReader(); 36 41 … … 38 43 void readBuffer(const String& filename, const String& type, Ref<SharedBuffer>&&) final; 39 44 45 PAL::SessionID sessionID; 40 46 Vector<Ref<File>> files; 41 47 }; -
trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
r246892 r248503 260 260 if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) { 261 261 auto image = HTMLImageElement::create(document); 262 image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, Blob::create( buffer.get(), contentType)));262 image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, Blob::create(document.sessionID(), buffer.get(), contentType))); 263 263 image->setAttachmentElement(WTFMove(attachment)); 264 264 if (preferredSize.width) … … 272 272 } 273 273 } else { 274 attachment->setFile(File::create(Blob::create( buffer.get(), contentType), defaultImageAttachmentName), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);274 attachment->setFile(File::create(Blob::create(document.sessionID(), buffer.get(), contentType), defaultImageAttachmentName), HTMLAttachmentElement::UpdateDisplayAttributes::Yes); 275 275 fragment->appendChild(WTFMove(attachment)); 276 276 } … … 366 366 if (is<HTMLImageElement>(originalElement.get()) && contentTypeIsSuitableForInlineImageRepresentation(info.contentType)) { 367 367 auto& image = downcast<HTMLImageElement>(originalElement.get()); 368 image.setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(*frame.document(), Blob::create( info.data, info.contentType)));368 image.setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(*frame.document(), Blob::create(fragment.document().sessionID(), info.data, info.contentType))); 369 369 image.setAttachmentElement(attachment.copyRef()); 370 370 } else { … … 374 374 frame.editor().registerAttachmentIdentifier(attachment->ensureUniqueIdentifier(), WTFMove(info.contentType), WTFMove(info.fileName), WTFMove(info.data)); 375 375 } else { 376 attachment->setFile(File::create(Blob::create( WTFMove(info.data), WTFMove(info.contentType)), WTFMove(info.fileName)), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);376 attachment->setFile(File::create(Blob::create(fragment.document().sessionID(), WTFMove(info.data), WTFMove(info.contentType)), WTFMove(info.fileName)), HTMLAttachmentElement::UpdateDisplayAttributes::Yes); 377 377 parent->replaceChild(WTFMove(attachment), WTFMove(originalElement)); 378 378 } … … 416 416 HashMap<AtomString, AtomString> blobURLMap; 417 417 for (const Ref<ArchiveResource>& subresource : fragmentAndResources.resources) { 418 auto blob = Blob::create( subresource->data(), subresource->mimeType());418 auto blob = Blob::create(document.sessionID(), subresource->data(), subresource->mimeType()); 419 419 String blobURL = DOMURL::createObjectURL(document, blob); 420 420 blobURLMap.set(subresource->url().string(), blobURL); … … 465 465 if (!shouldReplaceSubresourceURL(subresourceURL)) 466 466 continue; 467 auto blob = Blob::create( subresource->data(), subresource->mimeType());467 auto blob = Blob::create(destinationDocument.sessionID(), subresource->data(), subresource->mimeType()); 468 468 String blobURL = DOMURL::createObjectURL(destinationDocument, blob); 469 469 blobURLMap.set(subresourceURL.string(), blobURL); … … 492 492 blobBuffer.reserveCapacity(utf8.length()); 493 493 blobBuffer.append(reinterpret_cast<const uint8_t*>(utf8.data()), utf8.length()); 494 auto blob = Blob::create( WTFMove(blobBuffer), type);494 auto blob = Blob::create(destinationDocument.sessionID(), WTFMove(blobBuffer), type); 495 495 496 496 String subframeBlobURL = DOMURL::createObjectURL(destinationDocument, blob); … … 689 689 addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type, preferredPresentationSize)); 690 690 else 691 addFragment(createFragmentForImageAndURL(document, DOMURL::createObjectURL(document, Blob::create( buffer.get(), type)), preferredPresentationSize));691 addFragment(createFragmentForImageAndURL(document, DOMURL::createObjectURL(document, Blob::create(document.sessionID(), buffer.get(), type)), preferredPresentationSize)); 692 692 693 693 return fragment; … … 710 710 auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document); 711 711 if (!supportsClientSideAttachmentData(frame)) { 712 attachment->setFile(File::create( path), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);712 attachment->setFile(File::create(document->sessionID(), path), HTMLAttachmentElement::UpdateDisplayAttributes::Yes); 713 713 return attachment; 714 714 } … … 737 737 if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) { 738 738 auto image = HTMLImageElement::create(document); 739 image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create( path)));739 image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(document->sessionID(), path))); 740 740 image->setAttachmentElement(WTFMove(attachment)); 741 741 if (preferredSize.width) … … 766 766 767 767 if (!supportsClientSideAttachmentData(frame)) { 768 attachment->setFile(File::create(Blob::create( buffer, WTFMove(attachmentType)), fileName));768 attachment->setFile(File::create(Blob::create(document->sessionID(), buffer, WTFMove(attachmentType)), fileName)); 769 769 return attachment; 770 770 } … … 774 774 if (contentTypeIsSuitableForInlineImageRepresentation(attachmentType)) { 775 775 auto image = HTMLImageElement::create(document); 776 image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(Blob::create( buffer, WTFMove(attachmentType)), WTFMove(fileName))));776 image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(Blob::create(document->sessionID(), buffer, WTFMove(attachmentType)), WTFMove(fileName)))); 777 777 image->setAttachmentElement(WTFMove(attachment)); 778 778 if (preferredSize.width) -
trunk/Source/WebCore/editing/gtk/EditorGtk.cpp
r246490 r248503 67 67 }, &buffer); 68 68 if (status == CAIRO_STATUS_SUCCESS) { 69 auto blob = Blob::create( WTFMove(buffer), "image/png");69 auto blob = Blob::create(frame.document()->sessionID(), WTFMove(buffer), "image/png"); 70 70 if (!frame.document()) 71 71 return nullptr; -
trunk/Source/WebCore/editing/markup.cpp
r247222 r248503 984 984 auto blobURL = attachment->blobURL(); 985 985 if (!attachmentPath.isEmpty()) 986 attachment->setFile(File::create( attachmentPath));986 attachment->setFile(File::create(fragment.document().sessionID(), attachmentPath)); 987 987 else if (!blobURL.isEmpty()) 988 attachment->setFile(File::deserialize( { }, blobURL, attachment->attachmentType(), attachment->attachmentTitle()));988 attachment->setFile(File::deserialize(fragment.document().sessionID(), { }, blobURL, attachment->attachmentType(), attachment->attachmentTitle())); 989 989 990 990 // Remove temporary attributes that were previously added in StyledMarkupAccumulator::appendCustomAttributes. -
trunk/Source/WebCore/fileapi/Blob.cpp
r248473 r248503 73 73 } 74 74 75 Blob::Blob(UninitializedContructor) 76 { 77 } 78 79 Blob::Blob() 80 : m_size(0) 75 Blob::Blob(UninitializedContructor, PAL::SessionID sessionID) 76 : m_sessionID(sessionID) 77 { 78 } 79 80 Blob::Blob(PAL::SessionID sessionID) 81 : m_sessionID(sessionID) 82 , m_size(0) 81 83 { 82 84 m_internalURL = BlobURL::createInternalURL(); … … 84 86 } 85 87 86 Blob::Blob(Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& propertyBag) 87 : m_internalURL(BlobURL::createInternalURL()) 88 Blob::Blob(PAL::SessionID sessionID, Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& propertyBag) 89 : m_sessionID(sessionID) 90 , m_internalURL(BlobURL::createInternalURL()) 88 91 , m_type(normalizedContentType(propertyBag.type)) 89 92 , m_size(-1) … … 101 104 } 102 105 103 Blob::Blob(const SharedBuffer& buffer, const String& contentType) 104 : m_type(contentType) 106 Blob::Blob(PAL::SessionID sessionID, const SharedBuffer& buffer, const String& contentType) 107 : m_sessionID(sessionID) 108 , m_type(contentType) 105 109 , m_size(buffer.size()) 106 110 { … … 114 118 } 115 119 116 Blob::Blob(Vector<uint8_t>&& data, const String& contentType) 117 : m_type(contentType) 120 Blob::Blob(PAL::SessionID sessionID, Vector<uint8_t>&& data, const String& contentType) 121 : m_sessionID(sessionID) 122 , m_type(contentType) 118 123 , m_size(data.size()) 119 124 { … … 125 130 126 131 Blob::Blob(ReferencingExistingBlobConstructor, const Blob& blob) 127 : m_internalURL(BlobURL::createInternalURL()) 132 : m_sessionID(blob.m_sessionID) 133 , m_internalURL(BlobURL::createInternalURL()) 128 134 , m_type(blob.type()) 129 135 , m_size(blob.size()) … … 132 138 } 133 139 134 Blob::Blob(DeserializationContructor, const URL& srcURL, const String& type, long long size, const String& fileBackedPath) 135 : m_type(normalizedContentType(type)) 140 Blob::Blob(DeserializationContructor, PAL::SessionID sessionID, const URL& srcURL, const String& type, long long size, const String& fileBackedPath) 141 : m_sessionID(sessionID) 142 , m_type(normalizedContentType(type)) 136 143 , m_size(size) 137 144 { … … 143 150 } 144 151 145 Blob::Blob(const URL& srcURL, long long start, long long end, const String& type) 146 : m_type(normalizedContentType(type)) 152 Blob::Blob(PAL::SessionID sessionID, const URL& srcURL, long long start, long long end, const String& type) 153 : m_sessionID(sessionID) 154 , m_type(normalizedContentType(type)) 147 155 , m_size(-1) // size is not necessarily equal to end - start. 148 156 { -
trunk/Source/WebCore/fileapi/Blob.h
r243931 r248503 33 33 34 34 #include "BlobPropertyBag.h" 35 #include "ScriptExecutionContext.h" 35 36 #include "ScriptWrappable.h" 36 37 #include <wtf/IsoMalloc.h> 37 38 #include <wtf/URL.h> 38 39 #include "URLRegistry.h" 40 #include <pal/SessionID.h> 39 41 #include <wtf/Variant.h> 40 42 … … 55 57 WTF_MAKE_ISO_ALLOCATED_EXPORT(Blob, WEBCORE_EXPORT); 56 58 public: 57 static Ref<Blob> create( )59 static Ref<Blob> create(PAL::SessionID sessionID) 58 60 { 59 return adoptRef(*new Blob );61 return adoptRef(*new Blob(sessionID)); 60 62 } 61 63 62 static Ref<Blob> create( Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& propertyBag)64 static Ref<Blob> create(ScriptExecutionContext& context, Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& propertyBag) 63 65 { 64 return adoptRef(*new Blob( WTFMove(blobPartVariants), propertyBag));66 return adoptRef(*new Blob(context.sessionID(), WTFMove(blobPartVariants), propertyBag)); 65 67 } 66 68 67 static Ref<Blob> create( const SharedBuffer& buffer, const String& contentType)69 static Ref<Blob> create(PAL::SessionID sessionID, const SharedBuffer& buffer, const String& contentType) 68 70 { 69 return adoptRef(*new Blob( buffer, contentType));71 return adoptRef(*new Blob(sessionID, buffer, contentType)); 70 72 } 71 73 72 static Ref<Blob> create( Vector<uint8_t>&& data, const String& contentType)74 static Ref<Blob> create(PAL::SessionID sessionID, Vector<uint8_t>&& data, const String& contentType) 73 75 { 74 return adoptRef(*new Blob( WTFMove(data), contentType));76 return adoptRef(*new Blob(sessionID, WTFMove(data), contentType)); 75 77 } 76 78 77 static Ref<Blob> deserialize( const URL& srcURL, const String& type, long long size, const String& fileBackedPath)79 static Ref<Blob> deserialize(PAL::SessionID sessionID, const URL& srcURL, const String& type, long long size, const String& fileBackedPath) 78 80 { 79 81 ASSERT(Blob::isNormalizedContentType(type)); 80 return adoptRef(*new Blob(deserializationContructor, s rcURL, type, size, fileBackedPath));82 return adoptRef(*new Blob(deserializationContructor, sessionID, srcURL, type, size, fileBackedPath)); 81 83 } 82 84 … … 103 105 Ref<Blob> slice(long long start = 0, long long end = std::numeric_limits<long long>::max(), const String& contentType = String()) const 104 106 { 105 return adoptRef(*new Blob(m_ internalURL, start, end, contentType));107 return adoptRef(*new Blob(m_sessionID, m_internalURL, start, end, contentType)); 106 108 } 107 109 108 110 protected: 109 WEBCORE_EXPORT Blob();110 Blob( Vector<BlobPartVariant>&&, const BlobPropertyBag&);111 Blob( const SharedBuffer&, const String& contentType);112 Blob( Vector<uint8_t>&&, const String& contentType);111 WEBCORE_EXPORT explicit Blob(PAL::SessionID); 112 Blob(PAL::SessionID, Vector<BlobPartVariant>&&, const BlobPropertyBag&); 113 Blob(PAL::SessionID, const SharedBuffer&, const String& contentType); 114 Blob(PAL::SessionID, Vector<uint8_t>&&, const String& contentType); 113 115 114 116 enum ReferencingExistingBlobConstructor { referencingExistingBlobConstructor }; … … 116 118 117 119 enum UninitializedContructor { uninitializedContructor }; 118 Blob(UninitializedContructor );120 Blob(UninitializedContructor, PAL::SessionID); 119 121 120 122 enum DeserializationContructor { deserializationContructor }; 121 Blob(DeserializationContructor, const URL& srcURL, const String& type, long long size, const String& fileBackedPath);123 Blob(DeserializationContructor, PAL::SessionID, const URL& srcURL, const String& type, long long size, const String& fileBackedPath); 122 124 123 125 // For slicing. 124 Blob( const URL& srcURL, long long start, long long end, const String& contentType);126 Blob(PAL::SessionID, const URL& srcURL, long long start, long long end, const String& contentType); 125 127 128 PAL::SessionID m_sessionID; 126 129 // This is an internal URL referring to the blob data associated with this object. It serves 127 130 // as an identifier for this blob. The internal URL is never used to source the blob's content -
trunk/Source/WebCore/fileapi/Blob.idl
r218495 r248503 36 36 CustomToJSObject, 37 37 Constructor(optional sequence<BlobPart> blobParts, optional BlobPropertyBag options), 38 ConstructorCallWith=ScriptExecutionContext, 38 39 ] interface Blob { 39 40 readonly attribute unsigned long long size; -
trunk/Source/WebCore/fileapi/File.cpp
r243887 r248503 40 40 WTF_MAKE_ISO_ALLOCATED_IMPL(File); 41 41 42 Ref<File> File::createWithRelativePath( const String& path, const String& relativePath)42 Ref<File> File::createWithRelativePath(PAL::SessionID sessionID, const String& path, const String& relativePath) 43 43 { 44 auto file = File::create( path);44 auto file = File::create(sessionID, path); 45 45 file->setRelativePath(relativePath); 46 46 return file; 47 47 } 48 48 49 File::File( const String& path)50 : Blob(uninitializedContructor )49 File::File(PAL::SessionID sessionID, const String& path) 50 : Blob(uninitializedContructor, sessionID) 51 51 , m_path(path) 52 52 { … … 57 57 } 58 58 59 File::File( const String& path, const String& nameOverride)60 : Blob(uninitializedContructor )59 File::File(PAL::SessionID sessionID, const String& path, const String& nameOverride) 60 : Blob(uninitializedContructor, sessionID) 61 61 , m_path(path) 62 62 { … … 67 67 } 68 68 69 File::File(DeserializationContructor, const String& path, const URL& url, const String& type, const String& name, const Optional<int64_t>& lastModified)70 : Blob(deserializationContructor, url, type, -1, path)69 File::File(DeserializationContructor, PAL::SessionID sessionID, const String& path, const URL& url, const String& type, const String& name, const Optional<int64_t>& lastModified) 70 : Blob(deserializationContructor, sessionID, url, type, -1, path) 71 71 , m_path(path) 72 72 , m_name(name) … … 82 82 } 83 83 84 File::File( Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag& propertyBag)85 : Blob( WTFMove(blobPartVariants), convertPropertyBag(propertyBag))84 File::File(ScriptExecutionContext& context, Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag& propertyBag) 85 : Blob(context.sessionID(), WTFMove(blobPartVariants), convertPropertyBag(propertyBag)) 86 86 , m_name(filename) 87 87 , m_lastModifiedDateOverride(propertyBag.lastModified.valueOr(WallTime::now().secondsSinceEpoch().milliseconds())) -
trunk/Source/WebCore/fileapi/File.h
r243931 r248503 42 42 }; 43 43 44 static Ref<File> create( const String& path)44 static Ref<File> create(PAL::SessionID sessionID, const String& path) 45 45 { 46 return adoptRef(*new File( path));46 return adoptRef(*new File(sessionID, path)); 47 47 } 48 48 49 49 // Create a File using the 'new File' constructor. 50 static Ref<File> create( Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag& propertyBag)50 static Ref<File> create(ScriptExecutionContext& context, Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag& propertyBag) 51 51 { 52 return adoptRef(*new File( WTFMove(blobPartVariants), filename, propertyBag));52 return adoptRef(*new File(context, WTFMove(blobPartVariants), filename, propertyBag)); 53 53 } 54 54 55 static Ref<File> deserialize( const String& path, const URL& srcURL, const String& type, const String& name, const Optional<int64_t>& lastModified = WTF::nullopt)55 static Ref<File> deserialize(PAL::SessionID sessionID, const String& path, const URL& srcURL, const String& type, const String& name, const Optional<int64_t>& lastModified = WTF::nullopt) 56 56 { 57 return adoptRef(*new File(deserializationContructor, path, srcURL, type, name, lastModified));57 return adoptRef(*new File(deserializationContructor, sessionID, path, srcURL, type, name, lastModified)); 58 58 } 59 59 60 60 // Create a file with a name exposed to the author (via File.name and associated DOM properties) that differs from the one provided in the path. 61 static Ref<File> createWithName( const String& path, const String& nameOverride)61 static Ref<File> createWithName(PAL::SessionID sessionID, const String& path, const String& nameOverride) 62 62 { 63 63 if (nameOverride.isEmpty()) 64 return adoptRef(*new File( path));65 return adoptRef(*new File( path, nameOverride));64 return adoptRef(*new File(sessionID, path)); 65 return adoptRef(*new File(sessionID, path, nameOverride)); 66 66 } 67 67 … … 76 76 } 77 77 78 static Ref<File> createWithRelativePath( const String& path, const String& relativePath);78 static Ref<File> createWithRelativePath(PAL::SessionID, const String& path, const String& relativePath); 79 79 80 80 bool isFile() const override { return true; } … … 96 96 97 97 private: 98 WEBCORE_EXPORT explicit File( const String& path);99 File( const String& path, const String& nameOverride);100 File( Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag&);98 WEBCORE_EXPORT explicit File(PAL::SessionID, const String& path); 99 File(PAL::SessionID, const String& path, const String& nameOverride); 100 File(ScriptExecutionContext&, Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag&); 101 101 File(const Blob&, const String& name); 102 102 File(const File&, const String& name); 103 103 104 File(DeserializationContructor, const String& path, const URL& srcURL, const String& type, const String& name, const Optional<int64_t>& lastModified);104 File(DeserializationContructor, PAL::SessionID, const String& path, const URL& srcURL, const String& type, const String& name, const Optional<int64_t>& lastModified); 105 105 106 106 static void computeNameAndContentType(const String& path, const String& nameOverride, String& effectiveName, String& effectiveContentType); -
trunk/Source/WebCore/fileapi/File.idl
r221177 r248503 29 29 [ 30 30 Constructor(sequence<BlobPart> fileBits, USVString fileName, optional FilePropertyBag options), 31 ConstructorCallWith=ScriptExecutionContext, 31 32 ExportMacro=WEBCORE_EXPORT, 32 33 Exposed=(Window), -
trunk/Source/WebCore/html/FileInputType.cpp
r246490 r248503 176 176 // Null would be more logical, but Netscape posts an empty file. Argh. 177 177 if (fileList->isEmpty()) { 178 formData.append(name, File::create(e mptyString()));178 formData.append(name, File::create(element()->document().sessionID(), emptyString())); 179 179 return true; 180 180 } … … 415 415 auto shouldResolveDirectories = allowsDirectories() ? FileListCreator::ShouldResolveDirectories::Yes : FileListCreator::ShouldResolveDirectories::No; 416 416 auto shouldRequestIcon = icon ? RequestIcon::Yes : RequestIcon::No; 417 m_fileListCreator = FileListCreator::create( paths, shouldResolveDirectories, [this, shouldRequestIcon](Ref<FileList>&& fileList) {417 m_fileListCreator = FileListCreator::create(element()->document().sessionID(), paths, shouldResolveDirectories, [this, shouldRequestIcon](Ref<FileList>&& fileList) { 418 418 setFiles(WTFMove(fileList), shouldRequestIcon); 419 419 m_fileListCreator = nullptr; -
trunk/Source/WebCore/html/FileListCreator.cpp
r240437 r248503 40 40 } 41 41 42 static void appendDirectoryFiles( const String& directory, const String& relativePath, Vector<Ref<File>>& fileObjects)42 static void appendDirectoryFiles(PAL::SessionID sessionID, const String& directory, const String& relativePath, Vector<Ref<File>>& fileObjects) 43 43 { 44 44 for (auto& childPath : FileSystem::listDirectory(directory, "*")) { … … 52 52 String childRelativePath = relativePath + "/" + FileSystem::pathGetFileName(childPath); 53 53 if (metadata.value().type == FileMetadata::Type::Directory) 54 appendDirectoryFiles( childPath, childRelativePath, fileObjects);54 appendDirectoryFiles(sessionID, childPath, childRelativePath, fileObjects); 55 55 else if (metadata.value().type == FileMetadata::Type::File) 56 fileObjects.append(File::createWithRelativePath( childPath, childRelativePath));56 fileObjects.append(File::createWithRelativePath(sessionID, childPath, childRelativePath)); 57 57 } 58 58 } 59 59 60 FileListCreator::FileListCreator( const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories shouldResolveDirectories, CompletionHandler&& completionHandler)60 FileListCreator::FileListCreator(PAL::SessionID sessionID, const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories shouldResolveDirectories, CompletionHandler&& completionHandler) 61 61 { 62 62 if (shouldResolveDirectories == ShouldResolveDirectories::No) 63 completionHandler(createFileList<ShouldResolveDirectories::No>( paths));63 completionHandler(createFileList<ShouldResolveDirectories::No>(sessionID, paths)); 64 64 else { 65 65 // Resolve directories on a background thread to avoid blocking the main thread. 66 66 m_completionHander = WTFMove(completionHandler); 67 67 m_workQueue = WorkQueue::create("FileListCreator Work Queue"); 68 m_workQueue->dispatch([this, protectedThis = makeRef(*this), paths = crossThreadCopy(paths)]() mutable {69 auto fileList = createFileList<ShouldResolveDirectories::Yes>( paths);68 m_workQueue->dispatch([this, protectedThis = makeRef(*this), sessionID, paths = crossThreadCopy(paths)]() mutable { 69 auto fileList = createFileList<ShouldResolveDirectories::Yes>(sessionID, paths); 70 70 callOnMainThread([this, protectedThis = WTFMove(protectedThis), fileList = WTFMove(fileList)]() mutable { 71 71 if (auto completionHander = WTFMove(m_completionHander)) … … 77 77 78 78 template<FileListCreator::ShouldResolveDirectories shouldResolveDirectories> 79 Ref<FileList> FileListCreator::createFileList( const Vector<FileChooserFileInfo>& paths)79 Ref<FileList> FileListCreator::createFileList(PAL::SessionID sessionID, const Vector<FileChooserFileInfo>& paths) 80 80 { 81 81 Vector<Ref<File>> fileObjects; 82 82 for (auto& info : paths) { 83 83 if (shouldResolveDirectories == ShouldResolveDirectories::Yes && FileSystem::fileIsDirectory(info.path, FileSystem::ShouldFollowSymbolicLinks::No)) 84 appendDirectoryFiles( info.path, FileSystem::pathGetFileName(info.path), fileObjects);84 appendDirectoryFiles(sessionID, info.path, FileSystem::pathGetFileName(info.path), fileObjects); 85 85 else 86 fileObjects.append(File::createWithName( info.path, info.displayName));86 fileObjects.append(File::createWithName(sessionID, info.path, info.displayName)); 87 87 } 88 88 return FileList::create(WTFMove(fileObjects)); -
trunk/Source/WebCore/html/FileListCreator.h
r222113 r248503 26 26 #pragma once 27 27 28 #include <pal/SessionID.h> 28 29 #include <wtf/Forward.h> 29 30 #include <wtf/Function.h> … … 39 40 class FileListCreator : public ThreadSafeRefCounted<FileListCreator> { 40 41 public: 41 using CompletionHandler = WTF::Function<void(Ref<FileList>&&)>;42 using CompletionHandler = Function<void(Ref<FileList>&&)>; 42 43 43 44 enum class ShouldResolveDirectories { No, Yes }; 44 static Ref<FileListCreator> create( const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories shouldResolveDirectories, CompletionHandler&& completionHandler)45 static Ref<FileListCreator> create(PAL::SessionID sessionID, const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories shouldResolveDirectories, CompletionHandler&& completionHandler) 45 46 { 46 return adoptRef(*new FileListCreator( paths, shouldResolveDirectories, WTFMove(completionHandler)));47 return adoptRef(*new FileListCreator(sessionID, paths, shouldResolveDirectories, WTFMove(completionHandler))); 47 48 } 48 49 … … 52 53 53 54 private: 54 FileListCreator( const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories, CompletionHandler&&);55 FileListCreator(PAL::SessionID, const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories, CompletionHandler&&); 55 56 56 57 template<ShouldResolveDirectories shouldResolveDirectories> 57 static Ref<FileList> createFileList( const Vector<FileChooserFileInfo>&);58 static Ref<FileList> createFileList(PAL::SessionID, const Vector<FileChooserFileInfo>&); 58 59 59 60 RefPtr<WorkQueue> m_workQueue; -
trunk/Source/WebCore/html/HTMLAttachmentElement.cpp
r246490 r248503 247 247 return; 248 248 249 hostElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document(), Blob::create( WTFMove(data), mimeType)));249 hostElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document(), Blob::create(document().sessionID(), WTFMove(data), mimeType))); 250 250 } 251 251 -
trunk/Source/WebCore/html/HTMLCanvasElement.cpp
r246490 r248503 740 740 Vector<uint8_t> blobData = data(*imageData, encodingMIMEType, quality); 741 741 if (!blobData.isEmpty()) 742 blob = Blob::create( WTFMove(blobData), encodingMIMEType);742 blob = Blob::create(context.sessionID(), WTFMove(blobData), encodingMIMEType); 743 743 callback->scheduleCallback(context, WTFMove(blob)); 744 744 return { }; … … 751 751 Vector<uint8_t> blobData = buffer()->toData(encodingMIMEType, quality); 752 752 if (!blobData.isEmpty()) 753 blob = Blob::create( WTFMove(blobData), encodingMIMEType);753 blob = Blob::create(context.sessionID(), WTFMove(blobData), encodingMIMEType); 754 754 callback->scheduleCallback(context, WTFMove(blob)); 755 755 return { }; -
trunk/Source/WebCore/page/EventHandler.cpp
r247530 r248503 3773 3773 invalidateDataTransfer(); 3774 3774 3775 dragState().dataTransfer = DataTransfer::createForDrag( );3775 dragState().dataTransfer = DataTransfer::createForDrag(*m_frame.document()); 3776 3776 HasNonDefaultPasteboardData hasNonDefaultPasteboardData = HasNonDefaultPasteboardData::No; 3777 3777 -
trunk/Source/WebCore/testing/Internals.cpp
r248497 r248503 4233 4233 return nullptr; 4234 4234 4235 return File::create( url.fileSystemPath());4235 return File::create(document->sessionID(), url.fileSystemPath()); 4236 4236 } 4237 4237 -
trunk/Source/WebCore/testing/ServiceWorkerInternals.cpp
r245299 r248503 69 69 Ref<FetchResponse> ServiceWorkerInternals::createOpaqueWithBlobBodyResponse(ScriptExecutionContext& context) 70 70 { 71 auto blob = Blob::create( );71 auto blob = Blob::create(context.sessionID()); 72 72 auto formData = FormData::create(); 73 73 formData->appendBlob(blob->url()); … … 76 76 response.setType(ResourceResponse::Type::Cors); 77 77 response.setTainting(ResourceResponse::Tainting::Opaque); 78 auto fetchResponse = FetchResponse::create(context, FetchBody::fromFormData( formData), FetchHeaders::Guard::Response, WTFMove(response));78 auto fetchResponse = FetchResponse::create(context, FetchBody::fromFormData(context.sessionID(), formData), FetchHeaders::Guard::Response, WTFMove(response)); 79 79 fetchResponse->initializeOpaqueLoadIdentifierForTesting(); 80 80 return fetchResponse; -
trunk/Source/WebCore/workers/WorkerGlobalScope.h
r243887 r248503 127 127 unsigned long createUniqueIdentifier() { return m_uniqueIdentifier++; } 128 128 129 PAL::SessionID sessionID() const final { return m_sessionID; } 130 129 131 protected: 130 132 WorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, WorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID); … … 150 152 ScriptExecutionContext* scriptExecutionContext() const final { return const_cast<WorkerGlobalScope*>(this); } 151 153 URL completeURL(const String&) const final; 152 PAL::SessionID sessionID() const final { return m_sessionID; }153 154 String userAgent(const URL&) const final; 154 155 void disableEval(const String& errorMessage) final; -
trunk/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp
r244115 r248503 150 150 Optional<FetchBody> body; 151 151 if (formData && !formData->isEmpty()) { 152 body = FetchBody::fromFormData( *formData);152 body = FetchBody::fromFormData(globalScope.sessionID(), *formData); 153 153 if (!body) { 154 154 client->didNotHandle(); -
trunk/Source/WebCore/xml/XMLHttpRequest.cpp
r248139 r248503 213 213 m_binaryResponseBuilder = nullptr; 214 214 String normalizedContentType = Blob::normalizedContentType(responseMIMEType()); // responseMIMEType defaults to text/xml which may be incorrect. 215 return Blob::create( WTFMove(data), normalizedContentType);215 return Blob::create(scriptExecutionContext()->sessionID(), WTFMove(data), normalizedContentType); 216 216 } 217 217
Note: See TracChangeset
for help on using the changeset viewer.