Flutter Engine
The Flutter Engine
htmlrenamer.py
Go to the documentation of this file.
1#!/usr/bin/env python3
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
4# BSD-style license that can be found in the LICENSE file.
5import logging
6import monitored
7import re
8
9typed_array_renames = {
10 'ArrayBuffer': 'ByteBuffer',
11 'ArrayBufferView': 'TypedData',
12 'DataView': 'ByteData',
13 'Float32Array': 'Float32List',
14 'Float64Array': 'Float64List',
15 'Int8Array': 'Int8List',
16 'Int16Array': 'Int16List',
17 'Int32Array': 'Int32List',
18 'Uint8Array': 'Uint8List',
19 'Uint8ClampedArray': 'Uint8ClampedList',
20 'Uint16Array': 'Uint16List',
21 'Uint32Array': 'Uint32List',
22}
23
24html_interface_renames = monitored.Dict(
25 'htmlrenamer.html_interface_renames',
26 dict(
27 {
28 'Attr':
29 '_Attr',
30 'BudgetService':
31 '_BudgetService',
32 'CDATASection':
33 'CDataSection',
34 'Clipboard':
35 '_Clipboard', # TODO(terry): Need to remove when ACX Clipboard is renamed to AcxClipboard.
36 'Database':
37 'SqlDatabase', # Avoid conflict with Index DB's Database.
38 'DatabaseSync':
39 'SqlDatabaseSync',
40 'DOMFileSystem':
41 'FileSystem',
42 'Entity':
43 '_Entity', # Not sure if we want to expose this yet, may conflict with other libs.
44 'EntryCallback':
45 '_EntryCallback',
46 'EntriesCallback':
47 '_EntriesCallback',
48 'ErrorCallback':
49 '_ErrorCallback',
50 'FileCallback':
51 '_FileCallback',
52 'FileSystemCallback':
53 '_FileSystemCallback',
54 'FileWriterCallback':
55 '_FileWriterCallback',
56 'HTMLDocument':
57 'HtmlDocument',
58 'HTMLElement':
59 'HtmlElement',
60 'HTMLHtmlElement':
61 'HtmlHtmlElement',
62 'IDBFactory':
63 'IdbFactory', # Manual to avoid name conflicts.
64 'Iterator':
65 'DomIterator',
66 'Key':
67 'CryptoKey',
68 'NamedNodeMap':
69 '_NamedNodeMap',
70 'NavigatorUserMediaErrorCallback':
71 '_NavigatorUserMediaErrorCallback',
72 'NavigatorUserMediaSuccessCallback':
73 '_NavigatorUserMediaSuccessCallback',
74 'NotificationPermissionCallback':
75 '_NotificationPermissionCallback',
76 'Position':
77 'Geoposition',
78 'PositionCallback':
79 '_PositionCallback',
80 'PositionErrorCallback':
81 '_PositionErrorCallback',
82 'Request':
83 '_Request',
84 'Report':
85 '_Report',
86 'RTCDTMFSender':
87 'RtcDtmfSender',
88 'RTCDTMFToneChangeEvent':
89 'RtcDtmfToneChangeEvent',
90 'RTCErrorCallback':
91 '_RtcErrorCallback',
92 'RTCSessionDescriptionCallback':
93 '_RtcSessionDescriptionCallback',
94 'SVGDocument':
95 'SvgDocument', # Manual to avoid name conflicts.
96 'SVGElement':
97 'SvgElement', # Manual to avoid name conflicts.
98 'SVGGradientElement':
99 '_GradientElement',
100 'SVGSVGElement':
101 'SvgSvgElement', # Manual to avoid name conflicts.
102 'Stream':
103 'FileStream',
104 'StringCallback':
105 '_StringCallback',
106 'WebGL2RenderingContext':
107 'RenderingContext2',
108 'WebGL2RenderingContextBase':
109 'RenderingContextBase2',
110 'WindowTimers':
111 '_WindowTimers',
112 'XMLHttpRequest':
113 'HttpRequest',
114 'XMLHttpRequestUpload':
115 'HttpRequestUpload',
116 'XMLHttpRequestEventTarget':
117 'HttpRequestEventTarget',
118 },
119 **typed_array_renames))
120
121# Some callback interfaces are not just a simple callback functions. If the callback
122# interface is in this list then the interface is exposed as a class.
123_gen_callback_interfaces = ['NodeFilter']
124
125
126def generateCallbackInterface(id):
127 return id in _gen_callback_interfaces
128
129
130# Interfaces that are suppressed, but need to still exist for Dartium and to
131# properly wrap DOM objects if/when encountered.
132_removed_html_interfaces = [
133 'Bluetooth',
134 'BluetoothAdvertisingData',
135 'BluetoothCharacteristicProperties',
136 'BluetoothDevice',
137 'BluetoothRemoteGATTCharacteristic',
138 'BluetoothRemoteGATTServer',
139 'BluetoothRemoteGATTService',
140 'BluetoothUUID',
141 'Cache', # TODO: Symbol conflicts with Angular: dartbug.com/20937
142 'CanvasPath',
143 'CDataSection',
144 'CSSPrimitiveValue',
145 'CSSUnknownRule',
146 'CSSValue',
147 'Counter',
148 'DOMFileSystemSync', # Workers
149 'DatabaseCallback', # WebSql was removed
150 'DatabaseSync', # Workers
151 'DirectoryEntrySync', # Workers
152 'DirectoryReaderSync', # Workers
153 'DocumentType',
154 'EntrySync', # Workers
155 'FileEntrySync', # Workers
156 'FileReaderSync', # Workers
157 'FileWriterSync', # Workers
158 'HTMLAllCollection',
159 'HTMLAppletElement',
160 'HTMLBaseFontElement',
161 'HTMLDirectoryElement',
162 'HTMLFontElement',
163 'HTMLFrameElement',
164 'HTMLFrameSetElement',
165 'HTMLMarqueeElement',
166 'IDBAny',
167 'Mojo',
168 'MojoHandle',
169 'MojoInterfaceInterceptor',
170 'MojoInterfaceRequestEvent',
171 'MojoWatcher',
172 'NFC',
173 'Notation',
174 'PagePopupController',
175 'RGBColor',
176 'RadioNodeList', # Folded onto NodeList in dart2js.
177 'Rect',
178 'Response', # TODO: Symbol conflicts with Angular: dartbug.com/20937
179 'SQLTransactionSync', # Workers
180 'SQLTransactionSyncCallback', # Workers
181 'SVGAltGlyphDefElement', # Webkit only.
182 'SVGAltGlyphItemElement', # Webkit only.
183 'SVGAnimateColorElement', # Deprecated. Use AnimateElement instead.
184 'SVGColor',
185 'SVGComponentTransferFunctionElement', # Currently not supported anywhere.
186 'SVGCursorElement', # Webkit only.
187 'SVGFEDropShadowElement', # Webkit only for the following:
188 'SVGFontElement',
189 'SVGFontFaceElement',
190 'SVGFontFaceFormatElement',
191 'SVGFontFaceNameElement',
192 'SVGFontFaceSrcElement',
193 'SVGFontFaceUriElement',
194 'SVGGlyphElement',
195 'SVGGlyphRefElement',
196 'SVGHKernElement',
197 'SVGMPathElement',
198 'SVGPaint',
199 'SVGMissingGlyphElement',
200 'SVGTRefElement',
201 'SVGVKernElement',
202 'SubtleCrypto',
203 'USB',
204 'USBAlternateInterface',
205 'USBConfiguration',
206 'USBConnectionEvent',
207 'USBDevice',
208 'USBEndpoint',
209 'USBInTransferResult',
210 'USBInterface',
211 'USBIsochronousInTransferPacket',
212 'USBIsochronousInTransferResult',
213 'USBIsochronousOutTransferPacket',
214 'USBIsochronousOutTransferResult',
215 'USBOutTransferResult',
216 'WebKitCSSFilterValue',
217 'WebKitCSSMatrix',
218 'WebKitCSSMixFunctionValue',
219 'WebKitCSSTransformValue',
220 'WebKitMediaSource',
221 'WebKitNotification',
222 'WebGLRenderingContextBase',
223 'WebGL2RenderingContextBase',
224 'WebKitSourceBuffer',
225 'WebKitSourceBufferList',
226 'WorkerLocation', # Workers
227 'WorkerNavigator', # Workers
228 'Worklet', # Rendering Workers
229 'XMLHttpRequestProgressEvent',
230 # Obsolete event for NaCl.
231 'ResourceProgressEvent',
232]
233
234for interface in _removed_html_interfaces:
235 html_interface_renames[interface] = '_' + interface
236
237convert_to_future_members = monitored.Set(
238 'htmlrenamer.converted_to_future_members', [
239 'Database.changeVersion',
240 'Database.readTransaction',
241 'DataTransferItem.getAsString',
242 'DirectoryEntry.getDirectory',
243 'DirectoryEntry.getFile',
244 'DirectoryEntry.removeRecursively',
245 'Entry.copyTo',
246 'Entry.getMetadata',
247 'Entry.getParent',
248 'Entry.moveTo',
249 'Entry.remove',
250 'FileEntry.createWriter',
251 'FileEntry.file',
252 'FontLoader.notifyWhenFontsReady',
253 'MediaStreamTrack.getSources',
254 'Notification.requestPermission',
255 'SQLTransaction.executeSql',
256 'StorageInfo.requestQuota',
257 'StorageQuota.requestQuota',
258 'Window.webkitRequestFileSystem',
259 'Window.webkitResolveLocalFileSystemURL',
260 'WorkerGlobalScope.webkitRequestFileSystem',
261 'WorkerGlobalScope.webkitResolveLocalFileSystemURL',
262 ])
263
264# DDC Exposed Classes
265ddc_extensions = monitored.Dict(
266 'ddcextensions.ddc_extensions', {
267 'DirectoryEntry': {
268 'getDirectory': [''],
269 'getFile': [
270 'applyExtension(\'FileEntry\', value);',
271 'applyExtension(\'webkitFileSystemFileEntry\', value);',
272 'applyExtension(\'FileSystemFileEntry\', value);',
273 ]
274 },
275 'Entry': {
276 'getMetadata': [
277 'applyExtension(\'Metadata\', value);',
278 ],
279 'getParent': [
280 'applyExtension(\'Entry\', value);',
281 'applyExtension(\'webkitFileSystemEntry\', value);',
282 'applyExtension(\'FileSystemEntry\', value);',
283 ]
284 },
285 'FileEntry': {
286 'createWriter': ['applyExtension(\'FileWriter\', value);'],
287 'file': ['applyExtension(\'File\', value);']
288 },
289 'SQLTransaction': {
290 'executeSql': [
291 'applyExtension(\'SQLResultSet\', resultSet);'
292 'applyExtension(\'SQLResultSetRowList\', resultSet.rows);'
293 ],
294 },
295 'Window': {
296 'webkitRequestFileSystem': [
297 'applyExtension(\'DOMFileSystem\', value);',
298 'applyExtension(\'WebKitFileSystem\', value);',
299 'applyExtension(\'webkitFileSystem\', value);',
300 'applyExtension(\'FileSystem\', value);',
301 'applyExtension(\'DirectoryEntry\', value.root);',
302 'applyExtension(\'webkitFileSystemDirectoryEntry\', value.root);',
303 'applyExtension(\'FileSystemDirectoryEntry\', value.root);',
304 ]
305 },
306 })
307
308
309# DDC Extension for this interface operation?
310def GetDDC_Extension(interface, operationName):
311 if interface.id in ddc_extensions:
312 entry = ddc_extensions[interface.id]
313 if operationName in entry:
314 return entry[operationName]
315 return None
316
317
318# Classes where we have customized constructors, but we need to keep the old
319# constructor for dispatch purposes.
320custom_html_constructors = monitored.Set(
321 'htmlrenamer.custom_html_constructors',
322 [
323 'CompositionEvent', # 45 Roll hide default constructor use Dart's custom
324 'CustomEvent', # 45 Roll hide default constructor use Dart's custom
325 'Event', # 45 Roll hide default constructor use Dart's custom
326 'HashChangeEvent', # 45 Roll hide default constructor use Dart's custom
327 'HTMLAudioElement',
328 'HTMLOptionElement',
329 'KeyboardEvent', # 45 Roll hide default constructor use Dart's custom
330 'MessageEvent', # 45 Roll hide default constructor use Dart's custom
331 'MouseEvent', # 45 Roll hide default constructor use Dart's custom
332 'MutationObserver',
333 'StorageEvent', # 45 Roll hide default constructor use Dart's custom
334 'UIEvent', # 45 Roll hide default constructor use Dart's custom
335 'WheelEvent', # 45 Roll hide default constructor use Dart's custom
336 ])
337
338# Members from the standard dom that should not be exposed publicly in dart:html
339# but need to be exposed internally to implement dart:html on top of a standard
340# browser. They are exposed simply by placing an underscore in front of the
341# name.
342private_html_members = monitored.Set(
343 'htmlrenamer.private_html_members',
344 [
345 'AudioNode.connect',
346 'Cache.add',
347 'Cache.delete',
348 'Cache.keys',
349 'Cache.match',
350 'Cache.matchAll',
351 'Cache.put',
352 'CanvasRenderingContext2D.arc',
353 'CanvasRenderingContext2D.drawImage',
354 'CanvasRenderingContext2D.getLineDash',
355 'Crypto.getRandomValues',
356 'CSSStyleDeclaration.getPropertyValue',
357 'CSSStyleDeclaration.setProperty',
358 'CSSStyleDeclaration.var',
359 'CompositionEvent.initCompositionEvent',
360 'CustomEvent.detail',
361 'CustomEvent.initCustomEvent',
362 'DataTransferItem.webkitGetAsEntry',
363 'DeviceOrientationEvent.initDeviceOrientationEvent',
364 'DirectoryEntry.createReader',
365 'DirectoryReader.readEntries',
366 'Document.createElement',
367 'Document.createElementNS',
368 'Document.createEvent',
369 'Document.createNodeIterator',
370 'Document.createTextNode',
371 'Document.createTouch',
372 'Document.createTouchList',
373 'Document.createTreeWalker',
374 'Document.querySelectorAll',
375 'DocumentFragment.querySelectorAll',
376
377 # Moved to HTMLDocument.
378 'Document.body',
379 'Document.caretRangeFromPoint',
380 'Document.elementFromPoint',
381 'Document.getCSSCanvasContext',
382 'Document.head',
383 'Document.lastModified',
384 'Document.preferredStylesheetSet',
385 'Document.referrer',
386 'Document.selectedStylesheetSet',
387 'Document.styleSheets',
388 'Document.title',
389 'Document.webkitCancelFullScreen',
390 'Document.webkitExitFullscreen',
391 # Not prefixed.
392 'Document.webkitFullscreenElement',
393 'Document.webkitFullscreenEnabled',
394 'Document.webkitHidden',
395 'Document.webkitIsFullScreen',
396 'Document.webkitVisibilityState',
397 # Not prefixed but requires custom implementation for cross-browser compatibility.
398 'Document.visibilityState',
399 'Element.animate',
400 'Element.childElementCount',
401 'Element.firstElementChild',
402 'Element.getClientRects',
403 'Element.getElementsByTagName',
404 'Element.insertAdjacentHTML',
405 'Element.scrollIntoView',
406 'Element.getAttribute',
407 'Element.getAttributeNS',
408 'Element.hasAttribute',
409 'Element.hasAttributeNS',
410 'Element.removeAttribute',
411 'Element.removeAttributeNS',
412 'Element.setAttribute',
413 'Element.setAttributeNS',
414 'Element.innerHTML',
415 'Element.querySelectorAll',
416 # TODO(vsm): These have been converted from int to double in Chrome 36.
417 # Special case them so we run on 34, 35, and 36.
418 'Element.scrollLeft',
419 'Element.scrollTop',
420 'Element.scrollWidth',
421 'Element.scrollHeight',
422 'Event.initEvent',
423 'EventTarget.addEventListener',
424 'EventTarget.removeEventListener',
425 'FileReader.result',
426 'Geolocation.clearWatch',
427 'Geolocation.getCurrentPosition',
428 'Geolocation.watchPosition',
429 'HashChangeEvent.initHashChangeEvent',
430 'HTMLCanvasElement.toDataURL',
431 'HTMLTableElement.createCaption',
432 'HTMLTableElement.createTFoot',
433 'HTMLTableElement.createTHead',
434 'HTMLTableElement.createTBody',
435 'HTMLTableElement.insertRow',
436 'HTMLTableElement.rows',
437 'HTMLTableElement.tBodies',
438 'HTMLTableRowElement.cells',
439 'HTMLTableRowElement.insertCell',
440 'HTMLTableSectionElement.insertRow',
441 'HTMLTableSectionElement.rows',
442 'IDBCursor.delete',
443 'IDBCursor.update',
444 'IDBDatabase.createObjectStore',
445 'IDBFactory.deleteDatabase',
446 'IDBFactory.webkitGetDatabaseNames',
447 'IDBFactory.open',
448 'IDBIndex.count',
449 'IDBIndex.get',
450 'IDBIndex.getKey',
451 'IDBIndex.openCursor',
452 'IDBIndex.openKeyCursor',
453 'IDBObjectStore.add',
454 'IDBObjectStore.clear',
455 'IDBObjectStore.count',
456 'IDBObjectStore.createIndex',
457 'IDBObjectStore.delete',
458 'IDBObjectStore.get',
459 'IDBObjectStore.openCursor',
460 'IDBObjectStore.put',
461 'KeyboardEvent.initKeyboardEvent',
462 'KeyboardEvent.keyIdentifier',
463 'MediaKeys.createSession',
464 'MediaKeySession.update',
465 'MessageEvent.initMessageEvent',
466 'MessagePort.start',
467 'MouseEvent.initMouseEvent',
468 'MouseEvent.clientX',
469 'MouseEvent.clientY',
470 'MouseEvent.movementX',
471 'MouseEvent.movementY',
472 'MouseEvent.offsetX',
473 'MouseEvent.offsetY',
474 'MouseEvent.screenX',
475 'MouseEvent.screenY',
476 'MutationObserver.observe',
477 'Navigator.getGamepads',
478 'Node.attributes',
479 'Node.localName',
480 'Node.namespaceURI',
481 'Node.removeChild',
482 'Node.replaceChild',
483 'ParentNode.childElementCount',
484 'ParentNode.children',
485 'ParentNode.firstElementChild',
486 'ParentNode.lastElementChild',
487 'ParentNode.querySelectorAll',
488 'Range.getClientRects',
489 'Screen.availHeight',
490 'Screen.availLeft',
491 'Screen.availTop',
492 'Screen.availWidth',
493 'ShadowRoot.resetStyleInheritance',
494 'Storage.clear',
495 'Storage.getItem',
496 'Storage.key',
497 'Storage.length',
498 'Storage.removeItem',
499 'Storage.setItem',
500 'StorageEvent.initStorageEvent',
501 'SubtleCrypto.encrypt',
502 'SubtleCrypto.decrypt',
503 'SubtleCrypto.sign',
504 'SubtleCrypto.digest',
505 'SubtleCrypto.importKey',
506 'SubtleCrypto.unwrapKey',
507 'ShadowRoot.applyAuthorStyles',
508 'SpeechSynthesis.getVoices',
509 'TextEvent.initTextEvent',
510 # TODO(leafp): These have been converted from int to double in Chrome 37.
511 # client, page, and screen were already special cased, adding radiusX/radiusY.
512 # See impl_Touch.darttemplate for impedance matching code
513 'Touch.clientX',
514 'Touch.clientY',
515 'Touch.pageX',
516 'Touch.pageY',
517 'Touch.screenX',
518 'Touch.screenY',
519 'Touch.radiusX',
520 'Touch.radiusY',
521 'UIEvent.initUIEvent',
522 'UIEvent.layerX',
523 'UIEvent.layerY',
524 'UIEvent.pageX',
525 'UIEvent.pageY',
526 'UIEvent.which',
527 'KeyboardEvent.charCode',
528 'KeyboardEvent.keyCode',
529 'KeyboardEvent.which',
530 'WebGLRenderingContext.readPixels',
531 'WebGL2RenderingContext.readPixels',
532 'WheelEvent.initWebKitWheelEvent',
533 'WheelEvent.deltaX',
534 'WheelEvent.deltaY',
535 'WorkerGlobalScope.webkitNotifications',
536 'Window.getComputedStyle',
537 'Window.clearInterval',
538 'Window.clearTimeout',
539 # TODO(tll): These have been converted from int to double in Chrome 39 for
540 # subpixel precision. Special case for backward compatibility.
541 'Window.pageXOffset',
542 'Window.pageYOffset',
543 'Window.scrollX',
544 'Window.scrollY',
545 'WindowTimers.clearInterval',
546 'WindowTimers.clearTimeout',
547 'WindowTimers.setInterval',
548 'WindowTimers.setTimeout',
549 'Window.moveTo',
550 'Window.requestAnimationFrame',
551 'Window.setInterval',
552 'Window.setTimeout',
553 ])
554
555# Members from the standard dom that exist in the dart:html library with
556# identical functionality but with cleaner names.
557renamed_html_members = monitored.Dict(
558 'htmlrenamer.renamed_html_members',
559 {
560 'ConsoleBase.assert': 'assertCondition',
561 'CSSKeyframesRule.insertRule': 'appendRule',
562 'DirectoryEntry.getDirectory': '_getDirectory',
563 'DirectoryEntry.getFile': '_getFile',
564 'Document.createCDATASection': 'createCDataSection',
565 'Document.defaultView': 'window',
566 'Window.CSS': 'css',
567 'Window.webkitNotifications': 'notifications',
568 'Window.webkitRequestFileSystem': '_requestFileSystem',
569 'Window.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
570 'Navigator.webkitGetUserMedia': '_getUserMedia',
571 'Node.appendChild': 'append',
572 'Node.cloneNode': 'clone',
573 'Node.nextSibling': 'nextNode',
574 'Node.parentElement': 'parent',
575 'Node.previousSibling': 'previousNode',
576 'Node.textContent': 'text',
577 'SVGElement.className': '_svgClassName',
578 'SVGStopElement.offset': 'gradientOffset',
579 'URL.createObjectURL': 'createObjectUrl',
580 'URL.revokeObjectURL': 'revokeObjectUrl',
581 #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem',
582 #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync',
583
584 # OfflineAudioContext.suspend has an signature incompatible with shadowed
585 # base class method AudioContext.suspend.
586 'OfflineAudioContext.suspend': 'suspendFor',
587 })
588
589# Members that have multiple definitions, but their types are vary, so we rename
590# them to make them distinct.
591renamed_overloads = monitored.Dict(
592 'htmldartgenerator.renamed_overloads', {
593 'AudioContext.createBuffer(ArrayBuffer buffer, boolean mixToMono)':
594 'createBufferFromBuffer',
595 'CSS.supports(DOMString conditionText)':
596 'supportsCondition',
597 'DataTransferItemList.add(File file)':
598 'addFile',
599 'DataTransferItemList.add(DOMString data, DOMString type)':
600 'addData',
601 'FormData.append(DOMString name, Blob value, DOMString filename)':
602 'appendBlob',
603 'RTCDataChannel.send(ArrayBuffer data)':
604 'sendByteBuffer',
605 'RTCDataChannel.send(ArrayBufferView data)':
606 'sendTypedData',
607 'RTCDataChannel.send(Blob data)':
608 'sendBlob',
609 'RTCDataChannel.send(DOMString data)':
610 'sendString',
611 'SourceBuffer.appendBuffer(ArrayBufferView data)':
612 'appendTypedData',
613 'URL.createObjectURL(MediaSource source)':
614 'createObjectUrlFromSource',
615 'URL.createObjectURL(WebKitMediaSource source)':
616 '_createObjectUrlFromWebKitSource',
617 'URL.createObjectURL(MediaStream stream)':
618 'createObjectUrlFromStream',
619 'URL.createObjectURL(Blob blob)':
620 'createObjectUrlFromBlob',
621 'WebSocket.send(ArrayBuffer data)':
622 'sendByteBuffer',
623 'WebSocket.send(ArrayBufferView data)':
624 'sendTypedData',
625 'WebSocket.send(DOMString data)':
626 'sendString',
627 'WebSocket.send(Blob data)':
628 'sendBlob',
629 'Window.setInterval(DOMString handler, long timeout, any arguments)':
630 '_setInterval_String',
631 'Window.setTimeout(DOMString handler, long timeout, any arguments)':
632 '_setTimeout_String',
633 'WindowTimers.setInterval(DOMString handler, long timeout, any arguments)':
634 '_setInterval_String',
635 'WindowTimers.setTimeout(DOMString handler, long timeout, any arguments)':
636 '_setTimeout_String',
637 })
638
639# Members that have multiple definitions, but their types are identical (only
640# number of arguments vary), so we do not rename them as a _raw method.
641keep_overloaded_members = monitored.Set(
642 'htmldartgenerator.keep_overloaded_members', [
643 'CanvasRenderingContext2D.putImageData',
644 'CanvasRenderingContext2D.webkitPutImageDataHD',
645 'DataTransferItemList.add', 'Document.createElement',
646 'Document.createElementNS', 'HTMLInputElement.setRangeText',
647 'HTMLTextAreaElement.setRangeText', 'IDBDatabase.transaction',
648 'RTCDataChannel.send', 'URL.createObjectURL', 'WebSocket.send',
649 'XMLHttpRequest.send'
650 ])
651
652# Members that can be overloaded.
653overloaded_and_renamed = monitored.Set(
654 'htmldartgenerator.overloaded_and_renamed', [
655 'CanvasRenderingContext2D.clip',
656 'CanvasRenderingContext2D.drawFocusIfNeeded',
657 'CanvasRenderingContext2D.fill',
658 'CanvasRenderingContext2D.isPointInPath',
659 'CanvasRenderingContext2D.isPointInStroke',
660 'CanvasRenderingContext2D.stroke',
661 'Navigator.sendBeacon',
662 ])
663
664
665def convertedFutureMembers(member):
666 return member in convert_to_future_members
667
668
669for member in convert_to_future_members:
670 if member in renamed_html_members:
671 renamed_html_members[member] = '_' + renamed_html_members[member]
672 else:
673 renamed_html_members[member] = '_' + member[member.find('.') + 1:]
674
675# Members and classes from the dom that should be removed completely from
676# dart:html. These could be expressed in the IDL instead but expressing this
677# as a simple table instead is more concise.
678# Syntax is: ClassName.(get\:|set\:|call\:|on\:)?MemberName
679# Using get: and set: is optional and should only be used when a getter needs
680# to be suppressed but not the setter, etc.
681# Prepending ClassName with = will only match against direct class, not for
682# subclasses.
683# TODO(jacobr): cleanup and augment this list.
684removed_html_members = monitored.Set(
685 'htmlrenamer.removed_html_members',
686 [
687 'Attr.textContent', # Not needed as it is the same as Node.textContent.
688 'AudioContext.decodeAudioData',
689 'AudioBufferSourceNode.looping', # TODO(vsm): Use deprecated IDL annotation
690 'CSSStyleDeclaration.getPropertyCSSValue',
691 'HTMLCanvasElement.toBlob',
692 'CanvasRenderingContext2D.clearShadow',
693 'CanvasRenderingContext2D.drawImageFromRect',
694 'CanvasRenderingContext2D.setAlpha',
695 'CanvasRenderingContext2D.setCompositeOperation',
696 'CanvasRenderingContext2D.setFillColor',
697 'CanvasRenderingContext2D.setLineCap',
698 'CanvasRenderingContext2D.setLineJoin',
699 'CanvasRenderingContext2D.setLineWidth',
700 'CanvasRenderingContext2D.setMiterLimit',
701 'CanvasRenderingContext2D.setShadow',
702 'CanvasRenderingContext2D.setStrokeColor',
703 # Disable the webKit version, imageSmoothingEnabled is exposed.
704 'CanvasRenderingContext2D.webkitImageSmoothingEnabled',
705 'CharacterData.remove',
706 'ChildNode.replaceWith',
707 'CSSStyleDeclaration.__getter__',
708 'CSSStyleDeclaration.__setter__',
709 'Window.call:blur',
710 'Window.call:focus',
711 'Window.clientInformation',
712 'Window.createImageBitmap',
713 'Window.get:frames',
714 'Window.get:length',
715 'Window.openDatabase',
716 'Window.on:beforeUnload',
717 'Window.on:webkitTransitionEnd',
718 'Window.pagePopupController',
719 'Window.prompt',
720 'Window.webkitCancelAnimationFrame',
721 'Window.webkitCancelRequestAnimationFrame',
722 'Window.webkitIndexedDB',
723 'Window.webkitRequestAnimationFrame',
724 'Document.alinkColor',
725 'Document.all',
726 'Document.append',
727 'Document.applets',
728 'Document.bgColor',
729 'Document.clear',
730 'Document.createAttribute',
731 'Document.createAttributeNS',
732 'Document.createComment',
733 'Document.createExpression',
734 'Document.createNSResolver',
735 'Document.createProcessingInstruction',
736 'Document.designMode',
737 'Document.dir',
738 'Document.evaluate',
739 'Document.fgColor',
740 'Document.get:URL',
741 'Document.get:anchors',
742 'Document.get:characterSet',
743 'Document.get:compatMode',
744 'Document.get:defaultCharset',
745 'Document.get:doctype',
746 'Document.get:documentURI',
747 'Document.get:embeds',
748 'Document.get:forms',
749 'Document.get:inputEncoding',
750 'Document.get:links',
751 'Document.get:plugins',
752 'Document.get:scripts',
753 'Document.get:xmlEncoding',
754 'Document.getElementsByTagNameNS',
755 'Document.getOverrideStyle',
756 'Document.getSelection',
757 'Document.images',
758 'Document.linkColor',
759 'Document.location',
760 'Document.on:wheel',
761 'Document.open',
762 'Document.prepend',
763 'Document.register',
764 'Document.set:domain',
765 'Document.vlinkColor',
766 'Document.webkitCurrentFullScreenElement',
767 'Document.webkitFullScreenKeyboardInputAllowed',
768 'Document.write',
769 'Document.writeln',
770 'Document.xmlStandalone',
771 'Document.xmlVersion',
772 'DocumentFragment.children',
773 'DocumentType.*',
774 'DOMException.code',
775 'DOMException.ABORT_ERR',
776 'DOMException.DATA_CLONE_ERR',
777 'DOMException.DOMSTRING_SIZE_ERR',
778 'DOMException.HIERARCHY_REQUEST_ERR',
779 'DOMException.INDEX_SIZE_ERR',
780 'DOMException.INUSE_ATTRIBUTE_ERR',
781 'DOMException.INVALID_ACCESS_ERR',
782 'DOMException.INVALID_CHARACTER_ERR',
783 'DOMException.INVALID_MODIFICATION_ERR',
784 'DOMException.INVALID_NODE_TYPE_ERR',
785 'DOMException.INVALID_STATE_ERR',
786 'DOMException.NAMESPACE_ERR',
787 'DOMException.NETWORK_ERR',
788 'DOMException.NOT_FOUND_ERR',
789 'DOMException.NOT_SUPPORTED_ERR',
790 'DOMException.NO_DATA_ALLOWED_ERR',
791 'DOMException.NO_MODIFICATION_ALLOWED_ERR',
792 'DOMException.QUOTA_EXCEEDED_ERR',
793 'DOMException.SECURITY_ERR',
794 'DOMException.SYNTAX_ERR',
795 'DOMException.TIMEOUT_ERR',
796 'DOMException.TYPE_MISMATCH_ERR',
797 'DOMException.URL_MISMATCH_ERR',
798 'DOMException.VALIDATION_ERR',
799 'DOMException.WRONG_DOCUMENT_ERR',
800 'Element.accessKey',
801 'Element.append',
802 'Element.children',
803 'Element.dataset',
804 'Element.get:classList',
805 'Element.getAttributeNode',
806 'Element.getAttributeNodeNS',
807 'Element.getElementsByTagNameNS',
808 'Element.innerText',
809 # TODO(terry): All offset* attributes are in both HTMLElement and Element
810 # (it's a Chrome bug with a FIXME note to correct - sometime).
811 # Until corrected these Element attributes must be ignored.
812 'Element.offsetParent',
813 'Element.offsetTop',
814 'Element.offsetLeft',
815 'Element.offsetWidth',
816 'Element.offsetHeight',
817 'Element.outerText',
818 'Element.prepend',
819 'Element.removeAttributeNode',
820 'Element.set:outerHTML',
821 'Element.setApplyScroll',
822 'Element.setAttributeNode',
823 'Element.setAttributeNodeNS',
824 'Element.setDistributeScroll',
825 'Element.webkitCreateShadowRoot',
826 'Element.webkitMatchesSelector',
827 'Element.webkitPseudo',
828 'Element.webkitShadowRoot',
829 '=Event.returnValue', # Only suppress on Event, allow for BeforeUnloadEvnt.
830 'Event.srcElement',
831 'EventSource.URL',
832 'FontFace.ready',
833 'FontFaceSet.load',
834 'FontFaceSet.ready',
835 'HTMLAnchorElement.charset',
836 'HTMLAnchorElement.coords',
837 'HTMLAnchorElement.rev',
838 'HTMLAnchorElement.shape',
839 'HTMLAnchorElement.text',
840 'HTMLAppletElement.*',
841 'HTMLAreaElement.noHref',
842 'HTMLBRElement.clear',
843 'HTMLBaseFontElement.*',
844 'HTMLBodyElement.aLink',
845 'HTMLBodyElement.background',
846 'HTMLBodyElement.bgColor',
847 'HTMLBodyElement.link',
848 'HTMLBodyElement.on:beforeUnload',
849 'HTMLBodyElement.text',
850 'HTMLBodyElement.vLink',
851 'HTMLDListElement.compact',
852 'HTMLDirectoryElement.*',
853 'HTMLDivElement.align',
854 'HTMLFontElement.*',
855 'HTMLFormControlsCollection.__getter__',
856 'HTMLFormElement.get:elements',
857 'HTMLFrameElement.*',
858 'HTMLFrameSetElement.*',
859 'HTMLHRElement.align',
860 'HTMLHRElement.noShade',
861 'HTMLHRElement.size',
862 'HTMLHRElement.width',
863 'HTMLHeadElement.profile',
864 'HTMLHeadingElement.align',
865 'HTMLHtmlElement.manifest',
866 'HTMLHtmlElement.version',
867 'HTMLIFrameElement.align',
868 'HTMLIFrameElement.frameBorder',
869 'HTMLIFrameElement.longDesc',
870 'HTMLIFrameElement.marginHeight',
871 'HTMLIFrameElement.marginWidth',
872 'HTMLIFrameElement.scrolling',
873 'HTMLImageElement.align',
874 'HTMLImageElement.hspace',
875 'HTMLImageElement.longDesc',
876 'HTMLImageElement.name',
877 'HTMLImageElement.vspace',
878 'HTMLInputElement.align',
879 'HTMLLegendElement.align',
880 'HTMLLinkElement.charset',
881 'HTMLLinkElement.rev',
882 'HTMLLinkElement.target',
883 'HTMLMarqueeElement.*',
884 'HTMLMenuElement.compact',
885 'HTMLMetaElement.scheme',
886 'HTMLOListElement.compact',
887 'HTMLObjectElement.align',
888 'HTMLObjectElement.archive',
889 'HTMLObjectElement.border',
890 'HTMLObjectElement.codeBase',
891 'HTMLObjectElement.codeType',
892 'HTMLObjectElement.declare',
893 'HTMLObjectElement.hspace',
894 'HTMLObjectElement.standby',
895 'HTMLObjectElement.vspace',
896 'HTMLOptionElement.text',
897 'HTMLOptionsCollection.*',
898 'HTMLParagraphElement.align',
899 'HTMLParamElement.type',
900 'HTMLParamElement.valueType',
901 'HTMLPreElement.width',
902 'HTMLScriptElement.text',
903 'HTMLSelectElement.options',
904 'HTMLSelectElement.selectedOptions',
905 'HTMLTableCaptionElement.align',
906 'HTMLTableCellElement.abbr',
907 'HTMLTableCellElement.align',
908 'HTMLTableCellElement.axis',
909 'HTMLTableCellElement.bgColor',
910 'HTMLTableCellElement.ch',
911 'HTMLTableCellElement.chOff',
912 'HTMLTableCellElement.height',
913 'HTMLTableCellElement.noWrap',
914 'HTMLTableCellElement.scope',
915 'HTMLTableCellElement.vAlign',
916 'HTMLTableCellElement.width',
917 'HTMLTableColElement.align',
918 'HTMLTableColElement.ch',
919 'HTMLTableColElement.chOff',
920 'HTMLTableColElement.vAlign',
921 'HTMLTableColElement.width',
922 'HTMLTableElement.align',
923 'HTMLTableElement.bgColor',
924 'HTMLTableElement.cellPadding',
925 'HTMLTableElement.cellSpacing',
926 'HTMLTableElement.frame',
927 'HTMLTableElement.rules',
928 'HTMLTableElement.summary',
929 'HTMLTableElement.width',
930 'HTMLTableRowElement.align',
931 'HTMLTableRowElement.bgColor',
932 'HTMLTableRowElement.ch',
933 'HTMLTableRowElement.chOff',
934 'HTMLTableRowElement.vAlign',
935 'HTMLTableSectionElement.align',
936 'HTMLTableSectionElement.ch',
937 'HTMLTableSectionElement.chOff',
938 'HTMLTableSectionElement.vAlign',
939 'HTMLTitleElement.text',
940 'HTMLUListElement.compact',
941 'HTMLUListElement.type',
942 'IDBDatabase.transaction', # We do this in a template without the generated implementation at all.
943 'Location.valueOf',
944 'MessageEvent.data',
945 'MouseEvent.webkitMovementX',
946 'MouseEvent.webkitMovementY',
947 'MouseEvent.x',
948 'MouseEvent.y',
949 'Navigator.bluetooth',
950 'Navigator.isProtocolHandlerRegistered',
951 'Navigator.unregisterProtocolHandler',
952 'Navigator.usb',
953 'Node.compareDocumentPosition',
954 'Node.get:DOCUMENT_POSITION_CONTAINED_BY',
955 'Node.get:DOCUMENT_POSITION_CONTAINS',
956 'Node.get:DOCUMENT_POSITION_DISCONNECTED',
957 'Node.get:DOCUMENT_POSITION_FOLLOWING',
958 'Node.get:DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC',
959 'Node.get:DOCUMENT_POSITION_PRECEDING',
960 'Node.get:childNodes',
961 'Node.get:prefix',
962 'Node.hasAttributes',
963 'Node.isDefaultNamespace',
964 'Node.isEqualNode',
965 'Node.isSameNode',
966 'Node.isSupported',
967 'Node.lookupNamespaceURI',
968 'Node.lookupPrefix',
969 'Node.normalize',
970 'Node.set:nodeValue',
971 'NodeFilter.acceptNode',
972 'NodeIterator.expandEntityReferences',
973 'NodeIterator.filter',
974 'NodeList.item',
975 'ParentNode.append',
976 'ParentNode.prepend',
977 'RTCPeerConnection.generateCertificate',
978 'ShadowRoot.getElementsByTagNameNS',
979 'SVGElement.getPresentationAttribute',
980 'SVGElementInstance.on:wheel',
981 'Touch.get:webkitRadiusX',
982 'Touch.get:webkitRadiusY',
983 'Touch.get:webkitForce',
984 'Touch.get:webkitRotationAngle',
985 'WheelEvent.wheelDelta',
986 'WheelEvent.wheelDeltaX',
987 'WheelEvent.wheelDeltaY',
988 'Window.on:wheel',
989 'WindowEventHandlers.on:beforeUnload',
990 'WorkerGlobalScope.webkitIndexedDB',
991 'XMLHttpRequest.open',
992 # TODO(jacobr): should these be removed?
993 'Document.close',
994 'Document.hasFocus',
995 ])
996
997# Manual dart: library name lookup.
998_library_names = monitored.Dict(
999 'htmlrenamer._library_names', {
1000 'ANGLEInstancedArrays': 'web_gl',
1001 'CHROMIUMSubscribeUniform': 'web_gl',
1002 'Database': 'web_sql',
1003 'Navigator': 'html',
1004 'Window': 'html',
1005 'AnalyserNode': 'web_audio',
1006 'AudioBufferCallback': 'web_audio',
1007 'AudioBuffer': 'web_audio',
1008 'AudioBufferSourceNode': 'web_audio',
1009 'AudioContext': 'web_audio',
1010 'AudioDestinationNode': 'web_audio',
1011 'AudioElement': 'web_audio',
1012 'AudioListener': 'web_audio',
1013 'AudioNode': 'web_audio',
1014 'AudioParam': 'web_audio',
1015 'AudioParamMap': 'web_audio',
1016 'AudioProcessingEvent': 'web_audio',
1017 'AudioScheduledSourceNode': 'web_audio',
1018 'AudioSourceNode': 'web_audio',
1019 'AudioTrack': 'web_audio',
1020 'AudioTrackList': 'web_audio',
1021 'AudioWorkletGlobalScope': 'web_audio',
1022 'AudioWorkletNode': 'web_audio',
1023 'AudioWorkletProcessor': 'web_audio',
1024 'BaseAudioContext': 'web_audio',
1025 'BiquadFilterNode': 'web_audio',
1026 'ChannelMergerNode': 'web_audio',
1027 'ChannelSplitterNode': 'web_audio',
1028 'ConstantSourceNode': 'web_audio',
1029 'ConvolverNode': 'web_audio',
1030 'DelayNode': 'web_audio',
1031 'DynamicsCompressorNode': 'web_audio',
1032 'GainNode': 'web_audio',
1033 'IIRFilterNode': 'web_audio',
1034 'MediaElementAudioSourceNode': 'web_audio',
1035 'MediaStreamAudioDestinationNode': 'web_audio',
1036 'MediaStreamAudioSourceNode': 'web_audio',
1037 'OfflineAudioCompletionEvent': 'web_audio',
1038 'OfflineAudioContext': 'web_audio',
1039 'OscillatorNode': 'web_audio',
1040 'PannerNode': 'web_audio',
1041 'PeriodicWave': 'web_audio',
1042 'ScriptProcessorNode': 'web_audio',
1043 'StereoPannerNode': 'web_audio',
1044 'WaveShaperNode': 'web_audio',
1045 'WindowWebAudio': 'web_audio',
1046 })
1047
1048_library_ids = monitored.Dict(
1049 'htmlrenamer._library_names', {
1050 'ANGLEInstancedArrays': 'WebGl',
1051 'CHROMIUMSubscribeUniform': 'WebGl',
1052 'Database': 'WebSql',
1053 'Navigator': 'Html',
1054 'Window': 'Html',
1055 'AnalyserNode': 'WebAudio',
1056 'AudioBufferCallback': 'WebAudio',
1057 'AudioBuffer': 'WebAudio',
1058 'AudioBufferSourceNode': 'WebAudio',
1059 'AudioContext': 'WebAudio',
1060 'AudioDestinationNode': 'WebAudio',
1061 'AudioListener': 'WebAudio',
1062 'AudioNode': 'WebAudio',
1063 'AudioParam': 'WebAudio',
1064 'AudioProcessingEvent': 'WebAudio',
1065 'AudioSourceNode': 'WebAudio',
1066 'BiquadFilterNode': 'WebAudio',
1067 'ChannelMergerNode': 'WebAudio',
1068 'ChannelSplitterNode': 'WebAudio',
1069 'ConvolverNode': 'WebAudio',
1070 'DelayNode': 'WebAudio',
1071 'DynamicsCompressorNode': 'WebAudio',
1072 'GainNode': 'WebAudio',
1073 'IIRFilterNode': 'WebAudio',
1074 'MediaElementAudioSourceNode': 'WebAudio',
1075 'MediaStreamAudioDestinationNode': 'WebAudio',
1076 'MediaStreamAudioSourceNode': 'WebAudio',
1077 'OfflineAudioCompletionEvent': 'WebAudio',
1078 'OfflineAudioContext': 'WebAudio',
1079 'OscillatorNode': 'WebAudio',
1080 'PannerNode': 'WebAudio',
1081 'PeriodicWave': 'WebAudio',
1082 'ScriptProcessorNode': 'WebAudio',
1083 'StereoPannerNode': 'WebAudio',
1084 'WaveShaperNode': 'WebAudio',
1085 'WindowWebAudio': 'WebAudio',
1086 })
1087
1088
1089class HtmlRenamer(object):
1090
1091 def __init__(self, database, metadata):
1092 self._database = database
1093 self._metadata = metadata
1094
1095 def RenameInterface(self, interface):
1096 if 'Callback' in interface.ext_attrs:
1097 if interface.id in _removed_html_interfaces:
1098 return None
1099
1100 candidate = self.RenameInterfaceId(interface.id)
1101 if candidate:
1102 return candidate
1103
1104 if interface.id.startswith('HTML'):
1105 if any(interface.id in ['Element', 'Document']
1106 for interface in self._database.Hierarchy(interface)):
1107 return interface.id[len('HTML'):]
1108 return self._DartifyName(interface.javascript_binding_name)
1109
1110 def RenameInterfaceId(self, interface_id):
1111 if interface_id in html_interface_renames:
1112 return html_interface_renames[interface_id]
1113 return None
1114
1115 def isPrivate(self, interface, member):
1116 return self._FindMatch(interface, member, '', private_html_members)
1117
1118 def RenameMember(self,
1119 interface_name,
1120 member_node,
1121 member,
1122 member_prefix='',
1123 dartify_name=True):
1124 """
1125 Returns the name of the member in the HTML library or None if the member is
1126 suppressed in the HTML library
1127 """
1128 interface = self._database.GetInterface(interface_name)
1129
1130 if not member:
1131 if 'ImplementedAs' in member_node.ext_attrs:
1132 member = member_node.ext_attrs['ImplementedAs']
1133
1134 if self.ShouldSuppressMember(interface, member, member_prefix):
1135 return None
1136
1137 if 'CheckSecurity' in member_node.ext_attrs:
1138 return None
1139
1140 name = self._FindMatch(interface, member, member_prefix,
1141 renamed_html_members)
1142
1143 target_name = renamed_html_members[name] if name else member
1144 if self._FindMatch(interface, member, member_prefix,
1145 private_html_members):
1146 if not target_name.startswith('_'): # e.g. _svgClassName
1147 target_name = '_' + target_name
1148
1149 if not name and target_name.startswith('webkit'):
1150 target_name = member[len('webkit'):]
1151 target_name = target_name[:1].lower() + target_name[1:]
1152
1153 if dartify_name:
1154 target_name = self._DartifyMemberName(target_name)
1155 return target_name
1156
1157 def ShouldSuppressMember(self, interface, member, member_prefix=''):
1158 """ Returns true if the member should be suppressed."""
1159 if self._FindMatch(interface, member, member_prefix,
1160 removed_html_members):
1161 return True
1162 if interface.id in _removed_html_interfaces:
1163 return True
1164 metadata_member = member
1165 if member_prefix == 'on:':
1166 metadata_member = 'on' + metadata_member.lower()
1167 if self._metadata.IsSuppressed(interface, metadata_member):
1168 return True
1169 return False
1170
1171 def ShouldSuppressInterface(self, interface):
1172 """ Returns true if the interface should be suppressed."""
1173 if interface.id in _removed_html_interfaces:
1174 return True
1175
1176 def _FindMatch(self, interface, member, member_prefix, candidates):
1177
1178 def find_match(interface_id):
1179 member_name = interface_id + '.' + member
1180 if member_name in candidates:
1181 return member_name
1182 member_name = interface_id + '.' + member_prefix + member
1183 if member_name in candidates:
1184 return member_name
1185 member_name = interface_id + '.*'
1186 if member_name in candidates:
1187 return member_name
1188
1189 # Check direct matches first
1190 match = find_match('=%s' % interface.id)
1191 if match:
1192 return match
1193
1194 for interface in self._database.Hierarchy(interface):
1195 match = find_match(interface.id)
1196 if match:
1197 return match
1198
1199 def GetLibraryName(self, interface):
1200 # Some types have attributes merged in from many other interfaces.
1201 if interface.id in _library_names:
1202 return _library_names[interface.id]
1203
1204 # Support for IDL conditional has been removed from indexed db, web_sql,
1205 # svg and web_gl so we can no longer determine the library based on conditional.
1206 # Use interface prefix to do that. web_audio interfaces have no common prefix
1207 # - all audio interfaces added to _library_names/_library_ids.
1208 if interface.id.startswith("IDB"):
1209 return 'indexed_db'
1210 if interface.id.startswith("SQL"):
1211 return 'web_sql'
1212 if interface.id.startswith("SVG"):
1213 return 'svg'
1214 if interface.id.startswith("WebGL") or interface.id.startswith("OES") \
1215 or interface.id.startswith("EXT") \
1216 or interface.id == "WebGL": # Name of the synthesized class for WebGL constants.
1217 return 'web_gl'
1218
1219 if interface.id in typed_array_renames:
1220 return 'typed_data'
1221
1222 return 'html'
1223
1224 def GetLibraryId(self, interface):
1225 # Some types have attributes merged in from many other interfaces.
1226 if interface.id in _library_ids:
1227 return _library_ids[interface.id]
1228
1229 # Support for IDL conditional has been removed from indexed db, web_sql,
1230 # svg and web_gl so we can no longer determine the library based on conditional.
1231 # Use interface prefix to do that. web_audio interfaces have no common prefix
1232 # - all audio interfaces added to _library_names/_library_ids.
1233 if interface.id.startswith("IDB"):
1234 return 'IndexedDb'
1235 if interface.id.startswith("SQL"):
1236 return 'WebSql'
1237 if interface.id.startswith("SVG"):
1238 return 'Svg'
1239 if interface.id.startswith("WebGL") or interface.id.startswith("OES") \
1240 or interface.id.startswith("EXT") \
1241 or interface.id == 'WebGL': # Name of the synthesized class for WebGL constants.
1242 return 'WebGl'
1243
1244 if interface.id in typed_array_renames:
1245 return 'TypedData'
1246
1247 return 'Html'
1248
1249 def DartifyTypeName(self, type_name):
1250 """Converts a DOM name to a Dart-friendly class name. """
1251
1252 if type_name in html_interface_renames:
1253 return html_interface_renames[type_name]
1254
1255 return self._DartifyName(type_name)
1256
1257 def _DartifyName(self, dart_name):
1258 # Strip off any standard prefixes.
1259 name = re.sub(r'^SVG', '', dart_name)
1260 name = re.sub(r'^IDB', '', name)
1261 # Don't Strip the synthesized class name WebGL contains all rendering/draw constants.
1262 if name != 'WebGL':
1263 name = re.sub(r'^WebGL', '', name)
1264 name = re.sub(r'^WebKit', '', name)
1265
1266 return self._CamelCaseName(name)
1267
1268 def _DartifyMemberName(self, member_name):
1269 # Strip off any OpenGL ES suffixes.
1270 name = re.sub(r'OES$', '', member_name)
1271 return self._CamelCaseName(name)
1272
1273 def _CamelCaseName(self, name):
1274
1275 def toLower(match):
1276 return match.group(1) + match.group(2).lower() + match.group(3)
1277
1278 # We're looking for a sequence of letters which start with capital letter
1279 # then a series of caps and finishes with either the end of the string or
1280 # a capital letter.
1281 # The [0-9] check is for names such as 2D or 3D
1282 # The following test cases should match as:
1283 # WebKitCSSFilterValue: WebKit(C)(SS)(F)ilterValue
1284 # XPathNSResolver: (X)()(P)ath(N)(S)(R)esolver (no change)
1285 # IFrameElement: (I)()(F)rameElement (no change)
1286 return re.sub(r'([A-Z])([A-Z]{2,})([A-Z]|$)', toLower, name)
static uint64_t toLower(uint64_t n)
SIT bool any(const Vec< 1, T > &x)
Definition: SkVx.h:530