| OLD | NEW |
| 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t
o_local_cpp_value %} | 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t
o_local_cpp_value %} |
| 2 | 2 |
| 3 {##############################################################################} | 3 {##############################################################################} |
| 4 {% macro generate_method(method, world_suffix) %} | 4 {% macro generate_method(method, world_suffix) %} |
| 5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) | 5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) |
| 6 {% filter format_remove_duplicates([ | 6 {% filter format_remove_duplicates([ |
| 7 'ExceptionState exceptionState', | 7 'ExceptionState exceptionState', |
| 8 'ScriptState* scriptState = ']) %} | 8 'ScriptState* scriptState = ']) %} |
| 9 { | 9 { |
| 10 {% set define_exception_state -%} | 10 {% set define_exception_state -%} |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 428 |
| 429 {##############################################################################} | 429 {##############################################################################} |
| 430 {% macro generate_post_message_impl(method) %} | 430 {% macro generate_post_message_impl(method) %} |
| 431 static void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance,
const v8::FunctionCallbackInfo<v8::Value>& info) | 431 static void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance,
const v8::FunctionCallbackInfo<v8::Value>& info) |
| 432 { | 432 { |
| 433 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCo
ntext, interfaceName, "postMessage"); | 433 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCo
ntext, interfaceName, "postMessage"); |
| 434 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { | 434 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { |
| 435 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{me
thod.number_of_required_arguments}}, info.Length())); | 435 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{me
thod.number_of_required_arguments}}, info.Length())); |
| 436 return; | 436 return; |
| 437 } | 437 } |
| 438 |
| 438 Transferables transferables; | 439 Transferables transferables; |
| 439 if (info.Length() > 1) { | 440 if (info.Length() > 1) { |
| 440 const int transferablesArgIndex = 1; | 441 const int transferablesArgIndex = 1; |
| 441 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info
[transferablesArgIndex], transferablesArgIndex, transferables, exceptionState))
{ | 442 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info
[transferablesArgIndex], transferablesArgIndex, transferables, exceptionState))
{ |
| 442 return; | 443 return; |
| 443 } | 444 } |
| 444 } | 445 } |
| 445 RefPtr<SerializedScriptValue> message = SerializedScriptValue::serialize(inf
o.GetIsolate(), info[0], &transferables, nullptr, exceptionState); | 446 |
| 446 if (exceptionState.hadException()) | 447 RefPtr<SerializedScriptValue> message; |
| 447 return; | 448 if (instance->canTransferArrayBuffer()) { |
| 449 // This instance supports sending array buffers by move semantics. |
| 450 message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &
transferables, nullptr, exceptionState); |
| 451 if (exceptionState.hadException()) |
| 452 return; |
| 453 } else { |
| 454 // This instance doesn't support sending array buffers by move |
| 455 // semantics. Emulate it by copy-and-neuter semantics that sends array |
| 456 // buffers by copy semantics and then neuters the original array |
| 457 // buffers. |
| 458 |
| 459 // Clear references to array buffers from transferables so that the |
| 460 // serializer can consider the array buffers as non-transferable and |
| 461 // copy them into the message. |
| 462 ArrayBufferArray transferableArrayBuffers = transferables.arrayBuffers; |
| 463 transferables.arrayBuffers.clear(); |
| 464 message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &
transferables, nullptr, exceptionState); |
| 465 if (exceptionState.hadException()) |
| 466 return; |
| 467 |
| 468 // Neuter the original array buffers on the sender context. |
| 469 SerializedScriptValue::transferArrayBufferContents(info.GetIsolate(), tr
ansferableArrayBuffers, exceptionState); |
| 470 if (exceptionState.hadException()) |
| 471 return; |
| 472 } |
| 473 |
| 448 // FIXME: Only pass context/exceptionState if instance really requires it. | 474 // FIXME: Only pass context/exceptionState if instance really requires it. |
| 449 ExecutionContext* context = currentExecutionContext(info.GetIsolate()); | 475 ExecutionContext* context = currentExecutionContext(info.GetIsolate()); |
| 450 instance->postMessage(context, message.release(), transferables.messagePorts
, exceptionState); | 476 instance->postMessage(context, message.release(), transferables.messagePorts
, exceptionState); |
| 451 } | 477 } |
| 452 {% endmacro %} | 478 {% endmacro %} |
| 453 | 479 |
| 454 | 480 |
| 455 {##############################################################################} | 481 {##############################################################################} |
| 456 {% macro method_callback(method, world_suffix) %} | 482 {% macro method_callback(method, world_suffix) %} |
| 457 void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCallbackInf
o<v8::Value>& info) | 483 void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCallbackInf
o<v8::Value>& info) |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 if method.overloads else | 678 if method.overloads else |
| 653 method.runtime_enabled_function) %} | 679 method.runtime_enabled_function) %} |
| 654 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; | 680 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; |
| 655 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto
typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); | 681 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto
typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); |
| 656 {% endfilter %}{# runtime_enabled() #} | 682 {% endfilter %}{# runtime_enabled() #} |
| 657 {% endfilter %}{# exposed() #} | 683 {% endfilter %}{# exposed() #} |
| 658 {% endfilter %}{# secure_context() #} | 684 {% endfilter %}{# secure_context() #} |
| 659 {% endfor %} | 685 {% endfor %} |
| 660 {% endif %} | 686 {% endif %} |
| 661 {%- endmacro %} | 687 {%- endmacro %} |
| OLD | NEW |