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

Side by Side Diff: client/dom/templates/html/frog/impl_Node.darttemplate

Issue 9403004: Wrapperless dart:html generator (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final version to check in. changes generator script but doesn't check in an active version of the … 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // TODO(nweiz): when all implementations we target have the same name for the
6 // coreimpl implementation of List<E>, extend that rather than wrapping.
7 class _ListWrapper<E> implements List<E> {
8 List<E> _list;
9
10 _ListWrapper(List<E> this._list);
11
12 Iterator<E> iterator() => _list.iterator();
13
14 void forEach(void f(E element)) => _list.forEach(f);
15
16 Collection map(f(E element)) => _list.map(f);
17
18 List<E> filter(bool f(E element)) => _list.filter(f);
19
20 bool every(bool f(E element)) => _list.every(f);
21
22 bool some(bool f(E element)) => _list.some(f);
23
24 bool isEmpty() => _list.isEmpty();
25
26 int get length() => _list.length;
27
28 E operator [](int index) => _list[index];
29
30 void operator []=(int index, E value) { _list[index] = value; }
31
32 void set length(int newLength) { _list.length = newLength; }
33
34 void add(E value) => _list.add(value);
35
36 void addLast(E value) => _list.addLast(value);
37
38 void addAll(Collection<E> collection) => _list.addAll(collection);
39
40 void sort(int compare(E a, E b)) => _list.sort(compare);
41
42 int indexOf(E element, [int start = 0]) => _list.indexOf(element, start);
43
44 int lastIndexOf(E element, [int start = 0]) =>
45 _list.lastIndexOf(element, start);
46
47 void clear() => _list.clear();
48
49 E removeLast() => _list.removeLast();
50
51 E last() => _list.last();
52
53 List<E> getRange(int start, int length) => _list.getRange(start, length);
54
55 void setRange(int start, int length, List<E> from, [int startFrom = 0]) =>
56 _list.setRange(start, length, from, startFrom);
57
58 void removeRange(int start, int length) => _list.removeRange(start, length);
59
60 void insertRange(int start, int length, [E initialValue = null]) =>
61 _list.insertRange(start, length, initialValue);
62
63 E get first() => _list[0];
64 }
65
66 class _NodeList extends _ListWrapper<Node> implements NodeList {
67 _NodeList(List<Node> list) : super(list);
68
69 NodeList filter(bool f(Node element)) => new _NodeList(super.filter(f));
70
71 NodeList getRange(int start, int length) =>
72 new _NodeList(super.getRange(start, length));
73 }
74
75 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
76 _NodeListJs get nodes() {
77 final list = _childNodes;
78 list._parent = this;
79 return list;
80 }
81
82 void set nodes(Collection<Node> value) {
83 // Copy list first since we don't want liveness during iteration.
84 // TODO(jacobr): there is a better way to do this.
85 List copy = new List.from(value);
86 nodes.clear();
87 nodes.addAll(copy);
88 }
89
90 _NodeJs get nextNode() native "return this.nextSibling;";
91
92 _NodeJs get previousNode() native "return this.previousSibling;";
93
94 _DocumentJs get document() native "return this.ownerDocument;";
95
96 _NodeJs get parent() native "return this.parentNode;";
97
98 String get text() native "return this.textContent;";
99
100 void set text(String value) native "this.textContent = value;";
101
102 // TODO(jacobr): should we throw an exception if parent is already null?
103 _NodeJs remove() {
104 if (this.parent != null) {
105 this.parent._removeChild(this);
106 }
107 return this;
108 }
109
110 _NodeJs replaceWith(Node otherNode) {
111 try {
112 this.parent._replaceChild(otherNode, this);
113 } catch(var e) {
114
115 };
116 return this;
117 }
118
119 $!MEMBERS
120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698