| Index: third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp b/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp
|
| index bc1e32f4a090fdb4f9d5092eab00f52cbc79609f..ed681e0a95c93d5333861830ebacbee296411800 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp
|
| @@ -38,6 +38,7 @@
|
| #include "bindings/core/v8/ScriptValueSerializer.h"
|
| #include "bindings/core/v8/SerializedScriptValueFactory.h"
|
| #include "bindings/core/v8/V8ArrayBuffer.h"
|
| +#include "bindings/core/v8/V8ImageBitmap.h"
|
| #include "bindings/core/v8/V8MessagePort.h"
|
| #include "bindings/core/v8/V8SharedArrayBuffer.h"
|
| #include "core/dom/ExceptionCode.h"
|
| @@ -101,6 +102,29 @@ static void acculumateArrayBuffersForAllWorlds(v8::Isolate* isolate, DOMArrayBuf
|
| }
|
| }
|
|
|
| +PassOwnPtr<SerializedScriptValue::ImageBitmapContentsArray> SerializedScriptValue::createImageBitmaps(v8::Isolate* isolate, ImageBitmapArray& imageBitmaps, ExceptionState& exceptionState)
|
| +{
|
| + ASSERT(imageBitmaps.size());
|
| +
|
| + for (size_t i = 0; i < imageBitmaps.size(); i++) {
|
| + if (imageBitmaps[i]->isNeutered()) {
|
| + exceptionState.throwDOMException(DataCloneError, "ImageBitmap at index " + String::number(i) + " is already neutered.");
|
| + return nullptr;
|
| + }
|
| + }
|
| +
|
| + OwnPtr<ImageBitmapContentsArray> contents = adoptPtr(new ImageBitmapContentsArray);
|
| + WillBeHeapHashSet<RawPtrWillBeMember<ImageBitmap>> visited;
|
| + for (ImageBitmap* imageBitmap : imageBitmaps) {
|
| + if (visited.contains(imageBitmap))
|
| + continue;
|
| + visited.add(imageBitmap);
|
| + contents->append(imageBitmap->transfer());
|
| + }
|
| + return contents.release();
|
| +}
|
| +
|
| +
|
| PassOwnPtr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValue::createArrayBuffers(v8::Isolate* isolate, ArrayBufferArray& arrayBuffers, ExceptionState& exceptionState)
|
| {
|
| ASSERT(arrayBuffers.size());
|
| @@ -169,11 +193,12 @@ v8::Local<v8::Value> SerializedScriptValue::deserialize(v8::Isolate* isolate, Me
|
| return SerializedScriptValueFactory::instance().deserialize(this, isolate, messagePorts, blobInfo);
|
| }
|
|
|
| -bool SerializedScriptValue::extractTransferables(v8::Isolate* isolate, v8::Local<v8::Value> value, int argumentIndex, MessagePortArray& ports, ArrayBufferArray& arrayBuffers, ExceptionState& exceptionState)
|
| +bool SerializedScriptValue::extractTransferables(v8::Isolate* isolate, v8::Local<v8::Value> value, int argumentIndex, MessagePortArray& ports, ArrayBufferArray& arrayBuffers, ImageBitmapArray& imageBitmaps, ExceptionState& exceptionState)
|
| {
|
| if (isUndefinedOrNull(value)) {
|
| ports.resize(0);
|
| arrayBuffers.resize(0);
|
| + imageBitmaps.resize(0);
|
| return true;
|
| }
|
|
|
| @@ -222,6 +247,13 @@ bool SerializedScriptValue::extractTransferables(v8::Isolate* isolate, v8::Local
|
| return false;
|
| }
|
| arrayBuffers.append(sharedArrayBuffer.release());
|
| + } else if (V8ImageBitmap::hasInstance(transferrable, isolate)) {
|
| + RefPtrWillBeRawPtr<ImageBitmap> imageBitmap = V8ImageBitmap::toImpl(v8::Local<v8::Object>::Cast(transferrable));
|
| + if (imageBitmaps.contains(imageBitmap)) {
|
| + exceptionState.throwDOMException(DataCloneError, "ImageBitmap at index " + String::number(i) + " is a duplicate of an earlier ImageBitmap.");
|
| + return false;
|
| + }
|
| + imageBitmaps.append(imageBitmap.release());
|
| } else {
|
| exceptionState.throwTypeError("Value at index " + String::number(i) + " does not have a transferable type.");
|
| return false;
|
| @@ -259,4 +291,9 @@ void SerializedScriptValue::transferArrayBuffers(v8::Isolate* isolate, ArrayBuff
|
| m_arrayBufferContentsArray = createArrayBuffers(isolate, arrayBuffers, exceptionState);
|
| }
|
|
|
| +void SerializedScriptValue::transferImageBitmaps(v8::Isolate* isolate, ImageBitmapArray& imageBitmaps, ExceptionState& exceptionState)
|
| +{
|
| + m_imageBitmapContentsArray = createImageBitmaps(isolate, imageBitmaps, exceptionState);
|
| +}
|
| +
|
| } // namespace blink
|
|
|