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

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/v8_attributes.py

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 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (base_idl_type == 'EventHandler' and 97 if (base_idl_type == 'EventHandler' and
98 interface.name in ['Window', 'WorkerGlobalScope'] and 98 interface.name in ['Window', 'WorkerGlobalScope'] and
99 attribute.name == 'onerror'): 99 attribute.name == 'onerror'):
100 includes.add('bindings/core/v8/V8ErrorHandler.h') 100 includes.add('bindings/core/v8/V8ErrorHandler.h')
101 101
102 cached_attribute_validation_method = extended_attributes.get('CachedAttribut e') 102 cached_attribute_validation_method = extended_attributes.get('CachedAttribut e')
103 keep_alive_for_gc = is_keep_alive_for_gc(interface, attribute) 103 keep_alive_for_gc = is_keep_alive_for_gc(interface, attribute)
104 if cached_attribute_validation_method or keep_alive_for_gc: 104 if cached_attribute_validation_method or keep_alive_for_gc:
105 includes.add('bindings/core/v8/V8HiddenValue.h') 105 includes.add('bindings/core/v8/V8HiddenValue.h')
106 106
107 # [CachedAccessor]
108 is_cached_accessor = 'CachedAccessor' in extended_attributes
109 if is_cached_accessor:
110 includes.add('bindings/core/v8/V8PrivateProperty.h')
111
107 context = { 112 context = {
108 'access_control_list': access_control_list(interface, attribute), 113 'access_control_list': access_control_list(interface, attribute),
109 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_ world_list(attribute, 'Getter'), # [ActivityLogging] 114 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_ world_list(attribute, 'Getter'), # [ActivityLogging]
110 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_ world_list(attribute, 'Setter'), # [ActivityLogging] 115 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_ world_list(attribute, 'Setter'), # [ActivityLogging]
111 'activity_logging_world_check': v8_utilities.activity_logging_world_chec k(attribute), # [ActivityLogging] 116 'activity_logging_world_check': v8_utilities.activity_logging_world_chec k(attribute), # [ActivityLogging]
112 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), 117 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
113 'cached_attribute_validation_method': cached_attribute_validation_method , 118 'cached_attribute_validation_method': cached_attribute_validation_method ,
114 'constructor_type': constructor_type, 119 'constructor_type': constructor_type,
115 'cpp_name': cpp_name(attribute), 120 'cpp_name': cpp_name(attribute),
116 'cpp_type': idl_type.cpp_type, 121 'cpp_type': idl_type.cpp_type,
117 'cpp_type_initializer': idl_type.cpp_type_initializer, 122 'cpp_type_initializer': idl_type.cpp_type_initializer,
118 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] 123 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs]
119 'enum_type': idl_type.enum_type, 124 'enum_type': idl_type.enum_type,
120 'enum_values': idl_type.enum_values, 125 'enum_values': idl_type.enum_values,
121 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] 126 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed]
122 'has_custom_getter': has_custom_getter(attribute), 127 'has_custom_getter': has_custom_getter(attribute),
123 'has_custom_setter': has_custom_setter(attribute), 128 'has_custom_setter': has_custom_setter(attribute),
124 'has_setter': has_setter(interface, attribute), 129 'has_setter': has_setter(interface, attribute),
125 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType 130 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType
131 'is_cached_accessor': is_cached_accessor,
126 'is_call_with_execution_context': has_extended_attribute_value(attribute , 'CallWith', 'ExecutionContext'), 132 'is_call_with_execution_context': has_extended_attribute_value(attribute , 'CallWith', 'ExecutionContext'),
127 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca llWith', 'ScriptState'), 133 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca llWith', 'ScriptState'),
128 'is_ce_reactions': is_ce_reactions, 134 'is_ce_reactions': is_ce_reactions,
129 'is_check_security_for_receiver': is_check_security_for_receiver, 135 'is_check_security_for_receiver': is_check_security_for_receiver,
130 'is_check_security_for_return_value': is_check_security_for_return_value , 136 'is_check_security_for_return_value': is_check_security_for_return_value ,
131 'is_custom_element_callbacks': is_custom_element_callbacks, 137 'is_custom_element_callbacks': is_custom_element_callbacks,
132 # TODO(yukishiino): Make all DOM attributes accessor-type properties. 138 # TODO(yukishiino): Make all DOM attributes accessor-type properties.
133 'is_data_type_property': is_data_type_property(interface, attribute), 139 'is_data_type_property': not ('CachedAccessor' in extended_attributes) a nd is_data_type_property(interface, attribute),
134 'is_getter_raises_exception': # [RaisesException] 140 'is_getter_raises_exception': # [RaisesException]
135 'RaisesException' in extended_attributes and 141 'RaisesException' in extended_attributes and
136 extended_attributes['RaisesException'] in (None, 'Getter'), 142 extended_attributes['RaisesException'] in (None, 'Getter'),
137 'is_implemented_in_private_script': is_implemented_in_private_script, 143 'is_implemented_in_private_script': is_implemented_in_private_script,
138 'is_keep_alive_for_gc': keep_alive_for_gc, 144 'is_keep_alive_for_gc': keep_alive_for_gc,
139 'is_lenient_this': 'LenientThis' in extended_attributes, 145 'is_lenient_this': 'LenientThis' in extended_attributes,
140 'is_nullable': idl_type.is_nullable, 146 'is_nullable': idl_type.is_nullable,
141 'is_explicit_nullable': idl_type.is_explicit_nullable, 147 'is_explicit_nullable': idl_type.is_explicit_nullable,
142 'is_partial_interface_member': 148 'is_partial_interface_member':
143 'PartialInterfaceImplementedAs' in extended_attributes, 149 'PartialInterfaceImplementedAs' in extended_attributes,
(...skipping 19 matching lines...) Expand all
163 extended_attributes, 'v8Value', 'cppValue', bailout_return_value='fa lse', isolate='scriptState->isolate()'), 169 extended_attributes, 'v8Value', 'cppValue', bailout_return_value='fa lse', isolate='scriptState->isolate()'),
164 'property_attributes': property_attributes(interface, attribute), 170 'property_attributes': property_attributes(interface, attribute),
165 'reflect_empty': extended_attributes.get('ReflectEmpty'), 171 'reflect_empty': extended_attributes.get('ReflectEmpty'),
166 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), 172 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''),
167 'reflect_missing': extended_attributes.get('ReflectMissing'), 173 'reflect_missing': extended_attributes.get('ReflectMissing'),
168 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly '), 174 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly '),
169 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a ttribute), # [RuntimeEnabled] 175 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a ttribute), # [RuntimeEnabled]
170 'runtime_feature_name': v8_utilities.runtime_feature_name(attribute), # [RuntimeEnabled] 176 'runtime_feature_name': v8_utilities.runtime_feature_name(attribute), # [RuntimeEnabled]
171 'secure_context_test': v8_utilities.secure_context(attribute, interface) , # [SecureContext] 177 'secure_context_test': v8_utilities.secure_context(attribute, interface) , # [SecureContext]
172 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script), 178 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script),
179 'cached_accessor_name': '%s%sCachedAccessor' % (interface.name, attribut e.name.capitalize()),
173 'world_suffixes': ( 180 'world_suffixes': (
174 ['', 'ForMainWorld'] 181 ['', 'ForMainWorld']
175 if 'PerWorldBindings' in extended_attributes 182 if 'PerWorldBindings' in extended_attributes
176 else ['']), # [PerWorldBindings] 183 else ['']), # [PerWorldBindings]
177 } 184 }
178 185
179 if is_constructor_attribute(attribute): 186 if is_constructor_attribute(attribute):
180 update_constructor_attribute_context(interface, attribute, context) 187 update_constructor_attribute_context(interface, attribute, context)
181 if not has_custom_getter(attribute): 188 if not has_custom_getter(attribute):
182 getter_context(interface, attribute, context) 189 getter_context(interface, attribute, context)
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 lambda self: strip_suffix(self.base_type, 'Constructor')) 575 lambda self: strip_suffix(self.base_type, 'Constructor'))
569 576
570 577
571 def is_constructor_attribute(attribute): 578 def is_constructor_attribute(attribute):
572 # FIXME: replace this with [ConstructorAttribute] extended attribute 579 # FIXME: replace this with [ConstructorAttribute] extended attribute
573 return attribute.idl_type.name.endswith('Constructor') 580 return attribute.idl_type.name.endswith('Constructor')
574 581
575 582
576 def update_constructor_attribute_context(interface, attribute, context): 583 def update_constructor_attribute_context(interface, attribute, context):
577 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] 584 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as']
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698