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

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

Issue 618373003: [bindings] partial interfaces should not violate componentization (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
1 {##############################################################################} 1 {##############################################################################}
2 {% macro attribute_getter(attribute, world_suffix) %} 2 {% macro attribute_getter(attribute, world_suffix) %}
3 {% filter conditional(attribute.conditional_string) %} 3 {% filter conditional(attribute.conditional_string) %}
4 static void {{attribute.name}}AttributeGetter{{world_suffix}}( 4 static void {{attribute.name}}AttributeGetter{{world_suffix}}(
5 {%- if attribute.is_expose_js_accessors %} 5 {%- if attribute.is_expose_js_accessors %}
6 const v8::FunctionCallbackInfo<v8::Value>& info 6 const v8::FunctionCallbackInfo<v8::Value>& info
7 {%- else %} 7 {%- else %}
8 const v8::PropertyCallbackInfo<v8::Value>& info 8 const v8::PropertyCallbackInfo<v8::Value>& info
9 {%- endif %}) 9 {%- endif %})
10 { 10 {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 {% if attribute.activity_logging_world_check %} 158 {% if attribute.activity_logging_world_check %}
159 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac tivityLogger()) 159 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac tivityLogger())
160 {% else %} 160 {% else %}
161 if (contextData && contextData->activityLogger()) 161 if (contextData && contextData->activityLogger())
162 {% endif %} 162 {% endif %}
163 contextData->activityLogger()->logGetter("{{interface_name}}.{{attribute .name}}"); 163 contextData->activityLogger()->logGetter("{{interface_name}}.{{attribute .name}}");
164 {% endif %} 164 {% endif %}
165 {% if attribute.has_custom_getter %} 165 {% if attribute.has_custom_getter %}
166 {{v8_class}}::{{attribute.name}}AttributeGetterCustom(info); 166 {{v8_class}}::{{attribute.name}}AttributeGetterCustom(info);
167 {% else %} 167 {% else %}
168 {{cpp_class}}V8Internal::{{attribute.name}}AttributeGetter{{world_suffix}}(i nfo); 168 {{actual_cpp_class}}V8Internal::{{attribute.name}}AttributeGetter{{world_suf fix}}(info);
169 {% endif %} 169 {% endif %}
170 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 170 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
171 } 171 }
172 {% endfilter %} 172 {% endfilter %}
173 {% endmacro %} 173 {% endmacro %}
174 174
175 175
176 {##############################################################################} 176 {##############################################################################}
177 {% macro constructor_getter_callback(attribute, world_suffix) %} 177 {% macro constructor_getter_callback(attribute, world_suffix) %}
178 {% filter conditional(attribute.conditional_string) %} 178 {% filter conditional(attribute.conditional_string) %}
179 static void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Loca l<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) 179 static void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Loca l<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info)
180 { 180 {
181 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 181 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
182 {% if attribute.deprecate_as %} 182 {% if attribute.deprecate_as %}
183 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), Use Counter::{{attribute.deprecate_as}}); 183 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), Use Counter::{{attribute.deprecate_as}});
184 {% endif %} 184 {% endif %}
185 {% if attribute.measure_as %} 185 {% if attribute.measure_as %}
186 UseCounter::count(callingExecutionContext(info.GetIsolate()), UseCounter::{{ attribute.measure_as}}); 186 UseCounter::count(callingExecutionContext(info.GetIsolate()), UseCounter::{{ attribute.measure_as}});
187 {% endif %} 187 {% endif %}
188 {{cpp_class}}V8Internal::{{cpp_class}}ConstructorGetter{{world_suffix}}(prop erty, info); 188 {{actual_cpp_class}}V8Internal::{{cpp_class}}ConstructorGetter{{world_suffix }}(property, info);
189 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 189 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
190 } 190 }
191 {% endfilter %} 191 {% endfilter %}
192 {% endmacro %} 192 {% endmacro %}
193 193
194 194
195 {##############################################################################} 195 {##############################################################################}
196 {% macro attribute_setter(attribute, world_suffix) %} 196 {% macro attribute_setter(attribute, world_suffix) %}
197 {% filter conditional(attribute.conditional_string) %} 197 {% filter conditional(attribute.conditional_string) %}
198 static void {{attribute.name}}AttributeSetter{{world_suffix}}( 198 static void {{attribute.name}}AttributeSetter{{world_suffix}}(
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 {% endif %} 315 {% endif %}
316 contextData->activityLogger()->logSetter("{{interface_name}}.{{attribute .name}}", v8Value); 316 contextData->activityLogger()->logSetter("{{interface_name}}.{{attribute .name}}", v8Value);
317 } 317 }
318 {% endif %} 318 {% endif %}
319 {% if attribute.is_custom_element_callbacks or attribute.is_reflect %} 319 {% if attribute.is_custom_element_callbacks or attribute.is_reflect %}
320 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; 320 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope;
321 {% endif %} 321 {% endif %}
322 {% if attribute.has_custom_setter %} 322 {% if attribute.has_custom_setter %}
323 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(v8Value, info); 323 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(v8Value, info);
324 {% else %} 324 {% else %}
325 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(v 8Value, info); 325 {{actual_cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suf fix}}(v8Value, info);
326 {% endif %} 326 {% endif %}
327 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 327 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
328 } 328 }
329 {% endfilter %} 329 {% endfilter %}
330 {% endmacro %} 330 {% endmacro %}
331 331
332 332
333 {##############################################################################} 333 {##############################################################################}
334 {% macro attribute_getter_implemented_in_private_script(attribute) %} 334 {% macro attribute_getter_implemented_in_private_script(attribute) %}
335 bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeGetter(LocalFrame* frame, {{cpp_class}}* holderImpl, {{attribute.cpp_type}}* result) 335 bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeGetter(LocalFrame* frame, {{cpp_class}}* holderImpl, {{attribute.cpp_type}}* result)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() ); 382 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() );
383 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "{{cpp_class}}", "{{attribute.name}}", holder, {{attribute.private_s cript_cpp_value_to_v8_value}}); 383 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "{{cpp_class}}", "{{attribute.name}}", holder, {{attribute.private_s cript_cpp_value_to_v8_value}});
384 } 384 }
385 {% endmacro %} 385 {% endmacro %}
386 386
387 387
388 {##############################################################################} 388 {##############################################################################}
389 {% macro attribute_configuration(attribute) %} 389 {% macro attribute_configuration(attribute) %}
390 {% set getter_callback = 390 {% set getter_callback =
391 '%sV8Internal::%sAttributeGetterCallback' % 391 '%sV8Internal::%sAttributeGetterCallback' %
392 (cpp_class, attribute.name) 392 (actual_cpp_class, attribute.name)
393 if not attribute.constructor_type else 393 if not attribute.constructor_type else
394 ('%sV8Internal::%sConstructorGetterCallback' % 394 ('%sV8Internal::%sConstructorGetterCallback' %
395 (cpp_class, attribute.name) 395 (actual_cpp_class, attribute.name)
396 if attribute.needs_constructor_getter_callback else 396 if attribute.needs_constructor_getter_callback else
397 '{0}V8Internal::{0}ConstructorGetter'.format(cpp_class)) %} 397 '%sV8Internal::%sConstructorGetter' % (actual_cpp_class, cpp_class)) %}
398 {% set getter_callback_for_main_world = 398 {% set getter_callback_for_main_world =
399 '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % 399 '%sV8Internal::%sAttributeGetterCallbackForMainWorld' %
400 (cpp_class, attribute.name) 400 (actual_cpp_class, attribute.name)
401 if attribute.is_per_world_bindings else '0' %} 401 if attribute.is_per_world_bindings else '0' %}
402 {% set setter_callback = attribute.setter_callback %} 402 {% set setter_callback = attribute.setter_callback %}
403 {% set setter_callback_for_main_world = 403 {% set setter_callback_for_main_world =
404 '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % 404 '%sV8Internal::%sAttributeSetterCallbackForMainWorld' %
405 (cpp_class, attribute.name) 405 (actual_cpp_class, attribute.name)
406 if attribute.is_per_world_bindings and 406 if attribute.is_per_world_bindings and
407 (not attribute.is_read_only or attribute.put_forwards) else '0' %} 407 (not attribute.is_read_only or attribute.put_forwards) else '0' %}
408 {% set wrapper_type_info = 408 {% set wrapper_type_info =
409 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % 409 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' %
410 attribute.constructor_type 410 attribute.constructor_type
411 if attribute.constructor_type else '0' %} 411 if attribute.constructor_type else '0' %}
412 {% set access_control = 'static_cast<v8::AccessControl>(%s)' % 412 {% set access_control = 'static_cast<v8::AccessControl>(%s)' %
413 ' | '.join(attribute.access_control_list) %} 413 ' | '.join(attribute.access_control_list) %}
414 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % 414 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' %
415 ' | '.join(attribute.property_attributes) %} 415 ' | '.join(attribute.property_attributes) %}
(...skipping 11 matching lines...) Expand all
427 access_control, 427 access_control,
428 property_attribute, 428 property_attribute,
429 only_exposed_to_private_script, 429 only_exposed_to_private_script,
430 ] %} 430 ] %}
431 {% if not attribute.is_expose_js_accessors %} 431 {% if not attribute.is_expose_js_accessors %}
432 {% set attribute_configuration_list = attribute_configuration_list 432 {% set attribute_configuration_list = attribute_configuration_list
433 + [on_prototype] %} 433 + [on_prototype] %}
434 {% endif %} 434 {% endif %}
435 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 435 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
436 {%- endmacro %} 436 {%- endmacro %}
437
438 {##############################################################################}
439 {% macro install_conditionally_enabled_properties() %}
440 void {{actual_v8_class}}::installConditionallyEnabledProperties(v8::Handle<v8::O bject> instanceObject, v8::Isolate* isolate)
haraken 2014/10/16 04:24:08 BTW, do we need to support installConditionallyEna
tasak 2014/10/17 07:38:18 Done.
441 {
442 {% if is_partial %}
443 {# install per-context enabled properties defined in original interface. #}
444 {{v8_class}}::installConditionallyEnabledProperties(instanceObject, isolate) ;
445 {% endif %}
446 {% if has_conditional_attributes %}
447 v8::Local<v8::Object> prototypeObject = v8::Local<v8::Object>::Cast(instance Object->GetPrototype());
448 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont ext());
449
450 {% for attribute in attributes if attribute.per_context_enabled_function or attribute.exposed_test %}
451 {% filter per_context_enabled(attribute.per_context_enabled_function) %}
452 {% filter exposed(attribute.exposed_test) %}
453 static const V8DOMConfiguration::AttributeConfiguration attributeConfigurati on =\
454 {{attribute_configuration(attribute)}};
455 V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, attrib uteConfiguration, isolate);
456 {% endfilter %}
457 {% endfilter %}
458 {% endfor %}
459 {% endif %}
460 }
461 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698