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

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

Issue 12543014: Reapply Futureification. (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',
28 'Rect': 'CssRect', 35 'Rect': 'CssRect',
29 'RGBColor': 'CssRgbColor', 36 'RGBColor': 'CssRgbColor',
37 'RTCErrorCallback': '_RtcErrorCallback',
38 'RTCSessionDescriptionCallback': '_RtcSessionDescriptionCallback',
39 'StorageInfoErrorCallback': '_StorageInfoErrorCallback',
40 'StorageInfoUsageCallback': '_StorageInfoUsageCallback',
41 'StringCallback': '_StringCallback',
30 'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts. 42 'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts.
31 'SVGElement': 'SvgElement', # Manual to avoid name conflicts. 43 'SVGElement': 'SvgElement', # Manual to avoid name conflicts.
32 'SVGException': 'SvgException', # Manual of avoid conflict with Exception. 44 'SVGException': 'SvgException', # Manual of avoid conflict with Exception.
33 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts. 45 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts.
34 'WebGLVertexArrayObjectOES': 'WebGLVertexArrayObject', 46 'WebGLVertexArrayObjectOES': 'WebGLVertexArrayObject',
35 'WebKitAnimationEvent': 'AnimationEvent', 47 'WebKitAnimationEvent': 'AnimationEvent',
36 'WebKitCSSKeyframeRule': 'CssKeyframeRule', 48 'WebKitCSSKeyframeRule': 'CssKeyframeRule',
37 'WebKitCSSKeyframesRule': 'CssKeyframesRule', 49 'WebKitCSSKeyframesRule': 'CssKeyframesRule',
38 'WebKitCSSMatrix': 'CssMatrix', 50 'WebKitCSSMatrix': 'CssMatrix',
39 'WebKitCSSTransformValue': 'CssTransformValue', 51 'WebKitCSSTransformValue': 'CssTransformValue',
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 'SVGHKernElement', 86 'SVGHKernElement',
75 'SVGMissingGlyphElement', 87 'SVGMissingGlyphElement',
76 'SVGMPathElement', 88 'SVGMPathElement',
77 'SVGTRefElement', 89 'SVGTRefElement',
78 'SVGVKernElement', 90 'SVGVKernElement',
79 ] 91 ]
80 92
81 for interface in _removed_html_interfaces: 93 for interface in _removed_html_interfaces:
82 html_interface_renames[interface] = '_' + interface 94 html_interface_renames[interface] = '_' + interface
83 95
96 convert_to_future_members = monitored.Set(
97 'htmlrenamer.converted_to_future_members', [
98 'DataTransferItem.getAsString',
99 'DirectoryEntry.getDirectory',
100 'DirectoryEntry.getFile',
101 'DirectoryEntry.removeRecursively',
102 'DirectoryReader.readEntries',
103 'DOMWindow.webkitRequestFileSystem',
104 'DOMWindow.webkitResolveLocalFileSystemURL',
105 'Entry.copyTo',
106 'Entry.getMetadata',
107 'Entry.getParent',
108 'Entry.moveTo',
109 'Entry.remove',
110 'FileEntry.createWriter',
111 'FileEntry.file',
112 'Notification.requestPermission',
113 'NotificationCenter.requestPermission',
114 'RTCPeerConnection.createAnswer',
115 'RTCPeerConnection.createOffer',
116 'RTCPeerConnection.setLocalDescription',
117 'RTCPeerConnection.setRemoteDescription',
118 'StorageInfo.queryUsageAndQuota',
119 'StorageInfo.requestQuota',
120 'WorkerContext.webkitResolveLocalFileSystemURL',
121 ])
122
84 # Members from the standard dom that should not be exposed publicly in dart:html 123 # Members from the standard dom that should not be exposed publicly in dart:html
85 # but need to be exposed internally to implement dart:html on top of a standard 124 # but need to be exposed internally to implement dart:html on top of a standard
86 # browser. 125 # browser.
87 _private_html_members = monitored.Set('htmlrenamer._private_html_members', [ 126 _private_html_members = monitored.Set('htmlrenamer._private_html_members', [
88 'CompositionEvent.initCompositionEvent', 127 'CompositionEvent.initCompositionEvent',
89 'CustomEvent.initCustomEvent', 128 'CustomEvent.initCustomEvent',
90 'DeviceOrientationEvent.initDeviceOrientationEvent', 129 'DeviceOrientationEvent.initDeviceOrientationEvent',
91 'Document.createElement', 130 'Document.createElement',
92 'Document.createElementNS', 131 'Document.createElementNS',
93 'Document.createEvent', 132 'Document.createEvent',
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 'DOMURL.revokeObjectURL': 'revokeObjectUrl', 269 'DOMURL.revokeObjectURL': 'revokeObjectUrl',
231 'DOMWindow.clearTimeout': '_clearTimeout', 270 'DOMWindow.clearTimeout': '_clearTimeout',
232 'DOMWindow.clearInterval': '_clearInterval', 271 'DOMWindow.clearInterval': '_clearInterval',
233 'DOMWindow.setTimeout': '_setTimeout', 272 'DOMWindow.setTimeout': '_setTimeout',
234 'DOMWindow.setInterval': '_setInterval', 273 'DOMWindow.setInterval': '_setInterval',
235 'DOMWindow.webkitConvertPointFromNodeToPage': 'convertPointFromNodeToPage', 274 'DOMWindow.webkitConvertPointFromNodeToPage': 'convertPointFromNodeToPage',
236 'DOMWindow.webkitConvertPointFromPageToNode': 'convertPointFromPageToNode', 275 'DOMWindow.webkitConvertPointFromPageToNode': 'convertPointFromPageToNode',
237 'DOMWindow.webkitNotifications': 'notifications', 276 'DOMWindow.webkitNotifications': 'notifications',
238 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem', 277 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem',
239 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl', 278 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
240 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem',
241 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
242 'Element.webkitCreateShadowRoot': 'createShadowRoot', 279 'Element.webkitCreateShadowRoot': 'createShadowRoot',
243 'Element.webkitMatchesSelector' : 'matches', 280 'Element.webkitMatchesSelector' : 'matches',
244 'Navigator.webkitGetUserMedia': '_getUserMedia', 281 'Navigator.webkitGetUserMedia': '_getUserMedia',
245 'Node.cloneNode': 'clone', 282 'Node.cloneNode': 'clone',
246 'Node.nextSibling': 'nextNode', 283 'Node.nextSibling': 'nextNode',
247 'Node.ownerDocument': 'document', 284 'Node.ownerDocument': 'document',
248 'Node.parentElement': 'parent', 285 'Node.parentElement': 'parent',
249 'Node.previousSibling': 'previousNode', 286 'Node.previousSibling': 'previousNode',
250 'Node.textContent': 'text', 287 'Node.textContent': 'text',
251 'SVGElement.className': '$dom_svgClassName', 288 'SVGElement.className': '$dom_svgClassName',
252 'WorkerContext.webkitRequestFileSystem': 'requestFileSystem', 289 'WorkerContext.webkitRequestFileSystem': 'requestFileSystem',
253 'WorkerContext.webkitRequestFileSystemSync': 'requestFileSystemSync', 290 'WorkerContext.webkitRequestFileSystemSync': 'requestFileSystemSync',
254 'WorkerContext.webkitResolveLocalFileSystemSyncURL': 291 'WorkerContext.webkitResolveLocalFileSystemSyncURL':
255 'resolveLocalFileSystemSyncUrl', 292 'resolveLocalFileSystemSyncUrl',
256 'WorkerContext.webkitResolveLocalFileSystemURL': 293 'WorkerContext.webkitResolveLocalFileSystemURL':
257 'resolveLocalFileSystemUrl', 294 'resolveLocalFileSystemUrl',
258 }) 295 })
259 296
297 for member in convert_to_future_members:
298 if member in renamed_html_members:
299 renamed_html_members[member] = '_' + renamed_html_members[member]
300 else:
301 renamed_html_members[member] = '_' + member[member.find('.') + 1 :]
302
260 # Members and classes from the dom that should be removed completely from 303 # Members and classes from the dom that should be removed completely from
261 # dart:html. These could be expressed in the IDL instead but expressing this 304 # dart:html. These could be expressed in the IDL instead but expressing this
262 # as a simple table instead is more concise. 305 # as a simple table instead is more concise.
263 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName 306 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName
264 # Using get: and set: is optional and should only be used when a getter needs 307 # Using get: and set: is optional and should only be used when a getter needs
265 # to be suppressed but not the setter, etc. 308 # to be suppressed but not the setter, etc.
266 # TODO(jacobr): cleanup and augment this list. 309 # TODO(jacobr): cleanup and augment this list.
267 _removed_html_members = monitored.Set('htmlrenamer._removed_html_members', [ 310 _removed_html_members = monitored.Set('htmlrenamer._removed_html_members', [
268 'Attr.*', 311 'Attr.*',
269 'CanvasRenderingContext2D.clearShadow', 312 'CanvasRenderingContext2D.clearShadow',
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 677
635 # We're looking for a sequence of letters which start with capital letter 678 # We're looking for a sequence of letters which start with capital letter
636 # then a series of caps and finishes with either the end of the string or 679 # then a series of caps and finishes with either the end of the string or
637 # a capital letter. 680 # a capital letter.
638 # The [0-9] check is for names such as 2D or 3D 681 # The [0-9] check is for names such as 2D or 3D
639 # The following test cases should match as: 682 # The following test cases should match as:
640 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 683 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
641 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 684 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
642 # IFrameElement: (I)()(F)rameElement (no change) 685 # IFrameElement: (I)()(F)rameElement (no change)
643 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 686 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