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

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

Issue 10969073: Fixing up WheelEvent to follow W3C standards and work on all platforms. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporating review feedback Created 8 years, 2 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
« no previous file with comments | « lib/html/scripts/htmlrenamer.py ('k') | lib/html/scripts/systemnative.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import emitter 9 import emitter
10 10
11 from systemdart2js import * 11 from systemdart2js import *
12 from systeminterface import * 12 from systeminterface import *
13 13
14 _js_custom_members = set([ 14 _js_custom_members = set([
15 'CSSStyleDeclaration.setProperty', 15 'CSSStyleDeclaration.setProperty',
16 'Element.insertAdjacentElement', 16 'Element.insertAdjacentElement',
17 'Element.insertAdjacentHTML', 17 'Element.insertAdjacentHTML',
18 'Element.insertAdjacentText', 18 'Element.insertAdjacentText',
19 'ElementEvents.mouseWheel',
19 'IDBDatabase.transaction', 20 'IDBDatabase.transaction',
20 'IFrameElement.contentWindow', 21 'IFrameElement.contentWindow',
21 'MouseEvent.offsetX', 22 'MouseEvent.offsetX',
22 'MouseEvent.offsetY', 23 'MouseEvent.offsetY',
23 'TableElement.createTBody', 24 'TableElement.createTBody',
24 'Window.document', 25 'Window.document',
25 'Window.top', 26 'Window.top',
26 'Window.location', 27 'Window.location',
27 'Window.open', 28 'Window.open',
28 ]) 29 ])
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 return 704 return
704 705
705 self._EmitEventGetter(events_interface, events_class) 706 self._EmitEventGetter(events_interface, events_class)
706 707
707 events_members = self._interface_emitter.Emit( 708 events_members = self._interface_emitter.Emit(
708 '\nabstract class $INTERFACE implements $PARENTS {\n$!MEMBERS}\n', 709 '\nabstract class $INTERFACE implements $PARENTS {\n$!MEMBERS}\n',
709 INTERFACE=events_interface, 710 INTERFACE=events_interface,
710 PARENTS=', '.join( 711 PARENTS=', '.join(
711 self._shared.GetParentsEventsClasses(self._interface))) 712 self._shared.GetParentsEventsClasses(self._interface)))
712 713
713 # TODO(jacobr): specify the type of _ptr as EventTarget 714 template_file = 'impl_%s.darttemplate' % events_interface
714 implementation_events_members = self._implementation_emitter.Emit( 715 template = (self._backend._system._templates.TryLoad(template_file) or
715 '\n' 716 '\n'
716 'class $CLASSNAME extends $SUPER implements $INTERFACE {\n' 717 'class $CLASSNAME extends $SUPER implements $INTERFACE {\n'
717 ' $CLASSNAME(_ptr) : super(_ptr);\n' 718 ' $CLASSNAME(_ptr) : super(_ptr);\n'
718 '$!MEMBERS}\n', 719 '$!MEMBERS}\n')
720
721 # TODO(jacobr): specify the type of _ptr as EventTarget
722 implementation_events_members = self._implementation_emitter.Emit(
723 template,
719 CLASSNAME=events_class, 724 CLASSNAME=events_class,
720 INTERFACE=events_interface, 725 INTERFACE=events_interface,
721 SUPER=parent_events_class) 726 SUPER=parent_events_class)
722 727
723 event_attrs = DomToHtmlEvents(self._html_interface_name, event_attrs) 728 event_attrs = DomToHtmlEvents(self._html_interface_name, event_attrs)
724 for event_name in event_attrs: 729 for event_name in event_attrs:
725 if event_name in _html_event_names: 730 if event_name in _html_event_names:
731 dart_event_name = _html_event_names[event_name]
726 events_members.Emit('\n EventListenerList get $NAME;\n', 732 events_members.Emit('\n EventListenerList get $NAME;\n',
727 NAME=_html_event_names[event_name]) 733 NAME=dart_event_name)
728 implementation_events_members.Emit( 734 if not self._backend.HasCustomEventImplementation(dart_event_name):
729 "\n" 735 implementation_events_members.Emit(
730 " EventListenerList get $NAME => this['$DOM_NAME'];\n", 736 "\n"
731 NAME=_html_event_names[event_name], 737 " EventListenerList get $NAME => this['$DOM_NAME'];\n",
732 DOM_NAME=event_name) 738 NAME=dart_event_name,
739 DOM_NAME=event_name)
733 else: 740 else:
734 raise Exception('No known html even name for event: ' + event_name) 741 raise Exception('No known html even name for event: ' + event_name)
735 742
736 def _EmitEventGetter(self, events_interface, events_class): 743 def _EmitEventGetter(self, events_interface, events_class):
737 self._members_emitter.Emit( 744 self._members_emitter.Emit(
738 '\n /**' 745 '\n /**'
739 '\n * @domName EventTarget.addEventListener, ' 746 '\n * @domName EventTarget.addEventListener, '
740 'EventTarget.removeEventListener, EventTarget.dispatchEvent' 747 'EventTarget.removeEventListener, EventTarget.dispatchEvent'
741 '\n */' 748 '\n */'
742 '\n $TYPE get on;\n', 749 '\n $TYPE get on;\n',
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 def _OutputConversion(self, idl_type, member): 1210 def _OutputConversion(self, idl_type, member):
1204 return FindConversion(idl_type, 'get', self._interface.id, member) 1211 return FindConversion(idl_type, 'get', self._interface.id, member)
1205 1212
1206 def _InputConversion(self, idl_type, member): 1213 def _InputConversion(self, idl_type, member):
1207 return FindConversion(idl_type, 'set', self._interface.id, member) 1214 return FindConversion(idl_type, 'set', self._interface.id, member)
1208 1215
1209 def _HasCustomImplementation(self, member_name): 1216 def _HasCustomImplementation(self, member_name):
1210 member_name = '%s.%s' % (self._html_interface_name, member_name) 1217 member_name = '%s.%s' % (self._html_interface_name, member_name)
1211 return member_name in _js_custom_members 1218 return member_name in _js_custom_members
1212 1219
1220 def HasCustomEventImplementation(self, member_name):
1221 member_name = '%sEvents.%s' % (self._html_interface_name, member_name)
1222 return member_name in _js_custom_members
1223
1213 def _HasJavaScriptIndexingBehaviour(self): 1224 def _HasJavaScriptIndexingBehaviour(self):
1214 """Returns True if the native object has an indexer and length property.""" 1225 """Returns True if the native object has an indexer and length property."""
1215 (element_type, requires_indexer) = ListImplementationInfo( 1226 (element_type, requires_indexer) = ListImplementationInfo(
1216 self._interface, self._database) 1227 self._interface, self._database)
1217 if element_type and requires_indexer: return True 1228 if element_type and requires_indexer: return True
1218 return False 1229 return False
1219 1230
1220 # ------------------------------------------------------------------------------ 1231 # ------------------------------------------------------------------------------
1221 1232
1222 class HtmlDart2JSSystem(System): 1233 class HtmlDart2JSSystem(System):
1223 1234
1224 def __init__(self, options): 1235 def __init__(self, options):
1225 super(HtmlDart2JSSystem, self).__init__(options) 1236 super(HtmlDart2JSSystem, self).__init__(options)
1226 1237
1227 def ImplementationGenerator(self, interface): 1238 def ImplementationGenerator(self, interface):
1228 return HtmlDart2JSClassGenerator(self, interface) 1239 return HtmlDart2JSClassGenerator(self, interface)
1229 1240
1230 def GenerateLibraries(self, dart_files): 1241 def GenerateLibraries(self, dart_files):
1231 auxiliary_dir = os.path.relpath(self._auxiliary_dir, self._output_dir) 1242 auxiliary_dir = os.path.relpath(self._auxiliary_dir, self._output_dir)
1232 self._GenerateLibFile( 1243 self._GenerateLibFile(
1233 'html_dart2js.darttemplate', 1244 'html_dart2js.darttemplate',
1234 os.path.join(self._output_dir, 'html_dart2js.dart'), 1245 os.path.join(self._output_dir, 'html_dart2js.dart'),
1235 dart_files, 1246 dart_files,
1236 AUXILIARY_DIR=systembase.MassagePath(auxiliary_dir)) 1247 AUXILIARY_DIR=systembase.MassagePath(auxiliary_dir))
1237 1248
1238 def Finish(self): 1249 def Finish(self):
1239 pass 1250 pass
OLDNEW
« no previous file with comments | « lib/html/scripts/htmlrenamer.py ('k') | lib/html/scripts/systemnative.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698