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) | |
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 = DOMRect::Create(x, y, width, height); | |
344 if (!rect) | |
345 return nullptr; | |
346 return rect; | |
347 } | |
348 case kDOMQuadTag: { | |
349 double x = 0, y = 0, z = 0, w = 1; | |
jbroman
2017/05/15 17:02:55
nit: this is a little repetitive to confirm that i
fserb
2017/05/15 17:52:17
much better. I don't know why I just repeteated it
| |
350 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&z) || | |
351 !ReadDouble(&w)) | |
352 return nullptr; | |
353 DOMPointInit pi1; | |
354 pi1.setX(x); | |
355 pi1.setY(y); | |
356 pi1.setZ(z); | |
357 pi1.setW(w); | |
358 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&z) || | |
359 !ReadDouble(&w)) | |
360 return nullptr; | |
361 DOMPointInit pi2; | |
362 pi2.setX(x); | |
363 pi2.setY(y); | |
364 pi2.setZ(z); | |
365 pi2.setW(w); | |
366 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&z) || | |
367 !ReadDouble(&w)) | |
368 return nullptr; | |
369 DOMPointInit pi3; | |
370 pi3.setX(x); | |
371 pi3.setY(y); | |
372 pi3.setZ(z); | |
373 pi3.setW(w); | |
374 if (!ReadDouble(&x) || !ReadDouble(&y) || !ReadDouble(&z) || | |
375 !ReadDouble(&w)) | |
376 return nullptr; | |
377 DOMPointInit pi4; | |
378 pi4.setX(x); | |
379 pi4.setY(y); | |
380 pi4.setZ(z); | |
381 pi4.setW(w); | |
382 DOMQuad* quad = DOMQuad::Create(pi1, pi2, pi3, pi4); | |
383 if (!quad) | |
384 return nullptr; | |
385 return quad; | |
386 } | |
387 case kDOMMatrix2DTag: { | |
simonp
2017/05/15 13:34:18
This is not supported by the spec; per spec all el
fserb
2017/05/15 17:52:17
It was partially unintended. I did it like this be
jbroman
2017/05/15 18:00:30
FWIW, you could just write 0 or 1 as a 32-bit inte
| |
388 double a = 0, b = 0, c = 0, d = 0, e = 0, f = 0; | |
389 if (!ReadDouble(&a) || !ReadDouble(&b) || !ReadDouble(&c) || | |
390 !ReadDouble(&d) || !ReadDouble(&e) || !ReadDouble(&f)) | |
391 return nullptr; | |
392 DOMMatrixInit init; | |
393 init.setIs2D(true); | |
394 init.setA(a); | |
395 init.setB(b); | |
396 init.setC(c); | |
397 init.setD(d); | |
398 init.setE(e); | |
399 init.setF(f); | |
400 DOMMatrix* matrix = DOMMatrix::fromMatrixForSerialization(init); | |
401 if (!matrix) | |
402 return nullptr; | |
403 return matrix; | |
404 } | |
405 case kDOMMatrix2DReadOnlyTag: { | |
406 double a = 0, b = 0, c = 0, d = 0, e = 0, f = 0; | |
407 if (!ReadDouble(&a) || !ReadDouble(&b) || !ReadDouble(&c) || | |
408 !ReadDouble(&d) || !ReadDouble(&e) || !ReadDouble(&f)) | |
409 return nullptr; | |
410 DOMMatrixInit init; | |
411 init.setIs2D(true); | |
412 init.setA(a); | |
413 init.setB(b); | |
414 init.setC(c); | |
415 init.setD(d); | |
416 init.setE(e); | |
417 init.setF(f); | |
418 DOMMatrixReadOnly* matrix = | |
419 DOMMatrixReadOnly::fromMatrixForSerialization(init); | |
420 if (!matrix) | |
421 return nullptr; | |
422 return matrix; | |
423 } | |
424 case kDOMMatrixTag: { | |
425 double m11 = 0, m12 = 0, m13 = 0, m14 = 0; | |
426 double m21 = 0, m22 = 0, m23 = 0, m24 = 0; | |
427 double m31 = 0, m32 = 0, m33 = 0, m34 = 0; | |
428 double m41 = 0, m42 = 0, m43 = 0, m44 = 0; | |
429 if (!ReadDouble(&m11) || !ReadDouble(&m12) || !ReadDouble(&m13) || | |
430 !ReadDouble(&m14) || !ReadDouble(&m21) || !ReadDouble(&m22) || | |
431 !ReadDouble(&m23) || !ReadDouble(&m24) || !ReadDouble(&m31) || | |
432 !ReadDouble(&m32) || !ReadDouble(&m33) || !ReadDouble(&m34) || | |
433 !ReadDouble(&m41) || !ReadDouble(&m42) || !ReadDouble(&m43) || | |
434 !ReadDouble(&m44)) | |
435 return nullptr; | |
436 DOMMatrixInit init; | |
437 init.setIs2D(false); | |
438 init.setM11(m11); | |
439 init.setM12(m12); | |
440 init.setM13(m13); | |
441 init.setM14(m14); | |
442 init.setM21(m21); | |
443 init.setM22(m22); | |
444 init.setM23(m23); | |
445 init.setM24(m24); | |
446 init.setM31(m31); | |
447 init.setM32(m32); | |
448 init.setM33(m33); | |
449 init.setM34(m34); | |
450 init.setM41(m41); | |
451 init.setM42(m42); | |
452 init.setM43(m43); | |
453 init.setM44(m44); | |
454 DOMMatrix* matrix = DOMMatrix::fromMatrixForSerialization(init); | |
jbroman
2017/05/15 17:02:55
Easy to change later, but do you really want to ma
fserb
2017/05/15 17:52:17
done. Also updated the interfaces.
| |
455 if (!matrix) | |
456 return nullptr; | |
457 return matrix; | |
458 } | |
459 case kDOMMatrixReadOnlyTag: { | |
460 double m11 = 0, m12 = 0, m13 = 0, m14 = 0; | |
461 double m21 = 0, m22 = 0, m23 = 0, m24 = 0; | |
462 double m31 = 0, m32 = 0, m33 = 0, m34 = 0; | |
463 double m41 = 0, m42 = 0, m43 = 0, m44 = 0; | |
464 if (!ReadDouble(&m11) || !ReadDouble(&m12) || !ReadDouble(&m13) || | |
465 !ReadDouble(&m14) || !ReadDouble(&m21) || !ReadDouble(&m22) || | |
466 !ReadDouble(&m23) || !ReadDouble(&m24) || !ReadDouble(&m31) || | |
467 !ReadDouble(&m32) || !ReadDouble(&m33) || !ReadDouble(&m34) || | |
468 !ReadDouble(&m41) || !ReadDouble(&m42) || !ReadDouble(&m43) || | |
469 !ReadDouble(&m44)) | |
470 return nullptr; | |
471 DOMMatrixInit init; | |
472 init.setIs2D(false); | |
473 init.setM11(m11); | |
474 init.setM12(m12); | |
475 init.setM13(m13); | |
476 init.setM14(m14); | |
477 init.setM21(m21); | |
478 init.setM22(m22); | |
479 init.setM23(m23); | |
480 init.setM24(m24); | |
481 init.setM31(m31); | |
482 init.setM32(m32); | |
483 init.setM33(m33); | |
484 init.setM34(m34); | |
485 init.setM41(m41); | |
486 init.setM42(m42); | |
487 init.setM43(m43); | |
488 init.setM44(m44); | |
489 DOMMatrixReadOnly* matrix = | |
490 DOMMatrixReadOnly::fromMatrixForSerialization(init); | |
491 if (!matrix) | |
492 return nullptr; | |
493 return matrix; | |
494 } | |
300 case kMessagePortTag: { | 495 case kMessagePortTag: { |
301 uint32_t index = 0; | 496 uint32_t index = 0; |
302 if (!ReadUint32(&index) || !transferred_message_ports_ || | 497 if (!ReadUint32(&index) || !transferred_message_ports_ || |
303 index >= transferred_message_ports_->size()) | 498 index >= transferred_message_ports_->size()) |
304 return nullptr; | 499 return nullptr; |
305 return (*transferred_message_ports_)[index].Get(); | 500 return (*transferred_message_ports_)[index].Get(); |
306 } | 501 } |
307 case kOffscreenCanvasTransferTag: { | 502 case kOffscreenCanvasTransferTag: { |
308 uint32_t width = 0, height = 0, canvas_id = 0, client_id = 0, sink_id = 0; | 503 uint32_t width = 0, height = 0, canvas_id = 0, client_id = 0, sink_id = 0; |
309 if (!ReadUint32(&width) || !ReadUint32(&height) || | 504 if (!ReadUint32(&width) || !ReadUint32(&height) || |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 uint32_t id) { | 609 uint32_t id) { |
415 if (id < serialized_script_value_->WasmModules().size()) { | 610 if (id < serialized_script_value_->WasmModules().size()) { |
416 return v8::WasmCompiledModule::FromTransferrableModule( | 611 return v8::WasmCompiledModule::FromTransferrableModule( |
417 isolate, serialized_script_value_->WasmModules()[id]); | 612 isolate, serialized_script_value_->WasmModules()[id]); |
418 } | 613 } |
419 CHECK(serialized_script_value_->WasmModules().IsEmpty()); | 614 CHECK(serialized_script_value_->WasmModules().IsEmpty()); |
420 return v8::MaybeLocal<v8::WasmCompiledModule>(); | 615 return v8::MaybeLocal<v8::WasmCompiledModule>(); |
421 } | 616 } |
422 | 617 |
423 } // namespace blink | 618 } // namespace blink |
OLD | NEW |