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

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

Issue 2199643003: binding: Uses the current context if attribute/method is static. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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 %} 1 {% from 'utilities.cpp' import declare_enum_validation_variable, v8_value_to_loc al_cpp_value %}
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 {% endif %} 55 {% endif %}
56 {% if interface_name == 'Window' and attribute.idl_type == 'EventHandler' %} 56 {% if interface_name == 'Window' and attribute.idl_type == 'EventHandler' %}
57 if (!impl->document()) 57 if (!impl->document())
58 return; 58 return;
59 {% endif %} 59 {% endif %}
60 {# Local variables #} 60 {# Local variables #}
61 {% if attribute.is_call_with_execution_context %} 61 {% if attribute.is_call_with_execution_context %}
62 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ()); 62 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ());
63 {% endif %} 63 {% endif %}
64 {% if attribute.is_call_with_script_state %} 64 {% if attribute.is_call_with_script_state %}
65 ScriptState* scriptState = ScriptState::forHolderObject(info); 65 {% if attribute.is_static %}
66 ScriptState* scriptState = ScriptState::forFunctionObject(info);
67 {% else %}
68 ScriptState* scriptState = ScriptState::forReceiverObject(info);
69 {% endif %}
66 {% endif %} 70 {% endif %}
67 {% if (attribute.is_check_security_for_receiver and 71 {% if (attribute.is_check_security_for_receiver and
68 not attribute.is_data_type_property) or 72 not attribute.is_data_type_property) or
69 attribute.is_check_security_for_return_value or 73 attribute.is_check_security_for_return_value or
70 attribute.is_getter_raises_exception %} 74 attribute.is_getter_raises_exception %}
71 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{interface_name}}", holder, info.GetIsolate()); 75 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{interface_name}}", holder, info.GetIsolate());
72 {% endif %} 76 {% endif %}
73 {% if attribute.is_explicit_nullable %} 77 {% if attribute.is_explicit_nullable %}
74 bool isNull = false; 78 bool isNull = false;
75 {% endif %} 79 {% endif %}
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 const v8::FunctionCallbackInfo<v8::Value>& info 190 const v8::FunctionCallbackInfo<v8::Value>& info
187 {%- endif %}) 191 {%- endif %})
188 { 192 {
189 {% if attribute.deprecate_as %} 193 {% if attribute.deprecate_as %}
190 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}); 194 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}});
191 {% endif %} 195 {% endif %}
192 {% if attribute.measure_as %} 196 {% if attribute.measure_as %}
193 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('AttributeGetter')}}); 197 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('AttributeGetter')}});
194 {% endif %} 198 {% endif %}
195 {% if world_suffix in attribute.activity_logging_world_list_for_getter %} 199 {% if world_suffix in attribute.activity_logging_world_list_for_getter %}
196 ScriptState* scriptState = ScriptState::forHolderObject(info); 200 {% if attribute.is_static %}
201 ScriptState* scriptState = ScriptState::forFunctionObject(info);
202 {% else %}
203 ScriptState* scriptState = ScriptState::forReceiverObject(info);
204 {% endif %}
197 V8PerContextData* contextData = scriptState->perContextData(); 205 V8PerContextData* contextData = scriptState->perContextData();
198 {% if attribute.activity_logging_world_check %} 206 {% if attribute.activity_logging_world_check %}
199 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac tivityLogger()) 207 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac tivityLogger())
200 {% else %} 208 {% else %}
201 if (contextData && contextData->activityLogger()) 209 if (contextData && contextData->activityLogger())
202 {% endif %} 210 {% endif %}
203 contextData->activityLogger()->logGetter("{{interface_name}}.{{attribute .name}}"); 211 contextData->activityLogger()->logGetter("{{interface_name}}.{{attribute .name}}");
204 {% endif %} 212 {% endif %}
205 {% if attribute.has_custom_getter %} 213 {% if attribute.has_custom_getter %}
206 {{v8_class}}::{{attribute.name}}AttributeGetterCustom(info); 214 {{v8_class}}::{{attribute.name}}AttributeGetterCustom(info);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 (attribute.is_reflect and 343 (attribute.is_reflect and
336 not(attribute.idl_type == 'DOMString' and is_node)) %} 344 not(attribute.idl_type == 'DOMString' and is_node)) %}
337 {# Skip on compact node DOMString getters #} 345 {# Skip on compact node DOMString getters #}
338 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; 346 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope;
339 {% endif %} 347 {% endif %}
340 {% if attribute.is_call_with_execution_context or 348 {% if attribute.is_call_with_execution_context or
341 attribute.is_setter_call_with_execution_context %} 349 attribute.is_setter_call_with_execution_context %}
342 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ()); 350 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ());
343 {% endif %} 351 {% endif %}
344 {% if attribute.is_call_with_script_state %} 352 {% if attribute.is_call_with_script_state %}
345 ScriptState* scriptState = ScriptState::forHolderObject(info); 353 {% if attribute.is_static %}
354 ScriptState* scriptState = ScriptState::forFunctionObject(info);
355 {% else %}
356 ScriptState* scriptState = ScriptState::forReceiverObject(info);
357 {% endif %}
346 {% endif %} 358 {% endif %}
347 {# Set #} 359 {# Set #}
348 {% if attribute.cpp_setter %} 360 {% if attribute.cpp_setter %}
349 {{attribute.cpp_setter}}; 361 {{attribute.cpp_setter}};
350 {% endif %} 362 {% endif %}
351 {# Post-set #} 363 {# Post-set #}
352 {% if attribute.is_setter_raises_exception %} 364 {% if attribute.is_setter_raises_exception %}
353 exceptionState.throwIfNeeded(); 365 exceptionState.throwIfNeeded();
354 {% endif %} 366 {% endif %}
355 {% if attribute.cached_attribute_validation_method %} 367 {% if attribute.cached_attribute_validation_method %}
(...skipping 15 matching lines...) Expand all
371 {% if not attribute.is_data_type_property %} 383 {% if not attribute.is_data_type_property %}
372 v8::Local<v8::Value> v8Value = info[0]; 384 v8::Local<v8::Value> v8Value = info[0];
373 {% endif %} 385 {% endif %}
374 {% if attribute.deprecate_as %} 386 {% if attribute.deprecate_as %}
375 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}); 387 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}});
376 {% endif %} 388 {% endif %}
377 {% if attribute.measure_as %} 389 {% if attribute.measure_as %}
378 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('AttributeSetter')}}); 390 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('AttributeSetter')}});
379 {% endif %} 391 {% endif %}
380 {% if world_suffix in attribute.activity_logging_world_list_for_setter %} 392 {% if world_suffix in attribute.activity_logging_world_list_for_setter %}
381 ScriptState* scriptState = ScriptState::forHolderObject(info); 393 {% if attribute.is_static %}
394 ScriptState* scriptState = ScriptState::forFunctionObject(info);
395 {% else %}
396 ScriptState* scriptState = ScriptState::forReceiverObject(info);
397 {% endif %}
382 V8PerContextData* contextData = scriptState->perContextData(); 398 V8PerContextData* contextData = scriptState->perContextData();
383 {% if attribute.activity_logging_world_check %} 399 {% if attribute.activity_logging_world_check %}
384 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac tivityLogger()) { 400 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac tivityLogger()) {
385 {% else %} 401 {% else %}
386 if (contextData && contextData->activityLogger()) { 402 if (contextData && contextData->activityLogger()) {
387 {% endif %} 403 {% endif %}
388 contextData->activityLogger()->logSetter("{{interface_name}}.{{attribute .name}}", v8Value); 404 contextData->activityLogger()->logSetter("{{interface_name}}.{{attribute .name}}", v8Value);
389 } 405 }
390 {% endif %} 406 {% endif %}
391 {% if attribute.is_ce_reactions %} 407 {% if attribute.is_ce_reactions %}
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 setter_callback_for_main_world, 525 setter_callback_for_main_world,
510 wrapper_type_info, 526 wrapper_type_info,
511 access_control, 527 access_control,
512 property_attribute, 528 property_attribute,
513 only_exposed_to_private_script, 529 only_exposed_to_private_script,
514 property_location(attribute), 530 property_location(attribute),
515 holder_check, 531 holder_check,
516 ] %} 532 ] %}
517 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 533 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
518 {%- endmacro %} 534 {%- endmacro %}
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptState.h ('k') | third_party/WebKit/Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698