Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 computed_pixel_length.ValueOrDie() != pixel_length) | 298 computed_pixel_length.ValueOrDie() != pixel_length) |
| 291 return nullptr; | 299 return nullptr; |
| 292 ImageData* image_data = ImageData::Create(IntSize(width, height)); | 300 ImageData* image_data = ImageData::Create(IntSize(width, height)); |
| 293 if (!image_data) | 301 if (!image_data) |
| 294 return nullptr; | 302 return nullptr; |
| 295 DOMUint8ClampedArray* pixel_array = image_data->data(); | 303 DOMUint8ClampedArray* pixel_array = image_data->data(); |
| 296 DCHECK_EQ(pixel_array->length(), pixel_length); | 304 DCHECK_EQ(pixel_array->length(), pixel_length); |
| 297 memcpy(pixel_array->Data(), pixels, pixel_length); | 305 memcpy(pixel_array->Data(), pixels, pixel_length); |
| 298 return image_data; | 306 return image_data; |
| 299 } | 307 } |
| 308 case kDOMPointTag: { | |
| 309 double x = 0, y = 0, z = 0, w = 1; | |
| 310 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&z) || | |
| 311 !ReadDouble(&w)) | |
| 312 return nullptr; | |
| 313 DOMPoint* point = DOMPoint::Create(x, y, z, w); | |
| 314 if (!point) | |
|
jbroman
2017/05/15 18:00:30
nit: These null checks don't really add much (exce
fserb
2017/05/15 18:27:28
yep. done.
| |
| 315 return nullptr; | |
| 316 return point; | |
| 317 } | |
| 318 case kDOMPointReadOnlyTag: { | |
| 319 double x = 0, y = 0, z = 0, w = 1; | |
| 320 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&z) || | |
| 321 !ReadDouble(&w)) | |
| 322 return nullptr; | |
| 323 DOMPointReadOnly* point = DOMPointReadOnly::Create(x, y, z, w); | |
| 324 if (!point) | |
| 325 return nullptr; | |
| 326 return point; | |
| 327 } | |
| 328 case kDOMRectTag: { | |
| 329 double x = 0, y = 0, width = 0, height = 0; | |
| 330 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&width) || | |
| 331 !ReadDouble(&height)) | |
| 332 return nullptr; | |
| 333 DOMRect* rect = DOMRect::Create(x, y, width, height); | |
| 334 if (!rect) | |
| 335 return nullptr; | |
| 336 return rect; | |
| 337 } | |
| 338 case kDOMRectReadOnlyTag: { | |
| 339 double x = 0, y = 0, width = 0, height = 0; | |
| 340 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&width) || | |
| 341 !ReadDouble(&height)) | |
| 342 return nullptr; | |
| 343 DOMRectReadOnly* rect = DOMRectReadOnly::Create(x, y, width, height); | |
| 344 if (!rect) | |
| 345 return nullptr; | |
| 346 return rect; | |
| 347 } | |
| 348 case kDOMQuadTag: { | |
| 349 DOMPointInit pointInits[4]; | |
| 350 for (DOMPointInit& init : pointInits) { | |
| 351 double x = 0, y = 0, z = 0, w = 0; | |
| 352 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&z) || | |
| 353 !ReadDouble(&w)) | |
| 354 return nullptr; | |
| 355 init.setX(x); | |
| 356 init.setY(y); | |
| 357 init.setZ(z); | |
| 358 init.setW(w); | |
| 359 } | |
| 360 DOMQuad* quad = DOMQuad::Create(pointInits[0], pointInits[1], | |
| 361 pointInits[2], pointInits[3]); | |
| 362 if (!quad) | |
| 363 return nullptr; | |
| 364 return quad; | |
| 365 } | |
| 366 case kDOMMatrix2DTag: { | |
| 367 double values[6]; | |
| 368 for (double& d : values) { | |
| 369 if (!ReadDouble(&d)) | |
| 370 return nullptr; | |
| 371 } | |
| 372 DOMMatrix* matrix = | |
| 373 DOMMatrix::CreateForSerialization(values, WTF_ARRAY_LENGTH(values)); | |
| 374 if (!matrix) | |
| 375 return nullptr; | |
| 376 return matrix; | |
| 377 } | |
| 378 case kDOMMatrix2DReadOnlyTag: { | |
| 379 double values[6]; | |
| 380 for (double& d : values) { | |
| 381 if (!ReadDouble(&d)) | |
| 382 return nullptr; | |
| 383 } | |
| 384 DOMMatrixReadOnly* matrix = DOMMatrixReadOnly::CreateForSerialization( | |
| 385 values, WTF_ARRAY_LENGTH(values)); | |
| 386 if (!matrix) | |
| 387 return nullptr; | |
| 388 return matrix; | |
| 389 } | |
| 390 case kDOMMatrixTag: { | |
| 391 double values[16]; | |
| 392 for (double& d : values) { | |
| 393 if (!ReadDouble(&d)) | |
| 394 return nullptr; | |
| 395 } | |
| 396 DOMMatrix* matrix = | |
| 397 DOMMatrix::CreateForSerialization(values, WTF_ARRAY_LENGTH(values)); | |
| 398 if (!matrix) | |
| 399 return nullptr; | |
| 400 return matrix; | |
| 401 } | |
| 402 case kDOMMatrixReadOnlyTag: { | |
| 403 double values[16]; | |
| 404 for (double& d : values) { | |
| 405 if (!ReadDouble(&d)) | |
| 406 return nullptr; | |
| 407 } | |
| 408 DOMMatrixReadOnly* matrix = DOMMatrixReadOnly::CreateForSerialization( | |
| 409 values, WTF_ARRAY_LENGTH(values)); | |
| 410 if (!matrix) | |
| 411 return nullptr; | |
| 412 return matrix; | |
| 413 } | |
| 300 case kMessagePortTag: { | 414 case kMessagePortTag: { |
| 301 uint32_t index = 0; | 415 uint32_t index = 0; |
| 302 if (!ReadUint32(&index) || !transferred_message_ports_ || | 416 if (!ReadUint32(&index) || !transferred_message_ports_ || |
| 303 index >= transferred_message_ports_->size()) | 417 index >= transferred_message_ports_->size()) |
| 304 return nullptr; | 418 return nullptr; |
| 305 return (*transferred_message_ports_)[index].Get(); | 419 return (*transferred_message_ports_)[index].Get(); |
| 306 } | 420 } |
| 307 case kOffscreenCanvasTransferTag: { | 421 case kOffscreenCanvasTransferTag: { |
| 308 uint32_t width = 0, height = 0, canvas_id = 0, client_id = 0, sink_id = 0; | 422 uint32_t width = 0, height = 0, canvas_id = 0, client_id = 0, sink_id = 0; |
| 309 if (!ReadUint32(&width) || !ReadUint32(&height) || | 423 if (!ReadUint32(&width) || !ReadUint32(&height) || |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 uint32_t id) { | 528 uint32_t id) { |
| 415 if (id < serialized_script_value_->WasmModules().size()) { | 529 if (id < serialized_script_value_->WasmModules().size()) { |
| 416 return v8::WasmCompiledModule::FromTransferrableModule( | 530 return v8::WasmCompiledModule::FromTransferrableModule( |
| 417 isolate, serialized_script_value_->WasmModules()[id]); | 531 isolate, serialized_script_value_->WasmModules()[id]); |
| 418 } | 532 } |
| 419 CHECK(serialized_script_value_->WasmModules().IsEmpty()); | 533 CHECK(serialized_script_value_->WasmModules().IsEmpty()); |
| 420 return v8::MaybeLocal<v8::WasmCompiledModule>(); | 534 return v8::MaybeLocal<v8::WasmCompiledModule>(); |
| 421 } | 535 } |
| 422 | 536 |
| 423 } // namespace blink | 537 } // namespace blink |
| OLD | NEW |