| 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 attribute_getter(attribute, world_suffix) %} | 4 {% macro attribute_getter(attribute, world_suffix) %} |
| 5 {% if attribute.has_cross_origin_getter %} |
| 6 static void {{attribute.name}}CrossOriginAttributeGetter( |
| 7 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 8 v8::Local<v8::Object> holder = info.Holder(); |
| 9 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); |
| 10 |
| 11 {% if attribute.cpp_value_original %} |
| 12 {{attribute.cpp_type}} {{attribute.cpp_value}}({{attribute.cpp_value_original}
}); |
| 13 {% endif %} |
| 14 |
| 15 {% if attribute.is_keep_alive_for_gc %} |
| 16 // Keep the wrapper object for the return value alive as long as |this| |
| 17 // object is alive in order to save creation time of the wrapper object. |
| 18 if ({{attribute.cpp_value}} && DOMDataStore::setReturnValue(info.GetReturnValu
e(), {{attribute.cpp_value}})) |
| 19 return; |
| 20 |
| 21 // https://whatwg.org/C/browsers.html#crossorigingetownpropertyhelper-(-o,-p-) |
| 22 // |
| 23 // If e.[[NeedsGet]] is true, then set crossOriginGet to an anonymous |
| 24 // built-in function, created in the current Realm Record, that performs the |
| 25 // same steps as the getter of the IDL attribute P on object O. |
| 26 // |
| 27 // However, the spec doesn't say exactly how this would work. The cross-origin |
| 28 // |holder| object may not have a creation context associated with it. The |
| 29 // current discussion on https://github.com/whatwg/html/issues/2273 suggests |
| 30 // that crossOriginGet should return an origin-appropriate wrapper for Locatio
n |
| 31 // associated with the current Realm record. |
| 32 // |
| 33 // This attempts to follow that suggestion by using the current context as the |
| 34 // creation context rather than the creation context of |holder|. |
| 35 v8::Isolate* isolate = info.GetIsolate(); |
| 36 v8::Local<v8::Value> v8Value(ToV8({{attribute.cpp_value}}, isolate->GetCurrent
Context()->Global(), isolate)); |
| 37 const char kKeepAliveKey[] = "KeepAlive#{{interface_name}}#{{attribute.name}}"
; |
| 38 V8HiddenValue::setHiddenValue(ScriptState::current(info.GetIsolate()), holder,
v8AtomicString(info.GetIsolate(), StringView(kKeepAliveKey, sizeof kKeepAliveKe
y)), v8Value); |
| 39 {% endif %} |
| 40 |
| 41 {{attribute.v8_set_return_value}}; |
| 42 } |
| 43 {% endif %} |
| 44 |
| 5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( | 45 static void {{attribute.name}}AttributeGetter{{world_suffix}}( |
| 6 {%- if attribute.is_data_type_property %} | 46 {%- if attribute.is_data_type_property %} |
| 7 const v8::PropertyCallbackInfo<v8::Value>& info | 47 const v8::PropertyCallbackInfo<v8::Value>& info |
| 8 {%- else %} | 48 {%- else %} |
| 9 const v8::FunctionCallbackInfo<v8::Value>& info | 49 const v8::FunctionCallbackInfo<v8::Value>& info |
| 10 {%- endif %}) { | 50 {%- endif %}) { |
| 11 {% filter format_remove_duplicates(['ExceptionState exceptionState']) %} | 51 {% filter format_remove_duplicates(['ExceptionState exceptionState']) %} |
| 12 {% set define_exception_state -%} | 52 {% set define_exception_state -%} |
| 13 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext
, "{{interface_name}}", "{{attribute.name}}"); | 53 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::GetterContext
, "{{interface_name}}", "{{attribute.name}}"); |
| 14 {%- endset %} | 54 {%- endset %} |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 setter_callback_for_main_world, | 507 setter_callback_for_main_world, |
| 468 cached_accessor_callback, | 508 cached_accessor_callback, |
| 469 wrapper_type_info, | 509 wrapper_type_info, |
| 470 access_control, | 510 access_control, |
| 471 property_attribute, | 511 property_attribute, |
| 472 property_location(attribute), | 512 property_location(attribute), |
| 473 holder_check, | 513 holder_check, |
| 474 ] %} | 514 ] %} |
| 475 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} | 515 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} |
| 476 {%- endmacro %} | 516 {%- endmacro %} |
| OLD | NEW |