Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: third_party/WebKit/Source/bindings/templates/attributes.cpp

Issue 2022013002: binding: Makes [SaveSameObject] use V8PrivateProperty. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 %})
(...skipping 10 matching lines...) Expand all
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 attribute.is_save_same_object %} 30 {% if attribute.is_save_same_object %}
31 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "same object_{{attribute.name}}"); 31 {% set same_object_private_symbol = 'SameObject' + interface_name + attribut e.name[0]|capitalize + attribute.name[1:] %}
32 // If you see a compile error that
33 // V8PrivateProperty::get{{same_object_private_symbol}}
34 // is not defined, then you need to register your attribute at
35 // V8_PRIVATE_PROPERTY_FOR_EACH defined in V8PrivateProperty.h as
36 // X(SameObject, {{interface_name}}{{attribute.name[0]|capitalize}}{{attri bute.name[1:]}})
37 auto privateSameObject = V8PrivateProperty::getSameObject{{interface_name}}{ {attribute.name[0]|capitalize}}{{attribute.name[1:]}}(info.GetIsolate());
32 { 38 {
33 v8::Local<v8::Value> v8Value = V8HiddenValue::getHiddenValue(ScriptState ::current(info.GetIsolate()), holder, propertyName); 39 v8::Local<v8::Value> v8Value = privateSameObject.get(info.GetIsolate()-> GetCurrentContext(), holder);
34 if (!v8Value.IsEmpty()) { 40 if (!v8Value.IsEmpty()) {
35 v8SetReturnValue(info, v8Value); 41 v8SetReturnValue(info, v8Value);
36 return; 42 return;
37 } 43 }
38 } 44 }
39 {% endif %} 45 {% endif %}
40 {% if not attribute.is_static %} 46 {% if not attribute.is_static %}
41 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); 47 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
42 {% endif %} 48 {% endif %}
43 {% if attribute.cached_attribute_validation_method %} 49 {% if attribute.cached_attribute_validation_method %}
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 {% elif world_suffix %} 133 {% elif world_suffix %}
128 {{attribute.v8_set_return_value_for_main_world}}; 134 {{attribute.v8_set_return_value_for_main_world}};
129 {% else %} 135 {% else %}
130 {% if attribute.use_output_parameter_for_result %} 136 {% if attribute.use_output_parameter_for_result %}
131 {{attribute.cpp_type}} result; 137 {{attribute.cpp_type}} result;
132 {{attribute.cpp_value}}; 138 {{attribute.cpp_value}};
133 {% endif %} 139 {% endif %}
134 {{attribute.v8_set_return_value}}; 140 {{attribute.v8_set_return_value}};
135 {% endif %} 141 {% endif %}
136 {% if attribute.is_save_same_object %} 142 {% if attribute.is_save_same_object %}
137 V8HiddenValue::setHiddenValue(ScriptState::current(info.GetIsolate()), holde r, propertyName, info.GetReturnValue().Get()); 143 privateSameObject.set(info.GetIsolate()->GetCurrentContext(), holder, info.G etReturnValue().Get());
138 {% endif %} 144 {% endif %}
139 } 145 }
140 {% endmacro %} 146 {% endmacro %}
141 147
142 148
143 {######################################} 149 {######################################}
144 {% macro release_only_check(reflect_only_values, reflect_missing, 150 {% macro release_only_check(reflect_only_values, reflect_missing,
145 reflect_invalid, reflect_empty, cpp_value) %} 151 reflect_invalid, reflect_empty, cpp_value) %}
146 {# Attribute is limited to only known values: check that the attribute value is 152 {# Attribute is limited to only known values: check that the attribute value is
147 one of those. If not, set it to the empty string. 153 one of those. If not, set it to the empty string.
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 setter_callback_for_main_world, 518 setter_callback_for_main_world,
513 wrapper_type_info, 519 wrapper_type_info,
514 access_control, 520 access_control,
515 property_attribute, 521 property_attribute,
516 only_exposed_to_private_script, 522 only_exposed_to_private_script,
517 property_location(attribute), 523 property_location(attribute),
518 holder_check, 524 holder_check,
519 ] %} 525 ] %}
520 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 526 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
521 {%- endmacro %} 527 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698