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

Side by Side Diff: lib/html/scripts/htmlrenamer.py

Issue 10957066: Reapply 12799. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | « lib/html/scripts/generator.py ('k') | lib/html/scripts/systemdart2js.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 5
6 _html_interface_renames = { 6 html_interface_renames = {
7 'DOMFormData': 'FormData', 7 'DOMFormData': 'FormData',
8 'DOMWindow': 'Window', 8 'DOMWindow': 'Window',
9 'WebKitAnimation': 'Animation', 9 'WebKitAnimation': 'Animation',
10 'WebKitAnimationEvent': 'AnimationEvent', 10 'WebKitAnimationEvent': 'AnimationEvent',
11 'WebKitAnimationList': 'AnimationList', 11 'WebKitAnimationList': 'AnimationList',
12 'WebKitBlobBuilder': 'BlobBuilder', 12 'WebKitBlobBuilder': 'BlobBuilder',
13 'WebKitCSSKeyframeRule': 'CSSKeyframeRule', 13 'WebKitCSSKeyframeRule': 'CSSKeyframeRule',
14 'WebKitCSSKeyframesRule': 'CSSKeyframesRule', 14 'WebKitCSSKeyframesRule': 'CSSKeyframesRule',
15 'WebKitCSSMatrix': 'CSSMatrix', 15 'WebKitCSSMatrix': 'CSSMatrix',
16 'WebKitCSSTransformValue': 'CSSTransformValue', 16 'WebKitCSSTransformValue': 'CSSTransformValue',
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 271
272 class HtmlRenamer(object): 272 class HtmlRenamer(object):
273 def __init__(self, database): 273 def __init__(self, database):
274 self._database = database 274 self._database = database
275 275
276 def RenameInterface(self, interface): 276 def RenameInterface(self, interface):
277 if interface.id.startswith('HTML'): 277 if interface.id.startswith('HTML'):
278 if any(interface.id in ['Element', 'Document'] 278 if any(interface.id in ['Element', 'Document']
279 for interface in self._database.Hierarchy(interface)): 279 for interface in self._database.Hierarchy(interface)):
280 return interface.id[len('HTML'):] 280 return interface.id[len('HTML'):]
281 elif interface.id in _html_interface_renames: 281 elif interface.id in html_interface_renames:
282 return _html_interface_renames[interface.id] 282 return html_interface_renames[interface.id]
283 return interface.id 283 return interface.id
284 284
285 def RenameMember(self, interface_name, member, member_prefix=''): 285 def RenameMember(self, interface_name, member, member_prefix=''):
286 """ 286 """
287 Returns the name of the member in the HTML library or None if the member is 287 Returns the name of the member in the HTML library or None if the member is
288 suppressed in the HTML library 288 suppressed in the HTML library
289 """ 289 """
290 interface = self._database.GetInterface(interface_name) 290 interface = self._database.GetInterface(interface_name)
291 291
292 if self._FindMatch(interface, member, member_prefix, _removed_html_members): 292 if self._FindMatch(interface, member, member_prefix, _removed_html_members):
293 return None 293 return None
294 294
295 name = self._FindMatch(interface, member, member_prefix, 295 name = self._FindMatch(interface, member, member_prefix,
296 _renamed_html_members) 296 _renamed_html_members)
297 target_name = _renamed_html_members[name] if name else member 297 target_name = _renamed_html_members[name] if name else member
298 if self._FindMatch(interface, member, member_prefix, _private_html_members): 298 if self._FindMatch(interface, member, member_prefix, _private_html_members):
299 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName 299 if not target_name.startswith('$dom_'): # e.g. $dom_svgClassName
300 target_name = '$dom_' + target_name 300 target_name = '$dom_' + target_name
301 return target_name 301 return target_name
302 302
303 def _FindMatch(self, interface, member, member_prefix, candidates): 303 def _FindMatch(self, interface, member, member_prefix, candidates):
304 for interface in self._database.Hierarchy(interface): 304 for interface in self._database.Hierarchy(interface):
305 html_interface_name = self.RenameInterface(interface) 305 html_interface_name = self.RenameInterface(interface)
306 member_name = html_interface_name + '.' + member 306 member_name = html_interface_name + '.' + member
307 if member_name in candidates: 307 if member_name in candidates:
308 return member_name 308 return member_name
309 member_name = html_interface_name + '.' + member_prefix + member 309 member_name = html_interface_name + '.' + member_prefix + member
310 if member_name in candidates: 310 if member_name in candidates:
311 return member_name 311 return member_name
OLDNEW
« no previous file with comments | « lib/html/scripts/generator.py ('k') | lib/html/scripts/systemdart2js.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698