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

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

Issue 12022027: Fixing up Navigator.getUserMedia. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes. Created 7 years, 11 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 | « tests/html/media_stream_test.dart ('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 'DOMApplicationCache': 'ApplicationCache', 11 'DOMApplicationCache': 'ApplicationCache',
12 'DOMCoreException': 'DomException', 12 'DOMCoreException': 'DomException',
13 'DOMFileSystem': 'FileSystem', 13 'DOMFileSystem': 'FileSystem',
14 'DOMFileSystemSync': 'FileSystemSync', 14 'DOMFileSystemSync': 'FileSystemSync',
15 'DOMFormData': 'FormData', 15 'DOMFormData': 'FormData',
16 'DOMURL': 'Url', 16 'DOMURL': 'Url',
17 'DOMWindow': 'Window', 17 'DOMWindow': 'Window',
18 'HTMLAppletElement' : '_AppletElement', 18 'HTMLAppletElement' : '_AppletElement',
19 'HTMLBaseFontElement' : '_BaseFontElement', 19 'HTMLBaseFontElement' : '_BaseFontElement',
20 'HTMLDirectoryElement' : '_DirectoryElement', 20 'HTMLDirectoryElement' : '_DirectoryElement',
21 'HTMLDocument' : 'HtmlDocument', 21 'HTMLDocument' : 'HtmlDocument',
22 'HTMLFontElement' : '_FontElement', 22 'HTMLFontElement' : '_FontElement',
23 'HTMLFrameElement' : '_FrameElement', 23 'HTMLFrameElement' : '_FrameElement',
24 'HTMLFrameSetElement' : '_FrameSetElement', 24 'HTMLFrameSetElement' : '_FrameSetElement',
25 'HTMLMarqueeElement' : '_MarqueeElement', 25 'HTMLMarqueeElement' : '_MarqueeElement',
26 'IDBAny': '_Any', # Suppressed, but needs to exist for Dartium. 26 'IDBAny': '_Any', # Suppressed, but needs to exist for Dartium.
27 'IDBFactory': 'IdbFactory', # Manual to avoid name conflicts. 27 'IDBFactory': 'IdbFactory', # Manual to avoid name conflicts.
28 'NavigatorUserMediaErrorCallback': '_NavigatorUserMediaErrorCallback',
29 'NavigatorUserMediaSuccessCallback': '_NavigatorUserMediaSuccessCallback',
28 'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts. 30 'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts.
29 'SVGElement': 'SvgElement', # Manual to avoid name conflicts. 31 'SVGElement': 'SvgElement', # Manual to avoid name conflicts.
30 'SVGException': 'SvgException', # Manual of avoid conflict with Exception. 32 'SVGException': 'SvgException', # Manual of avoid conflict with Exception.
31 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts. 33 'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts.
32 'WebGLVertexArrayObjectOES': 'WebGLVertexArrayObject', 34 'WebGLVertexArrayObjectOES': 'WebGLVertexArrayObject',
33 'WebKitAnimationEvent': 'AnimationEvent', 35 'WebKitAnimationEvent': 'AnimationEvent',
34 'WebKitCSSKeyframeRule': 'CssKeyframeRule', 36 'WebKitCSSKeyframeRule': 'CssKeyframeRule',
35 'WebKitCSSKeyframesRule': 'CssKeyframesRule', 37 'WebKitCSSKeyframesRule': 'CssKeyframesRule',
36 'WebKitCSSMatrix': 'CssMatrix', 38 'WebKitCSSMatrix': 'CssMatrix',
37 'WebKitCSSTransformValue': 'CssTransformValue', 39 'WebKitCSSTransformValue': 'CssTransformValue',
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 'DOMWindow.webkitNotifications': 'notifications', 150 'DOMWindow.webkitNotifications': 'notifications',
149 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem', 151 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem',
150 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl', 152 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
151 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem', 153 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem',
152 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl', 154 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
153 'Document.createCDATASection': 'createCDataSection', 155 'Document.createCDATASection': 'createCDataSection',
154 'Document.defaultView': 'window', 156 'Document.defaultView': 'window',
155 'Element.scrollIntoViewIfNeeded': 'scrollIntoView', 157 'Element.scrollIntoViewIfNeeded': 'scrollIntoView',
156 'Element.webkitCreateShadowRoot': 'createShadowRoot', 158 'Element.webkitCreateShadowRoot': 'createShadowRoot',
157 'Element.webkitMatchesSelector' : 'matches', 159 'Element.webkitMatchesSelector' : 'matches',
160 'Navigator.webkitGetUserMedia': '_getUserMedia',
158 'Node.cloneNode': 'clone', 161 'Node.cloneNode': 'clone',
159 'Node.nextSibling': 'nextNode', 162 'Node.nextSibling': 'nextNode',
160 'Node.ownerDocument': 'document', 163 'Node.ownerDocument': 'document',
161 'Node.parentElement': 'parent', 164 'Node.parentElement': 'parent',
162 'Node.previousSibling': 'previousNode', 165 'Node.previousSibling': 'previousNode',
163 'Node.textContent': 'text', 166 'Node.textContent': 'text',
164 'SVGElement.className': '$dom_svgClassName', 167 'SVGElement.className': '$dom_svgClassName',
165 'SVGStylable.className': '$dom_svgClassName', 168 'SVGStylable.className': '$dom_svgClassName',
166 'WorkerContext.webkitRequestFileSystem': 'requestFileSystem', 169 'WorkerContext.webkitRequestFileSystem': 'requestFileSystem',
167 'WorkerContext.webkitRequestFileSystemSync': 'requestFileSystemSync', 170 'WorkerContext.webkitRequestFileSystemSync': 'requestFileSystemSync',
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 if 'SVG' in interface.ext_attrs['Conditional']: 508 if 'SVG' in interface.ext_attrs['Conditional']:
506 return 'svg' 509 return 'svg'
507 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']: 510 if 'INDEXED_DATABASE' in interface.ext_attrs['Conditional']:
508 return 'indexed_db' 511 return 'indexed_db'
509 512
510 return 'html' 513 return 'html'
511 514
512 def DartifyTypeName(self, type_name): 515 def DartifyTypeName(self, type_name):
513 """Converts a DOM name to a Dart-friendly class name. """ 516 """Converts a DOM name to a Dart-friendly class name. """
514 517
518 if type_name in html_interface_renames:
519 return html_interface_renames[type_name]
520
515 # Strip off any standard prefixes. 521 # Strip off any standard prefixes.
516 name = re.sub(r'^SVG', '', type_name) 522 name = re.sub(r'^SVG', '', type_name)
517 name = re.sub(r'^IDB', '', name) 523 name = re.sub(r'^IDB', '', name)
518 524
519 return self._CamelCaseName(name) 525 return self._CamelCaseName(name)
520 526
521 def _DartifyMemberName(self, member_name): 527 def _DartifyMemberName(self, member_name):
522 # Strip off any OpenGL ES suffixes. 528 # Strip off any OpenGL ES suffixes.
523 name = re.sub(r'OES$', '', member_name) 529 name = re.sub(r'OES$', '', member_name)
524 return self._CamelCaseName(name) 530 return self._CamelCaseName(name)
525 531
526 def _CamelCaseName(self, name): 532 def _CamelCaseName(self, name):
527 533
528 def toLower(match): 534 def toLower(match):
529 return match.group(1) + match.group(2).lower() + match.group(3) 535 return match.group(1) + match.group(2).lower() + match.group(3)
530 536
531 # We're looking for a sequence of letters which start with capital letter 537 # We're looking for a sequence of letters which start with capital letter
532 # then a series of caps and finishes with either the end of the string or 538 # then a series of caps and finishes with either the end of the string or
533 # a capital letter. 539 # a capital letter.
534 # The [0-9] check is for names such as 2D or 3D 540 # The [0-9] check is for names such as 2D or 3D
535 # The following test cases should match as: 541 # The following test cases should match as:
536 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 542 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
537 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 543 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
538 # IFrameElement: (I)()(F)rameElement (no change) 544 # IFrameElement: (I)()(F)rameElement (no change)
539 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 545 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name)
OLDNEW
« no previous file with comments | « tests/html/media_stream_test.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698