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

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

Issue 1667653002: V8-binding: Use v8::Template::SetNativeDataProperty without setter for [Replaceable]. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved the [LenientThis] test to http/tests/. Created 4 years, 9 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 'constructor_type': constructor_type, 111 'constructor_type': constructor_type,
112 'cpp_name': cpp_name(attribute), 112 'cpp_name': cpp_name(attribute),
113 'cpp_type': idl_type.cpp_type, 113 'cpp_type': idl_type.cpp_type,
114 'cpp_type_initializer': idl_type.cpp_type_initializer, 114 'cpp_type_initializer': idl_type.cpp_type_initializer,
115 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] 115 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs]
116 'enum_type': idl_type.enum_type, 116 'enum_type': idl_type.enum_type,
117 'enum_values': idl_type.enum_values, 117 'enum_values': idl_type.enum_values,
118 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] 118 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed]
119 'has_custom_getter': has_custom_getter(attribute), 119 'has_custom_getter': has_custom_getter(attribute),
120 'has_custom_setter': has_custom_setter(attribute), 120 'has_custom_setter': has_custom_setter(attribute),
121 'has_setter': has_setter(attribute), 121 'has_setter': has_setter(interface, attribute),
122 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType 122 'idl_type': str(idl_type), # need trailing [] on array for Dictionary:: ConversionContext::setConversionType
123 'is_origin_trial_enabled': v8_utilities.origin_trial_enabled_function(at tribute) or v8_utilities.origin_trial_enabled_function(interface), # [OriginTri alEnabled] 123 'is_origin_trial_enabled': v8_utilities.origin_trial_enabled_function(at tribute) or v8_utilities.origin_trial_enabled_function(interface), # [OriginTri alEnabled]
124 'is_call_with_execution_context': has_extended_attribute_value(attribute , 'CallWith', 'ExecutionContext'), 124 'is_call_with_execution_context': has_extended_attribute_value(attribute , 'CallWith', 'ExecutionContext'),
125 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca llWith', 'ScriptState'), 125 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca llWith', 'ScriptState'),
126 'is_check_security_for_receiver': is_check_security_for_receiver, 126 'is_check_security_for_receiver': is_check_security_for_receiver,
127 'is_check_security_for_return_value': is_check_security_for_return_value , 127 'is_check_security_for_return_value': is_check_security_for_return_value ,
128 'is_custom_element_callbacks': is_custom_element_callbacks, 128 'is_custom_element_callbacks': is_custom_element_callbacks,
129 # TODO(yukishiino): Make all DOM attributes accessor-type properties. 129 # TODO(yukishiino): Make all DOM attributes accessor-type properties.
130 'is_data_type_property': constructor_type or interface.name == 'Window' or interface.name == 'Location', 130 'is_data_type_property': is_data_type_property(interface, attribute),
131 'is_getter_raises_exception': # [RaisesException] 131 'is_getter_raises_exception': # [RaisesException]
132 'RaisesException' in extended_attributes and 132 'RaisesException' in extended_attributes and
133 extended_attributes['RaisesException'] in (None, 'Getter'), 133 extended_attributes['RaisesException'] in (None, 'Getter'),
134 'is_implemented_in_private_script': is_implemented_in_private_script, 134 'is_implemented_in_private_script': is_implemented_in_private_script,
135 'is_keep_alive_for_gc': keep_alive_for_gc, 135 'is_keep_alive_for_gc': keep_alive_for_gc,
136 'is_lenient_this': 'LenientThis' in extended_attributes, 136 'is_lenient_this': 'LenientThis' in extended_attributes,
137 'is_nullable': idl_type.is_nullable, 137 'is_nullable': idl_type.is_nullable,
138 'is_explicit_nullable': idl_type.is_explicit_nullable, 138 'is_explicit_nullable': idl_type.is_explicit_nullable,
139 'is_partial_interface_member': 139 'is_partial_interface_member':
140 'PartialInterfaceImplementedAs' in extended_attributes, 140 'PartialInterfaceImplementedAs' in extended_attributes,
(...skipping 26 matching lines...) Expand all
167 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script), 167 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script),
168 'world_suffixes': ['', 'ForMainWorld'] 168 'world_suffixes': ['', 'ForMainWorld']
169 if 'PerWorldBindings' in extended_attributes 169 if 'PerWorldBindings' in extended_attributes
170 else [''], # [PerWorldBindings] 170 else [''], # [PerWorldBindings]
171 } 171 }
172 172
173 if is_constructor_attribute(attribute): 173 if is_constructor_attribute(attribute):
174 update_constructor_attribute_context(interface, attribute, context) 174 update_constructor_attribute_context(interface, attribute, context)
175 if not has_custom_getter(attribute): 175 if not has_custom_getter(attribute):
176 getter_context(interface, attribute, context) 176 getter_context(interface, attribute, context)
177 if not has_custom_setter(attribute) and has_setter(attribute): 177 if not has_custom_setter(attribute) and has_setter(interface, attribute):
178 setter_context(interface, attribute, context) 178 setter_context(interface, attribute, context)
179 179
180 return context 180 return context
181 181
182 182
183 ################################################################################ 183 ################################################################################
184 # Getter 184 # Getter
185 ################################################################################ 185 ################################################################################
186 186
187 def getter_context(interface, attribute, context): 187 def getter_context(interface, attribute, context):
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 else: 442 else:
443 namespace = 'HTMLNames' 443 namespace = 'HTMLNames'
444 includes.add('core/%s.h' % namespace) 444 includes.add('core/%s.h' % namespace)
445 return '%s::%sAttr' % (namespace, content_attribute_name) 445 return '%s::%sAttr' % (namespace, content_attribute_name)
446 446
447 447
448 ################################################################################ 448 ################################################################################
449 # Attribute configuration 449 # Attribute configuration
450 ################################################################################ 450 ################################################################################
451 451
452 # [PutForwards], [Replaceable] 452 # Property descriptor's {writable: boolean}
453 def has_setter(attribute): 453 def is_writable(attribute):
454 return (not attribute.is_read_only or 454 return (not attribute.is_read_only or
455 'PutForwards' in attribute.extended_attributes or 455 'PutForwards' in attribute.extended_attributes or
456 'Replaceable' in attribute.extended_attributes) 456 'Replaceable' in attribute.extended_attributes)
457 457
458 458
459 def is_data_type_property(interface, attribute):
460 return (is_constructor_attribute(attribute) or
461 interface.name == 'Window' or
462 interface.name == 'Location')
463
464
465 # [PutForwards], [Replaceable]
466 def has_setter(interface, attribute):
467 if (is_data_type_property(interface, attribute) and
468 (is_constructor_attribute(attribute) or
469 'Replaceable' in attribute.extended_attributes)):
470 return False
471
472 return is_writable(attribute)
473
474
459 # [DoNotCheckSecurity], [Unforgeable] 475 # [DoNotCheckSecurity], [Unforgeable]
460 def access_control_list(interface, attribute): 476 def access_control_list(interface, attribute):
461 extended_attributes = attribute.extended_attributes 477 extended_attributes = attribute.extended_attributes
462 access_control = [] 478 access_control = []
463 if 'DoNotCheckSecurity' in extended_attributes: 479 if 'DoNotCheckSecurity' in extended_attributes:
464 do_not_check_security = extended_attributes['DoNotCheckSecurity'] 480 do_not_check_security = extended_attributes['DoNotCheckSecurity']
465 if do_not_check_security == 'Setter': 481 if do_not_check_security == 'Setter':
466 access_control.append('v8::ALL_CAN_WRITE') 482 access_control.append('v8::ALL_CAN_WRITE')
467 else: 483 else:
468 access_control.append('v8::ALL_CAN_READ') 484 access_control.append('v8::ALL_CAN_READ')
469 if has_setter(attribute): 485 if has_setter(interface, attribute):
470 access_control.append('v8::ALL_CAN_WRITE') 486 access_control.append('v8::ALL_CAN_WRITE')
471 if is_unforgeable(interface, attribute): 487 if is_unforgeable(interface, attribute):
472 access_control.append('v8::PROHIBITS_OVERWRITING') 488 access_control.append('v8::PROHIBITS_OVERWRITING')
473 return access_control or ['v8::DEFAULT'] 489 return access_control or ['v8::DEFAULT']
474 490
475 491
476 # [NotEnumerable], [Unforgeable] 492 # [NotEnumerable], [Unforgeable]
477 def property_attributes(interface, attribute): 493 def property_attributes(interface, attribute):
478 extended_attributes = attribute.extended_attributes 494 extended_attributes = attribute.extended_attributes
479 property_attributes_list = [] 495 property_attributes_list = []
480 if ('NotEnumerable' in extended_attributes or 496 if ('NotEnumerable' in extended_attributes or
481 is_constructor_attribute(attribute)): 497 is_constructor_attribute(attribute)):
482 property_attributes_list.append('v8::DontEnum') 498 property_attributes_list.append('v8::DontEnum')
483 if is_unforgeable(interface, attribute): 499 if is_unforgeable(interface, attribute):
484 property_attributes_list.append('v8::DontDelete') 500 property_attributes_list.append('v8::DontDelete')
501 if not is_writable(attribute):
502 property_attributes_list.append('v8::ReadOnly')
485 return property_attributes_list or ['v8::None'] 503 return property_attributes_list or ['v8::None']
486 504
487 505
488 # [Custom], [Custom=Getter] 506 # [Custom], [Custom=Getter]
489 def has_custom_getter(attribute): 507 def has_custom_getter(attribute):
490 extended_attributes = attribute.extended_attributes 508 extended_attributes = attribute.extended_attributes
491 return ('Custom' in extended_attributes and 509 return ('Custom' in extended_attributes and
492 extended_attributes['Custom'] in [None, 'Getter']) 510 extended_attributes['Custom'] in [None, 'Getter'])
493 511
494 512
(...skipping 14 matching lines...) Expand all
509 lambda self: strip_suffix(self.base_type, 'Constructor')) 527 lambda self: strip_suffix(self.base_type, 'Constructor'))
510 528
511 529
512 def is_constructor_attribute(attribute): 530 def is_constructor_attribute(attribute):
513 # FIXME: replace this with [ConstructorAttribute] extended attribute 531 # FIXME: replace this with [ConstructorAttribute] extended attribute
514 return attribute.idl_type.name.endswith('Constructor') 532 return attribute.idl_type.name.endswith('Constructor')
515 533
516 534
517 def update_constructor_attribute_context(interface, attribute, context): 535 def update_constructor_attribute_context(interface, attribute, context):
518 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] or context['origin_trial_name'] 536 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] or context['origin_trial_name']
519 # When the attribute name is the same as the interface name, do not generate
520 # callback functions for each attribute and use
521 # {{cpp_class}}ConstructorAttributeSetterCallback. Otherwise, generate
522 # a callback function in order to hard-code the attribute name.
523 context['needs_constructor_setter_callback'] = context['name'] != context['c onstructor_type']
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698