| 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 int SerializedScriptValueWriter::v8StringWriteOptions() | 551 int SerializedScriptValueWriter::v8StringWriteOptions() |
| 552 { | 552 { |
| 553 return v8::String::NO_NULL_TERMINATION; | 553 return v8::String::NO_NULL_TERMINATION; |
| 554 } | 554 } |
| 555 | 555 |
| 556 ScriptValueSerializer::StateBase* ScriptValueSerializer::AbstractObjectState::se
rializeProperties(ScriptValueSerializer& serializer) | 556 ScriptValueSerializer::StateBase* ScriptValueSerializer::AbstractObjectState::se
rializeProperties(ScriptValueSerializer& serializer) |
| 557 { | 557 { |
| 558 while (m_index < m_propertyNames->Length()) { | 558 while (m_index < m_propertyNames->Length()) { |
| 559 v8::Local<v8::Value> propertyName; | 559 v8::Local<v8::Value> propertyName; |
| 560 if (!m_propertyNames->Get(serializer.context(), m_index).ToLocal(&proper
tyName)) | 560 if (!m_propertyNames->Get(serializer.context(), m_index).ToLocal(&proper
tyName)) |
| 561 return serializer.handleError(JSException, "Failed to get a property
while cloning an object.", this); | 561 return serializer.handleError(Status::JSException, "Failed to get a
property while cloning an object.", this); |
| 562 | 562 |
| 563 bool hasProperty = false; | 563 bool hasProperty = false; |
| 564 if (propertyName->IsString()) { | 564 if (propertyName->IsString()) { |
| 565 hasProperty = v8CallBoolean(composite()->HasRealNamedProperty(serial
izer.context(), propertyName.As<v8::String>())); | 565 hasProperty = v8CallBoolean(composite()->HasRealNamedProperty(serial
izer.context(), propertyName.As<v8::String>())); |
| 566 } else if (propertyName->IsUint32()) { | 566 } else if (propertyName->IsUint32()) { |
| 567 hasProperty = v8CallBoolean(composite()->HasRealIndexedProperty(seri
alizer.context(), propertyName.As<v8::Uint32>()->Value())); | 567 hasProperty = v8CallBoolean(composite()->HasRealIndexedProperty(seri
alizer.context(), propertyName.As<v8::Uint32>()->Value())); |
| 568 } | 568 } |
| 569 if (StateBase* newState = serializer.checkException(this)) | 569 if (StateBase* newState = serializer.checkException(this)) |
| 570 return newState; | 570 return newState; |
| 571 if (!hasProperty) { | 571 if (!hasProperty) { |
| 572 ++m_index; | 572 ++m_index; |
| 573 continue; | 573 continue; |
| 574 } | 574 } |
| 575 | 575 |
| 576 // |propertyName| is v8::String or v8::Uint32, so its serialization cann
ot be recursive. | 576 // |propertyName| is v8::String or v8::Uint32, so its serialization cann
ot be recursive. |
| 577 serializer.doSerialize(propertyName, nullptr); | 577 serializer.doSerialize(propertyName, nullptr); |
| 578 | 578 |
| 579 v8::Local<v8::Value> value; | 579 v8::Local<v8::Value> value; |
| 580 if (!composite()->Get(serializer.context(), propertyName).ToLocal(&value
)) | 580 if (!composite()->Get(serializer.context(), propertyName).ToLocal(&value
)) |
| 581 return serializer.handleError(JSException, "Failed to get a property
while cloning an object.", this); | 581 return serializer.handleError(Status::JSException, "Failed to get a
property while cloning an object.", this); |
| 582 ++m_index; | 582 ++m_index; |
| 583 ++m_numSerializedProperties; | 583 ++m_numSerializedProperties; |
| 584 // If we return early here, it's either because we have pushed a new sta
te onto the | 584 // If we return early here, it's either because we have pushed a new sta
te onto the |
| 585 // serialization state stack or because we have encountered an error (an
d in both cases | 585 // serialization state stack or because we have encountered an error (an
d in both cases |
| 586 // we are unwinding the native stack). | 586 // we are unwinding the native stack). |
| 587 if (StateBase* newState = serializer.doSerialize(value, this)) | 587 if (StateBase* newState = serializer.doSerialize(value, this)) |
| 588 return newState; | 588 return newState; |
| 589 } | 589 } |
| 590 return objectDone(m_numSerializedProperties, serializer); | 590 return objectDone(m_numSerializedProperties, serializer); |
| 591 } | 591 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 602 ScriptValueSerializer::StateBase* ScriptValueSerializer::ObjectState::objectDone
(unsigned numProperties, ScriptValueSerializer& serializer) | 602 ScriptValueSerializer::StateBase* ScriptValueSerializer::ObjectState::objectDone
(unsigned numProperties, ScriptValueSerializer& serializer) |
| 603 { | 603 { |
| 604 return serializer.writeObject(numProperties, this); | 604 return serializer.writeObject(numProperties, this); |
| 605 } | 605 } |
| 606 | 606 |
| 607 ScriptValueSerializer::StateBase* ScriptValueSerializer::DenseArrayState::advanc
e(ScriptValueSerializer& serializer) | 607 ScriptValueSerializer::StateBase* ScriptValueSerializer::DenseArrayState::advanc
e(ScriptValueSerializer& serializer) |
| 608 { | 608 { |
| 609 while (m_arrayIndex < m_arrayLength) { | 609 while (m_arrayIndex < m_arrayLength) { |
| 610 v8::Local<v8::Value> value; | 610 v8::Local<v8::Value> value; |
| 611 if (!composite().As<v8::Array>()->Get(serializer.context(), m_arrayIndex
).ToLocal(&value)) | 611 if (!composite().As<v8::Array>()->Get(serializer.context(), m_arrayIndex
).ToLocal(&value)) |
| 612 return serializer.handleError(JSException, "Failed to get an element
while cloning an array.", this); | 612 return serializer.handleError(Status::JSException, "Failed to get an
element while cloning an array.", this); |
| 613 m_arrayIndex++; | 613 m_arrayIndex++; |
| 614 if (StateBase* newState = serializer.checkException(this)) | 614 if (StateBase* newState = serializer.checkException(this)) |
| 615 return newState; | 615 return newState; |
| 616 if (StateBase* newState = serializer.doSerialize(value, this)) | 616 if (StateBase* newState = serializer.doSerialize(value, this)) |
| 617 return newState; | 617 return newState; |
| 618 } | 618 } |
| 619 return serializeProperties(serializer); | 619 return serializeProperties(serializer); |
| 620 } | 620 } |
| 621 | 621 |
| 622 ScriptValueSerializer::StateBase* ScriptValueSerializer::DenseArrayState::object
Done(unsigned numProperties, ScriptValueSerializer& serializer) | 622 ScriptValueSerializer::StateBase* ScriptValueSerializer::DenseArrayState::object
Done(unsigned numProperties, ScriptValueSerializer& serializer) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 633 { | 633 { |
| 634 return serializer.writeSparseArray(numProperties, composite().As<v8::Array>(
)->Length(), this); | 634 return serializer.writeSparseArray(numProperties, composite().As<v8::Array>(
)->Length(), this); |
| 635 } | 635 } |
| 636 | 636 |
| 637 template <typename T> | 637 template <typename T> |
| 638 ScriptValueSerializer::StateBase* ScriptValueSerializer::CollectionState<T>::adv
ance(ScriptValueSerializer& serializer) | 638 ScriptValueSerializer::StateBase* ScriptValueSerializer::CollectionState<T>::adv
ance(ScriptValueSerializer& serializer) |
| 639 { | 639 { |
| 640 while (m_index < m_length) { | 640 while (m_index < m_length) { |
| 641 v8::Local<v8::Value> value; | 641 v8::Local<v8::Value> value; |
| 642 if (!m_entries->Get(serializer.context(), m_index).ToLocal(&value)) | 642 if (!m_entries->Get(serializer.context(), m_index).ToLocal(&value)) |
| 643 return serializer.handleError(JSException, "Failed to get an element
while cloning a collection.", this); | 643 return serializer.handleError(Status::JSException, "Failed to get an
element while cloning a collection.", this); |
| 644 m_index++; | 644 m_index++; |
| 645 if (StateBase* newState = serializer.checkException(this)) | 645 if (StateBase* newState = serializer.checkException(this)) |
| 646 return newState; | 646 return newState; |
| 647 if (StateBase* newState = serializer.doSerialize(value, this)) | 647 if (StateBase* newState = serializer.doSerialize(value, this)) |
| 648 return newState; | 648 return newState; |
| 649 } | 649 } |
| 650 return serializer.writeCollection<T>(m_length, this); | 650 return serializer.writeCollection<T>(m_length, this); |
| 651 } | 651 } |
| 652 | 652 |
| 653 static v8::Local<v8::Object> toV8Object(MessagePort* impl, v8::Local<v8::Object>
creationContext, v8::Isolate* isolate) | 653 static v8::Local<v8::Object> toV8Object(MessagePort* impl, v8::Local<v8::Object>
creationContext, v8::Isolate* isolate) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 // HTML5 structured clone algorithm. | 695 // HTML5 structured clone algorithm. |
| 696 static bool isHostObject(v8::Local<v8::Object> object) | 696 static bool isHostObject(v8::Local<v8::Object> object) |
| 697 { | 697 { |
| 698 // If the object has any internal fields, then we won't be able to serialize
or deserialize | 698 // If the object has any internal fields, then we won't be able to serialize
or deserialize |
| 699 // them; conveniently, this is also a quick way to detect DOM wrapper object
s, because | 699 // them; conveniently, this is also a quick way to detect DOM wrapper object
s, because |
| 700 // the mechanism for these relies on data stored in these fields. We should | 700 // the mechanism for these relies on data stored in these fields. We should |
| 701 // catch external array data as a special case. | 701 // catch external array data as a special case. |
| 702 return object->InternalFieldCount(); | 702 return object->InternalFieldCount(); |
| 703 } | 703 } |
| 704 | 704 |
| 705 ScriptValueSerializer::ScriptValueSerializer(SerializedScriptValueWriter& writer
, const Transferables* transferables, WebBlobInfoArray* blobInfo, BlobDataHandle
Map& blobDataHandles, v8::TryCatch& tryCatch, ScriptState* scriptState) | 705 ScriptValueSerializer::ScriptValueSerializer(SerializedScriptValueWriter& writer
, const Transferables* transferables, WebBlobInfoArray* blobInfo, ScriptState* s
criptState) |
| 706 : m_scriptState(scriptState) | 706 : m_scriptState(scriptState) |
| 707 , m_writer(writer) | 707 , m_writer(writer) |
| 708 , m_tryCatch(tryCatch) | 708 , m_tryCatch(scriptState->isolate()) |
| 709 , m_depth(0) | 709 , m_depth(0) |
| 710 , m_status(Success) | 710 , m_status(Status::Success) |
| 711 , m_nextObjectReference(0) | 711 , m_nextObjectReference(0) |
| 712 , m_blobInfo(blobInfo) | 712 , m_blobInfo(blobInfo) |
| 713 , m_blobDataHandles(blobDataHandles) | 713 , m_blobDataHandles(nullptr) |
| 714 { | 714 { |
| 715 ASSERT(!tryCatch.HasCaught()); | 715 DCHECK(!m_tryCatch.HasCaught()); |
| 716 if (transferables) | 716 if (transferables) |
| 717 copyTransferables(*transferables); | 717 copyTransferables(*transferables); |
| 718 } | 718 } |
| 719 | 719 |
| 720 void ScriptValueSerializer::copyTransferables(const Transferables& transferables
) | 720 void ScriptValueSerializer::copyTransferables(const Transferables& transferables
) |
| 721 { | 721 { |
| 722 v8::Local<v8::Object> creationContext = m_scriptState->context()->Global(); | 722 v8::Local<v8::Object> creationContext = m_scriptState->context()->Global(); |
| 723 | 723 |
| 724 // Also kept in separate ObjectPools, iterate and copy the contents | 724 // Also kept in separate ObjectPools, iterate and copy the contents |
| 725 // of each kind of transferable vector. | 725 // of each kind of transferable vector. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 746 } | 746 } |
| 747 | 747 |
| 748 const auto& offscreenCanvases = transferables.offscreenCanvases; | 748 const auto& offscreenCanvases = transferables.offscreenCanvases; |
| 749 for (size_t i = 0; i < offscreenCanvases.size(); ++i) { | 749 for (size_t i = 0; i < offscreenCanvases.size(); ++i) { |
| 750 v8::Local<v8::Object> v8OffscreenCanvas = toV8Object(offscreenCanvases[i
].get(), creationContext, isolate()); | 750 v8::Local<v8::Object> v8OffscreenCanvas = toV8Object(offscreenCanvases[i
].get(), creationContext, isolate()); |
| 751 if (!m_transferredOffscreenCanvas.contains(v8OffscreenCanvas)) | 751 if (!m_transferredOffscreenCanvas.contains(v8OffscreenCanvas)) |
| 752 m_transferredOffscreenCanvas.set(v8OffscreenCanvas, i); | 752 m_transferredOffscreenCanvas.set(v8OffscreenCanvas, i); |
| 753 } | 753 } |
| 754 } | 754 } |
| 755 | 755 |
| 756 ScriptValueSerializer::Status ScriptValueSerializer::serialize(v8::Local<v8::Val
ue> value) | 756 PassRefPtr<SerializedScriptValue> ScriptValueSerializer::serialize(v8::Local<v8:
:Value> value, Transferables* transferables, ExceptionState& exceptionState) |
| 757 { | 757 { |
| 758 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::creat
e(); |
| 759 m_blobDataHandles = &serializedValue->blobDataHandles(); |
| 760 |
| 758 v8::HandleScope scope(isolate()); | 761 v8::HandleScope scope(isolate()); |
| 759 m_writer.writeVersion(); | 762 writer().writeVersion(); |
| 760 StateBase* state = doSerialize(value, 0); | 763 StateBase* state = doSerialize(value, nullptr); |
| 761 while (state) | 764 while (state) |
| 762 state = state->advance(*this); | 765 state = state->advance(*this); |
| 763 return m_status; | 766 |
| 767 switch (m_status) { |
| 768 case Status::Success: |
| 769 transferData(transferables, exceptionState, serializedValue.get()); |
| 770 break; |
| 771 case Status::InputError: |
| 772 case Status::DataCloneError: |
| 773 exceptionState.throwDOMException(blink::DataCloneError, errorMessage()); |
| 774 break; |
| 775 case Status::JSException: |
| 776 exceptionState.rethrowV8Exception(m_tryCatch.Exception()); |
| 777 break; |
| 778 default: |
| 779 NOTREACHED(); |
| 780 } |
| 781 |
| 782 m_blobDataHandles = nullptr; |
| 783 |
| 784 return serializedValue.release(); |
| 785 } |
| 786 |
| 787 void ScriptValueSerializer::transferData(Transferables* transferables, Exception
State& exceptionState, SerializedScriptValue* serializedValue) |
| 788 { |
| 789 serializedValue->setData(m_writer.takeWireString()); |
| 790 DCHECK(serializedValue->data().impl()->hasOneRef()); |
| 791 if (!transferables) |
| 792 return; |
| 793 |
| 794 serializedValue->transferImageBitmaps(isolate(), transferables->imageBitmaps
, exceptionState); |
| 795 if (exceptionState.hadException()) |
| 796 return; |
| 797 serializedValue->transferArrayBuffers(isolate(), transferables->arrayBuffers
, exceptionState); |
| 798 if (exceptionState.hadException()) |
| 799 return; |
| 800 serializedValue->transferOffscreenCanvas(isolate(), transferables->offscreen
Canvases, exceptionState); |
| 764 } | 801 } |
| 765 | 802 |
| 766 // static | 803 // static |
| 767 String ScriptValueSerializer::serializeWTFString(const String& data) | 804 String ScriptValueSerializer::serializeWTFString(const String& data) |
| 768 { | 805 { |
| 769 SerializedScriptValueWriter valueWriter; | 806 SerializedScriptValueWriter valueWriter; |
| 770 valueWriter.writeWebCoreString(data); | 807 valueWriter.writeWebCoreString(data); |
| 771 return valueWriter.takeWireString(); | 808 return valueWriter.takeWireString(); |
| 772 } | 809 } |
| 773 | 810 |
| 774 // static | 811 // static |
| 775 String ScriptValueSerializer::serializeNullValue() | 812 String ScriptValueSerializer::serializeNullValue() |
| 776 { | 813 { |
| 777 SerializedScriptValueWriter valueWriter; | 814 SerializedScriptValueWriter valueWriter; |
| 778 valueWriter.writeNull(); | 815 valueWriter.writeNull(); |
| 779 return valueWriter.takeWireString(); | 816 return valueWriter.takeWireString(); |
| 780 } | 817 } |
| 781 | 818 |
| 782 ScriptValueSerializer::StateBase* ScriptValueSerializer::doSerialize(v8::Local<v
8::Value> value, ScriptValueSerializer::StateBase* next) | 819 ScriptValueSerializer::StateBase* ScriptValueSerializer::doSerialize(v8::Local<v
8::Value> value, ScriptValueSerializer::StateBase* next) |
| 783 { | 820 { |
| 784 m_writer.writeReferenceCount(m_nextObjectReference); | 821 m_writer.writeReferenceCount(m_nextObjectReference); |
| 785 | 822 |
| 786 if (value.IsEmpty()) | 823 if (value.IsEmpty()) |
| 787 return handleError(InputError, "The empty property cannot be cloned.", n
ext); | 824 return handleError(Status::InputError, "The empty property cannot be clo
ned.", next); |
| 788 | 825 |
| 789 uint32_t objectReference; | 826 uint32_t objectReference; |
| 790 if ((value->IsObject() || value->IsDate() || value->IsRegExp()) | 827 if ((value->IsObject() || value->IsDate() || value->IsRegExp()) |
| 791 && m_objectPool.tryGet(value.As<v8::Object>(), &objectReference)) { | 828 && m_objectPool.tryGet(value.As<v8::Object>(), &objectReference)) { |
| 792 // Note that IsObject() also detects wrappers (eg, it will catch the thi
ngs | 829 // Note that IsObject() also detects wrappers (eg, it will catch the thi
ngs |
| 793 // that we grey and write below). | 830 // that we grey and write below). |
| 794 ASSERT(!value->IsString()); | 831 ASSERT(!value->IsString()); |
| 795 m_writer.writeObjectReference(objectReference); | 832 m_writer.writeObjectReference(objectReference); |
| 796 return nullptr; | 833 return nullptr; |
| 797 } | 834 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 808 m_writer.writeFalse(); | 845 m_writer.writeFalse(); |
| 809 } else if (value->IsInt32()) { | 846 } else if (value->IsInt32()) { |
| 810 m_writer.writeInt32(value.As<v8::Int32>()->Value()); | 847 m_writer.writeInt32(value.As<v8::Int32>()->Value()); |
| 811 } else if (value->IsUint32()) { | 848 } else if (value->IsUint32()) { |
| 812 m_writer.writeUint32(value.As<v8::Uint32>()->Value()); | 849 m_writer.writeUint32(value.As<v8::Uint32>()->Value()); |
| 813 } else if (value->IsNumber()) { | 850 } else if (value->IsNumber()) { |
| 814 m_writer.writeNumber(value.As<v8::Number>()->Value()); | 851 m_writer.writeNumber(value.As<v8::Number>()->Value()); |
| 815 } else if (value->IsString()) { | 852 } else if (value->IsString()) { |
| 816 writeString(value); | 853 writeString(value); |
| 817 } else { | 854 } else { |
| 818 return handleError(DataCloneError, "A value could not be cloned.", next)
; | 855 return handleError(Status::DataCloneError, "A value could not be cloned.
", next); |
| 819 } | 856 } |
| 820 return nullptr; | 857 return nullptr; |
| 821 } | 858 } |
| 822 | 859 |
| 823 ScriptValueSerializer::StateBase* ScriptValueSerializer::doSerializeObject(v8::L
ocal<v8::Object> object, ScriptValueSerializer::StateBase* next) | 860 ScriptValueSerializer::StateBase* ScriptValueSerializer::doSerializeObject(v8::L
ocal<v8::Object> object, ScriptValueSerializer::StateBase* next) |
| 824 { | 861 { |
| 825 DCHECK(!object.IsEmpty()); | 862 DCHECK(!object.IsEmpty()); |
| 826 | 863 |
| 827 | 864 |
| 828 if (object->IsArrayBufferView()) { | 865 if (object->IsArrayBufferView()) { |
| 829 return writeAndGreyArrayBufferView(object, next); | 866 return writeAndGreyArrayBufferView(object, next); |
| 830 } | 867 } |
| 831 if (object->IsArrayBuffer()) { | 868 if (object->IsArrayBuffer()) { |
| 832 return writeAndGreyArrayBuffer(object, next); | 869 return writeAndGreyArrayBuffer(object, next); |
| 833 } | 870 } |
| 834 if (object->IsSharedArrayBuffer()) { | 871 if (object->IsSharedArrayBuffer()) { |
| 835 uint32_t index; | 872 uint32_t index; |
| 836 if (!m_transferredArrayBuffers.tryGet(object, &index)) { | 873 if (!m_transferredArrayBuffers.tryGet(object, &index)) { |
| 837 return handleError(DataCloneError, "A SharedArrayBuffer could not be
cloned.", next); | 874 return handleError(Status::DataCloneError, "A SharedArrayBuffer coul
d not be cloned.", next); |
| 838 } | 875 } |
| 839 return writeTransferredSharedArrayBuffer(object, index, next); | 876 return writeTransferredSharedArrayBuffer(object, index, next); |
| 840 } | 877 } |
| 841 | 878 |
| 842 // Transferable only objects | 879 // Transferable only objects |
| 843 if (V8MessagePort::hasInstance(object, isolate())) { | 880 if (V8MessagePort::hasInstance(object, isolate())) { |
| 844 uint32_t index; | 881 uint32_t index; |
| 845 if (!m_transferredMessagePorts.tryGet(object, &index)) { | 882 if (!m_transferredMessagePorts.tryGet(object, &index)) { |
| 846 return handleError(DataCloneError, "A MessagePort could not be clone
d.", next); | 883 return handleError(Status::DataCloneError, "A MessagePort could not
be cloned.", next); |
| 847 } | 884 } |
| 848 m_writer.writeTransferredMessagePort(index); | 885 m_writer.writeTransferredMessagePort(index); |
| 849 return nullptr; | 886 return nullptr; |
| 850 } | 887 } |
| 851 if (V8OffscreenCanvas::hasInstance(object, isolate())) { | 888 if (V8OffscreenCanvas::hasInstance(object, isolate())) { |
| 852 uint32_t index; | 889 uint32_t index; |
| 853 if (!m_transferredOffscreenCanvas.tryGet(object, &index)) { | 890 if (!m_transferredOffscreenCanvas.tryGet(object, &index)) { |
| 854 return handleError(DataCloneError, "A OffscreenCanvas could not be c
loned.", next); | 891 return handleError(Status::DataCloneError, "A OffscreenCanvas could
not be cloned.", next); |
| 855 } | 892 } |
| 856 return writeTransferredOffscreenCanvas(object, index, next); | 893 return writeTransferredOffscreenCanvas(object, index, next); |
| 857 } | 894 } |
| 858 if (V8ImageBitmap::hasInstance(object, isolate())) { | 895 if (V8ImageBitmap::hasInstance(object, isolate())) { |
| 859 return writeAndGreyImageBitmap(object, next); | 896 return writeAndGreyImageBitmap(object, next); |
| 860 } | 897 } |
| 861 | 898 |
| 862 greyObject(object); | 899 greyObject(object); |
| 863 | 900 |
| 864 if (object->IsDate()) { | 901 if (object->IsDate()) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 if (object->IsRegExp()) { | 940 if (object->IsRegExp()) { |
| 904 writeRegExp(object); | 941 writeRegExp(object); |
| 905 return nullptr; | 942 return nullptr; |
| 906 } | 943 } |
| 907 if (V8CompositorProxy::hasInstance(object, isolate())) { | 944 if (V8CompositorProxy::hasInstance(object, isolate())) { |
| 908 return writeCompositorProxy(object, next); | 945 return writeCompositorProxy(object, next); |
| 909 } | 946 } |
| 910 | 947 |
| 911 // Since IsNativeError is expensive, this check should always be the last ch
eck. | 948 // Since IsNativeError is expensive, this check should always be the last ch
eck. |
| 912 if (isHostObject(object) || object->IsCallable() || object->IsNativeError())
{ | 949 if (isHostObject(object) || object->IsCallable() || object->IsNativeError())
{ |
| 913 return handleError(DataCloneError, "An object could not be cloned.", nex
t); | 950 return handleError(Status::DataCloneError, "An object could not be clone
d.", next); |
| 914 } | 951 } |
| 915 | 952 |
| 916 return startObjectState(object, next); | 953 return startObjectState(object, next); |
| 917 } | 954 } |
| 918 | 955 |
| 919 ScriptValueSerializer::StateBase* ScriptValueSerializer::doSerializeArrayBuffer(
v8::Local<v8::Value> arrayBuffer, ScriptValueSerializer::StateBase* next) | 956 ScriptValueSerializer::StateBase* ScriptValueSerializer::doSerializeArrayBuffer(
v8::Local<v8::Value> arrayBuffer, ScriptValueSerializer::StateBase* next) |
| 920 { | 957 { |
| 921 return doSerialize(arrayBuffer, next); | 958 return doSerialize(arrayBuffer, next); |
| 922 } | 959 } |
| 923 | 960 |
| 924 ScriptValueSerializer::StateBase* ScriptValueSerializer::checkException(ScriptVa
lueSerializer::StateBase* state) | 961 ScriptValueSerializer::StateBase* ScriptValueSerializer::checkException(ScriptVa
lueSerializer::StateBase* state) |
| 925 { | 962 { |
| 926 return m_tryCatch.HasCaught() ? handleError(JSException, "", state) : 0; | 963 return m_tryCatch.HasCaught() ? handleError(Status::JSException, "", state)
: nullptr; |
| 927 } | 964 } |
| 928 | 965 |
| 929 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeObject(uint32_t nu
mProperties, ScriptValueSerializer::StateBase* state) | 966 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeObject(uint32_t nu
mProperties, ScriptValueSerializer::StateBase* state) |
| 930 { | 967 { |
| 931 m_writer.writeObject(numProperties); | 968 m_writer.writeObject(numProperties); |
| 932 return pop(state); | 969 return pop(state); |
| 933 } | 970 } |
| 934 | 971 |
| 935 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeSparseArray(uint32
_t numProperties, uint32_t length, ScriptValueSerializer::StateBase* state) | 972 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeSparseArray(uint32
_t numProperties, uint32_t length, ScriptValueSerializer::StateBase* state) |
| 936 { | 973 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 953 | 990 |
| 954 template <> | 991 template <> |
| 955 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeCollection<v8::Set
>(uint32_t length, ScriptValueSerializer::StateBase* state) | 992 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeCollection<v8::Set
>(uint32_t length, ScriptValueSerializer::StateBase* state) |
| 956 { | 993 { |
| 957 m_writer.writeSet(length); | 994 m_writer.writeSet(length); |
| 958 return pop(state); | 995 return pop(state); |
| 959 } | 996 } |
| 960 | 997 |
| 961 ScriptValueSerializer::StateBase* ScriptValueSerializer::handleError(ScriptValue
Serializer::Status errorStatus, const String& message, ScriptValueSerializer::St
ateBase* state) | 998 ScriptValueSerializer::StateBase* ScriptValueSerializer::handleError(ScriptValue
Serializer::Status errorStatus, const String& message, ScriptValueSerializer::St
ateBase* state) |
| 962 { | 999 { |
| 963 ASSERT(errorStatus != Success); | 1000 DCHECK(errorStatus != Status::Success); |
| 964 m_status = errorStatus; | 1001 m_status = errorStatus; |
| 965 m_errorMessage = message; | 1002 m_errorMessage = message; |
| 966 while (state) { | 1003 while (state) { |
| 967 StateBase* tmp = state->nextState(); | 1004 StateBase* tmp = state->nextState(); |
| 968 delete state; | 1005 delete state; |
| 969 state = tmp; | 1006 state = tmp; |
| 970 } | 1007 } |
| 971 return new ErrorState; | 1008 return new ErrorState; |
| 972 } | 1009 } |
| 973 | 1010 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 v8::Local<v8::BooleanObject> booleanObject = value.As<v8::BooleanObject>(); | 1050 v8::Local<v8::BooleanObject> booleanObject = value.As<v8::BooleanObject>(); |
| 1014 m_writer.writeBooleanObject(booleanObject->ValueOf()); | 1051 m_writer.writeBooleanObject(booleanObject->ValueOf()); |
| 1015 } | 1052 } |
| 1016 | 1053 |
| 1017 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeBlob(v8::Local<v8:
:Value> value, ScriptValueSerializer::StateBase* next) | 1054 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeBlob(v8::Local<v8:
:Value> value, ScriptValueSerializer::StateBase* next) |
| 1018 { | 1055 { |
| 1019 Blob* blob = V8Blob::toImpl(value.As<v8::Object>()); | 1056 Blob* blob = V8Blob::toImpl(value.As<v8::Object>()); |
| 1020 if (!blob) | 1057 if (!blob) |
| 1021 return 0; | 1058 return 0; |
| 1022 if (blob->isClosed()) | 1059 if (blob->isClosed()) |
| 1023 return handleError(DataCloneError, "A Blob object has been closed, and c
ould therefore not be cloned.", next); | 1060 return handleError(Status::DataCloneError, "A Blob object has been close
d, and could therefore not be cloned.", next); |
| 1024 int blobIndex = -1; | 1061 int blobIndex = -1; |
| 1025 m_blobDataHandles.set(blob->uuid(), blob->blobDataHandle()); | 1062 m_blobDataHandles->set(blob->uuid(), blob->blobDataHandle()); |
| 1026 if (appendBlobInfo(blob->uuid(), blob->type(), blob->size(), &blobIndex)) | 1063 if (appendBlobInfo(blob->uuid(), blob->type(), blob->size(), &blobIndex)) |
| 1027 m_writer.writeBlobIndex(blobIndex); | 1064 m_writer.writeBlobIndex(blobIndex); |
| 1028 else | 1065 else |
| 1029 m_writer.writeBlob(blob->uuid(), blob->type(), blob->size()); | 1066 m_writer.writeBlob(blob->uuid(), blob->type(), blob->size()); |
| 1030 return 0; | 1067 return 0; |
| 1031 } | 1068 } |
| 1032 | 1069 |
| 1033 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeCompositorProxy(v8
::Local<v8::Value> value, ScriptValueSerializer::StateBase* next) | 1070 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeCompositorProxy(v8
::Local<v8::Value> value, ScriptValueSerializer::StateBase* next) |
| 1034 { | 1071 { |
| 1035 CompositorProxy* compositorProxy = V8CompositorProxy::toImpl(value.As<v8::Ob
ject>()); | 1072 CompositorProxy* compositorProxy = V8CompositorProxy::toImpl(value.As<v8::Ob
ject>()); |
| 1036 if (!compositorProxy) | 1073 if (!compositorProxy) |
| 1037 return nullptr; | 1074 return nullptr; |
| 1038 if (!compositorProxy->connected()) | 1075 if (!compositorProxy->connected()) |
| 1039 return handleError(DataCloneError, "A CompositorProxy object has been di
sconnected, and could therefore not be cloned.", next); | 1076 return handleError(Status::DataCloneError, "A CompositorProxy object has
been disconnected, and could therefore not be cloned.", next); |
| 1040 m_writer.writeCompositorProxy(*compositorProxy); | 1077 m_writer.writeCompositorProxy(*compositorProxy); |
| 1041 return nullptr; | 1078 return nullptr; |
| 1042 } | 1079 } |
| 1043 | 1080 |
| 1044 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeFile(v8::Local<v8:
:Value> value, ScriptValueSerializer::StateBase* next) | 1081 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeFile(v8::Local<v8:
:Value> value, ScriptValueSerializer::StateBase* next) |
| 1045 { | 1082 { |
| 1046 File* file = V8File::toImpl(value.As<v8::Object>()); | 1083 File* file = V8File::toImpl(value.As<v8::Object>()); |
| 1047 if (!file) | 1084 if (!file) |
| 1048 return 0; | 1085 return 0; |
| 1049 if (file->isClosed()) | 1086 if (file->isClosed()) |
| 1050 return handleError(DataCloneError, "A File object has been closed, and c
ould therefore not be cloned.", next); | 1087 return handleError(Status::DataCloneError, "A File object has been close
d, and could therefore not be cloned.", next); |
| 1051 int blobIndex = -1; | 1088 int blobIndex = -1; |
| 1052 m_blobDataHandles.set(file->uuid(), file->blobDataHandle()); | 1089 m_blobDataHandles->set(file->uuid(), file->blobDataHandle()); |
| 1053 if (appendFileInfo(file, &blobIndex)) { | 1090 if (appendFileInfo(file, &blobIndex)) { |
| 1054 ASSERT(blobIndex >= 0); | 1091 ASSERT(blobIndex >= 0); |
| 1055 m_writer.writeFileIndex(blobIndex); | 1092 m_writer.writeFileIndex(blobIndex); |
| 1056 } else { | 1093 } else { |
| 1057 m_writer.writeFile(*file); | 1094 m_writer.writeFile(*file); |
| 1058 } | 1095 } |
| 1059 return 0; | 1096 return 0; |
| 1060 } | 1097 } |
| 1061 | 1098 |
| 1062 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeFileList(v8::Local
<v8::Value> value, ScriptValueSerializer::StateBase* next) | 1099 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeFileList(v8::Local
<v8::Value> value, ScriptValueSerializer::StateBase* next) |
| 1063 { | 1100 { |
| 1064 FileList* fileList = V8FileList::toImpl(value.As<v8::Object>()); | 1101 FileList* fileList = V8FileList::toImpl(value.As<v8::Object>()); |
| 1065 if (!fileList) | 1102 if (!fileList) |
| 1066 return 0; | 1103 return 0; |
| 1067 unsigned length = fileList->length(); | 1104 unsigned length = fileList->length(); |
| 1068 Vector<int> blobIndices; | 1105 Vector<int> blobIndices; |
| 1069 for (unsigned i = 0; i < length; ++i) { | 1106 for (unsigned i = 0; i < length; ++i) { |
| 1070 int blobIndex = -1; | 1107 int blobIndex = -1; |
| 1071 const File* file = fileList->item(i); | 1108 const File* file = fileList->item(i); |
| 1072 if (file->isClosed()) | 1109 if (file->isClosed()) |
| 1073 return handleError(DataCloneError, "A File object has been closed, a
nd could therefore not be cloned.", next); | 1110 return handleError(Status::DataCloneError, "A File object has been c
losed, and could therefore not be cloned.", next); |
| 1074 m_blobDataHandles.set(file->uuid(), file->blobDataHandle()); | 1111 m_blobDataHandles->set(file->uuid(), file->blobDataHandle()); |
| 1075 if (appendFileInfo(file, &blobIndex)) { | 1112 if (appendFileInfo(file, &blobIndex)) { |
| 1076 ASSERT(!i || blobIndex > 0); | 1113 ASSERT(!i || blobIndex > 0); |
| 1077 ASSERT(blobIndex >= 0); | 1114 ASSERT(blobIndex >= 0); |
| 1078 blobIndices.append(blobIndex); | 1115 blobIndices.append(blobIndex); |
| 1079 } | 1116 } |
| 1080 } | 1117 } |
| 1081 if (!blobIndices.isEmpty()) | 1118 if (!blobIndices.isEmpty()) |
| 1082 m_writer.writeFileListIndex(blobIndices); | 1119 m_writer.writeFileListIndex(blobIndices); |
| 1083 else | 1120 else |
| 1084 m_writer.writeFileList(*fileList); | 1121 m_writer.writeFileList(*fileList); |
| 1085 return 0; | 1122 return 0; |
| 1086 } | 1123 } |
| 1087 | 1124 |
| 1088 void ScriptValueSerializer::writeImageData(v8::Local<v8::Value> value) | 1125 void ScriptValueSerializer::writeImageData(v8::Local<v8::Value> value) |
| 1089 { | 1126 { |
| 1090 ImageData* imageData = V8ImageData::toImpl(value.As<v8::Object>()); | 1127 ImageData* imageData = V8ImageData::toImpl(value.As<v8::Object>()); |
| 1091 if (!imageData) | 1128 if (!imageData) |
| 1092 return; | 1129 return; |
| 1093 DOMUint8ClampedArray* pixelArray = imageData->data(); | 1130 DOMUint8ClampedArray* pixelArray = imageData->data(); |
| 1094 m_writer.writeImageData(imageData->width(), imageData->height(), pixelArray-
>data(), pixelArray->length()); | 1131 m_writer.writeImageData(imageData->width(), imageData->height(), pixelArray-
>data(), pixelArray->length()); |
| 1095 } | 1132 } |
| 1096 | 1133 |
| 1097 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeAndGreyImageBitmap
(v8::Local<v8::Object> object, ScriptValueSerializer::StateBase* next) | 1134 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeAndGreyImageBitmap
(v8::Local<v8::Object> object, ScriptValueSerializer::StateBase* next) |
| 1098 { | 1135 { |
| 1099 ImageBitmap* imageBitmap = V8ImageBitmap::toImpl(object); | 1136 ImageBitmap* imageBitmap = V8ImageBitmap::toImpl(object); |
| 1100 if (!imageBitmap) | 1137 if (!imageBitmap) |
| 1101 return nullptr; | 1138 return nullptr; |
| 1102 if (imageBitmap->isNeutered()) | 1139 if (imageBitmap->isNeutered()) |
| 1103 return handleError(DataCloneError, "An ImageBitmap is detached and could
not be cloned.", next); | 1140 return handleError(Status::DataCloneError, "An ImageBitmap is detached a
nd could not be cloned.", next); |
| 1104 | 1141 |
| 1105 uint32_t index; | 1142 uint32_t index; |
| 1106 if (m_transferredImageBitmaps.tryGet(object, &index)) { | 1143 if (m_transferredImageBitmaps.tryGet(object, &index)) { |
| 1107 m_writer.writeTransferredImageBitmap(index); | 1144 m_writer.writeTransferredImageBitmap(index); |
| 1108 } else { | 1145 } else { |
| 1109 greyObject(object); | 1146 greyObject(object); |
| 1110 std::unique_ptr<uint8_t[]> pixelData = imageBitmap->copyBitmapData(Premu
ltiplyAlpha); | 1147 std::unique_ptr<uint8_t[]> pixelData = imageBitmap->copyBitmapData(Premu
ltiplyAlpha); |
| 1111 m_writer.writeImageBitmap(imageBitmap->width(), imageBitmap->height(), p
ixelData.get(), imageBitmap->width() * imageBitmap->height() * 4); | 1148 m_writer.writeImageBitmap(imageBitmap->width(), imageBitmap->height(), p
ixelData.get(), imageBitmap->width() * imageBitmap->height() * 4); |
| 1112 } | 1149 } |
| 1113 return nullptr; | 1150 return nullptr; |
| 1114 } | 1151 } |
| 1115 | 1152 |
| 1116 void ScriptValueSerializer::writeRegExp(v8::Local<v8::Value> value) | 1153 void ScriptValueSerializer::writeRegExp(v8::Local<v8::Value> value) |
| 1117 { | 1154 { |
| 1118 v8::Local<v8::RegExp> regExp = value.As<v8::RegExp>(); | 1155 v8::Local<v8::RegExp> regExp = value.As<v8::RegExp>(); |
| 1119 m_writer.writeRegExp(regExp->GetSource(), regExp->GetFlags()); | 1156 m_writer.writeRegExp(regExp->GetSource(), regExp->GetFlags()); |
| 1120 } | 1157 } |
| 1121 | 1158 |
| 1122 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeAndGreyArrayBuffer
View(v8::Local<v8::Object> object, ScriptValueSerializer::StateBase* next) | 1159 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeAndGreyArrayBuffer
View(v8::Local<v8::Object> object, ScriptValueSerializer::StateBase* next) |
| 1123 { | 1160 { |
| 1124 ASSERT(!object.IsEmpty()); | 1161 ASSERT(!object.IsEmpty()); |
| 1125 DOMArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(object); | 1162 DOMArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(object); |
| 1126 if (!arrayBufferView) | 1163 if (!arrayBufferView) |
| 1127 return 0; | 1164 return 0; |
| 1128 if (!arrayBufferView->bufferBase()) | 1165 if (!arrayBufferView->bufferBase()) |
| 1129 return handleError(DataCloneError, "An ArrayBuffer could not be cloned."
, next); | 1166 return handleError(Status::DataCloneError, "An ArrayBuffer could not be
cloned.", next); |
| 1130 v8::Local<v8::Value> underlyingBuffer = toV8(arrayBufferView->bufferBase(),
m_scriptState->context()->Global(), isolate()); | 1167 v8::Local<v8::Value> underlyingBuffer = toV8(arrayBufferView->bufferBase(),
m_scriptState->context()->Global(), isolate()); |
| 1131 if (underlyingBuffer.IsEmpty()) | 1168 if (underlyingBuffer.IsEmpty()) |
| 1132 return handleError(DataCloneError, "An ArrayBuffer could not be cloned."
, next); | 1169 return handleError(Status::DataCloneError, "An ArrayBuffer could not be
cloned.", next); |
| 1133 StateBase* stateOut = doSerializeArrayBuffer(underlyingBuffer, next); | 1170 StateBase* stateOut = doSerializeArrayBuffer(underlyingBuffer, next); |
| 1134 if (stateOut) | 1171 if (stateOut) |
| 1135 return stateOut; | 1172 return stateOut; |
| 1136 m_writer.writeArrayBufferView(*arrayBufferView); | 1173 m_writer.writeArrayBufferView(*arrayBufferView); |
| 1137 // This should be safe: we serialize something that we know to be a wrapper
(see | 1174 // This should be safe: we serialize something that we know to be a wrapper
(see |
| 1138 // the toV8 call above), so the call to doSerializeArrayBuffer should neithe
r | 1175 // the toV8 call above), so the call to doSerializeArrayBuffer should neithe
r |
| 1139 // cause the system stack to overflow nor should it have potential to reach | 1176 // cause the system stack to overflow nor should it have potential to reach |
| 1140 // this ArrayBufferView again. | 1177 // this ArrayBufferView again. |
| 1141 // | 1178 // |
| 1142 // We do need to grey the underlying buffer before we grey its view, however
; | 1179 // We do need to grey the underlying buffer before we grey its view, however
; |
| 1143 // ArrayBuffers may be shared, so they need to be given reference IDs, and a
n | 1180 // ArrayBuffers may be shared, so they need to be given reference IDs, and a
n |
| 1144 // ArrayBufferView cannot be constructed without a corresponding ArrayBuffer | 1181 // ArrayBufferView cannot be constructed without a corresponding ArrayBuffer |
| 1145 // (or without an additional tag that would allow us to do two-stage constru
ction | 1182 // (or without an additional tag that would allow us to do two-stage constru
ction |
| 1146 // like we do for Objects and Arrays). | 1183 // like we do for Objects and Arrays). |
| 1147 greyObject(object); | 1184 greyObject(object); |
| 1148 return 0; | 1185 return 0; |
| 1149 } | 1186 } |
| 1150 | 1187 |
| 1151 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeAndGreyArrayBuffer
(v8::Local<v8::Object> object, ScriptValueSerializer::StateBase* next) | 1188 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeAndGreyArrayBuffer
(v8::Local<v8::Object> object, ScriptValueSerializer::StateBase* next) |
| 1152 { | 1189 { |
| 1153 DOMArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(object); | 1190 DOMArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(object); |
| 1154 if (!arrayBuffer) | 1191 if (!arrayBuffer) |
| 1155 return nullptr; | 1192 return nullptr; |
| 1156 if (arrayBuffer->isNeutered()) | 1193 if (arrayBuffer->isNeutered()) |
| 1157 return handleError(DataCloneError, "An ArrayBuffer is neutered and could
not be cloned.", next); | 1194 return handleError(Status::DataCloneError, "An ArrayBuffer is neutered a
nd could not be cloned.", next); |
| 1158 | 1195 |
| 1159 uint32_t index; | 1196 uint32_t index; |
| 1160 if (m_transferredArrayBuffers.tryGet(object, &index)) { | 1197 if (m_transferredArrayBuffers.tryGet(object, &index)) { |
| 1161 m_writer.writeTransferredArrayBuffer(index); | 1198 m_writer.writeTransferredArrayBuffer(index); |
| 1162 } else { | 1199 } else { |
| 1163 greyObject(object); | 1200 greyObject(object); |
| 1164 m_writer.writeArrayBuffer(*arrayBuffer); | 1201 m_writer.writeArrayBuffer(*arrayBuffer); |
| 1165 } | 1202 } |
| 1166 return nullptr; | 1203 return nullptr; |
| 1167 } | 1204 } |
| 1168 | 1205 |
| 1169 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeTransferredOffscre
enCanvas(v8::Local<v8::Value> value, uint32_t index, ScriptValueSerializer::Stat
eBase* next) | 1206 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeTransferredOffscre
enCanvas(v8::Local<v8::Value> value, uint32_t index, ScriptValueSerializer::Stat
eBase* next) |
| 1170 { | 1207 { |
| 1171 OffscreenCanvas* offscreenCanvas = V8OffscreenCanvas::toImpl(value.As<v8::Ob
ject>()); | 1208 OffscreenCanvas* offscreenCanvas = V8OffscreenCanvas::toImpl(value.As<v8::Ob
ject>()); |
| 1172 if (!offscreenCanvas) | 1209 if (!offscreenCanvas) |
| 1173 return nullptr; | 1210 return nullptr; |
| 1174 if (offscreenCanvas->isNeutered()) | 1211 if (offscreenCanvas->isNeutered()) |
| 1175 return handleError(DataCloneError, "An OffscreenCanvas is detached and c
ould not be cloned.", next); | 1212 return handleError(Status::DataCloneError, "An OffscreenCanvas is detach
ed and could not be cloned.", next); |
| 1176 if (offscreenCanvas->renderingContext()) | 1213 if (offscreenCanvas->renderingContext()) |
| 1177 return handleError(DataCloneError, "An OffscreenCanvas with a context co
uld not be cloned.", next); | 1214 return handleError(Status::DataCloneError, "An OffscreenCanvas with a co
ntext could not be cloned.", next); |
| 1178 m_writer.writeTransferredOffscreenCanvas(index, offscreenCanvas->width(), of
fscreenCanvas->height(), offscreenCanvas->getAssociatedCanvasId()); | 1215 m_writer.writeTransferredOffscreenCanvas(index, offscreenCanvas->width(), of
fscreenCanvas->height(), offscreenCanvas->getAssociatedCanvasId()); |
| 1179 return nullptr; | 1216 return nullptr; |
| 1180 } | 1217 } |
| 1181 | 1218 |
| 1182 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeTransferredSharedA
rrayBuffer(v8::Local<v8::Value> value, uint32_t index, ScriptValueSerializer::St
ateBase* next) | 1219 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeTransferredSharedA
rrayBuffer(v8::Local<v8::Value> value, uint32_t index, ScriptValueSerializer::St
ateBase* next) |
| 1183 { | 1220 { |
| 1184 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled()); | 1221 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled()); |
| 1185 DOMSharedArrayBuffer* sharedArrayBuffer = V8SharedArrayBuffer::toImpl(value.
As<v8::Object>()); | 1222 DOMSharedArrayBuffer* sharedArrayBuffer = V8SharedArrayBuffer::toImpl(value.
As<v8::Object>()); |
| 1186 if (!sharedArrayBuffer) | 1223 if (!sharedArrayBuffer) |
| 1187 return 0; | 1224 return 0; |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 return false; | 2438 return false; |
| 2402 uint32_t objectReference = m_openCompositeReferenceStack[m_openCompositeRefe
renceStack.size() - 1]; | 2439 uint32_t objectReference = m_openCompositeReferenceStack[m_openCompositeRefe
renceStack.size() - 1]; |
| 2403 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() -
1); | 2440 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() -
1); |
| 2404 if (objectReference >= m_objectPool.size()) | 2441 if (objectReference >= m_objectPool.size()) |
| 2405 return false; | 2442 return false; |
| 2406 *object = m_objectPool[objectReference]; | 2443 *object = m_objectPool[objectReference]; |
| 2407 return true; | 2444 return true; |
| 2408 } | 2445 } |
| 2409 | 2446 |
| 2410 } // namespace blink | 2447 } // namespace blink |
| OLD | NEW |