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

Side by Side Diff: third_party/WebKit/Source/build/scripts/make_event_factory.py

Issue 2755313002: Fix issue 701381. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « AUTHORS ('k') | third_party/WebKit/Source/build/scripts/templates/EventFactory.cpp.tmpl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (C) 2013 Google Inc. All rights reserved. 2 # Copyright (C) 2013 Google Inc. All rights reserved.
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 or name == 'Event' 56 or name == 'Event'
57 or name == 'Events' 57 or name == 'Events'
58 or name.startswith('UIEvent') 58 or name.startswith('UIEvent')
59 or name.startswith('CustomEvent') 59 or name.startswith('CustomEvent')
60 or name == 'KeyboardEvent' 60 or name == 'KeyboardEvent'
61 or name == 'MessageEvent' 61 or name == 'MessageEvent'
62 or name.startswith('MouseEvent') 62 or name.startswith('MouseEvent')
63 or name == 'TouchEvent') 63 or name == 'TouchEvent')
64 64
65 65
66 # All events on the following whitelist are matched case-sensitively 66 # All events on the following whitelist are matched case-insensitively
67 # in createEvent and are measured using UseCounter. 67 # in createEvent and are mesured using UseCounter.
tkent 2017/03/20 22:51:07 mesured -> measured
68 # 68 def create_event_whitelist_use_counter(name):
foolip 2017/03/21 02:41:14 I don't think that a new list should be needed. I
69 # TODO(foolip): All events on this list should either be added to the spec and
70 # moved to the above whitelist (causing them to be matched case-insensitively)
71 # or be deprecated/removed. https://crbug.com/569690
72 def create_event_legacy_whitelist(name):
73 return (name == 'AnimationEvent' 69 return (name == 'AnimationEvent'
74 or name == 'BeforeUnloadEvent' 70 or name == 'BeforeUnloadEvent'
75 or name == 'CloseEvent' 71 or name == 'CloseEvent'
76 or name == 'CompositionEvent' 72 or name == 'CompositionEvent'
77 or name == 'DeviceMotionEvent' 73 or name == 'DeviceMotionEvent'
78 or name == 'DeviceOrientationEvent' 74 or name == 'DeviceOrientationEvent'
79 or name == 'DragEvent' 75 or name == 'DragEvent'
80 or name == 'ErrorEvent' 76 or name == 'ErrorEvent'
81 or name == 'FocusEvent' 77 or name == 'FocusEvent'
82 or name == 'HashChangeEvent' 78 or name == 'HashChangeEvent'
83 or name == 'IDBVersionChangeEvent' 79 or name == 'IDBVersionChangeEvent'
84 or name == 'KeyboardEvents'
85 or name == 'MutationEvent'
86 or name == 'MutationEvents'
87 or name == 'PageTransitionEvent' 80 or name == 'PageTransitionEvent'
88 or name == 'PopStateEvent' 81 or name == 'PopStateEvent'
89 or name == 'ProgressEvent' 82 or name == 'ProgressEvent'
90 or name == 'StorageEvent' 83 or name == 'StorageEvent'
91 or name == 'SVGEvents' 84 or name == 'SVGEvents'
92 or name == 'TextEvent' 85 or name == 'TextEvent'
93 or name == 'TrackEvent' 86 or name == 'TrackEvent'
94 or name == 'TransitionEvent' 87 or name == 'TransitionEvent'
95 or name == 'WebGLContextEvent' 88 or name == 'WebGLContextEvent'
89 or name == 'WheelEvent')
90
91
92 # All events on the following whitelist are matched case-sensitively
93 # in createEvent and are measured using UseCounter.
94 #
95 # TODO(foolip): All events on this list should either be added to the spec and
96 # moved to the above whitelist (causing them to be matched case-insensitively)
97 # or be deprecated/removed. https://crbug.com/569690
98 def create_event_legacy_whitelist(name):
99 return (name == 'KeyboardEvents'
100 or name == 'MutationEvent'
101 or name == 'MutationEvents'
96 or name == 'WebKitAnimationEvent' 102 or name == 'WebKitAnimationEvent'
97 or name == 'WebKitTransitionEvent' 103 or name == 'WebKitTransitionEvent')
98 or name == 'WheelEvent')
99 104
100 105
101 def measure_name(name): 106 def measure_name(name):
102 return 'DocumentCreateEvent' + name 107 return 'DocumentCreateEvent' + name
103 108
104 109
105 class EventFactoryWriter(json5_generator.Writer): 110 class EventFactoryWriter(json5_generator.Writer):
106 default_parameters = { 111 default_parameters = {
107 'ImplementedAs': None, 112 'ImplementedAs': None,
108 'RuntimeEnabled': None, 113 'RuntimeEnabled': None,
109 } 114 }
110 default_metadata = { 115 default_metadata = {
111 'export': '', 116 'export': '',
112 'namespace': '', 117 'namespace': '',
113 'suffix': '', 118 'suffix': '',
114 } 119 }
115 filters = { 120 filters = {
116 'cpp_name': name_utilities.cpp_name, 121 'cpp_name': name_utilities.cpp_name,
117 'lower_first': name_utilities.lower_first, 122 'lower_first': name_utilities.lower_first,
118 'script_name': name_utilities.script_name, 123 'script_name': name_utilities.script_name,
119 'create_event_whitelist': create_event_whitelist, 124 'create_event_whitelist': create_event_whitelist,
120 'create_event_legacy_whitelist': create_event_legacy_whitelist, 125 'create_event_legacy_whitelist': create_event_legacy_whitelist,
126 'create_event_whitelist_use_counter': create_event_whitelist_use_counter ,
121 'measure_name': measure_name, 127 'measure_name': measure_name,
122 } 128 }
123 129
124 def __init__(self, json5_file_path): 130 def __init__(self, json5_file_path):
125 super(EventFactoryWriter, self).__init__(json5_file_path) 131 super(EventFactoryWriter, self).__init__(json5_file_path)
126 self.namespace = self.json5_file.metadata['namespace'].strip('"') 132 self.namespace = self.json5_file.metadata['namespace'].strip('"')
127 self.suffix = self.json5_file.metadata['suffix'].strip('"') 133 self.suffix = self.json5_file.metadata['suffix'].strip('"')
128 self._outputs = {(self.namespace + self.suffix + "Headers.h"): self.gene rate_headers_header, 134 self._outputs = {(self.namespace + self.suffix + "Headers.h"): self.gene rate_headers_header,
129 (self.namespace + self.suffix + ".cpp"): self.generate_ implementation, 135 (self.namespace + self.suffix + ".cpp"): self.generate_ implementation,
130 } 136 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 def generate_implementation(self): 183 def generate_implementation(self):
178 return { 184 return {
179 'namespace': self.namespace, 185 'namespace': self.namespace,
180 'suffix': self.suffix, 186 'suffix': self.suffix,
181 'events': self.json5_file.name_dictionaries, 187 'events': self.json5_file.name_dictionaries,
182 } 188 }
183 189
184 190
185 if __name__ == "__main__": 191 if __name__ == "__main__":
186 json5_generator.Maker(EventFactoryWriter).main() 192 json5_generator.Maker(EventFactoryWriter).main()
OLDNEW
« no previous file with comments | « AUTHORS ('k') | third_party/WebKit/Source/build/scripts/templates/EventFactory.cpp.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698