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

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

Issue 1958883003: Revert of binding: Makes Window/Location's attributes accessor-type properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Synced. Created 4 years, 7 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 extended_attributes = attribute.extended_attributes 50 extended_attributes = attribute.extended_attributes
51 51
52 idl_type.add_includes_for_type(extended_attributes) 52 idl_type.add_includes_for_type(extended_attributes)
53 if idl_type.enum_values: 53 if idl_type.enum_values:
54 includes.add('core/inspector/ConsoleMessage.h') 54 includes.add('core/inspector/ConsoleMessage.h')
55 55
56 # [CheckSecurity] 56 # [CheckSecurity]
57 is_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes 57 is_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes
58 is_check_security_for_receiver = ( 58 is_check_security_for_receiver = (
59 has_extended_attribute_value(interface, 'CheckSecurity', 'Receiver') and 59 has_extended_attribute_value(interface, 'CheckSecurity', 'Receiver') and
60 is_do_not_check_security) 60 not is_do_not_check_security)
61 is_check_security_for_return_value = ( 61 is_check_security_for_return_value = (
62 has_extended_attribute_value(attribute, 'CheckSecurity', 'ReturnValue')) 62 has_extended_attribute_value(attribute, 'CheckSecurity', 'ReturnValue'))
63 if is_check_security_for_receiver or is_check_security_for_return_value: 63 if is_check_security_for_receiver or is_check_security_for_return_value:
64 includes.add('bindings/core/v8/BindingSecurity.h') 64 includes.add('bindings/core/v8/BindingSecurity.h')
65 # [Constructor] 65 # [Constructor]
66 # TODO(yukishiino): Constructors are much like methods although constructors 66 # TODO(yukishiino): Constructors are much like methods although constructors
67 # are not methods. Constructors must be data-type properties, and we can 67 # are not methods. Constructors must be data-type properties, and we can
68 # support them as a kind of methods. 68 # support them as a kind of methods.
69 constructor_type = idl_type.constructor_type_name if is_constructor_attribut e(attribute) else None 69 constructor_type = idl_type.constructor_type_name if is_constructor_attribut e(attribute) else None
70 # [CustomElementCallbacks], [Reflect] 70 # [CustomElementCallbacks], [Reflect]
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 'has_custom_setter': has_custom_setter(attribute), 113 'has_custom_setter': has_custom_setter(attribute),
114 'has_setter': has_setter(interface, attribute), 114 'has_setter': has_setter(interface, attribute),
115 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType 115 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType
116 'is_call_with_execution_context': has_extended_attribute_value(attribute , 'CallWith', 'ExecutionContext'), 116 'is_call_with_execution_context': has_extended_attribute_value(attribute , 'CallWith', 'ExecutionContext'),
117 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca llWith', 'ScriptState'), 117 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca llWith', 'ScriptState'),
118 'is_check_security_for_receiver': is_check_security_for_receiver, 118 'is_check_security_for_receiver': is_check_security_for_receiver,
119 'is_check_security_for_return_value': is_check_security_for_return_value , 119 'is_check_security_for_return_value': is_check_security_for_return_value ,
120 'is_custom_element_callbacks': is_custom_element_callbacks, 120 'is_custom_element_callbacks': is_custom_element_callbacks,
121 # TODO(yukishiino): Make all DOM attributes accessor-type properties. 121 # TODO(yukishiino): Make all DOM attributes accessor-type properties.
122 'is_data_type_property': is_data_type_property(interface, attribute), 122 'is_data_type_property': is_data_type_property(interface, attribute),
123 'is_getter_raises_exception': ( # [RaisesException] 123 'is_getter_raises_exception': # [RaisesException]
124 'RaisesException' in extended_attributes and 124 'RaisesException' in extended_attributes and
125 extended_attributes['RaisesException'] in (None, 'Getter')), 125 extended_attributes['RaisesException'] in (None, 'Getter'),
126 'is_implemented_in_private_script': is_implemented_in_private_script, 126 'is_implemented_in_private_script': is_implemented_in_private_script,
127 'is_keep_alive_for_gc': keep_alive_for_gc, 127 'is_keep_alive_for_gc': keep_alive_for_gc,
128 'is_lenient_this': 'LenientThis' in extended_attributes, 128 'is_lenient_this': 'LenientThis' in extended_attributes,
129 'is_nullable': idl_type.is_nullable, 129 'is_nullable': idl_type.is_nullable,
130 'is_explicit_nullable': idl_type.is_explicit_nullable, 130 'is_explicit_nullable': idl_type.is_explicit_nullable,
131 'is_partial_interface_member': 131 'is_partial_interface_member':
132 'PartialInterfaceImplementedAs' in extended_attributes, 132 'PartialInterfaceImplementedAs' in extended_attributes,
133 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, 133 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes,
134 'is_put_forwards': 'PutForwards' in extended_attributes, 134 'is_put_forwards': 'PutForwards' in extended_attributes,
135 'is_read_only': attribute.is_read_only, 135 'is_read_only': attribute.is_read_only,
(...skipping 12 matching lines...) Expand all
148 'only_exposed_to_private_script': is_only_exposed_to_private_script, 148 'only_exposed_to_private_script': is_only_exposed_to_private_script,
149 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value( 149 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value(
150 extended_attributes, 'v8Value', 'cppValue', bailout_return_value='fa lse', isolate='scriptState->isolate()'), 150 extended_attributes, 'v8Value', 'cppValue', bailout_return_value='fa lse', isolate='scriptState->isolate()'),
151 'property_attributes': property_attributes(interface, attribute), 151 'property_attributes': property_attributes(interface, attribute),
152 'reflect_empty': extended_attributes.get('ReflectEmpty'), 152 'reflect_empty': extended_attributes.get('ReflectEmpty'),
153 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), 153 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''),
154 'reflect_missing': extended_attributes.get('ReflectMissing'), 154 'reflect_missing': extended_attributes.get('ReflectMissing'),
155 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly '), 155 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly '),
156 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a ttribute), # [RuntimeEnabled] 156 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a ttribute), # [RuntimeEnabled]
157 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script), 157 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script),
158 'world_suffixes': (['', 'ForMainWorld'] 158 'world_suffixes': (
159 if 'PerWorldBindings' in extended_attributes 159 ['', 'ForMainWorld']
160 else ['']), # [PerWorldBindings] 160 if 'PerWorldBindings' in extended_attributes
161 else ['']), # [PerWorldBindings]
161 } 162 }
162 163
163 if is_constructor_attribute(attribute): 164 if is_constructor_attribute(attribute):
164 update_constructor_attribute_context(interface, attribute, context) 165 update_constructor_attribute_context(interface, attribute, context)
165 if not has_custom_getter(attribute): 166 if not has_custom_getter(attribute):
166 getter_context(interface, attribute, context) 167 getter_context(interface, attribute, context)
167 if not has_custom_setter(attribute) and has_setter(interface, attribute): 168 if not has_custom_setter(attribute) and has_setter(interface, attribute):
168 setter_context(interface, attribute, context) 169 setter_context(interface, attribute, context)
169 170
170 return context 171 return context
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 context['cpp_value_original'] = cpp_value 204 context['cpp_value_original'] = cpp_value
204 cpp_value = 'cppValue' 205 cpp_value = 'cppValue'
205 206
206 def v8_set_return_value_statement(for_main_world=False): 207 def v8_set_return_value_statement(for_main_world=False):
207 if context['is_keep_alive_for_gc'] or 'CachedAttribute' in extended_attr ibutes: 208 if context['is_keep_alive_for_gc'] or 'CachedAttribute' in extended_attr ibutes:
208 return 'v8SetReturnValue(info, v8Value)' 209 return 'v8SetReturnValue(info, v8Value)'
209 return idl_type.v8_set_return_value( 210 return idl_type.v8_set_return_value(
210 cpp_value, extended_attributes=extended_attributes, script_wrappable ='impl', 211 cpp_value, extended_attributes=extended_attributes, script_wrappable ='impl',
211 for_main_world=for_main_world, is_static=attribute.is_static) 212 for_main_world=for_main_world, is_static=attribute.is_static)
212 213
213 def v8_set_return_value_statement_for_security_failure():
214 # In the case that the access check fails, there is no common rule for
215 # the return value. The return value depends on each attribute.
216 # However, we shouldn't return null or undefiend for attributes of type
217 # boolean or DOMString at least. We're making the best guess here.
218 if idl_type.is_explicit_nullable:
219 return 'v8SetReturnValueNull(info)'
220 if idl_type.is_boolean_type:
221 return 'v8SetReturnValueBool(info, false)'
222 if idl_type.is_numeric_type:
223 return 'v8SetReturnValueInt(info, 0)'
224 if idl_type.is_string_type:
225 return 'v8SetReturnValueEmptyString(info)'
226 return 'v8SetReturnValueNull(info)'
227
228 context.update({ 214 context.update({
229 'cpp_value': cpp_value, 215 'cpp_value': cpp_value,
230 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( 216 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
231 cpp_value=cpp_value, creation_context='holder', 217 cpp_value=cpp_value, creation_context='holder',
232 extended_attributes=extended_attributes), 218 extended_attributes=extended_attributes),
233 'v8_set_return_value_for_main_world': v8_set_return_value_statement(for_ main_world=True), 219 'v8_set_return_value_for_main_world': v8_set_return_value_statement(for_ main_world=True),
234 'v8_set_return_value': v8_set_return_value_statement(), 220 'v8_set_return_value': v8_set_return_value_statement(),
235 'v8_set_return_value_for_security_failure':
236 v8_set_return_value_statement_for_security_failure(),
237 }) 221 })
238 222
239
240 def getter_expression(interface, attribute, context): 223 def getter_expression(interface, attribute, context):
241 arguments = [] 224 arguments = []
242 this_getter_base_name = getter_base_name(interface, attribute, arguments) 225 this_getter_base_name = getter_base_name(interface, attribute, arguments)
243 getter_name = scoped_name(interface, attribute, this_getter_base_name) 226 getter_name = scoped_name(interface, attribute, this_getter_base_name)
244 227
245 if 'ImplementedInPrivateScript' in attribute.extended_attributes: 228 if 'ImplementedInPrivateScript' in attribute.extended_attributes:
246 arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->G etCurrentContext()))') 229 arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->G etCurrentContext()))')
247 arguments.append('impl') 230 arguments.append('impl')
248 arguments.append('&result') 231 arguments.append('&result')
249 arguments.extend(v8_utilities.call_with_arguments( 232 arguments.extend(v8_utilities.call_with_arguments(
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 437
455 # Property descriptor's {writable: boolean} 438 # Property descriptor's {writable: boolean}
456 def is_writable(attribute): 439 def is_writable(attribute):
457 return (not attribute.is_read_only or 440 return (not attribute.is_read_only or
458 'PutForwards' in attribute.extended_attributes or 441 'PutForwards' in attribute.extended_attributes or
459 'Replaceable' in attribute.extended_attributes) 442 'Replaceable' in attribute.extended_attributes)
460 443
461 444
462 def is_data_type_property(interface, attribute): 445 def is_data_type_property(interface, attribute):
463 return (is_constructor_attribute(attribute) or 446 return (is_constructor_attribute(attribute) or
464 'DoNotCheckSecurity' in attribute.extended_attributes) 447 interface.name == 'Window' or
448 interface.name == 'Location')
465 449
466 450
467 # [PutForwards], [Replaceable] 451 # [PutForwards], [Replaceable]
468 def has_setter(interface, attribute): 452 def has_setter(interface, attribute):
469 if (is_data_type_property(interface, attribute) and 453 if (is_data_type_property(interface, attribute) and
470 (is_constructor_attribute(attribute) or 454 (is_constructor_attribute(attribute) or
471 'Replaceable' in attribute.extended_attributes)): 455 'Replaceable' in attribute.extended_attributes)):
472 return False 456 return False
473 457
474 return is_writable(attribute) 458 return is_writable(attribute)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 lambda self: strip_suffix(self.base_type, 'Constructor')) 513 lambda self: strip_suffix(self.base_type, 'Constructor'))
530 514
531 515
532 def is_constructor_attribute(attribute): 516 def is_constructor_attribute(attribute):
533 # FIXME: replace this with [ConstructorAttribute] extended attribute 517 # FIXME: replace this with [ConstructorAttribute] extended attribute
534 return attribute.idl_type.name.endswith('Constructor') 518 return attribute.idl_type.name.endswith('Constructor')
535 519
536 520
537 def update_constructor_attribute_context(interface, attribute, context): 521 def update_constructor_attribute_context(interface, attribute, context):
538 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] or context['origin_trial_enabled_function'] # TODO(chasej): Should/can this be true when OriginTrialEnabled is inherited from containing in terface? 522 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] or context['origin_trial_enabled_function'] # TODO(chasej): Should/can this be true when OriginTrialEnabled is inherited from containing in terface?
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/idl_types.py ('k') | third_party/WebKit/Source/bindings/templates/attributes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698