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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/templates/attributes.cpp
diff --git a/third_party/WebKit/Source/bindings/templates/attributes.cpp b/third_party/WebKit/Source/bindings/templates/attributes.cpp
index e45ecf8f418c59954ccd5f154cb6a74ec9f4a3b4..5235deae167222cc28199a2bdbf4a1bc374d0dce 100644
--- a/third_party/WebKit/Source/bindings/templates/attributes.cpp
+++ b/third_party/WebKit/Source/bindings/templates/attributes.cpp
@@ -216,6 +216,15 @@ static v8::experimental::FastAccessorBuilder* {{attribute.name}}AttributeGetterB
{##############################################################################}
+{% macro attribute_cache_property_callback(attribute) %}
haraken 2016/09/20 14:15:03 cached_accessor_callback
+static v8::Local<v8::Private> {{attribute.name}}CachePropertyCallback(v8::Isolate* isolate)
haraken 2016/09/20 14:15:03 CachedAccessorCallback
+{
+ return V8PrivateProperty::get{{attribute.cache_property_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)
{
@@ -499,6 +508,10 @@ bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame*
'V8DOMConfiguration::OnlyExposedToPrivateScript'
if attribute.only_exposed_to_private_script else
'V8DOMConfiguration::ExposedToAllScripts' %}
+{% set cache_property_callback =
haraken 2016/09/20 14:15:03 cached_accessor_callback
+ '%sV8Internal::%sCachePropertyCallback' % (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 = [
@@ -508,6 +521,7 @@ bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame*
getter_callback_for_main_world,
setter_callback_for_main_world,
getter_builder_callback,
+ cache_property_callback,
wrapper_type_info,
access_control,
property_attribute,

Powered by Google App Engine
This is Rietveld 408576698