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

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

Issue 11365203: Unmerging HTMLDocument from Document. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Try #2. Created 8 years, 1 month 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 5
6 html_interface_renames = { 6 html_interface_renames = {
7 'DOMCoreException': 'DOMException', 7 'DOMCoreException': 'DOMException',
8 'DOMFormData': 'FormData', 8 'DOMFormData': 'FormData',
9 'DOMURL': 'Url', 9 'DOMURL': 'Url',
10 'DOMWindow': 'LocalWindow', 10 'DOMWindow': 'LocalWindow',
11 'History': 'LocalHistory', 11 'History': 'LocalHistory',
12 'HTMLDocument' : 'HtmlDocument',
12 'Location': 'LocalLocation', 13 'Location': 'LocalLocation',
13 'WebKitAnimation': 'Animation', 14 'WebKitAnimation': 'Animation',
14 'WebKitAnimationEvent': 'AnimationEvent', 15 'WebKitAnimationEvent': 'AnimationEvent',
15 'WebKitBlobBuilder': 'BlobBuilder', 16 'WebKitBlobBuilder': 'BlobBuilder',
16 'WebKitCSSKeyframeRule': 'CSSKeyframeRule', 17 'WebKitCSSKeyframeRule': 'CSSKeyframeRule',
17 'WebKitCSSKeyframesRule': 'CSSKeyframesRule', 18 'WebKitCSSKeyframesRule': 'CSSKeyframesRule',
18 'WebKitCSSMatrix': 'CSSMatrix', 19 'WebKitCSSMatrix': 'CSSMatrix',
19 'WebKitCSSTransformValue': 'CSSTransformValue', 20 'WebKitCSSTransformValue': 'CSSTransformValue',
20 'WebKitFlags': 'Flags', 21 'WebKitFlags': 'Flags',
21 'WebKitLoseContext': 'LoseContext', 22 'WebKitLoseContext': 'LoseContext',
22 'WebKitPoint': 'Point', 23 'WebKitPoint': 'Point',
23 'WebKitTransitionEvent': 'TransitionEvent', 24 'WebKitTransitionEvent': 'TransitionEvent',
24 'XMLHttpRequest': 'HttpRequest', 25 'XMLHttpRequest': 'HttpRequest',
25 'XMLHttpRequestException': 'HttpRequestException', 26 'XMLHttpRequestException': 'HttpRequestException',
26 'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent', 27 'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent',
27 'XMLHttpRequestUpload': 'HttpRequestUpload', 28 'XMLHttpRequestUpload': 'HttpRequestUpload',
28 } 29 }
29 30
30 # Members from the standard dom that should not be exposed publicly in dart:html 31 # Members from the standard dom that should not be exposed publicly in dart:html
31 # but need to be exposed internally to implement dart:html on top of a standard 32 # but need to be exposed internally to implement dart:html on top of a standard
32 # browser. 33 # browser.
33 _private_html_members = set([ 34 _private_html_members = set([
34 'CustomEvent.initCustomEvent', 35 'CustomEvent.initCustomEvent',
35 'Document.createElement', 36 'Document.createElement',
36 'Document.createElementNS', 37 'Document.createElementNS',
37 'Document.createEvent', 38 'Document.createEvent',
38 'Document.createTextNode', 39 'Document.createTextNode',
39 'Document.createTouchList', 40 'Document.createTouchList',
40 'DocumentFragment.querySelector',
41 'DocumentFragment.querySelectorAll',
42 'Document.getElementById', 41 'Document.getElementById',
43 'Document.getElementsByClassName', 42 'Document.getElementsByClassName',
44 'Document.getElementsByName', 43 'Document.getElementsByName',
45 'Document.getElementsByTagName', 44 'Document.getElementsByTagName',
46 'Document.querySelector', 45 'Document.querySelector',
47 'Document.querySelectorAll', 46 'Document.querySelectorAll',
47
48 # Moved to HTMLDocument.
49 'Document.body',
50 'Document.caretRangeFromPoint',
51 'Document.elementFromPoint',
52 'Document.head',
53 'Document.lastModified',
54 'Document.referrer',
55 'Document.styleSheets',
56 'Document.title',
57 'Document.webkitCancelFullScreen',
58 'Document.webkitExitFullscreen',
59 'Document.webkitExitPointerLock',
60 'Document.webkitFullscreenElement',
61 'Document.webkitFullscreenEnabled',
62 'Document.webkitHidden',
63 'Document.webkitIsFullScreen',
64 'Document.webkitPointerLockElement',
65 'Document.webkitVisibilityState',
66
67 'DocumentFragment.querySelector',
68 'DocumentFragment.querySelectorAll',
48 'Element.childElementCount', 69 'Element.childElementCount',
49 'Element.children', 70 'Element.children',
50 'Element.className', 71 'Element.className',
51 'Element.firstElementChild', 72 'Element.firstElementChild',
52 'Element.getAttribute', 73 'Element.getAttribute',
53 'Element.getElementsByClassName', 74 'Element.getElementsByClassName',
54 'Element.getElementsByTagName', 75 'Element.getElementsByTagName',
55 'Element.hasAttribute', 76 'Element.hasAttribute',
56 'Element.lastElementChild', 77 'Element.lastElementChild',
57 'Element.querySelector', 78 'Element.querySelector',
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 'NodeList.item', 136 'NodeList.item',
116 "Attr.*", 137 "Attr.*",
117 # "BarProp.*", 138 # "BarProp.*",
118 # "BarInfo.*", 139 # "BarInfo.*",
119 # "Blob.webkitSlice", 140 # "Blob.webkitSlice",
120 # "CDATASection.*", 141 # "CDATASection.*",
121 # "Comment.*", 142 # "Comment.*",
122 # "DOMImplementation.*", 143 # "DOMImplementation.*",
123 "CanvasRenderingContext2D.setFillColor", 144 "CanvasRenderingContext2D.setFillColor",
124 "CanvasRenderingContext2D.setStrokeColor", 145 "CanvasRenderingContext2D.setStrokeColor",
146 'Document.applets',
125 "Document.get:forms", 147 "Document.get:forms",
126 # "Document.get:selectedStylesheetSet", 148 # "Document.get:selectedStylesheetSet",
127 # "Document.set:selectedStylesheetSet", 149 # "Document.set:selectedStylesheetSet",
128 # "Document.get:preferredStylesheetSet", 150 # "Document.get:preferredStylesheetSet",
129 "Document.get:links", 151 "Document.get:links",
130 "Document.set:domain", 152 "Document.set:domain",
131 "Document.createAttributeNS", 153 "Document.createAttributeNS",
132 "Document.get:inputEncoding", 154 "Document.get:inputEncoding",
133 "Document.get:height", 155 "Document.get:height",
134 "Document.get:width", 156 "Document.get:width",
135 "Element.getElementsByTagNameNS", 157 "Element.getElementsByTagNameNS",
136 "Document.get:compatMode", 158 "Document.get:compatMode",
159 'Document.images',
137 "Document.importNode", 160 "Document.importNode",
138 "Document.evaluate", 161 "Document.evaluate",
139 "Document.get:images", 162 "Document.get:images",
140 "Document.createExpression", 163 "Document.createExpression",
141 "Document.getOverrideStyle", 164 "Document.getOverrideStyle",
142 "Document.xmlStandalone", 165 "Document.xmlStandalone",
143 "Document.createComment", 166 "Document.createComment",
144 "Document.adoptNode", 167 "Document.adoptNode",
145 "Document.get:characterSet", 168 "Document.get:characterSet",
146 "Document.createAttribute", 169 "Document.createAttribute",
147 "Document.get:URL", 170 "Document.get:URL",
148 "Document.createEntityReference", 171 "Document.createEntityReference",
149 "Document.get:documentURI", 172 "Document.get:documentURI",
150 "Document.set:documentURI", 173 "Document.set:documentURI",
151 "Document.createNodeIterator", 174 "Document.createNodeIterator",
152 "Document.createProcessingInstruction", 175 "Document.createProcessingInstruction",
153 "Document.get:doctype", 176 "Document.get:doctype",
154 "Document.createTreeWalker", 177 "Document.createTreeWalker",
155 "Document.location", 178 "Document.location",
156 "Document.createNSResolver", 179 "Document.createNSResolver",
157 "Document.get:xmlEncoding", 180 "Document.get:xmlEncoding",
158 "Document.get:defaultCharset", 181 "Document.get:defaultCharset",
159 "Document.get:applets", 182 "Document.get:applets",
160 "Document.getSelection", 183 "Document.getSelection",
161 "Document.xmlVersion", 184 "Document.xmlVersion",
162 "Document.get:anchors", 185 "Document.get:anchors",
163 "Document.getElementsByTagNameNS", 186 "Document.getElementsByTagNameNS",
187 'Document.webkitCurrentFullScreenElement',
188 'Document.webkitFullScreenKeyboardInputAllowed',
164 "DocumentType.*", 189 "DocumentType.*",
165 "Element.hasAttributeNS", 190 "Element.hasAttributeNS",
166 "Element.getAttributeNS", 191 "Element.getAttributeNS",
167 "Element.setAttributeNode", 192 "Element.setAttributeNode",
168 "Element.getAttributeNode", 193 "Element.getAttributeNode",
169 "Element.removeAttributeNode", 194 "Element.removeAttributeNode",
170 "Element.removeAttributeNS", 195 "Element.removeAttributeNS",
171 "Element.setAttributeNodeNS", 196 "Element.setAttributeNodeNS",
172 "Element.getAttributeNodeNS", 197 "Element.getAttributeNodeNS",
173 "Element.setAttributeNS", 198 "Element.setAttributeNS",
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 "LocalWindow.get:length", 289 "LocalWindow.get:length",
265 "LocalWindow.webkitCancelRequestAnimationFrame", 290 "LocalWindow.webkitCancelRequestAnimationFrame",
266 "WheelEvent.wheelDelta", 291 "WheelEvent.wheelDelta",
267 ]) 292 ])
268 293
269 class HtmlRenamer(object): 294 class HtmlRenamer(object):
270 def __init__(self, database): 295 def __init__(self, database):
271 self._database = database 296 self._database = database
272 297
273 def RenameInterface(self, interface): 298 def RenameInterface(self, interface):
274 if interface.id.startswith('HTML'): 299 if interface.id in html_interface_renames:
300 return html_interface_renames[interface.id]
301 elif interface.id.startswith('HTML'):
275 if any(interface.id in ['Element', 'Document'] 302 if any(interface.id in ['Element', 'Document']
276 for interface in self._database.Hierarchy(interface)): 303 for interface in self._database.Hierarchy(interface)):
277 return interface.id[len('HTML'):] 304 return interface.id[len('HTML'):]
278 elif interface.id in html_interface_renames:
279 return html_interface_renames[interface.id]
280 return interface.id 305 return interface.id
281 306
282 def RenameMember(self, interface_name, member_node, member, member_prefix=''): 307 def RenameMember(self, interface_name, member_node, member, member_prefix=''):
283 """ 308 """
284 Returns the name of the member in the HTML library or None if the member is 309 Returns the name of the member in the HTML library or None if the member is
285 suppressed in the HTML library 310 suppressed in the HTML library
286 """ 311 """
287 interface = self._database.GetInterface(interface_name) 312 interface = self._database.GetInterface(interface_name)
288 313
289 if self._FindMatch(interface, member, member_prefix, _removed_html_members): 314 if self._FindMatch(interface, member, member_prefix, _removed_html_members):
(...skipping 12 matching lines...) Expand all
302 327
303 def _FindMatch(self, interface, member, member_prefix, candidates): 328 def _FindMatch(self, interface, member, member_prefix, candidates):
304 for interface in self._database.Hierarchy(interface): 329 for interface in self._database.Hierarchy(interface):
305 html_interface_name = self.RenameInterface(interface) 330 html_interface_name = self.RenameInterface(interface)
306 member_name = html_interface_name + '.' + member 331 member_name = html_interface_name + '.' + member
307 if member_name in candidates: 332 if member_name in candidates:
308 return member_name 333 return member_name
309 member_name = html_interface_name + '.' + member_prefix + member 334 member_name = html_interface_name + '.' + member_prefix + member
310 if member_name in candidates: 335 if member_name in candidates:
311 return member_name 336 return member_name
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698