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

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

Issue 12163009: Remove webkit prefix and annotate with experimental tag. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 'UIEvent.keyCode', 174 'UIEvent.keyCode',
175 'WheelEvent.wheelDeltaX', 175 'WheelEvent.wheelDeltaX',
176 'WheelEvent.wheelDeltaY', 176 'WheelEvent.wheelDeltaY',
177 'WheelEvent.initWebKitWheelEvent', 177 'WheelEvent.initWebKitWheelEvent',
178 'DOMWindow.getComputedStyle', 178 'DOMWindow.getComputedStyle',
179 ]) 179 ])
180 180
181 # Members from the standard dom that exist in the dart:html library with 181 # Members from the standard dom that exist in the dart:html library with
182 # identical functionality but with cleaner names. 182 # identical functionality but with cleaner names.
183 _renamed_html_members = monitored.Dict('htmlrenamer._renamed_html_members', { 183 _renamed_html_members = monitored.Dict('htmlrenamer._renamed_html_members', {
184 'Document.createCDATASection': 'createCDataSection',
185 'Document.defaultView': 'window',
184 'DOMURL.createObjectURL': 'createObjectUrl', 186 'DOMURL.createObjectURL': 'createObjectUrl',
185 'DOMURL.revokeObjectURL': 'revokeObjectUrl', 187 'DOMURL.revokeObjectURL': 'revokeObjectUrl',
186 'DOMWindow.webkitConvertPointFromNodeToPage': 'convertPointFromNodeToPage', 188 'DOMWindow.webkitConvertPointFromNodeToPage': 'convertPointFromNodeToPage',
187 'DOMWindow.webkitConvertPointFromPageToNode': 'convertPointFromPageToNode', 189 'DOMWindow.webkitConvertPointFromPageToNode': 'convertPointFromPageToNode',
188 'DOMWindow.webkitNotifications': 'notifications', 190 'DOMWindow.webkitNotifications': 'notifications',
189 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem', 191 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem',
190 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl', 192 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
191 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem', 193 'DOMWindow.webkitRequestFileSystem': 'requestFileSystem',
192 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl', 194 'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
193 'Document.createCDATASection': 'createCDataSection',
194 'Document.defaultView': 'window',
195 'Element.scrollIntoViewIfNeeded': 'scrollIntoView', 195 'Element.scrollIntoViewIfNeeded': 'scrollIntoView',
196 'Element.webkitCreateShadowRoot': 'createShadowRoot', 196 'Element.webkitCreateShadowRoot': 'createShadowRoot',
197 'Element.webkitMatchesSelector' : 'matches', 197 'Element.webkitMatchesSelector' : 'matches',
198 'Navigator.webkitGetUserMedia': '_getUserMedia', 198 'Navigator.webkitGetUserMedia': '_getUserMedia',
199 'Node.cloneNode': 'clone', 199 'Node.cloneNode': 'clone',
200 'Node.nextSibling': 'nextNode', 200 'Node.nextSibling': 'nextNode',
201 'Node.ownerDocument': 'document', 201 'Node.ownerDocument': 'document',
202 'Node.parentElement': 'parent', 202 'Node.parentElement': 'parent',
203 'Node.previousSibling': 'previousNode', 203 'Node.previousSibling': 'previousNode',
204 'Node.textContent': 'text', 204 'Node.textContent': 'text',
205 'SVGElement.className': '$dom_svgClassName', 205 'SVGElement.className': '$dom_svgClassName',
206 'WorkerContext.webkitRequestFileSystem': 'requestFileSystem', 206 'WorkerContext.webkitRequestFileSystem': 'requestFileSystem',
207 'WorkerContext.webkitRequestFileSystemSync': 'requestFileSystemSync', 207 'WorkerContext.webkitRequestFileSystemSync': 'requestFileSystemSync',
208 'WorkerContext.webkitResolveLocalFileSystemSyncURL': 208 'WorkerContext.webkitResolveLocalFileSystemSyncURL':
209 'resolveLocalFileSystemSyncUrl', 209 'resolveLocalFileSystemSyncUrl',
210 'WorkerContext.webkitResolveLocalFileSystemURL': 210 'WorkerContext.webkitResolveLocalFileSystemURL':
211 'resolveLocalFileSystemUrl', 211 'resolveLocalFileSystemUrl',
212 }) 212 })
213 213
214 # Autopopulated by members that start with webkit that were not explicitly
215 # listed.
216 webkit_member_prefix_renames = set()
217
214 # Members and classes from the dom that should be removed completely from 218 # Members and classes from the dom that should be removed completely from
215 # dart:html. These could be expressed in the IDL instead but expressing this 219 # dart:html. These could be expressed in the IDL instead but expressing this
216 # as a simple table instead is more concise. 220 # as a simple table instead is more concise.
217 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName 221 # Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName
218 # Using get: and set: is optional and should only be used when a getter needs 222 # Using get: and set: is optional and should only be used when a getter needs
219 # to be suppressed but not the setter, etc. 223 # to be suppressed but not the setter, etc.
220 # TODO(jacobr): cleanup and augment this list. 224 # TODO(jacobr): cleanup and augment this list.
221 _removed_html_members = monitored.Set('htmlrenamer._removed_html_members', [ 225 _removed_html_members = monitored.Set('htmlrenamer._removed_html_members', [
222 'Attr.*', 226 'Attr.*',
223 'CanvasRenderingContext2D.clearShadow', 227 'CanvasRenderingContext2D.clearShadow',
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 return None 513 return None
510 514
511 name = self._FindMatch(interface, member, member_prefix, 515 name = self._FindMatch(interface, member, member_prefix,
512 _renamed_html_members) 516 _renamed_html_members)
513 517
514 target_name = _renamed_html_members[name] if name else member 518 target_name = _renamed_html_members[name] if name else member
515 if self._FindMatch(interface, member, member_prefix, _private_html_members): 519 if self._FindMatch(interface, member, member_prefix, _private_html_members):
516 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName 520 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName
517 target_name = '$dom_' + target_name 521 target_name = '$dom_' + target_name
518 522
523 if not name and target_name.startswith('webkit'):
524 webkit_member_prefix_renames.add('%s.%s' % (interface.id, member))
525 target_name = member[len('webkit'):]
526 target_name = target_name[:1].lower() + target_name[1:]
527
519 if dartify_name: 528 if dartify_name:
520 target_name = self._DartifyMemberName(target_name) 529 target_name = self._DartifyMemberName(target_name)
521 return target_name 530 return target_name
522 531
523 def ShouldSuppressMember(self, interface, member, member_prefix=''): 532 def ShouldSuppressMember(self, interface, member, member_prefix=''):
524 """ Returns true if the member should be suppressed.""" 533 """ Returns true if the member should be suppressed."""
525 if self._FindMatch(interface, member, member_prefix, 534 if self._FindMatch(interface, member, member_prefix,
526 _removed_html_members): 535 _removed_html_members):
527 return True 536 return True
528 return False 537 return False
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 583
575 # We're looking for a sequence of letters which start with capital letter 584 # We're looking for a sequence of letters which start with capital letter
576 # then a series of caps and finishes with either the end of the string or 585 # then a series of caps and finishes with either the end of the string or
577 # a capital letter. 586 # a capital letter.
578 # The [0-9] check is for names such as 2D or 3D 587 # The [0-9] check is for names such as 2D or 3D
579 # The following test cases should match as: 588 # The following test cases should match as:
580 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue 589 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
581 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change) 590 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
582 # IFrameElement: (I)()(F)rameElement (no change) 591 # IFrameElement: (I)()(F)rameElement (no change)
583 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name) 592 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698