| Differences between
and this patch
- a/Source/WebCore/ChangeLog +110 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2019-08-09  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 NOBODY (OOPS!).
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
2019-08-09  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
111
2019-08-09  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
2
112
3
        [GL][GStreamer] activate wrapped shared context
113
        [GL][GStreamer] activate wrapped shared context
- a/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp -1 / +1 lines
Lines 343-349 void DOMFileSystem::getFile(ScriptExecutionContext& context, FileSystemFileEntry a/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp_sec1
343
            if (validatedVirtualPath.hasException())
343
            if (validatedVirtualPath.hasException())
344
                completionCallback(validatedVirtualPath.releaseException());
344
                completionCallback(validatedVirtualPath.releaseException());
345
            else
345
            else
346
                completionCallback(File::create(fullPath));
346
                completionCallback(File::create(context->sessionID(), fullPath));
347
        });
347
        });
348
    });
348
    });
349
}
349
}
- a/Source/WebCore/Modules/fetch/FetchBody.cpp -2 / +2 lines
Lines 75-81 ExceptionOr<FetchBody> FetchBody::extract(Init&& value, String& contentType) a/Source/WebCore/Modules/fetch/FetchBody.cpp_sec1
75
    });
75
    });
76
}
76
}
77
77
78
Optional<FetchBody> FetchBody::fromFormData(FormData& formData)
78
Optional<FetchBody> FetchBody::fromFormData(PAL::SessionID sessionID, FormData& formData)
79
{
79
{
80
    ASSERT(!formData.isEmpty());
80
    ASSERT(!formData.isEmpty());
81
81
Lines 88-94 Optional<FetchBody> FetchBody::fromFormData(FormData& formData) a/Source/WebCore/Modules/fetch/FetchBody.cpp_sec2
88
    auto url = formData.asBlobURL();
88
    auto url = formData.asBlobURL();
89
    if (!url.isNull()) {
89
    if (!url.isNull()) {
90
        // FIXME: Properly set mime type and size of the blob.
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
        return FetchBody { WTFMove(blob) };
92
        return FetchBody { WTFMove(blob) };
93
    }
93
    }
94
94
- a/Source/WebCore/Modules/fetch/FetchBody.h -1 / +1 lines
Lines 59-65 public: a/Source/WebCore/Modules/fetch/FetchBody.h_sec1
59
    static ExceptionOr<FetchBody> extract(Init&&, String&);
59
    static ExceptionOr<FetchBody> extract(Init&&, String&);
60
    FetchBody() = default;
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
    void loadingFailed(const Exception&);
64
    void loadingFailed(const Exception&);
65
    void loadingSucceeded();
65
    void loadingSucceeded();
- a/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp -7 / +7 lines
Lines 35-45 a/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp_sec1
35
35
36
namespace WebCore {
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
    Vector<uint8_t> value(length);
40
    Vector<uint8_t> value(length);
41
    memcpy(value.data(), data, length);
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
45
static inline bool shouldPrependBOM(const unsigned char* data, unsigned length)
45
static inline bool shouldPrependBOM(const unsigned char* data, unsigned length)
Lines 64-70 static void resolveWithTypeAndData(Ref<DeferredPromise>&& promise, FetchBodyCons a/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp_sec2
64
        fulfillPromiseWithArrayBuffer(WTFMove(promise), data, length);
64
        fulfillPromiseWithArrayBuffer(WTFMove(promise), data, length);
65
        return;
65
        return;
66
    case FetchBodyConsumer::Type::Blob:
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
        return;
68
        return;
69
    case FetchBodyConsumer::Type::JSON:
69
    case FetchBodyConsumer::Type::JSON:
70
        fulfillPromiseWithJSON(WTFMove(promise), textFromUTF8(data, length));
70
        fulfillPromiseWithJSON(WTFMove(promise), textFromUTF8(data, length));
Lines 130-136 void FetchBodyConsumer::resolve(Ref<DeferredPromise>&& promise, ReadableStream* a/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp_sec3
130
        fulfillPromiseWithArrayBuffer(WTFMove(promise), takeAsArrayBuffer().get());
130
        fulfillPromiseWithArrayBuffer(WTFMove(promise), takeAsArrayBuffer().get());
131
        return;
131
        return;
132
    case Type::Blob:
132
    case Type::Blob:
133
        promise->resolveWithNewlyCreated<IDLInterface<Blob>>(takeAsBlob().get());
133
        promise->resolveWithNewlyCreated<IDLInterface<Blob>>(takeAsBlob(promise->sessionID()).get());
134
        return;
134
        return;
135
    case Type::JSON:
135
    case Type::JSON:
136
        fulfillPromiseWithJSON(WTFMove(promise), takeAsText());
136
        fulfillPromiseWithJSON(WTFMove(promise), takeAsText());
Lines 177-189 RefPtr<JSC::ArrayBuffer> FetchBodyConsumer::takeAsArrayBuffer() a/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp_sec4
177
    return arrayBuffer;
177
    return arrayBuffer;
178
}
178
}
179
179
180
Ref<Blob> FetchBodyConsumer::takeAsBlob()
180
Ref<Blob> FetchBodyConsumer::takeAsBlob(PAL::SessionID sessionID)
181
{
181
{
182
    if (!m_buffer)
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
    // FIXME: We should try to move m_buffer to Blob without doing extra copy.
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
189
String FetchBodyConsumer::takeAsText()
189
String FetchBodyConsumer::takeAsText()
- a/Source/WebCore/Modules/fetch/FetchBodyConsumer.h -1 / +2 lines
Lines 54-60 public: a/Source/WebCore/Modules/fetch/FetchBodyConsumer.h_sec1
54
54
55
    RefPtr<SharedBuffer> takeData();
55
    RefPtr<SharedBuffer> takeData();
56
    RefPtr<JSC::ArrayBuffer> takeAsArrayBuffer();
56
    RefPtr<JSC::ArrayBuffer> takeAsArrayBuffer();
57
    Ref<Blob> takeAsBlob();
58
    String takeAsText();
57
    String takeAsText();
59
58
60
    void setContentType(const String& contentType) { m_contentType = contentType; }
59
    void setContentType(const String& contentType) { m_contentType = contentType; }
Lines 75-80 public: a/Source/WebCore/Modules/fetch/FetchBodyConsumer.h_sec2
75
    void setAsLoading() { m_isLoading = true; }
74
    void setAsLoading() { m_isLoading = true; }
76
75
77
private:
76
private:
77
    Ref<Blob> takeAsBlob(PAL::SessionID);
78
78
    Type m_type;
79
    Type m_type;
79
    String m_contentType;
80
    String m_contentType;
80
    RefPtr<SharedBuffer> m_buffer;
81
    RefPtr<SharedBuffer> m_buffer;
- a/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp -1 / +1 lines
Lines 124-130 void FetchBodyOwner::blob(Ref<DeferredPromise>&& promise) a/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp_sec1
124
    }
124
    }
125
125
126
    if (isBodyNullOrOpaque()) {
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
        return;
128
        return;
129
    }
129
    }
130
    if (isDisturbedOrLocked()) {
130
    if (isDisturbedOrLocked()) {
- a/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp -2 / +2 lines
Lines 157-164 Ref<Blob> MediaRecorder::createRecordingDataBlob() a/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp_sec1
157
{
157
{
158
    auto data = m_private->fetchData();
158
    auto data = m_private->fetchData();
159
    if (!data)
159
    if (!data)
160
        return Blob::create();
160
        return Blob::create(scriptExecutionContext()->sessionID());
161
    return Blob::create(*data, m_private->mimeType());
161
    return Blob::create(scriptExecutionContext()->sessionID(), *data, m_private->mimeType());
162
}
162
}
163
163
164
void MediaRecorder::didAddOrRemoveTrack()
164
void MediaRecorder::didAddOrRemoveTrack()
- a/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp -1 / +1 lines
Lines 202-208 void RTCDataChannel::didReceiveRawData(const char* data, size_t dataLength) a/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp_sec1
202
202
203
    switch (m_binaryType) {
203
    switch (m_binaryType) {
204
    case BinaryType::Blob:
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
        return;
206
        return;
207
    case BinaryType::ArrayBuffer:
207
    case BinaryType::ArrayBuffer:
208
        scheduleDispatchEvent(MessageEvent::create(ArrayBuffer::create(data, dataLength)));
208
        scheduleDispatchEvent(MessageEvent::create(ArrayBuffer::create(data, dataLength)));
- a/Source/WebCore/Modules/websockets/WebSocket.cpp -1 / +1 lines
Lines 584-590 void WebSocket::didReceiveBinaryData(Vector<uint8_t>&& binaryData) a/Source/WebCore/Modules/websockets/WebSocket.cpp_sec1
584
    switch (m_binaryType) {
584
    switch (m_binaryType) {
585
    case BinaryType::Blob:
585
    case BinaryType::Blob:
586
        // FIXME: We just received the data from NetworkProcess, and are sending it back. This is inefficient.
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
        break;
588
        break;
589
    case BinaryType::ArrayBuffer:
589
    case BinaryType::ArrayBuffer:
590
        dispatchEvent(MessageEvent::create(ArrayBuffer::create(binaryData.data(), binaryData.size()), SecurityOrigin::create(m_url)->toString()));
590
        dispatchEvent(MessageEvent::create(ArrayBuffer::create(binaryData.data(), binaryData.size()), SecurityOrigin::create(m_url)->toString()));
- a/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp -1 / +1 lines
Lines 465-471 ThreadableWebSocketChannel::SendResult WorkerThreadableWebSocketChannel::Bridge: a/Source/WebCore/Modules/websockets/WorkerThreadableWebSocketChannel.cpp_sec1
465
        ASSERT_UNUSED(context, context.isDocument());
465
        ASSERT_UNUSED(context, context.isDocument());
466
        ASSERT(peer);
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
471
    Ref<Bridge> protectedThis(*this);
471
    Ref<Bridge> protectedThis(*this);
- a/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h +4 lines
Lines 28-35 a/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h_sec1
28
#include "ExceptionOr.h"
28
#include "ExceptionOr.h"
29
#include "JSDOMConvert.h"
29
#include "JSDOMConvert.h"
30
#include "JSDOMGuardedObject.h"
30
#include "JSDOMGuardedObject.h"
31
#include "ScriptExecutionContext.h"
31
#include <JavaScriptCore/CatchScope.h>
32
#include <JavaScriptCore/CatchScope.h>
32
#include <JavaScriptCore/JSPromiseDeferred.h>
33
#include <JavaScriptCore/JSPromiseDeferred.h>
34
#include <pal/SessionID.h>
33
35
34
namespace WebCore {
36
namespace WebCore {
35
37
Lines 136-141 public: a/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h_sec2
136
138
137
    void whenSettled(std::function<void()>&&);
139
    void whenSettled(std::function<void()>&&);
138
140
141
    PAL::SessionID sessionID() const { return globalObject()->scriptExecutionContext()->sessionID(); }
142
139
private:
143
private:
140
    DeferredPromise(JSDOMGlobalObject& globalObject, JSC::JSPromiseDeferred& deferred, Mode mode)
144
    DeferredPromise(JSDOMGlobalObject& globalObject, JSC::JSPromiseDeferred& deferred, Mode mode)
141
        : DOMGuarded<JSC::JSPromiseDeferred>(globalObject, deferred)
145
        : DOMGuarded<JSC::JSPromiseDeferred>(globalObject, deferred)
- a/Source/WebCore/bindings/js/SerializedScriptValue.cpp -2 / +2 lines
Lines 2095-2101 private: a/Source/WebCore/bindings/js/SerializedScriptValue.cpp_sec1
2095
            filePath = path->string();
2095
            filePath = path->string();
2096
2096
2097
        if (m_isDOMGlobalObject)
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
        return true;
2099
        return true;
2100
    }
2100
    }
2101
2101
Lines 2861-2867 private: a/Source/WebCore/bindings/js/SerializedScriptValue.cpp_sec2
2861
                return JSValue();
2861
                return JSValue();
2862
            if (!m_isDOMGlobalObject)
2862
            if (!m_isDOMGlobalObject)
2863
                return jsNull();
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
        case StringTag: {
2866
        case StringTag: {
2867
            CachedStringRef cachedString;
2867
            CachedStringRef cachedString;
- a/Source/WebCore/dom/DataTransfer.cpp -15 / +16 lines
Lines 68-75 private: a/Source/WebCore/dom/DataTransfer.cpp_sec1
68
68
69
#endif
69
#endif
70
70
71
DataTransfer::DataTransfer(StoreMode mode, std::unique_ptr<Pasteboard> pasteboard, Type type)
71
DataTransfer::DataTransfer(const Document& document, StoreMode mode, std::unique_ptr<Pasteboard> pasteboard, Type type)
72
    : m_storeMode(mode)
72
    : m_sessionID(document.sessionID())
73
    , m_storeMode(mode)
73
    , m_pasteboard(WTFMove(pasteboard))
74
    , m_pasteboard(WTFMove(pasteboard))
74
#if ENABLE(DRAG_SUPPORT)
75
#if ENABLE(DRAG_SUPPORT)
75
    , m_type(type)
76
    , m_type(type)
Lines 83-91 DataTransfer::DataTransfer(StoreMode mode, std::unique_ptr<Pasteboard> pasteboar a/Source/WebCore/dom/DataTransfer.cpp_sec2
83
#endif
84
#endif
84
}
85
}
85
86
86
Ref<DataTransfer> DataTransfer::createForCopyAndPaste(Document& document, StoreMode storeMode, std::unique_ptr<Pasteboard>&& pasteboard)
87
Ref<DataTransfer> DataTransfer::createForCopyAndPaste(const Document& document, StoreMode storeMode, std::unique_ptr<Pasteboard>&& pasteboard)
87
{
88
{
88
    auto dataTransfer = adoptRef(*new DataTransfer(storeMode, WTFMove(pasteboard)));
89
    auto dataTransfer = adoptRef(*new DataTransfer(document, storeMode, WTFMove(pasteboard)));
89
    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
90
    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
90
    return dataTransfer;
91
    return dataTransfer;
91
}
92
}
Lines 348-354 Vector<Ref<File>> DataTransfer::filesFromPasteboardAndItemList() const a/Source/WebCore/dom/DataTransfer.cpp_sec3
348
    bool addedFilesFromPasteboard = false;
349
    bool addedFilesFromPasteboard = false;
349
    Vector<Ref<File>> files;
350
    Vector<Ref<File>> files;
350
    if ((!forDrag() || forFileDrag()) && m_pasteboard->fileContentState() != Pasteboard::FileContentState::NoFileOrImageData) {
351
    if ((!forDrag() || forFileDrag()) && m_pasteboard->fileContentState() != Pasteboard::FileContentState::NoFileOrImageData) {
351
        WebCorePasteboardFileReader reader;
352
        WebCorePasteboardFileReader reader { m_sessionID };
352
        m_pasteboard->read(reader);
353
        m_pasteboard->read(reader);
353
        files = WTFMove(reader.files);
354
        files = WTFMove(reader.files);
354
        addedFilesFromPasteboard = !files.isEmpty();
355
        addedFilesFromPasteboard = !files.isEmpty();
Lines 413-424 bool DataTransfer::hasStringOfType(const String& type) a/Source/WebCore/dom/DataTransfer.cpp_sec4
413
    return !type.isNull() && types().contains(type);
414
    return !type.isNull() && types().contains(type);
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
    auto pasteboard = std::make_unique<StaticPasteboard>();
419
    auto pasteboard = std::make_unique<StaticPasteboard>();
419
    pasteboard->writeString("text/plain"_s, plainText);
420
    pasteboard->writeString("text/plain"_s, plainText);
420
    pasteboard->writeString("text/html"_s, htmlText);
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
424
void DataTransfer::commitToPasteboard(Pasteboard& nativePasteboard)
425
void DataTransfer::commitToPasteboard(Pasteboard& nativePasteboard)
Lines 463-491 void DataTransfer::setDragImage(Element*, int, int) a/Source/WebCore/dom/DataTransfer.cpp_sec5
463
464
464
#else
465
#else
465
466
466
Ref<DataTransfer> DataTransfer::createForDrag()
467
Ref<DataTransfer> DataTransfer::createForDrag(const Document& document)
467
{
468
{
468
    return adoptRef(*new DataTransfer(StoreMode::ReadWrite, Pasteboard::createForDragAndDrop(), Type::DragAndDropData));
469
    return adoptRef(*new DataTransfer(document, StoreMode::ReadWrite, Pasteboard::createForDragAndDrop(), Type::DragAndDropData));
469
}
470
}
470
471
471
Ref<DataTransfer> DataTransfer::createForDragStartEvent(Document& document)
472
Ref<DataTransfer> DataTransfer::createForDragStartEvent(const Document& document)
472
{
473
{
473
    auto dataTransfer = adoptRef(*new DataTransfer(StoreMode::ReadWrite, std::make_unique<StaticPasteboard>(), Type::DragAndDropData));
474
    auto dataTransfer = adoptRef(*new DataTransfer(document, StoreMode::ReadWrite, std::make_unique<StaticPasteboard>(), Type::DragAndDropData));
474
    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
475
    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
475
    return dataTransfer;
476
    return dataTransfer;
476
}
477
}
477
478
478
Ref<DataTransfer> DataTransfer::createForDrop(Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
479
Ref<DataTransfer> DataTransfer::createForDrop(const Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
479
{
480
{
480
    auto dataTransfer = adoptRef(*new DataTransfer(DataTransfer::StoreMode::Readonly, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData));
481
    auto dataTransfer = adoptRef(*new DataTransfer(document, DataTransfer::StoreMode::Readonly, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData));
481
    dataTransfer->setSourceOperation(sourceOperation);
482
    dataTransfer->setSourceOperation(sourceOperation);
482
    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
483
    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
483
    return dataTransfer;
484
    return dataTransfer;
484
}
485
}
485
486
486
Ref<DataTransfer> DataTransfer::createForUpdatingDropTarget(Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
487
Ref<DataTransfer> DataTransfer::createForUpdatingDropTarget(const Document& document, std::unique_ptr<Pasteboard>&& pasteboard, DragOperation sourceOperation, bool draggingFiles)
487
{
488
{
488
    auto dataTransfer = adoptRef(*new DataTransfer(DataTransfer::StoreMode::Protected, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData));
489
    auto dataTransfer = adoptRef(*new DataTransfer(document, DataTransfer::StoreMode::Protected, WTFMove(pasteboard), draggingFiles ? Type::DragAndDropFiles : Type::DragAndDropData));
489
    dataTransfer->setSourceOperation(sourceOperation);
490
    dataTransfer->setSourceOperation(sourceOperation);
490
    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
491
    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
491
    return dataTransfer;
492
    return dataTransfer;
- a/Source/WebCore/dom/DataTransfer.h -7 / +9 lines
Lines 26-31 a/Source/WebCore/dom/DataTransfer.h_sec1
26
#include "CachedResourceHandle.h"
26
#include "CachedResourceHandle.h"
27
#include "DragActions.h"
27
#include "DragActions.h"
28
#include "DragImage.h"
28
#include "DragImage.h"
29
#include <pal/SessionID.h>
29
#include <wtf/text/WTFString.h>
30
#include <wtf/text/WTFString.h>
30
31
31
namespace WebCore {
32
namespace WebCore {
Lines 46-53 public: a/Source/WebCore/dom/DataTransfer.h_sec2
46
    // https://html.spec.whatwg.org/multipage/dnd.html#drag-data-store-mode
47
    // https://html.spec.whatwg.org/multipage/dnd.html#drag-data-store-mode
47
    enum class StoreMode { Invalid, ReadWrite, Readonly, Protected };
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> createForCopyAndPaste(const Document&, StoreMode, std::unique_ptr<Pasteboard>&&);
50
    static Ref<DataTransfer> createForInputEvent(const String& plainText, const String& htmlText);
51
    static Ref<DataTransfer> createForInputEvent(const Document&, const String& plainText, const String& htmlText);
51
52
52
    WEBCORE_EXPORT ~DataTransfer();
53
    WEBCORE_EXPORT ~DataTransfer();
53
54
Lines 86-95 public: a/Source/WebCore/dom/DataTransfer.h_sec3
86
    void commitToPasteboard(Pasteboard&);
87
    void commitToPasteboard(Pasteboard&);
87
88
88
#if ENABLE(DRAG_SUPPORT)
89
#if ENABLE(DRAG_SUPPORT)
89
    static Ref<DataTransfer> createForDrag();
90
    static Ref<DataTransfer> createForDrag(const Document&);
90
    static Ref<DataTransfer> createForDragStartEvent(Document&);
91
    static Ref<DataTransfer> createForDragStartEvent(const Document&);
91
    static Ref<DataTransfer> createForDrop(Document&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);
92
    static Ref<DataTransfer> createForDrop(const Document&, std::unique_ptr<Pasteboard>&&, DragOperation, bool draggingFiles);
92
    static Ref<DataTransfer> createForUpdatingDropTarget(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
    bool dropEffectIsUninitialized() const { return m_dropEffect == "uninitialized"; }
95
    bool dropEffectIsUninitialized() const { return m_dropEffect == "uninitialized"; }
95
96
Lines 112-118 public: a/Source/WebCore/dom/DataTransfer.h_sec4
112
113
113
private:
114
private:
114
    enum class Type { CopyAndPaste, DragAndDropData, DragAndDropFiles, InputEvent };
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
#if ENABLE(DRAG_SUPPORT)
118
#if ENABLE(DRAG_SUPPORT)
118
    bool forDrag() const { return m_type == Type::DragAndDropData || m_type == Type::DragAndDropFiles; }
119
    bool forDrag() const { return m_type == Type::DragAndDropData || m_type == Type::DragAndDropFiles; }
Lines 129-134 private: a/Source/WebCore/dom/DataTransfer.h_sec5
129
    Vector<String> types(AddFilesType) const;
130
    Vector<String> types(AddFilesType) const;
130
    Vector<Ref<File>> filesFromPasteboardAndItemList() const;
131
    Vector<Ref<File>> filesFromPasteboardAndItemList() const;
131
132
133
    PAL::SessionID m_sessionID;
132
    String m_originIdentifier;
134
    String m_originIdentifier;
133
    StoreMode m_storeMode;
135
    StoreMode m_storeMode;
134
    std::unique_ptr<Pasteboard> m_pasteboard;
136
    std::unique_ptr<Pasteboard> m_pasteboard;
- a/Source/WebCore/dom/Document.cpp -1 / +1 lines
Lines 5732-5738 bool Document::isTelephoneNumberParsingAllowed() const a/Source/WebCore/dom/Document.cpp_sec1
5732
5732
5733
#endif
5733
#endif
5734
5734
5735
String Document::originIdentifierForPasteboard()
5735
String Document::originIdentifierForPasteboard() const
5736
{
5736
{
5737
    auto origin = securityOrigin().toString();
5737
    auto origin = securityOrigin().toString();
5738
    if (origin != "null")
5738
    if (origin != "null")
- a/Source/WebCore/dom/Document.h -2 / +2 lines
Lines 1033-1039 public: a/Source/WebCore/dom/Document.h_sec1
1033
    void incDOMTreeVersion() { m_domTreeVersion = ++s_globalTreeVersion; }
1033
    void incDOMTreeVersion() { m_domTreeVersion = ++s_globalTreeVersion; }
1034
    uint64_t domTreeVersion() const { return m_domTreeVersion; }
1034
    uint64_t domTreeVersion() const { return m_domTreeVersion; }
1035
1035
1036
    WEBCORE_EXPORT String originIdentifierForPasteboard();
1036
    WEBCORE_EXPORT String originIdentifierForPasteboard() const;
1037
1037
1038
    // XPathEvaluator methods
1038
    // XPathEvaluator methods
1039
    WEBCORE_EXPORT ExceptionOr<Ref<XPathExpression>> createExpression(const String& expression, RefPtr<XPathNSResolver>&&);
1039
    WEBCORE_EXPORT ExceptionOr<Ref<XPathExpression>> createExpression(const String& expression, RefPtr<XPathNSResolver>&&);
Lines 1688-1694 private: a/Source/WebCore/dom/Document.h_sec2
1688
    uint64_t m_domTreeVersion;
1688
    uint64_t m_domTreeVersion;
1689
    static uint64_t s_globalTreeVersion;
1689
    static uint64_t s_globalTreeVersion;
1690
1690
1691
    String m_uniqueIdentifier;
1691
    mutable String m_uniqueIdentifier;
1692
1692
1693
    HashSet<NodeIterator*> m_nodeIterators;
1693
    HashSet<NodeIterator*> m_nodeIterators;
1694
    HashSet<Range*> m_ranges;
1694
    HashSet<Range*> m_ranges;
- a/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp -1 / +1 lines
Lines 82-88 String ReplaceRangeWithTextCommand::inputEventData() const a/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp_sec1
82
RefPtr<DataTransfer> ReplaceRangeWithTextCommand::inputEventDataTransfer() const
82
RefPtr<DataTransfer> ReplaceRangeWithTextCommand::inputEventDataTransfer() const
83
{
83
{
84
    if (!isEditingTextAreaOrTextInput())
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
    return CompositeEditCommand::inputEventDataTransfer();
87
    return CompositeEditCommand::inputEventDataTransfer();
88
}
88
}
- a/Source/WebCore/editing/ReplaceSelectionCommand.cpp -1 / +1 lines
Lines 1326-1332 RefPtr<DataTransfer> ReplaceSelectionCommand::inputEventDataTransfer() const a/Source/WebCore/editing/ReplaceSelectionCommand.cpp_sec1
1326
    if (isEditingTextAreaOrTextInput())
1326
    if (isEditingTextAreaOrTextInput())
1327
        return CompositeEditCommand::inputEventDataTransfer();
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
1332
bool ReplaceSelectionCommand::shouldRemoveEndBR(Node* endBR, const VisiblePosition& originalVisPosBeforeEndBR)
1332
bool ReplaceSelectionCommand::shouldRemoveEndBR(Node* endBR, const VisiblePosition& originalVisPosBeforeEndBR)
- a/Source/WebCore/editing/SpellingCorrectionCommand.cpp -1 / +1 lines
Lines 130-136 Vector<RefPtr<StaticRange>> SpellingCorrectionCommand::targetRanges() const a/Source/WebCore/editing/SpellingCorrectionCommand.cpp_sec1
130
RefPtr<DataTransfer> SpellingCorrectionCommand::inputEventDataTransfer() const
130
RefPtr<DataTransfer> SpellingCorrectionCommand::inputEventDataTransfer() const
131
{
131
{
132
    if (!isEditingTextAreaOrTextInput())
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
    return CompositeEditCommand::inputEventDataTransfer();
135
    return CompositeEditCommand::inputEventDataTransfer();
136
}
136
}
- a/Source/WebCore/editing/TypingCommand.cpp -1 / +1 lines
Lines 425-431 RefPtr<DataTransfer> TypingCommand::inputEventDataTransfer() const a/Source/WebCore/editing/TypingCommand.cpp_sec1
425
425
426
    StringBuilder htmlText;
426
    StringBuilder htmlText;
427
    MarkupAccumulator::appendCharactersReplacingEntities(htmlText, m_currentTextToInsert, 0, m_currentTextToInsert.length(), EntityMaskInHTMLPCDATA);
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
431
void TypingCommand::didApplyCommand()
431
void TypingCommand::didApplyCommand()
- a/Source/WebCore/editing/WebCorePasteboardFileReader.cpp -2 / +2 lines
Lines 35-46 WebCorePasteboardFileReader::~WebCorePasteboardFileReader() = default; a/Source/WebCore/editing/WebCorePasteboardFileReader.cpp_sec1
35
35
36
void WebCorePasteboardFileReader::readFilename(const String& filename)
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
void WebCorePasteboardFileReader::readBuffer(const String& filename, const String& type, Ref<SharedBuffer>&& buffer)
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
46
}
46
}
- a/Source/WebCore/editing/WebCorePasteboardFileReader.h +6 lines
Lines 32-42 namespace WebCore { a/Source/WebCore/editing/WebCorePasteboardFileReader.h_sec1
32
class File;
32
class File;
33
33
34
struct WebCorePasteboardFileReader final : PasteboardFileReader {
34
struct WebCorePasteboardFileReader final : PasteboardFileReader {
35
    explicit WebCorePasteboardFileReader(PAL::SessionID sessionID)
36
        : sessionID(sessionID)
37
    {
38
    }
39
35
    ~WebCorePasteboardFileReader();
40
    ~WebCorePasteboardFileReader();
36
41
37
    void readFilename(const String&) final;
42
    void readFilename(const String&) final;
38
    void readBuffer(const String& filename, const String& type, Ref<SharedBuffer>&&) final;
43
    void readBuffer(const String& filename, const String& type, Ref<SharedBuffer>&&) final;
39
44
45
    PAL::SessionID sessionID;
40
    Vector<Ref<File>> files;
46
    Vector<Ref<File>> files;
41
};
47
};
42
48
- a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm -12 / +12 lines
Lines 259-265 static Ref<DocumentFragment> createFragmentForImageAttachment(Frame& frame, Docu a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec1
259
        frame.editor().registerAttachmentIdentifier(attachment->ensureUniqueIdentifier(), contentType, defaultImageAttachmentName, WTFMove(buffer));
259
        frame.editor().registerAttachmentIdentifier(attachment->ensureUniqueIdentifier(), contentType, defaultImageAttachmentName, WTFMove(buffer));
260
        if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) {
260
        if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) {
261
            auto image = HTMLImageElement::create(document);
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
            image->setAttachmentElement(WTFMove(attachment));
263
            image->setAttachmentElement(WTFMove(attachment));
264
            if (preferredSize.width)
264
            if (preferredSize.width)
265
                image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomString::number(*preferredSize.width));
265
                image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomString::number(*preferredSize.width));
Lines 271-277 static Ref<DocumentFragment> createFragmentForImageAttachment(Frame& frame, Docu a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec2
271
            fragment->appendChild(WTFMove(attachment));
271
            fragment->appendChild(WTFMove(attachment));
272
        }
272
        }
273
    } else {
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
        fragment->appendChild(WTFMove(attachment));
275
        fragment->appendChild(WTFMove(attachment));
276
    }
276
    }
277
    return fragment;
277
    return fragment;
Lines 365-371 static void replaceRichContentWithAttachments(Frame& frame, DocumentFragment& fr a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec3
365
        if (supportsClientSideAttachmentData(frame)) {
365
        if (supportsClientSideAttachmentData(frame)) {
366
            if (is<HTMLImageElement>(originalElement.get()) && contentTypeIsSuitableForInlineImageRepresentation(info.contentType)) {
366
            if (is<HTMLImageElement>(originalElement.get()) && contentTypeIsSuitableForInlineImageRepresentation(info.contentType)) {
367
                auto& image = downcast<HTMLImageElement>(originalElement.get());
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
                image.setAttachmentElement(attachment.copyRef());
369
                image.setAttachmentElement(attachment.copyRef());
370
            } else {
370
            } else {
371
                attachment->updateAttributes(info.data->size(), info.contentType, info.fileName);
371
                attachment->updateAttributes(info.data->size(), info.contentType, info.fileName);
Lines 373-379 static void replaceRichContentWithAttachments(Frame& frame, DocumentFragment& fr a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec4
373
            }
373
            }
374
            frame.editor().registerAttachmentIdentifier(attachment->ensureUniqueIdentifier(), WTFMove(info.contentType), WTFMove(info.fileName), WTFMove(info.data));
374
            frame.editor().registerAttachmentIdentifier(attachment->ensureUniqueIdentifier(), WTFMove(info.contentType), WTFMove(info.fileName), WTFMove(info.data));
375
        } else {
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
            parent->replaceChild(WTFMove(attachment), WTFMove(originalElement));
377
            parent->replaceChild(WTFMove(attachment), WTFMove(originalElement));
378
        }
378
        }
379
    }
379
    }
Lines 415-421 RefPtr<DocumentFragment> createFragmentAndAddResources(Frame& frame, NSAttribute a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec5
415
415
416
    HashMap<AtomString, AtomString> blobURLMap;
416
    HashMap<AtomString, AtomString> blobURLMap;
417
    for (const Ref<ArchiveResource>& subresource : fragmentAndResources.resources) {
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
        String blobURL = DOMURL::createObjectURL(document, blob);
419
        String blobURL = DOMURL::createObjectURL(document, blob);
420
        blobURLMap.set(subresource->url().string(), blobURL);
420
        blobURLMap.set(subresource->url().string(), blobURL);
421
    }
421
    }
Lines 464-470 static String sanitizeMarkupWithArchive(Frame& frame, Document& destinationDocum a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec6
464
        auto& subresourceURL = subresource->url();
464
        auto& subresourceURL = subresource->url();
465
        if (!shouldReplaceSubresourceURL(subresourceURL))
465
        if (!shouldReplaceSubresourceURL(subresourceURL))
466
            continue;
466
            continue;
467
        auto blob = Blob::create(subresource->data(), subresource->mimeType());
467
        auto blob = Blob::create(destinationDocument.sessionID(), subresource->data(), subresource->mimeType());
468
        String blobURL = DOMURL::createObjectURL(destinationDocument, blob);
468
        String blobURL = DOMURL::createObjectURL(destinationDocument, blob);
469
        blobURLMap.set(subresourceURL.string(), blobURL);
469
        blobURLMap.set(subresourceURL.string(), blobURL);
470
    }
470
    }
Lines 491-497 static String sanitizeMarkupWithArchive(Frame& frame, Document& destinationDocum a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec7
491
        Vector<uint8_t> blobBuffer;
491
        Vector<uint8_t> blobBuffer;
492
        blobBuffer.reserveCapacity(utf8.length());
492
        blobBuffer.reserveCapacity(utf8.length());
493
        blobBuffer.append(reinterpret_cast<const uint8_t*>(utf8.data()), utf8.length());
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
        String subframeBlobURL = DOMURL::createObjectURL(destinationDocument, blob);
496
        String subframeBlobURL = DOMURL::createObjectURL(destinationDocument, blob);
497
        blobURLMap.set(subframeURL.string(), subframeBlobURL);
497
        blobURLMap.set(subframeURL.string(), subframeBlobURL);
Lines 688-694 bool WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type, a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec8
688
    if (shouldReplaceRichContentWithAttachments())
688
    if (shouldReplaceRichContentWithAttachments())
689
        addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type, preferredPresentationSize));
689
        addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type, preferredPresentationSize));
690
    else
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
    return fragment;
693
    return fragment;
694
}
694
}
Lines 709-715 static Ref<HTMLElement> attachmentForFilePath(Frame& frame, const String& path, a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec9
709
    auto document = makeRef(*frame.document());
709
    auto document = makeRef(*frame.document());
710
    auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document);
710
    auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document);
711
    if (!supportsClientSideAttachmentData(frame)) {
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
        return attachment;
713
        return attachment;
714
    }
714
    }
715
715
Lines 736-742 static Ref<HTMLElement> attachmentForFilePath(Frame& frame, const String& path, a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec10
736
736
737
    if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) {
737
    if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) {
738
        auto image = HTMLImageElement::create(document);
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
        image->setAttachmentElement(WTFMove(attachment));
740
        image->setAttachmentElement(WTFMove(attachment));
741
        if (preferredSize.width)
741
        if (preferredSize.width)
742
            image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomString::number(*preferredSize.width));
742
            image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomString::number(*preferredSize.width));
Lines 765-771 static Ref<HTMLElement> attachmentForData(Frame& frame, SharedBuffer& buffer, co a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec11
765
        fileName = name;
765
        fileName = name;
766
766
767
    if (!supportsClientSideAttachmentData(frame)) {
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
        return attachment;
769
        return attachment;
770
    }
770
    }
771
771
Lines 773-779 static Ref<HTMLElement> attachmentForData(Frame& frame, SharedBuffer& buffer, co a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec12
773
773
774
    if (contentTypeIsSuitableForInlineImageRepresentation(attachmentType)) {
774
    if (contentTypeIsSuitableForInlineImageRepresentation(attachmentType)) {
775
        auto image = HTMLImageElement::create(document);
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
        image->setAttachmentElement(WTFMove(attachment));
777
        image->setAttachmentElement(WTFMove(attachment));
778
        if (preferredSize.width)
778
        if (preferredSize.width)
779
            image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomString::number(*preferredSize.width));
779
            image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomString::number(*preferredSize.width));
- a/Source/WebCore/editing/markup.cpp -2 / +2 lines
Lines 983-991 static void restoreAttachmentElementsInFragment(DocumentFragment& fragment) a/Source/WebCore/editing/markup.cpp_sec1
983
        auto attachmentPath = attachment->attachmentPath();
983
        auto attachmentPath = attachment->attachmentPath();
984
        auto blobURL = attachment->blobURL();
984
        auto blobURL = attachment->blobURL();
985
        if (!attachmentPath.isEmpty())
985
        if (!attachmentPath.isEmpty())
986
            attachment->setFile(File::create(attachmentPath));
986
            attachment->setFile(File::create(fragment.document().sessionID(), attachmentPath));
987
        else if (!blobURL.isEmpty())
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
        // Remove temporary attributes that were previously added in StyledMarkupAccumulator::appendCustomAttributes.
990
        // Remove temporary attributes that were previously added in StyledMarkupAccumulator::appendCustomAttributes.
991
        attachment->removeAttribute(webkitattachmentidAttr);
991
        attachment->removeAttribute(webkitattachmentidAttr);
- a/Source/WebCore/fileapi/Blob.cpp -14 / +22 lines
Lines 72-90 URLRegistry& BlobURLRegistry::registry() a/Source/WebCore/fileapi/Blob.cpp_sec1
72
    return instance;
72
    return instance;
73
}
73
}
74
74
75
Blob::Blob(UninitializedContructor)
75
Blob::Blob(UninitializedContructor, PAL::SessionID sessionID)
76
    : m_sessionID(sessionID)
76
{
77
{
77
}
78
}
78
79
79
Blob::Blob()
80
Blob::Blob(PAL::SessionID sessionID)
80
    : m_size(0)
81
    : m_sessionID(sessionID)
82
    , m_size(0)
81
{
83
{
82
    m_internalURL = BlobURL::createInternalURL();
84
    m_internalURL = BlobURL::createInternalURL();
83
    ThreadableBlobRegistry::registerBlobURL(m_internalURL, { },  { });
85
    ThreadableBlobRegistry::registerBlobURL(m_internalURL, { },  { });
84
}
86
}
85
87
86
Blob::Blob(Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& propertyBag)
88
Blob::Blob(PAL::SessionID sessionID, Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& propertyBag)
87
    : m_internalURL(BlobURL::createInternalURL())
89
    : m_sessionID(sessionID)
90
    , m_internalURL(BlobURL::createInternalURL())
88
    , m_type(normalizedContentType(propertyBag.type))
91
    , m_type(normalizedContentType(propertyBag.type))
89
    , m_size(-1)
92
    , m_size(-1)
90
{
93
{
Lines 100-107 Blob::Blob(Vector<BlobPartVariant>&& blobPartVariants, const BlobPropertyBag& pr a/Source/WebCore/fileapi/Blob.cpp_sec2
100
    ThreadableBlobRegistry::registerBlobURL(m_internalURL, builder.finalize(), m_type);
103
    ThreadableBlobRegistry::registerBlobURL(m_internalURL, builder.finalize(), m_type);
101
}
104
}
102
105
103
Blob::Blob(const SharedBuffer& buffer, const String& contentType)
106
Blob::Blob(PAL::SessionID sessionID, const SharedBuffer& buffer, const String& contentType)
104
    : m_type(contentType)
107
    : m_sessionID(sessionID)
108
    , m_type(contentType)
105
    , m_size(buffer.size())
109
    , m_size(buffer.size())
106
{
110
{
107
    Vector<uint8_t> data;
111
    Vector<uint8_t> data;
Lines 113-120 Blob::Blob(const SharedBuffer& buffer, const String& contentType) a/Source/WebCore/fileapi/Blob.cpp_sec3
113
    ThreadableBlobRegistry::registerBlobURL(m_internalURL, WTFMove(blobParts), contentType);
117
    ThreadableBlobRegistry::registerBlobURL(m_internalURL, WTFMove(blobParts), contentType);
114
}
118
}
115
119
116
Blob::Blob(Vector<uint8_t>&& data, const String& contentType)
120
Blob::Blob(PAL::SessionID sessionID, Vector<uint8_t>&& data, const String& contentType)
117
    : m_type(contentType)
121
    : m_sessionID(sessionID)
122
    , m_type(contentType)
118
    , m_size(data.size())
123
    , m_size(data.size())
119
{
124
{
120
    Vector<BlobPart> blobParts;
125
    Vector<BlobPart> blobParts;
Lines 124-138 Blob::Blob(Vector<uint8_t>&& data, const String& contentType) a/Source/WebCore/fileapi/Blob.cpp_sec4
124
}
129
}
125
130
126
Blob::Blob(ReferencingExistingBlobConstructor, const Blob& blob)
131
Blob::Blob(ReferencingExistingBlobConstructor, const Blob& blob)
127
    : m_internalURL(BlobURL::createInternalURL())
132
    : m_sessionID(blob.m_sessionID)
133
    , m_internalURL(BlobURL::createInternalURL())
128
    , m_type(blob.type())
134
    , m_type(blob.type())
129
    , m_size(blob.size())
135
    , m_size(blob.size())
130
{
136
{
131
    ThreadableBlobRegistry::registerBlobURL(m_internalURL, { BlobPart(blob.url()) } , m_type);
137
    ThreadableBlobRegistry::registerBlobURL(m_internalURL, { BlobPart(blob.url()) } , m_type);
132
}
138
}
133
139
134
Blob::Blob(DeserializationContructor, const URL& srcURL, const String& type, long long size, const String& fileBackedPath)
140
Blob::Blob(DeserializationContructor, PAL::SessionID sessionID, const URL& srcURL, const String& type, long long size, const String& fileBackedPath)
135
    : m_type(normalizedContentType(type))
141
    : m_sessionID(sessionID)
142
    , m_type(normalizedContentType(type))
136
    , m_size(size)
143
    , m_size(size)
137
{
144
{
138
    m_internalURL = BlobURL::createInternalURL();
145
    m_internalURL = BlobURL::createInternalURL();
Lines 142-149 Blob::Blob(DeserializationContructor, const URL& srcURL, const String& type, lon a/Source/WebCore/fileapi/Blob.cpp_sec5
142
        ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked(m_internalURL, srcURL, fileBackedPath, m_type);
149
        ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked(m_internalURL, srcURL, fileBackedPath, m_type);
143
}
150
}
144
151
145
Blob::Blob(const URL& srcURL, long long start, long long end, const String& type)
152
Blob::Blob(PAL::SessionID sessionID, const URL& srcURL, long long start, long long end, const String& type)
146
    : m_type(normalizedContentType(type))
153
    : m_sessionID(sessionID)
154
    , m_type(normalizedContentType(type))
147
    , m_size(-1) // size is not necessarily equal to end - start.
155
    , m_size(-1) // size is not necessarily equal to end - start.
148
{
156
{
149
    m_internalURL = BlobURL::createInternalURL();
157
    m_internalURL = BlobURL::createInternalURL();
- a/Source/WebCore/fileapi/Blob.h -18 / +21 lines
Lines 32-41 a/Source/WebCore/fileapi/Blob.h_sec1
32
#pragma once
32
#pragma once
33
33
34
#include "BlobPropertyBag.h"
34
#include "BlobPropertyBag.h"
35
#include "ScriptExecutionContext.h"
35
#include "ScriptWrappable.h"
36
#include "ScriptWrappable.h"
36
#include <wtf/IsoMalloc.h>
37
#include <wtf/IsoMalloc.h>
37
#include <wtf/URL.h>
38
#include <wtf/URL.h>
38
#include "URLRegistry.h"
39
#include "URLRegistry.h"
40
#include <pal/SessionID.h>
39
#include <wtf/Variant.h>
41
#include <wtf/Variant.h>
40
42
41
namespace JSC {
43
namespace JSC {
Lines 54-83 using BlobPartVariant = Variant<RefPtr<JSC::ArrayBufferView>, RefPtr<JSC::ArrayB a/Source/WebCore/fileapi/Blob.h_sec2
54
class Blob : public ScriptWrappable, public URLRegistrable, public RefCounted<Blob> {
56
class Blob : public ScriptWrappable, public URLRegistrable, public RefCounted<Blob> {
55
    WTF_MAKE_ISO_ALLOCATED_EXPORT(Blob, WEBCORE_EXPORT);
57
    WTF_MAKE_ISO_ALLOCATED_EXPORT(Blob, WEBCORE_EXPORT);
56
public:
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
        ASSERT(Blob::isNormalizedContentType(type));
81
        ASSERT(Blob::isNormalizedContentType(type));
80
        return adoptRef(*new Blob(deserializationContructor, srcURL, type, size, fileBackedPath));
82
        return adoptRef(*new Blob(deserializationContructor, sessionID, srcURL, type, size, fileBackedPath));
81
    }
83
    }
82
84
83
    virtual ~Blob();
85
    virtual ~Blob();
Lines 102-128 public: a/Source/WebCore/fileapi/Blob.h_sec3
102
104
103
    Ref<Blob> slice(long long start = 0, long long end = std::numeric_limits<long long>::max(), const String& contentType = String()) const
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
protected:
110
protected:
109
    WEBCORE_EXPORT Blob();
111
    WEBCORE_EXPORT explicit Blob(PAL::SessionID);
110
    Blob(Vector<BlobPartVariant>&&, const BlobPropertyBag&);
112
    Blob(PAL::SessionID, Vector<BlobPartVariant>&&, const BlobPropertyBag&);
111
    Blob(const SharedBuffer&, const String& contentType);
113
    Blob(PAL::SessionID, const SharedBuffer&, const String& contentType);
112
    Blob(Vector<uint8_t>&&, const String& contentType);
114
    Blob(PAL::SessionID, Vector<uint8_t>&&, const String& contentType);
113
115
114
    enum ReferencingExistingBlobConstructor { referencingExistingBlobConstructor };
116
    enum ReferencingExistingBlobConstructor { referencingExistingBlobConstructor };
115
    Blob(ReferencingExistingBlobConstructor, const Blob&);
117
    Blob(ReferencingExistingBlobConstructor, const Blob&);
116
118
117
    enum UninitializedContructor { uninitializedContructor };
119
    enum UninitializedContructor { uninitializedContructor };
118
    Blob(UninitializedContructor);
120
    Blob(UninitializedContructor, PAL::SessionID);
119
121
120
    enum DeserializationContructor { deserializationContructor };
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
    // For slicing.
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
    // This is an internal URL referring to the blob data associated with this object. It serves
129
    // This is an internal URL referring to the blob data associated with this object. It serves
127
    // as an identifier for this blob. The internal URL is never used to source the blob's content
130
    // as an identifier for this blob. The internal URL is never used to source the blob's content
128
    // into an HTML or for FileRead'ing, public blob URLs must be used for those purposes.
131
    // into an HTML or for FileRead'ing, public blob URLs must be used for those purposes.
- a/Source/WebCore/fileapi/Blob.idl +1 lines
Lines 35-40 typedef (BufferSource or Blob or USVString) BlobPart; a/Source/WebCore/fileapi/Blob.idl_sec1
35
    GenerateIsReachable=Impl,
35
    GenerateIsReachable=Impl,
36
    CustomToJSObject,
36
    CustomToJSObject,
37
    Constructor(optional sequence<BlobPart> blobParts, optional BlobPropertyBag options),
37
    Constructor(optional sequence<BlobPart> blobParts, optional BlobPropertyBag options),
38
    ConstructorCallWith=ScriptExecutionContext,
38
] interface Blob {
39
] interface Blob {
39
    readonly attribute unsigned long long size;
40
    readonly attribute unsigned long long size;
40
    readonly attribute DOMString type;
41
    readonly attribute DOMString type;
- a/Source/WebCore/fileapi/File.cpp -10 / +10 lines
Lines 39-53 namespace WebCore { a/Source/WebCore/fileapi/File.cpp_sec1
39
39
40
WTF_MAKE_ISO_ALLOCATED_IMPL(File);
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
    file->setRelativePath(relativePath);
45
    file->setRelativePath(relativePath);
46
    return file;
46
    return file;
47
}
47
}
48
48
49
File::File(const String& path)
49
File::File(PAL::SessionID sessionID, const String& path)
50
    : Blob(uninitializedContructor)
50
    : Blob(uninitializedContructor, sessionID)
51
    , m_path(path)
51
    , m_path(path)
52
{
52
{
53
    m_internalURL = BlobURL::createInternalURL();
53
    m_internalURL = BlobURL::createInternalURL();
Lines 56-63 File::File(const String& path) a/Source/WebCore/fileapi/File.cpp_sec2
56
    ThreadableBlobRegistry::registerFileBlobURL(m_internalURL, path, m_type);
56
    ThreadableBlobRegistry::registerFileBlobURL(m_internalURL, path, m_type);
57
}
57
}
58
58
59
File::File(const String& path, const String& nameOverride)
59
File::File(PAL::SessionID sessionID, const String& path, const String& nameOverride)
60
    : Blob(uninitializedContructor)
60
    : Blob(uninitializedContructor, sessionID)
61
    , m_path(path)
61
    , m_path(path)
62
{
62
{
63
    m_internalURL = BlobURL::createInternalURL();
63
    m_internalURL = BlobURL::createInternalURL();
Lines 66-73 File::File(const String& path, const String& nameOverride) a/Source/WebCore/fileapi/File.cpp_sec3
66
    ThreadableBlobRegistry::registerFileBlobURL(m_internalURL, path, m_type);
66
    ThreadableBlobRegistry::registerFileBlobURL(m_internalURL, path, m_type);
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)
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, url, type, -1, path)
70
    : Blob(deserializationContructor, sessionID, url, type, -1, path)
71
    , m_path(path)
71
    , m_path(path)
72
    , m_name(name)
72
    , m_name(name)
73
    , m_lastModifiedDateOverride(lastModified)
73
    , m_lastModifiedDateOverride(lastModified)
Lines 81-88 static BlobPropertyBag convertPropertyBag(const File::PropertyBag& initialBag) a/Source/WebCore/fileapi/File.cpp_sec4
81
    return bag;
81
    return bag;
82
}
82
}
83
83
84
File::File(Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag& propertyBag)
84
File::File(ScriptExecutionContext& context, Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag& propertyBag)
85
    : Blob(WTFMove(blobPartVariants), convertPropertyBag(propertyBag))
85
    : Blob(context.sessionID(), WTFMove(blobPartVariants), convertPropertyBag(propertyBag))
86
    , m_name(filename)
86
    , m_name(filename)
87
    , m_lastModifiedDateOverride(propertyBag.lastModified.valueOr(WallTime::now().secondsSinceEpoch().milliseconds()))
87
    , m_lastModifiedDateOverride(propertyBag.lastModified.valueOr(WallTime::now().secondsSinceEpoch().milliseconds()))
88
{
88
{
- a/Source/WebCore/fileapi/File.h -14 / +14 lines
Lines 41-68 public: a/Source/WebCore/fileapi/File.h_sec1
41
        Optional<int64_t> lastModified;
41
        Optional<int64_t> lastModified;
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
    // Create a File using the 'new File' constructor.
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
    // 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.
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
        if (nameOverride.isEmpty())
63
        if (nameOverride.isEmpty())
64
            return adoptRef(*new File(path));
64
            return adoptRef(*new File(sessionID, path));
65
        return adoptRef(*new File(path, nameOverride));
65
        return adoptRef(*new File(sessionID, path, nameOverride));
66
    }
66
    }
67
67
68
    static Ref<File> create(const Blob& blob, const String& name)
68
    static Ref<File> create(const Blob& blob, const String& name)
Lines 75-81 public: a/Source/WebCore/fileapi/File.h_sec2
75
        return adoptRef(*new File(file, name));
75
        return adoptRef(*new File(file, name));
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
    bool isFile() const override { return true; }
80
    bool isFile() const override { return true; }
81
81
Lines 95-107 public: a/Source/WebCore/fileapi/File.h_sec3
95
    bool isDirectory() const;
95
    bool isDirectory() const;
96
96
97
private:
97
private:
98
    WEBCORE_EXPORT explicit File(const String& path);
98
    WEBCORE_EXPORT explicit File(PAL::SessionID, const String& path);
99
    File(const String& path, const String& nameOverride);
99
    File(PAL::SessionID, const String& path, const String& nameOverride);
100
    File(Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag&);
100
    File(ScriptExecutionContext&, Vector<BlobPartVariant>&& blobPartVariants, const String& filename, const PropertyBag&);
101
    File(const Blob&, const String& name);
101
    File(const Blob&, const String& name);
102
    File(const File&, const String& name);
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
    static void computeNameAndContentType(const String& path, const String& nameOverride, String& effectiveName, String& effectiveContentType);
106
    static void computeNameAndContentType(const String& path, const String& nameOverride, String& effectiveName, String& effectiveContentType);
107
#if ENABLE(FILE_REPLACEMENT)
107
#if ENABLE(FILE_REPLACEMENT)
- a/Source/WebCore/fileapi/File.idl +1 lines
Lines 28-33 typedef (BufferSource or Blob or USVString) BlobPart; a/Source/WebCore/fileapi/File.idl_sec1
28
// FIXME: This should be exposed on Workers as well.
28
// FIXME: This should be exposed on Workers as well.
29
[
29
[
30
    Constructor(sequence<BlobPart> fileBits, USVString fileName, optional FilePropertyBag options),
30
    Constructor(sequence<BlobPart> fileBits, USVString fileName, optional FilePropertyBag options),
31
    ConstructorCallWith=ScriptExecutionContext,
31
    ExportMacro=WEBCORE_EXPORT,
32
    ExportMacro=WEBCORE_EXPORT,
32
    Exposed=(Window),
33
    Exposed=(Window),
33
    JSGenerateToJSObject,
34
    JSGenerateToJSObject,
- a/Source/WebCore/html/FileInputType.cpp -2 / +2 lines
Lines 175-181 bool FileInputType::appendFormData(DOMFormData& formData, bool multipart) const a/Source/WebCore/html/FileInputType.cpp_sec1
175
    // If no filename at all is entered, return successful but empty.
175
    // If no filename at all is entered, return successful but empty.
176
    // Null would be more logical, but Netscape posts an empty file. Argh.
176
    // Null would be more logical, but Netscape posts an empty file. Argh.
177
    if (fileList->isEmpty()) {
177
    if (fileList->isEmpty()) {
178
        formData.append(name, File::create(emptyString()));
178
        formData.append(name, File::create(element()->document().sessionID(), emptyString()));
179
        return true;
179
        return true;
180
    }
180
    }
181
181
Lines 414-420 void FileInputType::filesChosen(const Vector<FileChooserFileInfo>& paths, const a/Source/WebCore/html/FileInputType.cpp_sec2
414
414
415
    auto shouldResolveDirectories = allowsDirectories() ? FileListCreator::ShouldResolveDirectories::Yes : FileListCreator::ShouldResolveDirectories::No;
415
    auto shouldResolveDirectories = allowsDirectories() ? FileListCreator::ShouldResolveDirectories::Yes : FileListCreator::ShouldResolveDirectories::No;
416
    auto shouldRequestIcon = icon ? RequestIcon::Yes : RequestIcon::No;
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
        setFiles(WTFMove(fileList), shouldRequestIcon);
418
        setFiles(WTFMove(fileList), shouldRequestIcon);
419
        m_fileListCreator = nullptr;
419
        m_fileListCreator = nullptr;
420
    });
420
    });
- a/Source/WebCore/html/FileListCreator.cpp -10 / +10 lines
Lines 39-45 FileListCreator::~FileListCreator() a/Source/WebCore/html/FileListCreator.cpp_sec1
39
    ASSERT(!m_completionHander);
39
    ASSERT(!m_completionHander);
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
    for (auto& childPath : FileSystem::listDirectory(directory, "*")) {
44
    for (auto& childPath : FileSystem::listDirectory(directory, "*")) {
45
        auto metadata = FileSystem::fileMetadata(childPath);
45
        auto metadata = FileSystem::fileMetadata(childPath);
Lines 51-72 static void appendDirectoryFiles(const String& directory, const String& relative a/Source/WebCore/html/FileListCreator.cpp_sec2
51
51
52
        String childRelativePath = relativePath + "/" + FileSystem::pathGetFileName(childPath);
52
        String childRelativePath = relativePath + "/" + FileSystem::pathGetFileName(childPath);
53
        if (metadata.value().type == FileMetadata::Type::Directory)
53
        if (metadata.value().type == FileMetadata::Type::Directory)
54
            appendDirectoryFiles(childPath, childRelativePath, fileObjects);
54
            appendDirectoryFiles(sessionID, childPath, childRelativePath, fileObjects);
55
        else if (metadata.value().type == FileMetadata::Type::File)
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
    if (shouldResolveDirectories == ShouldResolveDirectories::No)
62
    if (shouldResolveDirectories == ShouldResolveDirectories::No)
63
        completionHandler(createFileList<ShouldResolveDirectories::No>(paths));
63
        completionHandler(createFileList<ShouldResolveDirectories::No>(sessionID, paths));
64
    else {
64
    else {
65
        // Resolve directories on a background thread to avoid blocking the main thread.
65
        // Resolve directories on a background thread to avoid blocking the main thread.
66
        m_completionHander = WTFMove(completionHandler);
66
        m_completionHander = WTFMove(completionHandler);
67
        m_workQueue = WorkQueue::create("FileListCreator Work Queue");
67
        m_workQueue = WorkQueue::create("FileListCreator Work Queue");
68
        m_workQueue->dispatch([this, protectedThis = makeRef(*this), paths = crossThreadCopy(paths)]() mutable {
68
        m_workQueue->dispatch([this, protectedThis = makeRef(*this), sessionID, paths = crossThreadCopy(paths)]() mutable {
69
            auto fileList = createFileList<ShouldResolveDirectories::Yes>(paths);
69
            auto fileList = createFileList<ShouldResolveDirectories::Yes>(sessionID, paths);
70
            callOnMainThread([this, protectedThis = WTFMove(protectedThis), fileList = WTFMove(fileList)]() mutable {
70
            callOnMainThread([this, protectedThis = WTFMove(protectedThis), fileList = WTFMove(fileList)]() mutable {
71
                if (auto completionHander = WTFMove(m_completionHander))
71
                if (auto completionHander = WTFMove(m_completionHander))
72
                    completionHander(WTFMove(fileList));
72
                    completionHander(WTFMove(fileList));
Lines 76-89 FileListCreator::FileListCreator(const Vector<FileChooserFileInfo>& paths, Shoul a/Source/WebCore/html/FileListCreator.cpp_sec3
76
}
76
}
77
77
78
template<FileListCreator::ShouldResolveDirectories shouldResolveDirectories>
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
    Vector<Ref<File>> fileObjects;
81
    Vector<Ref<File>> fileObjects;
82
    for (auto& info : paths) {
82
    for (auto& info : paths) {
83
        if (shouldResolveDirectories == ShouldResolveDirectories::Yes && FileSystem::fileIsDirectory(info.path, FileSystem::ShouldFollowSymbolicLinks::No))
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
        else
85
        else
86
            fileObjects.append(File::createWithName(info.path, info.displayName));
86
            fileObjects.append(File::createWithName(sessionID, info.path, info.displayName));
87
    }
87
    }
88
    return FileList::create(WTFMove(fileObjects));
88
    return FileList::create(WTFMove(fileObjects));
89
}
89
}
- a/Source/WebCore/html/FileListCreator.h -5 / +6 lines
Lines 25-30 a/Source/WebCore/html/FileListCreator.h_sec1
25
25
26
#pragma once
26
#pragma once
27
27
28
#include <pal/SessionID.h>
28
#include <wtf/Forward.h>
29
#include <wtf/Forward.h>
29
#include <wtf/Function.h>
30
#include <wtf/Function.h>
30
#include <wtf/Ref.h>
31
#include <wtf/Ref.h>
Lines 38-49 class FileList; a/Source/WebCore/html/FileListCreator.h_sec2
38
39
39
class FileListCreator : public ThreadSafeRefCounted<FileListCreator> {
40
class FileListCreator : public ThreadSafeRefCounted<FileListCreator> {
40
public:
41
public:
41
    using CompletionHandler = WTF::Function<void(Ref<FileList>&&)>;
42
    using CompletionHandler = Function<void(Ref<FileList>&&)>;
42
43
43
    enum class ShouldResolveDirectories { No, Yes };
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
49
    ~FileListCreator();
50
    ~FileListCreator();
Lines 51-60 public: a/Source/WebCore/html/FileListCreator.h_sec3
51
    void cancel();
52
    void cancel();
52
53
53
private:
54
private:
54
    FileListCreator(const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories, CompletionHandler&&);
55
    FileListCreator(PAL::SessionID, const Vector<FileChooserFileInfo>& paths, ShouldResolveDirectories, CompletionHandler&&);
55
56
56
    template<ShouldResolveDirectories shouldResolveDirectories>
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
    RefPtr<WorkQueue> m_workQueue;
60
    RefPtr<WorkQueue> m_workQueue;
60
    CompletionHandler m_completionHander;
61
    CompletionHandler m_completionHander;
- a/Source/WebCore/html/HTMLAttachmentElement.cpp -1 / +1 lines
Lines 246-252 void HTMLAttachmentElement::updateEnclosingImageWithData(const String& contentTy a/Source/WebCore/html/HTMLAttachmentElement.cpp_sec1
246
    if (!mimeTypeIsSuitableForInlineImageAttachment(mimeType))
246
    if (!mimeTypeIsSuitableForInlineImageAttachment(mimeType))
247
        return;
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
252
} // namespace WebCore
252
} // namespace WebCore
- a/Source/WebCore/html/HTMLCanvasElement.cpp -2 / +2 lines
Lines 739-745 ExceptionOr<void> HTMLCanvasElement::toBlob(ScriptExecutionContext& context, Ref a/Source/WebCore/html/HTMLCanvasElement.cpp_sec1
739
        RefPtr<Blob> blob;
739
        RefPtr<Blob> blob;
740
        Vector<uint8_t> blobData = data(*imageData, encodingMIMEType, quality);
740
        Vector<uint8_t> blobData = data(*imageData, encodingMIMEType, quality);
741
        if (!blobData.isEmpty())
741
        if (!blobData.isEmpty())
742
            blob = Blob::create(WTFMove(blobData), encodingMIMEType);
742
            blob = Blob::create(context.sessionID(), WTFMove(blobData), encodingMIMEType);
743
        callback->scheduleCallback(context, WTFMove(blob));
743
        callback->scheduleCallback(context, WTFMove(blob));
744
        return { };
744
        return { };
745
    }
745
    }
Lines 750-756 ExceptionOr<void> HTMLCanvasElement::toBlob(ScriptExecutionContext& context, Ref a/Source/WebCore/html/HTMLCanvasElement.cpp_sec2
750
    RefPtr<Blob> blob;
750
    RefPtr<Blob> blob;
751
    Vector<uint8_t> blobData = buffer()->toData(encodingMIMEType, quality);
751
    Vector<uint8_t> blobData = buffer()->toData(encodingMIMEType, quality);
752
    if (!blobData.isEmpty())
752
    if (!blobData.isEmpty())
753
        blob = Blob::create(WTFMove(blobData), encodingMIMEType);
753
        blob = Blob::create(context.sessionID(), WTFMove(blobData), encodingMIMEType);
754
    callback->scheduleCallback(context, WTFMove(blob));
754
    callback->scheduleCallback(context, WTFMove(blob));
755
    return { };
755
    return { };
756
}
756
}
- a/Source/WebCore/page/EventHandler.cpp -1 / +1 lines
Lines 3772-3778 bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDr a/Source/WebCore/page/EventHandler.cpp_sec1
3772
    // This does work only if we missed a dragEnd. Do it anyway, just to make sure the old dataTransfer gets numbed.
3772
    // This does work only if we missed a dragEnd. Do it anyway, just to make sure the old dataTransfer gets numbed.
3773
    invalidateDataTransfer();
3773
    invalidateDataTransfer();
3774
3774
3775
    dragState().dataTransfer = DataTransfer::createForDrag();
3775
    dragState().dataTransfer = DataTransfer::createForDrag(*m_frame.document());
3776
    HasNonDefaultPasteboardData hasNonDefaultPasteboardData = HasNonDefaultPasteboardData::No;
3776
    HasNonDefaultPasteboardData hasNonDefaultPasteboardData = HasNonDefaultPasteboardData::No;
3777
    
3777
    
3778
    if (dragState().shouldDispatchEvents) {
3778
    if (dragState().shouldDispatchEvents) {
- a/Source/WebCore/testing/Internals.cpp -1 / +1 lines
Lines 4251-4257 RefPtr<File> Internals::createFile(const String& path) a/Source/WebCore/testing/Internals.cpp_sec1
4251
    if (!url.isLocalFile())
4251
    if (!url.isLocalFile())
4252
        return nullptr;
4252
        return nullptr;
4253
4253
4254
    return File::create(url.fileSystemPath());
4254
    return File::create(document->sessionID(), url.fileSystemPath());
4255
}
4255
}
4256
4256
4257
void Internals::queueMicroTask(int testNumber)
4257
void Internals::queueMicroTask(int testNumber)
- a/Source/WebCore/testing/ServiceWorkerInternals.cpp -2 / +2 lines
Lines 68-81 Ref<FetchEvent> ServiceWorkerInternals::createBeingDispatchedFetchEvent(ScriptEx a/Source/WebCore/testing/ServiceWorkerInternals.cpp_sec1
68
68
69
Ref<FetchResponse> ServiceWorkerInternals::createOpaqueWithBlobBodyResponse(ScriptExecutionContext& context)
69
Ref<FetchResponse> ServiceWorkerInternals::createOpaqueWithBlobBodyResponse(ScriptExecutionContext& context)
70
{
70
{
71
    auto blob = Blob::create();
71
    auto blob = Blob::create(context.sessionID());
72
    auto formData = FormData::create();
72
    auto formData = FormData::create();
73
    formData->appendBlob(blob->url());
73
    formData->appendBlob(blob->url());
74
74
75
    ResourceResponse response;
75
    ResourceResponse response;
76
    response.setType(ResourceResponse::Type::Cors);
76
    response.setType(ResourceResponse::Type::Cors);
77
    response.setTainting(ResourceResponse::Tainting::Opaque);
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
    fetchResponse->initializeOpaqueLoadIdentifierForTesting();
79
    fetchResponse->initializeOpaqueLoadIdentifierForTesting();
80
    return fetchResponse;
80
    return fetchResponse;
81
}
81
}
- a/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp -1 / +2 lines
Lines 149-155 void dispatchFetchEvent(Ref<Client>&& client, ServiceWorkerGlobalScope& globalSc a/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp_sec1
149
    auto* formData = request.httpBody();
149
    auto* formData = request.httpBody();
150
    Optional<FetchBody> body;
150
    Optional<FetchBody> body;
151
    if (formData && !formData->isEmpty()) {
151
    if (formData && !formData->isEmpty()) {
152
        body = FetchBody::fromFormData(*formData);
152
        ScriptExecutionContext& context = globalScope;
153
        body = FetchBody::fromFormData(context.sessionID(), *formData);
153
        if (!body) {
154
        if (!body) {
154
            client->didNotHandle();
155
            client->didNotHandle();
155
            return;
156
            return;
- a/Source/WebCore/xml/XMLHttpRequest.cpp -1 / +1 lines
Lines 212-218 Ref<Blob> XMLHttpRequest::createResponseBlob() a/Source/WebCore/xml/XMLHttpRequest.cpp_sec1
212
        data.append(m_binaryResponseBuilder->data(), m_binaryResponseBuilder->size());
212
        data.append(m_binaryResponseBuilder->data(), m_binaryResponseBuilder->size());
213
    m_binaryResponseBuilder = nullptr;
213
    m_binaryResponseBuilder = nullptr;
214
    String normalizedContentType = Blob::normalizedContentType(responseMIMEType()); // responseMIMEType defaults to text/xml which may be incorrect.
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
218
RefPtr<ArrayBuffer> XMLHttpRequest::createResponseArrayBuffer()
218
RefPtr<ArrayBuffer> XMLHttpRequest::createResponseArrayBuffer()

Return to Bug 200572