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/V8ScriptValueSerializer.h" | 5 #include "bindings/core/v8/serialization/V8ScriptValueSerializer.h" |
6 | 6 |
7 #include "bindings/core/v8/ToV8ForCore.h" | 7 #include "bindings/core/v8/ToV8ForCore.h" |
8 #include "bindings/core/v8/V8Blob.h" | 8 #include "bindings/core/v8/V8Blob.h" |
9 #include "bindings/core/v8/V8CompositorProxy.h" | 9 #include "bindings/core/v8/V8CompositorProxy.h" |
| 10 #include "bindings/core/v8/V8DOMMatrix.h" |
| 11 #include "bindings/core/v8/V8DOMMatrixReadOnly.h" |
| 12 #include "bindings/core/v8/V8DOMPoint.h" |
| 13 #include "bindings/core/v8/V8DOMPointReadOnly.h" |
| 14 #include "bindings/core/v8/V8DOMQuad.h" |
| 15 #include "bindings/core/v8/V8DOMRect.h" |
| 16 #include "bindings/core/v8/V8DOMRectReadOnly.h" |
10 #include "bindings/core/v8/V8File.h" | 17 #include "bindings/core/v8/V8File.h" |
11 #include "bindings/core/v8/V8FileList.h" | 18 #include "bindings/core/v8/V8FileList.h" |
12 #include "bindings/core/v8/V8ImageBitmap.h" | 19 #include "bindings/core/v8/V8ImageBitmap.h" |
13 #include "bindings/core/v8/V8ImageData.h" | 20 #include "bindings/core/v8/V8ImageData.h" |
14 #include "bindings/core/v8/V8MessagePort.h" | 21 #include "bindings/core/v8/V8MessagePort.h" |
15 #include "bindings/core/v8/V8OffscreenCanvas.h" | 22 #include "bindings/core/v8/V8OffscreenCanvas.h" |
16 #include "bindings/core/v8/V8SharedArrayBuffer.h" | 23 #include "bindings/core/v8/V8SharedArrayBuffer.h" |
17 #include "bindings/core/v8/V8ThrowDOMException.h" | 24 #include "bindings/core/v8/V8ThrowDOMException.h" |
18 #include "core/dom/DOMArrayBufferBase.h" | 25 #include "core/dom/DOMArrayBufferBase.h" |
| 26 #include "core/geometry/DOMMatrix.h" |
| 27 #include "core/geometry/DOMMatrixReadOnly.h" |
| 28 #include "core/geometry/DOMPoint.h" |
| 29 #include "core/geometry/DOMPointReadOnly.h" |
| 30 #include "core/geometry/DOMQuad.h" |
| 31 #include "core/geometry/DOMRect.h" |
| 32 #include "core/geometry/DOMRectReadOnly.h" |
19 #include "core/html/ImageData.h" | 33 #include "core/html/ImageData.h" |
20 #include "platform/RuntimeEnabledFeatures.h" | 34 #include "platform/RuntimeEnabledFeatures.h" |
21 #include "platform/wtf/AutoReset.h" | 35 #include "platform/wtf/AutoReset.h" |
22 #include "platform/wtf/DateMath.h" | 36 #include "platform/wtf/DateMath.h" |
23 #include "platform/wtf/allocator/Partitions.h" | 37 #include "platform/wtf/allocator/Partitions.h" |
24 #include "platform/wtf/text/StringUTF8Adaptor.h" | 38 #include "platform/wtf/text/StringUTF8Adaptor.h" |
25 #include "public/platform/WebBlobInfo.h" | 39 #include "public/platform/WebBlobInfo.h" |
26 | 40 |
27 namespace blink { | 41 namespace blink { |
28 | 42 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 if (wrapper_type_info == &V8ImageData::wrapperTypeInfo) { | 275 if (wrapper_type_info == &V8ImageData::wrapperTypeInfo) { |
262 ImageData* image_data = wrappable->ToImpl<ImageData>(); | 276 ImageData* image_data = wrappable->ToImpl<ImageData>(); |
263 DOMUint8ClampedArray* pixels = image_data->data(); | 277 DOMUint8ClampedArray* pixels = image_data->data(); |
264 WriteTag(kImageDataTag); | 278 WriteTag(kImageDataTag); |
265 WriteUint32(image_data->width()); | 279 WriteUint32(image_data->width()); |
266 WriteUint32(image_data->height()); | 280 WriteUint32(image_data->height()); |
267 WriteUint32(pixels->length()); | 281 WriteUint32(pixels->length()); |
268 WriteRawBytes(pixels->Data(), pixels->length()); | 282 WriteRawBytes(pixels->Data(), pixels->length()); |
269 return true; | 283 return true; |
270 } | 284 } |
| 285 if (wrapper_type_info == &V8DOMPoint::wrapperTypeInfo) { |
| 286 DOMPoint* point = wrappable->ToImpl<DOMPoint>(); |
| 287 WriteTag(kDOMPointTag); |
| 288 WriteDouble(point->x()); |
| 289 WriteDouble(point->y()); |
| 290 WriteDouble(point->z()); |
| 291 WriteDouble(point->w()); |
| 292 return true; |
| 293 } |
| 294 if (wrapper_type_info == &V8DOMPointReadOnly::wrapperTypeInfo) { |
| 295 DOMPointReadOnly* point = wrappable->ToImpl<DOMPointReadOnly>(); |
| 296 WriteTag(kDOMPointReadOnlyTag); |
| 297 WriteDouble(point->x()); |
| 298 WriteDouble(point->y()); |
| 299 WriteDouble(point->z()); |
| 300 WriteDouble(point->w()); |
| 301 return true; |
| 302 } |
| 303 if (wrapper_type_info == &V8DOMRect::wrapperTypeInfo) { |
| 304 DOMRect* rect = wrappable->ToImpl<DOMRect>(); |
| 305 WriteTag(kDOMRectTag); |
| 306 WriteDouble(rect->x()); |
| 307 WriteDouble(rect->y()); |
| 308 WriteDouble(rect->width()); |
| 309 WriteDouble(rect->height()); |
| 310 return true; |
| 311 } |
| 312 if (wrapper_type_info == &V8DOMRectReadOnly::wrapperTypeInfo) { |
| 313 DOMRectReadOnly* rect = wrappable->ToImpl<DOMRectReadOnly>(); |
| 314 WriteTag(kDOMRectReadOnlyTag); |
| 315 WriteDouble(rect->x()); |
| 316 WriteDouble(rect->y()); |
| 317 WriteDouble(rect->width()); |
| 318 WriteDouble(rect->height()); |
| 319 return true; |
| 320 } |
| 321 if (wrapper_type_info == &V8DOMQuad::wrapperTypeInfo) { |
| 322 DOMQuad* quad = wrappable->ToImpl<DOMQuad>(); |
| 323 WriteTag(kDOMQuadTag); |
| 324 for (const DOMPoint* point : |
| 325 {quad->p1(), quad->p2(), quad->p3(), quad->p4()}) { |
| 326 WriteDouble(point->x()); |
| 327 WriteDouble(point->y()); |
| 328 WriteDouble(point->z()); |
| 329 WriteDouble(point->w()); |
| 330 } |
| 331 return true; |
| 332 } |
| 333 if (wrapper_type_info == &V8DOMMatrix::wrapperTypeInfo) { |
| 334 DOMMatrix* matrix = wrappable->ToImpl<DOMMatrix>(); |
| 335 if (matrix->is2D()) { |
| 336 WriteTag(kDOMMatrix2DTag); |
| 337 WriteDouble(matrix->a()); |
| 338 WriteDouble(matrix->b()); |
| 339 WriteDouble(matrix->c()); |
| 340 WriteDouble(matrix->d()); |
| 341 WriteDouble(matrix->e()); |
| 342 WriteDouble(matrix->f()); |
| 343 } else { |
| 344 WriteTag(kDOMMatrixTag); |
| 345 WriteDouble(matrix->m11()); |
| 346 WriteDouble(matrix->m12()); |
| 347 WriteDouble(matrix->m13()); |
| 348 WriteDouble(matrix->m14()); |
| 349 WriteDouble(matrix->m21()); |
| 350 WriteDouble(matrix->m22()); |
| 351 WriteDouble(matrix->m23()); |
| 352 WriteDouble(matrix->m24()); |
| 353 WriteDouble(matrix->m31()); |
| 354 WriteDouble(matrix->m32()); |
| 355 WriteDouble(matrix->m33()); |
| 356 WriteDouble(matrix->m34()); |
| 357 WriteDouble(matrix->m41()); |
| 358 WriteDouble(matrix->m42()); |
| 359 WriteDouble(matrix->m43()); |
| 360 WriteDouble(matrix->m44()); |
| 361 } |
| 362 return true; |
| 363 } |
| 364 if (wrapper_type_info == &V8DOMMatrixReadOnly::wrapperTypeInfo) { |
| 365 DOMMatrixReadOnly* matrix = wrappable->ToImpl<DOMMatrixReadOnly>(); |
| 366 if (matrix->is2D()) { |
| 367 WriteTag(kDOMMatrix2DReadOnlyTag); |
| 368 WriteDouble(matrix->a()); |
| 369 WriteDouble(matrix->b()); |
| 370 WriteDouble(matrix->c()); |
| 371 WriteDouble(matrix->d()); |
| 372 WriteDouble(matrix->e()); |
| 373 WriteDouble(matrix->f()); |
| 374 } else { |
| 375 WriteTag(kDOMMatrixReadOnlyTag); |
| 376 WriteDouble(matrix->m11()); |
| 377 WriteDouble(matrix->m12()); |
| 378 WriteDouble(matrix->m13()); |
| 379 WriteDouble(matrix->m14()); |
| 380 WriteDouble(matrix->m21()); |
| 381 WriteDouble(matrix->m22()); |
| 382 WriteDouble(matrix->m23()); |
| 383 WriteDouble(matrix->m24()); |
| 384 WriteDouble(matrix->m31()); |
| 385 WriteDouble(matrix->m32()); |
| 386 WriteDouble(matrix->m33()); |
| 387 WriteDouble(matrix->m34()); |
| 388 WriteDouble(matrix->m41()); |
| 389 WriteDouble(matrix->m42()); |
| 390 WriteDouble(matrix->m43()); |
| 391 WriteDouble(matrix->m44()); |
| 392 } |
| 393 return true; |
| 394 } |
271 if (wrapper_type_info == &V8MessagePort::wrapperTypeInfo) { | 395 if (wrapper_type_info == &V8MessagePort::wrapperTypeInfo) { |
272 MessagePort* message_port = wrappable->ToImpl<MessagePort>(); | 396 MessagePort* message_port = wrappable->ToImpl<MessagePort>(); |
273 size_t index = kNotFound; | 397 size_t index = kNotFound; |
274 if (transferables_) | 398 if (transferables_) |
275 index = transferables_->message_ports.Find(message_port); | 399 index = transferables_->message_ports.Find(message_port); |
276 if (index == kNotFound) { | 400 if (index == kNotFound) { |
277 exception_state.ThrowDOMException( | 401 exception_state.ThrowDOMException( |
278 kDataCloneError, | 402 kDataCloneError, |
279 "A MessagePort could not be cloned because it was not transferred."); | 403 "A MessagePort could not be cloned because it was not transferred."); |
280 return false; | 404 return false; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 *actual_size = WTF::Partitions::BufferActualSize(size); | 609 *actual_size = WTF::Partitions::BufferActualSize(size); |
486 return WTF::Partitions::BufferRealloc(old_buffer, *actual_size, | 610 return WTF::Partitions::BufferRealloc(old_buffer, *actual_size, |
487 "SerializedScriptValue buffer"); | 611 "SerializedScriptValue buffer"); |
488 } | 612 } |
489 | 613 |
490 void V8ScriptValueSerializer::FreeBufferMemory(void* buffer) { | 614 void V8ScriptValueSerializer::FreeBufferMemory(void* buffer) { |
491 return WTF::Partitions::BufferFree(buffer); | 615 return WTF::Partitions::BufferFree(buffer); |
492 } | 616 } |
493 | 617 |
494 } // namespace blink | 618 } // namespace blink |
OLD | NEW |