| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 'RTCPeerConnection.setLocalDescription', | 149 'RTCPeerConnection.setLocalDescription', |
| 150 'RTCPeerConnection.setRemoteDescription', | 150 'RTCPeerConnection.setRemoteDescription', |
| 151 'StorageInfo.requestQuota', | 151 'StorageInfo.requestQuota', |
| 152 'StorageQuota.requestQuota', | 152 'StorageQuota.requestQuota', |
| 153 'Window.webkitRequestFileSystem', | 153 'Window.webkitRequestFileSystem', |
| 154 'Window.webkitResolveLocalFileSystemURL', | 154 'Window.webkitResolveLocalFileSystemURL', |
| 155 'WorkerGlobalScope.webkitRequestFileSystem', | 155 'WorkerGlobalScope.webkitRequestFileSystem', |
| 156 'WorkerGlobalScope.webkitResolveLocalFileSystemURL', | 156 'WorkerGlobalScope.webkitResolveLocalFileSystemURL', |
| 157 ]) | 157 ]) |
| 158 | 158 |
| 159 # "Private" members in the form $dom_foo. | |
| 160 # TODO(efortuna): Remove this set. This allows us to make the change of removing | |
| 161 # $dom in installments instead of all at once, but the intent is to move all of | |
| 162 # these either into private_html_members or remove them from this list entirely. | |
| 163 dom_private_html_members = monitored.Set('htmlrenamer.private_html_members', [ | |
| 164 'EventTarget.addEventListener', | |
| 165 'EventTarget.removeEventListener', | |
| 166 ]) | |
| 167 | |
| 168 # Classes where we have customized constructors, but we need to keep the old | 159 # Classes where we have customized constructors, but we need to keep the old |
| 169 # constructor for dispatch purposes. | 160 # constructor for dispatch purposes. |
| 170 custom_html_constructors = monitored.Set( | 161 custom_html_constructors = monitored.Set( |
| 171 'htmlrenamer.custom_html_constructors', [ | 162 'htmlrenamer.custom_html_constructors', [ |
| 172 'HTMLOptionElement', | 163 'HTMLOptionElement', |
| 173 'MutationObserver', | 164 'MutationObserver', |
| 174 ]) | 165 ]) |
| 175 | 166 |
| 176 # Members from the standard dom that should not be exposed publicly in dart:html | 167 # Members from the standard dom that should not be exposed publicly in dart:html |
| 177 # but need to be exposed internally to implement dart:html on top of a standard | 168 # but need to be exposed internally to implement dart:html on top of a standard |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 'Element.getElementsByTagName', | 217 'Element.getElementsByTagName', |
| 227 'Element.scrollIntoView', | 218 'Element.scrollIntoView', |
| 228 'Element.scrollIntoViewIfNeeded', | 219 'Element.scrollIntoViewIfNeeded', |
| 229 'Element.removeAttribute', | 220 'Element.removeAttribute', |
| 230 'Element.removeAttributeNS', | 221 'Element.removeAttributeNS', |
| 231 'Element.hasAttribute', | 222 'Element.hasAttribute', |
| 232 'Element.hasAttributeNS', | 223 'Element.hasAttributeNS', |
| 233 'Element.innerHTML', | 224 'Element.innerHTML', |
| 234 'Element.querySelectorAll', | 225 'Element.querySelectorAll', |
| 235 'Event.initEvent', | 226 'Event.initEvent', |
| 227 'EventTarget.addEventListener', |
| 228 'EventTarget.removeEventListener', |
| 236 'Geolocation.clearWatch', | 229 'Geolocation.clearWatch', |
| 237 'Geolocation.getCurrentPosition', | 230 'Geolocation.getCurrentPosition', |
| 238 'Geolocation.watchPosition', | 231 'Geolocation.watchPosition', |
| 239 'HashChangeEvent.initHashChangeEvent', | 232 'HashChangeEvent.initHashChangeEvent', |
| 240 'HTMLCanvasElement.toDataURL', | 233 'HTMLCanvasElement.toDataURL', |
| 241 'HTMLTableElement.createCaption', | 234 'HTMLTableElement.createCaption', |
| 242 'HTMLTableElement.createTFoot', | 235 'HTMLTableElement.createTFoot', |
| 243 'HTMLTableElement.createTHead', | 236 'HTMLTableElement.createTHead', |
| 244 'HTMLTableElement.createTBody', | 237 'HTMLTableElement.createTBody', |
| 245 'HTMLTableElement.insertRow', | 238 'HTMLTableElement.insertRow', |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 }) | 753 }) |
| 761 | 754 |
| 762 _library_ids = monitored.Dict('htmlrenamer._library_names', { | 755 _library_ids = monitored.Dict('htmlrenamer._library_names', { |
| 763 'ANGLEInstancedArrays': 'WebGl', | 756 'ANGLEInstancedArrays': 'WebGl', |
| 764 'Database': 'WebSql', | 757 'Database': 'WebSql', |
| 765 'Navigator': 'Html', | 758 'Navigator': 'Html', |
| 766 'Window': 'Html', | 759 'Window': 'Html', |
| 767 }) | 760 }) |
| 768 | 761 |
| 769 class HtmlRenamer(object): | 762 class HtmlRenamer(object): |
| 770 def __init__(self, database): | 763 def __init__(self, database, metadata): |
| 771 self._database = database | 764 self._database = database |
| 765 self._metadata = metadata |
| 772 | 766 |
| 773 def RenameInterface(self, interface): | 767 def RenameInterface(self, interface): |
| 774 if 'Callback' in interface.ext_attrs: | 768 if 'Callback' in interface.ext_attrs: |
| 775 if interface.id in _removed_html_interfaces: | 769 if interface.id in _removed_html_interfaces: |
| 776 return None | 770 return None |
| 777 | 771 |
| 778 candidate = self.RenameInterfaceId(interface.id) | 772 candidate = self.RenameInterfaceId(interface.id) |
| 779 if candidate: | 773 if candidate: |
| 780 return candidate | 774 return candidate |
| 781 | 775 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 809 if 'CheckSecurityForNode' in member_node.ext_attrs: | 803 if 'CheckSecurityForNode' in member_node.ext_attrs: |
| 810 return None | 804 return None |
| 811 | 805 |
| 812 name = self._FindMatch(interface, member, member_prefix, | 806 name = self._FindMatch(interface, member, member_prefix, |
| 813 renamed_html_members) | 807 renamed_html_members) |
| 814 | 808 |
| 815 target_name = renamed_html_members[name] if name else member | 809 target_name = renamed_html_members[name] if name else member |
| 816 if self._FindMatch(interface, member, member_prefix, private_html_members): | 810 if self._FindMatch(interface, member, member_prefix, private_html_members): |
| 817 if not target_name.startswith('_'): # e.g. _svgClassName | 811 if not target_name.startswith('_'): # e.g. _svgClassName |
| 818 target_name = '_' + target_name | 812 target_name = '_' + target_name |
| 819 elif self._FindMatch(interface, member, member_prefix, | |
| 820 dom_private_html_members): | |
| 821 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName | |
| 822 target_name = '$dom_' + target_name | |
| 823 | 813 |
| 824 if not name and target_name.startswith('webkit'): | 814 if not name and target_name.startswith('webkit'): |
| 825 target_name = member[len('webkit'):] | 815 target_name = member[len('webkit'):] |
| 826 target_name = target_name[:1].lower() + target_name[1:] | 816 target_name = target_name[:1].lower() + target_name[1:] |
| 827 | 817 |
| 828 if dartify_name: | 818 if dartify_name: |
| 829 target_name = self._DartifyMemberName(target_name) | 819 target_name = self._DartifyMemberName(target_name) |
| 830 return target_name | 820 return target_name |
| 831 | 821 |
| 832 def ShouldSuppressMember(self, interface, member, member_prefix=''): | 822 def ShouldSuppressMember(self, interface, member, member_prefix=''): |
| 833 """ Returns true if the member should be suppressed.""" | 823 """ Returns true if the member should be suppressed.""" |
| 834 if self._FindMatch(interface, member, member_prefix, removed_html_members): | 824 if self._FindMatch(interface, member, member_prefix, removed_html_members): |
| 835 return True | 825 return True |
| 836 if interface.id in _removed_html_interfaces: | 826 if interface.id in _removed_html_interfaces: |
| 837 return True | 827 return True |
| 828 metadata_member = member |
| 829 if member_prefix == 'on:': |
| 830 metadata_member = 'on' + metadata_member.lower() |
| 831 if self._metadata.IsDeprecated(interface, metadata_member): |
| 832 return True |
| 838 return False | 833 return False |
| 839 | 834 |
| 840 def ShouldSuppressInterface(self, interface): | 835 def ShouldSuppressInterface(self, interface): |
| 841 """ Returns true if the interface should be suppressed.""" | 836 """ Returns true if the interface should be suppressed.""" |
| 842 if interface.id in _removed_html_interfaces: | 837 if interface.id in _removed_html_interfaces: |
| 843 return True | 838 return True |
| 844 | 839 |
| 845 def _FindMatch(self, interface, member, member_prefix, candidates): | 840 def _FindMatch(self, interface, member, member_prefix, candidates): |
| 846 for interface in self._database.Hierarchy(interface): | 841 for interface in self._database.Hierarchy(interface): |
| 847 member_name = interface.id + '.' + member | 842 member_name = interface.id + '.' + member |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 | 938 |
| 944 # We're looking for a sequence of letters which start with capital letter | 939 # We're looking for a sequence of letters which start with capital letter |
| 945 # then a series of caps and finishes with either the end of the string or | 940 # then a series of caps and finishes with either the end of the string or |
| 946 # a capital letter. | 941 # a capital letter. |
| 947 # The [0-9] check is for names such as 2D or 3D | 942 # The [0-9] check is for names such as 2D or 3D |
| 948 # The following test cases should match as: | 943 # The following test cases should match as: |
| 949 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue | 944 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue |
| 950 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) | 945 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) |
| 951 # IFrameElement: (I)()(F)rameElement (no change) | 946 # IFrameElement: (I)()(F)rameElement (no change) |
| 952 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) | 947 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) |
| OLD | NEW |