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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl
diff --git a/third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl
index f6f6c99b6bad1b5ae7050a71f787447723a7c362..33a2076480e1e2777eb8939239d39b49752cec83 100644
--- a/third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl
+++ b/third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl
@@ -207,6 +207,15 @@ const v8::FunctionCallbackInfo<v8::Value>& info
{##############################################################################}
+{% macro attribute_cache_property_callback(attribute) %}
+static v8::Local<v8::Private> {{attribute.name}}CachedAccessorCallback(v8::Isolate* isolate)
+{
+ return V8PrivateProperty::get{{attribute.cached_accessor_name}}(isolate).getPrivate();
+}
+{% endmacro %}
+
+
+{##############################################################################}
{% macro constructor_getter_callback(attribute, world_suffix) %}
void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value>& info)
{
@@ -480,6 +489,10 @@ bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame*
'V8DOMConfiguration::OnlyExposedToPrivateScript'
if attribute.only_exposed_to_private_script else
'V8DOMConfiguration::ExposedToAllScripts' %}
+{% set cached_accessor_callback =
+ '%sV8Internal::%sCachedAccessorCallback' % (cpp_class_or_partial, attribute.name)
+ if attribute.is_cached_accessor else
+ 'nullptr' %}
{% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder'
if attribute.is_lenient_this else 'V8DOMConfiguration::CheckHolder' %}
{% set attribute_configuration_list = [
@@ -487,7 +500,8 @@ bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame*
getter_callback,
setter_callback,
getter_callback_for_main_world,
- setter_callback_for_main_world,
+ setter_callback_for_main_world,
+ cached_accessor_callback,
wrapper_type_info,
access_control,
property_attribute,

Powered by Google App Engine
This is Rietveld 408576698