示例#1
0
    def __init__(self,
                 api_status_path,
                 doc_comments_path,
                 logging_level=logging.WARNING):
        _logger.setLevel(logging_level)
        self._api_status_path = api_status_path
        status_file = open(self._api_status_path, 'r+')
        self._types = json.load(status_file)
        status_file.close()

        comments_file = open(doc_comments_path, 'r+')
        self._doc_comments = json.load(comments_file)
        comments_file.close()

        if _monitor_type_metadata:
            monitored_interfaces = {}
            for interface_id, interface_data in self._types.iteritems():
                monitored_interface = interface_data.copy()
                monitored_interface['members'] = monitored.Dict(
                    'dartmetadata.%s' % interface_id,
                    interface_data['members'])

                monitored_interfaces[interface_id] = monitored_interface

            self._monitored_types = monitored.Dict(
                'dartmetadata._monitored_types', monitored_interfaces)
        else:
            self._monitored_types = self._types
示例#2
0
    def __init__(self, database):
        """DatabaseBuilder is used for importing and merging interfaces into
    the Database"""
        self._database = database
        self._imported_interfaces = []
        self._impl_stmts = []
        self.conditionals_met = set()

        # Spin up the new IDL parser.
        self.build = Build(None)

        # Global typedef to mapping.
        self.global_type_defs = monitored.Dict(
            'databasebuilder.global_type_defs', {
                'Transferable': 'MessagePort',
            })
# BSD-style license that can be found in the LICENSE file.

"""This module provides functionality to generate dart:html event classes."""

import logging
import monitored

_logger = logging.getLogger('dartgenerator')

# Events without onEventName attributes in the  IDL we want to support.
# We can automatically extract most event names by checking for
# onEventName methods in the IDL but some events aren't listed so we need
# to manually add them here so that they are easy for users to find.
_html_manual_events = monitored.Dict('htmleventgenerator._html_manual_events', {
  'Element': ['ontouchleave', 'ontouchenter', 'ontransitionend'],
  'HTMLCanvasElement': ['onwebglcontextlost', 'onwebglcontextrestored'],
  'Window': ['onDOMContentLoaded']
})

# These event names must be camel case when attaching event listeners
# using addEventListener even though the onEventName properties in the DOM for
# them are not camel case.
_on_attribute_to_event_name_mapping = monitored.Dict(
    'htmleventgenerator._on_attribute_to_event_name_mapping', {
  'webkitanimationend': 'webkitAnimationEnd',
  'webkitanimationiteration': 'webkitAnimationIteration',
  'webkitanimationstart': 'webkitAnimationStart',
  'webkitspeechchange': 'webkitSpeechChange',
})

