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

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

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

Powered by Google App Engine
This is Rietveld 408576698