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/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 WriteDouble(quad->p1()->x()); | |
|
jbroman
2017/05/15 17:02:55
nit: or, this could be:
for (const DOMPoint* poin
fserb
2017/05/15 17:52:17
much better. ;)
| |
| 325 WriteDouble(quad->p1()->y()); | |
| 326 WriteDouble(quad->p1()->z()); | |
| 327 WriteDouble(quad->p1()->w()); | |
| 328 WriteDouble(quad->p2()->x()); | |
| 329 WriteDouble(quad->p2()->y()); | |
| 330 WriteDouble(quad->p2()->z()); | |
| 331 WriteDouble(quad->p2()->w()); | |
| 332 WriteDouble(quad->p3()->x()); | |
| 333 WriteDouble(quad->p3()->y()); | |
| 334 WriteDouble(quad->p3()->z()); | |
| 335 WriteDouble(quad->p3()->w()); | |
| 336 WriteDouble(quad->p4()->x()); | |
| 337 WriteDouble(quad->p4()->y()); | |
| 338 WriteDouble(quad->p4()->z()); | |
| 339 WriteDouble(quad->p4()->w()); | |
| 340 return true; | |
| 341 } | |
| 342 if (wrapper_type_info == &V8DOMMatrix::wrapperTypeInfo) { | |
| 343 DOMMatrix* matrix = wrappable->ToImpl<DOMMatrix>(); | |
| 344 if (matrix->is2D()) { | |
| 345 WriteTag(kDOMMatrix2DTag); | |
| 346 WriteDouble(matrix->a()); | |
| 347 WriteDouble(matrix->b()); | |
| 348 WriteDouble(matrix->c()); | |
| 349 WriteDouble(matrix->d()); | |
| 350 WriteDouble(matrix->e()); | |
| 351 WriteDouble(matrix->f()); | |
| 352 } else { | |
| 353 WriteTag(kDOMMatrixTag); | |
| 354 WriteDouble(matrix->m11()); | |
| 355 WriteDouble(matrix->m12()); | |
| 356 WriteDouble(matrix->m13()); | |
| 357 WriteDouble(matrix->m14()); | |
| 358 WriteDouble(matrix->m21()); | |
| 359 WriteDouble(matrix->m22()); | |
| 360 WriteDouble(matrix->m23()); | |
| 361 WriteDouble(matrix->m24()); | |
| 362 WriteDouble(matrix->m31()); | |
| 363 WriteDouble(matrix->m32()); | |
| 364 WriteDouble(matrix->m33()); | |
| 365 WriteDouble(matrix->m34()); | |
| 366 WriteDouble(matrix->m41()); | |
| 367 WriteDouble(matrix->m42()); | |
| 368 WriteDouble(matrix->m43()); | |
| 369 WriteDouble(matrix->m44()); | |
| 370 } | |
| 371 return true; | |
| 372 } | |
| 373 if (wrapper_type_info == &V8DOMMatrixReadOnly::wrapperTypeInfo) { | |
| 374 DOMMatrixReadOnly* matrix = wrappable->ToImpl<DOMMatrixReadOnly>(); | |
| 375 if (matrix->is2D()) { | |
| 376 WriteTag(kDOMMatrix2DReadOnlyTag); | |
| 377 WriteDouble(matrix->a()); | |
| 378 WriteDouble(matrix->b()); | |
| 379 WriteDouble(matrix->c()); | |
| 380 WriteDouble(matrix->d()); | |
| 381 WriteDouble(matrix->e()); | |
| 382 WriteDouble(matrix->f()); | |
| 383 } else { | |
| 384 WriteTag(kDOMMatrixReadOnlyTag); | |
| 385 WriteDouble(matrix->m11()); | |
| 386 WriteDouble(matrix->m12()); | |
| 387 WriteDouble(matrix->m13()); | |
| 388 WriteDouble(matrix->m14()); | |
| 389 WriteDouble(matrix->m21()); | |
| 390 WriteDouble(matrix->m22()); | |
| 391 WriteDouble(matrix->m23()); | |
| 392 WriteDouble(matrix->m24()); | |
| 393 WriteDouble(matrix->m31()); | |
| 394 WriteDouble(matrix->m32()); | |
| 395 WriteDouble(matrix->m33()); | |
| 396 WriteDouble(matrix->m34()); | |
| 397 WriteDouble(matrix->m41()); | |
| 398 WriteDouble(matrix->m42()); | |
| 399 WriteDouble(matrix->m43()); | |
| 400 WriteDouble(matrix->m44()); | |
| 401 } | |
| 402 return true; | |
| 403 } | |
| 271 if (wrapper_type_info == &V8MessagePort::wrapperTypeInfo) { | 404 if (wrapper_type_info == &V8MessagePort::wrapperTypeInfo) { |
| 272 MessagePort* message_port = wrappable->ToImpl<MessagePort>(); | 405 MessagePort* message_port = wrappable->ToImpl<MessagePort>(); |
| 273 size_t index = kNotFound; | 406 size_t index = kNotFound; |
| 274 if (transferables_) | 407 if (transferables_) |
| 275 index = transferables_->message_ports.Find(message_port); | 408 index = transferables_->message_ports.Find(message_port); |
| 276 if (index == kNotFound) { | 409 if (index == kNotFound) { |
| 277 exception_state.ThrowDOMException( | 410 exception_state.ThrowDOMException( |
| 278 kDataCloneError, | 411 kDataCloneError, |
| 279 "A MessagePort could not be cloned because it was not transferred."); | 412 "A MessagePort could not be cloned because it was not transferred."); |
| 280 return false; | 413 return false; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 *actual_size = WTF::Partitions::BufferActualSize(size); | 598 *actual_size = WTF::Partitions::BufferActualSize(size); |
| 466 return WTF::Partitions::BufferRealloc(old_buffer, *actual_size, | 599 return WTF::Partitions::BufferRealloc(old_buffer, *actual_size, |
| 467 "SerializedScriptValue buffer"); | 600 "SerializedScriptValue buffer"); |
| 468 } | 601 } |
| 469 | 602 |
| 470 void V8ScriptValueSerializer::FreeBufferMemory(void* buffer) { | 603 void V8ScriptValueSerializer::FreeBufferMemory(void* buffer) { |
| 471 return WTF::Partitions::BufferFree(buffer); | 604 return WTF::Partitions::BufferFree(buffer); |
| 472 } | 605 } |
| 473 | 606 |
| 474 } // namespace blink | 607 } // namespace blink |
| OLD | NEW |