Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {% from 'utilities.cpp' import declare_enum_validation_variable, v8_value_to_loc al_cpp_value, check_origin_trial %} | 1 {% from 'utilities.cpp' import declare_enum_validation_variable, v8_value_to_loc al_cpp_value, check_origin_trial %} |
| 2 | 2 |
| 3 {##############################################################################} | 3 {##############################################################################} |
| 4 {% macro attribute_getter(attribute, world_suffix) %} | 4 {% macro attribute_getter(attribute, world_suffix) %} |
| 5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( | 5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( |
| 6 {%- if attribute.is_data_type_property %} | 6 {%- if attribute.is_data_type_property %} |
| 7 const v8::PropertyCallbackInfo<v8::Value>& info | 7 const v8::PropertyCallbackInfo<v8::Value>& info |
| 8 {%- else %} | 8 {%- else %} |
| 9 const v8::FunctionCallbackInfo<v8::Value>& info | 9 const v8::FunctionCallbackInfo<v8::Value>& info |
| 10 {%- endif %}) | 10 {%- endif %}) |
| 11 { | 11 { |
| 12 {% if attribute.origin_trial_enabled_function %} | 12 {% if attribute.origin_trial_enabled_function %} |
| 13 {{check_origin_trial(attribute) | indent}} | 13 {{check_origin_trial(attribute) | indent}} |
| 14 {% endif %} | 14 {% endif %} |
| 15 {% if attribute.is_reflect and not attribute.is_url | 15 {% if attribute.is_reflect and not attribute.is_url |
| 16 and attribute.idl_type == 'DOMString' and is_node | 16 and attribute.idl_type == 'DOMString' and is_node |
| 17 and not attribute.is_implemented_in_private_script %} | 17 and not attribute.is_implemented_in_private_script %} |
| 18 {% set cpp_class, v8_class = 'Element', 'V8Element' %} | 18 {% set cpp_class, v8_class = 'Element', 'V8Element' %} |
| 19 {% endif %} | 19 {% endif %} |
| 20 {# holder #} | 20 {# holder #} |
| 21 {% if not attribute.is_static %} | 21 {% if not attribute.is_static %} |
| 22 {% if attribute.is_lenient_this %} | 22 {% if attribute.is_lenient_this %} |
| 23 {# Make sure that info.Holder() really points to an instance if [LenientThis ]. #} | 23 {# Make sure that info.Holder() really points to an instance if [LenientThis ]. #} |
| 24 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) | 24 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) |
| 25 return; // Return silently because of [LenientThis]. | 25 return; // Return silently because of [LenientThis]. |
| 26 {% endif %} | 26 {% endif %} |
| 27 v8::Local<v8::Object> holder = info.Holder(); | 27 v8::Local<v8::Object> holder = info.Holder(); |
| 28 {% endif %} | 28 {% endif %} |
| 29 {# impl #} | 29 {# impl #} |
| 30 {% if not attribute.is_static %} | |
| 31 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | |
| 32 {% endif %} | |
| 33 {% if attribute.is_same_object %} | |
| 34 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "same object_{{attribute.name}}"); | |
| 35 { | |
| 36 v8::Local<v8::Value> v8Value = V8HiddenValue::getHiddenValue(ScriptState ::current(info.GetIsolate()), holder, propertyName); | |
| 37 if (!v8Value.IsEmpty()) { | |
| 38 v8SetReturnValue(info, v8Value); | |
| 39 return; | |
| 40 } | |
| 41 } | |
| 42 {% endif %} | |
| 30 {% if attribute.cached_attribute_validation_method %} | 43 {% if attribute.cached_attribute_validation_method %} |
| 31 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{at tribute.name}}"); | 44 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{at tribute.name}}"); |
| 32 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | |
| 33 if (!impl->{{attribute.cached_attribute_validation_method}}()) { | 45 if (!impl->{{attribute.cached_attribute_validation_method}}()) { |
| 34 v8::Local<v8::Value> v8Value = V8HiddenValue::getHiddenValue(ScriptState ::current(info.GetIsolate()), holder, propertyName); | 46 v8::Local<v8::Value> v8Value = V8HiddenValue::getHiddenValue(ScriptState ::current(info.GetIsolate()), holder, propertyName); |
| 35 if (!v8Value.IsEmpty() && !v8Value->IsUndefined()) { | 47 if (!v8Value.IsEmpty() && !v8Value->IsUndefined()) { |
| 36 v8SetReturnValue(info, v8Value); | 48 v8SetReturnValue(info, v8Value); |
| 37 return; | 49 return; |
| 38 } | 50 } |
| 39 } | 51 } |
| 40 {% elif not attribute.is_static %} | |
| 41 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | |
| 42 {% endif %} | 52 {% endif %} |
| 43 {% if interface_name == 'Window' and attribute.idl_type == 'EventHandler' %} | 53 {% if interface_name == 'Window' and attribute.idl_type == 'EventHandler' %} |
| 44 if (!impl->document()) | 54 if (!impl->document()) |
| 45 return; | 55 return; |
| 46 {% endif %} | 56 {% endif %} |
| 47 {# Local variables #} | 57 {# Local variables #} |
| 48 {% if attribute.is_call_with_execution_context %} | 58 {% if attribute.is_call_with_execution_context %} |
| 49 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ()); | 59 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ()); |
| 50 {% endif %} | 60 {% endif %} |
| 51 {% if attribute.is_call_with_script_state %} | 61 {% if attribute.is_call_with_script_state %} |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 } | 126 } |
| 117 {% elif world_suffix %} | 127 {% elif world_suffix %} |
| 118 {{attribute.v8_set_return_value_for_main_world}}; | 128 {{attribute.v8_set_return_value_for_main_world}}; |
| 119 {% else %} | 129 {% else %} |
| 120 {% if attribute.use_output_parameter_for_result %} | 130 {% if attribute.use_output_parameter_for_result %} |
| 121 {{attribute.cpp_type}} result; | 131 {{attribute.cpp_type}} result; |
| 122 {{attribute.cpp_value}}; | 132 {{attribute.cpp_value}}; |
| 123 {% endif %} | 133 {% endif %} |
| 124 {{attribute.v8_set_return_value}}; | 134 {{attribute.v8_set_return_value}}; |
| 125 {% endif %} | 135 {% endif %} |
| 136 {% if attribute.is_same_object %} | |
| 137 V8HiddenValue::setHiddenValue(ScriptState::current(info.GetIsolate()), holde r, propertyName, info.GetReturnValue().Get()); | |
|
haraken
2016/05/16 09:17:44
Can we merge the branch with '{% if attribute.cach
Yuki
2016/05/16 09:32:14
I had the same idea, but it turned out that it's n
| |
| 138 {% endif %} | |
| 126 } | 139 } |
| 127 {% endmacro %} | 140 {% endmacro %} |
| 128 | 141 |
| 129 | 142 |
| 130 {######################################} | 143 {######################################} |
| 131 {% macro release_only_check(reflect_only_values, reflect_missing, | 144 {% macro release_only_check(reflect_only_values, reflect_missing, |
| 132 reflect_invalid, reflect_empty, cpp_value) %} | 145 reflect_invalid, reflect_empty, cpp_value) %} |
| 133 {# Attribute is limited to only known values: check that the attribute value is | 146 {# Attribute is limited to only known values: check that the attribute value is |
| 134 one of those. If not, set it to the empty string. | 147 one of those. If not, set it to the empty string. |
| 135 http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known-valu es #} | 148 http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known-valu es #} |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 499 setter_callback_for_main_world, | 512 setter_callback_for_main_world, |
| 500 wrapper_type_info, | 513 wrapper_type_info, |
| 501 access_control, | 514 access_control, |
| 502 property_attribute, | 515 property_attribute, |
| 503 only_exposed_to_private_script, | 516 only_exposed_to_private_script, |
| 504 property_location(attribute), | 517 property_location(attribute), |
| 505 holder_check, | 518 holder_check, |
| 506 ] %} | 519 ] %} |
| 507 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} | 520 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} |
| 508 {%- endmacro %} | 521 {%- endmacro %} |
| OLD | NEW |