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

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 again? 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 'NodeList.item', 135 'NodeList.item',
115 "Attr.*", 136 "Attr.*",
116 # "BarProp.*", 137 # "BarProp.*",
117 # "BarInfo.*", 138 # "BarInfo.*",
118 # "Blob.webkitSlice", 139 # "Blob.webkitSlice",
119 # "CDATASection.*", 140 # "CDATASection.*",
120 # "Comment.*", 141 # "Comment.*",
121 # "DOMImplementation.*", 142 # "DOMImplementation.*",
122 "CanvasRenderingContext2D.setFillColor", 143 "CanvasRenderingContext2D.setFillColor",
123 "CanvasRenderingContext2D.setStrokeColor", 144 "CanvasRenderingContext2D.setStrokeColor",
145 'Document.applets',
124 "Document.get:forms", 146 "Document.get:forms",
125 # "Document.get:selectedStylesheetSet", 147 # "Document.get:selectedStylesheetSet",
126 # "Document.set:selectedStylesheetSet", 148 # "Document.set:selectedStylesheetSet",
127 # "Document.get:preferredStylesheetSet", 149 # "Document.get:preferredStylesheetSet",
128 "Document.get:links", 150 "Document.get:links",
129 "Document.set:domain", 151 "Document.set:domain",
130 "Document.createAttributeNS", 152 "Document.createAttributeNS",
131 "Document.get:inputEncoding", 153 "Document.get:inputEncoding",
132 "Document.get:height", 154 "Document.get:height",
133 "Document.get:width", 155 "Document.get:width",
134 "Element.getElementsByTagNameNS", 156 "Element.getElementsByTagNameNS",
135 "Document.get:compatMode", 157 "Document.get:compatMode",
158 'Document.images',
136 "Document.importNode", 159 "Document.importNode",
137 "Document.evaluate", 160 "Document.evaluate",
138 "Document.get:images", 161 "Document.get:images",
139 "Document.createExpression", 162 "Document.createExpression",
140 "Document.getOverrideStyle", 163 "Document.getOverrideStyle",
141 "Document.xmlStandalone", 164 "Document.xmlStandalone",
142 "Document.createComment", 165 "Document.createComment",
143 "Document.adoptNode", 166 "Document.adoptNode",
144 "Document.get:characterSet", 167 "Document.get:characterSet",
145 "Document.createAttribute", 168 "Document.createAttribute",
146 "Document.get:URL", 169 "Document.get:URL",
147 "Document.createEntityReference", 170 "Document.createEntityReference",
148 "Document.get:documentURI", 171 "Document.get:documentURI",
149 "Document.set:documentURI", 172 "Document.set:documentURI",
150 "Document.createNodeIterator", 173 "Document.createNodeIterator",
151 "Document.createProcessingInstruction", 174 "Document.createProcessingInstruction",
152 "Document.get:doctype", 175 "Document.get:doctype",
153 "Document.createTreeWalker", 176 "Document.createTreeWalker",
154 "Document.location", 177 "Document.location",
155 "Document.createNSResolver", 178 "Document.createNSResolver",
156 "Document.get:xmlEncoding", 179 "Document.get:xmlEncoding",
157 "Document.get:defaultCharset", 180 "Document.get:defaultCharset",
158 "Document.get:applets", 181 "Document.get:applets",
159 "Document.getSelection", 182 "Document.getSelection",
160 "Document.xmlVersion", 183 "Document.xmlVersion",
161 "Document.get:anchors", 184 "Document.get:anchors",
162 "Document.getElementsByTagNameNS", 185 "Document.getElementsByTagNameNS",
186 'Document.webkitCurrentFullScreenElement',
187 'Document.webkitFullScreenKeyboardInputAllowed',
163 "DocumentType.*", 188 "DocumentType.*",
164 "Element.hasAttributeNS", 189 "Element.hasAttributeNS",
165 "Element.getAttributeNS", 190 "Element.getAttributeNS",
166 "Element.setAttributeNode", 191 "Element.setAttributeNode",
167 "Element.getAttributeNode", 192 "Element.getAttributeNode",
168 "Element.removeAttributeNode", 193 "Element.removeAttributeNode",
169 "Element.removeAttributeNS", 194 "Element.removeAttributeNS",
170 "Element.setAttributeNodeNS", 195 "Element.setAttributeNodeNS",
171 "Element.getAttributeNodeNS", 196 "Element.getAttributeNodeNS",
172 "Element.setAttributeNS", 197 "Element.setAttributeNS",
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 "LocalWindow.prompt", 291 "LocalWindow.prompt",
267 "LocalWindow.webkitCancelRequestAnimationFrame", 292 "LocalWindow.webkitCancelRequestAnimationFrame",
268 "WheelEvent.wheelDelta", 293 "WheelEvent.wheelDelta",
269 ]) 294 ])
270 295
271 class HtmlRenamer(object): 296 class HtmlRenamer(object):
272 def __init__(self, database): 297 def __init__(self, database):
273 self._database = database 298 self._database = database
274 299
275 def RenameInterface(self, interface): 300 def RenameInterface(self, interface):
276 if interface.id.startswith('HTML'): 301 if interface.id in html_interface_renames:
302 return html_interface_renames[interface.id]
303 elif interface.id.startswith('HTML'):
277 if any(interface.id in ['Element', 'Document'] 304 if any(interface.id in ['Element', 'Document']
278 for interface in self._database.Hierarchy(interface)): 305 for interface in self._database.Hierarchy(interface)):
279 return interface.id[len('HTML'):] 306 return interface.id[len('HTML'):]
280 elif interface.id in html_interface_renames:
281 return html_interface_renames[interface.id]
282 return interface.id 307 return interface.id
283 308
284 def RenameMember(self, interface_name, member_node, member, member_prefix=''): 309 def RenameMember(self, interface_name, member_node, member, member_prefix=''):
285 """ 310 """
286 Returns the name of the member in the HTML library or None if the member is 311 Returns the name of the member in the HTML library or None if the member is
287 suppressed in the HTML library 312 suppressed in the HTML library
288 """ 313 """
289 interface = self._database.GetInterface(interface_name) 314 interface = self._database.GetInterface(interface_name)
290 315
291 if self._FindMatch(interface, member, member_prefix, _removed_html_members): 316 if self._FindMatch(interface, member, member_prefix, _removed_html_members):
(...skipping 17 matching lines...) Expand all
309 if member_name in candidates: 334 if member_name in candidates:
310 return member_name 335 return member_name
311 member_name = html_interface_name + '.' + member_prefix + member 336 member_name = html_interface_name + '.' + member_prefix + member
312 if member_name in candidates: 337 if member_name in candidates:
313 return member_name 338 return member_name
314 339
315 def GetLibraryName(self, interface): 340 def GetLibraryName(self, interface):
316 if interface.id.startswith('SVG'): 341 if interface.id.startswith('SVG'):
317 return 'svg' 342 return 'svg'
318 return 'html' 343 return 'html'
OLDNEW
« no previous file with comments | « sdk/lib/html/scripts/generator.py ('k') | sdk/lib/html/templates/html/dart2js/html_dart2js.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698