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

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

Issue 2005433002: [Origin Trials] Install origin trial bindings on V8 context conditionally (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@track-ef-install
Patch Set: Fix multiple definition of signature; addressing nits 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 %}
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 %}
13 {{check_origin_trial(attribute) | indent}}
14 {% endif %}
15 {% if attribute.is_reflect and not attribute.is_url 12 {% if attribute.is_reflect and not attribute.is_url
16 and attribute.idl_type == 'DOMString' and is_node 13 and attribute.idl_type == 'DOMString' and is_node
17 and not attribute.is_implemented_in_private_script %} 14 and not attribute.is_implemented_in_private_script %}
18 {% set cpp_class, v8_class = 'Element', 'V8Element' %} 15 {% set cpp_class, v8_class = 'Element', 'V8Element' %}
19 {% endif %} 16 {% endif %}
20 {# holder #} 17 {# holder #}
21 {% if not attribute.is_static %} 18 {% if not attribute.is_static %}
22 {% if attribute.is_lenient_this %} 19 {% if attribute.is_lenient_this %}
23 {# Make sure that info.Holder() really points to an instance if [LenientThis ]. #} 20 {# Make sure that info.Holder() really points to an instance if [LenientThis ]. #}
24 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) 21 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate()))
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 {%- else %} 179 {%- else %}
183 const v8::FunctionCallbackInfo<v8::Value>& info 180 const v8::FunctionCallbackInfo<v8::Value>& info
184 {%- endif %}) 181 {%- endif %})
185 { 182 {
186 {% if attribute.deprecate_as %} 183 {% if attribute.deprecate_as %}
187 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}); 184 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}});
188 {% endif %} 185 {% endif %}
189 {% if attribute.measure_as %} 186 {% if attribute.measure_as %}
190 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('AttributeGetter')}}); 187 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('AttributeGetter')}});
191 {% endif %} 188 {% endif %}
192 {% if attribute.origin_trial_enabled_function %}
193 {{check_origin_trial(attribute) | indent}}
194 {% endif %}
195 {% if world_suffix in attribute.activity_logging_world_list_for_getter %} 189 {% if world_suffix in attribute.activity_logging_world_list_for_getter %}
196 ScriptState* scriptState = ScriptState::from(info.GetIsolate()->GetCurrentCo ntext()); 190 ScriptState* scriptState = ScriptState::from(info.GetIsolate()->GetCurrentCo ntext());
197 V8PerContextData* contextData = scriptState->perContextData(); 191 V8PerContextData* contextData = scriptState->perContextData();
198 {% if attribute.activity_logging_world_check %} 192 {% if attribute.activity_logging_world_check %}
199 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac tivityLogger()) 193 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac tivityLogger())
200 {% else %} 194 {% else %}
201 if (contextData && contextData->activityLogger()) 195 if (contextData && contextData->activityLogger())
202 {% endif %} 196 {% endif %}
203 contextData->activityLogger()->logGetter("{{interface_name}}.{{attribute .name}}"); 197 contextData->activityLogger()->logGetter("{{interface_name}}.{{attribute .name}}");
204 {% endif %} 198 {% endif %}
205 {% if attribute.has_custom_getter %} 199 {% if attribute.has_custom_getter %}
206 {{v8_class}}::{{attribute.name}}AttributeGetterCustom(info); 200 {{v8_class}}::{{attribute.name}}AttributeGetterCustom(info);
207 {% else %} 201 {% else %}
208 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeGetter{{world _suffix}}(info); 202 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeGetter{{world _suffix}}(info);
209 {% endif %} 203 {% endif %}
210 } 204 }
211 {% endmacro %} 205 {% endmacro %}
212 206
213 207
214 {##############################################################################} 208 {##############################################################################}
215 {% macro constructor_getter_callback(attribute, world_suffix) %} 209 {% macro constructor_getter_callback(attribute, world_suffix) %}
216 static void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Loca l<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value>& info) 210 static void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Loca l<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value>& info)
217 { 211 {
218 {% if attribute.deprecate_as %} 212 {% if attribute.deprecate_as %}
219 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}); 213 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}});
220 {% endif %} 214 {% endif %}
221 {% if attribute.measure_as %} 215 {% if attribute.measure_as %}
222 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('ConstructorGetter')}} ); 216 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('ConstructorGetter')}} );
223 {% endif %} 217 {% endif %}
224 {% if attribute.origin_trial_enabled_function %}
225 {{check_origin_trial(attribute) | indent}}
226 {% endif %}
227 v8ConstructorAttributeGetter(property, info); 218 v8ConstructorAttributeGetter(property, info);
228 } 219 }
229 {% endmacro %} 220 {% endmacro %}
230 221
231 222
232 {##############################################################################} 223 {##############################################################################}
233 {% macro attribute_setter(attribute, world_suffix) %} 224 {% macro attribute_setter(attribute, world_suffix) %}
234 static void {{attribute.name}}AttributeSetter{{world_suffix}}( 225 static void {{attribute.name}}AttributeSetter{{world_suffix}}(
235 {%- if attribute.is_data_type_property %} 226 {%- if attribute.is_data_type_property %}
236 v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info 227 v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 return false; 407 return false;
417 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); 408 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame);
418 if (!scriptStateInUserScript) 409 if (!scriptStateInUserScript)
419 return false; 410 return false;
420 411
421 ScriptState::Scope scope(scriptState); 412 ScriptState::Scope scope(scriptState);
422 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate()); 413 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate());
423 if (holder.IsEmpty()) 414 if (holder.IsEmpty())
424 return false; 415 return false;
425 416
426 {% if attribute.origin_trial_enabled_function %}
427 {{check_origin_trial(attribute, "scriptState->isolate()") | indent}}
428 {% endif %}
429 417
430 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() ); 418 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() );
431 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(sc riptState, scriptStateInUserScript, "{{cpp_class}}", "{{attribute.name}}", holde r); 419 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(sc riptState, scriptStateInUserScript, "{{cpp_class}}", "{{attribute.name}}", holde r);
432 if (v8Value.IsEmpty()) 420 if (v8Value.IsEmpty())
433 return false; 421 return false;
434 {{v8_value_to_local_cpp_value(attribute.private_script_v8_value_to_local_cpp _value) | indent}} 422 {{v8_value_to_local_cpp_value(attribute.private_script_v8_value_to_local_cpp _value) | indent}}
435 RELEASE_ASSERT(!exceptionState.hadException()); 423 RELEASE_ASSERT(!exceptionState.hadException());
436 *result = cppValue; 424 *result = cppValue;
437 return true; 425 return true;
438 } 426 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 setter_callback_for_main_world, 500 setter_callback_for_main_world,
513 wrapper_type_info, 501 wrapper_type_info,
514 access_control, 502 access_control,
515 property_attribute, 503 property_attribute,
516 only_exposed_to_private_script, 504 only_exposed_to_private_script,
517 property_location(attribute), 505 property_location(attribute),
518 holder_check, 506 holder_check,
519 ] %} 507 ] %}
520 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 508 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
521 {%- endmacro %} 509 {%- endmacro %}
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/v8_utilities.py ('k') | third_party/WebKit/Source/bindings/templates/constants.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698