OLD | NEW |
---|---|
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 29 matching lines...) Expand all Loading... | |
40 | 40 |
41 #ifndef %(namespace)s%(suffix)sHeaders_h | 41 #ifndef %(namespace)s%(suffix)sHeaders_h |
42 #define %(namespace)s%(suffix)sHeaders_h | 42 #define %(namespace)s%(suffix)sHeaders_h |
43 %(base_header_for_suffix)s | 43 %(base_header_for_suffix)s |
44 %(includes)s | 44 %(includes)s |
45 | 45 |
46 #endif // %(namespace)s%(suffix)sHeaders_h | 46 #endif // %(namespace)s%(suffix)sHeaders_h |
47 """ | 47 """ |
48 | 48 |
49 | 49 |
50 # The list is a close match to: | |
51 # | |
52 # https://dom.spec.whatwg.org/#dom-document-createevent | |
53 # | |
54 # with the exepction for |keyevents| not present in Blink. | |
philipj_slow
2016/02/13 14:29:58
https://github.com/whatwg/dom/issues/148
| |
50 def case_insensitive_matching(name): | 55 def case_insensitive_matching(name): |
51 return (name == ('HTMLEvents') | 56 return (name == ('HTMLEvents') |
52 or name == 'Event' | 57 or name == 'Event' |
53 or name == 'Events' | 58 or name == 'Events' |
54 or name.startswith('UIEvent') | 59 or name.startswith('UIEvent') |
55 or name.startswith('CustomEvent') | 60 or name.startswith('CustomEvent') |
56 or name == 'KeyboardEvent' | 61 or name == 'KeyboardEvent' |
57 or name == 'MessageEvent' | 62 or name == 'MessageEvent' |
58 or name.startswith('MouseEvent') | 63 or name.startswith('MouseEvent') |
59 or name == 'TouchEvent') | 64 or name == 'TouchEvent') |
60 | 65 |
61 | 66 |
67 # All events not on the following whitelist are being measured in | |
68 # createEvent. The plan is to limit createEvent to just a few selected | |
69 # events necessary for legacy content in accordance with the | |
70 # specification: | |
71 # | |
72 # https://dom.spec.whatwg.org/#dom-document-createevent | |
73 def candidate_whitelist(name): | |
74 return (case_insensitive_matching(name) | |
75 or name == 'SVGZoomEvent' # Will be deprecated instead. | |
76 or name == 'SVGZoomEvents') # Will be deprecated instead. | |
77 | |
78 | |
79 def measure_name(name): | |
80 return 'DocumentCreateEvent' + name | |
81 | |
62 class EventFactoryWriter(in_generator.Writer): | 82 class EventFactoryWriter(in_generator.Writer): |
63 defaults = { | 83 defaults = { |
64 'ImplementedAs': None, | 84 'ImplementedAs': None, |
65 'RuntimeEnabled': None, | 85 'RuntimeEnabled': None, |
66 } | 86 } |
67 default_parameters = { | 87 default_parameters = { |
68 'export': '', | 88 'export': '', |
69 'namespace': '', | 89 'namespace': '', |
70 'suffix': '', | 90 'suffix': '', |
71 } | 91 } |
72 filters = { | 92 filters = { |
73 'cpp_name': name_utilities.cpp_name, | 93 'cpp_name': name_utilities.cpp_name, |
74 'lower_first': name_utilities.lower_first, | 94 'lower_first': name_utilities.lower_first, |
75 'case_insensitive_matching': case_insensitive_matching, | 95 'case_insensitive_matching': case_insensitive_matching, |
76 'script_name': name_utilities.script_name, | 96 'script_name': name_utilities.script_name, |
97 'candidate_whitelist': candidate_whitelist, | |
98 'measure_name': measure_name, | |
77 } | 99 } |
78 | 100 |
79 def __init__(self, in_file_path): | 101 def __init__(self, in_file_path): |
80 super(EventFactoryWriter, self).__init__(in_file_path) | 102 super(EventFactoryWriter, self).__init__(in_file_path) |
81 self.namespace = self.in_file.parameters['namespace'].strip('"') | 103 self.namespace = self.in_file.parameters['namespace'].strip('"') |
82 self.suffix = self.in_file.parameters['suffix'].strip('"') | 104 self.suffix = self.in_file.parameters['suffix'].strip('"') |
83 self._validate_entries() | 105 self._validate_entries() |
84 self._outputs = {(self.namespace + self.suffix + "Headers.h"): self.gene rate_headers_header, | 106 self._outputs = {(self.namespace + self.suffix + "Headers.h"): self.gene rate_headers_header, |
85 (self.namespace + self.suffix + ".cpp"): self.generate_ implementation, | 107 (self.namespace + self.suffix + ".cpp"): self.generate_ implementation, |
86 } | 108 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 def generate_implementation(self): | 169 def generate_implementation(self): |
148 return { | 170 return { |
149 'namespace': self.namespace, | 171 'namespace': self.namespace, |
150 'suffix': self.suffix, | 172 'suffix': self.suffix, |
151 'events': self.in_file.name_dictionaries, | 173 'events': self.in_file.name_dictionaries, |
152 } | 174 } |
153 | 175 |
154 | 176 |
155 if __name__ == "__main__": | 177 if __name__ == "__main__": |
156 in_generator.Maker(EventFactoryWriter).main(sys.argv) | 178 in_generator.Maker(EventFactoryWriter).main(sys.argv) |
OLD | NEW |