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

Unified Diff: client/html/generated/html/frog/Node.dart

Issue 9403004: Wrapperless dart:html generator (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review fixes Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: client/html/generated/html/frog/Node.dart
diff --git a/client/html/generated/html/frog/Node.dart b/client/html/generated/html/frog/Node.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0ed4254ae603ced09fff0377b3734d92efea5a88
--- /dev/null
+++ b/client/html/generated/html/frog/Node.dart
@@ -0,0 +1,190 @@
+// 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.
+
+// TODO(nweiz): when all implementations we target have the same name for the
+// coreimpl implementation of List<E>, extend that rather than wrapping.
+class _ListWrapper<E> implements List<E> {
+ List<E> _list;
+
+ _ListWrapper(List<E> this._list);
+
+ Iterator<E> iterator() => _list.iterator();
+
+ void forEach(void f(E element)) => _list.forEach(f);
+
+ Collection map(f(E element)) => _list.map(f);
+
+ List<E> filter(bool f(E element)) => _list.filter(f);
+
+ bool every(bool f(E element)) => _list.every(f);
+
+ bool some(bool f(E element)) => _list.some(f);
+
+ bool isEmpty() => _list.isEmpty();
+
+ int get length() => _list.length;
+
+ E operator [](int index) => _list[index];
+
+ void operator []=(int index, E value) { _list[index] = value; }
+
+ void set length(int newLength) { _list.length = newLength; }
+
+ void add(E value) => _list.add(value);
+
+ void addLast(E value) => _list.addLast(value);
+
+ void addAll(Collection<E> collection) => _list.addAll(collection);
+
+ void sort(int compare(E a, E b)) => _list.sort(compare);
+
+ int indexOf(E element, [int start = 0]) => _list.indexOf(element, start);
+
+ int lastIndexOf(E element, [int start = 0]) =>
+ _list.lastIndexOf(element, start);
+
+ void clear() => _list.clear();
+
+ E removeLast() => _list.removeLast();
+
+ E last() => _list.last();
+
+ List<E> getRange(int start, int length) => _list.getRange(start, length);
+
+ void setRange(int start, int length, List<E> from, [int startFrom = 0]) =>
+ _list.setRange(start, length, from, startFrom);
+
+ void removeRange(int start, int length) => _list.removeRange(start, length);
+
+ void insertRange(int start, int length, [E initialValue = null]) =>
+ _list.insertRange(start, length, initialValue);
+
+ E get first() => _list[0];
+}
+
+class _NodeList extends _ListWrapper<Node> implements NodeList {
+ _NodeList(List<Node> list) : super(list);
+
+ NodeList filter(bool f(Node element)) => new _NodeList(super.filter(f));
+
+ NodeList getRange(int start, int length) =>
+ new _NodeList(super.getRange(start, length));
+}
+
+class _NodeJs implements Node native "*Node" {
+ _NodeListJs get nodes() {
+ final list = _childNodes;
+ list._parent = this;
+ return list;
+ }
+
+ void set nodes(Collection<Node> value) {
+ // Copy list first since we don't want liveness during iteration.
+ // TODO(jacobr): there is a better way to do this.
+ List copy = new List.from(value);
+ nodes.clear();
+ nodes.addAll(copy);
+ }
+
+ _NodeJs get nextNode() native "return this.nextSibling;";
+
+ _NodeJs get previousNode() native "return this.previousSibling;";
+
+ _DocumentJs get document() native "return this.ownerDocument;";
+
+ _NodeJs get parent() native "return this.parentNode;";
+
+ String get text() native "return this.textContent;";
+
+ void set text(String value) native "this.textContent = value;";
+
+ // TODO(jacobr): should we throw an exception if parent is already null?
+ _NodeJs remove() {
+ if (this.parent != null) {
+ this.parent._removeChild(this);
+ }
+ return this;
+ }
+
+ _NodeJs replaceWith(Node otherNode) {
+ try {
+ this.parent._replaceChild(otherNode, this);
+ } catch(var e) {
+
+ };
+ return this;
+ }
+
+
+ static final int ATTRIBUTE_NODE = 2;
+
+ static final int CDATA_SECTION_NODE = 4;
+
+ static final int COMMENT_NODE = 8;
+
+ static final int DOCUMENT_FRAGMENT_NODE = 11;
+
+ static final int DOCUMENT_NODE = 9;
+
+ static final int DOCUMENT_POSITION_CONTAINED_BY = 0x10;
+
+ static final int DOCUMENT_POSITION_CONTAINS = 0x08;
+
+ static final int DOCUMENT_POSITION_DISCONNECTED = 0x01;
+
+ static final int DOCUMENT_POSITION_FOLLOWING = 0x04;
+
+ static final int DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
+
+ static final int DOCUMENT_POSITION_PRECEDING = 0x02;
+
+ static final int DOCUMENT_TYPE_NODE = 10;
+
+ static final int ELEMENT_NODE = 1;
+
+ static final int ENTITY_NODE = 6;
+
+ static final int ENTITY_REFERENCE_NODE = 5;
+
+ static final int NOTATION_NODE = 12;
+
+ static final int PROCESSING_INSTRUCTION_NODE = 7;
+
+ static final int TEXT_NODE = 3;
+
+ _NamedNodeMapJs get _attributes() native "return this.attributes;";
+
+ _NodeListJs get _childNodes() native "return this.childNodes;";
+
+ final _NodeJs nextSibling;
+
+ final _DocumentJs ownerDocument;
+
+ final _NodeJs parentNode;
+
+ final _NodeJs previousSibling;
+
+ String textContent;
+
+ void _addEventListener(String type, EventListener listener, [bool useCapture = null]) native "this.addEventListener(type, listener, useCapture);";
+
+ _NodeJs _appendChild(_NodeJs newChild) native "return this.appendChild(newChild);";
+
+ _NodeJs cloneNode(bool deep) native;
+
+ bool contains(_NodeJs other) native;
+
+ bool _dispatchEvent(_EventJs event) native "return this.dispatchEvent(event);";
+
+ bool hasChildNodes() native;
+
+ _NodeJs insertBefore(_NodeJs newChild, _NodeJs refChild) native;
+
+ _NodeJs _removeChild(_NodeJs oldChild) native "return this.removeChild(oldChild);";
+
+ void _removeEventListener(String type, EventListener listener, [bool useCapture = null]) native "this.removeEventListener(type, listener, useCapture);";
+
+ _NodeJs _replaceChild(_NodeJs newChild, _NodeJs oldChild) native "return this.replaceChild(newChild, oldChild);";
+
+}

Powered by Google App Engine
This is Rietveld 408576698