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 is_do_not_check_security) | 74 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), | 134 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), |
132 'cached_attribute_validation_method': cached_attribute_validation_method
, | 135 'cached_attribute_validation_method': cached_attribute_validation_method
, |
133 'constructor_type': constructor_type, | 136 'constructor_type': constructor_type, |
134 'cpp_name': cpp_name(attribute), | 137 'cpp_name': cpp_name(attribute), |
135 'cpp_type': idl_type.cpp_type, | 138 'cpp_type': idl_type.cpp_type, |
136 'cpp_type_initializer': idl_type.cpp_type_initializer, | 139 'cpp_type_initializer': idl_type.cpp_type_initializer, |
137 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] | 140 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] |
138 'enum_type': idl_type.enum_type, | 141 'enum_type': idl_type.enum_type, |
139 'enum_values': idl_type.enum_values, | 142 'enum_values': idl_type.enum_values, |
140 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] | 143 'exposed_test': v8_utilities.exposed(attribute, interface), # [Exposed] |
| 144 'has_cross_origin_getter': |
| 145 has_extended_attribute_value(attribute, 'CrossOrigin', None) or |
| 146 has_extended_attribute_value(attribute, 'CrossOrigin', 'Getter'), |
| 147 'has_cross_origin_setter': has_extended_attribute_value(attribute, 'Cros
sOrigin', 'Setter'), |
141 'has_custom_getter': has_custom_getter(attribute), | 148 'has_custom_getter': has_custom_getter(attribute), |
142 'has_custom_setter': has_custom_setter(attribute), | 149 'has_custom_setter': has_custom_setter(attribute), |
143 'has_setter': has_setter(interface, attribute), | 150 'has_setter': has_setter(interface, attribute), |
144 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType | 151 'idl_type': str(idl_type), # need trailing [] on array for Dictionary::
ConversionContext::setConversionType |
145 'is_cached_accessor': is_cached_accessor, | 152 'is_cached_accessor': is_cached_accessor, |
146 'is_call_with_execution_context': has_extended_attribute_value(attribute
, 'CallWith', 'ExecutionContext'), | 153 'is_call_with_execution_context': has_extended_attribute_value(attribute
, 'CallWith', 'ExecutionContext'), |
147 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca
llWith', 'ScriptState'), | 154 'is_call_with_script_state': has_extended_attribute_value(attribute, 'Ca
llWith', 'ScriptState'), |
148 'is_ce_reactions': is_ce_reactions, | 155 'is_ce_reactions': is_ce_reactions, |
149 'is_check_security_for_receiver': is_check_security_for_receiver, | 156 'is_check_security_for_receiver': is_check_security_for_receiver, |
150 'is_check_security_for_return_value': is_check_security_for_return_value
, | 157 'is_check_security_for_return_value': is_check_security_for_return_value
, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 else ['']), # [PerWorldBindings] | 204 else ['']), # [PerWorldBindings] |
198 } | 205 } |
199 | 206 |
200 if is_constructor_attribute(attribute): | 207 if is_constructor_attribute(attribute): |
201 update_constructor_attribute_context(interface, attribute, context) | 208 update_constructor_attribute_context(interface, attribute, context) |
202 if not has_custom_getter(attribute): | 209 if not has_custom_getter(attribute): |
203 getter_context(interface, attribute, context) | 210 getter_context(interface, attribute, context) |
204 if not has_custom_setter(attribute) and has_setter(interface, attribute): | 211 if not has_custom_setter(attribute) and has_setter(interface, attribute): |
205 setter_context(interface, attribute, interfaces, context) | 212 setter_context(interface, attribute, interfaces, context) |
206 | 213 |
| 214 # [CrossOrigin] is incompatible with a number of other attributes, so check |
| 215 # for them here. |
| 216 if is_cross_origin: |
| 217 if context['has_cross_origin_getter'] and context['has_custom_getter']: |
| 218 raise Exception('[CrossOrigin] and [Custom] are incompatible on the
same getter: %s.%s', interface.name, attribute.name) |
| 219 if context['has_cross_origin_setter'] and context['has_custom_setter']: |
| 220 raise Exception('[CrossOrigin] and [Custom] are incompatible on the
same setter: %s.%s', interface.name, attribute.name) |
| 221 if context['is_per_world_bindings']: |
| 222 raise Exception('[CrossOrigin] and [PerWorldBindings] are incompatib
le: %s.%s', interface.name, attribute.name) |
| 223 if context['constructor_type']: |
| 224 raise Exception('[CrossOrigin] cannot be used for constructors: %s.%
s', interface.name, attribute.name) |
| 225 if not context['should_be_exposed_to_script']: |
| 226 raise Exception('[CrossOrigin] attributes must be exposed to script:
%s.%s', interface.name, attribute.name) |
| 227 |
207 return context | 228 return context |
208 | 229 |
209 | 230 |
210 def filter_has_accessor_configuration(attributes): | 231 def filter_has_accessor_configuration(attributes): |
211 return [attribute for attribute in attributes if | 232 return [attribute for attribute in attributes if |
212 not (attribute['exposed_test'] or | 233 not (attribute['exposed_test'] or |
213 attribute['secure_context_test'] or | 234 attribute['secure_context_test'] or |
214 attribute['origin_trial_enabled_function'] or | 235 attribute['origin_trial_enabled_function'] or |
215 attribute['runtime_enabled_function']) and | 236 attribute['runtime_enabled_function']) and |
216 not attribute['is_data_type_property'] and | 237 not attribute['is_data_type_property'] and |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 def is_writable(attribute): | 554 def is_writable(attribute): |
534 return (not attribute.is_read_only or | 555 return (not attribute.is_read_only or |
535 'PutForwards' in attribute.extended_attributes or | 556 'PutForwards' in attribute.extended_attributes or |
536 'Replaceable' in attribute.extended_attributes) | 557 'Replaceable' in attribute.extended_attributes) |
537 | 558 |
538 | 559 |
539 def is_data_type_property(interface, attribute): | 560 def is_data_type_property(interface, attribute): |
540 if 'CachedAccessor' in attribute.extended_attributes: | 561 if 'CachedAccessor' in attribute.extended_attributes: |
541 return False | 562 return False |
542 return (is_constructor_attribute(attribute) or | 563 return (is_constructor_attribute(attribute) or |
543 'DoNotCheckSecurity' in attribute.extended_attributes) | 564 'CrossOrigin' in attribute.extended_attributes) |
544 | 565 |
545 | 566 |
546 # [PutForwards], [Replaceable] | 567 # [PutForwards], [Replaceable] |
547 def has_setter(interface, attribute): | 568 def has_setter(interface, attribute): |
548 if (is_data_type_property(interface, attribute) and | 569 if (is_data_type_property(interface, attribute) and |
549 (is_constructor_attribute(attribute) or | 570 (is_constructor_attribute(attribute) or |
550 'Replaceable' in attribute.extended_attributes)): | 571 'Replaceable' in attribute.extended_attributes)): |
551 return False | 572 return False |
552 | 573 |
553 return is_writable(attribute) | 574 return is_writable(attribute) |
554 | 575 |
555 | 576 |
556 # [DoNotCheckSecurity], [Unforgeable] | 577 # [Unforgeable] |
557 def access_control_list(interface, attribute): | 578 def access_control_list(interface, attribute): |
558 extended_attributes = attribute.extended_attributes | 579 extended_attributes = attribute.extended_attributes |
559 access_control = [] | 580 access_control = [] |
560 if 'DoNotCheckSecurity' in extended_attributes: | |
561 do_not_check_security = extended_attributes['DoNotCheckSecurity'] | |
562 if do_not_check_security == 'Setter': | |
563 access_control.append('v8::ALL_CAN_WRITE') | |
564 else: | |
565 access_control.append('v8::ALL_CAN_READ') | |
566 if has_setter(interface, attribute): | |
567 access_control.append('v8::ALL_CAN_WRITE') | |
568 if is_unforgeable(interface, attribute): | 581 if is_unforgeable(interface, attribute): |
569 access_control.append('v8::PROHIBITS_OVERWRITING') | 582 access_control.append('v8::PROHIBITS_OVERWRITING') |
570 return access_control or ['v8::DEFAULT'] | 583 return access_control or ['v8::DEFAULT'] |
571 | 584 |
572 | 585 |
573 # [NotEnumerable], [Unforgeable] | 586 # [NotEnumerable], [Unforgeable] |
574 def property_attributes(interface, attribute): | 587 def property_attributes(interface, attribute): |
575 extended_attributes = attribute.extended_attributes | 588 extended_attributes = attribute.extended_attributes |
576 property_attributes_list = [] | 589 property_attributes_list = [] |
577 if ('NotEnumerable' in extended_attributes or | 590 if ('NotEnumerable' in extended_attributes or |
(...skipping 30 matching lines...) Expand all Loading... |
608 lambda self: strip_suffix(self.base_type, 'Constructor')) | 621 lambda self: strip_suffix(self.base_type, 'Constructor')) |
609 | 622 |
610 | 623 |
611 def is_constructor_attribute(attribute): | 624 def is_constructor_attribute(attribute): |
612 # FIXME: replace this with [ConstructorAttribute] extended attribute | 625 # FIXME: replace this with [ConstructorAttribute] extended attribute |
613 return attribute.idl_type.name.endswith('Constructor') | 626 return attribute.idl_type.name.endswith('Constructor') |
614 | 627 |
615 | 628 |
616 def update_constructor_attribute_context(interface, attribute, context): | 629 def update_constructor_attribute_context(interface, attribute, context): |
617 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] | 630 context['needs_constructor_getter_callback'] = context['measure_as'] or cont
ext['deprecate_as'] |
OLD | NEW |