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

Side by Side Diff: tools/dom/scripts/htmleventgenerator.py

Issue 21607003: Add Event delegation to Elements and groups of elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 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
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 # If the provider is declared elsewhere, point to that. 285 # If the provider is declared elsewhere, point to that.
286 redirection = self._GetEventRedirection(interface, html_name, event_type) 286 redirection = self._GetEventRedirection(interface, html_name, event_type)
287 if redirection: 287 if redirection:
288 provider = '%s.%sEvent' % (redirection, html_name) 288 provider = '%s.%sEvent' % (redirection, html_name)
289 else: 289 else:
290 provider = html_name + 'Event' 290 provider = html_name + 'Event'
291 291
292 annotations = self._metadata.GetFormattedMetadata( 292 annotations = self._metadata.GetFormattedMetadata(
293 library_name, interface, annotation_name, ' ') 293 library_name, interface, annotation_name, ' ')
294 294
295 isElement = False
296 for parent in self._database.Hierarchy(interface):
297 if parent.id == 'Element':
298 isElement = True
295 members_emitter.Emit( 299 members_emitter.Emit(
296 "\n" 300 "\n"
297 " $(ANNOTATIONS)Stream<$TYPE> get $(NAME) => " 301 " $(ANNOTATIONS)$(ELEM_TYPE)Stream<$TYPE> get $(NAME) => "
298 "$PROVIDER.forTarget(this);\n", 302 "$PROVIDER.for$(ELEM_TYPE)Target(this);\n",
299 ANNOTATIONS=annotations, 303 ANNOTATIONS=annotations,
304 ELEM_TYPE='Element' if isElement else '',
300 NAME=getter_name, 305 NAME=getter_name,
301 PROVIDER=provider, 306 PROVIDER=provider,
302 TYPE=event_type) 307 TYPE=event_type)
303 308
304 def _GetRawEvents(self, interface): 309 def _GetRawEvents(self, interface):
305 all_interfaces = ([ interface ] + 310 all_interfaces = ([ interface ] +
306 self._database.TransitiveSecondaryParents(interface)) 311 self._database.TransitiveSecondaryParents(interface))
307 events = set([]) 312 events = set([])
308 for super_interface in all_interfaces: 313 for super_interface in all_interfaces:
309 events = events.union( 314 events = events.union(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 """ 387 """
383 key = '%s.%s' % (html_interface_name, dom_event_name) 388 key = '%s.%s' % (html_interface_name, dom_event_name)
384 if key in _html_event_types: 389 if key in _html_event_types:
385 return _html_event_types[key] 390 return _html_event_types[key]
386 key = '*.%s' % dom_event_name 391 key = '*.%s' % dom_event_name
387 if key in _html_event_types: 392 if key in _html_event_types:
388 return _html_event_types[key] 393 return _html_event_types[key]
389 _logger.warn('Cannot resolve event type for %s.%s' % 394 _logger.warn('Cannot resolve event type for %s.%s' %
390 (html_interface_name, dom_event_name)) 395 (html_interface_name, dom_event_name))
391 return None 396 return None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698