Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl

Issue 2541683002: Make ImageBitmap transfers work in cases that require serialization (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl
diff --git a/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl
index 573953a7913e8eeb0c8f41a1b6c6b724c24a3a9f..c0457dc0a9a85a733a5342bb2bcbab1e309ee4fd 100644
--- a/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl
+++ b/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl
@@ -447,22 +447,24 @@ static void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance,
}
RefPtr<SerializedScriptValue> message;
- if (instance->canTransferArrayBuffer()) {
+ if (instance->canTransferArrayBuffersAndImageBitmaps()) {
// This instance supports sending array buffers by move semantics.
message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &transferables, nullptr, exceptionState);
if (exceptionState.hadException())
return;
} else {
- // This instance doesn't support sending array buffers by move
- // semantics. Emulate it by copy-and-neuter semantics that sends array
- // buffers by copy semantics and then neuters the original array
- // buffers.
-
- // Clear references to array buffers from transferables so that the
- // serializer can consider the array buffers as non-transferable and
- // copy them into the message.
+ // This instance doesn't support sending array buffers and image bitmaps
+ // by move semantics. Emulate it by copy-and-neuter semantics that sends
+ // array buffers and image bitmaps via structured clone and then neuters
+ // the original objects
+
+ // Clear references to array buffers and image bitmaps from transferables
+ // so that the serializer can consider the array buffers as
+ // non-transferable and serialize them into the message.
ArrayBufferArray transferableArrayBuffers = transferables.arrayBuffers;
transferables.arrayBuffers.clear();
+ ImageBitmapArray transferableImageBitmaps = transferables.imageBitmaps;
+ transferables.imageBitmaps.clear();
message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &transferables, nullptr, exceptionState);
if (exceptionState.hadException())
return;
@@ -471,6 +473,10 @@ static void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance,
SerializedScriptValue::transferArrayBufferContents(info.GetIsolate(), transferableArrayBuffers, exceptionState);
if (exceptionState.hadException())
return;
+ // Neuter the original image bitmaps on the sender context.
+ SerializedScriptValue::transferImageBitmapContents(info.GetIsolate(), transferableImageBitmaps, exceptionState);
+ if (exceptionState.hadException())
+ return;
}
// FIXME: Only pass context/exceptionState if instance really requires it.

Powered by Google App Engine
This is Rietveld 408576698