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

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

Issue 1526833003: bindings: Fixes [LenientThis] to refer to the correct object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Synced. Created 5 years 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 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %} 1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro attribute_getter(attribute, world_suffix) %} 5 {% macro attribute_getter(attribute, world_suffix) %}
6 {% filter conditional(attribute.conditional_string) %} 6 {% filter conditional(attribute.conditional_string) %}
7 static void {{attribute.name}}AttributeGetter{{world_suffix}}( 7 static void {{attribute.name}}AttributeGetter{{world_suffix}}(
8 {%- if attribute.is_data_type_property %} 8 {%- if attribute.is_data_type_property %}
9 const v8::PropertyCallbackInfo<v8::Value>& info 9 const v8::PropertyCallbackInfo<v8::Value>& info
10 {%- else %} 10 {%- else %}
11 const v8::FunctionCallbackInfo<v8::Value>& info 11 const v8::FunctionCallbackInfo<v8::Value>& info
12 {%- endif %}) 12 {%- endif %})
13 { 13 {
14 {% if attribute.is_reflect and not attribute.is_url 14 {% if attribute.is_reflect and not attribute.is_url
15 and attribute.idl_type == 'DOMString' and is_node 15 and attribute.idl_type == 'DOMString' and is_node
16 and not attribute.is_implemented_in_private_script %} 16 and not attribute.is_implemented_in_private_script %}
17 {% set cpp_class, v8_class = 'Element', 'V8Element' %} 17 {% set cpp_class, v8_class = 'Element', 'V8Element' %}
18 {% endif %} 18 {% endif %}
19 {# holder #} 19 {# holder #}
20 {% if not attribute.is_static %} 20 {% if not attribute.is_static %}
21 {% if attribute.is_lenient_this %} 21 {% if attribute.is_lenient_this %}
22 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(in fo.This(), info.GetIsolate()); 22 {# Make sure that info.Holder() really points to an instance if [LenientThis ]. #}
23 if (holder.IsEmpty()) 23 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate()))
24 return; // Return silently because of [LenientThis]. 24 return; // Return silently because of [LenientThis].
25 // Note that it's okay to use |holder|, but |info.Holder()| is still unsafe 25 {% endif %}
26 // and must not be used.
27 {% else %}
28 v8::Local<v8::Object> holder = info.Holder(); 26 v8::Local<v8::Object> holder = info.Holder();
29 {% endif %} 27 {% endif %}
30 {% endif %}
31 {# impl #} 28 {# impl #}
32 {% if attribute.cached_attribute_validation_method %} 29 {% if attribute.cached_attribute_validation_method %}
33 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{at tribute.name}}"); 30 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{at tribute.name}}");
34 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); 31 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
35 if (!impl->{{attribute.cached_attribute_validation_method}}()) { 32 if (!impl->{{attribute.cached_attribute_validation_method}}()) {
36 v8::Local<v8::Value> v8Value = V8HiddenValue::getHiddenValue(ScriptState ::current(info.GetIsolate()), holder, propertyName); 33 v8::Local<v8::Value> v8Value = V8HiddenValue::getHiddenValue(ScriptState ::current(info.GetIsolate()), holder, propertyName);
37 if (!v8Value.IsEmpty()) { 34 if (!v8Value.IsEmpty()) {
38 v8SetReturnValue(info, v8Value); 35 v8SetReturnValue(info, v8Value);
39 return; 36 return;
40 } 37 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 {% set raise_exception = 1 %} 241 {% set raise_exception = 1 %}
245 {% else %} 242 {% else %}
246 {% set raise_exception = 0 %} 243 {% set raise_exception = 0 %}
247 {% endif %} 244 {% endif %}
248 {# Local variables #} 245 {# Local variables #}
249 {% if (not attribute.is_static and 246 {% if (not attribute.is_static and
250 not attribute.is_replaceable and 247 not attribute.is_replaceable and
251 not attribute.constructor_type) or 248 not attribute.constructor_type) or
252 raise_exception %} 249 raise_exception %}
253 {% if attribute.is_lenient_this %} 250 {% if attribute.is_lenient_this %}
254 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(in fo.This(), info.GetIsolate()); 251 {# Make sure that info.Holder() really points to an instance if [LenientThis ]. #}
255 if (holder.IsEmpty()) 252 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate()))
256 return; // Return silently because of [LenientThis]. 253 return; // Return silently because of [LenientThis].
257 // Note that it's okay to use |holder|, but |info.Holder()| is still unsafe 254 {% endif %}
258 // and must not be used.
259 {% else %}
260 v8::Local<v8::Object> holder = info.Holder(); 255 v8::Local<v8::Object> holder = info.Holder();
261 {% endif %} 256 {% endif %}
262 {% endif %}
263 {% if raise_exception %} 257 {% if raise_exception %}
264 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{interface_name}}", holder, info.GetIsolate()); 258 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{interface_name}}", holder, info.GetIsolate());
265 {% endif %} 259 {% endif %}
266 {% if attribute.is_replaceable or 260 {% if attribute.is_replaceable or
267 attribute.constructor_type %} 261 attribute.constructor_type %}
268 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{at tribute.name}}"); 262 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{at tribute.name}}");
269 {% endif %} 263 {% endif %}
270 {# impl #} 264 {# impl #}
271 {% if attribute.is_put_forwards %} 265 {% if attribute.is_put_forwards %}
272 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder); 266 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 setter_callback_for_main_world, 506 setter_callback_for_main_world,
513 wrapper_type_info, 507 wrapper_type_info,
514 access_control, 508 access_control,
515 property_attribute, 509 property_attribute,
516 only_exposed_to_private_script, 510 only_exposed_to_private_script,
517 property_location(attribute), 511 property_location(attribute),
518 holder_check, 512 holder_check,
519 ] %} 513 ] %}
520 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 514 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
521 {%- endmacro %} 515 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698