Index: third_party/WebKit/Source/bindings/scripts/v8_interface.py |
diff --git a/third_party/WebKit/Source/bindings/scripts/v8_interface.py b/third_party/WebKit/Source/bindings/scripts/v8_interface.py |
index 1f7ab537dcb7f25dd709670ea9d73499d1966d62..d7bb3aba08ae8fc7300338a642c6318035d1ee11 100644 |
--- a/third_party/WebKit/Source/bindings/scripts/v8_interface.py |
+++ b/third_party/WebKit/Source/bindings/scripts/v8_interface.py |
@@ -107,25 +107,36 @@ def origin_trial_features(interface, constants, attributes, methods): |
to be installed on every instance of the interface. This list is the union |
of the sets of features used for constants, attributes and methods. |
""" |
+ key = 'origin_trial_feature_name' |
Yuki
2016/12/15 06:22:59
Constants should be all capital letters.
s/key/KEY
peria
2016/12/16 02:48:12
Done.
|
+ |
+ def member_filter(members): |
+ return sorted([member for member in members if member.get(key) and not member.get('exposed_test')]) |
+ |
+ def member_filter_by_name(members, name): |
+ return [member for member in members if member[key] == name] |
iclelland
2016/12/16 04:19:22
Very minor nit -- These two methods look very simi
peria
2016/12/16 05:02:10
I got it. I'll put a comment in a follow-up CL.
|
# Collect all members visible on this interface with a defined origin trial |
- origin_trial_members = ( |
- [constant for constant in constants if constant['origin_trial_feature_name']] + |
- [attribute for attribute in attributes if attribute['origin_trial_feature_name']] + |
- [method for method in methods if ( |
- v8_methods.method_is_visible(method, interface.is_partial) and |
- method['origin_trial_feature_name'])] |
- ) |
- # Group members by origin_trial_feature_name |
- members_by_name = itertools.groupby(sorted(origin_trial_members, |
- key=itemgetter('origin_trial_feature_name')), |
- itemgetter('origin_trial_feature_name')) |
+ origin_trial_constants = member_filter(constants) |
+ origin_trial_attributes = member_filter(attributes) |
+ origin_trial_methods = member_filter([method for method in methods |
+ if method['should_be_exposed_to_script'] and |
+ v8_methods.method_is_visible(method, interface.is_partial) and |
+ not v8_methods.conditionally_exposed(method) and |
+ not v8_methods.custom_registration(method)]) |
+ |
+ feature_names = set([member[key] for member in origin_trial_constants + origin_trial_attributes + origin_trial_methods]) |
+ |
# Construct the list of dictionaries. 'needs_instance' will be true if any |
# member for the feature has 'on_instance' defined as true. |
features = [{'name': name, |
- 'needs_instance': reduce(or_, (member.get('on_instance', False) |
- for member in members))} |
- for name, members in members_by_name] |
+ 'constants': member_filter_by_name(origin_trial_constants, name), |
+ 'attributes': member_filter_by_name(origin_trial_attributes, name), |
+ 'methods': member_filter_by_name(origin_trial_methods, name)} |
+ for name in feature_names] |
+ for feature in features: |
+ members = feature['constants'] + feature['attributes'] + feature['methods'] |
+ feature['needs_instance'] = reduce(or_, (member.get('on_instance', False) for member in members)) |
+ |
if features: |
includes.add('bindings/core/v8/ScriptState.h') |
includes.add('core/origin_trials/OriginTrials.h') |