mirror of
https://github.com/dart-lang/sdk
synced 2024-09-22 11:21:35 +00:00
Merging dart:html interfaces and implementations.
This CL leaves a lot of the infrastructure around for the interfaces (and also renames them to _IInterfaceName), but the interfaces are not in the generated files. I'll continue to clean this up in future CLs. BUG= Review URL: https://codereview.chromium.org//11365019 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14612 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
80a4b76c81
commit
4fc5d3a686
|
@ -894,6 +894,9 @@ class Dartdoc {
|
|||
listTypes(types, header) {
|
||||
if (types == null) return;
|
||||
|
||||
// Filter out injected types. (JavaScriptIndexingBehavior)
|
||||
types = new List.from(types.filter((t) => t.library != null));
|
||||
|
||||
var publicTypes;
|
||||
if (showPrivate) {
|
||||
publicTypes = types;
|
||||
|
@ -1537,7 +1540,9 @@ class Dartdoc {
|
|||
if (type is LibraryMirror) {
|
||||
return '${sanitize(type.simpleName)}.html';
|
||||
}
|
||||
assert (type is TypeMirror);
|
||||
if (type.library == null) {
|
||||
return '';
|
||||
}
|
||||
// Always get the generic type to strip off any type parameters or
|
||||
// arguments. If the type isn't generic, genericType returns `this`, so it
|
||||
// works for non-generic types too.
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -445,9 +445,6 @@ def TypeName(type_ids, interface):
|
|||
# Dynamically type this field for now.
|
||||
return 'dynamic'
|
||||
|
||||
def ImplementationClassNameForInterfaceName(interface_name):
|
||||
return '_%sImpl' % interface_name
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
class Conversion(object):
|
||||
|
@ -686,14 +683,14 @@ class InterfaceIDLTypeInfo(IDLTypeInfo):
|
|||
if self.idl_type() == 'NodeList':
|
||||
return 'List<Node>'
|
||||
if self.list_item_type():
|
||||
return ImplementationClassNameForInterfaceName(self.idl_type())
|
||||
return self.idl_type()
|
||||
# TODO(podivilov): only primitive and collection types should override
|
||||
# dart_type.
|
||||
if self._data.dart_type != None:
|
||||
return self.dart_type()
|
||||
if IsPureInterface(self.idl_type()):
|
||||
return self.idl_type()
|
||||
return ImplementationClassNameForInterfaceName(self.interface_name())
|
||||
return self.interface_name()
|
||||
|
||||
def interface_name(self):
|
||||
if self.list_item_type() and not self.has_generated_interface():
|
||||
|
@ -702,11 +699,15 @@ class InterfaceIDLTypeInfo(IDLTypeInfo):
|
|||
|
||||
def implementation_name(self):
|
||||
if self.list_item_type():
|
||||
return ImplementationClassNameForInterfaceName(self.idl_type())
|
||||
implementation_name = ImplementationClassNameForInterfaceName(
|
||||
self.interface_name())
|
||||
implementation_name = self.idl_type()
|
||||
else:
|
||||
implementation_name = self.interface_name()
|
||||
if self.merged_into():
|
||||
implementation_name = '%s_Merged' % implementation_name
|
||||
|
||||
if not self.has_generated_interface():
|
||||
implementation_name = '_%s' % implementation_name
|
||||
|
||||
return implementation_name
|
||||
|
||||
def has_generated_interface(self):
|
||||
|
|
88
sdk/lib/html/scripts/htmldartgenerator.py
Normal file
88
sdk/lib/html/scripts/htmldartgenerator.py
Normal file
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/python
|
||||
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
"""This module provides shared functionality for the system to generate
|
||||
dart:html APIs from the IDL database."""
|
||||
|
||||
from generator import DartDomNameOfAttribute
|
||||
|
||||
class HtmlDartGenerator(object):
|
||||
def __init__(self, interface, options):
|
||||
self._interface = interface
|
||||
|
||||
def EmitAttributeDocumentation(self, attribute):
|
||||
dom_name = DartDomNameOfAttribute(attribute)
|
||||
self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */',
|
||||
DOMINTERFACE=attribute.doc_js_interface_name,
|
||||
DOMNAME=dom_name)
|
||||
|
||||
def EmitOperationDocumentation(self, operation):
|
||||
self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */',
|
||||
DOMINTERFACE=operation.overloads[0].doc_js_interface_name,
|
||||
DOMNAME=operation.name)
|
||||
|
||||
def AdditionalImplementedInterfaces(self):
|
||||
# TODO: Include all implemented interfaces, including other Lists.
|
||||
implements = []
|
||||
if self._interface_type_info.is_typed_array():
|
||||
element_type = self._interface_type_info.list_item_type()
|
||||
implements.append('List<%s>' % self._DartType(element_type))
|
||||
if self._interface_type_info.list_item_type():
|
||||
item_type_info = self._type_registry.TypeInfo(
|
||||
self._interface_type_info.list_item_type())
|
||||
implements.append('List<%s>' % item_type_info.dart_type())
|
||||
return implements
|
||||
|
||||
def AddConstructors(self, constructors, factory_provider, class_name,
|
||||
base_class):
|
||||
for constructor_info in constructors:
|
||||
self._AddConstructor(constructor_info, factory_provider)
|
||||
|
||||
typed_array_type = None
|
||||
for interface in self._database.Hierarchy(self._interface):
|
||||
type_info = self._type_registry.TypeInfo(interface.id)
|
||||
if type_info.is_typed_array():
|
||||
typed_array_type = type_info.list_item_type()
|
||||
break
|
||||
if typed_array_type:
|
||||
self._members_emitter.Emit(
|
||||
'\n'
|
||||
' factory $CTOR(int length) =>\n'
|
||||
' $FACTORY.create$(CTOR)(length);\n'
|
||||
'\n'
|
||||
' factory $CTOR.fromList(List<$TYPE> list) =>\n'
|
||||
' $FACTORY.create$(CTOR)_fromList(list);\n'
|
||||
'\n'
|
||||
' factory $CTOR.fromBuffer(ArrayBuffer buffer, [int byteOffset, int length]) => \n'
|
||||
' $FACTORY.create$(CTOR)_fromBuffer(buffer, byteOffset, length);\n',
|
||||
CTOR=self._interface.id,
|
||||
TYPE=self._DartType(typed_array_type),
|
||||
FACTORY=factory_provider)
|
||||
|
||||
def _AddConstructor(self, constructor_info, factory_provider):
|
||||
constructor_info.GenerateFactoryInvocation(
|
||||
self._DartType, self._members_emitter, factory_provider)
|
||||
|
||||
def DeclareAttribute(self, attribute, type_name, html_name, read_only):
|
||||
# Declares an attribute but does not include the code to invoke it.
|
||||
self.EmitAttributeDocumentation(attribute)
|
||||
if read_only:
|
||||
template = '\n $TYPE get $NAME;\n'
|
||||
else:
|
||||
template = '\n $TYPE $NAME;\n'
|
||||
|
||||
self._members_emitter.Emit(template,
|
||||
NAME=html_name,
|
||||
TYPE=type_name)
|
||||
|
||||
def DeclareOperation(self, operation, type_name, html_name):
|
||||
# Declares an operation but does not include the code to invoke it.
|
||||
self.EmitOperationDocumentation(operation)
|
||||
self._members_emitter.Emit(
|
||||
'\n'
|
||||
' $TYPE $NAME($PARAMS);\n',
|
||||
TYPE=type_name,
|
||||
NAME=html_name,
|
||||
PARAMS=operation.ParametersDeclaration(self._DartType))
|
|
@ -202,30 +202,24 @@ class HtmlEventGenerator(object):
|
|||
return None
|
||||
|
||||
self._event_classes.add(interface.id)
|
||||
events_interface = html_interface_name + 'Events'
|
||||
events_class_name = html_interface_name + 'Events'
|
||||
parent_events_interface = self._GetParentEventsInterface(interface)
|
||||
|
||||
if not events:
|
||||
return parent_events_interface
|
||||
|
||||
interface_events_members = events_interface_emitter.Emit(
|
||||
'\nabstract class $INTERFACE implements $PARENT {\n$!MEMBERS}\n',
|
||||
INTERFACE=events_interface,
|
||||
PARENT=parent_events_interface)
|
||||
|
||||
template_file = 'impl_%s.darttemplate' % events_interface
|
||||
template_file = 'impl_%s.darttemplate' % events_class_name
|
||||
template = (self._template_loader.TryLoad(template_file) or
|
||||
'\n'
|
||||
'class $CLASSNAME extends $SUPER implements $INTERFACE {\n'
|
||||
' $CLASSNAME(_ptr) : super(_ptr);\n'
|
||||
'class $CLASSNAME extends $SUPER {\n'
|
||||
' $CLASSNAME(EventTarget _ptr) : super(_ptr);\n'
|
||||
'$!MEMBERS}\n')
|
||||
|
||||
# TODO(jacobr): specify the type of _ptr as EventTarget
|
||||
implementation_events_members = events_implementation_emitter.Emit(
|
||||
template,
|
||||
CLASSNAME='_%sImpl' % events_interface,
|
||||
INTERFACE=events_interface,
|
||||
SUPER='_%sImpl' % parent_events_interface)
|
||||
CLASSNAME=events_class_name,
|
||||
SUPER='%s' % parent_events_interface)
|
||||
|
||||
dom_event_names = set()
|
||||
for event in events:
|
||||
|
@ -240,8 +234,6 @@ class HtmlEventGenerator(object):
|
|||
continue
|
||||
|
||||
html_name = _html_event_names[dom_name]
|
||||
interface_events_members.Emit('\n EventListenerList get $NAME;\n',
|
||||
NAME=html_name)
|
||||
full_event_name = '%sEvents.%s' % (html_interface_name, html_name)
|
||||
if not full_event_name in custom_events:
|
||||
implementation_events_members.Emit(
|
||||
|
@ -250,7 +242,7 @@ class HtmlEventGenerator(object):
|
|||
NAME=html_name,
|
||||
DOM_NAME=dom_name)
|
||||
|
||||
return events_interface
|
||||
return events_class_name
|
||||
|
||||
# TODO(jacobr): this isn't quite right....
|
||||
def _GetParentEventsInterface(self, interface):
|
||||
|
|
|
@ -9,6 +9,7 @@ Dart:html APIs from the IDL database."""
|
|||
import emitter
|
||||
import os
|
||||
from generator import *
|
||||
from htmldartgenerator import *
|
||||
|
||||
_js_custom_members = set([
|
||||
'AudioBufferSourceNode.start',
|
||||
|
@ -188,7 +189,7 @@ def EmitHtmlElementFactoryConstructors(emitter, infos, typename, class_name,
|
|||
inits = emitter.Emit(
|
||||
'\n'
|
||||
' static $RETURN_TYPE $CONSTRUCTOR($PARAMS) {\n'
|
||||
' $CLASS _e = _document.$dom_createElement("$TAG");\n'
|
||||
' $CLASS _e = document.$dom_createElement("$TAG");\n'
|
||||
'$!INITS'
|
||||
' return _e;\n'
|
||||
' }\n',
|
||||
|
@ -239,11 +240,8 @@ class HtmlDartInterfaceGenerator(object):
|
|||
def GenerateInterface(self):
|
||||
interface_name = self._interface_type_info.interface_name()
|
||||
|
||||
if (self._interface_type_info.has_generated_interface() and
|
||||
not self._interface_type_info.merged_into()):
|
||||
interface_emitter = self._library_emitter.FileEmitter(interface_name)
|
||||
else:
|
||||
interface_emitter = emitter.Emitter()
|
||||
# TODO: this is just tossing the interface, need to skip it completely.
|
||||
interface_emitter = emitter.Emitter()
|
||||
|
||||
template_file = 'interface_%s.darttemplate' % interface_name
|
||||
interface_template = (self._template_loader.TryLoad(template_file) or
|
||||
|
@ -308,30 +306,45 @@ class HtmlDartInterfaceGenerator(object):
|
|||
self._members_emitter,
|
||||
self._top_level_emitter) = interface_emitter.Emit(
|
||||
interface_template + '$!TOP_LEVEL',
|
||||
ID=interface_name,
|
||||
ID='_I%s' % interface_name,
|
||||
EXTENDS=implements_str)
|
||||
|
||||
self._type_comment_emitter.Emit("/// @domName $DOMNAME",
|
||||
DOMNAME=self._interface.doc_js_name)
|
||||
|
||||
implementation_emitter = self._ImplementationEmitter()
|
||||
|
||||
base_class = self._backend.RootClassName()
|
||||
base_type_info = None
|
||||
if self._interface.parents:
|
||||
supertype = self._interface.parents[0].type.id
|
||||
if not IsDartCollectionType(supertype) and not IsPureInterface(supertype):
|
||||
type_info = self._type_registry.TypeInfo(supertype)
|
||||
if type_info.merged_into() and self._backend.ImplementsMergedMembers():
|
||||
type_info = self._type_registry.TypeInfo(type_info.merged_into())
|
||||
base_class = type_info.implementation_name()
|
||||
base_type_info = self._type_registry.TypeInfo(supertype)
|
||||
if base_type_info.merged_into() \
|
||||
and self._backend.ImplementsMergedMembers():
|
||||
base_type_info = self._type_registry.TypeInfo(
|
||||
base_type_info.merged_into())
|
||||
|
||||
if base_type_info:
|
||||
base_class = base_type_info.implementation_name()
|
||||
else:
|
||||
base_class = self._backend.RootClassName()
|
||||
|
||||
implements = self._backend.AdditionalImplementedInterfaces()
|
||||
for parent in self._interface.parents:
|
||||
parent_type_info = self._type_registry.TypeInfo(parent.type.id)
|
||||
if parent_type_info != base_type_info:
|
||||
implements.append(parent_type_info.interface_name())
|
||||
|
||||
if interface_name in _secure_base_types:
|
||||
implements.append(_secure_base_types[interface_name])
|
||||
|
||||
implements_str = ''
|
||||
if implements:
|
||||
implements_str = ' implements ' + ', '.join(set(implements))
|
||||
|
||||
implemented_interfaces = [interface_name] +\
|
||||
self._backend.AdditionalImplementedInterfaces()
|
||||
self._implementation_members_emitter = implementation_emitter.Emit(
|
||||
self._backend.ImplementationTemplate(),
|
||||
CLASSNAME=self._interface_type_info.implementation_name(),
|
||||
EXTENDS=' extends %s' % base_class if base_class else '',
|
||||
IMPLEMENTS=' implements ' + ', '.join(implemented_interfaces),
|
||||
IMPLEMENTS=implements_str,
|
||||
DOMNAME=self._interface.doc_js_name,
|
||||
NATIVESPEC=self._backend.NativeSpec())
|
||||
self._backend.StartInterface(self._implementation_members_emitter)
|
||||
|
||||
|
@ -339,13 +352,17 @@ class HtmlDartInterfaceGenerator(object):
|
|||
constructor_info.GenerateFactoryInvocation(
|
||||
self._DartType, self._members_emitter, factory_provider)
|
||||
|
||||
element_type = None
|
||||
self._backend.AddConstructors(constructors, factory_provider,
|
||||
self._interface_type_info.implementation_name(),
|
||||
base_class)
|
||||
|
||||
typed_array_type = None
|
||||
for interface in self._database.Hierarchy(self._interface):
|
||||
type_info = self._type_registry.TypeInfo(interface.id)
|
||||
if type_info.is_typed_array():
|
||||
element_type = type_info.list_item_type()
|
||||
typed_array_type = type_info.list_item_type()
|
||||
break
|
||||
if element_type:
|
||||
if typed_array_type:
|
||||
self._members_emitter.Emit(
|
||||
'\n'
|
||||
' factory $CTOR(int length) =>\n'
|
||||
|
@ -357,7 +374,7 @@ class HtmlDartInterfaceGenerator(object):
|
|||
' factory $CTOR.fromBuffer(ArrayBuffer buffer, [int byteOffset, int length]) => \n'
|
||||
' $FACTORY.create$(CTOR)_fromBuffer(buffer, byteOffset, length);\n',
|
||||
CTOR=self._interface.id,
|
||||
TYPE=self._DartType(element_type),
|
||||
TYPE=self._DartType(typed_array_type),
|
||||
FACTORY=factory_provider)
|
||||
|
||||
events_interface = self._event_generator.ProcessInterface(
|
||||
|
@ -365,7 +382,7 @@ class HtmlDartInterfaceGenerator(object):
|
|||
self._backend.CustomJSMembers(),
|
||||
interface_emitter, implementation_emitter)
|
||||
if events_interface:
|
||||
self._EmitEventGetter(events_interface, '_%sImpl' % events_interface)
|
||||
self._EmitEventGetter(events_interface, events_interface)
|
||||
|
||||
old_backend = self._backend
|
||||
if not self._backend.ImplementsMergedMembers():
|
||||
|
@ -376,16 +393,19 @@ class HtmlDartInterfaceGenerator(object):
|
|||
self._backend = old_backend
|
||||
|
||||
self.AddMembers(self._interface)
|
||||
if merged_interface and not self._backend.ImplementsMergedMembers():
|
||||
self.AddMembers(self._database.GetInterface(merged_interface), True)
|
||||
|
||||
self.AddSecondaryMembers(self._interface)
|
||||
self._backend.FinishInterface()
|
||||
|
||||
def AddMembers(self, interface):
|
||||
def AddMembers(self, interface, declare_only=False):
|
||||
for const in sorted(interface.constants, ConstantOutputOrder):
|
||||
self.AddConstant(const)
|
||||
|
||||
for attr in sorted(interface.attributes, ConstantOutputOrder):
|
||||
if attr.type.id != 'EventListener':
|
||||
self.AddAttribute(attr)
|
||||
self.AddAttribute(attr, False, declare_only)
|
||||
|
||||
# The implementation should define an indexer if the interface directly
|
||||
# extends List.
|
||||
|
@ -413,7 +433,7 @@ class HtmlDartInterfaceGenerator(object):
|
|||
for id in sorted(operationsById.keys()):
|
||||
operations = operationsById[id]
|
||||
info = AnalyzeOperation(interface, operations)
|
||||
self.AddOperation(info)
|
||||
self.AddOperation(info, False, declare_only)
|
||||
|
||||
def AddSecondaryMembers(self, interface):
|
||||
# With multiple inheritance, attributes and operations of non-first
|
||||
|
@ -448,7 +468,7 @@ class HtmlDartInterfaceGenerator(object):
|
|||
def AmendIndexer(self, element_type):
|
||||
self._backend.AmendIndexer(element_type)
|
||||
|
||||
def AddAttribute(self, attribute, is_secondary=False):
|
||||
def AddAttribute(self, attribute, is_secondary=False, declare_only=False):
|
||||
dom_name = DartDomNameOfAttribute(attribute)
|
||||
html_name = self._renamer.RenameMember(
|
||||
self._interface.id, attribute, dom_name, 'get:')
|
||||
|
@ -477,13 +497,17 @@ class HtmlDartInterfaceGenerator(object):
|
|||
NAME=html_name,
|
||||
TYPE=SecureOutputType(self, attribute.type.id))
|
||||
|
||||
self._backend.AddAttribute(attribute, html_name, read_only)
|
||||
if declare_only:
|
||||
self._backend.DeclareAttribute(attribute,
|
||||
SecureOutputType(self, attribute.type.id), html_name, read_only)
|
||||
else:
|
||||
self._backend.AddAttribute(attribute, html_name, read_only)
|
||||
|
||||
def AddSecondaryAttribute(self, interface, attribute):
|
||||
self._backend.SecondaryContext(interface)
|
||||
self.AddAttribute(attribute, True)
|
||||
|
||||
def AddOperation(self, info, skip_declaration=False):
|
||||
def AddOperation(self, info, skip_declaration=False, declare_only=False):
|
||||
"""
|
||||
Arguments:
|
||||
operations - contains the overloads, one or more operations with the same
|
||||
|
@ -521,11 +545,15 @@ class HtmlDartInterfaceGenerator(object):
|
|||
TYPE=SecureOutputType(self, info.type_name),
|
||||
NAME=html_name,
|
||||
PARAMS=info.ParametersDeclaration(self._DartType))
|
||||
self._backend.AddOperation(info, html_name)
|
||||
if declare_only:
|
||||
self._backend.DeclareOperation(info,
|
||||
SecureOutputType(self, info.type_name), html_name)
|
||||
else:
|
||||
self._backend.AddOperation(info, html_name)
|
||||
|
||||
def AddSecondaryOperation(self, interface, info):
|
||||
self._backend.SecondaryContext(interface)
|
||||
self.AddOperation(info, True)
|
||||
self.AddOperation(info)
|
||||
|
||||
def AddConstant(self, constant):
|
||||
type = TypeOrNothing(self._DartType(constant.type.id), constant.type.id)
|
||||
|
@ -534,15 +562,15 @@ class HtmlDartInterfaceGenerator(object):
|
|||
TYPE=type,
|
||||
VALUE=constant.value)
|
||||
|
||||
self._backend.AddConstant(constant)
|
||||
|
||||
def _ImplementationEmitter(self):
|
||||
if IsPureInterface(self._interface.id):
|
||||
return emitter.Emitter()
|
||||
basename = self._interface_type_info.implementation_name()
|
||||
if (self._interface_type_info.merged_into() and
|
||||
self._backend.ImplementsMergedMembers()):
|
||||
# Merged members are implemented in target interface implementation.
|
||||
return emitter.Emitter()
|
||||
return self._library_emitter.FileEmitter(basename.lstrip('_'))
|
||||
return self._library_emitter.FileEmitter(basename)
|
||||
|
||||
def _EmitEventGetter(self, events_interface, events_class):
|
||||
self._members_emitter.Emit(
|
||||
|
@ -554,6 +582,10 @@ class HtmlDartInterfaceGenerator(object):
|
|||
TYPE=events_interface)
|
||||
|
||||
self._implementation_members_emitter.Emit(
|
||||
'\n /**'
|
||||
'\n * @domName EventTarget.addEventListener, '
|
||||
'EventTarget.removeEventListener, EventTarget.dispatchEvent'
|
||||
'\n */'
|
||||
'\n $TYPE get on =>\n new $TYPE(this);\n',
|
||||
TYPE=events_class)
|
||||
|
||||
|
@ -604,16 +636,18 @@ class HtmlGeneratorDummyBackend(object):
|
|||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
class Dart2JSBackend(object):
|
||||
class Dart2JSBackend(HtmlDartGenerator):
|
||||
"""Generates a dart2js class for the dart:html library from a DOM IDL
|
||||
interface.
|
||||
"""
|
||||
|
||||
def __init__(self, interface, options):
|
||||
self._interface = interface
|
||||
super(Dart2JSBackend, self).__init__(interface, options)
|
||||
|
||||
self._database = options.database
|
||||
self._template_loader = options.templates
|
||||
self._type_registry = options.type_registry
|
||||
self._renamer = options.renamer
|
||||
self._interface_type_info = self._type_registry.TypeInfo(self._interface.id)
|
||||
self._current_secondary_parent = None
|
||||
|
||||
|
@ -627,11 +661,7 @@ class Dart2JSBackend(object):
|
|||
return None
|
||||
|
||||
def AdditionalImplementedInterfaces(self):
|
||||
# TODO: Include all implemented interfaces, including other Lists.
|
||||
implements = []
|
||||
if self._interface_type_info.is_typed_array():
|
||||
element_type = self._interface_type_info.list_item_type()
|
||||
implements.append('List<%s>' % self._DartType(element_type))
|
||||
implements = super(Dart2JSBackend, self).AdditionalImplementedInterfaces()
|
||||
if self._interface_type_info.list_item_type():
|
||||
implements.append('JavaScriptIndexingBehavior')
|
||||
return implements
|
||||
|
@ -641,6 +671,9 @@ class Dart2JSBackend(object):
|
|||
return ' native "%s"' % native_spec
|
||||
|
||||
def ImplementationTemplate(self):
|
||||
if IsPureInterface(self._interface.id):
|
||||
return self._template_loader.Load('pure_interface.darttemplate')
|
||||
|
||||
template_file = ('impl_%s.darttemplate' %
|
||||
self._interface_type_info.interface_name())
|
||||
return (self._template_loader.TryLoad(template_file) or
|
||||
|
@ -733,6 +766,10 @@ class Dart2JSBackend(object):
|
|||
if self._HasCustomImplementation(attribute.id):
|
||||
return
|
||||
|
||||
if IsPureInterface(self._interface.id):
|
||||
self._AddInterfaceAttribute(attribute)
|
||||
return
|
||||
|
||||
if attribute.id != html_name:
|
||||
self._AddAttributeUsingProperties(attribute, html_name, read_only)
|
||||
return
|
||||
|
@ -771,6 +808,7 @@ class Dart2JSBackend(object):
|
|||
|
||||
output_type = self._NarrowOutputType(attribute.type.id)
|
||||
input_type = self._NarrowInputType(attribute.type.id)
|
||||
self.EmitAttributeDocumentation(attribute)
|
||||
if not read_only:
|
||||
self._members_emitter.Emit(
|
||||
'\n $TYPE $NAME;'
|
||||
|
@ -789,7 +827,16 @@ class Dart2JSBackend(object):
|
|||
if not read_only:
|
||||
self._AddRenamingSetter(attribute, html_name)
|
||||
|
||||
def _AddInterfaceAttribute(self, attribute):
|
||||
self._members_emitter.Emit(
|
||||
'\n $TYPE $NAME;'
|
||||
'\n',
|
||||
NAME=DartDomNameOfAttribute(attribute),
|
||||
TYPE=self._NarrowOutputType(attribute.type.id))
|
||||
|
||||
def _AddRenamingGetter(self, attr, html_name):
|
||||
self.EmitAttributeDocumentation(attr)
|
||||
|
||||
conversion = self._OutputConversion(attr.type.id, attr.id)
|
||||
if conversion:
|
||||
return self._AddConvertingGetter(attr, html_name, conversion)
|
||||
|
@ -803,6 +850,8 @@ class Dart2JSBackend(object):
|
|||
TYPE=return_type)
|
||||
|
||||
def _AddRenamingSetter(self, attr, html_name):
|
||||
self.EmitAttributeDocumentation(attr)
|
||||
|
||||
conversion = self._InputConversion(attr.type.id, attr.id)
|
||||
if conversion:
|
||||
return self._AddConvertingSetter(attr, html_name, conversion)
|
||||
|
@ -856,8 +905,12 @@ class Dart2JSBackend(object):
|
|||
if self._HasCustomImplementation(info.name):
|
||||
return
|
||||
|
||||
# Any conversions needed?
|
||||
if any(self._OperationRequiresConversions(op) for op in info.overloads):
|
||||
self.EmitOperationDocumentation(info)
|
||||
|
||||
if IsPureInterface(self._interface.id):
|
||||
self._AddInterfaceOperation(info, html_name)
|
||||
elif any(self._OperationRequiresConversions(op) for op in info.overloads):
|
||||
# Any conversions needed?
|
||||
self._AddOperationWithConversions(info, html_name)
|
||||
else:
|
||||
self._AddDirectNativeOperation(info, html_name)
|
||||
|
@ -1026,6 +1079,20 @@ class Dart2JSBackend(object):
|
|||
argument_count = position
|
||||
GenerateCall(operation, argument_count, [])
|
||||
|
||||
def _AddInterfaceOperation(self, info, html_name):
|
||||
self._members_emitter.Emit(
|
||||
'\n'
|
||||
' $TYPE $NAME($PARAMS);\n',
|
||||
TYPE=self._NarrowOutputType(info.type_name),
|
||||
NAME=info.name,
|
||||
PARAMS=info.ParametersDeclaration(self._NarrowInputType))
|
||||
|
||||
def AddConstant(self, constant):
|
||||
type = TypeOrNothing(self._DartType(constant.type.id), constant.type.id)
|
||||
self._members_emitter.Emit('\n static const $TYPE$NAME = $VALUE;\n',
|
||||
NAME=constant.id,
|
||||
TYPE=type,
|
||||
VALUE=constant.value)
|
||||
|
||||
def _IsOptional(self, operation, argument):
|
||||
return IsOptional(argument)
|
||||
|
@ -1063,8 +1130,7 @@ class Dart2JSBackend(object):
|
|||
return self._NarrowToImplementationType(type_name)
|
||||
|
||||
def _NarrowOutputType(self, type_name):
|
||||
secure_name = SecureOutputType(self, type_name, True)
|
||||
return self._NarrowToImplementationType(secure_name)
|
||||
return SecureOutputType(self, type_name)
|
||||
|
||||
def _FindShadowedAttribute(self, attr):
|
||||
"""Returns (attribute, superinterface) or (None, None)."""
|
||||
|
|
|
@ -10,11 +10,14 @@ import emitter
|
|||
import os
|
||||
from generator import *
|
||||
from systemhtml import SecureOutputType
|
||||
from htmldartgenerator import *
|
||||
|
||||
class DartiumBackend(object):
|
||||
class DartiumBackend(HtmlDartGenerator):
|
||||
"""Generates Dart implementation for one DOM IDL interface."""
|
||||
|
||||
def __init__(self, interface, cpp_library_emitter, options):
|
||||
super(DartiumBackend, self).__init__(interface, options)
|
||||
|
||||
self._interface = interface
|
||||
self._cpp_library_emitter = cpp_library_emitter
|
||||
self._database = options.database
|
||||
|
@ -104,9 +107,6 @@ class DartiumBackend(object):
|
|||
def RootClassName(self):
|
||||
return 'NativeFieldWrapperClass1'
|
||||
|
||||
def AdditionalImplementedInterfaces(self):
|
||||
return []
|
||||
|
||||
def NativeSpec(self):
|
||||
return ''
|
||||
|
||||
|
@ -209,6 +209,20 @@ class DartiumBackend(object):
|
|||
ARGUMENTS=constructor_info.ParametersAsArgumentList(),
|
||||
NATIVE_NAME=native_binding)
|
||||
|
||||
def AddConstructors(self, constructors, factory_provider, class_name,
|
||||
base_class):
|
||||
super(DartiumBackend, self).AddConstructors(constructors, factory_provider,
|
||||
class_name, base_class)
|
||||
|
||||
super_constructor = ''
|
||||
if base_class and base_class != 'NativeFieldWrapperClass1':
|
||||
super_constructor = ': super.internal()'
|
||||
|
||||
self._members_emitter.Emit(
|
||||
' $CLASSNAME.internal()$SUPERCONSTRUCTOR;\n',
|
||||
CLASSNAME=class_name,
|
||||
SUPERCONSTRUCTOR=super_constructor)
|
||||
|
||||
def FinishInterface(self):
|
||||
self._GenerateCPPHeader()
|
||||
|
||||
|
@ -462,6 +476,13 @@ class DartiumBackend(object):
|
|||
else:
|
||||
self._GenerateDispatcher(info.operations, dart_declaration, [info.name for info in info.param_infos])
|
||||
|
||||
def AddConstant(self, constant):
|
||||
type = TypeOrNothing(self._DartType(constant.type.id), constant.type.id)
|
||||
self._members_emitter.Emit('\n static const $TYPE$NAME = $VALUE;\n',
|
||||
NAME=constant.id,
|
||||
TYPE=type,
|
||||
VALUE=constant.value)
|
||||
|
||||
def _GenerateDispatcher(self, operations, dart_declaration, argument_names):
|
||||
|
||||
body = self._members_emitter.Emit(
|
||||
|
@ -757,8 +778,12 @@ class DartiumBackend(object):
|
|||
native_binding = '%s_%s_%s' % (self._interface.id, idl_name, native_suffix)
|
||||
self._members_emitter.Emit(
|
||||
'\n'
|
||||
' $DART_DECLARATION native "$NATIVE_BINDING";\n',
|
||||
DART_DECLARATION=dart_declaration, NATIVE_BINDING=native_binding)
|
||||
'\n /** @domName $DOMINTERFACE.$DOMNAME */'
|
||||
'\n $DART_DECLARATION native "$NATIVE_BINDING";\n',
|
||||
DOMINTERFACE=self._interface.id,
|
||||
DOMNAME=idl_name,
|
||||
DART_DECLARATION=dart_declaration,
|
||||
NATIVE_BINDING=native_binding)
|
||||
|
||||
cpp_callback_name = '%s%s' % (idl_name, native_suffix)
|
||||
self._cpp_resolver_emitter.Emit(
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// window as a parameter.
|
||||
|
||||
Window _convertNativeToDart_Window(win) {
|
||||
return _DOMWindowCrossFrameImpl._createSafe(win);
|
||||
return _DOMWindowCrossFrame._createSafe(win);
|
||||
}
|
||||
|
||||
EventTarget _convertNativeToDart_EventTarget(e) {
|
||||
|
@ -35,13 +35,13 @@ EventTarget _convertNativeToDart_EventTarget(e) {
|
|||
// from a different frame - without a patched prototype - so we cannot
|
||||
// rely on Dart type checking.
|
||||
if (JS('bool', r'"setInterval" in #', e))
|
||||
return _DOMWindowCrossFrameImpl._createSafe(e);
|
||||
return _DOMWindowCrossFrame._createSafe(e);
|
||||
else
|
||||
return e;
|
||||
}
|
||||
|
||||
EventTarget _convertDartToNative_EventTarget(e) {
|
||||
if (e is _DOMWindowCrossFrameImpl) {
|
||||
if (e is _DOMWindowCrossFrame) {
|
||||
return e._window;
|
||||
} else {
|
||||
return e;
|
||||
|
@ -75,9 +75,11 @@ ImageData _convertNativeToDart_ImageData(nativeImageData) {
|
|||
// We can get rid of this conversion if _TypedImageData implements the fields
|
||||
// with native names.
|
||||
_convertDartToNative_ImageData(ImageData imageData) {
|
||||
if (imageData is _ImageDataImpl) return imageData;
|
||||
return JS('Object', '{data: #, height: #, width: #}',
|
||||
imageData.data, imageData.height, imageData.width);
|
||||
if (imageData is _TypedImageData) {
|
||||
return JS('Object', '{data: #, height: #, width: #}',
|
||||
imageData.data, imageData.height, imageData.width);
|
||||
}
|
||||
return imageData;
|
||||
}
|
||||
|
||||
|
||||
|
@ -231,33 +233,15 @@ _convertDartToNative_PrepareForStructuredClone(value) {
|
|||
// TODO(sra): The JavaScript objects suitable for direct cloning by the
|
||||
// structured clone algorithm could be tagged with an private interface.
|
||||
|
||||
if (e is _FileImpl) return e;
|
||||
if (e is File) {
|
||||
throw new UnimplementedError('structured clone of File');
|
||||
}
|
||||
|
||||
if (e is _BlobImpl) return e;
|
||||
if (e is Blob) {
|
||||
throw new UnimplementedError('structured clone of Blob');
|
||||
}
|
||||
|
||||
if (e is _FileListImpl) return e;
|
||||
if (e is File) return e;
|
||||
if (e is Blob) return e;
|
||||
if (e is _FileList) return e;
|
||||
|
||||
// TODO(sra): Firefox: How to convert _TypedImageData on the other end?
|
||||
if (e is _ImageDataImpl) return e;
|
||||
if (e is ImageData) {
|
||||
throw new UnimplementedError('structured clone of ImageData');
|
||||
}
|
||||
if (e is ImageData) return e;
|
||||
if (e is ArrayBuffer) return e;
|
||||
|
||||
if (e is _ArrayBufferImpl) return e;
|
||||
if (e is ArrayBuffer) {
|
||||
throw new UnimplementedError('structured clone of ArrayBuffer');
|
||||
}
|
||||
|
||||
if (e is _ArrayBufferViewImpl) return e;
|
||||
if (e is ArrayBufferView) {
|
||||
throw new UnimplementedError('structured clone of ArrayBufferView');
|
||||
}
|
||||
if (e is ArrayBufferView) return e;
|
||||
|
||||
if (e is Map) {
|
||||
var slot = findSlot(e);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// TODO(vsm): Unify with Dartium version.
|
||||
class _DOMWindowCrossFrameImpl implements Window {
|
||||
class _DOMWindowCrossFrame implements Window {
|
||||
// Private window. Note, this is a window in another frame, so it
|
||||
// cannot be typed as "Window" as its prototype is not patched
|
||||
// properly. Its fields and methods can only be accessed via JavaScript.
|
||||
|
@ -11,9 +11,9 @@ class _DOMWindowCrossFrameImpl implements Window {
|
|||
|
||||
// Fields.
|
||||
History get history =>
|
||||
_HistoryCrossFrameImpl._createSafe(JS('History', '#.history', _window));
|
||||
_HistoryCrossFrame._createSafe(JS('History', '#.history', _window));
|
||||
Location get location =>
|
||||
_LocationCrossFrameImpl._createSafe(JS('Location', '#.location', _window));
|
||||
_LocationCrossFrame._createSafe(JS('Location', '#.location', _window));
|
||||
|
||||
// TODO(vsm): Add frames to navigate subframes. See 2312.
|
||||
|
||||
|
@ -41,19 +41,19 @@ class _DOMWindowCrossFrameImpl implements Window {
|
|||
}
|
||||
|
||||
// Implementation support.
|
||||
_DOMWindowCrossFrameImpl(this._window);
|
||||
_DOMWindowCrossFrame(this._window);
|
||||
|
||||
static Window _createSafe(w) {
|
||||
if (identical(w, window)) {
|
||||
return w;
|
||||
} else {
|
||||
// TODO(vsm): Cache or implement equality.
|
||||
return new _DOMWindowCrossFrameImpl(w);
|
||||
return new _DOMWindowCrossFrame(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _LocationCrossFrameImpl implements Location {
|
||||
class _LocationCrossFrame implements Location {
|
||||
// Private location. Note, this is a location object in another frame, so it
|
||||
// cannot be typed as "Location" as its prototype is not patched
|
||||
// properly. Its fields and methods can only be accessed via JavaScript.
|
||||
|
@ -65,19 +65,19 @@ class _LocationCrossFrameImpl implements Location {
|
|||
}
|
||||
|
||||
// Implementation support.
|
||||
_LocationCrossFrameImpl(this._location);
|
||||
_LocationCrossFrame(this._location);
|
||||
|
||||
static Location _createSafe(location) {
|
||||
if (identical(location, window.location)) {
|
||||
return location;
|
||||
} else {
|
||||
// TODO(vsm): Cache or implement equality.
|
||||
return new _LocationCrossFrameImpl(location);
|
||||
return new _LocationCrossFrame(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _HistoryCrossFrameImpl implements History {
|
||||
class _HistoryCrossFrame implements History {
|
||||
// Private history. Note, this is a history object in another frame, so it
|
||||
// cannot be typed as "History" as its prototype is not patched
|
||||
// properly. Its fields and methods can only be accessed via JavaScript.
|
||||
|
@ -90,14 +90,14 @@ class _HistoryCrossFrameImpl implements History {
|
|||
void go(int distance) => JS('void', '#.go(#)', _history, distance);
|
||||
|
||||
// Implementation support.
|
||||
_HistoryCrossFrameImpl(this._history);
|
||||
_HistoryCrossFrame(this._history);
|
||||
|
||||
static History _createSafe(h) {
|
||||
if (identical(h, window.history)) {
|
||||
return h;
|
||||
} else {
|
||||
// TODO(vsm): Cache or implement equality.
|
||||
return new _HistoryCrossFrameImpl(h);
|
||||
return new _HistoryCrossFrame(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,16 +34,16 @@ class _IDBKeyRangeFactoryProvider {
|
|||
|
||||
static _translateKey(idbkey) => idbkey; // TODO: fixme.
|
||||
|
||||
static _IDBKeyRangeImpl _only(cls, value) =>
|
||||
JS('_IDBKeyRangeImpl', '#.only(#)', cls, value);
|
||||
static IDBKeyRange _only(cls, value) =>
|
||||
JS('IDBKeyRange', '#.only(#)', cls, value);
|
||||
|
||||
static _IDBKeyRangeImpl _lowerBound(cls, bound, open) =>
|
||||
JS('_IDBKeyRangeImpl', '#.lowerBound(#, #)', cls, bound, open);
|
||||
static IDBKeyRange _lowerBound(cls, bound, open) =>
|
||||
JS('IDBKeyRange', '#.lowerBound(#, #)', cls, bound, open);
|
||||
|
||||
static _IDBKeyRangeImpl _upperBound(cls, bound, open) =>
|
||||
JS('_IDBKeyRangeImpl', '#.upperBound(#, #)', cls, bound, open);
|
||||
static IDBKeyRange _upperBound(cls, bound, open) =>
|
||||
JS('IDBKeyRange', '#.upperBound(#, #)', cls, bound, open);
|
||||
|
||||
static _IDBKeyRangeImpl _bound(cls, lower, upper, lowerOpen, upperOpen) =>
|
||||
JS('_IDBKeyRangeImpl', '#.bound(#, #, #, #)',
|
||||
static IDBKeyRange _bound(cls, lower, upper, lowerOpen, upperOpen) =>
|
||||
JS('IDBKeyRange', '#.bound(#, #, #, #)',
|
||||
cls, lower, upper, lowerOpen, upperOpen);
|
||||
}
|
||||
|
|
|
@ -13,20 +13,20 @@ class _AudioContextFactoryProvider {
|
|||
class _IDBKeyRangeFactoryProvider {
|
||||
|
||||
static IDBKeyRange createIDBKeyRange_only(/*IDBKey*/ value) =>
|
||||
_IDBKeyRangeImpl.only_(value);
|
||||
IDBKeyRange.only_(value);
|
||||
|
||||
static IDBKeyRange createIDBKeyRange_lowerBound(
|
||||
/*IDBKey*/ bound, [bool open = false]) =>
|
||||
_IDBKeyRangeImpl.lowerBound_(bound, open);
|
||||
IDBKeyRange.lowerBound_(bound, open);
|
||||
|
||||
static IDBKeyRange createIDBKeyRange_upperBound(
|
||||
/*IDBKey*/ bound, [bool open = false]) =>
|
||||
_IDBKeyRangeImpl.upperBound_(bound, open);
|
||||
IDBKeyRange.upperBound_(bound, open);
|
||||
|
||||
static IDBKeyRange createIDBKeyRange_bound(
|
||||
/*IDBKey*/ lower, /*IDBKey*/ upper,
|
||||
[bool lowerOpen = false, bool upperOpen = false]) =>
|
||||
_IDBKeyRangeImpl.bound_(lower, upper, lowerOpen, upperOpen);
|
||||
IDBKeyRange.bound_(lower, upper, lowerOpen, upperOpen);
|
||||
}
|
||||
|
||||
class _TypedArrayFactoryProvider {
|
||||
|
@ -108,5 +108,5 @@ class _WebSocketFactoryProvider {
|
|||
}
|
||||
|
||||
class _TextFactoryProvider {
|
||||
static Text createText(String data) => _document.$dom_createTextNode(data);
|
||||
static Text createText(String data) => document.$dom_createTextNode(data);
|
||||
}
|
||||
|
|
|
@ -39,14 +39,14 @@ class _Utils {
|
|||
}
|
||||
|
||||
class _NPObject extends NativeFieldWrapperClass1 {
|
||||
_NPObject();
|
||||
_NPObject.internal();
|
||||
static _NPObject retrieve(String key) native "NPObject_retrieve";
|
||||
property(String propertyName) native "NPObject_property";
|
||||
invoke(String methodName, [List args = null]) native "NPObject_invoke";
|
||||
}
|
||||
|
||||
class _DOMWindowCrossFrameImpl extends NativeFieldWrapperClass1 implements Window {
|
||||
_DOMWindowCrossFrameImpl();
|
||||
class _DOMWindowCrossFrame extends NativeFieldWrapperClass1 implements Window {
|
||||
_DOMWindowCrossFrame.internal();
|
||||
|
||||
// Fields.
|
||||
History get history() native "DOMWindow_history_cross_frame_Getter";
|
||||
|
@ -67,8 +67,8 @@ class _DOMWindowCrossFrameImpl extends NativeFieldWrapperClass1 implements Windo
|
|||
String get typeName => "DOMWindow";
|
||||
}
|
||||
|
||||
class _HistoryCrossFrameImpl extends NativeFieldWrapperClass1 implements History {
|
||||
_HistoryCrossFrameImpl();
|
||||
class _HistoryCrossFrame extends NativeFieldWrapperClass1 implements History {
|
||||
_HistoryCrossFrame.internal();
|
||||
|
||||
// Methods.
|
||||
void back() native "History_back_Callback";
|
||||
|
@ -79,8 +79,8 @@ class _HistoryCrossFrameImpl extends NativeFieldWrapperClass1 implements History
|
|||
String get typeName => "History";
|
||||
}
|
||||
|
||||
class _LocationCrossFrameImpl extends NativeFieldWrapperClass1 implements Location {
|
||||
_LocationCrossFrameImpl();
|
||||
class _LocationCrossFrame extends NativeFieldWrapperClass1 implements Location {
|
||||
_LocationCrossFrame.internal();
|
||||
|
||||
// Fields.
|
||||
void set href(String) native "Location_href_Setter";
|
||||
|
@ -89,8 +89,8 @@ class _LocationCrossFrameImpl extends NativeFieldWrapperClass1 implements Locati
|
|||
String get typeName => "Location";
|
||||
}
|
||||
|
||||
class _DOMStringMapImpl extends NativeFieldWrapperClass1 implements Map<String, String> {
|
||||
_DOMStringMapImpl();
|
||||
class _DOMStringMap extends NativeFieldWrapperClass1 implements Map<String, String> {
|
||||
_DOMStringMap.internal();
|
||||
|
||||
bool containsValue(String value) => Maps.containsValue(this, value);
|
||||
bool containsKey(String key) native "DOMStringMap_containsKey_Callback";
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
class _CustomEventFactoryProvider {
|
||||
static CustomEvent createCustomEvent(String type, [bool canBubble = true,
|
||||
bool cancelable = true, Object detail = null]) {
|
||||
final _CustomEventImpl e = _document.$dom_createEvent("CustomEvent");
|
||||
final CustomEvent e = document.$dom_createEvent("CustomEvent");
|
||||
e.$dom_initCustomEvent(type, canBubble, cancelable, detail);
|
||||
return e;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class _CustomEventFactoryProvider {
|
|||
class _EventFactoryProvider {
|
||||
static Event createEvent(String type, [bool canBubble = true,
|
||||
bool cancelable = true]) {
|
||||
final _EventImpl e = _document.$dom_createEvent("Event");
|
||||
final Event e = document.$dom_createEvent("Event");
|
||||
e.$dom_initEvent(type, canBubble, cancelable);
|
||||
return e;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class _MouseEventFactoryProvider {
|
|||
[bool canBubble = true, bool cancelable = true, bool ctrlKey = false,
|
||||
bool altKey = false, bool shiftKey = false, bool metaKey = false,
|
||||
EventTarget relatedTarget = null]) {
|
||||
final e = _document.$dom_createEvent("MouseEvent");
|
||||
final e = document.$dom_createEvent("MouseEvent");
|
||||
e.$dom_initMouseEvent(type, canBubble, cancelable, view, detail,
|
||||
screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey,
|
||||
button, relatedTarget);
|
||||
|
@ -84,7 +84,7 @@ class _DocumentFragmentFactoryProvider {
|
|||
class _SVGElementFactoryProvider {
|
||||
static SVGElement createSVGElement_tag(String tag) {
|
||||
final Element temp =
|
||||
_document.$dom_createElementNS("http://www.w3.org/2000/svg", tag);
|
||||
document.$dom_createElementNS("http://www.w3.org/2000/svg", tag);
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
/// @domName $DOMNAME
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
$!MEMBERS}
|
||||
|
|
|
@ -39,18 +39,15 @@ part '$AUXILIARY_DIR/_Lists.dart';
|
|||
|
||||
|
||||
LocalWindow get window => JS('LocalWindow', 'window');
|
||||
_LocalWindowImpl get _window => JS('_LocalWindowImpl', 'window');
|
||||
|
||||
Document get document => JS('Document', 'document');
|
||||
|
||||
_DocumentImpl get _document => JS('_DocumentImpl', 'document');
|
||||
|
||||
Element query(String selector) => _document.query(selector);
|
||||
List<Element> queryAll(String selector) => _document.queryAll(selector);
|
||||
Element query(String selector) => document.query(selector);
|
||||
List<Element> queryAll(String selector) => document.queryAll(selector);
|
||||
|
||||
// Workaround for tags like <cite> that lack their own Element subclass --
|
||||
// Dart issue 1990.
|
||||
class _HTMLElementImpl extends _ElementImpl native "*HTMLElement" {
|
||||
class HTMLElement extends Element native "*HTMLElement" {
|
||||
}
|
||||
|
||||
// Support for Send/ReceivePortSync.
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
$!MEMBERS
|
||||
|
||||
_CanvasRenderingContext2DImpl get context2d => getContext('2d');
|
||||
CanvasRenderingContext2D get context2d => getContext('2d');
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
class $CLASSNAME
|
||||
// Console is sometimes a singleton bag-of-properties without a prototype.
|
||||
implements Console
|
||||
native "=(typeof console == 'undefined' ? {} : console)" {
|
||||
$!MEMBERS
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class $CLASSNAME extends $SUPER implements $INTERFACE {
|
||||
$CLASSNAME(_ptr) : super(_ptr);
|
||||
class $CLASSNAME extends $SUPER {
|
||||
$CLASSNAME(EventTarget _ptr) : super(_ptr);
|
||||
$!MEMBERS
|
||||
EventListenerList get mouseWheel {
|
||||
if (JS('bool', '#.onwheel !== undefined', _ptr)) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
|
||||
_IDBTransactionImpl transaction(storeName_OR_storeNames, String mode) {
|
||||
IDBTransaction transaction(storeName_OR_storeNames, String mode) {
|
||||
if (mode != 'readonly' && mode != 'readwrite') {
|
||||
throw new ArgumentError(mode);
|
||||
}
|
||||
|
@ -29,24 +29,24 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|||
return txn;
|
||||
}
|
||||
|
||||
static _IDBTransactionImpl _transaction_string_mode($CLASSNAME db, stores, mode) {
|
||||
static IDBTransaction _transaction_string_mode($CLASSNAME db, stores, mode) {
|
||||
return db._transaction(stores, mode);
|
||||
}
|
||||
|
||||
static _IDBTransactionImpl _transaction_numeric_mode($CLASSNAME db, stores, mode) {
|
||||
static IDBTransaction _transaction_numeric_mode($CLASSNAME db, stores, mode) {
|
||||
int intMode;
|
||||
if (mode == 'readonly') intMode = IDBTransaction.READ_ONLY;
|
||||
if (mode == 'readwrite') intMode = IDBTransaction.READ_WRITE;
|
||||
return db._transaction(stores, intMode);
|
||||
}
|
||||
|
||||
_IDBTransactionImpl _transaction(stores, mode) native 'transaction';
|
||||
IDBTransaction _transaction(stores, mode) native 'transaction';
|
||||
|
||||
static bool _hasNumericMode(txn) =>
|
||||
JS('bool', 'typeof(#.mode) === "number"', txn);
|
||||
|
||||
$!MEMBERS}
|
||||
|
||||
// TODO(sra): This should be a static member of _IDBTransactionImpl but dart2js
|
||||
// TODO(sra): This should be a static member of IDBTransaction but dart2js
|
||||
// can't handle that. Move it back after dart2js is completely done.
|
||||
var _transaction_fn; // Assigned one of the static methods.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" {
|
||||
|
||||
_DocumentImpl get document => JS('_DocumentImpl', '#.document', this);
|
||||
Document get document => JS('Document', '#.document', this);
|
||||
|
||||
Window _open2(url, name) => JS('Window', '#.open(#,#)', this, url, name);
|
||||
|
||||
|
@ -13,28 +13,18 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" {
|
|||
|
||||
Window open(String url, String name, [String options]) {
|
||||
if (options == null) {
|
||||
return _DOMWindowCrossFrameImpl._createSafe(_open2(url, name));
|
||||
return _DOMWindowCrossFrame._createSafe(_open2(url, name));
|
||||
} else {
|
||||
return _DOMWindowCrossFrameImpl._createSafe(_open3(url, name, options));
|
||||
return _DOMWindowCrossFrame._createSafe(_open3(url, name, options));
|
||||
}
|
||||
}
|
||||
|
||||
// API level getter and setter for Location.
|
||||
// TODO: The cross domain safe wrapper can be inserted here or folded into
|
||||
// _LocationWrapper.
|
||||
LocalLocation get location => _get_location();
|
||||
|
||||
// TODO: consider forcing users to do: window.location.assign('string').
|
||||
/**
|
||||
* Sets the window's location, which causes the browser to navigate to the new
|
||||
* location. [value] may be a Location object or a string.
|
||||
*/
|
||||
void set location(value) => _set_location(value);
|
||||
|
||||
// Firefox work-around for Location. The Firefox location object cannot be
|
||||
// made to behave like a Dart object so must be wrapped.
|
||||
|
||||
LocalLocation _get_location() {
|
||||
LocalLocation get location() {
|
||||
// Firefox work-around for Location. The Firefox location object cannot be
|
||||
// made to behave like a Dart object so must be wrapped.
|
||||
var result = _location;
|
||||
if (_isDartLocation(result)) return result; // e.g. on Chrome.
|
||||
if (null == _location_wrapper) {
|
||||
|
@ -43,7 +33,12 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" {
|
|||
return _location_wrapper;
|
||||
}
|
||||
|
||||
void _set_location(value) {
|
||||
// TODO: consider forcing users to do: window.location.assign('string').
|
||||
/**
|
||||
* Sets the window's location, which causes the browser to navigate to the new
|
||||
* location. [value] may be a Location object or a string.
|
||||
*/
|
||||
void set location(value) {
|
||||
if (value is _LocationWrapper) {
|
||||
_location = value._ptr;
|
||||
} else {
|
||||
|
@ -72,7 +67,11 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes a [callback] after the next batch of browser layout measurements
|
||||
* has completed or would have completed if any browser layout measurements
|
||||
* had been scheduled.
|
||||
*/
|
||||
void requestLayoutFrame(TimeoutHandler callback) {
|
||||
_addMeasurementFrameCallback(callback);
|
||||
}
|
||||
|
@ -120,21 +119,26 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" {
|
|||
this);
|
||||
}
|
||||
|
||||
|
||||
_IDBFactoryImpl get indexedDB => _get_indexedDB();
|
||||
|
||||
_IDBFactoryImpl _get_indexedDB() =>
|
||||
JS('_IDBFactoryImpl',
|
||||
IDBFactory get indexedDB() =>
|
||||
JS('IDBFactory',
|
||||
'#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB',
|
||||
this, this, this);
|
||||
|
||||
// TODO(kasperl): Document these.
|
||||
lookupPort(String name) {
|
||||
/**
|
||||
* Lookup a port by its [name]. Return null if no port is
|
||||
* registered under [name].
|
||||
*/
|
||||
SendPortSync lookupPort(String name) {
|
||||
var port = JSON.parse(localStorage['dart-port:$name']);
|
||||
return _deserialize(port);
|
||||
}
|
||||
|
||||
registerPort(String name, var port) {
|
||||
/**
|
||||
* Register a [port] on this window under the given [name]. This
|
||||
* port may be retrieved by any isolate (or JavaScript script)
|
||||
* running in this window.
|
||||
*/
|
||||
void registerPort(String name, var port) {
|
||||
var serialized = _serialize(port);
|
||||
localStorage['dart-port:$name'] = JSON.stringify(serialized);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,16 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
factory $CLASSNAME(String type, Window view, int detail, int screenX,
|
||||
int screenY, int clientX, int clientY, int button, [bool canBubble = true,
|
||||
bool cancelable = true, bool ctrlKey = false, bool altKey = false,
|
||||
bool shiftKey = false, bool metaKey = false,
|
||||
EventTarget relatedTarget = null]) =>
|
||||
_$(CLASSNAME)FactoryProvider.create$CLASSNAME(
|
||||
type, view, detail, screenX, screenY,
|
||||
clientX, clientY, button, canBubble, cancelable,
|
||||
ctrlKey, altKey, shiftKey, metaKey,
|
||||
relatedTarget);
|
||||
$!MEMBERS
|
||||
|
||||
int get offsetX {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
$!MEMBERS
|
||||
|
||||
_ElementImpl createTBody() {
|
||||
Element createTBody() {
|
||||
if (JS('bool', '!!#.createTBody', this)) {
|
||||
return this._createTBody();
|
||||
}
|
||||
|
@ -14,5 +14,5 @@ $!MEMBERS
|
|||
return tbody;
|
||||
}
|
||||
|
||||
_ElementImpl _createTBody() native 'createTBody';
|
||||
Element _createTBody() native 'createTBody';
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
// WARNING: Do not edit - generated code.
|
||||
|
||||
/// @domName $DOMNAME
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS {
|
||||
$!MEMBERS
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ part '$AUXILIARY_DIR/_Lists.dart';
|
|||
part '$AUXILIARY_DIR/native_DOMPublic.dart';
|
||||
part '$AUXILIARY_DIR/native_DOMImplementation.dart';
|
||||
|
||||
// FIXME (blois): Rename to _window (ditto __document).
|
||||
LocalWindow __window;
|
||||
|
||||
LocalWindow get window {
|
||||
|
@ -46,22 +47,19 @@ LocalWindow get window {
|
|||
return __window;
|
||||
}
|
||||
|
||||
LocalWindow get _window native "Utils_window";
|
||||
|
||||
Document __document;
|
||||
|
||||
Document get document {
|
||||
if (__document != null) {
|
||||
return __document;
|
||||
}
|
||||
__document = _document;
|
||||
__document = window.document;
|
||||
return __document;
|
||||
}
|
||||
|
||||
Document get _document => _window.document;
|
||||
|
||||
Element query(String selector) => _document.query(selector);
|
||||
List<Element> queryAll(String selector) => _document.queryAll(selector);
|
||||
Element query(String selector) => document.query(selector);
|
||||
List<Element> queryAll(String selector) => document.queryAll(selector);
|
||||
|
||||
int _getNewIsolateId() => _Utils._getNewIsolateId();
|
||||
|
||||
|
|
|
@ -4,16 +4,29 @@
|
|||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
|
||||
/**
|
||||
* Executes a [callback] after the next batch of browser layout measurements
|
||||
* has completed or would have completed if any browser layout measurements
|
||||
* had been scheduled.
|
||||
*/
|
||||
void requestLayoutFrame(TimeoutHandler callback) {
|
||||
_addMeasurementFrameCallback(callback);
|
||||
}
|
||||
|
||||
// TODO(kasperl): Document these.
|
||||
/**
|
||||
* Lookup a port by its [name]. Return null if no port is
|
||||
* registered under [name].
|
||||
*/
|
||||
lookupPort(String name) {
|
||||
var port = JSON.parse(localStorage['dart-port:$name']);
|
||||
return _deserialize(port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a [port] on this window under the given [name]. This
|
||||
* port may be retrieved by any isolate (or JavaScript script)
|
||||
* running in this window.
|
||||
*/
|
||||
registerPort(String name, var port) {
|
||||
var serialized = _serialize(port);
|
||||
localStorage['dart-port:$name'] = JSON.stringify(serialized);
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// WARNING: Do not edit - generated code.
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
factory $CLASSNAME(String type, Window view, int detail, int screenX,
|
||||
int screenY, int clientX, int clientY, int button, [bool canBubble = true,
|
||||
bool cancelable = true, bool ctrlKey = false, bool altKey = false,
|
||||
bool shiftKey = false, bool metaKey = false,
|
||||
EventTarget relatedTarget = null]) =>
|
||||
_$(CLASSNAME)FactoryProvider.create$CLASSNAME(
|
||||
type, view, detail, screenX, screenY,
|
||||
clientX, clientY, button, canBubble, cancelable,
|
||||
ctrlKey, altKey, shiftKey, metaKey,
|
||||
relatedTarget);
|
||||
$!MEMBERS
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
factory $CLASSNAME() => _$(CLASSNAME)FactoryProvider.create$CLASSNAME();
|
||||
$!MEMBERS
|
||||
$if DART2JS
|
||||
GainNode createGain() {
|
||||
|
|
|
@ -20,6 +20,9 @@ String get _browserPrefix {
|
|||
}
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
factory $CLASSNAME() => _$(CLASSNAME)FactoryProvider.create$CLASSNAME();
|
||||
factory $CLASSNAME.css(String css) =>
|
||||
_$(CLASSNAME)FactoryProvider.create$(CLASSNAME)_css(css);
|
||||
|
||||
$!MEMBERS
|
||||
|
||||
|
|
|
@ -5,18 +5,38 @@
|
|||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
$!MEMBERS
|
||||
|
||||
/**
|
||||
* Sets the color used inside shapes.
|
||||
* [r], [g], [b] are 0-255, [a] is 0-1.
|
||||
*/
|
||||
void setFillColorRgb(int r, int g, int b, [num a = 1]) {
|
||||
this.fillStyle = 'rgba($r, $g, $b, $a)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color used inside shapes.
|
||||
* [h] is in degrees, 0-360.
|
||||
* [s], [l] are in percent, 0-100.
|
||||
* [a] is 0-1.
|
||||
*/
|
||||
void setFillColorHsl(int h, num s, num l, [num a = 1]) {
|
||||
this.fillStyle = 'hsla($h, $s%, $l%, $a)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color used for stroking shapes.
|
||||
* [r], [g], [b] are 0-255, [a] is 0-1.
|
||||
*/
|
||||
void setStrokeColorRgb(int r, int g, int b, [num a = 1]) {
|
||||
this.strokeStyle = 'rgba($r, $g, $b, $a)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color used for stroking shapes.
|
||||
* [h] is in degrees, 0-360.
|
||||
* [s], [l] are in percent, 0-100.
|
||||
* [a] is 0-1.
|
||||
*/
|
||||
void setStrokeColorHsl(int h, num s, num l, [num a = 1]) {
|
||||
this.strokeStyle = 'hsla($h, $s%, $l%, $a)';
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// WARNING: Do not edit - generated code.
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
factory $CLASSNAME(String type, [bool canBubble = true, bool cancelable = true,
|
||||
Object detail]) => _$(CLASSNAME)FactoryProvider.create$CLASSNAME(
|
||||
type, canBubble, cancelable, detail);
|
||||
$!MEMBERS
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class $CLASSNAME extends _NodeImpl implements Document
|
||||
class $CLASSNAME extends Node
|
||||
$if DART2JS
|
||||
native "*HTMLDocument"
|
||||
$endif
|
||||
|
@ -11,7 +11,7 @@ $endif
|
|||
$!MEMBERS
|
||||
// TODO(jacobr): implement all Element methods not on Document.
|
||||
|
||||
_ElementImpl query(String selectors) {
|
||||
Element query(String selectors) {
|
||||
// It is fine for our RegExp to detect element id query selectors to have
|
||||
// false negatives but not false positives.
|
||||
if (const RegExp("^#[_a-zA-Z]\\w*\$").hasMatch(selectors)) {
|
||||
|
|
|
@ -116,8 +116,8 @@ class EmptyElementRect implements ElementRect {
|
|||
const EmptyElementRect();
|
||||
}
|
||||
|
||||
class _FrozenCSSClassSet extends _CssClassSet {
|
||||
_FrozenCSSClassSet() : super(null);
|
||||
class _FrozenCssClassSet extends _CssClassSet {
|
||||
_FrozenCssClassSet() : super(null);
|
||||
|
||||
void _write(Set s) {
|
||||
throw new UnsupportedError(
|
||||
|
@ -129,6 +129,14 @@ class _FrozenCSSClassSet extends _CssClassSet {
|
|||
}
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
factory $CLASSNAME() => _$(CLASSNAME)FactoryProvider.createDocumentFragment();
|
||||
|
||||
factory $CLASSNAME.html(String html) =>
|
||||
_$(CLASSNAME)FactoryProvider.createDocumentFragment_html(html);
|
||||
|
||||
factory $CLASSNAME.svg(String svg) =>
|
||||
new _$(CLASSNAME)FactoryProvider.createDocumentFragment_svg(svg);
|
||||
|
||||
List<Element> _elements;
|
||||
|
||||
List<Element> get elements {
|
||||
|
@ -147,7 +155,7 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|||
elements.addAll(copy);
|
||||
}
|
||||
|
||||
_ElementImpl query(String selectors) => $dom_querySelector(selectors);
|
||||
Element query(String selectors) => $dom_querySelector(selectors);
|
||||
|
||||
List<Element> queryAll(String selectors) =>
|
||||
new _FrozenElementList._wrap($dom_querySelectorAll(selectors));
|
||||
|
@ -240,7 +248,7 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|||
Element get offsetParent => null;
|
||||
Element get parent => null;
|
||||
Map<String, String> get attributes => const {};
|
||||
CSSClassSet get classes => new _FrozenCSSClassSet();
|
||||
CssClassSet get classes => new _FrozenCssClassSet();
|
||||
Map<String, String> get dataAttributes => const {};
|
||||
CSSStyleDeclaration get style => new Element.tag('div').style;
|
||||
Future<CSSStyleDeclaration> get computedStyle =>
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
// functionality.
|
||||
class _ChildrenElementList implements List {
|
||||
// Raw Element.
|
||||
final _ElementImpl _element;
|
||||
final _HTMLCollectionImpl _childElements;
|
||||
final Element _element;
|
||||
final HTMLCollection _childElements;
|
||||
|
||||
_ChildrenElementList._wrap(_ElementImpl element)
|
||||
_ChildrenElementList._wrap(Element element)
|
||||
: _childElements = element.$dom_children,
|
||||
_element = element;
|
||||
|
||||
|
@ -24,7 +24,7 @@ class _ChildrenElementList implements List {
|
|||
bool contains(Element element) => _childElements.contains(element);
|
||||
|
||||
void forEach(void f(Element element)) {
|
||||
for (_ElementImpl element in _childElements) {
|
||||
for (Element element in _childElements) {
|
||||
f(element);
|
||||
}
|
||||
}
|
||||
|
@ -73,11 +73,11 @@ class _ChildrenElementList implements List {
|
|||
return _childElements.length;
|
||||
}
|
||||
|
||||
_ElementImpl operator [](int index) {
|
||||
Element operator [](int index) {
|
||||
return _childElements[index];
|
||||
}
|
||||
|
||||
void operator []=(int index, _ElementImpl value) {
|
||||
void operator []=(int index, Element value) {
|
||||
_element.$dom_replaceChild(value, _childElements[index]);
|
||||
}
|
||||
|
||||
|
@ -86,17 +86,17 @@ class _ChildrenElementList implements List {
|
|||
throw new UnsupportedError('');
|
||||
}
|
||||
|
||||
Element add(_ElementImpl value) {
|
||||
Element add(Element value) {
|
||||
_element.$dom_appendChild(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
Element addLast(_ElementImpl value) => add(value);
|
||||
Element addLast(Element value) => add(value);
|
||||
|
||||
Iterator<Element> iterator() => _toList().iterator();
|
||||
|
||||
void addAll(Collection<Element> collection) {
|
||||
for (_ElementImpl element in collection) {
|
||||
for (Element element in collection) {
|
||||
_element.$dom_appendChild(element);
|
||||
}
|
||||
}
|
||||
|
@ -296,9 +296,18 @@ class _FrozenElementListIterator implements Iterator<Element> {
|
|||
bool get hasNext => _index < _list.length;
|
||||
}
|
||||
|
||||
class _ElementAttributeMap implements AttributeMap {
|
||||
/**
|
||||
* All your attribute manipulation needs in one place.
|
||||
* Extends the regular Map interface by automatically coercing non-string
|
||||
* values to strings.
|
||||
*/
|
||||
abstract class AttributeMap implements Map<String, String> {
|
||||
void operator []=(String key, value);
|
||||
}
|
||||
|
||||
final _ElementImpl _element;
|
||||
class _ElementAttributeMap extends AttributeMap {
|
||||
|
||||
final Element _element;
|
||||
|
||||
_ElementAttributeMap(this._element);
|
||||
|
||||
|
@ -391,7 +400,7 @@ class _ElementAttributeMap implements AttributeMap {
|
|||
* Provides a Map abstraction on top of data-* attributes, similar to the
|
||||
* dataSet in the old DOM.
|
||||
*/
|
||||
class _DataAttributeMap implements AttributeMap {
|
||||
class _DataAttributeMap extends AttributeMap {
|
||||
|
||||
final Map<String, String> $dom_attributes;
|
||||
|
||||
|
@ -461,9 +470,23 @@ class _DataAttributeMap implements AttributeMap {
|
|||
String _strip(String key) => key.substring(5);
|
||||
}
|
||||
|
||||
class _CssClassSet implements CSSClassSet {
|
||||
abstract class CssClassSet implements Set<String> {
|
||||
/**
|
||||
* Adds the class [token] to the element if it is not on it, removes it if it
|
||||
* is.
|
||||
*/
|
||||
bool toggle(String token);
|
||||
|
||||
final _ElementImpl _element;
|
||||
/**
|
||||
* Returns [:true:] if classes cannot be added or removed from this
|
||||
* [:CssClassSet:].
|
||||
*/
|
||||
bool get frozen;
|
||||
}
|
||||
|
||||
class _CssClassSet extends CssClassSet {
|
||||
|
||||
final Element _element;
|
||||
|
||||
_CssClassSet(this._element);
|
||||
|
||||
|
@ -488,6 +511,10 @@ class _CssClassSet implements CSSClassSet {
|
|||
|
||||
bool get isEmpty => _read().isEmpty;
|
||||
|
||||
/**
|
||||
* Returns [:true:] if classes cannot be added or removed from this
|
||||
* [:CssClassSet:].
|
||||
*/
|
||||
bool get frozen => false;
|
||||
|
||||
int get length =>_read().length;
|
||||
|
@ -510,6 +537,10 @@ class _CssClassSet implements CSSClassSet {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the class [token] to the element if it is not on it, removes it if it
|
||||
* is.
|
||||
*/
|
||||
bool toggle(String value) {
|
||||
Set<String> s = _read();
|
||||
bool result = false;
|
||||
|
@ -620,20 +651,21 @@ class _SimpleClientRect implements ClientRect {
|
|||
// rects as we must perform all measurement queries at a safe point to avoid
|
||||
// triggering unneeded layouts.
|
||||
/**
|
||||
* All your element measurement needs in one place
|
||||
* All your element measurement needs in one place.
|
||||
* @domName none
|
||||
*/
|
||||
class _ElementRectImpl implements ElementRect {
|
||||
class ElementRect {
|
||||
// Relative to offsetParent.
|
||||
final ClientRect client;
|
||||
final ClientRect offset;
|
||||
final ClientRect scroll;
|
||||
|
||||
// TODO(jacobr): should we move these outside of ElementRect to avoid the
|
||||
// overhead of computing them every time even though they are rarely used.
|
||||
final _ClientRectImpl _boundingClientRect;
|
||||
final _ClientRectListImpl _clientRects;
|
||||
final ClientRect _boundingClientRect;
|
||||
final _ClientRectList _clientRects;
|
||||
|
||||
_ElementRectImpl(_ElementImpl element) :
|
||||
ElementRect(Element element) :
|
||||
client = new _SimpleClientRect(element.clientLeft,
|
||||
element.clientTop,
|
||||
element.clientWidth,
|
||||
|
@ -649,9 +681,10 @@ class _ElementRectImpl implements ElementRect {
|
|||
_boundingClientRect = element.getBoundingClientRect(),
|
||||
_clientRects = element.getClientRects();
|
||||
|
||||
_ClientRectImpl get bounding => _boundingClientRect;
|
||||
// In global coords.
|
||||
ClientRect get bounding => _boundingClientRect;
|
||||
|
||||
// TODO(jacobr): cleanup.
|
||||
// In global coords.
|
||||
List<ClientRect> get clientRects {
|
||||
final out = new List(_clientRects.length);
|
||||
for (num i = 0; i < _clientRects.length; i++) {
|
||||
|
@ -663,6 +696,11 @@ class _ElementRectImpl implements ElementRect {
|
|||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
|
||||
factory $CLASSNAME.html(String html) =>
|
||||
_$(CLASSNAME)FactoryProvider.createElement_html(html);
|
||||
factory $CLASSNAME.tag(String tag) =>
|
||||
_$(CLASSNAME)FactoryProvider.createElement_tag(tag);
|
||||
|
||||
/**
|
||||
* @domName Element.hasAttribute, Element.getAttribute, Element.setAttribute,
|
||||
* Element.removeAttribute
|
||||
|
@ -683,17 +721,22 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|||
elements.addAll(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @domName childElementCount, firstElementChild, lastElementChild,
|
||||
* children, Node.nodes.add
|
||||
*/
|
||||
List<Element> get elements => new _ChildrenElementList._wrap(this);
|
||||
|
||||
_ElementImpl query(String selectors) => $dom_querySelector(selectors);
|
||||
Element query(String selectors) => $dom_querySelector(selectors);
|
||||
|
||||
List<Element> queryAll(String selectors) =>
|
||||
new _FrozenElementList._wrap($dom_querySelectorAll(selectors));
|
||||
|
||||
_CssClassSet get classes => new _CssClassSet(this);
|
||||
/** @domName className, classList */
|
||||
CssClassSet get classes => new _CssClassSet(this);
|
||||
|
||||
void set classes(Collection<String> value) {
|
||||
_CssClassSet classSet = classes;
|
||||
CssClassSet classSet = classes;
|
||||
classSet.clear();
|
||||
classSet.addAll(value);
|
||||
}
|
||||
|
@ -709,32 +752,56 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @domName getClientRects, getBoundingClientRect, clientHeight, clientWidth,
|
||||
* clientTop, clientLeft, offsetHeight, offsetWidth, offsetTop, offsetLeft,
|
||||
* scrollHeight, scrollWidth, scrollTop, scrollLeft
|
||||
*/
|
||||
Future<ElementRect> get rect {
|
||||
return _createMeasurementFuture(
|
||||
() => new _ElementRectImpl(this),
|
||||
() => new ElementRect(this),
|
||||
new Completer<ElementRect>());
|
||||
}
|
||||
|
||||
/** @domName Window.getComputedStyle */
|
||||
Future<CSSStyleDeclaration> get computedStyle {
|
||||
// TODO(jacobr): last param should be null, see b/5045788
|
||||
return getComputedStyle('');
|
||||
}
|
||||
|
||||
/** @domName Window.getComputedStyle */
|
||||
Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) {
|
||||
return _createMeasurementFuture(
|
||||
() => _window.$dom_getComputedStyle(this, pseudoElement),
|
||||
() => window.$dom_getComputedStyle(this, pseudoElement),
|
||||
new Completer<CSSStyleDeclaration>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified text as a text node after the last child of this.
|
||||
*/
|
||||
void addText(String text) {
|
||||
this.insertAdjacentText('beforeend', text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the specified text as HTML and adds the resulting node after the
|
||||
* last child of this.
|
||||
*/
|
||||
void addHTML(String text) {
|
||||
this.insertAdjacentHTML('beforeend', text);
|
||||
}
|
||||
|
||||
// Hooks to support custom WebComponents.
|
||||
/**
|
||||
* Experimental support for [web components][wc]. This field stores a
|
||||
* reference to the component implementation. It was inspired by Mozilla's
|
||||
* [x-tags][] project. Please note: in the future it may be possible to
|
||||
* `extend Element` from your class, in which case this field will be
|
||||
* deprecated and will simply return this [Element] object.
|
||||
*
|
||||
* [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html
|
||||
* [x-tags]: http://x-tags.org/
|
||||
*/
|
||||
var xtag;
|
||||
|
||||
$if DARTIUM
|
||||
|
@ -855,7 +922,7 @@ class _ElementFactoryProvider {
|
|||
parentTag = _CUSTOM_PARENT_TAG_MAP[tag];
|
||||
}
|
||||
}
|
||||
final _ElementImpl temp = new Element.tag(parentTag);
|
||||
final Element temp = new Element.tag(parentTag);
|
||||
temp.innerHTML = html;
|
||||
|
||||
Element element;
|
||||
|
@ -882,6 +949,6 @@ $if DART2JS
|
|||
JS('Element', 'document.createElement(#)', tag);
|
||||
$else
|
||||
static Element createElement_tag(String tag) =>
|
||||
_document.$dom_createElement(tag);
|
||||
document.$dom_createElement(tag);
|
||||
$endif
|
||||
}
|
||||
|
|
17
sdk/lib/html/templates/html/impl/impl_Event.darttemplate
Normal file
17
sdk/lib/html/templates/html/impl/impl_Event.darttemplate
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// WARNING: Do not edit - generated code.
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
// In JS, canBubble and cancelable are technically required parameters to
|
||||
// init*Event. In practice, though, if they aren't provided they simply
|
||||
// default to false (since that's Boolean(undefined)).
|
||||
//
|
||||
// Contrary to JS, we default canBubble and cancelable to true, since that's
|
||||
// what people want most of the time anyway.
|
||||
factory $CLASSNAME(String type, [bool canBubble = true, bool cancelable = true]) =>
|
||||
_$(CLASSNAME)FactoryProvider.create$CLASSNAME(type, canBubble, cancelable);
|
||||
$!MEMBERS
|
||||
}
|
|
@ -2,36 +2,33 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class _EventsImpl implements Events {
|
||||
class Events {
|
||||
/* Raw event target. */
|
||||
// TODO(jacobr): it would be nice if we could specify this as
|
||||
// _EventTargetImpl or EventTarget
|
||||
final _ptr;
|
||||
final EventTarget _ptr;
|
||||
|
||||
_EventsImpl(this._ptr);
|
||||
Events(this._ptr);
|
||||
|
||||
_EventListenerListImpl operator [](String type) {
|
||||
return new _EventListenerListImpl(_ptr, type);
|
||||
EventListenerList operator [](String type) {
|
||||
return new EventListenerList(_ptr, type);
|
||||
}
|
||||
}
|
||||
|
||||
class _EventListenerListImpl implements EventListenerList {
|
||||
class EventListenerList {
|
||||
|
||||
// TODO(jacobr): make this _EventTargetImpl
|
||||
final _ptr;
|
||||
final EventTarget _ptr;
|
||||
final String _type;
|
||||
|
||||
_EventListenerListImpl(this._ptr, this._type);
|
||||
EventListenerList(this._ptr, this._type);
|
||||
|
||||
// TODO(jacobr): implement equals.
|
||||
|
||||
_EventListenerListImpl add(EventListener listener,
|
||||
EventListenerList add(EventListener listener,
|
||||
[bool useCapture = false]) {
|
||||
_add(listener, useCapture);
|
||||
return this;
|
||||
}
|
||||
|
||||
_EventListenerListImpl remove(EventListener listener,
|
||||
EventListenerList remove(EventListener listener,
|
||||
[bool useCapture = false]) {
|
||||
_remove(listener, useCapture);
|
||||
return this;
|
||||
|
@ -53,6 +50,7 @@ class _EventListenerListImpl implements EventListenerList {
|
|||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
|
||||
Events get on => new _EventsImpl(this);
|
||||
/** @domName EventTarget.addEventListener, EventTarget.removeEventListener, EventTarget.dispatchEvent */
|
||||
Events get on => new Events(this);
|
||||
$!MEMBERS
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
factory $CLASSNAME.get(String url, onSuccess($CLASSNAME request)) =>
|
||||
_$(CLASSNAME)FactoryProvider.create$(CLASSNAME)_get(url, onSuccess);
|
||||
|
||||
factory $CLASSNAME.getWithCredentials(String url, onSuccess($CLASSNAME request)) =>
|
||||
_$(CLASSNAME)FactoryProvider.create$(CLASSNAME)getWithCredentials(url, onSuccess);
|
||||
|
||||
$!MEMBERS
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
/**
|
||||
* @domName IDBKeyRange.only
|
||||
*/
|
||||
factory IDBKeyRange.only(/*IDBKey*/ value) =>
|
||||
_IDBKeyRangeFactoryProvider.create$(CLASSNAME)_only(value);
|
||||
|
||||
/**
|
||||
* @domName IDBKeyRange.lowerBound
|
||||
*/
|
||||
factory IDBKeyRange.lowerBound(/*IDBKey*/ bound, [bool open = false]) =>
|
||||
_IDBKeyRangeFactoryProvider.create$(CLASSNAME)_lowerBound(bound, open);
|
||||
|
||||
/**
|
||||
* @domName IDBKeyRange.upperBound
|
||||
*/
|
||||
factory IDBKeyRange.upperBound(/*IDBKey*/ bound, [bool open = false]) =>
|
||||
_IDBKeyRangeFactoryProvider.create$(CLASSNAME)_upperBound(bound, open);
|
||||
|
||||
/**
|
||||
* @domName IDBKeyRange.bound
|
||||
*/
|
||||
factory IDBKeyRange.bound(/*IDBKey*/ lower, /*IDBKey*/ upper,
|
||||
[bool lowerOpen = false, bool upperOpen = false]) =>
|
||||
_IDBKeyRangeFactoryProvider.create$(CLASSNAME)_bound(
|
||||
lower, upper, lowerOpen, upperOpen);
|
||||
|
||||
$!MEMBERS
|
||||
}
|
|
@ -8,35 +8,35 @@
|
|||
* improving performance for the typical cases where it is not required.
|
||||
*/
|
||||
class _ChildNodeListLazy implements List {
|
||||
final _NodeImpl _this;
|
||||
final Node _this;
|
||||
|
||||
_ChildNodeListLazy(this._this);
|
||||
|
||||
|
||||
$if DART2JS
|
||||
_NodeImpl get first => JS('_NodeImpl', '#.firstChild', _this);
|
||||
_NodeImpl get last => JS('_NodeImpl', '#.lastChild', _this);
|
||||
Node get first => JS('Node', '#.firstChild', _this);
|
||||
Node get last => JS('Node', '#.lastChild', _this);
|
||||
$else
|
||||
_NodeImpl get first => _this.$dom_firstChild;
|
||||
_NodeImpl get last => _this.$dom_lastChild;
|
||||
Node get first => _this.$dom_firstChild;
|
||||
Node get last => _this.$dom_lastChild;
|
||||
$endif
|
||||
|
||||
void add(_NodeImpl value) {
|
||||
void add(Node value) {
|
||||
_this.$dom_appendChild(value);
|
||||
}
|
||||
|
||||
void addLast(_NodeImpl value) {
|
||||
void addLast(Node value) {
|
||||
_this.$dom_appendChild(value);
|
||||
}
|
||||
|
||||
|
||||
void addAll(Collection<_NodeImpl> collection) {
|
||||
for (_NodeImpl node in collection) {
|
||||
void addAll(Collection<Node> collection) {
|
||||
for (Node node in collection) {
|
||||
_this.$dom_appendChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
_NodeImpl removeLast() {
|
||||
Node removeLast() {
|
||||
final result = last;
|
||||
if (result != null) {
|
||||
_this.$dom_removeChild(result);
|
||||
|
@ -48,7 +48,7 @@ $endif
|
|||
_this.text = '';
|
||||
}
|
||||
|
||||
void operator []=(int index, _NodeImpl value) {
|
||||
void operator []=(int index, Node value) {
|
||||
_this.$dom_replaceChild(value, this[index]);
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ $endif
|
|||
// a local copy of $dom_childNodes is more efficient.
|
||||
int get length => _this.$dom_childNodes.length;
|
||||
|
||||
_NodeImpl operator[](int index) => _this.$dom_childNodes[index];
|
||||
Node operator[](int index) => _this.$dom_childNodes[index];
|
||||
}
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
|
@ -125,18 +125,26 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO(jacobr): should we throw an exception if parent is already null?
|
||||
// TODO(vsm): Use the native remove when available.
|
||||
/**
|
||||
* Removes this node from the DOM.
|
||||
* @domName Node.removeChild
|
||||
*/
|
||||
void remove() {
|
||||
// TODO(jacobr): should we throw an exception if parent is already null?
|
||||
// TODO(vsm): Use the native remove when available.
|
||||
if (this.parent != null) {
|
||||
final _NodeImpl parent = this.parent;
|
||||
final Node parent = this.parent;
|
||||
parent.$dom_removeChild(this);
|
||||
}
|
||||
}
|
||||
|
||||
_NodeImpl replaceWith(Node otherNode) {
|
||||
/**
|
||||
* Replaces this node with another node.
|
||||
* @domName Node.replaceChild
|
||||
*/
|
||||
Node replaceWith(Node otherNode) {
|
||||
try {
|
||||
final _NodeImpl parent = this.parent;
|
||||
final Node parent = this.parent;
|
||||
parent.$dom_replaceChild(otherNode, this);
|
||||
} catch (e) {
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class _NodeListWrapper extends _ListWrapper<Node> implements List {
|
|||
}
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
_NodeImpl _parent;
|
||||
Node _parent;
|
||||
|
||||
// -- start List<Node> mixins.
|
||||
// Node is the element type.
|
||||
|
@ -98,21 +98,21 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|||
|
||||
// From Collection<Node>:
|
||||
|
||||
void add(_NodeImpl value) {
|
||||
void add(Node value) {
|
||||
_parent.$dom_appendChild(value);
|
||||
}
|
||||
|
||||
void addLast(_NodeImpl value) {
|
||||
void addLast(Node value) {
|
||||
_parent.$dom_appendChild(value);
|
||||
}
|
||||
|
||||
void addAll(Collection<_NodeImpl> collection) {
|
||||
for (_NodeImpl node in collection) {
|
||||
void addAll(Collection<Node> collection) {
|
||||
for (Node node in collection) {
|
||||
_parent.$dom_appendChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
_NodeImpl removeLast() {
|
||||
Node removeLast() {
|
||||
final result = this.last;
|
||||
if (result != null) {
|
||||
_parent.$dom_removeChild(result);
|
||||
|
@ -124,7 +124,7 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|||
_parent.text = '';
|
||||
}
|
||||
|
||||
void operator []=(int index, _NodeImpl value) {
|
||||
void operator []=(int index, Node value) {
|
||||
_parent.$dom_replaceChild(value, this[index]);
|
||||
}
|
||||
|
||||
|
|
10
sdk/lib/html/templates/html/impl/impl_Point.darttemplate
Normal file
10
sdk/lib/html/templates/html/impl/impl_Point.darttemplate
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// WARNING: Do not edit - generated code.
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
factory $CLASSNAME(num x, num y) => _$(CLASSNAME)FactoryProvider.create$CLASSNAME(x, y);
|
||||
$!MEMBERS
|
||||
}
|
|
@ -13,7 +13,12 @@ class _AttributeClassSet extends _CssClassSet {
|
|||
}
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
CSSClassSet get classes {
|
||||
factory $CLASSNAME.tag(String tag) =>
|
||||
_$(CLASSNAME)FactoryProvider.create$(CLASSNAME)_tag(tag);
|
||||
factory $CLASSNAME.svg(String svg) =>
|
||||
_$(CLASSNAME)FactoryProvider.create$(CLASSNAME)_svg(svg);
|
||||
|
||||
CssClassSet get classes {
|
||||
if (_cssClassSet == null) {
|
||||
_cssClassSet = new _AttributeClassSet(_ptr);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
factory $CLASSNAME() => _$(CLASSNAME)FactoryProvider.createSVGSVGElement();
|
||||
|
||||
$!MEMBERS
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
class $CLASSNAME$EXTENDS implements Map<String, String> $NATIVESPEC {
|
||||
|
||||
// TODO(nweiz): update this when maps support lazy iteration
|
||||
bool containsValue(String value) => values.some((e) => e == value);
|
||||
|
|
10
sdk/lib/html/templates/html/impl/impl_Text.darttemplate
Normal file
10
sdk/lib/html/templates/html/impl/impl_Text.darttemplate
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// WARNING: Do not edit - generated code.
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
factory $CLASSNAME(String data) => _$(CLASSNAME)FactoryProvider.create$CLASSNAME(data);
|
||||
$!MEMBERS
|
||||
}
|
10
sdk/lib/html/templates/html/impl/impl_WebSocket.darttemplate
Normal file
10
sdk/lib/html/templates/html/impl/impl_WebSocket.darttemplate
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// WARNING: Do not edit - generated code.
|
||||
|
||||
class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
||||
factory $CLASSNAME(String url) => _$(CLASSNAME)FactoryProvider.create$CLASSNAME(url);
|
||||
$!MEMBERS
|
||||
}
|
|
@ -6,6 +6,7 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|||
$!MEMBERS
|
||||
|
||||
$if DART2JS
|
||||
/** @domName WheelEvent.deltaY */
|
||||
num get deltaY {
|
||||
if (JS('bool', '#.deltaY !== undefined', this)) {
|
||||
// W3C WheelEvent
|
||||
|
@ -33,6 +34,7 @@ $if DART2JS
|
|||
'deltaY is not supported');
|
||||
}
|
||||
|
||||
/** @domName WheelEvent.deltaX */
|
||||
num get deltaX {
|
||||
if (JS('bool', '#.deltaX !== undefined', this)) {
|
||||
// W3C WheelEvent
|
||||
|
@ -77,8 +79,11 @@ $if DART2JS
|
|||
int get _deltaMode => JS('int', '#.deltaMode', this);
|
||||
|
||||
$else
|
||||
/** @domName WheelEvent.deltaX */
|
||||
num get deltaX => $dom_wheelDeltaX;
|
||||
/** @domName WheelEvent.deltaY */
|
||||
num get deltaY => $dom_wheelDeltaY;
|
||||
/** @domName WheelEvent.deltaMode */
|
||||
int get deltaMode => 0;
|
||||
|
||||
$endif
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
/// @domName $DOMNAME
|
||||
abstract class $CLASSNAME$EXTENDS$IMPLEMENTS {
|
||||
$!MEMBERS}
|
|
@ -5,7 +5,7 @@
|
|||
part of html;
|
||||
|
||||
$!COMMENT
|
||||
abstract class Document extends HtmlElement {
|
||||
abstract class _IDocument extends _IHtmlElement {
|
||||
|
||||
$!MEMBERS
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
part of html;
|
||||
|
||||
$!COMMENT
|
||||
abstract class DocumentFragment extends Element {
|
||||
abstract class _IDocumentFragment extends Element {
|
||||
|
||||
factory DocumentFragment() => _$(ID)FactoryProvider.createDocumentFragment();
|
||||
factory _IDocumentFragment() => _$(ID)FactoryProvider.createDocumentFragment();
|
||||
|
||||
factory DocumentFragment.html(String html) =>
|
||||
factory _IDocumentFragment.html(String html) =>
|
||||
_$(ID)FactoryProvider.createDocumentFragment_html(html);
|
||||
|
||||
// TODO(nweiz): enable this when XML is ported
|
||||
|
@ -17,7 +17,7 @@ abstract class DocumentFragment extends Element {
|
|||
// DocumentFragment.xml(String xml);
|
||||
|
||||
factory DocumentFragment.svg(String svg) =>
|
||||
new _$(ID)FactoryProvider.DocumentFragment.svg(svg);
|
||||
new _$(ID)FactoryProvider.createDocumentFragment_svg(svg);
|
||||
|
||||
DocumentFragment clone(bool deep);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ abstract class CSSClassSet implements Set<String> {
|
|||
}
|
||||
|
||||
$!COMMENT
|
||||
abstract class Element implements Node, NodeSelector {
|
||||
abstract class _IElement implements _INode, NodeSelector {
|
||||
factory Element.html(String html) =>
|
||||
_$(ID)FactoryProvider.createElement_html(html);
|
||||
factory Element.tag(String tag) =>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
part of html;
|
||||
|
||||
abstract class EventListenerList {
|
||||
abstract class _IEventListenerList {
|
||||
EventListenerList add(EventListener handler, [bool useCapture]);
|
||||
|
||||
EventListenerList remove(EventListener handler, [bool useCapture]);
|
||||
|
@ -14,7 +14,7 @@ abstract class EventListenerList {
|
|||
bool dispatch(Event evt);
|
||||
}
|
||||
|
||||
abstract class Events {
|
||||
abstract class _IEvents {
|
||||
EventListenerList operator [](String type);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
part of html;
|
||||
|
||||
$!COMMENT
|
||||
abstract class SVGElement implements Element {
|
||||
abstract class _ISVGElement implements _IElement {
|
||||
|
||||
factory SVGElement.tag(String tag) =>
|
||||
_$(ID)FactoryProvider.create$(ID)_tag(tag);
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
part of html;
|
||||
|
||||
$!COMMENT
|
||||
abstract class SVGSVGElement extends SVGElement implements SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGStylable, SVGLocatable, SVGFitToViewBox, SVGZoomAndPan {
|
||||
factory SVGSVGElement() => _$(ID)FactoryProvider.createSVGSVGElement();
|
||||
abstract class _ISVGSVGElement extends _ISVGElement implements _ISVGTests, _ISVGLangSpace, _ISVGExternalResourcesRequired, _ISVGStylable, _ISVGLocatable, _ISVGFitToViewBox, _ISVGZoomAndPan {
|
||||
|
||||
$!MEMBERS
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@ part of html;
|
|||
$!COMMENT
|
||||
abstract class $ID$EXTENDS {
|
||||
$!MEMBERS
|
||||
static bool get supported => _$(ID)Impl.supported;
|
||||
static bool get supported => $(ID).supported;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue