| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """This module provides functionality to generate dart:html event classes.""" | 6 """This module provides functionality to generate dart:html event classes.""" |
| 7 | 7 |
| 8 import logging | 8 import logging |
| 9 import monitored | 9 import monitored |
| 10 | 10 |
| 11 _logger = logging.getLogger('dartgenerator') | 11 _logger = logging.getLogger('dartgenerator') |
| 12 | 12 |
| 13 # Events without onEventName attributes in the IDL we want to support. | 13 # Events without onEventName attributes in the IDL we want to support. |
| 14 # We can automatically extract most event names by checking for | 14 # We can automatically extract most event names by checking for |
| 15 # onEventName methods in the IDL but some events aren't listed so we need | 15 # onEventName methods in the IDL but some events aren't listed so we need |
| 16 # to manually add them here so that they are easy for users to find. | 16 # to manually add them here so that they are easy for users to find. |
| 17 _html_manual_events = monitored.Dict('htmleventgenerator._html_manual_events', { | 17 _html_manual_events = monitored.Dict('htmleventgenerator._html_manual_events', { |
| 18 'Element': ['touchleave', 'touchenter', 'webkitTransitionEnd'], | 18 'Element': ['touchleave', 'touchenter', 'transitionend'], |
| 19 'Window': ['DOMContentLoaded'] | 19 'Window': ['DOMContentLoaded'] |
| 20 }) | 20 }) |
| 21 | 21 |
| 22 # These event names must be camel case when attaching event listeners | 22 # These event names must be camel case when attaching event listeners |
| 23 # using addEventListener even though the onEventName properties in the DOM for | 23 # using addEventListener even though the onEventName properties in the DOM for |
| 24 # them are not camel case. | 24 # them are not camel case. |
| 25 _on_attribute_to_event_name_mapping = monitored.Dict( | 25 _on_attribute_to_event_name_mapping = monitored.Dict( |
| 26 'htmleventgenerator._on_attribute_to_event_name_mapping', { | 26 'htmleventgenerator._on_attribute_to_event_name_mapping', { |
| 27 'webkitanimationend': 'webkitAnimationEnd', | 27 'webkitanimationend': 'webkitAnimationEnd', |
| 28 'webkitanimationiteration': 'webkitAnimationIteration', | 28 'webkitanimationiteration': 'webkitAnimationIteration', |
| 29 'webkitanimationstart': 'webkitAnimationStart', | 29 'webkitanimationstart': 'webkitAnimationStart', |
| 30 'webkitspeechchange': 'webkitSpeechChange', | 30 'webkitspeechchange': 'webkitSpeechChange', |
| 31 'webkittransitionend': 'webkitTransitionEnd', | |
| 32 }) | 31 }) |
| 33 | 32 |
| 34 _html_event_types = monitored.Dict('htmleventgenerator._html_event_types', { | 33 _html_event_types = monitored.Dict('htmleventgenerator._html_event_types', { |
| 35 '*.abort': ('abort', 'Event'), | 34 '*.abort': ('abort', 'Event'), |
| 36 '*.beforecopy': ('beforeCopy', 'Event'), | 35 '*.beforecopy': ('beforeCopy', 'Event'), |
| 37 '*.beforecut': ('beforeCut', 'Event'), | 36 '*.beforecut': ('beforeCut', 'Event'), |
| 38 '*.beforepaste': ('beforePaste', 'Event'), | 37 '*.beforepaste': ('beforePaste', 'Event'), |
| 39 '*.beforeunload': ('beforeUnload', 'Event'), | 38 '*.beforeunload': ('beforeUnload', 'Event'), |
| 40 '*.blur': ('blur', 'Event'), | 39 '*.blur': ('blur', 'Event'), |
| 41 '*.canplay': ('canPlay', 'Event'), | 40 '*.canplay': ('canPlay', 'Event'), |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 '*.touchenter': ('touchEnter', 'TouchEvent'), | 100 '*.touchenter': ('touchEnter', 'TouchEvent'), |
| 102 '*.touchleave': ('touchLeave', 'TouchEvent'), | 101 '*.touchleave': ('touchLeave', 'TouchEvent'), |
| 103 '*.touchmove': ('touchMove', 'TouchEvent'), | 102 '*.touchmove': ('touchMove', 'TouchEvent'), |
| 104 '*.touchstart': ('touchStart', 'TouchEvent'), | 103 '*.touchstart': ('touchStart', 'TouchEvent'), |
| 105 '*.unload': ('unload', 'Event'), | 104 '*.unload': ('unload', 'Event'), |
| 106 '*.volumechange': ('volumeChange', 'Event'), | 105 '*.volumechange': ('volumeChange', 'Event'), |
| 107 '*.waiting': ('waiting', 'Event'), | 106 '*.waiting': ('waiting', 'Event'), |
| 108 '*.webkitAnimationEnd': ('animationEnd', 'AnimationEvent'), | 107 '*.webkitAnimationEnd': ('animationEnd', 'AnimationEvent'), |
| 109 '*.webkitAnimationIteration': ('animationIteration', 'AnimationEvent'), | 108 '*.webkitAnimationIteration': ('animationIteration', 'AnimationEvent'), |
| 110 '*.webkitAnimationStart': ('animationStart', 'AnimationEvent'), | 109 '*.webkitAnimationStart': ('animationStart', 'AnimationEvent'), |
| 111 '*.webkitTransitionEnd': ('transitionEnd', 'TransitionEvent'), | 110 '*.transitionend': ('transitionEnd', 'TransitionEvent'), |
| 112 '*.webkitfullscreenchange': ('fullscreenChange', 'Event'), | 111 '*.webkitfullscreenchange': ('fullscreenChange', 'Event'), |
| 113 '*.webkitfullscreenerror': ('fullscreenError', 'Event'), | 112 '*.webkitfullscreenerror': ('fullscreenError', 'Event'), |
| 114 'AbstractWorker.error': ('error', 'ErrorEvent'), | 113 'AbstractWorker.error': ('error', 'ErrorEvent'), |
| 115 'AudioContext.complete': ('complete', 'Event'), | 114 'AudioContext.complete': ('complete', 'Event'), |
| 116 'DOMApplicationCache.cached': ('cached', 'Event'), | 115 'DOMApplicationCache.cached': ('cached', 'Event'), |
| 117 'DOMApplicationCache.checking': ('checking', 'Event'), | 116 'DOMApplicationCache.checking': ('checking', 'Event'), |
| 118 'DOMApplicationCache.downloading': ('downloading', 'Event'), | 117 'DOMApplicationCache.downloading': ('downloading', 'Event'), |
| 119 'DOMApplicationCache.noupdate': ('noUpdate', 'Event'), | 118 'DOMApplicationCache.noupdate': ('noUpdate', 'Event'), |
| 120 'DOMApplicationCache.obsolete': ('obsolete', 'Event'), | 119 'DOMApplicationCache.obsolete': ('obsolete', 'Event'), |
| 121 'DOMApplicationCache.progress': ('progress', 'Event'), | 120 'DOMApplicationCache.progress': ('progress', 'Event'), |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 """ | 361 """ |
| 363 key = '%s.%s' % (html_interface_name, dom_event_name) | 362 key = '%s.%s' % (html_interface_name, dom_event_name) |
| 364 if key in _html_event_types: | 363 if key in _html_event_types: |
| 365 return _html_event_types[key] | 364 return _html_event_types[key] |
| 366 key = '*.%s' % dom_event_name | 365 key = '*.%s' % dom_event_name |
| 367 if key in _html_event_types: | 366 if key in _html_event_types: |
| 368 return _html_event_types[key] | 367 return _html_event_types[key] |
| 369 _logger.warn('Cannot resolve event type for %s.%s' % | 368 _logger.warn('Cannot resolve event type for %s.%s' % |
| 370 (html_interface_name, dom_event_name)) | 369 (html_interface_name, dom_event_name)) |
| 371 return None | 370 return None |
| OLD | NEW |