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

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

Issue 15930013: Fixing codegen issues from Blink roll. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 'NamedNodeMap': '_NamedNodeMap', 43 'NamedNodeMap': '_NamedNodeMap',
44 'NavigatorUserMediaErrorCallback': '_NavigatorUserMediaErrorCallback', 44 'NavigatorUserMediaErrorCallback': '_NavigatorUserMediaErrorCallback',
45 'NavigatorUserMediaSuccessCallback': '_NavigatorUserMediaSuccessCallback', 45 'NavigatorUserMediaSuccessCallback': '_NavigatorUserMediaSuccessCallback',
46 'NotificationPermissionCallback': '_NotificationPermissionCallback', 46 'NotificationPermissionCallback': '_NotificationPermissionCallback',
47 'PositionCallback': '_PositionCallback', 47 'PositionCallback': '_PositionCallback',
48 'PositionErrorCallback': '_PositionErrorCallback', 48 'PositionErrorCallback': '_PositionErrorCallback',
49 'RTCDTMFSender': 'RtcDtmfSender', 49 'RTCDTMFSender': 'RtcDtmfSender',
50 'RTCDTMFToneChangeEvent': 'RtcDtmfToneChangeEvent', 50 'RTCDTMFToneChangeEvent': 'RtcDtmfToneChangeEvent',
51 'RTCErrorCallback': '_RtcErrorCallback', 51 'RTCErrorCallback': '_RtcErrorCallback',
52 'RTCSessionDescriptionCallback': '_RtcSessionDescriptionCallback', 52 'RTCSessionDescriptionCallback': '_RtcSessionDescriptionCallback',
53 'StringCallback': '_StringCallback',
54 'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts. 53 'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts.
55 'SVGElement': 'SvgElement', # Manual to avoid name conflicts. 54 'SVGElement': 'SvgElement', # Manual to avoid name conflicts.
56 'SVGException': 'SvgException', # Manual of avoid conflict with Exception. 55 'SVGException': 'SvgException', # Manual of avoid conflict with Exception.
57 'SVGGradientElement': '_GradientElement', 56 'SVGGradientElement': '_GradientElement',
58 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts. 57 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts.
58 'StringCallback': '_StringCallback',
59 'WebGLVertexArrayObjectOES': 'VertexArrayObject', 59 'WebGLVertexArrayObjectOES': 'VertexArrayObject',
60 'WebKitCSSFilterRule': '_WebKitCssFilterRule',
61 'WebKitCSSKeyframeRule': '_WebKitCssKeyframeRule',
62 'WebKitCSSKeyframesRule': '_WebKitCssKeyframesRule',
63 'WebKitCSSRegionRule': '_WebKitCssRegionRule',
60 'XMLHttpRequest': 'HttpRequest', 64 'XMLHttpRequest': 'HttpRequest',
61 'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent', 65 'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent',
62 'XMLHttpRequestUpload': 'HttpRequestUpload', 66 'XMLHttpRequestUpload': 'HttpRequestUpload',
63 }, **typed_array_renames)) 67 }, **typed_array_renames))
64 68
65 # Interfaces that are suppressed, but need to still exist for Dartium and to 69 # Interfaces that are suppressed, but need to still exist for Dartium and to
66 # properly wrap DOM objects if/when encountered. 70 # properly wrap DOM objects if/when encountered.
67 _removed_html_interfaces = [ 71 _removed_html_interfaces = [
68 'CSSPrimitiveValue', 72 'CSSPrimitiveValue',
69 'CSSValue', 73 'CSSValue',
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 if 'Callback' in interface.ext_attrs: 650 if 'Callback' in interface.ext_attrs:
647 if interface.id in _removed_html_interfaces: 651 if interface.id in _removed_html_interfaces:
648 return None 652 return None
649 653
650 if interface.id in html_interface_renames: 654 if interface.id in html_interface_renames:
651 return html_interface_renames[interface.id] 655 return html_interface_renames[interface.id]
652 elif interface.id.startswith('HTML'): 656 elif interface.id.startswith('HTML'):
653 if any(interface.id in ['Element', 'Document'] 657 if any(interface.id in ['Element', 'Document']
654 for interface in self._database.Hierarchy(interface)): 658 for interface in self._database.Hierarchy(interface)):
655 return interface.id[len('HTML'):] 659 return interface.id[len('HTML'):]
656 return self.DartifyTypeName(interface.javascript_binding_name) 660 return self._DartifyName(interface.javascript_binding_name)
661
657 662
658 663
659 def RenameMember(self, interface_name, member_node, member, member_prefix='', 664 def RenameMember(self, interface_name, member_node, member, member_prefix='',
660 dartify_name=True): 665 dartify_name=True):
661 """ 666 """
662 Returns the name of the member in the HTML library or None if the member is 667 Returns the name of the member in the HTML library or None if the member is
663 suppressed in the HTML library 668 suppressed in the HTML library
664 """ 669 """
665 interface = self._database.GetInterface(interface_name) 670 interface = self._database.GetInterface(interface_name)
666 671
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 return 'typed_data' 750 return 'typed_data'
746 751
747 return 'html' 752 return 'html'
748 753
749 def DartifyTypeName(self, type_name): 754 def DartifyTypeName(self, type_name):
750 """Converts a DOM name to a Dart-friendly class name. """ 755 """Converts a DOM name to a Dart-friendly class name. """
751 756
752 if type_name in html_interface_renames: 757 if type_name in html_interface_renames:
753 return html_interface_renames[type_name] 758 return html_interface_renames[type_name]
754 759
760 return self._DartifyName(type_name)
761
762 def _DartifyName(self, dart_name):
755 # Strip off any standard prefixes. 763 # Strip off any standard prefixes.
756 name = re.sub(r'^SVG', '', type_name) 764 name = re.sub(r'^SVG', '', dart_name)
757 name = re.sub(r'^IDB', '', name) 765 name = re.sub(r'^IDB', '', name)
758 name = re.sub(r'^WebGL', '', name) 766 name = re.sub(r'^WebGL', '', name)
759 name = re.sub(r'^WebKit', '', name) 767 name = re.sub(r'^WebKit', '', name)
760 768
761 return self._CamelCaseName(name) 769 return self._CamelCaseName(name)
762 770
763 def _DartifyMemberName(self, member_name): 771 def _DartifyMemberName(self, member_name):
764 # Strip off any OpenGL ES suffixes. 772 # Strip off any OpenGL ES suffixes.
765 name = re.sub(r'OES$', '', member_name) 773 name = re.sub(r'OES$', '', member_name)
766 return self._CamelCaseName(name) 774 return self._CamelCaseName(name)
767 775
768 def _CamelCaseName(self, name): 776 def _CamelCaseName(self, name):
769 777
770 def toLower(match): 778 def toLower(match):
771 return match.group(1) + match.group(2).lower() + match.group(3) 779 return match.group(1) + match.group(2).lower() + match.group(3)
772 780
773 # We're looking for a sequence of letters which start with capital letter 781 # We're looking for a sequence of letters which start with capital letter
774 # then a series of caps and finishes with either the end of the string or 782 # then a series of caps and finishes with either the end of the string or
775 # a capital letter. 783 # a capital letter.
776 # The [0-9] check is for names such as 2D or 3D 784 # The [0-9] check is for names such as 2D or 3D
777 # The following test cases should match as: 785 # The following test cases should match as:
778 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 786 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
779 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 787 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
780 # IFrameElement: (I)()(F)rameElement (no change) 788 # IFrameElement: (I)()(F)rameElement (no change)
781 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 789 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name)
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698