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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueDeserializer.cpp

Issue 2874203003: Implement serialization/deserialization of geometry interfaces (Closed)
Patch Set: x Created 3 years, 6 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/serialization/V8ScriptValueDeserializer.h" 5 #include "bindings/core/v8/serialization/V8ScriptValueDeserializer.h"
6 6
7 #include "bindings/core/v8/ToV8ForCore.h" 7 #include "bindings/core/v8/ToV8ForCore.h"
8 #include "core/dom/CompositorProxy.h" 8 #include "core/dom/CompositorProxy.h"
9 #include "core/dom/DOMArrayBuffer.h" 9 #include "core/dom/DOMArrayBuffer.h"
10 #include "core/dom/DOMSharedArrayBuffer.h" 10 #include "core/dom/DOMSharedArrayBuffer.h"
11 #include "core/dom/ExecutionContext.h" 11 #include "core/dom/ExecutionContext.h"
12 #include "core/dom/MessagePort.h" 12 #include "core/dom/MessagePort.h"
13 #include "core/fileapi/Blob.h" 13 #include "core/fileapi/Blob.h"
14 #include "core/fileapi/File.h" 14 #include "core/fileapi/File.h"
15 #include "core/fileapi/FileList.h" 15 #include "core/fileapi/FileList.h"
16 #include "core/frame/ImageBitmap.h" 16 #include "core/frame/ImageBitmap.h"
17 #include "core/geometry/DOMMatrix.h"
18 #include "core/geometry/DOMMatrixReadOnly.h"
19 #include "core/geometry/DOMPoint.h"
20 #include "core/geometry/DOMPointInit.h"
21 #include "core/geometry/DOMPointReadOnly.h"
22 #include "core/geometry/DOMQuad.h"
23 #include "core/geometry/DOMRect.h"
24 #include "core/geometry/DOMRectReadOnly.h"
17 #include "core/html/ImageData.h" 25 #include "core/html/ImageData.h"
18 #include "core/offscreencanvas/OffscreenCanvas.h" 26 #include "core/offscreencanvas/OffscreenCanvas.h"
19 #include "platform/RuntimeEnabledFeatures.h" 27 #include "platform/RuntimeEnabledFeatures.h"
20 #include "platform/graphics/CompositorMutableProperties.h" 28 #include "platform/graphics/CompositorMutableProperties.h"
21 #include "platform/wtf/CheckedNumeric.h" 29 #include "platform/wtf/CheckedNumeric.h"
22 #include "platform/wtf/DateMath.h" 30 #include "platform/wtf/DateMath.h"
23 #include "public/platform/WebBlobInfo.h" 31 #include "public/platform/WebBlobInfo.h"
24 32
25 namespace blink { 33 namespace blink {
26 34
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 computed_pixel_length.ValueOrDie() != pixel_length) 287 computed_pixel_length.ValueOrDie() != pixel_length)
280 return nullptr; 288 return nullptr;
281 ImageData* image_data = ImageData::Create(IntSize(width, height)); 289 ImageData* image_data = ImageData::Create(IntSize(width, height));
282 if (!image_data) 290 if (!image_data)
283 return nullptr; 291 return nullptr;
284 DOMUint8ClampedArray* pixel_array = image_data->data(); 292 DOMUint8ClampedArray* pixel_array = image_data->data();
285 DCHECK_EQ(pixel_array->length(), pixel_length); 293 DCHECK_EQ(pixel_array->length(), pixel_length);
286 memcpy(pixel_array->Data(), pixels, pixel_length); 294 memcpy(pixel_array->Data(), pixels, pixel_length);
287 return image_data; 295 return image_data;
288 } 296 }
297 case kDOMPointTag: {
298 double x = 0, y = 0, z = 0, w = 1;
299 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&z) ||
300 !ReadDouble(&w))
301 return nullptr;
302 return DOMPoint::Create(x, y, z, w);
303 }
304 case kDOMPointReadOnlyTag: {
305 double x = 0, y = 0, z = 0, w = 1;
306 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&z) ||
307 !ReadDouble(&w))
308 return nullptr;
309 return DOMPointReadOnly::Create(x, y, z, w);
310 }
311 case kDOMRectTag: {
312 double x = 0, y = 0, width = 0, height = 0;
313 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&width) ||
314 !ReadDouble(&height))
315 return nullptr;
316 return DOMRect::Create(x, y, width, height);
317 }
318 case kDOMRectReadOnlyTag: {
319 double x = 0, y = 0, width = 0, height = 0;
320 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&width) ||
321 !ReadDouble(&height))
322 return nullptr;
323 return DOMRectReadOnly::Create(x, y, width, height);
324 }
325 case kDOMQuadTag: {
326 DOMPointInit pointInits[4];
327 for (DOMPointInit& init : pointInits) {
328 double x = 0, y = 0, z = 0, w = 0;
329 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&z) ||
330 !ReadDouble(&w))
331 return nullptr;
332 init.setX(x);
333 init.setY(y);
334 init.setZ(z);
335 init.setW(w);
336 }
337 return DOMQuad::Create(pointInits[0], pointInits[1], pointInits[2],
338 pointInits[3]);
339 }
340 case kDOMMatrix2DTag: {
341 double values[6];
342 for (double& d : values) {
343 if (!ReadDouble(&d))
344 return nullptr;
345 }
346 return DOMMatrix::CreateForSerialization(values,
347 WTF_ARRAY_LENGTH(values));
348 }
349 case kDOMMatrix2DReadOnlyTag: {
350 double values[6];
351 for (double& d : values) {
352 if (!ReadDouble(&d))
353 return nullptr;
354 }
355 return DOMMatrixReadOnly::CreateForSerialization(
356 values, WTF_ARRAY_LENGTH(values));
357 }
358 case kDOMMatrixTag: {
359 double values[16];
360 for (double& d : values) {
361 if (!ReadDouble(&d))
362 return nullptr;
363 }
364 return DOMMatrix::CreateForSerialization(values,
365 WTF_ARRAY_LENGTH(values));
366 }
367 case kDOMMatrixReadOnlyTag: {
368 double values[16];
369 for (double& d : values) {
370 if (!ReadDouble(&d))
371 return nullptr;
372 }
373 return DOMMatrixReadOnly::CreateForSerialization(
374 values, WTF_ARRAY_LENGTH(values));
375 }
289 case kMessagePortTag: { 376 case kMessagePortTag: {
290 uint32_t index = 0; 377 uint32_t index = 0;
291 if (!ReadUint32(&index) || !transferred_message_ports_ || 378 if (!ReadUint32(&index) || !transferred_message_ports_ ||
292 index >= transferred_message_ports_->size()) 379 index >= transferred_message_ports_->size())
293 return nullptr; 380 return nullptr;
294 return (*transferred_message_ports_)[index].Get(); 381 return (*transferred_message_ports_)[index].Get();
295 } 382 }
296 case kOffscreenCanvasTransferTag: { 383 case kOffscreenCanvasTransferTag: {
297 uint32_t width = 0, height = 0, canvas_id = 0, client_id = 0, sink_id = 0; 384 uint32_t width = 0, height = 0, canvas_id = 0, client_id = 0, sink_id = 0;
298 if (!ReadUint32(&width) || !ReadUint32(&height) || 385 if (!ReadUint32(&width) || !ReadUint32(&height) ||
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 uint32_t id) { 490 uint32_t id) {
404 if (id < serialized_script_value_->WasmModules().size()) { 491 if (id < serialized_script_value_->WasmModules().size()) {
405 return v8::WasmCompiledModule::FromTransferrableModule( 492 return v8::WasmCompiledModule::FromTransferrableModule(
406 isolate, serialized_script_value_->WasmModules()[id]); 493 isolate, serialized_script_value_->WasmModules()[id]);
407 } 494 }
408 CHECK(serialized_script_value_->WasmModules().IsEmpty()); 495 CHECK(serialized_script_value_->WasmModules().IsEmpty());
409 return v8::MaybeLocal<v8::WasmCompiledModule>(); 496 return v8::MaybeLocal<v8::WasmCompiledModule>();
410 } 497 }
411 498
412 } // namespace blink 499 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698