| OLD | NEW |
| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 idl_type = attribute.idl_type | 62 idl_type = attribute.idl_type |
| 63 base_idl_type = idl_type.base_type | 63 base_idl_type = idl_type.base_type |
| 64 extended_attributes = attribute.extended_attributes | 64 extended_attributes = attribute.extended_attributes |
| 65 | 65 |
| 66 idl_type.add_includes_for_type(extended_attributes) | 66 idl_type.add_includes_for_type(extended_attributes) |
| 67 if idl_type.enum_values: | 67 if idl_type.enum_values: |
| 68 includes.add('core/inspector/ConsoleMessage.h') | 68 includes.add('core/inspector/ConsoleMessage.h') |
| 69 | 69 |
| 70 # [CheckSecurity] | 70 # [CheckSecurity] |
| 71 is_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes | 71 is_cross_origin = 'CrossOrigin' in extended_attributes |
| 72 is_check_security_for_receiver = ( | 72 is_check_security_for_receiver = ( |
| 73 has_extended_attribute_value(interface, 'CheckSecurity', 'Receiver') and | 73 has_extended_attribute_value(interface, 'CheckSecurity', 'Receiver') and |
| 74 not is_do_not_check_security) | 74 not is_cross_origin) |
| 75 is_check_security_for_return_value = ( | 75 is_check_security_for_return_value = ( |
| 76 has_extended_attribute_value(attribute, 'CheckSecurity', 'ReturnValue')) | 76 has_extended_attribute_value(attribute, 'CheckSecurity', 'ReturnValue')) |
| 77 if is_check_security_for_receiver or is_check_security_for_return_value: | 77 if is_check_security_for_receiver or is_check_security_for_return_value: |
| 78 includes.add('bindings/core/v8/BindingSecurity.h') | 78 includes.add('bindings/core/v8/BindingSecurity.h') |
| 79 # [CrossOrigin] |
| 80 if has_extended_attribute_value(attribute, 'CrossOrigin', 'Setter'): |
| 81 includes.add('bindings/core/v8/V8CrossOriginSetterInfo.h') |
| 79 # [Constructor] | 82 # [Constructor] |
| 80 # TODO(yukishiino): Constructors are much like methods although constructors | 83 # TODO(yukishiino): Constructors are much like methods although constructors |
| 81 # are not methods. Constructors must be data-type properties, and we can | 84 # are not methods. Constructors must be data-type properties, and we can |
| 82 # support them as a kind of methods. | 85 # support them as a kind of methods. |
| 83 constructor_type = idl_type.constructor_type_name if is_constructor_attribut
e(attribute) else None | 86 constructor_type = idl_type.constructor_type_name if is_constructor_attribut
e(attribute) else None |
| 84 # [CEReactions] | 87 # [CEReactions] |
| 85 is_ce_reactions = 'CEReactions' in extended_attributes | 88 is_ce_reactions = 'CEReactions' in extended_attributes |
| 86 if is_ce_reactions: | 89 if is_ce_reactions: |
| 87 includes.add('core/dom/custom/CEReactionsScope.h') | 90 includes.add('core/dom/custom/CEReactionsScope.h') |
| 88 # [CustomElementCallbacks], [Reflect] | 91 # [CustomElementCallbacks], [Reflect] |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), | 129 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), |
| 127 'cached_attribute_validation_method': cached_attribute_validation_method
, | 130 'cached_attribute_validation_method': cached_attribute_validation_method
, |
| 128 'constructor_type': constructor_type, | 131 'constructor_type': constructor_type, |
| 129 'cpp_name': cpp_name(attribute), | 132 'cpp_name': cpp_name(attribute), |
| 130 'cpp_type': idl_type.cpp_type, | 133 'cpp_type': idl_type.cpp_type, |
| 131 'cpp_type_initializer': idl_type.cpp_type_initializer, | 134 'cpp_type_initializer': idl_type.cpp_type_initializer, |
| 132 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] | 135 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] |
| 133 'enum_type': idl_type.enum_type, | 136 'enum_type': idl_type.enum_type, |
| 134 'enum_values': idl_type.enum_values, | 137 'enum_values': idl_type.enum_values, |
| 135 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] | 138 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] |
| 139 'has_cross_origin_getter': |
| 140 has_extended_attribute_value(attribute, 'CrossOrigin', None) or |
| 141 has_extended_attribute_value(attribute, 'CrossOrigin', 'Getter'), |
| 142 'has_cross_origin_setter': has_extended_attribute_value(attribute, 'Cros
sOrigin', 'Setter'), |
| 136 'has_custom_getter': has_custom_getter(attribute), | 143 'has_custom_getter': has_custom_getter(attribute), |
| 137 'has_custom_setter': has_custom_setter(attribute), | 144 'has_custom_setter': has_custom_setter(attribute), |
| 138 'has_setter': has_setter(interface, attribute), | 145 'has_setter': has_setter(interface, attribute), |
| 139 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType | 146 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType |
| 140 'is_call_with_execution_context': has_extended_attribute_value(attribute
, 'CallWith', 'ExecutionContext'), | 147 'is_call_with_execution_context': has_extended_attribute_value(attribute
, 'CallWith', 'ExecutionContext'), |
| 141 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca
llWith', 'ScriptState'), | 148 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca
llWith', 'ScriptState'), |
| 142 'is_ce_reactions': is_ce_reactions, | 149 'is_ce_reactions': is_ce_reactions, |
| 143 'is_check_security_for_receiver': is_check_security_for_receiver, | 150 'is_check_security_for_receiver': is_check_security_for_receiver, |
| 144 'is_check_security_for_return_value': is_check_security_for_return_value
, | 151 'is_check_security_for_return_value': is_check_security_for_return_value
, |
| 145 'is_custom_element_callbacks': is_custom_element_callbacks, | 152 'is_custom_element_callbacks': is_custom_element_callbacks, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 else ['']), # [PerWorldBindings] | 197 else ['']), # [PerWorldBindings] |
| 191 } | 198 } |
| 192 | 199 |
| 193 if is_constructor_attribute(attribute): | 200 if is_constructor_attribute(attribute): |
| 194 update_constructor_attribute_context(interface, attribute, context) | 201 update_constructor_attribute_context(interface, attribute, context) |
| 195 if not has_custom_getter(attribute): | 202 if not has_custom_getter(attribute): |
| 196 getter_context(interface, attribute, context) | 203 getter_context(interface, attribute, context) |
| 197 if not has_custom_setter(attribute) and has_setter(interface, attribute): | 204 if not has_custom_setter(attribute) and has_setter(interface, attribute): |
| 198 setter_context(interface, attribute, interfaces, context) | 205 setter_context(interface, attribute, interfaces, context) |
| 199 | 206 |
| 207 # [CrossOrigin] is incompatible with a number of other attributes, so check |
| 208 # for them here. |
| 209 if is_cross_origin: |
| 210 if context['has_cross_origin_getter'] and context['has_custom_getter']: |
| 211 raise Exception('[CrossOrigin] and [Custom] are incompatible on the
same getter: %s.%s', interface.name, attribute.name) |
| 212 if context['has_cross_origin_setter'] and context['has_custom_setter']: |
| 213 raise Exception('[CrossOrigin] and [Custom] are incompatible on the
same setter: %s.%s', interface.name, attribute.name) |
| 214 if context['is_per_world_bindings']: |
| 215 raise Exception('[CrossOrigin] and [PerWorldBindings] are incompatib
le: %s.%s', interface.name, attribute.name) |
| 216 if context['constructor_type']: |
| 217 raise Exception('[CrossOrigin] cannot be used for constructors: %s.%
s', interface.name, attribute.name) |
| 218 if not context['should_be_exposed_to_script']: |
| 219 raise Exception('[CrossOrigin] attributes must be exposed to script:
%s.%s', interface.name, attribute.name) |
| 220 |
| 200 return context | 221 return context |
| 201 | 222 |
| 202 | 223 |
| 203 def filter_has_accessor_configuration(attributes): | 224 def filter_has_accessor_configuration(attributes): |
| 204 return [attribute for attribute in attributes if | 225 return [attribute for attribute in attributes if |
| 205 not (attribute['exposed_test'] or | 226 not (attribute['exposed_test'] or |
| 206 attribute['secure_context_test'] or | 227 attribute['secure_context_test'] or |
| 207 attribute['origin_trial_enabled_function'] or | 228 attribute['origin_trial_enabled_function'] or |
| 208 attribute['runtime_enabled_function']) and | 229 attribute['runtime_enabled_function']) and |
| 209 not attribute['is_data_type_property'] and | 230 not attribute['is_data_type_property'] and |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 # [PutForwards], [Replaceable] | 559 # [PutForwards], [Replaceable] |
| 539 def has_setter(interface, attribute): | 560 def has_setter(interface, attribute): |
| 540 if (is_data_type_property(interface, attribute) and | 561 if (is_data_type_property(interface, attribute) and |
| 541 (is_constructor_attribute(attribute) or | 562 (is_constructor_attribute(attribute) or |
| 542 'Replaceable' in attribute.extended_attributes)): | 563 'Replaceable' in attribute.extended_attributes)): |
| 543 return False | 564 return False |
| 544 | 565 |
| 545 return is_writable(attribute) | 566 return is_writable(attribute) |
| 546 | 567 |
| 547 | 568 |
| 548 # [DoNotCheckSecurity], [Unforgeable] | 569 # [Unforgeable] |
| 549 def access_control_list(interface, attribute): | 570 def access_control_list(interface, attribute): |
| 550 extended_attributes = attribute.extended_attributes | 571 extended_attributes = attribute.extended_attributes |
| 551 access_control = [] | 572 access_control = [] |
| 552 if 'DoNotCheckSecurity' in extended_attributes: | |
| 553 do_not_check_security = extended_attributes['DoNotCheckSecurity'] | |
| 554 if do_not_check_security == 'Setter': | |
| 555 access_control.append('v8::ALL_CAN_WRITE') | |
| 556 else: | |
| 557 access_control.append('v8::ALL_CAN_READ') | |
| 558 if has_setter(interface, attribute): | |
| 559 access_control.append('v8::ALL_CAN_WRITE') | |
| 560 if is_unforgeable(interface, attribute): | 573 if is_unforgeable(interface, attribute): |
| 561 access_control.append('v8::PROHIBITS_OVERWRITING') | 574 access_control.append('v8::PROHIBITS_OVERWRITING') |
| 562 return access_control or ['v8::DEFAULT'] | 575 return access_control or ['v8::DEFAULT'] |
| 563 | 576 |
| 564 | 577 |
| 565 # [NotEnumerable], [Unforgeable] | 578 # [NotEnumerable], [Unforgeable] |
| 566 def property_attributes(interface, attribute): | 579 def property_attributes(interface, attribute): |
| 567 extended_attributes = attribute.extended_attributes | 580 extended_attributes = attribute.extended_attributes |
| 568 property_attributes_list = [] | 581 property_attributes_list = [] |
| 569 if ('NotEnumerable' in extended_attributes or | 582 if ('NotEnumerable' in extended_attributes or |
| (...skipping 30 matching lines...) Expand all Loading... |
| 600 lambda self: strip_suffix(self.base_type, 'Constructor')) | 613 lambda self: strip_suffix(self.base_type, 'Constructor')) |
| 601 | 614 |
| 602 | 615 |
| 603 def is_constructor_attribute(attribute): | 616 def is_constructor_attribute(attribute): |
| 604 # FIXME: replace this with [ConstructorAttribute] extended attribute | 617 # FIXME: replace this with [ConstructorAttribute] extended attribute |
| 605 return attribute.idl_type.name.endswith('Constructor') | 618 return attribute.idl_type.name.endswith('Constructor') |
| 606 | 619 |
| 607 | 620 |
| 608 def update_constructor_attribute_context(interface, attribute, context): | 621 def update_constructor_attribute_context(interface, attribute, context): |
| 609 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] | 622 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
| OLD | NEW |