OLD | NEW |
1 {% extends 'interface_base.cpp' %} | 1 {% extends 'interface_base.cpp' %} |
2 | 2 |
3 | 3 |
4 {##############################################################################} | 4 {##############################################################################} |
5 {% block indexed_property_getter %} | 5 {% block indexed_property_getter %} |
6 {% if indexed_property_getter and not indexed_property_getter.is_custom %} | 6 {% if indexed_property_getter and not indexed_property_getter.is_custom %} |
7 {% set getter = indexed_property_getter %} | 7 {% set getter = indexed_property_getter %} |
8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) | 8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) |
9 { | 9 { |
10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 {# No match, throw error #} | 538 {# No match, throw error #} |
539 exceptionState.throwTypeError("No matching constructor signature."); | 539 exceptionState.throwTypeError("No matching constructor signature."); |
540 exceptionState.throwIfNeeded(); | 540 exceptionState.throwIfNeeded(); |
541 } | 541 } |
542 | 542 |
543 {% endif %} | 543 {% endif %} |
544 {% endblock %} | 544 {% endblock %} |
545 | 545 |
546 | 546 |
547 {##############################################################################} | 547 {##############################################################################} |
548 {% block event_constructor %} | |
549 {% if has_event_constructor %} | |
550 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | |
551 { | |
552 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf
ace_name}}", info.Holder(), info.GetIsolate()); | |
553 if (info.Length() < 1) { | |
554 exceptionState.throwTypeError("An event name must be provided."); | |
555 exceptionState.throwIfNeeded(); | |
556 return; | |
557 } | |
558 | |
559 V8StringResource<> type(info[0]); | |
560 if (!type.prepare()) | |
561 return; | |
562 {% for attribute in any_type_attributes %} | |
563 v8::Local<v8::Value> {{attribute.name}}; | |
564 {% endfor %} | |
565 {{cpp_class}}Init eventInit; | |
566 if (info.Length() >= 2) { | |
567 Dictionary options(info[1], info.GetIsolate(), exceptionState); | |
568 if (!initialize{{cpp_class}}(eventInit, options, exceptionState, info))
{ | |
569 exceptionState.throwIfNeeded(); | |
570 return; | |
571 } | |
572 {# Store attributes of type |any| on the wrapper to avoid leaking them | |
573 between isolated worlds. #} | |
574 {% for attribute in any_type_attributes %} | |
575 options.get("{{attribute.name}}", {{attribute.name}}); | |
576 if (!{{attribute.name}}.IsEmpty()) | |
577 V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), v8At
omicString(info.GetIsolate(), "{{attribute.name}}"), {{attribute.name}}); | |
578 {% endfor %} | |
579 } | |
580 {% if is_constructor_raises_exception %} | |
581 RefPtrWillBeRawPtr<{{cpp_class}}> event = {{cpp_class}}::create(type, eventI
nit, exceptionState); | |
582 if (exceptionState.throwIfNeeded()) | |
583 return; | |
584 {% else %} | |
585 RefPtrWillBeRawPtr<{{cpp_class}}> event = {{cpp_class}}::create(type, eventI
nit); | |
586 {% endif %} | |
587 {% if any_type_attributes %} | |
588 {# If we're in an isolated world, create a SerializedScriptValue and store | |
589 it in the event for later cloning if the property is accessed from | |
590 another world. The main world case is handled lazily (in custom code). #} | |
591 if (DOMWrapperWorld::current(info.GetIsolate()).isIsolatedWorld()) { | |
592 {% for attribute in any_type_attributes %} | |
593 if (!{{attribute.name}}.IsEmpty()) | |
594 event->setSerialized{{attribute.name | blink_capitalize}}(Serialized
ScriptValueFactory::instance().createAndSwallowExceptions(info.GetIsolate(), {{a
ttribute.name}})); | |
595 {% endfor %} | |
596 } | |
597 | |
598 {% endif %} | |
599 v8::Local<v8::Object> wrapper = info.Holder(); | |
600 event->associateWithWrapper(info.GetIsolate(), &{{v8_class}}::wrapperTypeInf
o, wrapper); | |
601 v8SetReturnValue(info, wrapper); | |
602 } | |
603 | |
604 {% endif %} | |
605 {% endblock %} | |
606 | |
607 | |
608 {##############################################################################} | |
609 {% block visit_dom_wrapper %} | 548 {% block visit_dom_wrapper %} |
610 {% if reachable_node_function or set_wrapper_reference_to_list %} | 549 {% if reachable_node_function or set_wrapper_reference_to_list %} |
611 void {{v8_class}}::visitDOMWrapper(v8::Isolate* isolate, ScriptWrappable* script
Wrappable, const v8::Persistent<v8::Object>& wrapper) | 550 void {{v8_class}}::visitDOMWrapper(v8::Isolate* isolate, ScriptWrappable* script
Wrappable, const v8::Persistent<v8::Object>& wrapper) |
612 { | 551 { |
613 {{cpp_class}}* impl = scriptWrappable->toImpl<{{cpp_class}}>(); | 552 {{cpp_class}}* impl = scriptWrappable->toImpl<{{cpp_class}}>(); |
614 {% if set_wrapper_reference_to_list %} | 553 {% if set_wrapper_reference_to_list %} |
615 v8::Local<v8::Object> creationContext = v8::Local<v8::Object>::New(isolate,
wrapper); | 554 v8::Local<v8::Object> creationContext = v8::Local<v8::Object>::New(isolate,
wrapper); |
616 V8WrapperInstantiationScope scope(creationContext, isolate); | 555 V8WrapperInstantiationScope scope(creationContext, isolate); |
617 {% for set_wrapper_reference_to in set_wrapper_reference_to_list %} | 556 {% for set_wrapper_reference_to in set_wrapper_reference_to_list %} |
618 {{set_wrapper_reference_to.cpp_type}} {{set_wrapper_reference_to.name}} = im
pl->{{set_wrapper_reference_to.name}}(); | 557 {{set_wrapper_reference_to.cpp_type}} {{set_wrapper_reference_to.name}} = im
pl->{{set_wrapper_reference_to.name}}(); |
(...skipping 27 matching lines...) Expand all Loading... |
646 {% for attribute in attributes if attribute.is_unforgeable and attribute.sho
uld_be_exposed_to_script %} | 585 {% for attribute in attributes if attribute.is_unforgeable and attribute.sho
uld_be_exposed_to_script %} |
647 {{attribute_configuration(attribute)}}, | 586 {{attribute_configuration(attribute)}}, |
648 {% endfor %} | 587 {% endfor %} |
649 }; | 588 }; |
650 | 589 |
651 {% endif %} | 590 {% endif %} |
652 {% endblock %} | 591 {% endblock %} |
653 | 592 |
654 | 593 |
655 {##############################################################################} | 594 {##############################################################################} |
656 {% block initialize_event %} | |
657 {% if has_event_constructor %} | |
658 {{exported}}bool initialize{{cpp_class}}({{cpp_class}}Init& eventInit, const Dic
tionary& options, ExceptionState& exceptionState, const v8::FunctionCallbackInfo
<v8::Value>& info) | |
659 { | |
660 Dictionary::ConversionContext conversionContext(exceptionState); | |
661 {% if parent_interface %}{# any Event interface except Event itself #} | |
662 if (!initialize{{parent_interface}}(eventInit, options, exceptionState, info
)) | |
663 return false; | |
664 | |
665 {% endif %} | |
666 {% for attribute in attributes | |
667 if (attribute.is_initialized_by_event_constructor and | |
668 not attribute.idl_type == 'any')%} | |
669 {% set is_nullable = 'true' if attribute.is_nullable else 'false' %} | |
670 {% if attribute.deprecate_as %} | |
671 if (DictionaryHelper::convert(options, conversionContext.setConversionType("
{{attribute.idl_type}}", {{is_nullable}}), "{{attribute.name}}", eventInit.{{att
ribute.cpp_name}})) { | |
672 if (options.hasProperty("{{attribute.name}}")) | |
673 UseCounter::countDeprecationIfNotPrivateScript(info.GetIsolate(), ca
llingExecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}
); | |
674 } else { | |
675 return false; | |
676 } | |
677 {% else %} | |
678 if (!DictionaryHelper::convert(options, conversionContext.setConversionType(
"{{attribute.idl_type}}", {{is_nullable}}), "{{attribute.name}}", eventInit.{{at
tribute.cpp_name}})) | |
679 return false; | |
680 {% endif %} | |
681 {% endfor %} | |
682 return true; | |
683 } | |
684 | |
685 {% endif %} | |
686 {% endblock %} | |
687 | |
688 | |
689 {##############################################################################} | |
690 {% block constructor_callback %} | 595 {% block constructor_callback %} |
691 {% if constructors or has_custom_constructor or has_event_constructor %} | 596 {% if constructors or has_custom_constructor or has_event_constructor %} |
692 void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>
& info) | 597 void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>
& info) |
693 { | 598 { |
694 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor"); | 599 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor"); |
695 {% if measure_as %} | 600 {% if measure_as %} |
696 UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionConte
xt(info.GetIsolate()), UseCounter::{{measure_as('Constructor')}}); | 601 UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionConte
xt(info.GetIsolate()), UseCounter::{{measure_as('Constructor')}}); |
697 {% endif %} | 602 {% endif %} |
698 if (!info.IsConstructCall()) { | 603 if (!info.IsConstructCall()) { |
699 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::c
onstructorNotCallableAsFunction("{{interface_name}}")); | 604 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::c
onstructorNotCallableAsFunction("{{interface_name}}")); |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 } | 943 } |
1039 | 944 |
1040 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} | 945 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} |
1041 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) | 946 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) |
1042 { | 947 { |
1043 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; | 948 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; |
1044 } | 949 } |
1045 {% endfor %} | 950 {% endfor %} |
1046 {% endif %} | 951 {% endif %} |
1047 {% endblock %} | 952 {% endblock %} |
OLD | NEW |