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

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: 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 # 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,
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
127 'is_cached_accessor': 'CachedAccessor' in extended_attributes,
128 'is_call_with_execution_context': has_extended_attribute_value(attribute , 'CallWith', 'ExecutionContext'), 128 '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'), 129 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca llWith', 'ScriptState'),
130 'is_ce_reactions': is_ce_reactions, 130 'is_ce_reactions': is_ce_reactions,
131 'is_check_security_for_receiver': is_check_security_for_receiver, 131 'is_check_security_for_receiver': is_check_security_for_receiver,
132 'is_check_security_for_return_value': is_check_security_for_return_value , 132 'is_check_security_for_return_value': is_check_security_for_return_value ,
133 'is_custom_element_callbacks': is_custom_element_callbacks, 133 'is_custom_element_callbacks': is_custom_element_callbacks,
134 # TODO(yukishiino): Make all DOM attributes accessor-type properties. 134 # TODO(yukishiino): Make all DOM attributes accessor-type properties.
135 'is_data_type_property': is_data_type_property(interface, attribute), 135 'is_data_type_property': not ('CachedAccessor' in extended_attributes) a nd is_data_type_property(interface, attribute),
136 'is_getter_raises_exception': # [RaisesException] 136 'is_getter_raises_exception': # [RaisesException]
137 'RaisesException' in extended_attributes and 137 'RaisesException' in extended_attributes and
138 extended_attributes['RaisesException'] in (None, 'Getter'), 138 extended_attributes['RaisesException'] in (None, 'Getter'),
139 'is_implemented_in_private_script': is_implemented_in_private_script, 139 'is_implemented_in_private_script': is_implemented_in_private_script,
140 'is_keep_alive_for_gc': keep_alive_for_gc, 140 'is_keep_alive_for_gc': keep_alive_for_gc,
141 'is_lenient_this': 'LenientThis' in extended_attributes, 141 'is_lenient_this': 'LenientThis' in extended_attributes,
142 'is_nullable': idl_type.is_nullable, 142 'is_nullable': idl_type.is_nullable,
143 'is_explicit_nullable': idl_type.is_explicit_nullable, 143 'is_explicit_nullable': idl_type.is_explicit_nullable,
144 'is_partial_interface_member': 144 'is_partial_interface_member':
145 'PartialInterfaceImplementedAs' in extended_attributes, 145 'PartialInterfaceImplementedAs' in extended_attributes,
(...skipping 19 matching lines...) Expand all
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 'cache_property_name': '%s%s' % (interface.name, attribute.name.capitali ze()),
haraken 2016/09/20 14:15:03 cached_accessor_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