OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ScriptValueSerializer.h" | 5 #include "bindings/core/v8/ScriptValueSerializer.h" |
6 | 6 |
7 #include "bindings/core/v8/Transferables.h" | 7 #include "bindings/core/v8/Transferables.h" |
8 #include "bindings/core/v8/V8ArrayBuffer.h" | 8 #include "bindings/core/v8/V8ArrayBuffer.h" |
9 #include "bindings/core/v8/V8ArrayBufferView.h" | 9 #include "bindings/core/v8/V8ArrayBufferView.h" |
10 #include "bindings/core/v8/V8Blob.h" | 10 #include "bindings/core/v8/V8Blob.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "core/dom/DOMTypedArray.h" | 22 #include "core/dom/DOMTypedArray.h" |
23 #include "core/fileapi/Blob.h" | 23 #include "core/fileapi/Blob.h" |
24 #include "core/fileapi/File.h" | 24 #include "core/fileapi/File.h" |
25 #include "core/fileapi/FileList.h" | 25 #include "core/fileapi/FileList.h" |
26 #include "platform/RuntimeEnabledFeatures.h" | 26 #include "platform/RuntimeEnabledFeatures.h" |
27 #include "public/platform/Platform.h" | 27 #include "public/platform/Platform.h" |
28 #include "public/platform/WebBlobInfo.h" | 28 #include "public/platform/WebBlobInfo.h" |
29 #include "wtf/DateMath.h" | 29 #include "wtf/DateMath.h" |
30 #include "wtf/text/StringHash.h" | 30 #include "wtf/text/StringHash.h" |
31 #include "wtf/text/StringUTF8Adaptor.h" | 31 #include "wtf/text/StringUTF8Adaptor.h" |
| 32 #include <memory> |
32 | 33 |
33 // FIXME: consider crashing in debug mode on deserialization errors | 34 // FIXME: consider crashing in debug mode on deserialization errors |
34 // NOTE: be sure to change wireFormatVersion as necessary! | 35 // NOTE: be sure to change wireFormatVersion as necessary! |
35 | 36 |
36 namespace blink { | 37 namespace blink { |
37 | 38 |
38 // This code implements the HTML5 Structured Clone algorithm: | 39 // This code implements the HTML5 Structured Clone algorithm: |
39 // http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#safe-pa
ssing-of-structured-data | 40 // http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#safe-pa
ssing-of-structured-data |
40 | 41 |
41 // ZigZag encoding helps VarInt encoding stay small for negative | 42 // ZigZag encoding helps VarInt encoding stay small for negative |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 if (!imageBitmap) | 1100 if (!imageBitmap) |
1100 return nullptr; | 1101 return nullptr; |
1101 if (imageBitmap->isNeutered()) | 1102 if (imageBitmap->isNeutered()) |
1102 return handleError(DataCloneError, "An ImageBitmap is detached and could
not be cloned.", next); | 1103 return handleError(DataCloneError, "An ImageBitmap is detached and could
not be cloned.", next); |
1103 | 1104 |
1104 uint32_t index; | 1105 uint32_t index; |
1105 if (m_transferredImageBitmaps.tryGet(object, &index)) { | 1106 if (m_transferredImageBitmaps.tryGet(object, &index)) { |
1106 m_writer.writeTransferredImageBitmap(index); | 1107 m_writer.writeTransferredImageBitmap(index); |
1107 } else { | 1108 } else { |
1108 greyObject(object); | 1109 greyObject(object); |
1109 OwnPtr<uint8_t[]> pixelData = imageBitmap->copyBitmapData(PremultiplyAlp
ha); | 1110 std::unique_ptr<uint8_t[]> pixelData = imageBitmap->copyBitmapData(Premu
ltiplyAlpha); |
1110 m_writer.writeImageBitmap(imageBitmap->width(), imageBitmap->height(), p
ixelData.get(), imageBitmap->width() * imageBitmap->height() * 4); | 1111 m_writer.writeImageBitmap(imageBitmap->width(), imageBitmap->height(), p
ixelData.get(), imageBitmap->width() * imageBitmap->height() * 4); |
1111 } | 1112 } |
1112 return nullptr; | 1113 return nullptr; |
1113 } | 1114 } |
1114 | 1115 |
1115 void ScriptValueSerializer::writeRegExp(v8::Local<v8::Value> value) | 1116 void ScriptValueSerializer::writeRegExp(v8::Local<v8::Value> value) |
1116 { | 1117 { |
1117 v8::Local<v8::RegExp> regExp = value.As<v8::RegExp>(); | 1118 v8::Local<v8::RegExp> regExp = value.As<v8::RegExp>(); |
1118 m_writer.writeRegExp(regExp->GetSource(), regExp->GetFlags()); | 1119 m_writer.writeRegExp(regExp->GetSource(), regExp->GetFlags()); |
1119 } | 1120 } |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 return false; | 2401 return false; |
2401 uint32_t objectReference = m_openCompositeReferenceStack[m_openCompositeRefe
renceStack.size() - 1]; | 2402 uint32_t objectReference = m_openCompositeReferenceStack[m_openCompositeRefe
renceStack.size() - 1]; |
2402 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() -
1); | 2403 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() -
1); |
2403 if (objectReference >= m_objectPool.size()) | 2404 if (objectReference >= m_objectPool.size()) |
2404 return false; | 2405 return false; |
2405 *object = m_objectPool[objectReference]; | 2406 *object = m_objectPool[objectReference]; |
2406 return true; | 2407 return true; |
2407 } | 2408 } |
2408 | 2409 |
2409 } // namespace blink | 2410 } // namespace blink |
OLD | NEW |