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

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

Issue 23055008: Making almost all dom_ methods private. Exceptions will be addressed in a later CL. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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/src/AttributeMap.dart » ('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 typed_array_renames = { 9 typed_array_renames = {
10 'ArrayBuffer': 'ByteBuffer', 10 'ArrayBuffer': 'ByteBuffer',
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 'FileEntry.file', 145 'FileEntry.file',
146 'Notification.requestPermission', 146 'Notification.requestPermission',
147 'NotificationCenter.requestPermission', 147 'NotificationCenter.requestPermission',
148 'RTCPeerConnection.setLocalDescription', 148 'RTCPeerConnection.setLocalDescription',
149 'RTCPeerConnection.setRemoteDescription', 149 'RTCPeerConnection.setRemoteDescription',
150 'StorageInfo.requestQuota', 150 'StorageInfo.requestQuota',
151 'WorkerGlobalScope.webkitResolveLocalFileSystemURL', 151 'WorkerGlobalScope.webkitResolveLocalFileSystemURL',
152 'WorkerGlobalScope.webkitRequestFileSystem', 152 'WorkerGlobalScope.webkitRequestFileSystem',
153 ]) 153 ])
154 154
155 # "Private" members in the form $dom_foo.
156 # TODO(efortuna): Remove this set. This allows us to make the change of removing
157 # $dom in installments instead of all at once, but the intent is to move all of
158 # these either into private_html_members or remove them from this list entirely.
159 dom_private_html_members = monitored.Set('htmlrenamer.private_html_members', [
160 'Document.createElement',
161 'Document.createElementNS',
162 'Document.createRange',
163 'Element.getAttribute',
164 'Element.getAttributeNS',
165 'Element.setAttribute',
166 'Element.setAttributeNS',
167 'EventTarget.addEventListener',
168 'EventTarget.removeEventListener',
169 'Node.childNodes',
170 ])
171
155 # Members from the standard dom that should not be exposed publicly in dart:html 172 # Members from the standard dom that should not be exposed publicly in dart:html
156 # but need to be exposed internally to implement dart:html on top of a standard 173 # but need to be exposed internally to implement dart:html on top of a standard
157 # browser. 174 # browser. They are exposed simply by placing an underscore in front of the
175 # name.
158 private_html_members = monitored.Set('htmlrenamer.private_html_members', [ 176 private_html_members = monitored.Set('htmlrenamer.private_html_members', [
159 'AudioNode.connect', 177 'AudioNode.connect',
160 'CanvasRenderingContext2D.arc', 178 'CanvasRenderingContext2D.arc',
179 'CanvasRenderingContext2D.drawImage',
161 'CompositionEvent.initCompositionEvent', 180 'CompositionEvent.initCompositionEvent',
162 'CustomEvent.initCustomEvent', 181 'CustomEvent.initCustomEvent',
182 'CSSStyleDeclaration.getPropertyValue',
183 'CSSStyleDeclaration.setProperty',
184 'CSSStyleDeclaration.var',
163 'DeviceOrientationEvent.initDeviceOrientationEvent', 185 'DeviceOrientationEvent.initDeviceOrientationEvent',
164 'Document.createElement',
165 'Document.createElementNS',
166 'Document.createEvent', 186 'Document.createEvent',
167 'Document.createNodeIterator', 187 'Document.createNodeIterator',
168 'Document.createRange',
169 'Document.createTextNode', 188 'Document.createTextNode',
170 'Document.createTouch', 189 'Document.createTouch',
171 'Document.createTouchList', 190 'Document.createTouchList',
172 'Document.createTreeWalker', 191 'Document.createTreeWalker',
173 'Document.querySelectorAll', 192 'Document.querySelectorAll',
193 'DocumentFragment.querySelector',
194 'DocumentFragment.querySelectorAll',
174 195
175 # Moved to HTMLDocument. 196 # Moved to HTMLDocument.
176 'Document.body', 197 'Document.body',
177 'Document.caretRangeFromPoint', 198 'Document.caretRangeFromPoint',
178 'Document.elementFromPoint', 199 'Document.elementFromPoint',
179 'Document.getCSSCanvasContext', 200 'Document.getCSSCanvasContext',
180 'Document.head', 201 'Document.head',
181 'Document.lastModified', 202 'Document.lastModified',
182 'Document.preferredStylesheetSet', 203 'Document.preferredStylesheetSet',
183 'Document.referrer', 204 'Document.referrer',
184 'Document.selectedStylesheetSet', 205 'Document.selectedStylesheetSet',
185 'Document.styleSheets', 206 'Document.styleSheets',
186 'Document.title', 207 'Document.title',
187 'Document.webkitCancelFullScreen', 208 'Document.webkitCancelFullScreen',
188 'Document.webkitExitFullscreen', 209 'Document.webkitExitFullscreen',
189 'Document.webkitExitPointerLock', 210 'Document.webkitExitPointerLock',
190 'Document.webkitFullscreenElement', 211 'Document.webkitFullscreenElement',
191 'Document.webkitFullscreenEnabled', 212 'Document.webkitFullscreenEnabled',
192 'Document.webkitHidden', 213 'Document.webkitHidden',
193 'Document.webkitIsFullScreen', 214 'Document.webkitIsFullScreen',
194 'Document.webkitPointerLockElement', 215 'Document.webkitPointerLockElement',
195 'Document.webkitVisibilityState', 216 'Document.webkitVisibilityState',
196 217
197 'DocumentFragment.querySelector', 218 'Element.children',
198 'DocumentFragment.querySelectorAll',
199 'Element.childElementCount', 219 'Element.childElementCount',
200 'Element.children',
201 'Element.firstElementChild', 220 'Element.firstElementChild',
202 'ParentNode.childElementCount',
203 'ParentNode.children',
204 'ParentNode.firstElementChild',
205 'Element.getAttribute',
206 'Element.getAttributeNS',
207 'Element.getElementsByTagName', 221 'Element.getElementsByTagName',
222 'Element.scrollIntoView',
223 'Element.scrollIntoViewIfNeeded',
224 'Element.removeAttribute',
225 'Element.removeAttributeNS',
208 'Element.hasAttribute', 226 'Element.hasAttribute',
209 'Element.hasAttributeNS', 227 'Element.hasAttributeNS',
210 'ParentNode.lastElementChild',
211 'Element.querySelectorAll', 228 'Element.querySelectorAll',
212 'Element.removeAttribute',
213 'Element.removeAttributeNS',
214 'Element.scrollIntoView',
215 'Element.scrollIntoViewIfNeeded',
216 'Element.setAttributeNS',
217 'Element.setAttribute',
218 'Element.setAttributeNS',
219 'Event.initEvent', 229 'Event.initEvent',
220 'EventTarget.addEventListener',
221 'EventTarget.removeEventListener',
222 'Geolocation.clearWatch', 230 'Geolocation.clearWatch',
223 'Geolocation.getCurrentPosition', 231 'Geolocation.getCurrentPosition',
224 'Geolocation.watchPosition', 232 'Geolocation.watchPosition',
225 'HashChangeEvent.initHashChangeEvent', 233 'HashChangeEvent.initHashChangeEvent',
226 'HTMLCanvasElement.toDataURL', 234 'HTMLCanvasElement.toDataURL',
227 'HTMLTableElement.createCaption', 235 'HTMLTableElement.createCaption',
228 'HTMLTableElement.createTBody',
229 'HTMLTableElement.createTFoot', 236 'HTMLTableElement.createTFoot',
230 'HTMLTableElement.createTHead', 237 'HTMLTableElement.createTHead',
238 'HTMLTableElement.createTBody',
231 'HTMLTableElement.insertRow', 239 'HTMLTableElement.insertRow',
232 'HTMLTableElement.rows', 240 'HTMLTableElement.rows',
233 'HTMLTableElement.tBodies', 241 'HTMLTableElement.tBodies',
234 'HTMLTableRowElement.cells', 242 'HTMLTableRowElement.cells',
235 'HTMLTableRowElement.insertCell', 243 'HTMLTableRowElement.insertCell',
236 'HTMLTableSectionElement.insertRow', 244 'HTMLTableSectionElement.insertRow',
237 'HTMLTableSectionElement.rows', 245 'HTMLTableSectionElement.rows',
238 'HTMLTemplateElement.content', 246 'HTMLTemplateElement.content',
239 'IDBCursor.delete', 247 'IDBCursor.delete',
240 'IDBCursor.update', 248 'IDBCursor.update',
(...skipping 20 matching lines...) Expand all
261 'MouseEvent.initMouseEvent', 269 'MouseEvent.initMouseEvent',
262 'MouseEvent.clientX', 270 'MouseEvent.clientX',
263 'MouseEvent.clientY', 271 'MouseEvent.clientY',
264 'MouseEvent.webkitMovementX', 272 'MouseEvent.webkitMovementX',
265 'MouseEvent.webkitMovementY', 273 'MouseEvent.webkitMovementY',
266 'MouseEvent.offsetX', 274 'MouseEvent.offsetX',
267 'MouseEvent.offsetY', 275 'MouseEvent.offsetY',
268 'MouseEvent.screenX', 276 'MouseEvent.screenX',
269 'MouseEvent.screenY', 277 'MouseEvent.screenY',
270 'MutationEvent.initMutationEvent', 278 'MutationEvent.initMutationEvent',
279 'MutationObserver.observe',
271 'Node.attributes', 280 'Node.attributes',
272 'Node.childNodes',
273 'Node.localName', 281 'Node.localName',
274 'Node.namespaceURI', 282 'Node.namespaceURI',
275 'Node.removeChild', 283 'Node.removeChild',
276 'Node.replaceChild', 284 'Node.replaceChild',
285 'ParentNode.childElementCount',
286 'ParentNode.children',
287 'ParentNode.firstElementChild',
288 'ParentNode.lastElementChild',
289 'RTCPeerConnection.createAnswer',
290 'RTCPeerConnection.createOffer',
277 'Screen.availHeight', 291 'Screen.availHeight',
278 'Screen.availLeft', 292 'Screen.availLeft',
279 'Screen.availTop', 293 'Screen.availTop',
280 'Screen.availWidth', 294 'Screen.availWidth',
281 'Storage.clear', 295 'Storage.clear',
282 'Storage.getItem', 296 'Storage.getItem',
283 'Storage.key', 297 'Storage.key',
284 'Storage.length', 298 'Storage.length',
285 'Storage.removeItem', 299 'Storage.removeItem',
286 'Storage.setItem', 300 'Storage.setItem',
287 'StorageEvent.initStorageEvent', 301 'StorageEvent.initStorageEvent',
302 'StorageInfo.queryUsageAndQuota',
288 'TextEvent.initTextEvent', 303 'TextEvent.initTextEvent',
289 'Touch.clientX', 304 'Touch.clientX',
290 'Touch.clientY', 305 'Touch.clientY',
291 'Touch.pageX', 306 'Touch.pageX',
292 'Touch.pageY', 307 'Touch.pageY',
293 'Touch.screenX', 308 'Touch.screenX',
294 'Touch.screenY', 309 'Touch.screenY',
295 'TouchEvent.initTouchEvent', 310 'TouchEvent.initTouchEvent',
296 'UIEvent.charCode', 311 'UIEvent.charCode',
297 'UIEvent.initUIEvent', 312 'UIEvent.initUIEvent',
298 'UIEvent.keyCode', 313 'UIEvent.keyCode',
299 'UIEvent.layerX', 314 'UIEvent.layerX',
300 'UIEvent.layerY', 315 'UIEvent.layerY',
301 'UIEvent.pageX', 316 'UIEvent.pageX',
302 'UIEvent.pageY', 317 'UIEvent.pageY',
318 'WebGLRenderingContext.texImage2D',
303 'WheelEvent.initWebKitWheelEvent', 319 'WheelEvent.initWebKitWheelEvent',
320 'WheelEvent.wheelDeltaX',
321 'WheelEvent.wheelDeltaY',
322 'Window.createImageBitmap',
304 'Window.getComputedStyle', 323 'Window.getComputedStyle',
305 'Window.moveTo', 324 'Window.moveTo',
325 'Window.clearTimeout',
326 'Window.clearInterval',
327 'Window.setTimeout',
328 'Window.setInterval',
306 ]) 329 ])
307 330
308 # Members from the standard dom that exist in the dart:html library with 331 # Members from the standard dom that exist in the dart:html library with
309 # identical functionality but with cleaner names. 332 # identical functionality but with cleaner names.
310 renamed_html_members = monitored.Dict('htmlrenamer.renamed_html_members', { 333 renamed_html_members = monitored.Dict('htmlrenamer.renamed_html_members', {
311 'CanvasRenderingContext2D.drawImage': '_drawImage',
312 'WebKitCSSKeyframesRule.insertRule': 'appendRule', 334 'WebKitCSSKeyframesRule.insertRule': 'appendRule',
313 'CSSStyleDeclaration.getPropertyValue': '_getPropertyValue',
314 'CSSStyleDeclaration.setProperty': '_setProperty',
315 'CSSStyleDeclaration.var': '_var',
316 'DirectoryEntry.getDirectory': '_getDirectory', 335 'DirectoryEntry.getDirectory': '_getDirectory',
317 'DirectoryEntry.getFile': '_getFile', 336 'DirectoryEntry.getFile': '_getFile',
318 'Document.createCDATASection': 'createCDataSection', 337 'Document.createCDATASection': 'createCDataSection',
319 'Document.defaultView': 'window', 338 'Document.defaultView': 'window',
320 'Document.querySelector': 'query', 339 'Document.querySelector': 'query',
321 'Window.CSS': 'css', 340 'Window.CSS': 'css',
322 'Window.clearTimeout': '_clearTimeout',
323 'Window.clearInterval': '_clearInterval',
324 'Window.setTimeout': '_setTimeout',
325 'Window.setInterval': '_setInterval',
326 'Window.webkitConvertPointFromNodeToPage': '_convertPointFromNodeToPage', 341 'Window.webkitConvertPointFromNodeToPage': '_convertPointFromNodeToPage',
327 'Window.webkitConvertPointFromPageToNode': '_convertPointFromPageToNode', 342 'Window.webkitConvertPointFromPageToNode': '_convertPointFromPageToNode',
328 'Window.webkitNotifications': 'notifications', 343 'Window.webkitNotifications': 'notifications',
329 'Window.webkitRequestFileSystem': '_requestFileSystem', 344 'Window.webkitRequestFileSystem': '_requestFileSystem',
330 'Window.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl', 345 'Window.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
331 'Element.querySelector': 'query', 346 'Element.querySelector': 'query',
332 'Element.webkitMatchesSelector' : 'matches', 347 'Element.webkitMatchesSelector' : 'matches',
333 'MutationObserver.observe': '_observe',
334 'Navigator.webkitGetUserMedia': '_getUserMedia', 348 'Navigator.webkitGetUserMedia': '_getUserMedia',
335 'Node.appendChild': 'append', 349 'Node.appendChild': 'append',
336 'Node.cloneNode': 'clone', 350 'Node.cloneNode': 'clone',
337 'Node.nextSibling': 'nextNode', 351 'Node.nextSibling': 'nextNode',
338 'Node.ownerDocument': 'document', 352 'Node.ownerDocument': 'document',
339 'Node.parentElement': 'parent', 353 'Node.parentElement': 'parent',
340 'Node.previousSibling': 'previousNode', 354 'Node.previousSibling': 'previousNode',
341 'Node.textContent': 'text', 355 'Node.textContent': 'text',
342 'RTCPeerConnection.createAnswer': '_createAnswer', 356 'SVGElement.className': '_svgClassName',
343 'RTCPeerConnection.createOffer': '_createOffer',
344 'StorageInfo.queryUsageAndQuota': '_queryUsageAndQuota',
345 'SVGElement.className': '$dom_svgClassName',
346 'SVGStopElement.offset': 'gradientOffset', 357 'SVGStopElement.offset': 'gradientOffset',
347 'URL.createObjectURL': 'createObjectUrl', 358 'URL.createObjectURL': 'createObjectUrl',
348 'URL.revokeObjectURL': 'revokeObjectUrl', 359 'URL.revokeObjectURL': 'revokeObjectUrl',
349 'WebGLRenderingContext.texImage2D': '_texImage2D',
350 'WebGLRenderingContext.texSubImage2D': '_texSubImageImage2D', 360 'WebGLRenderingContext.texSubImage2D': '_texSubImageImage2D',
351 'WheelEvent.wheelDeltaX': '_wheelDeltaX',
352 'WheelEvent.wheelDeltaY': '_wheelDeltaY',
353 'Window.createImageBitmap': '_createImageBitmap',
354 #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem', 361 #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem',
355 #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync', 362 #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync',
356 }) 363 })
357 364
358 # Members that have multiple definitions, but their types are vary, so we rename 365 # Members that have multiple definitions, but their types are vary, so we rename
359 # them to make them distinct. 366 # them to make them distinct.
360 renamed_overloads = monitored.Dict('htmldartgenreator.renamed_overloads', { 367 renamed_overloads = monitored.Dict('htmldartgenreator.renamed_overloads', {
361 'AudioContext.createBuffer(ArrayBuffer buffer, boolean mixToMono)': 368 'AudioContext.createBuffer(ArrayBuffer buffer, boolean mixToMono)':
362 'createBufferFromBuffer', 369 'createBufferFromBuffer',
363 'CSS.supports(DOMString conditionText)': 'supportsCondition', 370 'CSS.supports(DOMString conditionText)': 'supportsCondition',
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 return None 790 return None
784 791
785 if 'CheckSecurityForNode' in member_node.ext_attrs: 792 if 'CheckSecurityForNode' in member_node.ext_attrs:
786 return None 793 return None
787 794
788 name = self._FindMatch(interface, member, member_prefix, 795 name = self._FindMatch(interface, member, member_prefix,
789 renamed_html_members) 796 renamed_html_members)
790 797
791 target_name = renamed_html_members[name] if name else member 798 target_name = renamed_html_members[name] if name else member
792 if self._FindMatch(interface, member, member_prefix, private_html_members): 799 if self._FindMatch(interface, member, member_prefix, private_html_members):
800 if not target_name.startswith('_'): # e.g. _svgClassName
801 target_name = '_' + target_name
802 elif self._FindMatch(interface, member, member_prefix,
803 dom_private_html_members):
793 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName 804 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName
794 target_name = '$dom_' + target_name 805 target_name = '$dom_' + target_name
795 806
796 if not name and target_name.startswith('webkit'): 807 if not name and target_name.startswith('webkit'):
797 target_name = member[len('webkit'):] 808 target_name = member[len('webkit'):]
798 target_name = target_name[:1].lower() + target_name[1:] 809 target_name = target_name[:1].lower() + target_name[1:]
799 810
800 if dartify_name: 811 if dartify_name:
801 target_name = self._DartifyMemberName(target_name) 812 target_name = self._DartifyMemberName(target_name)
802 return target_name 813 return target_name
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 896
886 # We're looking for a sequence of letters which start with capital letter 897 # We're looking for a sequence of letters which start with capital letter
887 # then a series of caps and finishes with either the end of the string or 898 # then a series of caps and finishes with either the end of the string or
888 # a capital letter. 899 # a capital letter.
889 # The [0-9] check is for names such as 2D or 3D 900 # The [0-9] check is for names such as 2D or 3D
890 # The following test cases should match as: 901 # The following test cases should match as:
891 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 902 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
892 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 903 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
893 # IFrameElement: (I)()(F)rameElement (no change) 904 # IFrameElement: (I)()(F)rameElement (no change)
894 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 905 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/src/AttributeMap.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698