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

Side by Side Diff: lib/dom/scripts/systemhtml.py

Issue 10014028: Remove EventListener attributes from Dart DOM API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Create real IDLParentInterface. Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
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 shared functionality for the system to generate 6 """This module provides shared functionality for the system to generate
7 Dart:html APIs from the IDL database.""" 7 Dart:html APIs from the IDL database."""
8 8
9 from systemfrog import * 9 from systemfrog import *
10 from systeminterface import * 10 from systeminterface import *
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 'webkitanimationstart': 'webkitAnimationStart', 288 'webkitanimationstart': 'webkitAnimationStart',
289 'webkitspeechchange': 'webkitSpeechChange', 289 'webkitspeechchange': 'webkitSpeechChange',
290 'webkittransitionend': 'webkitTransitionEnd', 290 'webkittransitionend': 'webkitTransitionEnd',
291 } 291 }
292 292
293 # Mapping from raw event names to the pretty camelCase event names exposed as 293 # Mapping from raw event names to the pretty camelCase event names exposed as
294 # properties in dart:html. If the DOM exposes a new event name, you will need 294 # properties in dart:html. If the DOM exposes a new event name, you will need
295 # to add the lower case to camel case conversion for that event name here. 295 # to add the lower case to camel case conversion for that event name here.
296 _html_event_names = { 296 _html_event_names = {
297 'DOMContentLoaded': 'contentLoaded', 297 'DOMContentLoaded': 'contentLoaded',
298 'touchleave': 'touchLeave',
299 'abort': 'abort', 298 'abort': 'abort',
299 'addstream': 'addStream',
300 'addtrack': 'addTrack',
301 'audioend': 'audioEnd',
302 'audioprocess': 'audioProcess',
303 'audiostart': 'audioStart',
300 'beforecopy': 'beforeCopy', 304 'beforecopy': 'beforeCopy',
301 'beforecut': 'beforeCut', 305 'beforecut': 'beforeCut',
302 'beforepaste': 'beforePaste', 306 'beforepaste': 'beforePaste',
303 'beforeunload': 'beforeUnload', 307 'beforeunload': 'beforeUnload',
308 'blocked': 'blocked',
304 'blur': 'blur', 309 'blur': 'blur',
305 'cached': 'cached', 310 'cached': 'cached',
306 'canplay': 'canPlay', 311 'canplay': 'canPlay',
307 'canplaythrough': 'canPlayThrough', 312 'canplaythrough': 'canPlayThrough',
308 'change': 'change', 313 'change': 'change',
309 'checking': 'checking', 314 'checking': 'checking',
310 'click': 'click', 315 'click': 'click',
311 'close': 'close', 316 'close': 'close',
317 'complete': 'complete',
318 'connect': 'connect',
319 'connecting': 'connecting',
312 'contextmenu': 'contextMenu', 320 'contextmenu': 'contextMenu',
313 'copy': 'copy', 321 'copy': 'copy',
322 'cuechange': 'cueChange',
314 'cut': 'cut', 323 'cut': 'cut',
315 'dblclick': 'doubleClick', 324 'dblclick': 'doubleClick',
316 'devicemotion': 'deviceMotion', 325 'devicemotion': 'deviceMotion',
317 'deviceorientation': 'deviceOrientation', 326 'deviceorientation': 'deviceOrientation',
318 'display': 'display', 327 'display': 'display',
319 'downloading': 'downloading', 328 'downloading': 'downloading',
320 'drag': 'drag', 329 'drag': 'drag',
321 'dragend': 'dragEnd', 330 'dragend': 'dragEnd',
322 'dragenter': 'dragEnter', 331 'dragenter': 'dragEnter',
323 'dragleave': 'dragLeave', 332 'dragleave': 'dragLeave',
324 'dragover': 'dragOver', 333 'dragover': 'dragOver',
325 'dragstart': 'dragStart', 334 'dragstart': 'dragStart',
326 'drop': 'drop', 335 'drop': 'drop',
327 'durationchange': 'durationChange', 336 'durationchange': 'durationChange',
328 'emptied': 'emptied', 337 'emptied': 'emptied',
338 'end': 'end',
329 'ended': 'ended', 339 'ended': 'ended',
340 'enter': 'enter',
330 'error': 'error', 341 'error': 'error',
342 'exit': 'exit',
331 'focus': 'focus', 343 'focus': 'focus',
332 'hashchange': 'hashChange', 344 'hashchange': 'hashChange',
333 'input': 'input', 345 'input': 'input',
334 'invalid': 'invalid', 346 'invalid': 'invalid',
335 'keydown': 'keyDown', 347 'keydown': 'keyDown',
336 'keypress': 'keyPress', 348 'keypress': 'keyPress',
337 'keyup': 'keyUp', 349 'keyup': 'keyUp',
338 'load': 'load', 350 'load': 'load',
339 'loadeddata': 'loadedData', 351 'loadeddata': 'loadedData',
340 'loadedmetadata': 'loadedMetadata', 352 'loadedmetadata': 'loadedMetadata',
341 'loadend': 'loadEnd', 353 'loadend': 'loadEnd',
342 'loadstart': 'loadStart', 354 'loadstart': 'loadStart',
343 'message': 'message', 355 'message': 'message',
344 'mousedown': 'mouseDown', 356 'mousedown': 'mouseDown',
345 'mousemove': 'mouseMove', 357 'mousemove': 'mouseMove',
346 'mouseout': 'mouseOut', 358 'mouseout': 'mouseOut',
347 'mouseover': 'mouseOver', 359 'mouseover': 'mouseOver',
348 'mouseup': 'mouseUp', 360 'mouseup': 'mouseUp',
349 'mousewheel': 'mouseWheel', 361 'mousewheel': 'mouseWheel',
362 'nomatch': 'noMatch',
350 'noupdate': 'noUpdate', 363 'noupdate': 'noUpdate',
351 'obsolete': 'obsolete', 364 'obsolete': 'obsolete',
352 'offline': 'offline', 365 'offline': 'offline',
353 'online': 'online', 366 'online': 'online',
354 'open': 'open', 367 'open': 'open',
355 'pagehide': 'pageHide', 368 'pagehide': 'pageHide',
356 'pageshow': 'pageShow', 369 'pageshow': 'pageShow',
357 'paste': 'paste', 370 'paste': 'paste',
358 'pause': 'pause', 371 'pause': 'pause',
359 'play': 'play', 372 'play': 'play',
360 'playing': 'playing', 373 'playing': 'playing',
361 'popstate': 'popState', 374 'popstate': 'popState',
362 'progress': 'progress', 375 'progress': 'progress',
363 'ratechange': 'rateChange', 376 'ratechange': 'rateChange',
364 'readystatechange': 'readyStateChange', 377 'readystatechange': 'readyStateChange',
378 'removestream': 'removeStream',
365 'reset': 'reset', 379 'reset': 'reset',
366 'resize': 'resize', 380 'resize': 'resize',
381 'result': 'result',
382 'resultdeleted': 'resultDeleted',
367 'scroll': 'scroll', 383 'scroll': 'scroll',
368 'search': 'search', 384 'search': 'search',
369 'seeked': 'seeked', 385 'seeked': 'seeked',
370 'seeking': 'seeking', 386 'seeking': 'seeking',
371 'select': 'select', 387 'select': 'select',
372 'selectionchange': 'selectionChange', 388 'selectionchange': 'selectionChange',
373 'selectstart': 'selectStart', 389 'selectstart': 'selectStart',
374 'show': 'show', 390 'show': 'show',
391 'soundend': 'soundEnd',
392 'soundstart': 'soundStart',
393 'speechend': 'speechEnd',
394 'speechstart': 'speechStart',
375 'stalled': 'stalled', 395 'stalled': 'stalled',
396 'start': 'start',
397 'statechange': 'stateChange',
376 'storage': 'storage', 398 'storage': 'storage',
377 'submit': 'submit', 399 'submit': 'submit',
400 'success': 'success',
378 'suspend': 'suspend', 401 'suspend': 'suspend',
379 'timeupdate': 'timeUpdate', 402 'timeupdate': 'timeUpdate',
380 'touchcancel': 'touchCancel', 403 'touchcancel': 'touchCancel',
381 'touchend': 'touchEnd', 404 'touchend': 'touchEnd',
382 'touchenter': 'touchEnter', 405 'touchenter': 'touchEnter',
406 'touchleave': 'touchLeave',
383 'touchmove': 'touchMove', 407 'touchmove': 'touchMove',
384 'touchstart': 'touchStart', 408 'touchstart': 'touchStart',
385 'unload': 'unload', 409 'unload': 'unload',
386 'updateready': 'updateReady', 410 'updateready': 'updateReady',
411 'versionchange': 'versionChange',
387 'volumechange': 'volumeChange', 412 'volumechange': 'volumeChange',
388 'waiting': 'waiting', 413 'waiting': 'waiting',
389 'webkitAnimationEnd': 'animationEnd', 414 'webkitAnimationEnd': 'animationEnd',
390 'webkitAnimationIteration': 'animationIteration', 415 'webkitAnimationIteration': 'animationIteration',
391 'webkitAnimationStart': 'animationStart', 416 'webkitAnimationStart': 'animationStart',
392 'webkitfullscreenchange': 'fullscreenChange', 417 'webkitfullscreenchange': 'fullscreenChange',
393 'webkitfullscreenerror': 'fullscreenError', 418 'webkitfullscreenerror': 'fullscreenError',
394 'webkitSpeechChange': 'speechChange', 419 'webkitSpeechChange': 'speechChange',
395 'webkitTransitionEnd': 'transitionEnd' 420 'webkitTransitionEnd': 'transitionEnd',
421 'write': 'write',
422 'writeend': 'writeEnd',
423 'writestart': 'writeStart'
396 } 424 }
397 425
398 # These classes require an explicit declaration for the "on" method even though 426 # These classes require an explicit declaration for the "on" method even though
399 # they don't declare any unique events, because the concrete class hierarchy 427 # they don't declare any unique events, because the concrete class hierarchy
400 # doesn't match the interface hierarchy. 428 # doesn't match the interface hierarchy.
401 _html_explicit_event_classes = set(['DocumentFragment']) 429 _html_explicit_event_classes = set(['DocumentFragment'])
402 430
403 def _OnAttributeToEventName(on_method): 431 def _OnAttributeToEventName(on_method):
404 event_name = on_method.id[2:] 432 event_name = on_method.id[2:]
405 if event_name in _on_attribute_to_event_name_mapping: 433 if event_name in _on_attribute_to_event_name_mapping:
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 return parent_event_classes[0] 541 return parent_event_classes[0]
514 542
515 def _ImplClassName(self, type_name): 543 def _ImplClassName(self, type_name):
516 return '_' + type_name + 'Impl' 544 return '_' + type_name + 'Impl'
517 545
518 # This returns two values: the first is whether or not an "on" property should 546 # This returns two values: the first is whether or not an "on" property should
519 # be generated for the interface, and the second is the event attributes to 547 # be generated for the interface, and the second is the event attributes to
520 # generate if it should. 548 # generate if it should.
521 def GetEventAttributes(self, interface): 549 def GetEventAttributes(self, interface):
522 events = set([attr for attr in interface.attributes 550 events = set([attr for attr in interface.attributes
523 if self._generator._IsEventAttribute(interface, attr)]) 551 if attr.type.id == 'EventListener'])
524 552
525 if events or interface.id in _html_explicit_event_classes: 553 if events or interface.id in _html_explicit_event_classes:
526 return True, events 554 return True, events
527 else: 555 else:
528 return False, None 556 return False, None
529 557
530 def IsPrivate(self, name): 558 def IsPrivate(self, name):
531 return name.startswith('_') 559 return name.startswith('_')
532 560
533 class HtmlSystem(System): 561 class HtmlSystem(System):
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee 1674 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee
1647 # that Y = Z-X, so we need to check for Y. 1675 # that Y = Z-X, so we need to check for Y.
1648 true_code = emitter.Emit( 1676 true_code = emitter.Emit(
1649 '$(INDENT)if ($COND) {\n' 1677 '$(INDENT)if ($COND) {\n'
1650 '$!TRUE' 1678 '$!TRUE'
1651 '$(INDENT)}\n', 1679 '$(INDENT)}\n',
1652 COND=test, INDENT=indent) 1680 COND=test, INDENT=indent)
1653 self.GenerateDispatch( 1681 self.GenerateDispatch(
1654 true_code, info, indent + ' ', position + 1, positive) 1682 true_code, info, indent + ' ', position + 1, positive)
1655 return True 1683 return True
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698