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

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

Issue 13444007: Removing all Worker-related APIs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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/generator.py ('k') | tools/dom/scripts/systemhtml.py » ('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 html_interface_renames = monitored.Dict('htmlrenamer.html_interface_renames', { 9 html_interface_renames = monitored.Dict('htmlrenamer.html_interface_renames', {
10 'CDATASection': 'CDataSection', 10 'CDATASection': 'CDataSection',
11 'Clipboard': 'DataTransfer', 11 'Clipboard': 'DataTransfer',
12 'Database': 'SqlDatabase', # Avoid conflict with Index DB's Database. 12 'Database': 'SqlDatabase', # Avoid conflict with Index DB's Database.
13 'DatabaseSync': 'SqlDatabaseSync', 13 'DatabaseSync': 'SqlDatabaseSync',
14 'DOMApplicationCache': 'ApplicationCache', 14 'DOMApplicationCache': 'ApplicationCache',
15 'DOMCoreException': 'DomException', 15 'DOMCoreException': 'DomException',
16 'DOMFileSystem': 'FileSystem', 16 'DOMFileSystem': 'FileSystem',
17 'DOMFileSystemSync': 'FileSystemSync',
18 'DOMFormData': 'FormData', 17 'DOMFormData': 'FormData',
19 'DOMURL': 'Url', 18 'DOMURL': 'Url',
20 'DOMWindow': 'Window', 19 'DOMWindow': 'Window',
21 'EntryCallback': '_EntryCallback', 20 'EntryCallback': '_EntryCallback',
22 'EntriesCallback': '_EntriesCallback', 21 'EntriesCallback': '_EntriesCallback',
23 'ErrorCallback': '_ErrorCallback', 22 'ErrorCallback': '_ErrorCallback',
24 'FileCallback': '_FileCallback', 23 'FileCallback': '_FileCallback',
25 'FileSystemCallback': '_FileSystemCallback', 24 'FileSystemCallback': '_FileSystemCallback',
26 'FileWriterCallback': '_FileWriterCallback', 25 'FileWriterCallback': '_FileWriterCallback',
27 'HTMLDocument' : 'HtmlDocument', 26 'HTMLDocument' : 'HtmlDocument',
(...skipping 27 matching lines...) Expand all
55 'WebKitTransitionEvent': '_WebKitTransitionEvent', 54 'WebKitTransitionEvent': '_WebKitTransitionEvent',
56 'XMLHttpRequest': 'HttpRequest', 55 'XMLHttpRequest': 'HttpRequest',
57 'XMLHttpRequestException': 'HttpRequestException', 56 'XMLHttpRequestException': 'HttpRequestException',
58 'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent', 57 'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent',
59 'XMLHttpRequestUpload': 'HttpRequestUpload', 58 'XMLHttpRequestUpload': 'HttpRequestUpload',
60 }) 59 })
61 60
62 # Interfaces that are suppressed, but need to still exist for Dartium and to 61 # Interfaces that are suppressed, but need to still exist for Dartium and to
63 # properly wrap DOM objects if/when encountered. 62 # properly wrap DOM objects if/when encountered.
64 _removed_html_interfaces = [ 63 _removed_html_interfaces = [
64 'DOMFileSystemSync', # Workers
65 'DatabaseSync', # Workers
66 'DedicatedWorkerContext', # Workers
67 'DirectoryEntrySync', # Workers
68 'DirectoryReaderSync', # Workers
69 'EntrySync', # Workers
70 'FileEntrySync', # Workers
71 'FileReaderSync', # Workers
72 'FileWriterSync', # Workers
65 'HTMLAppletElement', 73 'HTMLAppletElement',
66 'HTMLBaseFontElement', 74 'HTMLBaseFontElement',
67 'HTMLDirectoryElement', 75 'HTMLDirectoryElement',
68 'HTMLFontElement', 76 'HTMLFontElement',
69 'HTMLFrameElement', 77 'HTMLFrameElement',
70 'HTMLFrameSetElement', 78 'HTMLFrameSetElement',
71 'HTMLMarqueeElement', 79 'HTMLMarqueeElement',
72 'IDBAny', 80 'IDBAny',
81 'SQLTransactionSync', # Workers
82 'SQLTransactionSyncCallback', # Workers
73 'SVGAltGlyphDefElement', # Webkit only. 83 'SVGAltGlyphDefElement', # Webkit only.
74 'SVGAltGlyphItemElement', # Webkit only. 84 'SVGAltGlyphItemElement', # Webkit only.
75 'SVGAnimateColorElement', # Deprecated. Use AnimateElement instead. 85 'SVGAnimateColorElement', # Deprecated. Use AnimateElement instead.
76 'SVGComponentTransferFunctionElement', # Currently not supported anywhere. 86 'SVGComponentTransferFunctionElement', # Currently not supported anywhere.
77 'SVGCursorElement', # Webkit only. 87 'SVGCursorElement', # Webkit only.
78 'SVGGradientElement', # Currently not supported anywhere.
79 'SVGFEDropShadowElement', # Webkit only for the following: 88 'SVGFEDropShadowElement', # Webkit only for the following:
80 'SVGFontElement', 89 'SVGFontElement',
81 'SVGFontFaceElement', 90 'SVGFontFaceElement',
82 'SVGFontFaceFormatElement', 91 'SVGFontFaceFormatElement',
83 'SVGFontFaceNameElement', 92 'SVGFontFaceNameElement',
84 'SVGFontFaceSrcElement', 93 'SVGFontFaceSrcElement',
85 'SVGFontFaceUriElement', 94 'SVGFontFaceUriElement',
86 'SVGGlyphElement', 95 'SVGGlyphElement',
87 'SVGGlyphRefElement', 96 'SVGGlyphRefElement',
97 'SVGGradientElement', # Currently not supported anywhere.
88 'SVGHKernElement', 98 'SVGHKernElement',
99 'SVGMPathElement',
89 'SVGMissingGlyphElement', 100 'SVGMissingGlyphElement',
90 'SVGMPathElement',
91 'SVGTRefElement', 101 'SVGTRefElement',
92 'SVGVKernElement', 102 'SVGVKernElement',
103 'SharedWorker', # Workers
104 'SharedWorkerContext', # Workers
105 'WorkerContext', # Workers
106 'WorkerLocation', # Workers
107 'WorkerNavigator', # Workers
93 ] 108 ]
94 109
95 for interface in _removed_html_interfaces: 110 for interface in _removed_html_interfaces:
96 html_interface_renames[interface] = '_' + interface 111 html_interface_renames[interface] = '_' + interface
97 112
98 convert_to_future_members = monitored.Set( 113 convert_to_future_members = monitored.Set(
99 'htmlrenamer.converted_to_future_members', [ 114 'htmlrenamer.converted_to_future_members', [
100 'DataTransferItem.getAsString', 115 'DataTransferItem.getAsString',
101 'DirectoryEntry.getDirectory', 116 'DirectoryEntry.getDirectory',
102 'DirectoryEntry.getFile', 117 'DirectoryEntry.getFile',
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 'Node.appendChild': 'append', 314 'Node.appendChild': 'append',
300 'Node.cloneNode': 'clone', 315 'Node.cloneNode': 'clone',
301 'Node.nextSibling': 'nextNode', 316 'Node.nextSibling': 'nextNode',
302 'Node.ownerDocument': 'document', 317 'Node.ownerDocument': 'document',
303 'Node.parentElement': 'parent', 318 'Node.parentElement': 'parent',
304 'Node.previousSibling': 'previousNode', 319 'Node.previousSibling': 'previousNode',
305 'Node.textContent': 'text', 320 'Node.textContent': 'text',
306 'RTCPeerConnection.createAnswer': '_createAnswer', 321 'RTCPeerConnection.createAnswer': '_createAnswer',
307 'RTCPeerConnection.createOffer': '_createOffer', 322 'RTCPeerConnection.createOffer': '_createOffer',
308 'StorageInfo.queryUsageAndQuota': '_queryUsageAndQuota', 323 'StorageInfo.queryUsageAndQuota': '_queryUsageAndQuota',
309 'SVGComponentTransferFunctionElement.offset': 'gradientOffset',
310 'SVGElement.className': '$dom_svgClassName', 324 'SVGElement.className': '$dom_svgClassName',
311 'SVGStopElement.offset': 'gradientOffset', 325 'SVGStopElement.offset': 'gradientOffset',
312 'WorkerContext.webkitRequestFileSystem': '_requestFileSystem', 326 #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem', # Workers
313 'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync', 327 #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync', # Wo rkers
314 'WorkerContext.webkitResolveLocalFileSystemSyncURL':
315 'resolveLocalFileSystemSyncUrl',
316 'WorkerContext.webkitResolveLocalFileSystemURL':
317 'resolveLocalFileSystemUrl',
318 }) 328 })
319 329
320 for member in convert_to_future_members: 330 for member in convert_to_future_members:
321 if member in renamed_html_members: 331 if member in renamed_html_members:
322 renamed_html_members[member] = '_' + renamed_html_members[member] 332 renamed_html_members[member] = '_' + renamed_html_members[member]
323 else: 333 else:
324 renamed_html_members[member] = '_' + member[member.find('.') + 1 :] 334 renamed_html_members[member] = '_' + member[member.find('.') + 1 :]
325 335
326 # Members and classes from the dom that should be removed completely from 336 # Members and classes from the dom that should be removed completely from
327 # dart:html. These could be expressed in the IDL instead but expressing this 337 # dart:html. These could be expressed in the IDL instead but expressing this
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 'DOMWindow': 'html', 614 'DOMWindow': 'html',
605 'Navigator': 'html', 615 'Navigator': 'html',
606 'WorkerContext': 'html', 616 'WorkerContext': 'html',
607 }) 617 })
608 618
609 class HtmlRenamer(object): 619 class HtmlRenamer(object):
610 def __init__(self, database): 620 def __init__(self, database):
611 self._database = database 621 self._database = database
612 622
613 def RenameInterface(self, interface): 623 def RenameInterface(self, interface):
624 if 'Callback' in interface.ext_attrs:
625 if interface.id in _removed_html_interfaces:
626 return None
627
614 if interface.id in html_interface_renames: 628 if interface.id in html_interface_renames:
615 return html_interface_renames[interface.id] 629 return html_interface_renames[interface.id]
616 elif interface.id.startswith('HTML'): 630 elif interface.id.startswith('HTML'):
617 if any(interface.id in ['Element', 'Document'] 631 if any(interface.id in ['Element', 'Document']
618 for interface in self._database.Hierarchy(interface)): 632 for interface in self._database.Hierarchy(interface)):
619 return interface.id[len('HTML'):] 633 return interface.id[len('HTML'):]
620 return self.DartifyTypeName(interface.id) 634 return self.DartifyTypeName(interface.id)
621 635
622 636
623 def RenameMember(self, interface_name, member_node, member, member_prefix='', 637 def RenameMember(self, interface_name, member_node, member, member_prefix='',
(...skipping 24 matching lines...) Expand all
648 662
649 if dartify_name: 663 if dartify_name:
650 target_name = self._DartifyMemberName(target_name) 664 target_name = self._DartifyMemberName(target_name)
651 return target_name 665 return target_name
652 666
653 def ShouldSuppressMember(self, interface, member, member_prefix=''): 667 def ShouldSuppressMember(self, interface, member, member_prefix=''):
654 """ Returns true if the member should be suppressed.""" 668 """ Returns true if the member should be suppressed."""
655 if self._FindMatch(interface, member, member_prefix, 669 if self._FindMatch(interface, member, member_prefix,
656 _removed_html_members): 670 _removed_html_members):
657 return True 671 return True
672 if interface.id in _removed_html_interfaces:
673 return True
658 return False 674 return False
659 675
660 def _FindMatch(self, interface, member, member_prefix, candidates): 676 def _FindMatch(self, interface, member, member_prefix, candidates):
661 for interface in self._database.Hierarchy(interface): 677 for interface in self._database.Hierarchy(interface):
662 member_name = interface.id + '.' + member 678 member_name = interface.id + '.' + member
663 if member_name in candidates: 679 if member_name in candidates:
664 return member_name 680 return member_name
665 member_name = interface.id + '.' + member_prefix + member 681 member_name = interface.id + '.' + member_prefix + member
666 if member_name in candidates: 682 if member_name in candidates:
667 return member_name 683 return member_name
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 729
714 # We're looking for a sequence of letters which start with capital letter 730 # We're looking for a sequence of letters which start with capital letter
715 # then a series of caps and finishes with either the end of the string or 731 # then a series of caps and finishes with either the end of the string or
716 # a capital letter. 732 # a capital letter.
717 # The [0-9] check is for names such as 2D or 3D 733 # The [0-9] check is for names such as 2D or 3D
718 # The following test cases should match as: 734 # The following test cases should match as:
719 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 735 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
720 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 736 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
721 # IFrameElement: (I)()(F)rameElement (no change) 737 # IFrameElement: (I)()(F)rameElement (no change)
722 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 738 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name)
OLDNEW
« no previous file with comments | « tools/dom/scripts/generator.py ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698