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

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

Issue 2335203006: Add [CachedAccessor] attribute to cache (almost) constant accessors (window.document). (Closed)
Patch Set: Fix rebase dirt Created 4 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
OLDNEW
1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %} 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 {% if attribute.has_custom_getter %} 200 {% if attribute.has_custom_getter %}
201 {{v8_class}}::{{attribute.name}}AttributeGetterCustom(info); 201 {{v8_class}}::{{attribute.name}}AttributeGetterCustom(info);
202 {% else %} 202 {% else %}
203 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeGetter{{world _suffix}}(info); 203 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeGetter{{world _suffix}}(info);
204 {% endif %} 204 {% endif %}
205 } 205 }
206 {% endmacro %} 206 {% endmacro %}
207 207
208 208
209 {##############################################################################} 209 {##############################################################################}
210 {% macro attribute_cache_property_callback(attribute) %}
211 static v8::Local<v8::Private> {{attribute.name}}CachedAccessorCallback(v8::Isola te* isolate)
212 {
213 return V8PrivateProperty::get{{attribute.cached_accessor_name}}(isolate).get Private();
214 }
215 {% endmacro %}
216
217
218 {##############################################################################}
210 {% macro constructor_getter_callback(attribute, world_suffix) %} 219 {% macro constructor_getter_callback(attribute, world_suffix) %}
211 void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Local<v8::N ame> property, const v8::PropertyCallbackInfo<v8::Value>& info) 220 void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Local<v8::N ame> property, const v8::PropertyCallbackInfo<v8::Value>& info)
212 { 221 {
213 {% if attribute.deprecate_as %} 222 {% if attribute.deprecate_as %}
214 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}); 223 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}});
215 {% endif %} 224 {% endif %}
216 {% if attribute.measure_as %} 225 {% if attribute.measure_as %}
217 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('ConstructorGetter')}} ); 226 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('ConstructorGetter')}} );
218 {% endif %} 227 {% endif %}
219 v8ConstructorAttributeGetter(property, info); 228 v8ConstructorAttributeGetter(property, info);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 ' | '.join(attribute.access_control_list) %} 482 ' | '.join(attribute.access_control_list) %}
474 {% else %} 483 {% else %}
475 {% set access_control = 'v8::DEFAULT' %} 484 {% set access_control = 'v8::DEFAULT' %}
476 {% endif %} 485 {% endif %}
477 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % 486 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' %
478 ' | '.join(attribute.property_attributes) %} 487 ' | '.join(attribute.property_attributes) %}
479 {% set only_exposed_to_private_script = 488 {% set only_exposed_to_private_script =
480 'V8DOMConfiguration::OnlyExposedToPrivateScript' 489 'V8DOMConfiguration::OnlyExposedToPrivateScript'
481 if attribute.only_exposed_to_private_script else 490 if attribute.only_exposed_to_private_script else
482 'V8DOMConfiguration::ExposedToAllScripts' %} 491 'V8DOMConfiguration::ExposedToAllScripts' %}
492 {% set cached_accessor_callback =
493 '%sV8Internal::%sCachedAccessorCallback' % (cpp_class_or_partial, attribu te.name)
494 if attribute.is_cached_accessor else
495 'nullptr' %}
483 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' 496 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder'
484 if attribute.is_lenient_this else 'V8DOMConfiguration::CheckHolder' %} 497 if attribute.is_lenient_this else 'V8DOMConfiguration::CheckHolder' %}
485 {% set attribute_configuration_list = [ 498 {% set attribute_configuration_list = [
486 '"%s"' % attribute.name, 499 '"%s"' % attribute.name,
487 getter_callback, 500 getter_callback,
488 setter_callback, 501 setter_callback,
489 getter_callback_for_main_world, 502 getter_callback_for_main_world,
490 setter_callback_for_main_world, 503 setter_callback_for_main_world,
504 cached_accessor_callback,
491 wrapper_type_info, 505 wrapper_type_info,
492 access_control, 506 access_control,
493 property_attribute, 507 property_attribute,
494 only_exposed_to_private_script, 508 only_exposed_to_private_script,
495 property_location(attribute), 509 property_location(attribute),
496 holder_check, 510 holder_check,
497 ] %} 511 ] %}
498 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 512 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
499 {%- endmacro %} 513 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698