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

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

Issue 2335203006: Add [CachedAccessor] attribute to cache (almost) constant accessors (window.document). (Closed)
Patch Set: Polishing + naming revisited Created 4 years, 3 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 {##############################################################################} 209 {##############################################################################}
210 {% macro attribute_getter_builder_callback(attribute) %} 210 {% macro attribute_getter_builder_callback(attribute) %}
211 static v8::experimental::FastAccessorBuilder* {{attribute.name}}AttributeGetterB uilderCallback(v8::Isolate* isolate, v8::FunctionCallback callback) 211 static v8::experimental::FastAccessorBuilder* {{attribute.name}}AttributeGetterB uilderCallback(v8::Isolate* isolate, v8::FunctionCallback callback)
212 { 212 {
213 return {{v8_class}}::{{attribute.name}}AttributeGetterBuilder(isolate, callb ack); 213 return {{v8_class}}::{{attribute.name}}AttributeGetterBuilder(isolate, callb ack);
214 } 214 }
215 {% endmacro %} 215 {% endmacro %}
216 216
217 217
218 {##############################################################################} 218 {##############################################################################}
219 {% macro attribute_cache_property_callback(attribute) %}
haraken 2016/09/20 14:15:03 cached_accessor_callback
220 static v8::Local<v8::Private> {{attribute.name}}CachePropertyCallback(v8::Isolat e* isolate)
haraken 2016/09/20 14:15:03 CachedAccessorCallback
221 {
222 return V8PrivateProperty::get{{attribute.cache_property_name}}(isolate).getP rivate();
223 }
224 {% endmacro %}
225
226
227 {##############################################################################}
219 {% macro constructor_getter_callback(attribute, world_suffix) %} 228 {% macro constructor_getter_callback(attribute, world_suffix) %}
220 void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Local<v8::N ame> property, const v8::PropertyCallbackInfo<v8::Value>& info) 229 void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Local<v8::N ame> property, const v8::PropertyCallbackInfo<v8::Value>& info)
221 { 230 {
222 {% if attribute.deprecate_as %} 231 {% if attribute.deprecate_as %}
223 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}); 232 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentEx ecutionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}});
224 {% endif %} 233 {% endif %}
225 {% if attribute.measure_as %} 234 {% if attribute.measure_as %}
226 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('ConstructorGetter')}} ); 235 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionConte xt(info.GetIsolate()), UseCounter::{{attribute.measure_as('ConstructorGetter')}} );
227 {% endif %} 236 {% endif %}
228 v8ConstructorAttributeGetter(property, info); 237 v8ConstructorAttributeGetter(property, info);
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 ' | '.join(attribute.access_control_list) %} 501 ' | '.join(attribute.access_control_list) %}
493 {% else %} 502 {% else %}
494 {% set access_control = 'v8::DEFAULT' %} 503 {% set access_control = 'v8::DEFAULT' %}
495 {% endif %} 504 {% endif %}
496 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % 505 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' %
497 ' | '.join(attribute.property_attributes) %} 506 ' | '.join(attribute.property_attributes) %}
498 {% set only_exposed_to_private_script = 507 {% set only_exposed_to_private_script =
499 'V8DOMConfiguration::OnlyExposedToPrivateScript' 508 'V8DOMConfiguration::OnlyExposedToPrivateScript'
500 if attribute.only_exposed_to_private_script else 509 if attribute.only_exposed_to_private_script else
501 'V8DOMConfiguration::ExposedToAllScripts' %} 510 'V8DOMConfiguration::ExposedToAllScripts' %}
511 {% set cache_property_callback =
haraken 2016/09/20 14:15:03 cached_accessor_callback
512 '%sV8Internal::%sCachePropertyCallback' % (cpp_class_or_partial, attribut e.name)
513 if attribute.is_cached_accessor else
514 'nullptr' %}
502 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' 515 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder'
503 if attribute.is_lenient_this else 'V8DOMConfiguration::CheckHolder' %} 516 if attribute.is_lenient_this else 'V8DOMConfiguration::CheckHolder' %}
504 {% set attribute_configuration_list = [ 517 {% set attribute_configuration_list = [
505 '"%s"' % attribute.name, 518 '"%s"' % attribute.name,
506 getter_callback, 519 getter_callback,
507 setter_callback, 520 setter_callback,
508 getter_callback_for_main_world, 521 getter_callback_for_main_world,
509 setter_callback_for_main_world, 522 setter_callback_for_main_world,
510 getter_builder_callback, 523 getter_builder_callback,
524 cache_property_callback,
511 wrapper_type_info, 525 wrapper_type_info,
512 access_control, 526 access_control,
513 property_attribute, 527 property_attribute,
514 only_exposed_to_private_script, 528 only_exposed_to_private_script,
515 property_location(attribute), 529 property_location(attribute),
516 holder_check, 530 holder_check,
517 ] %} 531 ] %}
518 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 532 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
519 {%- endmacro %} 533 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698