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