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

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: Pre-review nits 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 # 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), 112 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
113 'cached_attribute_validation_method': cached_attribute_validation_method , 113 'cached_attribute_validation_method': cached_attribute_validation_method ,
114 'constructor_type': constructor_type, 114 'constructor_type': constructor_type,
115 'cpp_name': cpp_name(attribute), 115 'cpp_name': cpp_name(attribute),
116 'cpp_type': idl_type.cpp_type, 116 'cpp_type': idl_type.cpp_type,
117 'cpp_type_initializer': idl_type.cpp_type_initializer, 117 'cpp_type_initializer': idl_type.cpp_type_initializer,
118 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] 118 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs]
119 'enum_type': idl_type.enum_type, 119 'enum_type': idl_type.enum_type,
120 'enum_values': idl_type.enum_values, 120 'enum_values': idl_type.enum_values,
121 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] 121 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed]
122 'has_fast_accessor': 'FastAccessor' in extended_attributes,
jochen (gone - plz use gerrit) 2016/09/15 08:20:51 unrelated?
Alfonso 2016/09/16 14:21:48 The attribute is duplicated, will move it to the F
123 'has_custom_getter': has_custom_getter(attribute), 122 'has_custom_getter': has_custom_getter(attribute),
124 'has_custom_setter': has_custom_setter(attribute), 123 'has_custom_setter': has_custom_setter(attribute),
125 'has_fast_accessor': 'FastAccessor' in extended_attributes, 124 'has_fast_accessor': 'FastAccessor' in extended_attributes,
126 'has_setter': has_setter(interface, attribute), 125 'has_setter': has_setter(interface, attribute),
127 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType 126 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType
128 'is_call_with_execution_context': has_extended_attribute_value(attribute , 'CallWith', 'ExecutionContext'), 127 'is_call_with_execution_context': has_extended_attribute_value(attribute , 'CallWith', 'ExecutionContext'),
129 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca llWith', 'ScriptState'), 128 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca llWith', 'ScriptState'),
130 'is_ce_reactions': is_ce_reactions, 129 'is_ce_reactions': is_ce_reactions,
131 'is_check_security_for_receiver': is_check_security_for_receiver, 130 'is_check_security_for_receiver': is_check_security_for_receiver,
132 'is_check_security_for_return_value': is_check_security_for_return_value , 131 'is_check_security_for_return_value': is_check_security_for_return_value ,
133 'is_custom_element_callbacks': is_custom_element_callbacks, 132 'is_custom_element_callbacks': is_custom_element_callbacks,
134 # TODO(yukishiino): Make all DOM attributes accessor-type properties. 133 # TODO(yukishiino): Make all DOM attributes accessor-type properties.
135 'is_data_type_property': is_data_type_property(interface, attribute), 134 'is_data_type_property': not ('StoreInField' in extended_attributes) and is_data_type_property(interface, attribute),
136 'is_getter_raises_exception': # [RaisesException] 135 'is_getter_raises_exception': # [RaisesException]
137 'RaisesException' in extended_attributes and 136 'RaisesException' in extended_attributes and
138 extended_attributes['RaisesException'] in (None, 'Getter'), 137 extended_attributes['RaisesException'] in (None, 'Getter'),
139 'is_implemented_in_private_script': is_implemented_in_private_script, 138 'is_implemented_in_private_script': is_implemented_in_private_script,
140 'is_keep_alive_for_gc': keep_alive_for_gc, 139 'is_keep_alive_for_gc': keep_alive_for_gc,
141 'is_lenient_this': 'LenientThis' in extended_attributes, 140 'is_lenient_this': 'LenientThis' in extended_attributes,
142 'is_nullable': idl_type.is_nullable, 141 'is_nullable': idl_type.is_nullable,
143 'is_explicit_nullable': idl_type.is_explicit_nullable, 142 'is_explicit_nullable': idl_type.is_explicit_nullable,
144 'is_partial_interface_member': 143 'is_partial_interface_member':
145 'PartialInterfaceImplementedAs' in extended_attributes, 144 'PartialInterfaceImplementedAs' in extended_attributes,
146 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, 145 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes,
147 'is_put_forwards': 'PutForwards' in extended_attributes, 146 'is_put_forwards': 'PutForwards' in extended_attributes,
148 'is_read_only': attribute.is_read_only, 147 'is_read_only': attribute.is_read_only,
149 'is_reflect': is_reflect, 148 'is_reflect': is_reflect,
150 'is_replaceable': 'Replaceable' in attribute.extended_attributes, 149 'is_replaceable': 'Replaceable' in attribute.extended_attributes,
151 'is_save_same_object': is_save_same_object, 150 'is_save_same_object': is_save_same_object,
152 'is_static': attribute.is_static, 151 'is_static': attribute.is_static,
152 'is_store_in_field': 'StoreInField' in extended_attributes,
153 'is_url': 'URL' in extended_attributes, 153 'is_url': 'URL' in extended_attributes,
154 'is_unforgeable': is_unforgeable(interface, attribute), 154 'is_unforgeable': is_unforgeable(interface, attribute),
155 'on_instance': v8_utilities.on_instance(interface, attribute), 155 'on_instance': v8_utilities.on_instance(interface, attribute),
156 'on_interface': v8_utilities.on_interface(interface, attribute), 156 'on_interface': v8_utilities.on_interface(interface, attribute),
157 'on_prototype': v8_utilities.on_prototype(interface, attribute), 157 'on_prototype': v8_utilities.on_prototype(interface, attribute),
158 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct ion_name(attribute), # [OriginTrialEnabled] 158 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct ion_name(attribute), # [OriginTrialEnabled]
159 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(attr ibute), # [OriginTrialEnabled] 159 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(attr ibute), # [OriginTrialEnabled]
160 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res ult, 160 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res ult,
161 'measure_as': v8_utilities.measure_as(attribute, interface), # [Measure As] 161 'measure_as': v8_utilities.measure_as(attribute, interface), # [Measure As]
162 'name': attribute.name, 162 'name': attribute.name,
163 'only_exposed_to_private_script': is_only_exposed_to_private_script, 163 'only_exposed_to_private_script': is_only_exposed_to_private_script,
164 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value( 164 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value(
165 extended_attributes, 'v8Value', 'cppValue', bailout_return_value='fa lse', isolate='scriptState->isolate()'), 165 extended_attributes, 'v8Value', 'cppValue', bailout_return_value='fa lse', isolate='scriptState->isolate()'),
166 'property_attributes': property_attributes(interface, attribute), 166 'property_attributes': property_attributes(interface, attribute),
167 'reflect_empty': extended_attributes.get('ReflectEmpty'), 167 'reflect_empty': extended_attributes.get('ReflectEmpty'),
168 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), 168 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''),
169 'reflect_missing': extended_attributes.get('ReflectMissing'), 169 'reflect_missing': extended_attributes.get('ReflectMissing'),
170 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly '), 170 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly '),
171 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a ttribute), # [RuntimeEnabled] 171 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a ttribute), # [RuntimeEnabled]
172 'runtime_feature_name': v8_utilities.runtime_feature_name(attribute), # [RuntimeEnabled] 172 'runtime_feature_name': v8_utilities.runtime_feature_name(attribute), # [RuntimeEnabled]
173 'secure_context_test': v8_utilities.secure_context(attribute, interface) , # [SecureContext] 173 'secure_context_test': v8_utilities.secure_context(attribute, interface) , # [SecureContext]
174 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script), 174 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script),
175 'surrogate_name': '%s#%s' % (interface.name, attribute.name),
175 'world_suffixes': ( 176 'world_suffixes': (
176 ['', 'ForMainWorld'] 177 ['', 'ForMainWorld']
177 if 'PerWorldBindings' in extended_attributes 178 if 'PerWorldBindings' in extended_attributes
178 else ['']), # [PerWorldBindings] 179 else ['']), # [PerWorldBindings]
179 } 180 }
180 181
181 if is_constructor_attribute(attribute): 182 if is_constructor_attribute(attribute):
182 update_constructor_attribute_context(interface, attribute, context) 183 update_constructor_attribute_context(interface, attribute, context)
183 if not has_custom_getter(attribute): 184 if not has_custom_getter(attribute):
184 getter_context(interface, attribute, context) 185 getter_context(interface, attribute, context)
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 lambda self: strip_suffix(self.base_type, 'Constructor')) 571 lambda self: strip_suffix(self.base_type, 'Constructor'))
571 572
572 573
573 def is_constructor_attribute(attribute): 574 def is_constructor_attribute(attribute):
574 # FIXME: replace this with [ConstructorAttribute] extended attribute 575 # FIXME: replace this with [ConstructorAttribute] extended attribute
575 return attribute.idl_type.name.endswith('Constructor') 576 return attribute.idl_type.name.endswith('Constructor')
576 577
577 578
578 def update_constructor_attribute_context(interface, attribute, context): 579 def update_constructor_attribute_context(interface, attribute, context):
579 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] 580 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as']
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698