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 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 Loading... |
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', |
155 'CanvasRenderingContext2D.arc', | 156 'CanvasRenderingContext2D.arc', |
156 'CompositionEvent.initCompositionEvent', | 157 'CompositionEvent.initCompositionEvent', |
157 'CustomEvent.initCustomEvent', | 158 'CustomEvent.initCustomEvent', |
158 'DeviceOrientationEvent.initDeviceOrientationEvent', | 159 'DeviceOrientationEvent.initDeviceOrientationEvent', |
159 'Document.createElement', | 160 'Document.createElement', |
160 'Document.createElementNS', | 161 'Document.createElementNS', |
161 'Document.createEvent', | 162 'Document.createEvent', |
162 'Document.createNodeIterator', | 163 'Document.createNodeIterator', |
163 'Document.createRange', | 164 'Document.createRange', |
164 'Document.createTextNode', | 165 'Document.createTextNode', |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 'SVGElement.className': '$dom_svgClassName', | 342 'SVGElement.className': '$dom_svgClassName', |
342 'SVGStopElement.offset': 'gradientOffset', | 343 'SVGStopElement.offset': 'gradientOffset', |
343 'URL.createObjectURL': 'createObjectUrl', | 344 'URL.createObjectURL': 'createObjectUrl', |
344 'URL.revokeObjectURL': 'revokeObjectUrl', | 345 'URL.revokeObjectURL': 'revokeObjectUrl', |
345 'WheelEvent.wheelDeltaX': '_wheelDeltaX', | 346 'WheelEvent.wheelDeltaX': '_wheelDeltaX', |
346 'WheelEvent.wheelDeltaY': '_wheelDeltaY', | 347 'WheelEvent.wheelDeltaY': '_wheelDeltaY', |
347 #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem', | 348 #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem', |
348 #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync', | 349 #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync', |
349 }) | 350 }) |
350 | 351 |
| 352 # Members that have multiple definitions, but their types are vary, so we rename |
| 353 # them to make them distinct. |
| 354 renamed_overloads = monitored.Dict('htmldartgenreator.renamed_overloads', { |
| 355 'AudioContext.createBuffer(unsigned long numberOfChannels, unsigned long ' |
| 356 'numberOfFrames, float sampleRate)': 'createEmptyBuffer', |
| 357 'AudioContext.createBuffer(ArrayBuffer buffer, boolean mixToMono)': |
| 358 'createBufferFromBuffer', |
| 359 'CSS.supports(DOMString conditionText)': 'supportsCondition', |
| 360 'CSS.supports(DOMString property, DOMString value)': 'supportsProperty', |
| 361 'CanvasRenderingContext2D.createPattern(HTMLCanvasElement canvas, ' |
| 362 'DOMString repetitionType)': 'createPatternFromCanvas', |
| 363 'CanvasRenderingContext2D.createPattern(HTMLImageElement image, ' |
| 364 'DOMString repetitionType)': 'createPatternFromImage', |
| 365 'CanvasRenderingContext2D.setFillColor(DOMString color, float alpha)': |
| 366 'setFillColorString', |
| 367 'CanvasRenderingContext2D.setFillColor(float grayLevel, float alpha)': |
| 368 'setFillColorGrayLevel', |
| 369 'CanvasRenderingContext2D.setFillColor(float r, float g, float b, float a)': |
| 370 'setFillColorRgb', |
| 371 'CanvasRenderingContext2D.setFillColor(float c, float m, float y, float k, ' |
| 372 'float a)': 'setFillColorCmyk', |
| 373 'CanvasRenderingContext2D.setShadow(float width, float height, float blur, ' |
| 374 'DOMString color, float alpha)': 'setShadowString', |
| 375 'CanvasRenderingContext2D.setShadow(float width, float height, float blur, ' |
| 376 'float grayLevel, float alpha)': 'setShadowGrayLevel', |
| 377 'CanvasRenderingContext2D.setShadow(float width, float height, float blur, ' |
| 378 'float r, float g, float b, float a)': 'setShadowRgb', |
| 379 'CanvasRenderingContext2D.setShadow(float width, float height, float blur, ' |
| 380 'float c, float m, float y, float k, float a)': 'setShadowCmyk', |
| 381 'CanvasRenderingContext2D.setStrokeColor(DOMString color, float alpha)': |
| 382 'setStrokeColorString', |
| 383 'CanvasRenderingContext2D.setStrokeColor(float grayLevel, float alpha)': |
| 384 'setStrokeColorGrayLevel', |
| 385 'CanvasRenderingContext2D.setStrokeColor(float r, float g, float b, float a)': |
| 386 'setStrokeColorRgb', |
| 387 'CanvasRenderingContext2D.setStrokeColor(float c, float m, float y, float k,' |
| 388 ' float a)': 'setStrokeColorCmyk', |
| 389 'DataTransferItemList.add(File file)': 'addFile', |
| 390 'DataTransferItemList.add(DOMString data, DOMString type)': 'addData', |
| 391 'FormData.append(DOMString name, DOMString value)': 'appendString', |
| 392 'FormData.append(DOMString name, Blob value, DOMString filename)': |
| 393 'appendBlob', |
| 394 'IDBDatabase.transaction(DOMStringList storeNames, DOMString mode)': |
| 395 'transactionStores', |
| 396 'IDBDatabase.transaction(sequence<DOMString> storeNames, DOMString mode)': |
| 397 'transactionList', |
| 398 'IDBDatabase.transaction(DOMString storeName, DOMString mode)': |
| 399 'transactionStore', |
| 400 'RTCDataChannel.send(ArrayBuffer data)': 'sendByteBuffer', |
| 401 'RTCDataChannel.send(ArrayBufferView data)': 'sendTypedData', |
| 402 'RTCDataChannel.send(Blob data)': 'sendBlob', |
| 403 'RTCDataChannel.send(DOMString data)': 'sendString', |
| 404 'URL.createObjectURL(WebKitMediaSource source)': |
| 405 'createObjectUrlFromSource', |
| 406 'URL.createObjectURL(MediaStream stream)': 'createObjectUrlFromStream', |
| 407 'URL.createObjectURL(Blob blob)': 'createObjectUrlFromBlob', |
| 408 'WebGLRenderingContext.texImage2D(unsigned long target, long level, ' |
| 409 'unsigned long internalformat, unsigned long format, unsigned long ' |
| 410 'type, ImageData pixels)': 'texImage2DData', |
| 411 'WebGLRenderingContext.texImage2D(unsigned long target, long level, ' |
| 412 'unsigned long internalformat, unsigned long format, unsigned long ' |
| 413 'type, HTMLImageElement image)': 'texImage2DImage', |
| 414 'WebGLRenderingContext.texImage2D(unsigned long target, long level, ' |
| 415 'unsigned long internalformat, unsigned long format, unsigned long ' |
| 416 'type, HTMLCanvasElement canvas)': 'texImage2DCanvas', |
| 417 'WebGLRenderingContext.texImage2D(unsigned long target, long level, ' |
| 418 'unsigned long internalformat, unsigned long format, unsigned long ' |
| 419 'type, HTMLVideoElement video)': 'texImage2DVideo', |
| 420 'WebGLRenderingContext.texSubImage2D(unsigned long target, long level, ' |
| 421 'long xoffset, long yoffset, unsigned long format, unsigned long type, ' |
| 422 'ImageData pixels)': 'texSubImage2DData', |
| 423 'WebGLRenderingContext.texSubImage2D(unsigned long target, long level, ' |
| 424 'long xoffset, long yoffset, unsigned long format, unsigned long type, ' |
| 425 'HTMLImageElement image)': 'texSubImage2DImage', |
| 426 'WebGLRenderingContext.texSubImage2D(unsigned long target, long level, ' |
| 427 'long xoffset, long yoffset, unsigned long format, unsigned long type, ' |
| 428 'HTMLCanvasElement canvas)': 'texSubImage2DCanvas', |
| 429 'WebGLRenderingContext.texSubImage2D(unsigned long target, long level, ' |
| 430 'long xoffset, long yoffset, unsigned long format, unsigned long type, ' |
| 431 'HTMLVideoElement video)': 'texSubImage2DVideo', |
| 432 'WebGLRenderingContext.bufferData(unsigned long target, ' |
| 433 'ArrayBufferView data, unsigned long usage)': 'bufferTypedData', |
| 434 'WebGLRenderingContext.bufferData(unsigned long target, long long size, ' |
| 435 'unsigned long usage)': 'bufferEmptyData', |
| 436 'WebGLRenderingContext.bufferSubData(unsigned long target, ' |
| 437 'long long offset, ArrayBufferView data)': 'bufferSubTypedData', |
| 438 'WebSocket.send(ArrayBuffer data)': 'sendByteBuffer', |
| 439 'WebSocket.send(ArrayBufferView data)': 'sendTypeData', |
| 440 'WebSocket.send(DOMString data)': 'sendString', |
| 441 'WebSocket.send(Blob data)': 'sendBlob' |
| 442 }) |
| 443 |
| 444 # Members that have multiple definitions, but their types are identical (only |
| 445 # number of arguments vary), so we do not rename them as a _raw method. |
| 446 keep_overloaded_members = monitored.Set( |
| 447 'htmldartgenerator.keep_overloaded_members', [ |
| 448 'AudioBufferSourceNode.start', |
| 449 'CanvasRenderingContext2D.putImageData', |
| 450 'CanvasRenderingContext2D.webkitPutImageDataHD', |
| 451 'HTMLInputElement.setRangeText', |
| 452 'HTMLTextAreaElement.setRangeText', |
| 453 'XMLHttpRequest.send' |
| 454 ]) |
| 455 |
351 for member in convert_to_future_members: | 456 for member in convert_to_future_members: |
352 if member in renamed_html_members: | 457 if member in renamed_html_members: |
353 renamed_html_members[member] = '_' + renamed_html_members[member] | 458 renamed_html_members[member] = '_' + renamed_html_members[member] |
354 else: | 459 else: |
355 renamed_html_members[member] = '_' + member[member.find('.') + 1 :] | 460 renamed_html_members[member] = '_' + member[member.find('.') + 1 :] |
356 | 461 |
357 # Members and classes from the dom that should be removed completely from | 462 # Members and classes from the dom that should be removed completely from |
358 # dart:html. These could be expressed in the IDL instead but expressing this | 463 # dart:html. These could be expressed in the IDL instead but expressing this |
359 # as a simple table instead is more concise. | 464 # as a simple table instead is more concise. |
360 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName | 465 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 if self.ShouldSuppressMember(interface, member, member_prefix): | 775 if self.ShouldSuppressMember(interface, member, member_prefix): |
671 return None | 776 return None |
672 | 777 |
673 if 'CheckSecurityForNode' in member_node.ext_attrs: | 778 if 'CheckSecurityForNode' in member_node.ext_attrs: |
674 return None | 779 return None |
675 | 780 |
676 name = self._FindMatch(interface, member, member_prefix, | 781 name = self._FindMatch(interface, member, member_prefix, |
677 renamed_html_members) | 782 renamed_html_members) |
678 | 783 |
679 target_name = renamed_html_members[name] if name else member | 784 target_name = renamed_html_members[name] if name else member |
680 if self._FindMatch(interface, member, member_prefix, _private_html_members): | 785 if self._FindMatch(interface, member, member_prefix, private_html_members): |
681 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName | 786 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName |
682 target_name = '$dom_' + target_name | 787 target_name = '$dom_' + target_name |
683 | 788 |
684 if not name and target_name.startswith('webkit'): | 789 if not name and target_name.startswith('webkit'): |
685 target_name = member[len('webkit'):] | 790 target_name = member[len('webkit'):] |
686 target_name = target_name[:1].lower() + target_name[1:] | 791 target_name = target_name[:1].lower() + target_name[1:] |
687 | 792 |
688 if dartify_name: | 793 if dartify_name: |
689 target_name = self._DartifyMemberName(target_name) | 794 target_name = self._DartifyMemberName(target_name) |
690 return target_name | 795 return target_name |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 | 879 |
775 # We're looking for a sequence of letters which start with capital letter | 880 # We're looking for a sequence of letters which start with capital letter |
776 # then a series of caps and finishes with either the end of the string or | 881 # then a series of caps and finishes with either the end of the string or |
777 # a capital letter. | 882 # a capital letter. |
778 # The [0-9] check is for names such as 2D or 3D | 883 # The [0-9] check is for names such as 2D or 3D |
779 # The following test cases should match as: | 884 # The following test cases should match as: |
780 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue | 885 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue |
781 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) | 886 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) |
782 # IFrameElement: (I)()(F)rameElement (no change) | 887 # IFrameElement: (I)()(F)rameElement (no change) |
783 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) | 888 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) |
OLD | NEW |