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

Unified Diff: sdk/lib/html/dart2js/html_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | sdk/lib/html/dartium/html_dartium.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 0066e92ca2f302ba0a6ee8236b4bacfe28c93369..3ab3344800acf6dd48d79fb7a59cb0425bd9307a 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -6827,8 +6827,10 @@ class DomStringList extends Object with ListMixin<String>, ImmutableListMixin<St
@DocsEditable
int get length => JS("int", "#.length", this);
- String operator[](int index) => JS("String", "#[#]", this, index);
-
+ String operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("String", "#[#]", this, index);
+ }
void operator[]=(int index, String value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -6840,6 +6842,34 @@ class DomStringList extends Object with ListMixin<String>, ImmutableListMixin<St
throw new UnsupportedError("Cannot resize immutable List.");
}
+ String get first {
+ if (this.length > 0) {
+ return JS('String', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ String get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('String', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ String get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('String', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ String elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<String> mixins.
@DomName('DOMStringList.contains')
@@ -9193,8 +9223,10 @@ class FileList extends Object with ListMixin<File>, ImmutableListMixin<File> imp
@DocsEditable
int get length => JS("int", "#.length", this);
- File operator[](int index) => JS("File", "#[#]", this, index);
-
+ File operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("File", "#[#]", this, index);
+ }
void operator[]=(int index, File value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -9206,6 +9238,34 @@ class FileList extends Object with ListMixin<File>, ImmutableListMixin<File> imp
throw new UnsupportedError("Cannot resize immutable List.");
}
+ File get first {
+ if (this.length > 0) {
+ return JS('File', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ File get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('File', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ File get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('File', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ File elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<File> mixins.
@DomName('FileList.item')
@@ -9990,8 +10050,10 @@ class HtmlAllCollection extends Object with ListMixin<Node>, ImmutableListMixin<
@DocsEditable
int get length => JS("int", "#.length", this);
- Node operator[](int index) => JS("Node", "#[#]", this, index);
-
+ Node operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("Node", "#[#]", this, index);
+ }
void operator[]=(int index, Node value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -10003,6 +10065,34 @@ class HtmlAllCollection extends Object with ListMixin<Node>, ImmutableListMixin<
throw new UnsupportedError("Cannot resize immutable List.");
}
+ Node get first {
+ if (this.length > 0) {
+ return JS('Node', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ Node get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('Node', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ Node get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('Node', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Node elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<Node> mixins.
@DomName('HTMLAllCollection.item')
@@ -10032,8 +10122,10 @@ class HtmlCollection extends Object with ListMixin<Node>, ImmutableListMixin<Nod
@DocsEditable
int get length => JS("int", "#.length", this);
- Node operator[](int index) => JS("Node", "#[#]", this, index);
-
+ Node operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("Node", "#[#]", this, index);
+ }
void operator[]=(int index, Node value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -10045,6 +10137,34 @@ class HtmlCollection extends Object with ListMixin<Node>, ImmutableListMixin<Nod
throw new UnsupportedError("Cannot resize immutable List.");
}
+ Node get first {
+ if (this.length > 0) {
+ return JS('Node', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ Node get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('Node', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ Node get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('Node', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Node elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<Node> mixins.
@DomName('HTMLCollection.item')
@@ -13510,8 +13630,10 @@ class MimeTypeArray extends Object with ListMixin<MimeType>, ImmutableListMixin<
@DocsEditable
int get length => JS("int", "#.length", this);
- MimeType operator[](int index) => JS("MimeType", "#[#]", this, index);
-
+ MimeType operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("MimeType", "#[#]", this, index);
+ }
void operator[]=(int index, MimeType value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -13523,6 +13645,34 @@ class MimeTypeArray extends Object with ListMixin<MimeType>, ImmutableListMixin<
throw new UnsupportedError("Cannot resize immutable List.");
}
+ MimeType get first {
+ if (this.length > 0) {
+ return JS('MimeType', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ MimeType get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('MimeType', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ MimeType get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('MimeType', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ MimeType elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<MimeType> mixins.
@DomName('DOMMimeTypeArray.item')
@@ -14762,8 +14912,10 @@ class NodeList extends Object with ListMixin<Node>, ImmutableListMixin<Node> imp
@DocsEditable
int get length => JS("int", "#.length", this);
- Node operator[](int index) => JS("Node", "#[#]", this, index);
-
+ Node operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("Node", "#[#]", this, index);
+ }
void operator[]=(int index, Node value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -14775,6 +14927,34 @@ class NodeList extends Object with ListMixin<Node>, ImmutableListMixin<Node> imp
throw new UnsupportedError("Cannot resize immutable List.");
}
+ Node get first {
+ if (this.length > 0) {
+ return JS('Node', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ Node get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('Node', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ Node get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('Node', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Node elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<Node> mixins.
@JSName('item')
@@ -15743,8 +15923,10 @@ class PluginArray extends Object with ListMixin<Plugin>, ImmutableListMixin<Plug
@DocsEditable
int get length => JS("int", "#.length", this);
- Plugin operator[](int index) => JS("Plugin", "#[#]", this, index);
-
+ Plugin operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("Plugin", "#[#]", this, index);
+ }
void operator[]=(int index, Plugin value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -15756,6 +15938,34 @@ class PluginArray extends Object with ListMixin<Plugin>, ImmutableListMixin<Plug
throw new UnsupportedError("Cannot resize immutable List.");
}
+ Plugin get first {
+ if (this.length > 0) {
+ return JS('Plugin', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ Plugin get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('Plugin', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ Plugin get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('Plugin', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Plugin elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<Plugin> mixins.
@DomName('DOMPluginArray.item')
@@ -17398,8 +17608,10 @@ class SourceBufferList extends EventTarget with ListMixin<SourceBuffer>, Immutab
@DocsEditable
int get length => JS("int", "#.length", this);
- SourceBuffer operator[](int index) => JS("SourceBuffer", "#[#]", this, index);
-
+ SourceBuffer operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("SourceBuffer", "#[#]", this, index);
+ }
void operator[]=(int index, SourceBuffer value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -17411,6 +17623,34 @@ class SourceBufferList extends EventTarget with ListMixin<SourceBuffer>, Immutab
throw new UnsupportedError("Cannot resize immutable List.");
}
+ SourceBuffer get first {
+ if (this.length > 0) {
+ return JS('SourceBuffer', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ SourceBuffer get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('SourceBuffer', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ SourceBuffer get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('SourceBuffer', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ SourceBuffer elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<SourceBuffer> mixins.
@JSName('addEventListener')
@@ -17513,8 +17753,10 @@ class SpeechGrammarList extends Object with ListMixin<SpeechGrammar>, ImmutableL
@DocsEditable
int get length => JS("int", "#.length", this);
- SpeechGrammar operator[](int index) => JS("SpeechGrammar", "#[#]", this, index);
-
+ SpeechGrammar operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("SpeechGrammar", "#[#]", this, index);
+ }
void operator[]=(int index, SpeechGrammar value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -17526,6 +17768,34 @@ class SpeechGrammarList extends Object with ListMixin<SpeechGrammar>, ImmutableL
throw new UnsupportedError("Cannot resize immutable List.");
}
+ SpeechGrammar get first {
+ if (this.length > 0) {
+ return JS('SpeechGrammar', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ SpeechGrammar get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('SpeechGrammar', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ SpeechGrammar get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('SpeechGrammar', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ SpeechGrammar elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<SpeechGrammar> mixins.
@DomName('SpeechGrammarList.addFromString')
@@ -18804,8 +19074,10 @@ class TextTrackCueList extends Object with ListMixin<TextTrackCue>, ImmutableLis
@DocsEditable
int get length => JS("int", "#.length", this);
- TextTrackCue operator[](int index) => JS("TextTrackCue", "#[#]", this, index);
-
+ TextTrackCue operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("TextTrackCue", "#[#]", this, index);
+ }
void operator[]=(int index, TextTrackCue value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -18817,6 +19089,34 @@ class TextTrackCueList extends Object with ListMixin<TextTrackCue>, ImmutableLis
throw new UnsupportedError("Cannot resize immutable List.");
}
+ TextTrackCue get first {
+ if (this.length > 0) {
+ return JS('TextTrackCue', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ TextTrackCue get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('TextTrackCue', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ TextTrackCue get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('TextTrackCue', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ TextTrackCue elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<TextTrackCue> mixins.
@DomName('TextTrackCueList.getCueById')
@@ -18844,8 +19144,10 @@ class TextTrackList extends EventTarget with ListMixin<TextTrack>, ImmutableList
@DocsEditable
int get length => JS("int", "#.length", this);
- TextTrack operator[](int index) => JS("TextTrack", "#[#]", this, index);
-
+ TextTrack operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("TextTrack", "#[#]", this, index);
+ }
void operator[]=(int index, TextTrack value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -18857,6 +19159,34 @@ class TextTrackList extends EventTarget with ListMixin<TextTrack>, ImmutableList
throw new UnsupportedError("Cannot resize immutable List.");
}
+ TextTrack get first {
+ if (this.length > 0) {
+ return JS('TextTrack', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ TextTrack get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('TextTrack', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ TextTrack get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('TextTrack', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ TextTrack elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<TextTrack> mixins.
@JSName('addEventListener')
@@ -19110,8 +19440,10 @@ class TouchList extends Object with ListMixin<Touch>, ImmutableListMixin<Touch>
@DocsEditable
int get length => JS("int", "#.length", this);
- Touch operator[](int index) => JS("Touch", "#[#]", this, index);
-
+ Touch operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("Touch", "#[#]", this, index);
+ }
void operator[]=(int index, Touch value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -19123,6 +19455,34 @@ class TouchList extends Object with ListMixin<Touch>, ImmutableListMixin<Touch>
throw new UnsupportedError("Cannot resize immutable List.");
}
+ Touch get first {
+ if (this.length > 0) {
+ return JS('Touch', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ Touch get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('Touch', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ Touch get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('Touch', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Touch elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<Touch> mixins.
@DomName('TouchList.item')
@@ -21398,8 +21758,10 @@ class _ClientRectList extends Object with ListMixin<Rect>, ImmutableListMixin<Re
@DocsEditable
int get length => JS("int", "#.length", this);
- Rect operator[](int index) => JS("Rect", "#[#]", this, index);
-
+ Rect operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("Rect", "#[#]", this, index);
+ }
void operator[]=(int index, Rect value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -21411,6 +21773,34 @@ class _ClientRectList extends Object with ListMixin<Rect>, ImmutableListMixin<Re
throw new UnsupportedError("Cannot resize immutable List.");
}
+ Rect get first {
+ if (this.length > 0) {
+ return JS('Rect', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ Rect get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('Rect', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ Rect get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('Rect', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Rect elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<Rect> mixins.
@DomName('ClientRectList.item')
@@ -21439,8 +21829,10 @@ class _CssRuleList extends Object with ListMixin<CssRule>, ImmutableListMixin<Cs
@DocsEditable
int get length => JS("int", "#.length", this);
- CssRule operator[](int index) => JS("CssRule", "#[#]", this, index);
-
+ CssRule operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("CssRule", "#[#]", this, index);
+ }
void operator[]=(int index, CssRule value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -21452,6 +21844,34 @@ class _CssRuleList extends Object with ListMixin<CssRule>, ImmutableListMixin<Cs
throw new UnsupportedError("Cannot resize immutable List.");
}
+ CssRule get first {
+ if (this.length > 0) {
+ return JS('CssRule', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ CssRule get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('CssRule', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ CssRule get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('CssRule', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ CssRule elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<CssRule> mixins.
@DomName('CSSRuleList.item')
@@ -21471,8 +21891,10 @@ class _CssValueList extends _CSSValue with ListMixin<_CSSValue>, ImmutableListMi
@DocsEditable
int get length => JS("int", "#.length", this);
- _CSSValue operator[](int index) => JS("_CSSValue", "#[#]", this, index);
-
+ _CSSValue operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("_CSSValue", "#[#]", this, index);
+ }
void operator[]=(int index, _CSSValue value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -21484,6 +21906,34 @@ class _CssValueList extends _CSSValue with ListMixin<_CSSValue>, ImmutableListMi
throw new UnsupportedError("Cannot resize immutable List.");
}
+ _CSSValue get first {
+ if (this.length > 0) {
+ return JS('_CSSValue', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ _CSSValue get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('_CSSValue', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ _CSSValue get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('_CSSValue', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ _CSSValue elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<_CSSValue> mixins.
@DomName('CSSValueList.item')
@@ -21595,8 +22045,10 @@ class _EntryArray extends Object with ListMixin<Entry>, ImmutableListMixin<Entry
@DocsEditable
int get length => JS("int", "#.length", this);
- Entry operator[](int index) => JS("Entry", "#[#]", this, index);
-
+ Entry operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("Entry", "#[#]", this, index);
+ }
void operator[]=(int index, Entry value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -21608,6 +22060,34 @@ class _EntryArray extends Object with ListMixin<Entry>, ImmutableListMixin<Entry
throw new UnsupportedError("Cannot resize immutable List.");
}
+ Entry get first {
+ if (this.length > 0) {
+ return JS('Entry', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ Entry get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('Entry', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ Entry get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('Entry', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Entry elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<Entry> mixins.
@DomName('EntryArray.item')
@@ -21627,8 +22107,10 @@ class _EntryArraySync extends Object with ListMixin<_EntrySync>, ImmutableListMi
@DocsEditable
int get length => JS("int", "#.length", this);
- _EntrySync operator[](int index) => JS("_EntrySync", "#[#]", this, index);
-
+ _EntrySync operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("_EntrySync", "#[#]", this, index);
+ }
void operator[]=(int index, _EntrySync value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -21640,6 +22122,34 @@ class _EntryArraySync extends Object with ListMixin<_EntrySync>, ImmutableListMi
throw new UnsupportedError("Cannot resize immutable List.");
}
+ _EntrySync get first {
+ if (this.length > 0) {
+ return JS('_EntrySync', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ _EntrySync get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('_EntrySync', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ _EntrySync get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('_EntrySync', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ _EntrySync elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<_EntrySync> mixins.
@DomName('EntryArraySync.item')
@@ -21702,8 +22212,10 @@ class _GamepadList extends Object with ListMixin<Gamepad>, ImmutableListMixin<Ga
@DocsEditable
int get length => JS("int", "#.length", this);
- Gamepad operator[](int index) => JS("Gamepad", "#[#]", this, index);
-
+ Gamepad operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("Gamepad", "#[#]", this, index);
+ }
void operator[]=(int index, Gamepad value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -21715,6 +22227,34 @@ class _GamepadList extends Object with ListMixin<Gamepad>, ImmutableListMixin<Ga
throw new UnsupportedError("Cannot resize immutable List.");
}
+ Gamepad get first {
+ if (this.length > 0) {
+ return JS('Gamepad', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ Gamepad get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('Gamepad', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ Gamepad get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('Gamepad', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Gamepad elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<Gamepad> mixins.
@DomName('GamepadList.item')
@@ -21797,8 +22337,10 @@ class _NamedNodeMap extends Object with ListMixin<Node>, ImmutableListMixin<Node
@DocsEditable
int get length => JS("int", "#.length", this);
- Node operator[](int index) => JS("Node", "#[#]", this, index);
-
+ Node operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("Node", "#[#]", this, index);
+ }
void operator[]=(int index, Node value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -21810,6 +22352,34 @@ class _NamedNodeMap extends Object with ListMixin<Node>, ImmutableListMixin<Node
throw new UnsupportedError("Cannot resize immutable List.");
}
+ Node get first {
+ if (this.length > 0) {
+ return JS('Node', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ Node get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('Node', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ Node get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('Node', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ Node elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<Node> mixins.
@DomName('NamedNodeMap.getNamedItem')
@@ -21918,8 +22488,10 @@ class _SpeechInputResultList extends Object with ListMixin<SpeechInputResult>, I
@DocsEditable
int get length => JS("int", "#.length", this);
- SpeechInputResult operator[](int index) => JS("SpeechInputResult", "#[#]", this, index);
-
+ SpeechInputResult operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("SpeechInputResult", "#[#]", this, index);
+ }
void operator[]=(int index, SpeechInputResult value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -21931,6 +22503,34 @@ class _SpeechInputResultList extends Object with ListMixin<SpeechInputResult>, I
throw new UnsupportedError("Cannot resize immutable List.");
}
+ SpeechInputResult get first {
+ if (this.length > 0) {
+ return JS('SpeechInputResult', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ SpeechInputResult get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('SpeechInputResult', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ SpeechInputResult get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('SpeechInputResult', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ SpeechInputResult elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<SpeechInputResult> mixins.
@DomName('SpeechInputResultList.item')
@@ -21950,8 +22550,10 @@ class _SpeechRecognitionResultList extends Object with ListMixin<SpeechRecogniti
@DocsEditable
int get length => JS("int", "#.length", this);
- SpeechRecognitionResult operator[](int index) => JS("SpeechRecognitionResult", "#[#]", this, index);
-
+ SpeechRecognitionResult operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("SpeechRecognitionResult", "#[#]", this, index);
+ }
void operator[]=(int index, SpeechRecognitionResult value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -21963,6 +22565,34 @@ class _SpeechRecognitionResultList extends Object with ListMixin<SpeechRecogniti
throw new UnsupportedError("Cannot resize immutable List.");
}
+ SpeechRecognitionResult get first {
+ if (this.length > 0) {
+ return JS('SpeechRecognitionResult', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ SpeechRecognitionResult get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('SpeechRecognitionResult', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ SpeechRecognitionResult get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('SpeechRecognitionResult', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ SpeechRecognitionResult elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<SpeechRecognitionResult> mixins.
@DomName('SpeechRecognitionResultList.item')
@@ -21982,8 +22612,10 @@ class _StyleSheetList extends Object with ListMixin<StyleSheet>, ImmutableListMi
@DocsEditable
int get length => JS("int", "#.length", this);
- StyleSheet operator[](int index) => JS("StyleSheet", "#[#]", this, index);
-
+ StyleSheet operator[](int index) {
+ if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
+ return JS("StyleSheet", "#[#]", this, index);
+ }
void operator[]=(int index, StyleSheet value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
@@ -21995,6 +22627,34 @@ class _StyleSheetList extends Object with ListMixin<StyleSheet>, ImmutableListMi
throw new UnsupportedError("Cannot resize immutable List.");
}
+ StyleSheet get first {
+ if (this.length > 0) {
+ return JS('StyleSheet', '#[0]', this);
+ }
+ throw new StateError("No elements");
+ }
+
+ StyleSheet get last {
+ int len = this.length;
+ if (len > 0) {
+ return JS('StyleSheet', '#[#]', this, len - 1);
+ }
+ throw new StateError("No elements");
+ }
+
+ StyleSheet get single {
+ int len = this.length;
+ if (len == 1) {
+ return JS('StyleSheet', '#[0]', this);
+ }
+ if (len == 0) throw new StateError("No elements");
+ throw new StateError("More than one element");
+ }
+
+ StyleSheet elementAt(int index) {
+ return this[index];
+ }
+
// -- end List<StyleSheet> mixins.
@DomName('StyleSheetList.item')
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | sdk/lib/html/dartium/html_dartium.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698