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

Side by Side Diff: Source/bindings/scripts/v8_methods.py

Issue 331323012: Revert of Throw TypeError when addEventListener or removeEventListener are called (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/scripts/v8_types.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 if is_static: 81 if is_static:
82 return 'functionTemplate' 82 return 'functionTemplate'
83 if 'Unforgeable' in extended_attributes: 83 if 'Unforgeable' in extended_attributes:
84 return 'instanceTemplate' 84 return 'instanceTemplate'
85 return 'prototypeTemplate' 85 return 'prototypeTemplate'
86 86
87 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi th', 'ScriptArguments') 87 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi th', 'ScriptArguments')
88 if is_call_with_script_arguments: 88 if is_call_with_script_arguments:
89 includes.update(['bindings/v8/ScriptCallStackFactory.h', 89 includes.update(['bindings/v8/ScriptCallStackFactory.h',
90 'core/inspector/ScriptArguments.h']) 90 'core/inspector/ScriptArguments.h'])
91 is_call_with_script_state = has_extended_attribute_value( 91 is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState')
92 method, 'CallWith', 'ScriptState')
93 if is_call_with_script_state: 92 if is_call_with_script_state:
94 includes.add('bindings/v8/ScriptState.h') 93 includes.add('bindings/v8/ScriptState.h')
95 is_check_security_for_node = has_extended_attribute_value( 94 is_check_security_for_node = 'CheckSecurity' in extended_attributes
96 method, 'CheckSecurity', 'Node')
97 if is_check_security_for_node: 95 if is_check_security_for_node:
98 includes.add('bindings/v8/BindingSecurity.h') 96 includes.add('bindings/v8/BindingSecurity.h')
99 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s 97 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s
100 if is_custom_element_callbacks: 98 if is_custom_element_callbacks:
101 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') 99 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h')
102 100
103 has_event_listener_argument = any( 101 has_event_listener_argument = any(
104 argument for argument in arguments 102 argument for argument in arguments
105 if argument.idl_type.name == 'EventListenerOrNull') 103 if argument.idl_type.name == 'EventListener')
106 is_check_security_for_frame = ( 104 is_check_security_for_frame = (
107 has_extended_attribute_value(interface, 'CheckSecurity', 'Frame') and 105 'CheckSecurity' in interface.extended_attributes and
108 'DoNotCheckSecurity' not in extended_attributes) 106 'DoNotCheckSecurity' not in extended_attributes)
109 is_raises_exception = 'RaisesException' in extended_attributes 107 is_raises_exception = 'RaisesException' in extended_attributes
110 108
111 arguments_need_try_catch = any(argument_needs_try_catch(argument) 109 arguments_need_try_catch = any(argument_needs_try_catch(argument)
112 for argument in arguments) 110 for argument in arguments)
113 111
114 return { 112 return {
115 'activity_logging_world_list': v8_utilities.activity_logging_world_list( method), # [ActivityLogging] 113 'activity_logging_world_list': v8_utilities.activity_logging_world_list( method), # [ActivityLogging]
116 'arguments': [argument_context(interface, method, argument, index) 114 'arguments': [argument_context(interface, method, argument, index)
117 for index, argument in enumerate(arguments)], 115 for index, argument in enumerate(arguments)],
118 'arguments_need_try_catch': arguments_need_try_catch, 116 'arguments_need_try_catch': arguments_need_try_catch,
119 'conditional_string': v8_utilities.conditional_string(method), 117 'conditional_string': v8_utilities.conditional_string(method),
120 'cpp_type': idl_type.cpp_type, 118 'cpp_type': idl_type.cpp_type,
121 'cpp_value': this_cpp_value, 119 'cpp_value': this_cpp_value,
122 'custom_registration_extended_attributes': 120 'custom_registration_extended_attributes':
123 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection( 121 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
124 extended_attributes.iterkeys()), 122 extended_attributes.iterkeys()),
125 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] 123 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs]
126 'function_template': function_template(), 124 'function_template': function_template(),
127 'has_custom_registration': is_static or 125 'has_custom_registration': is_static or
128 v8_utilities.has_extended_attribute( 126 v8_utilities.has_extended_attribute(
129 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES), 127 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
130 'has_event_listener_argument': has_event_listener_argument, 128 'has_event_listener_argument': has_event_listener_argument,
131 'has_exception_state': 129 'has_exception_state':
132 interface.name == 'EventTarget' or # FIXME: merge with is_check_sec urity_for_frame http://crbug.com/383699 130 has_event_listener_argument or
133 is_raises_exception or 131 is_raises_exception or
134 is_check_security_for_frame or 132 is_check_security_for_frame or
135 any(argument for argument in arguments 133 any(argument for argument in arguments
136 if argument.idl_type.name == 'SerializedScriptValue' or 134 if argument.idl_type.name == 'SerializedScriptValue' or
137 argument.idl_type.may_raise_exception_on_conversion), 135 argument.idl_type.may_raise_exception_on_conversion),
138 'idl_type': idl_type.base_type, 136 'idl_type': idl_type.base_type,
139 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'), 137 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'),
140 'is_call_with_script_arguments': is_call_with_script_arguments, 138 'is_call_with_script_arguments': is_call_with_script_arguments,
141 'is_call_with_script_state': is_call_with_script_state, 139 'is_call_with_script_state': is_call_with_script_state,
142 'is_check_security_for_frame': is_check_security_for_frame, 140 'is_check_security_for_frame': is_check_security_for_frame,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 used_as_argument=True, 181 used_as_argument=True,
184 used_as_variadic_argument=argument.is _variadic), 182 used_as_variadic_argument=argument.is _variadic),
185 'cpp_value': this_cpp_value, 183 'cpp_value': this_cpp_value,
186 # FIXME: check that the default value's type is compatible with the argu ment's 184 # FIXME: check that the default value's type is compatible with the argu ment's
187 'default_value': str(argument.default_value) if argument.default_value e lse None, 185 'default_value': str(argument.default_value) if argument.default_value e lse None,
188 'enum_validation_expression': idl_type.enum_validation_expression, 186 'enum_validation_expression': idl_type.enum_validation_expression,
189 # FIXME: remove once [Default] removed and just use argument.default_val ue 187 # FIXME: remove once [Default] removed and just use argument.default_val ue
190 'has_default': 'Default' in extended_attributes or argument.default_valu e, 188 'has_default': 'Default' in extended_attributes or argument.default_valu e,
191 'has_event_listener_argument': any( 189 'has_event_listener_argument': any(
192 argument_so_far for argument_so_far in method.arguments[:index] 190 argument_so_far for argument_so_far in method.arguments[:index]
193 if argument_so_far.idl_type.name == 'EventListenerOrNull'), 191 if argument_so_far.idl_type.name == 'EventListener'),
194 'has_type_checking_interface': 192 'has_type_checking_interface':
195 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or 193 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or
196 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and 194 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and
197 idl_type.is_wrapper_type, 195 idl_type.is_wrapper_type,
198 'has_type_checking_unrestricted': 196 'has_type_checking_unrestricted':
199 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or 197 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or
200 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and 198 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and
201 idl_type.name in ('Float', 'Double'), 199 idl_type.name in ('Float', 'Double'),
202 # Dictionary is special-cased, but arrays and sequences shouldn't be 200 # Dictionary is special-cased, but arrays and sequences shouldn't be
203 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type, 201 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type,
(...skipping 13 matching lines...) Expand all
217 } 215 }
218 216
219 217
220 ################################################################################ 218 ################################################################################
221 # Value handling 219 # Value handling
222 ################################################################################ 220 ################################################################################
223 221
224 def cpp_value(interface, method, number_of_arguments): 222 def cpp_value(interface, method, number_of_arguments):
225 def cpp_argument(argument): 223 def cpp_argument(argument):
226 idl_type = argument.idl_type 224 idl_type = argument.idl_type
227 if idl_type.name == 'EventListenerOrNull': 225 if idl_type.name == 'EventListener':
228 if (interface.name == 'EventTarget' and 226 if (interface.name == 'EventTarget' and
229 method.name == 'removeEventListener'): 227 method.name == 'removeEventListener'):
230 # FIXME: remove this special case by moving get() into 228 # FIXME: remove this special case by moving get() into
231 # EventTarget::removeEventListener 229 # EventTarget::removeEventListener
232 return '%s.get()' % argument.name 230 return '%s.get()' % argument.name
233 return argument.name 231 return argument.name
234 if (idl_type.is_callback_interface or 232 if (idl_type.is_callback_interface or
235 idl_type.name in ['NodeFilter', 'XPathNSResolver']): 233 idl_type.name in ['NodeFilter', 'XPathNSResolver']):
236 # FIXME: remove this special case 234 # FIXME: remove this special case
237 return '%s.release()' % argument.name 235 return '%s.release()' % argument.name
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 338
341 339
342 def union_arguments(idl_type): 340 def union_arguments(idl_type):
343 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" 341 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value"""
344 return [arg 342 return [arg
345 for i in range(len(idl_type.member_types)) 343 for i in range(len(idl_type.member_types))
346 for arg in ['result%sEnabled' % i, 'result%s' % i]] 344 for arg in ['result%sEnabled' % i, 'result%s' % i]]
347 345
348 IdlType.union_arguments = property(lambda self: None) 346 IdlType.union_arguments = property(lambda self: None)
349 IdlUnionType.union_arguments = property(union_arguments) 347 IdlUnionType.union_arguments = property(union_arguments)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/scripts/v8_types.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698