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

Side by Side Diff: sdk/lib/web_sql/dart2js/web_sql_dart2js.dart

Issue 14619013: Explicitly implementing some DOM iterable APIs for performance (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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
1 /** 1 /**
2 * An API for storing data in the browser that can be queried with SQL. 2 * An API for storing data in the browser that can be queried with SQL.
3 * 3 *
4 * **Caution:** this specification is no longer actively maintained by the Web 4 * **Caution:** this specification is no longer actively maintained by the Web
5 * Applications Working Group and may be removed at any time. 5 * Applications Working Group and may be removed at any time.
6 * See [the W3C Web SQL Database specification](http://www.w3.org/TR/webdatabase /) 6 * See [the W3C Web SQL Database specification](http://www.w3.org/TR/webdatabase /)
7 * for more information. 7 * for more information.
8 * 8 *
9 * The [dart:indexed_db] APIs is a recommended alternatives. 9 * The [dart:indexed_db] APIs is a recommended alternatives.
10 */ 10 */
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 193
194 @DocsEditable 194 @DocsEditable
195 @DomName('SQLResultSetRowList') 195 @DomName('SQLResultSetRowList')
196 class SqlResultSetRowList extends Object with ListMixin<Map>, ImmutableListMixin <Map> implements JavaScriptIndexingBehavior, List<Map> native "SQLResultSetRowLi st" { 196 class SqlResultSetRowList extends Object with ListMixin<Map>, ImmutableListMixin <Map> implements JavaScriptIndexingBehavior, List<Map> native "SQLResultSetRowLi st" {
197 197
198 @DomName('SQLResultSetRowList.length') 198 @DomName('SQLResultSetRowList.length')
199 @DocsEditable 199 @DocsEditable
200 int get length => JS("int", "#.length", this); 200 int get length => JS("int", "#.length", this);
201 201
202 Map operator[](int index) => this.item(index); 202 Map operator[](int index) {
203 203 if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) thro w new RangeError.range(index, 0, length);
204 return this.item(index);
205 }
204 void operator[]=(int index, Map value) { 206 void operator[]=(int index, Map value) {
205 throw new UnsupportedError("Cannot assign element of immutable List."); 207 throw new UnsupportedError("Cannot assign element of immutable List.");
206 } 208 }
207 // -- start List<Map> mixins. 209 // -- start List<Map> mixins.
208 // Map is the element type. 210 // Map is the element type.
209 211
210 212
211 void set length(int value) { 213 void set length(int value) {
212 throw new UnsupportedError("Cannot resize immutable List."); 214 throw new UnsupportedError("Cannot resize immutable List.");
213 } 215 }
214 216
217 Map get first {
218 if (this.length > 0) {
219 return JS('Map', '#[0]', this);
220 }
221 throw new StateError("No elements");
222 }
223
224 Map get last {
225 int len = this.length;
226 if (len > 0) {
227 return JS('Map', '#[#]', this, len - 1);
228 }
229 throw new StateError("No elements");
230 }
231
232 Map get single {
233 int len = this.length;
234 if (len == 1) {
235 return JS('Map', '#[0]', this);
236 }
237 if (len == 0) throw new StateError("No elements");
238 throw new StateError("More than one element");
239 }
240
241 Map elementAt(int index) {
242 return this[index];
243 }
244
215 // -- end List<Map> mixins. 245 // -- end List<Map> mixins.
216 246
217 @DomName('SQLResultSetRowList.item') 247 @DomName('SQLResultSetRowList.item')
218 @DocsEditable 248 @DocsEditable
219 @Creates('=Object') 249 @Creates('=Object')
220 Map item(int index) { 250 Map item(int index) {
221 return convertNativeToDart_Dictionary(_item_1(index)); 251 return convertNativeToDart_Dictionary(_item_1(index));
222 } 252 }
223 @JSName('item') 253 @JSName('item')
224 @DomName('SQLResultSetRowList.item') 254 @DomName('SQLResultSetRowList.item')
(...skipping 22 matching lines...) Expand all
247 // BSD-style license that can be found in the LICENSE file. 277 // BSD-style license that can be found in the LICENSE file.
248 278
249 279
250 @DocsEditable 280 @DocsEditable
251 @DomName('SQLTransactionSync') 281 @DomName('SQLTransactionSync')
252 @SupportedBrowser(SupportedBrowser.CHROME) 282 @SupportedBrowser(SupportedBrowser.CHROME)
253 @SupportedBrowser(SupportedBrowser.SAFARI) 283 @SupportedBrowser(SupportedBrowser.SAFARI)
254 @Experimental 284 @Experimental
255 abstract class _SQLTransactionSync native "SQLTransactionSync" { 285 abstract class _SQLTransactionSync native "SQLTransactionSync" {
256 } 286 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698