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

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

Issue 12380046: Future-ify all the html methods and add named parameters (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « tools/dom/scripts/htmldartgenerator.py ('k') | tools/dom/scripts/monitored.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 import logging 5 import logging
6 import monitored 6 import monitored
7 import re 7 import re
8 8
9 html_interface_renames = monitored.Dict('htmlrenamer.html_interface_renames', { 9 html_interface_renames = monitored.Dict('htmlrenamer.html_interface_renames', {
10 'CDATASection': 'CDataSection', 10 'CDATASection': 'CDataSection',
11 'Clipboard': 'DataTransfer', 11 'Clipboard': 'DataTransfer',
12 'Database': 'SqlDatabase', # Avoid conflict with Index DB's Database. 12 'Database': 'SqlDatabase', # Avoid conflict with Index DB's Database.
13 'DatabaseSync': 'SqlDatabaseSync', 13 'DatabaseSync': 'SqlDatabaseSync',
14 'DOMApplicationCache': 'ApplicationCache', 14 'DOMApplicationCache': 'ApplicationCache',
15 'DOMCoreException': 'DomException', 15 'DOMCoreException': 'DomException',
16 'DOMFileSystem': 'FileSystem', 16 'DOMFileSystem': 'FileSystem',
17 'DOMFileSystemSync': 'FileSystemSync', 17 'DOMFileSystemSync': 'FileSystemSync',
18 'DOMFormData': 'FormData', 18 'DOMFormData': 'FormData',
19 'DOMURL': 'Url', 19 'DOMURL': 'Url',
20 'DOMWindow': 'Window', 20 'DOMWindow': 'Window',
21 'EntryCallback': '_EntryCallback',
22 'EntriesCallback': '_EntriesCallback',
23 'ErrorCallback': '_ErrorCallback',
24 'FileCallback': '_FileCallback',
25 'FileSystemCallback': '_FileSystemCallback',
26 'FileWriterCallback': '_FileWriterCallback',
21 'HTMLDocument' : 'HtmlDocument', 27 'HTMLDocument' : 'HtmlDocument',
22 'IDBFactory': 'IdbFactory', # Manual to avoid name conflicts. 28 'IDBFactory': 'IdbFactory', # Manual to avoid name conflicts.
23 'NamedNodeMap': '_NamedNodeMap', 29 'NamedNodeMap': '_NamedNodeMap',
24 'NavigatorUserMediaErrorCallback': '_NavigatorUserMediaErrorCallback', 30 'NavigatorUserMediaErrorCallback': '_NavigatorUserMediaErrorCallback',
25 'NavigatorUserMediaSuccessCallback': '_NavigatorUserMediaSuccessCallback', 31 'NavigatorUserMediaSuccessCallback': '_NavigatorUserMediaSuccessCallback',
32 'NotificationPermissionCallback': '_NotificationPermissionCallback',
26 'PositionCallback': '_PositionCallback', 33 'PositionCallback': '_PositionCallback',
27 'PositionErrorCallback': '_PositionErrorCallback', 34 'PositionErrorCallback': '_PositionErrorCallback',
35 'RTCErrorCallback': '_RtcErrorCallback',
36 'RTCSessionDescriptionCallback': '_RtcSessionDescriptionCallback',
37 'StorageInfoErrorCallback': '_StorageInfoErrorCallback',
38 'StorageInfoUsageCallback': '_StorageInfoUsageCallback',
39 'StringCallback': '_StringCallback',
28 'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts. 40 'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts.
29 'SVGElement': 'SvgElement', # Manual to avoid name conflicts. 41 'SVGElement': 'SvgElement', # Manual to avoid name conflicts.
30 'SVGException': 'SvgException', # Manual of avoid conflict with Exception. 42 'SVGException': 'SvgException', # Manual of avoid conflict with Exception.
31 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts. 43 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts.
32 'WebGLVertexArrayObjectOES': 'WebGLVertexArrayObject', 44 'WebGLVertexArrayObjectOES': 'WebGLVertexArrayObject',
33 'WebKitAnimationEvent': 'AnimationEvent', 45 'WebKitAnimationEvent': 'AnimationEvent',
34 'WebKitCSSKeyframeRule': 'CssKeyframeRule', 46 'WebKitCSSKeyframeRule': 'CssKeyframeRule',
35 'WebKitCSSKeyframesRule': 'CssKeyframesRule', 47 'WebKitCSSKeyframesRule': 'CssKeyframesRule',
36 'WebKitCSSMatrix': 'CssMatrix', 48 'WebKitCSSMatrix': 'CssMatrix',
37 'WebKitCSSTransformValue': 'CssTransformValue', 49 'WebKitCSSTransformValue': 'CssTransformValue',
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 'SVGHKernElement', 84 'SVGHKernElement',
73 'SVGMissingGlyphElement', 85 'SVGMissingGlyphElement',
74 'SVGMPathElement', 86 'SVGMPathElement',
75 'SVGTRefElement', 87 'SVGTRefElement',
76 'SVGVKernElement', 88 'SVGVKernElement',
77 ] 89 ]
78 90
79 for interface in _removed_html_interfaces: 91 for interface in _removed_html_interfaces:
80 html_interface_renames[interface] = '_' + interface 92 html_interface_renames[interface] = '_' + interface
81 93
94 convert_to_future_members = monitored.Set(
95 'htmlrenamer.converted_to_future_members', [
96 'DataTransferItem.getAsString',
97 'DirectoryEntry.getDirectory',
98 'DirectoryEntry.getFile',
99 'DirectoryEntry.removeRecursively',
100 'DirectoryReader.readEntries',
101 'DOMWindow.webkitRequestFileSystem',
102 'DOMWindow.webkitResolveLocalFileSystemURL',
103 'Entry.copyTo',
104 'Entry.getMetadata',
105 'Entry.getParent',
106 'Entry.moveTo',
107 'Entry.remove',
108 'FileEntry.createWriter',
109 'FileEntry.file',
110 'Notification.requestPermission',
111 'NotificationCenter.requestPermission',
112 'RTCPeerConnection.createAnswer',
113 'RTCPeerConnection.createOffer',
114 'RTCPeerConnection.setLocalDescription',
115 'RTCPeerConnection.setRemoteDescription',
116 'StorageInfo.queryUsageAndQuota',
117 'StorageInfo.requestQuota',
118 'WorkerContext.webkitResolveLocalFileSystemURL',
119 ])
120
82 # Members from the standard dom that should not be exposed publicly in dart:html 121 # Members from the standard dom that should not be exposed publicly in dart:html
83 # but need to be exposed internally to implement dart:html on top of a standard 122 # but need to be exposed internally to implement dart:html on top of a standard
84 # browser. 123 # browser.
85 _private_html_members = monitored.Set('htmlrenamer._private_html_members', [ 124 _private_html_members = monitored.Set('htmlrenamer._private_html_members', [
86 'CompositionEvent.initCompositionEvent', 125 'CompositionEvent.initCompositionEvent',
87 'CustomEvent.initCustomEvent', 126 'CustomEvent.initCustomEvent',
88 'DeviceOrientationEvent.initDeviceOrientationEvent', 127 'DeviceOrientationEvent.initDeviceOrientationEvent',
89 'Document.createElement', 128 'Document.createElement',
90 'Document.createElementNS', 129 'Document.createElementNS',
91 'Document.createEvent', 130 'Document.createEvent',
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 'DOMURL.revokeObjectURL': 'revokeObjectUrl', 267 'DOMURL.revokeObjectURL': 'revokeObjectUrl',
229 'DOMWindow.clearTimeout': '_clearTimeout', 268 'DOMWindow.clearTimeout': '_clearTimeout',
230 'DOMWindow.clearInterval': '_clearInterval', 269 'DOMWindow.clearInterval': '_clearInterval',
231 'DOMWindow.setTimeout': '_setTimeout', 270 'DOMWindow.setTimeout': '_setTimeout',
232 'DOMWindow.setInterval': '_setInterval', 271 'DOMWindow.setInterval': '_setInterval',
233 'DOMWindow.webkitConvertPointFromNodeToPage': 'convertPointFromNodeToPage', 272 'DOMWindow.webkitConvertPointFromNodeToPage': 'convertPointFromNodeToPage',
234 'DOMWindow.webkitConvertPointFromPageToNode': 'convertPointFromPageToNode', 273 'DOMWindow.webkitConvertPointFromPageToNode': 'convertPointFromPageToNode',
235 'DOMWindow.webkitNotifications': 'notifications', 274 'DOMWindow.webkitNotifications': 'notifications',
236 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem', 275 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem',
237 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl', 276 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
238 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem',
239 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
240 'Element.webkitCreateShadowRoot': 'createShadowRoot', 277 'Element.webkitCreateShadowRoot': 'createShadowRoot',
241 'Element.webkitMatchesSelector' : 'matches', 278 'Element.webkitMatchesSelector' : 'matches',
242 'Navigator.webkitGetUserMedia': '_getUserMedia', 279 'Navigator.webkitGetUserMedia': '_getUserMedia',
243 'Node.cloneNode': 'clone', 280 'Node.cloneNode': 'clone',
244 'Node.nextSibling': 'nextNode', 281 'Node.nextSibling': 'nextNode',
245 'Node.ownerDocument': 'document', 282 'Node.ownerDocument': 'document',
246 'Node.parentElement': 'parent', 283 'Node.parentElement': 'parent',
247 'Node.previousSibling': 'previousNode', 284 'Node.previousSibling': 'previousNode',
248 'Node.textContent': 'text', 285 'Node.textContent': 'text',
249 'SVGElement.className': '$dom_svgClassName', 286 'SVGElement.className': '$dom_svgClassName',
250 'WorkerContext.webkitRequestFileSystem': 'requestFileSystem', 287 'WorkerContext.webkitRequestFileSystem': 'requestFileSystem',
251 'WorkerContext.webkitRequestFileSystemSync': 'requestFileSystemSync', 288 'WorkerContext.webkitRequestFileSystemSync': 'requestFileSystemSync',
252 'WorkerContext.webkitResolveLocalFileSystemSyncURL': 289 'WorkerContext.webkitResolveLocalFileSystemSyncURL':
253 'resolveLocalFileSystemSyncUrl', 290 'resolveLocalFileSystemSyncUrl',
254 'WorkerContext.webkitResolveLocalFileSystemURL': 291 'WorkerContext.webkitResolveLocalFileSystemURL':
255 'resolveLocalFileSystemUrl', 292 'resolveLocalFileSystemUrl',
256 }) 293 })
257 294
295 for member in convert_to_future_members:
296 if member in renamed_html_members:
297 renamed_html_members[member] = '_' + renamed_html_members[member]
298 else:
299 renamed_html_members[member] = '_' + member[member.find('.') + 1 :]
300
258 # Members and classes from the dom that should be removed completely from 301 # Members and classes from the dom that should be removed completely from
259 # dart:html. These could be expressed in the IDL instead but expressing this 302 # dart:html. These could be expressed in the IDL instead but expressing this
260 # as a simple table instead is more concise. 303 # as a simple table instead is more concise.
261 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName 304 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName
262 # Using get: and set: is optional and should only be used when a getter needs 305 # Using get: and set: is optional and should only be used when a getter needs
263 # to be suppressed but not the setter, etc. 306 # to be suppressed but not the setter, etc.
264 # TODO(jacobr): cleanup and augment this list. 307 # TODO(jacobr): cleanup and augment this list.
265 _removed_html_members = monitored.Set('htmlrenamer._removed_html_members', [ 308 _removed_html_members = monitored.Set('htmlrenamer._removed_html_members', [
266 'Attr.*', 309 'Attr.*',
267 'CanvasRenderingContext2D.clearShadow', 310 'CanvasRenderingContext2D.clearShadow',
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 675
633 # We're looking for a sequence of letters which start with capital letter 676 # We're looking for a sequence of letters which start with capital letter
634 # then a series of caps and finishes with either the end of the string or 677 # then a series of caps and finishes with either the end of the string or
635 # a capital letter. 678 # a capital letter.
636 # The [0-9] check is for names such as 2D or 3D 679 # The [0-9] check is for names such as 2D or 3D
637 # The following test cases should match as: 680 # The following test cases should match as:
638 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 681 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
639 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 682 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
640 # IFrameElement: (I)()(F)rameElement (no change) 683 # IFrameElement: (I)()(F)rameElement (no change)
641 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 684 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name)
OLDNEW
« no previous file with comments | « tools/dom/scripts/htmldartgenerator.py ('k') | tools/dom/scripts/monitored.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698