Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 class _ChildrenNodeList implements NodeList { | 5 class _ChildrenNodeList implements NodeList { |
| 6 // Raw node. | 6 // Raw node. |
| 7 final _node; | 7 final _node; |
| 8 final _childNodes; | 8 final _childNodes; |
| 9 | 9 |
| 10 _ChildrenNodeList._wrap(var node) | 10 _ChildrenNodeList._wrap(var node) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 | 68 |
| 69 int get length() { | 69 int get length() { |
| 70 return _childNodes.length; | 70 return _childNodes.length; |
| 71 } | 71 } |
| 72 | 72 |
| 73 Node operator [](int index) { | 73 Node operator [](int index) { |
| 74 return LevelDom.wrapNode(_childNodes[index]); | 74 return LevelDom.wrapNode(_childNodes[index]); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void operator []=(int index, Node value) { | 77 void operator []=(int index, Node value) { |
| 78 _childNodes[index] = LevelDom.unwrap(value); | 78 _node.replaceChild(LevelDom.unwrap(value), _childNodes[index]); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void set length(int newLength) { | 81 void set length(int newLength) { |
| 82 throw new UnsupportedOperationException(''); | 82 throw new UnsupportedOperationException(''); |
| 83 } | 83 } |
| 84 | 84 |
| 85 /** @domName Node.appendChild */ | 85 /** @domName Node.appendChild */ |
| 86 Node add(Node value) { | 86 Node add(Node value) { |
| 87 _node.appendChild(LevelDom.unwrap(value)); | 87 _node.appendChild(LevelDom.unwrap(value)); |
| 88 return value; | 88 return value; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 105 | 105 |
| 106 void sort(int compare(Node a, Node b)) { | 106 void sort(int compare(Node a, Node b)) { |
| 107 throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); | 107 throw const UnsupportedOperationException('TODO(jacobr): should we impl?'); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { | 110 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) { |
| 111 throw 'Not impl yet. todo(jacobr)'; | 111 throw 'Not impl yet. todo(jacobr)'; |
| 112 } | 112 } |
| 113 | 113 |
| 114 void setRange(int start, int length, List from, [int startFrom = 0]) { | 114 void setRange(int start, int length, List from, [int startFrom = 0]) { |
| 115 throw const NotImplementedException(); | 115 // TODO(nweiz): remove these IndexOutOfRange checks once Frog has bounds |
| 116 // checking for List indexing | |
| 117 if (start < 0) { | |
| 118 throw new IndexOutOfRangeException(start); | |
| 119 } else if (startFrom < 0) { | |
| 120 throw new IndexOutOfRangeException(startFrom); | |
| 121 } else if (length < 0) { | |
| 122 throw new IllegalArgumentException("negative length $length"); | |
| 123 } else if (start + length > this.length) { | |
| 124 throw new IndexOutOfRangeException(Math.min(this.length, start)); | |
| 125 } else if (startFrom + length > from.length) { | |
| 126 throw new IndexOutOfRangeException(Math.min(from.length, startFrom)); | |
| 127 } | |
| 128 | |
| 129 for (var i = 0; i < length; i++) { | |
| 130 this[start + i] = from[startFrom + i]; | |
| 131 } | |
| 116 } | 132 } |
| 117 | 133 |
| 118 void removeRange(int start, int length) { | 134 void removeRange(int start, int length) { |
| 119 throw const NotImplementedException(); | 135 // TODO(nweiz): remove these IndexOutOfRange checks once Frog has bounds |
| 136 // checking for List indexing | |
| 137 if (start < 0) { | |
| 138 throw new IndexOutOfRangeException(start); | |
| 139 } else if (length < 0) { | |
| 140 throw new IllegalArgumentException("negative length $length"); | |
| 141 } else if (start + length > this.length) { | |
| 142 throw new IndexOutOfRangeException(Math.min(this.length, start)); | |
| 143 } | |
| 144 | |
| 145 for (var i = 0; i < length; i++) { | |
| 146 this[start].remove(); | |
| 147 } | |
| 120 } | 148 } |
| 121 | 149 |
| 122 void insertRange(int start, int length, [initialValue = null]) { | 150 void insertRange(int start, int length, [initialValue = null]) { |
| 123 throw const NotImplementedException(); | 151 throw const NotImplementedException(); |
| 124 } | 152 } |
| 125 | 153 |
| 126 List getRange(int start, int length) { | 154 List getRange(int start, int length) { |
| 127 throw const NotImplementedException(); | 155 // TODO(nweiz): remove these IndexOutOfRange checks once Frog has bounds |
| 156 // checking for List indexing | |
| 157 if (start < 0) { | |
| 158 throw new IndexOutOfRangeException(start); | |
| 159 } else if (length < 0) { | |
| 160 throw new IllegalArgumentException("negative length $length"); | |
| 161 } else if (start + length > this.length) { | |
| 162 throw new IndexOutOfRangeException(Math.min(this.length, start)); | |
| 163 } | |
| 164 | |
| 165 var nodes = <Node>[]; | |
|
Jacob
2012/01/17 18:14:53
make this return a Nodelist rather than a List so
nweiz
2012/01/17 23:23:22
How will this work type-wise? The user only access
| |
| 166 for (var i = 0; i < length; i++) { | |
| 167 nodes.add(this[start + i]); | |
| 168 } | |
| 169 return nodes; | |
| 128 } | 170 } |
| 129 | 171 |
| 130 int indexOf(Node element, [int start = 0]) { | 172 int indexOf(Node element, [int start = 0]) { |
| 131 return _Lists.indexOf(this, element, start, this.length); | 173 return _Lists.indexOf(this, element, start, this.length); |
| 132 } | 174 } |
| 133 | 175 |
| 134 int lastIndexOf(Node element, [int start = null]) { | 176 int lastIndexOf(Node element, [int start = null]) { |
| 135 if (start === null) start = length - 1; | 177 if (start === null) start = length - 1; |
| 136 return _Lists.lastIndexOf(this, element, start); | 178 return _Lists.lastIndexOf(this, element, start); |
| 137 } | 179 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 // array. | 258 // array. |
| 217 Node insertBefore(Node newChild, Node refChild) { | 259 Node insertBefore(Node newChild, Node refChild) { |
| 218 return LevelDom.wrapNode(_ptr.insertBefore( | 260 return LevelDom.wrapNode(_ptr.insertBefore( |
| 219 LevelDom.unwrap(newChild), LevelDom.unwrap(refChild))); | 261 LevelDom.unwrap(newChild), LevelDom.unwrap(refChild))); |
| 220 } | 262 } |
| 221 | 263 |
| 222 Node clone(bool deep) { | 264 Node clone(bool deep) { |
| 223 return LevelDom.wrapNode(_ptr.cloneNode(deep)); | 265 return LevelDom.wrapNode(_ptr.cloneNode(deep)); |
| 224 } | 266 } |
| 225 } | 267 } |
| OLD | NEW |