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

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

Issue 1380503002: binding: Makes Window/Location's attributes accessor-type properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated the test for cross-origin accesses. Created 4 years, 7 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 %})
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 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(in fo.This(), info.GetIsolate());
25 if (holder.IsEmpty())
25 return; // Return silently because of [LenientThis]. 26 return; // Return silently because of [LenientThis].
27 {% else %}
28 v8::Local<v8::Object> holder = info.Holder();
26 {% endif %} 29 {% endif %}
27 v8::Local<v8::Object> holder = info.Holder();
28 {% endif %} 30 {% endif %}
29 {# impl #} 31 {# impl #}
30 {% if attribute.cached_attribute_validation_method %} 32 {% if attribute.cached_attribute_validation_method %}
31 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{at tribute.name}}"); 33 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{at tribute.name}}");
32 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); 34 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
33 if (!impl->{{attribute.cached_attribute_validation_method}}()) { 35 if (!impl->{{attribute.cached_attribute_validation_method}}()) {
34 v8::Local<v8::Value> v8Value = V8HiddenValue::getHiddenValue(ScriptState ::current(info.GetIsolate()), holder, propertyName); 36 v8::Local<v8::Value> v8Value = V8HiddenValue::getHiddenValue(ScriptState ::current(info.GetIsolate()), holder, propertyName);
35 if (!v8Value.IsEmpty() && !v8Value->IsUndefined()) { 37 if (!v8Value.IsEmpty() && !v8Value->IsUndefined()) {
36 v8SetReturnValue(info, v8Value); 38 v8SetReturnValue(info, v8Value);
37 return; 39 return;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 {% endif %} 71 {% endif %}
70 {# Checks #} 72 {# Checks #}
71 {% if attribute.is_getter_raises_exception %} 73 {% if attribute.is_getter_raises_exception %}
72 if (UNLIKELY(exceptionState.throwIfNeeded())) 74 if (UNLIKELY(exceptionState.throwIfNeeded()))
73 return; 75 return;
74 {% endif %} 76 {% endif %}
75 {# Security checks #} 77 {# Security checks #}
76 {% if not attribute.is_data_type_property %} 78 {% if not attribute.is_data_type_property %}
77 {% if attribute.is_check_security_for_receiver %} 79 {% if attribute.is_check_security_for_receiver %}
78 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindo w(info.GetIsolate()), impl, exceptionState)) { 80 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindo w(info.GetIsolate()), impl, exceptionState)) {
79 v8SetReturnValueNull(info); 81 {{attribute.v8_set_return_value_for_security_failure}};
80 exceptionState.throwIfNeeded(); 82 exceptionState.throwIfNeeded();
81 return; 83 return;
82 } 84 }
83 {% endif %} 85 {% endif %}
84 {% endif %} 86 {% endif %}
85 {% if attribute.is_check_security_for_return_value %} 87 {% if attribute.is_check_security_for_return_value %}
86 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindo w(info.GetIsolate()), {{attribute.cpp_value}}, exceptionState)) { 88 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindo w(info.GetIsolate()), {{attribute.cpp_value}}, exceptionState)) {
87 v8SetReturnValueNull(info); 89 v8SetReturnValueNull(info);
haraken 2016/04/27 16:15:12 Does this need to be checked as well?
Yuki 2016/04/28 07:53:39 I was on the fence at this point, but now I follow
88 exceptionState.throwIfNeeded(); 90 exceptionState.throwIfNeeded();
89 return; 91 return;
90 } 92 }
91 {% endif %} 93 {% endif %}
92 {% if attribute.reflect_only %} 94 {% if attribute.reflect_only %}
93 {{release_only_check(attribute.reflect_only, attribute.reflect_missing, 95 {{release_only_check(attribute.reflect_only, attribute.reflect_missing,
94 attribute.reflect_invalid, attribute.reflect_empty, 96 attribute.reflect_invalid, attribute.reflect_empty,
95 attribute.cpp_value) 97 attribute.cpp_value)
96 | indent}} 98 | indent}}
97 {% endif %} 99 {% endif %}
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 {% else %} 241 {% else %}
240 {% set raise_exception = 0 %} 242 {% set raise_exception = 0 %}
241 {% endif %} 243 {% endif %}
242 {# Local variables #} 244 {# Local variables #}
243 {% if (not attribute.is_static and 245 {% if (not attribute.is_static and
244 not attribute.is_replaceable and 246 not attribute.is_replaceable and
245 not attribute.constructor_type) or 247 not attribute.constructor_type) or
246 raise_exception %} 248 raise_exception %}
247 {% if attribute.is_lenient_this %} 249 {% if attribute.is_lenient_this %}
248 {# Make sure that info.Holder() really points to an instance if [LenientThis ]. #} 250 {# Make sure that info.Holder() really points to an instance if [LenientThis ]. #}
249 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) 251 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(in fo.This(), info.GetIsolate());
252 if (holder.IsEmpty())
250 return; // Return silently because of [LenientThis]. 253 return; // Return silently because of [LenientThis].
254 {% else %}
255 v8::Local<v8::Object> holder = info.Holder();
251 {% endif %} 256 {% endif %}
252 v8::Local<v8::Object> holder = info.Holder();
253 {% endif %} 257 {% endif %}
254 {% if raise_exception %} 258 {% if raise_exception %}
255 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{interface_name}}", holder, info.GetIsolate()); 259 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{interface_name}}", holder, info.GetIsolate());
256 {% endif %} 260 {% endif %}
257 {% if attribute.is_replaceable or 261 {% if attribute.is_replaceable or
258 attribute.constructor_type %} 262 attribute.constructor_type %}
259 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{at tribute.name}}"); 263 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{at tribute.name}}");
260 {% endif %} 264 {% endif %}
261 {# impl #} 265 {# impl #}
262 {% if attribute.is_put_forwards %} 266 {% if attribute.is_put_forwards %}
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 setter_callback_for_main_world, 503 setter_callback_for_main_world,
500 wrapper_type_info, 504 wrapper_type_info,
501 access_control, 505 access_control,
502 property_attribute, 506 property_attribute,
503 only_exposed_to_private_script, 507 only_exposed_to_private_script,
504 property_location(attribute), 508 property_location(attribute),
505 holder_check, 509 holder_check,
506 ] %} 510 ] %}
507 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 511 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
508 {%- endmacro %} 512 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698