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

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
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.openDatabase',
119 'WorkerContext.openDatabaseSync',
120 'WorkerContext.webkitRequestFileSystem',
121 'WorkerContext.webkitResolveLocalFileSystemURL',
122 ])
123
82 # Members from the standard dom that should not be exposed publicly in dart:html 124 # 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 125 # but need to be exposed internally to implement dart:html on top of a standard
84 # browser. 126 # browser.
85 _private_html_members = monitored.Set('htmlrenamer._private_html_members', [ 127 _private_html_members = monitored.Set('htmlrenamer._private_html_members', [
86 'CompositionEvent.initCompositionEvent', 128 'CompositionEvent.initCompositionEvent',
87 'CustomEvent.initCustomEvent', 129 'CustomEvent.initCustomEvent',
88 'DeviceOrientationEvent.initDeviceOrientationEvent', 130 'DeviceOrientationEvent.initDeviceOrientationEvent',
89 'Document.createElement', 131 'Document.createElement',
90 'Document.createElementNS', 132 'Document.createElementNS',
91 'Document.createEvent', 133 'Document.createEvent',
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 'DOMURL.revokeObjectURL': 'revokeObjectUrl', 270 'DOMURL.revokeObjectURL': 'revokeObjectUrl',
229 'DOMWindow.clearTimeout': '_clearTimeout', 271 'DOMWindow.clearTimeout': '_clearTimeout',
230 'DOMWindow.clearInterval': '_clearInterval', 272 'DOMWindow.clearInterval': '_clearInterval',
231 'DOMWindow.setTimeout': '_setTimeout', 273 'DOMWindow.setTimeout': '_setTimeout',
232 'DOMWindow.setInterval': '_setInterval', 274 'DOMWindow.setInterval': '_setInterval',
233 'DOMWindow.webkitConvertPointFromNodeToPage': 'convertPointFromNodeToPage', 275 'DOMWindow.webkitConvertPointFromNodeToPage': 'convertPointFromNodeToPage',
234 'DOMWindow.webkitConvertPointFromPageToNode': 'convertPointFromPageToNode', 276 'DOMWindow.webkitConvertPointFromPageToNode': 'convertPointFromPageToNode',
235 'DOMWindow.webkitNotifications': 'notifications', 277 'DOMWindow.webkitNotifications': 'notifications',
236 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem', 278 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem',
237 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl', 279 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
238 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem',
239 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
240 'Element.webkitCreateShadowRoot': 'createShadowRoot', 280 'Element.webkitCreateShadowRoot': 'createShadowRoot',
241 'Element.webkitMatchesSelector' : 'matches', 281 'Element.webkitMatchesSelector' : 'matches',
242 'Navigator.webkitGetUserMedia': '_getUserMedia', 282 'Navigator.webkitGetUserMedia': '_getUserMedia',
243 'Node.cloneNode': 'clone', 283 'Node.cloneNode': 'clone',
244 'Node.nextSibling': 'nextNode', 284 'Node.nextSibling': 'nextNode',
245 'Node.ownerDocument': 'document', 285 'Node.ownerDocument': 'document',
246 'Node.parentElement': 'parent', 286 'Node.parentElement': 'parent',
247 'Node.previousSibling': 'previousNode', 287 'Node.previousSibling': 'previousNode',
248 'Node.textContent': 'text', 288 'Node.textContent': 'text',
249 'SVGElement.className': '$dom_svgClassName', 289 'SVGElement.className': '$dom_svgClassName',
250 'WorkerContext.webkitRequestFileSystem': 'requestFileSystem', 290 'WorkerContext.webkitRequestFileSystem': 'requestFileSystem',
251 'WorkerContext.webkitRequestFileSystemSync': 'requestFileSystemSync', 291 'WorkerContext.webkitRequestFileSystemSync': 'requestFileSystemSync',
252 'WorkerContext.webkitResolveLocalFileSystemSyncURL': 292 'WorkerContext.webkitResolveLocalFileSystemSyncURL':
253 'resolveLocalFileSystemSyncUrl', 293 'resolveLocalFileSystemSyncUrl',
254 'WorkerContext.webkitResolveLocalFileSystemURL': 294 'WorkerContext.webkitResolveLocalFileSystemURL':
255 'resolveLocalFileSystemUrl', 295 'resolveLocalFileSystemUrl',
256 }) 296 })
257 297
298 for member in convert_to_future_members:
299 if member in renamed_html_members:
300 renamed_html_members[member] = '_' + renamed_html_members[member]
301 else:
302 renamed_html_members[member] = '_' + member[member.find('.') + 1 :]
303
258 # Members and classes from the dom that should be removed completely from 304 # 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 305 # dart:html. These could be expressed in the IDL instead but expressing this
260 # as a simple table instead is more concise. 306 # as a simple table instead is more concise.
261 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName 307 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName
262 # Using get: and set: is optional and should only be used when a getter needs 308 # Using get: and set: is optional and should only be used when a getter needs
263 # to be suppressed but not the setter, etc. 309 # to be suppressed but not the setter, etc.
264 # TODO(jacobr): cleanup and augment this list. 310 # TODO(jacobr): cleanup and augment this list.
265 _removed_html_members = monitored.Set('htmlrenamer._removed_html_members', [ 311 _removed_html_members = monitored.Set('htmlrenamer._removed_html_members', [
266 'Attr.*', 312 'Attr.*',
267 'CanvasRenderingContext2D.clearShadow', 313 'CanvasRenderingContext2D.clearShadow',
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 678
633 # We're looking for a sequence of letters which start with capital letter 679 # 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 680 # then a series of caps and finishes with either the end of the string or
635 # a capital letter. 681 # a capital letter.
636 # The [0-9] check is for names such as 2D or 3D 682 # The [0-9] check is for names such as 2D or 3D
637 # The following test cases should match as: 683 # The following test cases should match as:
638 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 684 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
639 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 685 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
640 # IFrameElement: (I)()(F)rameElement (no change) 686 # IFrameElement: (I)()(F)rameElement (no change)
641 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 687 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698