_html_event_types = monitored.Dict('htmleventgenerator._html_event_types', {
示例#4
0
_dart2js_annotations = monitored.Dict(
    'dartmetadata._dart2js_annotations',
    {
        'AnimationEffectTiming.duration': [
            "@Returns('num|String|Null')",
        ],
        'ArrayBufferView': [
            "@Creates('TypedData')",
            "@Returns('TypedData|Null')",
        ],
        'CanvasRenderingContext2D.createImageData': [
            "@Creates('ImageData|=Object')",
        ],
        'CanvasRenderingContext2D.getImageData': [
            "@Creates('ImageData|=Object')",
        ],
        'CanvasRenderingContext2D.webkitGetImageDataHD': [
            "@Creates('ImageData|=Object')",
        ],
        'CanvasRenderingContext2D.fillStyle': [
            "@Creates('String|CanvasGradient|CanvasPattern')",
            "@Returns('String|CanvasGradient|CanvasPattern')",
        ],
        'CanvasRenderingContext2D.strokeStyle': [
            "@Creates('String|CanvasGradient|CanvasPattern')",
            "@Returns('String|CanvasGradient|CanvasPattern')",
        ],
        'CryptoKey.algorithm': [
            "@Creates('Null')",
        ],
        'CustomEvent._detail': [
            "@Creates('Null')",
        ],

        # Normally Window is never null, but starting from a <template> element in
        # JavaScript, this will be null:
        #     template.content.ownerDocument.defaultView
        'Document.window': [
            "@Creates('Window|=Object|Null')",
            "@Returns('Window|=Object|Null')",
        ],
        'Document.getElementsByClassName': [
            "@Creates('NodeList|HtmlCollection')",
            "@Returns('NodeList|HtmlCollection')",
        ],
        'Document.getElementsByName': [
            "@Creates('NodeList|HtmlCollection')",
            "@Returns('NodeList|HtmlCollection')",
        ],
        'Document.getElementsByTagName': [
            "@Creates('NodeList|HtmlCollection')",
            "@Returns('NodeList|HtmlCollection')",
        ],

        # querysSelectorAll never returns `null`.
        'Document.querySelectorAll': [
            "@Creates('NodeList')",
            "@Returns('NodeList')",
        ],
        'DocumentFragment.querySelectorAll': [
            "@Creates('NodeList')",
            "@Returns('NodeList')",
        ],
        'Element.querySelectorAll': [
            "@Creates('NodeList')",
            "@Returns('NodeList')",
        ],
        'Element.getBoundingClientRect': [
            "@Creates('_DomRect')",
            "@Returns('_DomRect|Null')",  # TODO(sra): Verify and remove Null.
        ],
        'Element.getClientRects': [
            "@Creates('DomRectList')",
            "@Returns('DomRectList|Null')",
        ],

        # Methods returning Window can return a local window, or a cross-frame
        # window (=Object) that needs wrapping.
        'Window': [
            "@Creates('Window|=Object')",
            "@Returns('Window|=Object')",
        ],
        'Window.openDatabase': [
            "@Creates('SqlDatabase')",
        ],
        'Window.showModalDialog': [
            "@Creates('Null')",
        ],
        'Element.webkitGetRegionFlowRanges': [
            "@Creates('JSExtendableArray')",
            "@Returns('JSExtendableArray')",
        ],
        'Element.getElementsByClassName': [
            "@Creates('NodeList|HtmlCollection')",
            "@Returns('NodeList|HtmlCollection')",
        ],
        'Element.getElementsByName': [
            "@Creates('NodeList|HtmlCollection')",
            "@Returns('NodeList|HtmlCollection')",
        ],
        'Element.getElementsByTagName': [
            "@Creates('NodeList|HtmlCollection')",
            "@Returns('NodeList|HtmlCollection')",
        ],
        "ErrorEvent.error": [
            "@Creates('Null')",  # Only returns values created elsewhere.
        ],

        # To be in callback with the browser-created Event, we had to have called
        # addEventListener on the target, so we avoid
        'Event.currentTarget': [
            "@Creates('Null')",
            "@Returns('EventTarget|=Object|Null')",
        ],

        # Only nodes in the DOM bubble and have target !== currentTarget.
        'Event.target': [
            "@Creates('Node')",
            "@Returns('EventTarget|=Object')",
        ],

        # TODO(sra): Investigate how ExtendableMessageEvent.data is different from
        # MessageEvent.data. It might be necessary to put in a method to translate
        # the JavaScript wire type into a Dart type.
        'ExtendableMessageEvent.data': [
            "@annotation_Creates_SerializedScriptValue",
            "@annotation_Returns_SerializedScriptValue",
        ],

        # TODO(sra): We could determine the following by parsing the compound IDL
        # type.
        'ExtendableMessageEvent.source': [
            "@Creates('Client|ServiceWorker|MessagePort')",
            "@Returns('Client|ServiceWorker|MessagePort|Null')",
        ],
        'File.lastModifiedDate': [
            "@Creates('Null')",  # JS date object.
        ],
        'FocusEvent.relatedTarget': [
            "@Creates('Null')",
        ],
        'Gamepad.buttons': [
            "@Creates('JSExtendableArray|GamepadButton')",
            "@Returns('JSExtendableArray')",
        ],
        # Creates a GeolocationPosition or a GeolocationPositionError for a
        # callback. See issue #45562.
        'Geolocation.getCurrentPosition': [
            "@Creates('Geoposition')",
            "@Creates('PositionError')",
        ],
        'Geolocation.watchPosition': [
            "@Creates('Geoposition')",
            "@Creates('PositionError')",
        ],
        'HTMLCanvasElement.getContext': [
            "@Creates('CanvasRenderingContext2D|RenderingContext|RenderingContext2')",
            "@Returns('CanvasRenderingContext2D|RenderingContext|RenderingContext2|Null')",
        ],
        'HTMLInputElement.valueAsDate': [
            "@Creates('Null')",  # JS date object.
        ],

        # Rather than have the result of an IDBRequest as a union over all possible
        # results, we mark the result as instantiating any classes, and mark
        # each operation with the classes that it could cause to be asynchronously
        # instantiated.
        'IDBRequest.result': ["@Creates('Null')"],

        # The source is usually a participant in the operation that generated the
        # IDBRequest.
        'IDBRequest.source': ["@Creates('Null')"],
        'IDBFactory.open': ["@Creates('Database')"],
        'IDBFactory.webkitGetDatabaseNames': ["@Creates('DomStringList')"],
        'IDBObjectStore.put': ["@_annotation_Creates_IDBKey"],
        'IDBObjectStore.add': ["@_annotation_Creates_IDBKey"],
        'IDBObjectStore.get': ["@annotation_Creates_SerializedScriptValue"],
        'IDBObjectStore.openCursor': ["@Creates('Cursor')"],
        'IDBIndex.get': ["@annotation_Creates_SerializedScriptValue"],
        'IDBIndex.getKey': [
            "@annotation_Creates_SerializedScriptValue",
            # The source is the object store behind the index.
            "@Creates('ObjectStore')",
        ],
        'IDBIndex.openCursor': ["@Creates('Cursor')"],
        'IDBIndex.openKeyCursor': ["@Creates('Cursor')"],
        'IDBCursorWithValue.value': [
            '@annotation_Creates_SerializedScriptValue',
            '@annotation_Returns_SerializedScriptValue',
        ],
        'IDBCursor.key': [
            "@_annotation_Creates_IDBKey",
            "@_annotation_Returns_IDBKey",
        ],
        'IDBCursor.primaryKey': [
            "@_annotation_Creates_IDBKey",
            "@_annotation_Returns_IDBKey",
        ],
        'IDBCursor.source': [
            "@Creates('Null')",
            "@Returns('ObjectStore|Index|Null')",
        ],
        'IDBDatabase.version': [
            "@Creates('int|String|Null')",
            "@Returns('int|String|Null')",
        ],
        'IDBIndex.keyPath': [
            "@annotation_Creates_SerializedScriptValue",
        ],
        'IDBKeyRange.lower': [
            "@annotation_Creates_SerializedScriptValue",
        ],
        'IDBKeyRange.upper': [
            "@annotation_Creates_SerializedScriptValue",
        ],
        'IDBObjectStore.keyPath': [
            "@annotation_Creates_SerializedScriptValue",
        ],
        '+IDBOpenDBRequest': [
            "@Returns('Request')",
            "@Creates('Request')",
        ],
        '+IDBRequest': [
            "@Returns('Request')",
            "@Creates('Request')",
        ],
        'IDBVersionChangeEvent.newVersion': [
            "@Creates('int|String|Null')",
            "@Returns('int|String|Null')",
        ],
        'IDBVersionChangeEvent.oldVersion': [
            "@Creates('int|String|Null')",
            "@Returns('int|String|Null')",
        ],
        'ImageData.data': [
            "@Creates('NativeUint8ClampedList')",
            "@Returns('NativeUint8ClampedList')",
        ],
        'MediaStream.getAudioTracks': [
            "@Creates('JSExtendableArray|MediaStreamTrack')",
            "@Returns('JSExtendableArray')",
        ],
        'MediaStream.getVideoTracks': [
            "@Creates('JSExtendableArray|MediaStreamTrack')",
            "@Returns('JSExtendableArray')",
        ],
        'MessageEvent.data': [
            "@annotation_Creates_SerializedScriptValue",
            "@annotation_Returns_SerializedScriptValue",
        ],
        'MessageEvent.ports': ["@Creates('JSExtendableArray')"],
        'MessageEvent.source': [
            "@Creates('Null')",
            "@Returns('EventTarget|=Object')",
        ],
        'Metadata.modificationTime': [
            "@Creates('Null')",  # JS date object.
        ],
        'MouseEvent.relatedTarget': [
            "@Creates('Node')",
            "@Returns('EventTarget|=Object|Null')",
        ],
        'Notification.data': [
            "@annotation_Creates_SerializedScriptValue",
            "@annotation_Returns_SerializedScriptValue",
        ],
        'PopStateEvent.state': [
            "@annotation_Creates_SerializedScriptValue",
            "@annotation_Returns_SerializedScriptValue",
        ],
        'RTCStatsReport.timestamp': [
            "@Creates('Null')",  # JS date object.
        ],
        'SerializedScriptValue': [
            "@annotation_Creates_SerializedScriptValue",
            "@annotation_Returns_SerializedScriptValue",
        ],
        'ServiceWorkerMessageEvent.data': [
            "@annotation_Creates_SerializedScriptValue",
            "@annotation_Returns_SerializedScriptValue",
        ],
        'ServiceWorkerMessageEvent.source': [
            "@Creates('Null')",
            "@Returns('ServiceWorker|MessagePort')",
        ],
        'ShadowRoot.getElementsByClassName': [
            "@Creates('NodeList|HtmlCollection')",
            "@Returns('NodeList|HtmlCollection')",
        ],
        'ShadowRoot.getElementsByName': [
            "@Creates('NodeList|HtmlCollection')",
            "@Returns('NodeList|HtmlCollection')",
        ],
        'ShadowRoot.getElementsByTagName': [
            "@Creates('NodeList|HtmlCollection')",
            "@Returns('NodeList|HtmlCollection')",
        ],

        # Touch targets are Elements in a Document, or the Document.
        'Touch.target': [
            "@Creates('Element|Document')",
            "@Returns('Element|Document')",
        ],
        'TrackEvent.track': [
            "@Creates('Null')",
        ],
        'VTTCue.line': [
            "@Creates('Null')",
            "@Returns('num|String')",
        ],
        'VTTCue.position': [
            "@Creates('Null')",
            "@Returns('num|String')",
        ],
        'WebGLRenderingContext.getBufferParameter': [
            "@Creates('int|Null')",
            "@Returns('int|Null')",
        ],
        'WebGLRenderingContext.getFramebufferAttachmentParameter': [
            "@Creates('int|Renderbuffer|Texture|Null')",
            "@Returns('int|Renderbuffer|Texture|Null')",
        ],
        'WebGLRenderingContext.getProgramParameter': [
            "@Creates('int|bool|Null')",
            "@Returns('int|bool|Null')",
        ],
        'WebGLRenderingContext.getRenderbufferParameter': [
            "@Creates('int|Null')",
            "@Returns('int|Null')",
        ],
        'WebGLRenderingContext.getShaderParameter': [
            "@Creates('int|bool|Null')",
            "@Returns('int|bool|Null')",
        ],
        'WebGLRenderingContext.getTexParameter': [
            "@Creates('int|Null')",
            "@Returns('int|Null')",
        ],
        'WebGLRenderingContext.getUniform': [
            "@Creates('Null|num|String|bool|JSExtendableArray|"
            "NativeFloat32List|NativeInt32List|NativeUint32List')",
            "@Returns('Null|num|String|bool|JSExtendableArray|"
            "NativeFloat32List|NativeInt32List|NativeUint32List')",
        ],
        'WebGLRenderingContext.getVertexAttrib': [
            "@Creates('Null|num|bool|NativeFloat32List|Buffer')",
            "@Returns('Null|num|bool|NativeFloat32List|Buffer')",
        ],
        'WebGLRenderingContext.getParameter': [
            # Taken from http://www.khronos.org/registry/webgl/specs/latest/
            # Section 5.14.3 Setting and getting state
            "@Creates('Null|num|String|bool|JSExtendableArray|"
            "NativeFloat32List|NativeInt32List|NativeUint32List|"
            "Framebuffer|Renderbuffer|Texture')",
            "@Returns('Null|num|String|bool|JSExtendableArray|"
            "NativeFloat32List|NativeInt32List|NativeUint32List|"
            "Framebuffer|Renderbuffer|Texture')",
        ],
        'WebGLRenderingContext.getContextAttributes': [
            "@Creates('ContextAttributes|Null')",
        ],
        'XMLHttpRequest.response': [
            "@Creates('NativeByteBuffer|Blob|Document|=Object|JSExtendableArray"
            "|String|num')",
        ],
    },
    dart2jsOnly=True)
示例#5
0
html_interface_renames = monitored.Dict(
    'htmlrenamer.html_interface_renames',
    dict(
        {
            'Attr': '_Attr',
            'BudgetService': '_BudgetService',
            'CDATASection': 'CDataSection',
            'Clipboard':
            '_Clipboard',  # TODO(terry): Need to remove when ACX Clipboard is renamed to AcxClipboard.
            'Database':
            'SqlDatabase',  # Avoid conflict with Index DB's Database.
            'DatabaseSync': 'SqlDatabaseSync',
            'DOMFileSystem': 'FileSystem',
            'Entity':
            '_Entity',  # Not sure if we want to expose this yet, may conflict with other libs.
            'EntryCallback': '_EntryCallback',
            'EntriesCallback': '_EntriesCallback',
            'ErrorCallback': '_ErrorCallback',
            'FileCallback': '_FileCallback',
            'FileSystemCallback': '_FileSystemCallback',
            'FileWriterCallback': '_FileWriterCallback',
            'HTMLDocument': 'HtmlDocument',
            'HTMLElement': 'HtmlElement',
            'HTMLHtmlElement': 'HtmlHtmlElement',
            'IDBFactory': 'IdbFactory',  # Manual to avoid name conflicts.
            'Iterator': 'DomIterator',
            'Key': 'CryptoKey',
            'NamedNodeMap': '_NamedNodeMap',
            'NavigatorUserMediaErrorCallback':
            '_NavigatorUserMediaErrorCallback',
            'NavigatorUserMediaSuccessCallback':
            '_NavigatorUserMediaSuccessCallback',
            'NotificationPermissionCallback':
            '_NotificationPermissionCallback',
            'Position': 'Geoposition',
            'PositionCallback': '_PositionCallback',
            'PositionErrorCallback': '_PositionErrorCallback',
            'Request': '_Request',
            'Report': '_Report',
            'RTCDTMFSender': 'RtcDtmfSender',
            'RTCDTMFToneChangeEvent': 'RtcDtmfToneChangeEvent',
            'RTCErrorCallback': '_RtcErrorCallback',
            'RTCSessionDescriptionCallback': '_RtcSessionDescriptionCallback',
            'SVGDocument': 'SvgDocument',  # Manual to avoid name conflicts.
            'SVGElement': 'SvgElement',  # Manual to avoid name conflicts.
            'SVGGradientElement': '_GradientElement',
            'SVGSVGElement':
            'SvgSvgElement',  # Manual to avoid name conflicts.
            'Stream': 'FileStream',
            'StringCallback': '_StringCallback',
            'WebGL2RenderingContext': 'RenderingContext2',
            'WebGL2RenderingContextBase': 'RenderingContextBase2',
            'WindowTimers': '_WindowTimers',
            'XMLHttpRequest': 'HttpRequest',
            'XMLHttpRequestUpload': 'HttpRequestUpload',
            'XMLHttpRequestEventTarget': 'HttpRequestEventTarget',
        },
        **typed_array_renames))
示例#6
0
html_interface_renames = monitored.Dict('htmlrenamer.html_interface_renames',
                                        dict({
    'Attr': '_Attr',
    'CDATASection': 'CDataSection',
    'Clipboard': 'DataTransfer',
    'Database': 'SqlDatabase', # Avoid conflict with Index DB's Database.
    'DatabaseSync': 'SqlDatabaseSync',
    'DOMFileSystem': 'FileSystem',
    'WebKitPoint': '_DomPoint',
    'DOMRect': '_DomRect',
    'Entity': '_Entity', # Not sure if we want to expose this yet, may conflict with other libs.
    'EntryCallback': '_EntryCallback',
    'EntriesCallback': '_EntriesCallback',
    'ErrorCallback': '_ErrorCallback',
    'FileCallback': '_FileCallback',
    'FileSystemCallback': '_FileSystemCallback',
    'FileWriterCallback': '_FileWriterCallback',
    'HTMLDocument' : 'HtmlDocument',
    'HTMLElement' : 'HtmlElement',
    'HTMLHtmlElement' : 'HtmlHtmlElement',
    'IDBFactory': 'IdbFactory', # Manual to avoid name conflicts.
    'Key': 'CryptoKey',
    'NamedNodeMap': '_NamedNodeMap',
    'NavigatorUserMediaErrorCallback': '_NavigatorUserMediaErrorCallback',
    'NavigatorUserMediaSuccessCallback': '_NavigatorUserMediaSuccessCallback',
    'NotificationPermissionCallback': '_NotificationPermissionCallback',
    'PositionCallback': '_PositionCallback',
    'PositionErrorCallback': '_PositionErrorCallback',
    'Request': '_Request',
    'RTCDTMFSender': 'RtcDtmfSender',
    'RTCDTMFToneChangeEvent': 'RtcDtmfToneChangeEvent',
    'RTCErrorCallback': '_RtcErrorCallback',
    'RTCSessionDescriptionCallback': '_RtcSessionDescriptionCallback',
    'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts.
    'SVGElement': 'SvgElement', # Manual to avoid name conflicts.
    'SVGGradientElement': '_GradientElement',
    'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts.
    'Stream': 'FileStream',
    'StringCallback': '_StringCallback',
    'WebGLVertexArrayObjectOES': 'VertexArrayObject',
    'WindowTimers': '_WindowTimers',
    'XMLHttpRequest': 'HttpRequest',
    'XMLHttpRequestUpload': 'HttpRequestUpload',
    'XMLHttpRequestEventTarget': 'HttpRequestEventTarget',
}, **typed_array_renames))
示例#7
0
html_interface_renames = monitored.Dict(
    'htmlrenamer.html_interface_renames',
    dict(
        {
            'CDATASection': 'CDataSection',
            'Clipboard': 'DataTransfer',
            'Database':
            'SqlDatabase',  # Avoid conflict with Index DB's Database.
            'DatabaseSync': 'SqlDatabaseSync',
            'DOMApplicationCache': 'ApplicationCache',
            'DOMFileSystem': 'FileSystem',
            'DOMPoint': '_DomPoint',
            'EntryCallback': '_EntryCallback',
            'EntriesCallback': '_EntriesCallback',
            'ErrorCallback': '_ErrorCallback',
            'FileCallback': '_FileCallback',
            'FileSystemCallback': '_FileSystemCallback',
            'FileWriterCallback': '_FileWriterCallback',
            'HTMLDocument': 'HtmlDocument',
            'IDBFactory': 'IdbFactory',  # Manual to avoid name conflicts.
            'NamedNodeMap': '_NamedNodeMap',
            'NavigatorUserMediaErrorCallback':
            '_NavigatorUserMediaErrorCallback',
            'NavigatorUserMediaSuccessCallback':
            '_NavigatorUserMediaSuccessCallback',
            'NotificationPermissionCallback':
            '_NotificationPermissionCallback',
            'PositionCallback': '_PositionCallback',
            'PositionErrorCallback': '_PositionErrorCallback',
            'RTCDTMFSender': 'RtcDtmfSender',
            'RTCDTMFToneChangeEvent': 'RtcDtmfToneChangeEvent',
            'RTCErrorCallback': '_RtcErrorCallback',
            'RTCSessionDescriptionCallback': '_RtcSessionDescriptionCallback',
            'StringCallback': '_StringCallback',
            'SVGDocument': 'SvgDocument',  # Manual to avoid name conflicts.
            'SVGElement': 'SvgElement',  # Manual to avoid name conflicts.
            'SVGException':
            'SvgException',  # Manual of avoid conflict with Exception.
            'SVGGradientElement': '_GradientElement',
            'SVGSVGElement':
            'SvgSvgElement',  # Manual to avoid name conflicts.
            'WebGLVertexArrayObjectOES': 'VertexArrayObject',
            'XMLHttpRequest': 'HttpRequest',
            'XMLHttpRequestException': 'HttpRequestException',
            'XMLHttpRequestProgressEvent': 'HttpRequestProgressEvent',
            'XMLHttpRequestUpload': 'HttpRequestUpload',
        },
        **typed_array_renames))
示例#8
0
_html_element_constructors = monitored.Dict(
      'systemhtml._html_element_constructors', {
  'HTMLAnchorElement' :
    ElementConstructorInfo(tag='a', opt_params=[('DOMString', 'href')]),
  'HTMLAreaElement': 'area',
  'HTMLButtonElement': 'button',
  'HTMLBRElement': 'br',
  'HTMLBaseElement': 'base',
  'HTMLBodyElement': 'body',
  'HTMLButtonElement': 'button',
  'HTMLCanvasElement':
    ElementConstructorInfo(tag='canvas',
                           opt_params=[('int', 'width'), ('int', 'height')]),
  'HTMLContentElement': 'content',
  'HTMLDataListElement': 'datalist',
  'HTMLDListElement': 'dl',
  'HTMLDetailsElement': 'details',
  'HTMLDivElement': 'div',
  'HTMLEmbedElement': 'embed',
  'HTMLFieldSetElement': 'fieldset',
  'HTMLFormElement': 'form',
  'HTMLHRElement': 'hr',
  'HTMLHeadElement': 'head',
  'HTMLHeadingElement': [ElementConstructorInfo('h1'),
                     ElementConstructorInfo('h2'),
                     ElementConstructorInfo('h3'),
                     ElementConstructorInfo('h4'),
                     ElementConstructorInfo('h5'),
                     ElementConstructorInfo('h6')],
  'HTMLHtmlElement': 'html',
  'HTMLIFrameElement': 'iframe',
  'HTMLImageElement':
    ElementConstructorInfo(tag='img',
                           opt_params=[('DOMString', 'src'),
                                       ('int', 'width'), ('int', 'height')]),
  'HTMLKeygenElement': 'keygen',
  'HTMLLIElement': 'li',
  'HTMLLabelElement': 'label',
  'HTMLLegendElement': 'legend',
  'HTMLLinkElement': 'link',
  'HTMLMapElement': 'map',
  'HTMLMenuElement': 'menu',
  'HTMLMetaElement': 'meta',
  'HTMLMeterElement': 'meter',
  'HTMLOListElement': 'ol',
  'HTMLObjectElement': 'object',
  'HTMLOptGroupElement': 'optgroup',
  'HTMLOutputElement': 'output',
  'HTMLParagraphElement': 'p',
  'HTMLParamElement': 'param',
  'HTMLPreElement': 'pre',
  'HTMLProgressElement': 'progress',
  'HTMLQuoteElement': 'q',
  'HTMLScriptElement': 'script',
  'HTMLSelectElement': 'select',
  'HTMLShadowElement': 'shadow',
  'HTMLSourceElement': 'source',
  'HTMLSpanElement': 'span',
  'HTMLStyleElement': 'style',
  'HTMLTableCaptionElement': 'caption',
  'HTMLTableCellElement': 'td',
  'HTMLTableColElement': 'col',
  'HTMLTableElement': 'table',
  'HTMLTableRowElement': 'tr',
  #'HTMLTableSectionElement'  <thead> <tbody> <tfoot>
  'HTMLTemplateElement': 'template',
  'HTMLTextAreaElement': 'textarea',
  'HTMLTitleElement': 'title',
  'HTMLTrackElement': 'track',
  'HTMLUListElement': 'ul',
  'HTMLVideoElement': 'video'
})
示例#9
0
_dart2js_annotations = monitored.Dict('dartmetadata._dart2js_annotations', {

    'ArrayBufferView': [
      "@Creates('TypedData')",
      "@Returns('TypedData|Null')",
    ],

    'CanvasRenderingContext2D.createImageData': [
      "@Creates('ImageData|=Object')",
    ],

    'CanvasRenderingContext2D.getImageData': [
      "@Creates('ImageData|=Object')",
    ],

    'CanvasRenderingContext2D.webkitGetImageDataHD': [
      "@Creates('ImageData|=Object')",
    ],

    'CanvasRenderingContext2D.fillStyle': [
      "@Creates('String|CanvasGradient|CanvasPattern')",
      "@Returns('String|CanvasGradient|CanvasPattern')",
    ],

    'CanvasRenderingContext2D.strokeStyle': [
      "@Creates('String|CanvasGradient|CanvasPattern')",
      "@Returns('String|CanvasGradient|CanvasPattern')",
    ],

    # Normally DOMWindow is nevernull, but starting from a <template> element in
    # JavaScript, this will be null:
    #     template.content.ownerDocument.defaultView
    'Document.window': [
      "@Creates('Window|=Object|Null')",
      "@Returns('Window|=Object|Null')",
    ],

    # Methods returning Window can return a local window, or a cross-frame
    # window (=Object) that needs wrapping.
    'DOMWindow': [
      "@Creates('Window|=Object')",
      "@Returns('Window|=Object')",
    ],

    'DOMWindow.openDatabase': [
      "@Creates('SqlDatabase')",
    ],

    # To be in callback with the browser-created Event, we had to have called
    # addEventListener on the target, so we avoid
    'Event.currentTarget': [
      "@Creates('Null')",
      "@Returns('EventTarget|=Object')",
    ],

    # Only nodes in the DOM bubble and have target !== currentTarget.
    'Event.target': [
      "@Creates('Node')",
      "@Returns('EventTarget|=Object')",
    ],

    'MouseEvent.relatedTarget': [
      "@Creates('Node')",
      "@Returns('EventTarget|=Object')",
    ],

    # Touch targets are Elements in a Document, or the Document.
    'Touch.target': [
      "@Creates('Element|Document')",
      "@Returns('Element|Document')",
    ],

    'FileReader.result': ["@Creates('String|ByteBuffer|Null')"],

    # Rather than have the result of an IDBRequest as a union over all possible
    # results, we mark the result as instantiating any classes, and mark
    # each operation with the classes that it could cause to be asynchronously
    # instantiated.
    'IDBRequest.result': ["@Creates('Null')"],

    # The source is usually a participant in the operation that generated the
    # IDBRequest.
    'IDBRequest.source':  ["@Creates('Null')"],

    'IDBFactory.open': ["@Creates('Database')"],
    'IDBFactory.webkitGetDatabaseNames': ["@Creates('DomStringList')"],

    'IDBObjectStore.put': ["@_annotation_Creates_IDBKey"],
    'IDBObjectStore.add': ["@_annotation_Creates_IDBKey"],
    'IDBObjectStore.get': ["@annotation_Creates_SerializedScriptValue"],
    'IDBObjectStore.openCursor': ["@Creates('Cursor')"],

    'IDBIndex.get': ["@annotation_Creates_SerializedScriptValue"],
    'IDBIndex.getKey': [
      "@annotation_Creates_SerializedScriptValue",
      # The source is the object store behind the index.
      "@Creates('ObjectStore')",
    ],
    'IDBIndex.openCursor': ["@Creates('Cursor')"],
    'IDBIndex.openKeyCursor': ["@Creates('Cursor')"],

    'IDBCursorWithValue.value': [
      '@annotation_Creates_SerializedScriptValue',
      '@annotation_Returns_SerializedScriptValue',
    ],

    'IDBCursor.key': [
      "@_annotation_Creates_IDBKey",
      "@_annotation_Returns_IDBKey",
    ],

    '+IDBRequest': [
      "@Returns('Request')",
      "@Creates('Request')",
    ],

    '+IDBOpenDBRequest': [
      "@Returns('Request')",
      "@Creates('Request')",
    ],

    'MessageEvent.ports': ["@Creates('=List')"],

    'MessageEvent.data': [
      "@annotation_Creates_SerializedScriptValue",
      "@annotation_Returns_SerializedScriptValue",
    ],
    'PopStateEvent.state': [
      "@annotation_Creates_SerializedScriptValue",
      "@annotation_Returns_SerializedScriptValue",
    ],
    'SerializedScriptValue': [
      "@annotation_Creates_SerializedScriptValue",
      "@annotation_Returns_SerializedScriptValue",
    ],

    'SQLResultSetRowList.item': ["@Creates('=Object')"],

    'WebGLRenderingContext.getParameter': [
      # Taken from http://www.khronos.org/registry/webgl/specs/latest/
      # Section 5.14.3 Setting and getting state
      "@Creates('Null|num|String|bool|=List|Float32List|Int32List|Uint32List"
                "|Framebuffer|Renderbuffer|Texture')",
      "@Returns('Null|num|String|bool|=List|Float32List|Int32List|Uint32List"
                "|Framebuffer|Renderbuffer|Texture')",
    ],

    'XMLHttpRequest.response': [
      "@Creates('ByteBuffer|Blob|Document|=Object|=List|String|num')",
    ],
}, dart2jsOnly=True)
示例#10
0
_methods_with_named_formals = monitored.Set(
    'generator._methods_with_named_formals', [
  'DirectoryEntry.getDirectory',
  'DirectoryEntry.getFile',
  'Entry.copyTo',
  'Entry.moveTo',
  'HTMLInputElement.setRangeText',
  'HTMLTextAreaElement.setRangeText',
  'XMLHttpRequest.open',
  ])

#
# Renames for attributes that have names that are not legal Dart names.
#
_dart_attribute_renames = monitored.Dict('generator._dart_attribute_renames', {
    'default': 'defaultValue',
})

#
# Interface version of the DOM needs to delegate typed array constructors to a
# factory provider.
#
interface_factories = monitored.Dict('generator.interface_factories', {
})


#
# Custom native specs for the dart2js dom.
#
_dart2js_dom_custom_native_specs = monitored.Dict(
      'generator._dart2js_dom_custom_native_specs', {
示例#11
0
html_interface_renames = monitored.Dict(
    'htmlrenamer.html_interface_renames',
    dict(
        {
            'Attr': '_Attr',
            'CDATASection': 'CDataSection',
            'Clipboard': 'DataTransfer',
            'Database':
            'SqlDatabase',  # Avoid conflict with Index DB's Database.
            'DatabaseSync': 'SqlDatabaseSync',
            'DOMFileSystem': 'FileSystem',
            'DOMRect': '_DomRect',
            'Entity':
            '_Entity',  # Not sure if we want to expose this yet, may conflict with other libs.
            'EntryCallback': '_EntryCallback',
            'EntriesCallback': '_EntriesCallback',
            'ErrorCallback': '_ErrorCallback',
            'FileCallback': '_FileCallback',
            'FileSystemCallback': '_FileSystemCallback',
            'FileWriterCallback': '_FileWriterCallback',
            'HTMLDocument': 'HtmlDocument',
            'HTMLElement': 'HtmlElement',
            'HTMLHtmlElement': 'HtmlHtmlElement',
            'IDBFactory': 'IdbFactory',  # Manual to avoid name conflicts.
            'Iterator': 'DomIterator',
            'Key': 'CryptoKey',
            'NamedNodeMap': '_NamedNodeMap',
            'NavigatorUserMediaErrorCallback':
            '_NavigatorUserMediaErrorCallback',
            'NavigatorUserMediaSuccessCallback':
            '_NavigatorUserMediaSuccessCallback',
            'NotificationPermissionCallback':
            '_NotificationPermissionCallback',
            'PositionCallback': '_PositionCallback',
            'PositionErrorCallback': '_PositionErrorCallback',
            'Request': '_Request',
            'RTCDTMFSender': 'RtcDtmfSender',
            'RTCDTMFToneChangeEvent': 'RtcDtmfToneChangeEvent',
            'RTCErrorCallback': '_RtcErrorCallback',
            'RTCSessionDescriptionCallback': '_RtcSessionDescriptionCallback',
            'SVGDocument': 'SvgDocument',  # Manual to avoid name conflicts.
            'SVGElement': 'SvgElement',  # Manual to avoid name conflicts.
            'SVGGradientElement': '_GradientElement',
            'SVGSVGElement':
            'SvgSvgElement',  # Manual to avoid name conflicts.
            'Stream': 'FileStream',
            'StringCallback': '_StringCallback',
            'WebGL2RenderingContext': 'RenderingContext2',
            'WebGL2RenderingContextBase': 'RenderingContextBase2',
            'WindowTimers': '_WindowTimers',
            'XMLHttpRequest': 'HttpRequest',
            'XMLHttpRequestUpload': 'HttpRequestUpload',
            'XMLHttpRequestEventTarget': 'HttpRequestEventTarget',
        },
        **typed_array_renames))