Index: client/html/dartium/html_dartium.dart |
diff --git a/client/html/dartium/html_dartium.dart b/client/html/dartium/html_dartium.dart |
index 5bb4f6b3718d8e2e4cfae4e6496a2c0dd3f55c5c..fccdb40d727e7ca50fb1d8963b507afff31cc1f2 100644 |
--- a/client/html/dartium/html_dartium.dart |
+++ b/client/html/dartium/html_dartium.dart |
@@ -64,6 +64,8 @@ _wrap(raw) { |
throw 'A document should never be wrapped directly. TODO(jacobr) XXX'; |
case 'HTMLHtmlElement': |
return new _DocumentImpl._wrap(domObject); |
+ case 'HTMLElement': |
+ return new _UnknownElementImpl._wrap(domObject); |
case "EventTarget": return new _EventTargetImpl._wrap(domObject); |
case "AbstractWorker": return new _AbstractWorkerImpl._wrap(domObject); |
case "Node": return new _NodeImpl._wrap(domObject); |
@@ -5589,7 +5591,7 @@ class _ClipboardImpl extends _DOMTypeBase implements Clipboard { |
DataTransferItemList get items() => _wrap(_ptr.items); |
- List get types() => _wrap(_ptr.types); |
+ List<String> get types() => _wrap(_ptr.types); |
void clearData([String type = null]) { |
if (type === null) { |
@@ -6179,9 +6181,14 @@ class _DataTransferItemImpl extends _DOMTypeBase implements DataTransferItem { |
return _wrap(_ptr.getAsFile()); |
} |
- void getAsString(StringCallback callback) { |
- _ptr.getAsString(_unwrap(callback)); |
- return; |
+ void getAsString([StringCallback callback = null]) { |
+ if (callback === null) { |
+ _ptr.getAsString(); |
+ return; |
+ } else { |
+ _ptr.getAsString(_unwrap(callback)); |
+ return; |
+ } |
} |
} |
@@ -6741,7 +6748,7 @@ class _DocumentImpl extends _ElementImpl |
return _wrap(_documentPtr.execCommand(_unwrap(command), _unwrap(userInterface), _unwrap(value))); |
} |
- Object getCSSCanvasContext(String contextId, String name, int width, int height) { |
+ CanvasRenderingContext getCSSCanvasContext(String contextId, String name, int width, int height) { |
return _wrap(_documentPtr.getCSSCanvasContext(_unwrap(contextId), _unwrap(name), _unwrap(width), _unwrap(height))); |
} |
@@ -6912,10 +6919,342 @@ class _DocumentEventsImpl extends _ElementEventsImpl implements DocumentEvents { |
EventListenerList get touchStart() => _get('touchstart'); |
} |
+// Copyright (c) 2011, 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 FilteredElementList implements ElementList { |
+ final Node _node; |
+ final NodeList _childNodes; |
+ |
+ FilteredElementList(Node node): _childNodes = node.nodes, _node = node; |
+ |
+ // We can't memoize this, since it's possible that children will be messed |
+ // with externally to this class. |
+ // |
+ // TODO(nweiz): Do we really need to copy the list to make the types work out? |
+ List<Element> get _filtered() => |
+ new List.from(_childNodes.filter((n) => n is Element)); |
+ |
+ // Don't use _filtered.first so we can short-circuit once we find an element. |
+ Element get first() { |
+ for (var node in _childNodes) { |
+ if (node is Element) { |
+ return node; |
+ } |
+ } |
+ return null; |
+ } |
+ |
+ void forEach(void f(Element element)) { |
+ _filtered.forEach(f); |
+ } |
+ |
+ void operator []=(int index, Element value) { |
+ this[index].replaceWith(value); |
+ } |
+ |
+ void set length(int newLength) { |
+ var len = this.length; |
+ if (newLength >= len) { |
+ return; |
+ } else if (newLength < 0) { |
+ throw const IllegalArgumentException("Invalid list length"); |
+ } |
+ |
+ removeRange(newLength - 1, len - newLength); |
+ } |
+ |
+ void add(Element value) { |
+ _childNodes.add(value); |
+ } |
+ |
+ void addAll(Collection<Element> collection) { |
+ collection.forEach(add); |
+ } |
+ |
+ void addLast(Element value) { |
+ add(value); |
+ } |
+ |
+ void sort(int compare(Element a, Element b)) { |
+ throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); |
+ } |
+ |
+ void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { |
+ throw const NotImplementedException(); |
+ } |
+ |
+ void setRange(int start, int length, List from, [int startFrom = 0]) { |
+ throw const NotImplementedException(); |
+ } |
+ |
+ void removeRange(int start, int length) { |
+ _filtered.getRange(start, length).forEach((el) => el.remove()); |
+ } |
+ |
+ void insertRange(int start, int length, [initialValue = null]) { |
+ throw const NotImplementedException(); |
+ } |
+ |
+ void clear() { |
+ // Currently, ElementList#clear clears even non-element nodes, so we follow |
+ // that behavior. |
+ _childNodes.clear(); |
+ } |
+ |
+ Element removeLast() { |
+ var last = this.last(); |
+ if (last != null) { |
+ last.remove(); |
+ } |
+ return last; |
+ } |
+ |
+ Collection map(f(Element element)) => _filtered.map(f); |
+ Collection<Element> filter(bool f(Element element)) => _filtered.filter(f); |
+ bool every(bool f(Element element)) => _filtered.every(f); |
+ bool some(bool f(Element element)) => _filtered.some(f); |
+ bool isEmpty() => _filtered.isEmpty(); |
+ int get length() => _filtered.length; |
+ Element operator [](int index) => _filtered[index]; |
+ Iterator<Element> iterator() => _filtered.iterator(); |
+ List<Element> getRange(int start, int length) => |
+ _filtered.getRange(start, length); |
+ int indexOf(Element element, [int start = 0]) => |
+ _filtered.indexOf(element, start); |
+ |
+ int lastIndexOf(Element element, [int start = null]) { |
+ if (start === null) start = length - 1; |
+ return _filtered.lastIndexOf(element, start); |
+ } |
+ |
+ Element last() => _filtered.last(); |
+} |
+ |
+Future<CSSStyleDeclaration> _emptyStyleFuture() { |
+ return _createMeasurementFuture(() => new Element.tag('div').style, |
+ new Completer<CSSStyleDeclaration>()); |
+} |
+ |
+class EmptyElementRect implements ElementRect { |
+ final ClientRect client = const _SimpleClientRect(0, 0, 0, 0); |
+ final ClientRect offset = const _SimpleClientRect(0, 0, 0, 0); |
+ final ClientRect scroll = const _SimpleClientRect(0, 0, 0, 0); |
+ final ClientRect bounding = const _SimpleClientRect(0, 0, 0, 0); |
+ final List<ClientRect> clientRects = const <ClientRect>[]; |
+ |
+ const EmptyElementRect(); |
+} |
class _DocumentFragmentImpl extends _NodeImpl implements DocumentFragment { |
+ ElementList _elements; |
+ |
+ ElementList get elements() { |
+ if (_elements == null) { |
+ _elements = new FilteredElementList(this); |
+ } |
+ return _elements; |
+ } |
+ |
+ // TODO: The type of value should be Collection<Element>. See http://b/5392897 |
+ void set elements(value) { |
+ // Copy list first since we don't want liveness during iteration. |
+ List copy = new List.from(value); |
+ final elements = this.elements; |
+ elements.clear(); |
+ elements.addAll(copy); |
+ } |
+ |
+ ElementList queryAll(String selectors) => |
+ new _FrozenElementList._wrap(_querySelectorAll(selectors)); |
+ |
+ String get innerHTML() { |
+ var e = new Element.tag("div"); |
+ e.nodes.add(this.clone(true)); |
+ return e.innerHTML; |
+ } |
+ |
+ String get outerHTML() => innerHTML; |
+ |
+ // TODO(nweiz): Do we want to support some variant of innerHTML for XML and/or |
+ // SVG strings? |
+ void set innerHTML(String value) { |
+ this.nodes.clear(); |
+ |
+ var e = new Element.tag("div"); |
+ e.innerHTML = value; |
+ |
+ // Copy list first since we don't want liveness during iteration. |
+ List nodes = new List.from(e.nodes); |
+ this.nodes.addAll(nodes); |
+ } |
+ |
+ Node _insertAdjacentNode(String where, Node node) { |
+ switch (where.toLowerCase()) { |
+ case "beforebegin": return null; |
+ case "afterend": return null; |
+ case "afterbegin": |
+ this.insertBefore(node, nodes.first); |
+ return node; |
+ case "beforeend": |
+ this.nodes.add(node); |
+ return node; |
+ default: |
+ throw new IllegalArgumentException("Invalid position ${where}"); |
+ } |
+ } |
+ |
+ Element insertAdjacentElement([String where = null, Element element = null]) |
+ => this._insertAdjacentNode(where, element); |
+ |
+ void insertAdjacentText([String where = null, String text = null]) { |
+ this._insertAdjacentNode(where, new Text(text)); |
+ } |
+ |
+ void insertAdjacentHTML( |
+ [String position_OR_where = null, String text = null]) { |
+ this._insertAdjacentNode( |
+ position_OR_where, new DocumentFragment.html(text)); |
+ } |
+ |
+ Future<ElementRect> get rect() { |
+ return _createMeasurementFuture(() => const EmptyElementRect(), |
+ new Completer<ElementRect>()); |
+ } |
+ |
+ // If we can come up with a semi-reasonable default value for an Element |
+ // getter, we'll use it. In general, these return the same values as an |
+ // element that has no parent. |
+ String get contentEditable() => "false"; |
+ bool get isContentEditable() => false; |
+ bool get draggable() => false; |
+ bool get hidden() => false; |
+ bool get spellcheck() => false; |
+ int get tabIndex() => -1; |
+ String get id() => ""; |
+ String get title() => ""; |
+ String get tagName() => ""; |
+ String get webkitdropzone() => ""; |
+ Element get firstElementChild() => elements.first(); |
+ Element get lastElementChild() => elements.last(); |
+ Element get nextElementSibling() => null; |
+ Element get previousElementSibling() => null; |
+ Element get offsetParent() => null; |
+ Element get parent() => null; |
+ Map<String, String> get attributes() => const {}; |
+ // Issue 174: this should be a const set. |
+ Set<String> get classes() => new Set<String>(); |
+ Map<String, String> get dataAttributes() => const {}; |
+ CSSStyleDeclaration get style() => new Element.tag('div').style; |
+ Future<CSSStyleDeclaration> get computedStyle() => |
+ _emptyStyleFuture(); |
+ Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) => |
+ _emptyStyleFuture(); |
+ bool matchesSelector([String selectors]) => false; |
+ |
+ // Imperative Element methods are made into no-ops, as they are on parentless |
+ // elements. |
+ void blur() {} |
+ void focus() {} |
+ void scrollByLines([int lines]) {} |
+ void scrollByPages([int pages]) {} |
+ void scrollIntoView([bool centerIfNeeded]) {} |
+ |
+ // Setters throw errors rather than being no-ops because we aren't going to |
+ // retain the values that were set, and erroring out seems clearer. |
+ void set attributes(Map<String, String> value) { |
+ throw new UnsupportedOperationException( |
+ "Attributes can't be set for document fragments."); |
+ } |
+ |
+ void set classes(Collection<String> value) { |
+ throw new UnsupportedOperationException( |
+ "Classes can't be set for document fragments."); |
+ } |
+ |
+ void set dataAttributes(Map<String, String> value) { |
+ throw new UnsupportedOperationException( |
+ "Data attributes can't be set for document fragments."); |
+ } |
+ |
+ void set contentEditable(String value) { |
+ throw new UnsupportedOperationException( |
+ "Content editable can't be set for document fragments."); |
+ } |
+ |
+ String get dir() { |
+ throw new UnsupportedOperationException( |
+ "Document fragments don't support text direction."); |
+ } |
+ |
+ void set dir(String value) { |
+ throw new UnsupportedOperationException( |
+ "Document fragments don't support text direction."); |
+ } |
+ |
+ void set draggable(bool value) { |
+ throw new UnsupportedOperationException( |
+ "Draggable can't be set for document fragments."); |
+ } |
+ |
+ void set hidden(bool value) { |
+ throw new UnsupportedOperationException( |
+ "Hidden can't be set for document fragments."); |
+ } |
+ |
+ void set id(String value) { |
+ throw new UnsupportedOperationException( |
+ "ID can't be set for document fragments."); |
+ } |
+ |
+ String get lang() { |
+ throw new UnsupportedOperationException( |
+ "Document fragments don't support language."); |
+ } |
+ |
+ void set lang(String value) { |
+ throw new UnsupportedOperationException( |
+ "Document fragments don't support language."); |
+ } |
+ |
+ void set scrollLeft(int value) { |
+ throw new UnsupportedOperationException( |
+ "Document fragments don't support scrolling."); |
+ } |
+ |
+ void set scrollTop(int value) { |
+ throw new UnsupportedOperationException( |
+ "Document fragments don't support scrolling."); |
+ } |
+ |
+ void set spellcheck(bool value) { |
+ throw new UnsupportedOperationException( |
+ "Spellcheck can't be set for document fragments."); |
+ } |
+ |
+ void set tabIndex(int value) { |
+ throw new UnsupportedOperationException( |
+ "Tab index can't be set for document fragments."); |
+ } |
+ |
+ void set title(String value) { |
+ throw new UnsupportedOperationException( |
+ "Title can't be set for document fragments."); |
+ } |
+ |
+ void set webkitdropzone(String value) { |
+ throw new UnsupportedOperationException( |
+ "WebKit drop zone can't be set for document fragments."); |
+ } |
+ |
_DocumentFragmentImpl._wrap(ptr) : super._wrap(ptr); |
+ _DocumentFragmentEventsImpl get on() { |
+ if (_on == null) _on = new _DocumentFragmentEventsImpl(this); |
+ return _on; |
+ } |
+ |
Element query(String selectors) { |
return _wrap(_ptr.querySelector(_unwrap(selectors))); |
} |
@@ -6923,6 +7262,11 @@ class _DocumentFragmentImpl extends _NodeImpl implements DocumentFragment { |
NodeList _querySelectorAll(String selectors) { |
return _wrap(_ptr.querySelectorAll(_unwrap(selectors))); |
} |
+ |
+} |
+ |
+class _DocumentFragmentEventsImpl extends _ElementEventsImpl implements DocumentFragmentEvents { |
+ _DocumentFragmentEventsImpl(_ptr) : super(_ptr); |
} |
class _DocumentTypeImpl extends _NodeImpl implements DocumentType { |
@@ -7581,6 +7925,10 @@ class _ElementImpl extends _NodeImpl implements Element { |
void set title(String value) { _ptr.title = _unwrap(value); } |
+ bool get translate() => _wrap(_ptr.translate); |
+ |
+ void set translate(bool value) { _ptr.translate = _unwrap(value); } |
+ |
String get webkitRegionOverflow() => _wrap(_ptr.webkitRegionOverflow); |
String get webkitdropzone() => _wrap(_ptr.webkitdropzone); |
@@ -9381,12 +9729,20 @@ class _IDBDatabaseImpl extends _DOMTypeBase implements IDBDatabase { |
return _wrap(_ptr.setVersion(_unwrap(version))); |
} |
- IDBTransaction transaction(var storeName_OR_storeNames, int mode) { |
+ IDBTransaction transaction(var storeName_OR_storeNames, [int mode = null]) { |
if (storeName_OR_storeNames is List<String>) { |
- return _wrap(_ptr.transaction(_unwrap(storeName_OR_storeNames), _unwrap(mode))); |
+ if (mode === null) { |
+ return _wrap(_ptr.transaction(_unwrap(storeName_OR_storeNames))); |
+ } else { |
+ return _wrap(_ptr.transaction(_unwrap(storeName_OR_storeNames), _unwrap(mode))); |
+ } |
} else { |
if (storeName_OR_storeNames is String) { |
- return _wrap(_ptr.transaction(_unwrap(storeName_OR_storeNames), _unwrap(mode))); |
+ if (mode === null) { |
+ return _wrap(_ptr.transaction(_unwrap(storeName_OR_storeNames))); |
+ } else { |
+ return _wrap(_ptr.transaction(_unwrap(storeName_OR_storeNames), _unwrap(mode))); |
+ } |
} |
} |
throw "Incorrect number or type of arguments"; |
@@ -9585,8 +9941,15 @@ class _IDBObjectStoreImpl extends _DOMTypeBase implements IDBObjectStore { |
return _wrap(_ptr.createIndex(_unwrap(name), _unwrap(keyPath))); |
} |
- IDBRequest delete(IDBKey key) { |
- return _wrap(_ptr.delete(_unwrap(key))); |
+ IDBRequest delete(var key_OR_keyRange) { |
+ if (key_OR_keyRange is IDBKeyRange) { |
+ return _wrap(_ptr.delete(_unwrap(key_OR_keyRange))); |
+ } else { |
+ if (key_OR_keyRange is IDBKey) { |
+ return _wrap(_ptr.delete(_unwrap(key_OR_keyRange))); |
+ } |
+ } |
+ throw "Incorrect number or type of arguments"; |
} |
void deleteIndex(String name) { |
@@ -18662,6 +19025,16 @@ class _Uint8ClampedArrayImpl extends _Uint8ArrayImpl implements Uint8ClampedArra |
int get length() => _wrap(_ptr.length); |
+ void setElements(Object array, [int offset = null]) { |
+ if (offset === null) { |
+ _ptr.setElements(_unwrap(array)); |
+ return; |
+ } else { |
+ _ptr.setElements(_unwrap(array), _unwrap(offset)); |
+ return; |
+ } |
+ } |
+ |
Uint8ClampedArray subarray(int start, [int end = null]) { |
if (end === null) { |
return _wrap(_ptr.subarray(_unwrap(start))); |
@@ -19621,6 +19994,8 @@ class _WebKitCSSRegionRuleImpl extends _CSSRuleImpl implements WebKitCSSRegionRu |
class _WebKitNamedFlowImpl extends _DOMTypeBase implements WebKitNamedFlow { |
_WebKitNamedFlowImpl._wrap(ptr) : super._wrap(ptr); |
+ |
+ bool get overflow() => _wrap(_ptr.overflow); |
} |
class _WebSocketImpl extends _EventTargetImpl implements WebSocket { |
@@ -24139,7 +24514,7 @@ interface Clipboard { |
final DataTransferItemList items; |
- final List types; |
+ final List<String> types; |
void clearData([String type]); |
@@ -24686,7 +25061,7 @@ interface DataTransferItem { |
Blob getAsFile(); |
- void getAsString(StringCallback callback); |
+ void getAsString([StringCallback callback]); |
} |
// 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 |
@@ -24988,7 +25363,7 @@ interface Document extends HtmlElement { |
bool execCommand(String command, bool userInterface, String value); |
- Object getCSSCanvasContext(String contextId, String name, int width, int height); |
+ CanvasRenderingContext getCSSCanvasContext(String contextId, String name, int width, int height); |
bool queryCommandEnabled(String command); |
@@ -25106,13 +25481,29 @@ interface DocumentEvents extends ElementEvents { |
// 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. |
+interface DocumentFragment extends Element default _DocumentFragmentFactoryProvider { |
+ |
+ DocumentFragment(); |
-interface DocumentFragment extends Node, NodeSelector { |
+ DocumentFragment.html(String html); |
+ |
+ // TODO(nweiz): enable these when XML and/or SVG are ported |
+ // /** WARNING: Currently this doesn't work on Dartium (issue 649). */ |
+ // DocumentFragment.xml(String xml); |
+ // DocumentFragment.svg(String svg); |
+ |
+ DocumentFragment clone(bool deep); |
+ |
+ |
+ DocumentFragmentEvents get on(); |
Element query(String selectors); |
NodeList _querySelectorAll(String selectors); |
+ |
+} |
+ |
+interface DocumentFragmentEvents extends ElementEvents { |
} |
// 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 |
@@ -25515,6 +25906,8 @@ interface Element extends Node, NodeSelector default _ElementFactoryProvider { |
String title; |
+ bool translate; |
+ |
final String webkitRegionOverflow; |
String webkitdropzone; |
@@ -26734,7 +27127,7 @@ interface IDBDatabase { |
IDBVersionChangeRequest setVersion(String version); |
- IDBTransaction transaction(var storeName_OR_storeNames, int mode); |
+ IDBTransaction transaction(var storeName_OR_storeNames, [int mode]); |
} |
// 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 |
@@ -26890,7 +27283,7 @@ interface IDBObjectStore { |
IDBIndex createIndex(String name, String keyPath); |
- IDBRequest delete(IDBKey key); |
+ IDBRequest delete(var key_OR_keyRange); |
void deleteIndex(String name); |
@@ -32953,6 +33346,8 @@ interface Uint8ClampedArray extends Uint8Array default _TypedArrayFactoryProvide |
final int length; |
+ void setElements(Object array, [int offset]); |
+ |
Uint8ClampedArray subarray(int start, [int end]); |
} |
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
@@ -34089,6 +34484,8 @@ interface WebKitCSSRegionRule extends CSSRule { |
// WARNING: Do not edit - generated code. |
interface WebKitNamedFlow { |
+ |
+ final bool overflow; |
} |
// 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 |
@@ -35672,6 +36069,41 @@ class _ElementFactoryProvider { |
return document._createElement(tag); |
} |
} |
+ |
+class _DocumentFragmentFactoryProvider { |
+ /** @domName Document.createDocumentFragment */ |
+ factory DocumentFragment() => document.createDocumentFragment(); |
+ |
+ factory DocumentFragment.html(String html) { |
+ var fragment = new DocumentFragment(); |
+ fragment.innerHTML = html; |
+ return fragment; |
+ } |
+ |
+ // TODO(nweiz): enable this when XML is ported. |
+ // factory DocumentFragment.xml(String xml) { |
+ // var fragment = new DocumentFragment(); |
+ // var e = new XMLElement.tag("xml"); |
+ // e.innerHTML = xml; |
+ // |
+ // // Copy list first since we don't want liveness during iteration. |
+ // List nodes = new List.from(e.nodes); |
+ // fragment.nodes.addAll(nodes); |
+ // return fragment; |
+ // } |
+ |
+ // TODO(nweiz): enable this when SVG is ported. |
+ // factory DocumentFragment.svg(String svg) { |
+ // var fragment = new DocumentFragment(); |
+ // var e = new SVGSVGElement(); |
+ // e.innerHTML = svg; |
+ // |
+ // // Copy list first since we don't want liveness during iteration. |
+ // List nodes = new List.from(e.nodes); |
+ // fragment.nodes.addAll(nodes); |
+ // return fragment; |
+ // } |
+} |
// 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. |