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

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

Issue 18277003: "Reverting 24655" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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/logging.conf » ('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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 'RTCPeerConnection.setLocalDescription', 144 'RTCPeerConnection.setLocalDescription',
145 'RTCPeerConnection.setRemoteDescription', 145 'RTCPeerConnection.setRemoteDescription',
146 'StorageInfo.requestQuota', 146 'StorageInfo.requestQuota',
147 'WorkerContext.webkitResolveLocalFileSystemURL', 147 'WorkerContext.webkitResolveLocalFileSystemURL',
148 'WorkerContext.webkitRequestFileSystem', 148 'WorkerContext.webkitRequestFileSystem',
149 ]) 149 ])
150 150
151 # Members from the standard dom that should not be exposed publicly in dart:html 151 # Members from the standard dom that should not be exposed publicly in dart:html
152 # but need to be exposed internally to implement dart:html on top of a standard 152 # but need to be exposed internally to implement dart:html on top of a standard
153 # browser. 153 # browser.
154 private_html_members = monitored.Set('htmlrenamer.private_html_members', [ 154 _private_html_members = monitored.Set('htmlrenamer._private_html_members', [
155 'AudioNode.connect',
156 'CanvasRenderingContext2D.arc', 155 'CanvasRenderingContext2D.arc',
157 'CompositionEvent.initCompositionEvent', 156 'CompositionEvent.initCompositionEvent',
158 'CustomEvent.initCustomEvent', 157 'CustomEvent.initCustomEvent',
159 'DeviceOrientationEvent.initDeviceOrientationEvent', 158 'DeviceOrientationEvent.initDeviceOrientationEvent',
160 'Document.createElement', 159 'Document.createElement',
161 'Document.createElementNS', 160 'Document.createElementNS',
162 'Document.createEvent', 161 'Document.createEvent',
163 'Document.createNodeIterator', 162 'Document.createNodeIterator',
164 'Document.createRange', 163 'Document.createRange',
165 'Document.createTextNode', 164 'Document.createTextNode',
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 'SVGElement.className': '$dom_svgClassName', 339 'SVGElement.className': '$dom_svgClassName',
341 'SVGStopElement.offset': 'gradientOffset', 340 'SVGStopElement.offset': 'gradientOffset',
342 'URL.createObjectURL': 'createObjectUrl', 341 'URL.createObjectURL': 'createObjectUrl',
343 'URL.revokeObjectURL': 'revokeObjectUrl', 342 'URL.revokeObjectURL': 'revokeObjectUrl',
344 'WheelEvent.wheelDeltaX': '_wheelDeltaX', 343 'WheelEvent.wheelDeltaX': '_wheelDeltaX',
345 'WheelEvent.wheelDeltaY': '_wheelDeltaY', 344 'WheelEvent.wheelDeltaY': '_wheelDeltaY',
346 #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem', 345 #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem',
347 #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync', 346 #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync',
348 }) 347 })
349 348
350 # Members that have multiple definitions, but their types are vary, so we rename
351 # them to make them distinct.
352 renamed_overloads = monitored.Dict('htmldartgenreator.renamed_overloads', {
353 'AudioContext.createBuffer(ArrayBuffer buffer, boolean mixToMono)':
354 'createBufferFromBuffer',
355 'CSS.supports(DOMString conditionText)': 'supportsCondition',
356 'CanvasRenderingContext2D.createPattern(HTMLImageElement image, '
357 'DOMString repetitionType)': 'createPatternFromImage',
358 'DataTransferItemList.add(File file)': 'addFile',
359 'DataTransferItemList.add(DOMString data, DOMString type)': 'addData',
360 'FormData.append(DOMString name, Blob value, DOMString filename)':
361 'appendBlob',
362 'IDBDatabase.transaction(DOMStringList storeNames, DOMString mode)':
363 'transactionStores',
364 'IDBDatabase.transaction(sequence<DOMString> storeNames, DOMString mode)':
365 'transactionList',
366 'IDBDatabase.transaction(DOMString storeName, DOMString mode)':
367 'transactionStore',
368 'RTCDataChannel.send(ArrayBuffer data)': 'sendByteBuffer',
369 'RTCDataChannel.send(ArrayBufferView data)': 'sendTypedData',
370 'RTCDataChannel.send(Blob data)': 'sendBlob',
371 'RTCDataChannel.send(DOMString data)': 'sendString',
372 'URL.createObjectURL(WebKitMediaSource source)':
373 'createObjectUrlFromSource',
374 'URL.createObjectURL(MediaStream stream)': 'createObjectUrlFromStream',
375 'URL.createObjectURL(Blob blob)': 'createObjectUrlFromBlob',
376 'WebGLRenderingContext.texImage2D(unsigned long target, long level, '
377 'unsigned long internalformat, long width, long height, long border, '
378 'unsigned long format, unsigned long type, ArrayBufferView pixels)':
379 'texImage2DTypedData',
380 'WebGLRenderingContext.texImage2D(unsigned long target, long level, '
381 'unsigned long internalformat, unsigned long format, unsigned long '
382 'type, HTMLImageElement image)': 'texImage2DImage',
383 'WebGLRenderingContext.texImage2D(unsigned long target, long level, '
384 'unsigned long internalformat, unsigned long format, unsigned long '
385 'type, HTMLCanvasElement canvas)': 'texImage2DCanvas',
386 'WebGLRenderingContext.texImage2D(unsigned long target, long level, '
387 'unsigned long internalformat, unsigned long format, unsigned long '
388 'type, HTMLVideoElement video)': 'texImage2DVideo',
389 'WebGLRenderingContext.texSubImage2D(unsigned long target, long level, '
390 'long xoffset, long yoffset, long width, long height, unsigned long '
391 'format, unsigned long type, ArrayBufferView pixels)':
392 'texSubImage2DTypedData',
393 'WebGLRenderingContext.texSubImage2D(unsigned long target, long level, '
394 'long xoffset, long yoffset, unsigned long format, unsigned long type, '
395 'HTMLImageElement image)': 'texSubImage2DImage',
396 'WebGLRenderingContext.texSubImage2D(unsigned long target, long level, '
397 'long xoffset, long yoffset, unsigned long format, unsigned long type, '
398 'HTMLCanvasElement canvas)': 'texSubImage2DCanvas',
399 'WebGLRenderingContext.texSubImage2D(unsigned long target, long level, '
400 'long xoffset, long yoffset, unsigned long format, unsigned long type, '
401 'HTMLVideoElement video)': 'texSubImage2DVideo',
402 'WebGLRenderingContext.bufferData(unsigned long target, ArrayBuffer data, '
403 'unsigned long usage)': 'bufferByteData',
404 'WebGLRenderingContext.bufferData(unsigned long target, '
405 'ArrayBufferView data, unsigned long usage)': 'bufferTypedData',
406 'WebGLRenderingContext.bufferSubData(unsigned long target, '
407 'long long offset, ArrayBuffer data)': 'bufferSubByteData',
408 'WebGLRenderingContext.bufferSubData(unsigned long target, '
409 'long long offset, ArrayBufferView data)': 'bufferSubTypedData',
410 'WebSocket.send(ArrayBuffer data)': 'sendByteBuffer',
411 'WebSocket.send(ArrayBufferView data)': 'sendTypeData',
412 'WebSocket.send(DOMString data)': 'sendString',
413 'WebSocket.send(Blob data)': 'sendBlob'
414 })
415
416 # Members that have multiple definitions, but their types are identical (only
417 # number of arguments vary), so we do not rename them as a _raw method.
418 keep_overloaded_members = monitored.Set(
419 'htmldartgenerator.keep_overloaded_members', [
420 'AudioBufferSourceNode.start',
421 'CanvasRenderingContext2D.putImageData',
422 'CanvasRenderingContext2D.webkitPutImageDataHD',
423 'DataTransferItemList.add',
424 'HTMLInputElement.setRangeText',
425 'HTMLTextAreaElement.setRangeText',
426 'IDBDatabase.transaction',
427 'RTCDataChannel.send',
428 'URL.createObjectURL',
429 'WebSocket.send',
430 'XMLHttpRequest.send'
431 ])
432
433 for member in convert_to_future_members: 349 for member in convert_to_future_members:
434 if member in renamed_html_members: 350 if member in renamed_html_members:
435 renamed_html_members[member] = '_' + renamed_html_members[member] 351 renamed_html_members[member] = '_' + renamed_html_members[member]
436 else: 352 else:
437 renamed_html_members[member] = '_' + member[member.find('.') + 1 :] 353 renamed_html_members[member] = '_' + member[member.find('.') + 1 :]
438 354
439 # Members and classes from the dom that should be removed completely from 355 # Members and classes from the dom that should be removed completely from
440 # dart:html. These could be expressed in the IDL instead but expressing this 356 # dart:html. These could be expressed in the IDL instead but expressing this
441 # as a simple table instead is more concise. 357 # as a simple table instead is more concise.
442 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName 358 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName
443 # Using get: and set: is optional and should only be used when a getter needs 359 # Using get: and set: is optional and should only be used when a getter needs
444 # to be suppressed but not the setter, etc. 360 # to be suppressed but not the setter, etc.
445 # TODO(jacobr): cleanup and augment this list. 361 # TODO(jacobr): cleanup and augment this list.
446 removed_html_members = monitored.Set('htmlrenamer.removed_html_members', [ 362 _removed_html_members = monitored.Set('htmlrenamer._removed_html_members', [
447 'AudioBufferSourceNode.looping', # TODO(vsm): Use deprecated IDL annotation 363 'AudioBufferSourceNode.looping', # TODO(vsm): Use deprecated IDL annotation
448 'CSSStyleDeclaration.getPropertyCSSValue', 364 'CSSStyleDeclaration.getPropertyCSSValue',
449 'CanvasRenderingContext2D.clearShadow', 365 'CanvasRenderingContext2D.clearShadow',
450 'CanvasRenderingContext2D.drawImageFromRect', 366 'CanvasRenderingContext2D.drawImageFromRect',
451 'CanvasRenderingContext2D.setAlpha', 367 'CanvasRenderingContext2D.setAlpha',
452 'CanvasRenderingContext2D.setCompositeOperation', 368 'CanvasRenderingContext2D.setCompositeOperation',
453 'CanvasRenderingContext2D.setFillColor', 369 'CanvasRenderingContext2D.setFillColor',
454 'CanvasRenderingContext2D.setLineCap', 370 'CanvasRenderingContext2D.setLineCap',
455 'CanvasRenderingContext2D.setLineJoin', 371 'CanvasRenderingContext2D.setLineJoin',
456 'CanvasRenderingContext2D.setLineWidth', 372 'CanvasRenderingContext2D.setLineWidth',
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 if self.ShouldSuppressMember(interface, member, member_prefix): 666 if self.ShouldSuppressMember(interface, member, member_prefix):
751 return None 667 return None
752 668
753 if 'CheckSecurityForNode' in member_node.ext_attrs: 669 if 'CheckSecurityForNode' in member_node.ext_attrs:
754 return None 670 return None
755 671
756 name = self._FindMatch(interface, member, member_prefix, 672 name = self._FindMatch(interface, member, member_prefix,
757 renamed_html_members) 673 renamed_html_members)
758 674
759 target_name = renamed_html_members[name] if name else member 675 target_name = renamed_html_members[name] if name else member
760 if self._FindMatch(interface, member, member_prefix, private_html_members): 676 if self._FindMatch(interface, member, member_prefix, _private_html_members):
761 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName 677 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName
762 target_name = '$dom_' + target_name 678 target_name = '$dom_' + target_name
763 679
764 if not name and target_name.startswith('webkit'): 680 if not name and target_name.startswith('webkit'):
765 target_name = member[len('webkit'):] 681 target_name = member[len('webkit'):]
766 target_name = target_name[:1].lower() + target_name[1:] 682 target_name = target_name[:1].lower() + target_name[1:]
767 683
768 if dartify_name: 684 if dartify_name:
769 target_name = self._DartifyMemberName(target_name) 685 target_name = self._DartifyMemberName(target_name)
770 return target_name 686 return target_name
771 687
772 def ShouldSuppressMember(self, interface, member, member_prefix=''): 688 def ShouldSuppressMember(self, interface, member, member_prefix=''):
773 """ Returns true if the member should be suppressed.""" 689 """ Returns true if the member should be suppressed."""
774 if self._FindMatch(interface, member, member_prefix, removed_html_members): 690 if self._FindMatch(interface, member, member_prefix,
691 _removed_html_members):
775 return True 692 return True
776 if interface.id in _removed_html_interfaces: 693 if interface.id in _removed_html_interfaces:
777 return True 694 return True
778 return False 695 return False
779 696
780 def ShouldSuppressInterface(self, interface): 697 def ShouldSuppressInterface(self, interface):
781 """ Returns true if the interface should be suppressed.""" 698 """ Returns true if the interface should be suppressed."""
782 if interface.id in _removed_html_interfaces: 699 if interface.id in _removed_html_interfaces:
783 return True 700 return True
784 701
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 770
854 # We're looking for a sequence of letters which start with capital letter 771 # We're looking for a sequence of letters which start with capital letter
855 # then a series of caps and finishes with either the end of the string or 772 # then a series of caps and finishes with either the end of the string or
856 # a capital letter. 773 # a capital letter.
857 # The [0-9] check is for names such as 2D or 3D 774 # The [0-9] check is for names such as 2D or 3D
858 # The following test cases should match as: 775 # The following test cases should match as:
859 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 776 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
860 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 777 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
861 # IFrameElement: (I)()(F)rameElement (no change) 778 # IFrameElement: (I)()(F)rameElement (no change)
862 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 779 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/logging.conf » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698