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

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: Rebase; Respect runtime-enabled flags as well 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 {%- else %} 166 {%- else %}
170 const v8::FunctionCallbackInfo<v8::Value>& info 167 const v8::FunctionCallbackInfo<v8::Value>& info
171 {%- endif %}) 168 {%- endif %})
172 { 169 {
173 {% if attribute.deprecate_as %} 170 {% if attribute.deprecate_as %}
174 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}); 171 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}});
175 {% endif %} 172 {% endif %}
176 {% if attribute.measure_as %} 173 {% if attribute.measure_as %}
177 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('AttributeGetter')}}); 174 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('AttributeGetter')}});
178 {% endif %} 175 {% endif %}
179 {% if attribute.origin_trial_enabled_function %}
180 {{check_origin_trial(attribute) | indent}}
181 {% endif %}
182 {% if world_suffix in attribute.activity_logging_world_list_for_getter %} 176 {% if world_suffix in attribute.activity_logging_world_list_for_getter %}
183 ScriptState* scriptState = ScriptState::from(info.GetIsolate()->GetCurrentCo ntext()); 177 ScriptState* scriptState = ScriptState::from(info.GetIsolate()->GetCurrentCo ntext());
184 V8PerContextData* contextData = scriptState->perContextData(); 178 V8PerContextData* contextData = scriptState->perContextData();
185 {% if attribute.activity_logging_world_check %} 179 {% if attribute.activity_logging_world_check %}
186 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac tivityLogger()) 180 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac tivityLogger())
187 {% else %} 181 {% else %}
188 if (contextData && contextData->activityLogger()) 182 if (contextData && contextData->activityLogger())
189 {% endif %} 183 {% endif %}
190 contextData->activityLogger()->logGetter("{{interface_name}}.{{attribute .name}}"); 184 contextData->activityLogger()->logGetter("{{interface_name}}.{{attribute .name}}");
191 {% endif %} 185 {% endif %}
192 {% if attribute.has_custom_getter %} 186 {% if attribute.has_custom_getter %}
193 {{v8_class}}::{{attribute.name}}AttributeGetterCustom(info); 187 {{v8_class}}::{{attribute.name}}AttributeGetterCustom(info);
194 {% else %} 188 {% else %}
195 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeGetter{{world _suffix}}(info); 189 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeGetter{{world _suffix}}(info);
196 {% endif %} 190 {% endif %}
197 } 191 }
198 {% endmacro %} 192 {% endmacro %}
199 193
200 194
201 {##############################################################################} 195 {##############################################################################}
202 {% macro constructor_getter_callback(attribute, world_suffix) %} 196 {% macro constructor_getter_callback(attribute, world_suffix) %}
203 static void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Loca l<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value>& info) 197 static void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Loca l<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value>& info)
204 { 198 {
205 {% if attribute.deprecate_as %} 199 {% if attribute.deprecate_as %}
206 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}); 200 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}});
207 {% endif %} 201 {% endif %}
208 {% if attribute.measure_as %} 202 {% if attribute.measure_as %}
209 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('ConstructorGetter')}} ); 203 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('ConstructorGetter')}} );
210 {% endif %} 204 {% endif %}
211 {% if attribute.origin_trial_enabled_function %}
212 {{check_origin_trial(attribute) | indent}}
213 {% endif %}
214 v8ConstructorAttributeGetter(property, info); 205 v8ConstructorAttributeGetter(property, info);
215 } 206 }
216 {% endmacro %} 207 {% endmacro %}
217 208
218 209
219 {##############################################################################} 210 {##############################################################################}
220 {% macro attribute_setter(attribute, world_suffix) %} 211 {% macro attribute_setter(attribute, world_suffix) %}
221 static void {{attribute.name}}AttributeSetter{{world_suffix}}( 212 static void {{attribute.name}}AttributeSetter{{world_suffix}}(
222 {%- if attribute.is_data_type_property %} 213 {%- if attribute.is_data_type_property %}
223 v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info 214 v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return false; 394 return false;
404 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); 395 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame);
405 if (!scriptStateInUserScript) 396 if (!scriptStateInUserScript)
406 return false; 397 return false;
407 398
408 ScriptState::Scope scope(scriptState); 399 ScriptState::Scope scope(scriptState);
409 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate()); 400 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate());
410 if (holder.IsEmpty()) 401 if (holder.IsEmpty())
411 return false; 402 return false;
412 403
413 {% if attribute.origin_trial_enabled_function %}
414 {{check_origin_trial(attribute, "scriptState->isolate()") | indent}}
415 {% endif %}
416 404
417 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() ); 405 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() );
418 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(sc riptState, scriptStateInUserScript, "{{cpp_class}}", "{{attribute.name}}", holde r); 406 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(sc riptState, scriptStateInUserScript, "{{cpp_class}}", "{{attribute.name}}", holde r);
419 if (v8Value.IsEmpty()) 407 if (v8Value.IsEmpty())
420 return false; 408 return false;
421 {{v8_value_to_local_cpp_value(attribute.private_script_v8_value_to_local_cpp _value) | indent}} 409 {{v8_value_to_local_cpp_value(attribute.private_script_v8_value_to_local_cpp _value) | indent}}
422 RELEASE_ASSERT(!exceptionState.hadException()); 410 RELEASE_ASSERT(!exceptionState.hadException());
423 *result = cppValue; 411 *result = cppValue;
424 return true; 412 return true;
425 } 413 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 setter_callback_for_main_world, 487 setter_callback_for_main_world,
500 wrapper_type_info, 488 wrapper_type_info,
501 access_control, 489 access_control,
502 property_attribute, 490 property_attribute,
503 only_exposed_to_private_script, 491 only_exposed_to_private_script,
504 property_location(attribute), 492 property_location(attribute),
505 holder_check, 493 holder_check,
506 ] %} 494 ] %}
507 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 495 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
508 {%- endmacro %} 496 {%- 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