| 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: | 50 # All events on the following whitelist are matched case-insensitively |
| 51 # in createEvent. |
| 52 # |
| 53 # All events not on the list are being measured (except for already |
| 54 # deprecated ones). The plan is to limit createEvent to just a few |
| 55 # selected events necessary for legacy content in accordance with the |
| 56 # specification: |
| 51 # | 57 # |
| 52 # https://dom.spec.whatwg.org/#dom-document-createevent | 58 # https://dom.spec.whatwg.org/#dom-document-createevent |
| 53 # | 59 def create_event_whitelist(name): |
| 54 # with the exepction for |keyevents| not present in Blink. | |
| 55 def case_insensitive_matching(name): | |
| 56 return (name == ('HTMLEvents') | 60 return (name == ('HTMLEvents') |
| 57 or name == 'Event' | 61 or name == 'Event' |
| 58 or name == 'Events' | 62 or name == 'Events' |
| 59 or name.startswith('UIEvent') | 63 or name.startswith('UIEvent') |
| 60 or name.startswith('CustomEvent') | 64 or name.startswith('CustomEvent') |
| 61 or name == 'KeyboardEvent' | 65 or name == 'KeyboardEvent' |
| 62 or name == 'MessageEvent' | 66 or name == 'MessageEvent' |
| 63 or name.startswith('MouseEvent') | 67 or name.startswith('MouseEvent') |
| 64 or name == 'TouchEvent') | 68 or name == 'TouchEvent') |
| 65 | 69 |
| 66 | 70 |
| 67 # All events not on the following whitelist are being measured in | 71 def create_event_deprecate_list(name): |
| 68 # createEvent. The plan is to limit createEvent to just a few selected | 72 return (name == 'SVGZoomEvent' |
| 69 # events necessary for legacy content in accordance with the | 73 or name == 'SVGZoomEvents') |
| 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 | 74 |
| 78 | 75 |
| 79 def measure_name(name): | 76 def measure_name(name): |
| 80 return 'DocumentCreateEvent' + name | 77 return 'DocumentCreateEvent' + name |
| 81 | 78 |
| 79 |
| 80 def deprecate_name(name): |
| 81 if (name.startswith('SVGZoomEvent')): |
| 82 return 'DeprecateSVGZoomEvent' |
| 83 return None |
| 84 |
| 85 |
| 82 class EventFactoryWriter(in_generator.Writer): | 86 class EventFactoryWriter(in_generator.Writer): |
| 83 defaults = { | 87 defaults = { |
| 84 'ImplementedAs': None, | 88 'ImplementedAs': None, |
| 85 'RuntimeEnabled': None, | 89 'RuntimeEnabled': None, |
| 86 } | 90 } |
| 87 default_parameters = { | 91 default_parameters = { |
| 88 'export': '', | 92 'export': '', |
| 89 'namespace': '', | 93 'namespace': '', |
| 90 'suffix': '', | 94 'suffix': '', |
| 91 } | 95 } |
| 92 filters = { | 96 filters = { |
| 93 'cpp_name': name_utilities.cpp_name, | 97 'cpp_name': name_utilities.cpp_name, |
| 94 'lower_first': name_utilities.lower_first, | 98 'lower_first': name_utilities.lower_first, |
| 95 'case_insensitive_matching': case_insensitive_matching, | |
| 96 'script_name': name_utilities.script_name, | 99 'script_name': name_utilities.script_name, |
| 97 'candidate_whitelist': candidate_whitelist, | 100 'create_event_whitelist': create_event_whitelist, |
| 101 'create_event_deprecate_list': create_event_deprecate_list, |
| 98 'measure_name': measure_name, | 102 'measure_name': measure_name, |
| 103 'deprecate_name': deprecate_name, |
| 99 } | 104 } |
| 100 | 105 |
| 101 def __init__(self, in_file_path): | 106 def __init__(self, in_file_path): |
| 102 super(EventFactoryWriter, self).__init__(in_file_path) | 107 super(EventFactoryWriter, self).__init__(in_file_path) |
| 103 self.namespace = self.in_file.parameters['namespace'].strip('"') | 108 self.namespace = self.in_file.parameters['namespace'].strip('"') |
| 104 self.suffix = self.in_file.parameters['suffix'].strip('"') | 109 self.suffix = self.in_file.parameters['suffix'].strip('"') |
| 105 self._validate_entries() | 110 self._validate_entries() |
| 106 self._outputs = {(self.namespace + self.suffix + "Headers.h"): self.gene
rate_headers_header, | 111 self._outputs = {(self.namespace + self.suffix + "Headers.h"): self.gene
rate_headers_header, |
| 107 (self.namespace + self.suffix + ".cpp"): self.generate_
implementation, | 112 (self.namespace + self.suffix + ".cpp"): self.generate_
implementation, |
| 108 } | 113 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 def generate_implementation(self): | 174 def generate_implementation(self): |
| 170 return { | 175 return { |
| 171 'namespace': self.namespace, | 176 'namespace': self.namespace, |
| 172 'suffix': self.suffix, | 177 'suffix': self.suffix, |
| 173 'events': self.in_file.name_dictionaries, | 178 'events': self.in_file.name_dictionaries, |
| 174 } | 179 } |
| 175 | 180 |
| 176 | 181 |
| 177 if __name__ == "__main__": | 182 if __name__ == "__main__": |
| 178 in_generator.Maker(EventFactoryWriter).main(sys.argv) | 183 in_generator.Maker(EventFactoryWriter).main(sys.argv) |
| OLD | NEW |