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

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

Issue 2106983002: Allow origin trials to be declared on IDL operations (methods) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Eliminate empty install methods Created 4 years, 5 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 is_legacy_interface_type_checking) 43 is_legacy_interface_type_checking)
44 44
45 45
46 # Methods with any of these require custom method registration code in the 46 # Methods with any of these require custom method registration code in the
47 # interface's configure*Template() function. 47 # interface's configure*Template() function.
48 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([ 48 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([
49 'DoNotCheckSecurity', 49 'DoNotCheckSecurity',
50 ]) 50 ])
51 51
52 52
53 def method_is_visible(method, interface_is_partial):
54 if 'overloads' in method:
55 return method['overloads']['visible'] and not (method['overloads']['has_ partial_overloads'] and interface_is_partial)
56 return method['visible'] and 'overload_index' not in method
57
58
59 def conditionally_exposed(method):
60 return method['overloads']['exposed_test_all'] if 'overloads' in method else method['exposed_test']
61
62
63 def filter_conditionally_exposed(methods, interface_is_partial):
64 return [method for method in methods if (
65 method_is_visible(method, interface_is_partial) and conditionally_expose d(method))]
66
67
68 def custom_registration(method):
69 if 'overloads' in method:
70 return (method['overloads']['has_custom_registration_all'] or
71 method['overloads']['runtime_determined_lengths'] or
72 (method['overloads']['runtime_enabled_function_all'] and not con ditionally_exposed(method)))
73 return (method['has_custom_registration'] or
74 (method['runtime_enabled_function'] and not conditionally_exposed(me thod)))
75
76
77 def filter_custom_registration(methods, interface_is_partial):
78 return [method for method in methods if (
79 method_is_visible(method, interface_is_partial) and custom_registration( method))]
80
81
82 def filter_method_configuration(methods, interface_is_partial):
83 return [method for method in methods if
84 method_is_visible(method, interface_is_partial) and
85 method['should_be_exposed_to_script'] and
86 not method['origin_trial_feature_name'] and
87 not conditionally_exposed(method) and
88 not custom_registration(method)]
89
90
91 def method_for_origin_trial_feature(methods, feature_name, interface_is_partial) :
92 """Filters the list of methods, and returns those defined for the named orig in trial feature."""
93 return [method for method in methods if
94 method_is_visible(method, interface_is_partial) and
95 method['should_be_exposed_to_script'] and
96 method['origin_trial_feature_name'] == feature_name and
97 not conditionally_exposed(method) and
98 not custom_registration(method)]
99
100
101 def method_filters():
102 return {'has_method_configuration': filter_method_configuration,
103 'custom_registration': filter_custom_registration,
104 'conditionally_exposed': filter_conditionally_exposed,
105 'method_for_origin_trial_feature': method_for_origin_trial_feature}
haraken 2016/06/29 04:05:28 Nit: Alphabetical order.
iclelland 2016/06/29 05:04:20 Done.
106
107
53 def use_local_result(method): 108 def use_local_result(method):
54 extended_attributes = method.extended_attributes 109 extended_attributes = method.extended_attributes
55 idl_type = method.idl_type 110 idl_type = method.idl_type
56 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or 111 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or
57 'ImplementedInPrivateScript' in extended_attributes or 112 'ImplementedInPrivateScript' in extended_attributes or
58 'NewObject' in extended_attributes or 113 'NewObject' in extended_attributes or
59 'RaisesException' in extended_attributes or 114 'RaisesException' in extended_attributes or
60 idl_type.is_union_type or 115 idl_type.is_union_type or
61 idl_type.is_explicit_nullable) 116 idl_type.is_explicit_nullable)
62 117
63 118
64 def method_context(interface, method, is_visible=True): 119 def method_context(interface, method, is_visible=True):
65 arguments = method.arguments 120 arguments = method.arguments
66 extended_attributes = method.extended_attributes 121 extended_attributes = method.extended_attributes
67 idl_type = method.idl_type 122 idl_type = method.idl_type
68 is_static = method.is_static 123 is_static = method.is_static
69 name = method.name 124 name = method.name
70 125
71 # [OriginTrialEnabled]
72 # TODO(iclelland): Allow origin trials on methods
73 # (crbug.com/621641)
74 if v8_utilities.origin_trial_feature_name(method):
75 raise Exception('[OriginTrialEnabled] cannot be specified on '
76 'individual methods: %s.%s' % (interface.name, method.na me))
77
78 if is_visible: 126 if is_visible:
79 idl_type.add_includes_for_type(extended_attributes) 127 idl_type.add_includes_for_type(extended_attributes)
80 128
81 this_cpp_value = cpp_value(interface, method, len(arguments)) 129 this_cpp_value = cpp_value(interface, method, len(arguments))
82 130
83 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_ attributes 131 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_ attributes
84 if is_implemented_in_private_script: 132 if is_implemented_in_private_script:
85 includes.add('bindings/core/v8/PrivateScriptRunner.h') 133 includes.add('bindings/core/v8/PrivateScriptRunner.h')
86 includes.add('core/frame/LocalFrame.h') 134 includes.add('core/frame/LocalFrame.h')
87 includes.add('platform/ScriptForbiddenScope.h') 135 includes.add('platform/ScriptForbiddenScope.h')
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 argument for argument in arguments 239 argument for argument in arguments
192 if not (argument.is_optional or argument.is_variadic)]), 240 if not (argument.is_optional or argument.is_variadic)]),
193 'number_of_required_or_variadic_arguments': len([ 241 'number_of_required_or_variadic_arguments': len([
194 argument for argument in arguments 242 argument for argument in arguments
195 if not argument.is_optional]), 243 if not argument.is_optional]),
196 'on_instance': v8_utilities.on_instance(interface, method), 244 'on_instance': v8_utilities.on_instance(interface, method),
197 'on_interface': v8_utilities.on_interface(interface, method), 245 'on_interface': v8_utilities.on_interface(interface, method),
198 'on_prototype': v8_utilities.on_prototype(interface, method), 246 'on_prototype': v8_utilities.on_prototype(interface, method),
199 'only_exposed_to_private_script': is_only_exposed_to_private_script, 247 'only_exposed_to_private_script': is_only_exposed_to_private_script,
200 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct ion_name(method), # [OriginTrialEnabled] 248 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct ion_name(method), # [OriginTrialEnabled]
249 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(meth od), # [OriginTrialEnabled]
201 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value( 250 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value(
202 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is olate()', bailout_return_value='false'), 251 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is olate()', bailout_return_value='false'),
203 'property_attributes': property_attributes(interface, method), 252 'property_attributes': property_attributes(interface, method),
204 'returns_promise': method.returns_promise, 253 'returns_promise': method.returns_promise,
205 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m ethod), # [RuntimeEnabled] 254 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m ethod), # [RuntimeEnabled]
206 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script), 255 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script),
207 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res ult, 256 'use_output_parameter_for_result': idl_type.use_output_parameter_for_res ult,
208 'use_local_result': use_local_result(method), 257 'use_local_result': use_local_result(method),
209 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), 258 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value),
210 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), 259 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True),
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 return method.idl_type and method.idl_type.name == 'Promise' 520 return method.idl_type and method.idl_type.name == 'Promise'
472 521
473 IdlOperation.returns_promise = property(method_returns_promise) 522 IdlOperation.returns_promise = property(method_returns_promise)
474 523
475 524
476 def argument_conversion_needs_exception_state(method, argument): 525 def argument_conversion_needs_exception_state(method, argument):
477 idl_type = argument.idl_type 526 idl_type = argument.idl_type
478 return (idl_type.v8_conversion_needs_exception_state or 527 return (idl_type.v8_conversion_needs_exception_state or
479 argument.is_variadic or 528 argument.is_variadic or
480 (method.returns_promise and idl_type.is_string_type)) 529 (method.returns_promise and idl_type.is_string_type))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698