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

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

Issue 12769016: Fixing go.sh occasionally putting types into incorrect libraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « no previous file | 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 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',
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 'Node.set:nodeValue', 597 'Node.set:nodeValue',
598 'NodeList.item', 598 'NodeList.item',
599 'ShadowRoot.getElementsByTagNameNS', 599 'ShadowRoot.getElementsByTagNameNS',
600 'WheelEvent.wheelDelta', 600 'WheelEvent.wheelDelta',
601 'WorkerContext.webkitIndexedDB', 601 'WorkerContext.webkitIndexedDB',
602 # TODO(jacobr): should these be removed? 602 # TODO(jacobr): should these be removed?
603 'Document.close', 603 'Document.close',
604 'Document.hasFocus', 604 'Document.hasFocus',
605 ]) 605 ])
606 606
607 # Manual dart: library name lookup.
608 _library_names = monitored.Dict('htmlrenamer._library_names', {
609 'DOMWindow': 'html',
610 'Navigator': 'html',
611 'WorkerContext': 'html',
612 })
613
607 class HtmlRenamer(object): 614 class HtmlRenamer(object):
608 def __init__(self, database): 615 def __init__(self, database):
609 self._database = database 616 self._database = database
610 617
611 def RenameInterface(self, interface): 618 def RenameInterface(self, interface):
612 if interface.id in html_interface_renames: 619 if interface.id in html_interface_renames:
613 return html_interface_renames[interface.id] 620 return html_interface_renames[interface.id]
614 elif interface.id.startswith('HTML'): 621 elif interface.id.startswith('HTML'):
615 if any(interface.id in ['Element', 'Document'] 622 if any(interface.id in ['Element', 'Document']
616 for interface in self._database.Hierarchy(interface)): 623 for interface in self._database.Hierarchy(interface)):
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 if member_name in candidates: 668 if member_name in candidates:
662 return member_name 669 return member_name
663 member_name = interface.id + '.' + member_prefix + member 670 member_name = interface.id + '.' + member_prefix + member
664 if member_name in candidates: 671 if member_name in candidates:
665 return member_name 672 return member_name
666 member_name = interface.id + '.*' 673 member_name = interface.id + '.*'
667 if member_name in candidates: 674 if member_name in candidates:
668 return member_name 675 return member_name
669 676
670 def GetLibraryName(self, interface): 677 def GetLibraryName(self, interface):
678 # Some types have attributes merged in from many other interfaces.
679 if interface.id in _library_names:
680 return _library_names[interface.id]
681
671 if 'Conditional' in interface.ext_attrs: 682 if 'Conditional' in interface.ext_attrs:
672 if 'WEB_AUDIO' in interface.ext_attrs['Conditional']: 683 if 'WEB_AUDIO' in interface.ext_attrs['Conditional']:
673 return 'web_audio' 684 return 'web_audio'
674 if 'SVG' in interface.ext_attrs['Conditional']: 685 if 'SVG' in interface.ext_attrs['Conditional']:
675 return 'svg' 686 return 'svg'
676 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']: 687 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']:
677 return 'indexed_db' 688 return 'indexed_db'
678 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']: 689 if 'SQL_DATABASE' in interface.ext_attrs['Conditional']:
679 # WorkerContext has attributes merged in from many other interfaces. 690 return 'web_sql'
680 if interface.id != 'WorkerContext':
681 return 'web_sql'
682 691
683 return 'html' 692 return 'html'
684 693
685 def DartifyTypeName(self, type_name): 694 def DartifyTypeName(self, type_name):
686 """Converts a DOM name to a Dart-friendly class name. """ 695 """Converts a DOM name to a Dart-friendly class name. """
687 696
688 if type_name in html_interface_renames: 697 if type_name in html_interface_renames:
689 return html_interface_renames[type_name] 698 return html_interface_renames[type_name]
690 699
691 # Strip off any standard prefixes. 700 # Strip off any standard prefixes.
(...skipping 14 matching lines...) Expand all
706 715
707 # We're looking for a sequence of letters which start with capital letter 716 # We're looking for a sequence of letters which start with capital letter
708 # then a series of caps and finishes with either the end of the string or 717 # then a series of caps and finishes with either the end of the string or
709 # a capital letter. 718 # a capital letter.
710 # The [0-9] check is for names such as 2D or 3D 719 # The [0-9] check is for names such as 2D or 3D
711 # The following test cases should match as: 720 # The following test cases should match as:
712 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 721 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
713 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 722 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
714 # IFrameElement: (I)()(F)rameElement (no change) 723 # IFrameElement: (I)()(F)rameElement (no change)
715 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 724 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698