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

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

Issue 1673243002: Count document.createEvent() usage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-executioncontext-to
Patch Set: Update histograms.xml Created 4 years, 10 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 | « no previous file | 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 or name == 'Event' 52 or name == 'Event'
53 or name == 'Events' 53 or name == 'Events'
54 or name.startswith('UIEvent') 54 or name.startswith('UIEvent')
55 or name.startswith('CustomEvent') 55 or name.startswith('CustomEvent')
56 or name == 'KeyboardEvent' 56 or name == 'KeyboardEvent'
57 or name == 'MessageEvent' 57 or name == 'MessageEvent'
58 or name.startswith('MouseEvent') 58 or name.startswith('MouseEvent')
59 or name == 'TouchEvent') 59 or name == 'TouchEvent')
60 60
61 61
62 # All events _not_ on the following whitelist are being measured in
philipj_slow 2016/02/11 14:40:28 I like this approach! But can you reduce the list
63 # createEvent. The plan is to limit createEvent to just a few selected
64 # events necessary for legacy content according to the specification:
65 #
66 # https://dom.spec.whatwg.org/#dom-document-createevent
67 #
68 # The criteria for the current whitelist, unless otherwise noted, is
69 # to have a corresponding init*Event() function, or being an alias for
70 # an event that has a corresponding init*Event(). It isn't a full
71 # match with the spec yet.
72 def candidate_whitelist(name):
73 return (name == 'CustomEvent'
74 or name == 'CompositionEvent'
75 or name == 'DeviceMotionEvent'
76 or name == 'DeviceOrientationEvent'
77 or name == 'Event'
78 or name == 'Events'
79 or name == 'HTMLEvents'
80 or name == 'KeyboardEvent'
81 or name == 'KeyboardEvents'
82 or name == 'MessageEvent'
83 or name == 'MouseEvent'
84 or name == 'MutationEvent'
85 or name == 'OrientationEvent'
86 or name == 'SVGEvents'
87 or name == 'SVGZoomEvent' # Will be deprecated instead.
88 or name == 'StorageEvent'
89 or name == 'TextEvent'
90 or name == 'TouchEvent'
91 or name == 'UIEvent')
92
93
94 def measure_name(name):
95 return 'DocumentCreateEvent' + name
96
62 class EventFactoryWriter(in_generator.Writer): 97 class EventFactoryWriter(in_generator.Writer):
63 defaults = { 98 defaults = {
64 'ImplementedAs': None, 99 'ImplementedAs': None,
65 'RuntimeEnabled': None, 100 'RuntimeEnabled': None,
66 } 101 }
67 default_parameters = { 102 default_parameters = {
68 'export': '', 103 'export': '',
69 'namespace': '', 104 'namespace': '',
70 'suffix': '', 105 'suffix': '',
71 } 106 }
72 filters = { 107 filters = {
73 'cpp_name': name_utilities.cpp_name, 108 'cpp_name': name_utilities.cpp_name,
74 'lower_first': name_utilities.lower_first, 109 'lower_first': name_utilities.lower_first,
75 'case_insensitive_matching': case_insensitive_matching, 110 'case_insensitive_matching': case_insensitive_matching,
76 'script_name': name_utilities.script_name, 111 'script_name': name_utilities.script_name,
112 'candidate_whitelist': candidate_whitelist,
113 'measure_name': measure_name,
77 } 114 }
78 115
79 def __init__(self, in_file_path): 116 def __init__(self, in_file_path):
80 super(EventFactoryWriter, self).__init__(in_file_path) 117 super(EventFactoryWriter, self).__init__(in_file_path)
81 self.namespace = self.in_file.parameters['namespace'].strip('"') 118 self.namespace = self.in_file.parameters['namespace'].strip('"')
82 self.suffix = self.in_file.parameters['suffix'].strip('"') 119 self.suffix = self.in_file.parameters['suffix'].strip('"')
83 self._validate_entries() 120 self._validate_entries()
84 self._outputs = {(self.namespace + self.suffix + "Headers.h"): self.gene rate_headers_header, 121 self._outputs = {(self.namespace + self.suffix + "Headers.h"): self.gene rate_headers_header,
85 (self.namespace + self.suffix + ".cpp"): self.generate_ implementation, 122 (self.namespace + self.suffix + ".cpp"): self.generate_ implementation,
86 } 123 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 def generate_implementation(self): 184 def generate_implementation(self):
148 return { 185 return {
149 'namespace': self.namespace, 186 'namespace': self.namespace,
150 'suffix': self.suffix, 187 'suffix': self.suffix,
151 'events': self.in_file.name_dictionaries, 188 'events': self.in_file.name_dictionaries,
152 } 189 }
153 190
154 191
155 if __name__ == "__main__": 192 if __name__ == "__main__":
156 in_generator.Maker(EventFactoryWriter).main(sys.argv) 193 in_generator.Maker(EventFactoryWriter).main(sys.argv)
OLDNEW
« no previous file with comments | « no previous file | 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