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

Side by Side Diff: sdk/lib/svg/dart2js/svg_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
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | sdk/lib/svg/dartium/svg_dartium.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library dart.dom.svg; 1 library dart.dom.svg;
2 2
3 import 'dart:async'; 3 import 'dart:async';
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'dart:_collection-dev'; 5 import 'dart:_collection-dev';
6 import 'dart:html'; 6 import 'dart:html';
7 import 'dart:html_common'; 7 import 'dart:html_common';
8 import 'dart:_js_helper' show Creates, Returns, JavaScriptIndexingBehavior, JSNa me; 8 import 'dart:_js_helper' show Creates, Returns, JavaScriptIndexingBehavior, JSNa me;
9 import 'dart:_foreign_helper' show JS; 9 import 'dart:_foreign_helper' show JS;
10 // DO NOT EDIT - unless you are editing documentation as per: 10 // DO NOT EDIT - unless you are editing documentation as per:
(...skipping 2994 matching lines...) Expand 10 before | Expand all | Expand 10 after
3005 3005
3006 3006
3007 @DocsEditable 3007 @DocsEditable
3008 @DomName('SVGLengthList') 3008 @DomName('SVGLengthList')
3009 class LengthList extends Object with ListMixin<Length>, ImmutableListMixin<Lengt h> implements JavaScriptIndexingBehavior, List<Length> native "SVGLengthList" { 3009 class LengthList extends Object with ListMixin<Length>, ImmutableListMixin<Lengt h> implements JavaScriptIndexingBehavior, List<Length> native "SVGLengthList" {
3010 3010
3011 @DomName('SVGLengthList.numberOfItems') 3011 @DomName('SVGLengthList.numberOfItems')
3012 @DocsEditable 3012 @DocsEditable
3013 final int numberOfItems; 3013 final int numberOfItems;
3014 3014
3015 Length operator[](int index) => this.getItem(index); 3015 Length operator[](int index) {
3016 3016 if (JS("bool", "# >>> 0 !== # || # >= #", index,
3017 index, index, length))
3018 throw new RangeError.range(index, 0, length);
3019 return this.getItem(index);
3020 }
3017 void operator[]=(int index, Length value) { 3021 void operator[]=(int index, Length value) {
3018 throw new UnsupportedError("Cannot assign element of immutable List."); 3022 throw new UnsupportedError("Cannot assign element of immutable List.");
3019 } 3023 }
3020 // -- start List<Length> mixins. 3024 // -- start List<Length> mixins.
3021 // Length is the element type. 3025 // Length is the element type.
3022 3026
3023 // SVG Collections expose numberOfItems rather than length. 3027 // SVG Collections expose numberOfItems rather than length.
3024 int get length => numberOfItems; 3028 int get length => numberOfItems;
3025 3029
3026 void set length(int value) { 3030 void set length(int value) {
3027 throw new UnsupportedError("Cannot resize immutable List."); 3031 throw new UnsupportedError("Cannot resize immutable List.");
3028 } 3032 }
3029 3033
3034 Length get first {
3035 if (this.length > 0) {
3036 return JS('Length', '#[0]', this);
3037 }
3038 throw new StateError("No elements");
3039 }
3040
3041 Length get last {
3042 int len = this.length;
3043 if (len > 0) {
3044 return JS('Length', '#[#]', this, len - 1);
3045 }
3046 throw new StateError("No elements");
3047 }
3048
3049 Length get single {
3050 int len = this.length;
3051 if (len == 1) {
3052 return JS('Length', '#[0]', this);
3053 }
3054 if (len == 0) throw new StateError("No elements");
3055 throw new StateError("More than one element");
3056 }
3057
3058 Length elementAt(int index) => this[index];
3030 // -- end List<Length> mixins. 3059 // -- end List<Length> mixins.
3031 3060
3032 @DomName('SVGLengthList.appendItem') 3061 @DomName('SVGLengthList.appendItem')
3033 @DocsEditable 3062 @DocsEditable
3034 Length appendItem(Length item) native; 3063 Length appendItem(Length item) native;
3035 3064
3036 @DomName('SVGLengthList.clear') 3065 @DomName('SVGLengthList.clear')
3037 @DocsEditable 3066 @DocsEditable
3038 void clear() native; 3067 void clear() native;
3039 3068
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
3466 3495
3467 3496
3468 @DocsEditable 3497 @DocsEditable
3469 @DomName('SVGNumberList') 3498 @DomName('SVGNumberList')
3470 class NumberList extends Object with ListMixin<Number>, ImmutableListMixin<Numbe r> implements JavaScriptIndexingBehavior, List<Number> native "SVGNumberList" { 3499 class NumberList extends Object with ListMixin<Number>, ImmutableListMixin<Numbe r> implements JavaScriptIndexingBehavior, List<Number> native "SVGNumberList" {
3471 3500
3472 @DomName('SVGNumberList.numberOfItems') 3501 @DomName('SVGNumberList.numberOfItems')
3473 @DocsEditable 3502 @DocsEditable
3474 final int numberOfItems; 3503 final int numberOfItems;
3475 3504
3476 Number operator[](int index) => this.getItem(index); 3505 Number operator[](int index) {
3477 3506 if (JS("bool", "# >>> 0 !== # || # >= #", index,
3507 index, index, length))
3508 throw new RangeError.range(index, 0, length);
3509 return this.getItem(index);
3510 }
3478 void operator[]=(int index, Number value) { 3511 void operator[]=(int index, Number value) {
3479 throw new UnsupportedError("Cannot assign element of immutable List."); 3512 throw new UnsupportedError("Cannot assign element of immutable List.");
3480 } 3513 }
3481 // -- start List<Number> mixins. 3514 // -- start List<Number> mixins.
3482 // Number is the element type. 3515 // Number is the element type.
3483 3516
3484 // SVG Collections expose numberOfItems rather than length. 3517 // SVG Collections expose numberOfItems rather than length.
3485 int get length => numberOfItems; 3518 int get length => numberOfItems;
3486 3519
3487 void set length(int value) { 3520 void set length(int value) {
3488 throw new UnsupportedError("Cannot resize immutable List."); 3521 throw new UnsupportedError("Cannot resize immutable List.");
3489 } 3522 }
3490 3523
3524 Number get first {
3525 if (this.length > 0) {
3526 return JS('Number', '#[0]', this);
3527 }
3528 throw new StateError("No elements");
3529 }
3530
3531 Number get last {
3532 int len = this.length;
3533 if (len > 0) {
3534 return JS('Number', '#[#]', this, len - 1);
3535 }
3536 throw new StateError("No elements");
3537 }
3538
3539 Number get single {
3540 int len = this.length;
3541 if (len == 1) {
3542 return JS('Number', '#[0]', this);
3543 }
3544 if (len == 0) throw new StateError("No elements");
3545 throw new StateError("More than one element");
3546 }
3547
3548 Number elementAt(int index) => this[index];
3491 // -- end List<Number> mixins. 3549 // -- end List<Number> mixins.
3492 3550
3493 @DomName('SVGNumberList.appendItem') 3551 @DomName('SVGNumberList.appendItem')
3494 @DocsEditable 3552 @DocsEditable
3495 Number appendItem(Number item) native; 3553 Number appendItem(Number item) native;
3496 3554
3497 @DomName('SVGNumberList.clear') 3555 @DomName('SVGNumberList.clear')
3498 @DocsEditable 3556 @DocsEditable
3499 void clear() native; 3557 void clear() native;
3500 3558
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
4158 4216
4159 4217
4160 @DocsEditable 4218 @DocsEditable
4161 @DomName('SVGPathSegList') 4219 @DomName('SVGPathSegList')
4162 class PathSegList extends Object with ListMixin<PathSeg>, ImmutableListMixin<Pat hSeg> implements JavaScriptIndexingBehavior, List<PathSeg> native "SVGPathSegLis t" { 4220 class PathSegList extends Object with ListMixin<PathSeg>, ImmutableListMixin<Pat hSeg> implements JavaScriptIndexingBehavior, List<PathSeg> native "SVGPathSegLis t" {
4163 4221
4164 @DomName('SVGPathSegList.numberOfItems') 4222 @DomName('SVGPathSegList.numberOfItems')
4165 @DocsEditable 4223 @DocsEditable
4166 final int numberOfItems; 4224 final int numberOfItems;
4167 4225
4168 PathSeg operator[](int index) => this.getItem(index); 4226 PathSeg operator[](int index) {
4169 4227 if (JS("bool", "# >>> 0 !== # || # >= #", index,
4228 index, index, length))
4229 throw new RangeError.range(index, 0, length);
4230 return this.getItem(index);
4231 }
4170 void operator[]=(int index, PathSeg value) { 4232 void operator[]=(int index, PathSeg value) {
4171 throw new UnsupportedError("Cannot assign element of immutable List."); 4233 throw new UnsupportedError("Cannot assign element of immutable List.");
4172 } 4234 }
4173 // -- start List<PathSeg> mixins. 4235 // -- start List<PathSeg> mixins.
4174 // PathSeg is the element type. 4236 // PathSeg is the element type.
4175 4237
4176 // SVG Collections expose numberOfItems rather than length. 4238 // SVG Collections expose numberOfItems rather than length.
4177 int get length => numberOfItems; 4239 int get length => numberOfItems;
4178 4240
4179 void set length(int value) { 4241 void set length(int value) {
4180 throw new UnsupportedError("Cannot resize immutable List."); 4242 throw new UnsupportedError("Cannot resize immutable List.");
4181 } 4243 }
4182 4244
4245 PathSeg get first {
4246 if (this.length > 0) {
4247 return JS('PathSeg', '#[0]', this);
4248 }
4249 throw new StateError("No elements");
4250 }
4251
4252 PathSeg get last {
4253 int len = this.length;
4254 if (len > 0) {
4255 return JS('PathSeg', '#[#]', this, len - 1);
4256 }
4257 throw new StateError("No elements");
4258 }
4259
4260 PathSeg get single {
4261 int len = this.length;
4262 if (len == 1) {
4263 return JS('PathSeg', '#[0]', this);
4264 }
4265 if (len == 0) throw new StateError("No elements");
4266 throw new StateError("More than one element");
4267 }
4268
4269 PathSeg elementAt(int index) => this[index];
4183 // -- end List<PathSeg> mixins. 4270 // -- end List<PathSeg> mixins.
4184 4271
4185 @DomName('SVGPathSegList.appendItem') 4272 @DomName('SVGPathSegList.appendItem')
4186 @DocsEditable 4273 @DocsEditable
4187 PathSeg appendItem(PathSeg newItem) native; 4274 PathSeg appendItem(PathSeg newItem) native;
4188 4275
4189 @DomName('SVGPathSegList.clear') 4276 @DomName('SVGPathSegList.clear')
4190 @DocsEditable 4277 @DocsEditable
4191 void clear() native; 4278 void clear() native;
4192 4279
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
4880 4967
4881 4968
4882 @DocsEditable 4969 @DocsEditable
4883 @DomName('SVGStringList') 4970 @DomName('SVGStringList')
4884 class StringList extends Object with ListMixin<String>, ImmutableListMixin<Strin g> implements JavaScriptIndexingBehavior, List<String> native "SVGStringList" { 4971 class StringList extends Object with ListMixin<String>, ImmutableListMixin<Strin g> implements JavaScriptIndexingBehavior, List<String> native "SVGStringList" {
4885 4972
4886 @DomName('SVGStringList.numberOfItems') 4973 @DomName('SVGStringList.numberOfItems')
4887 @DocsEditable 4974 @DocsEditable
4888 final int numberOfItems; 4975 final int numberOfItems;
4889 4976
4890 String operator[](int index) => this.getItem(index); 4977 String operator[](int index) {
4891 4978 if (JS("bool", "# >>> 0 !== # || # >= #", index,
4979 index, index, length))
4980 throw new RangeError.range(index, 0, length);
4981 return this.getItem(index);
4982 }
4892 void operator[]=(int index, String value) { 4983 void operator[]=(int index, String value) {
4893 throw new UnsupportedError("Cannot assign element of immutable List."); 4984 throw new UnsupportedError("Cannot assign element of immutable List.");
4894 } 4985 }
4895 // -- start List<String> mixins. 4986 // -- start List<String> mixins.
4896 // String is the element type. 4987 // String is the element type.
4897 4988
4898 // SVG Collections expose numberOfItems rather than length. 4989 // SVG Collections expose numberOfItems rather than length.
4899 int get length => numberOfItems; 4990 int get length => numberOfItems;
4900 4991
4901 void set length(int value) { 4992 void set length(int value) {
4902 throw new UnsupportedError("Cannot resize immutable List."); 4993 throw new UnsupportedError("Cannot resize immutable List.");
4903 } 4994 }
4904 4995
4996 String get first {
4997 if (this.length > 0) {
4998 return JS('String', '#[0]', this);
4999 }
5000 throw new StateError("No elements");
5001 }
5002
5003 String get last {
5004 int len = this.length;
5005 if (len > 0) {
5006 return JS('String', '#[#]', this, len - 1);
5007 }
5008 throw new StateError("No elements");
5009 }
5010
5011 String get single {
5012 int len = this.length;
5013 if (len == 1) {
5014 return JS('String', '#[0]', this);
5015 }
5016 if (len == 0) throw new StateError("No elements");
5017 throw new StateError("More than one element");
5018 }
5019
5020 String elementAt(int index) => this[index];
4905 // -- end List<String> mixins. 5021 // -- end List<String> mixins.
4906 5022
4907 @DomName('SVGStringList.appendItem') 5023 @DomName('SVGStringList.appendItem')
4908 @DocsEditable 5024 @DocsEditable
4909 String appendItem(String item) native; 5025 String appendItem(String item) native;
4910 5026
4911 @DomName('SVGStringList.clear') 5027 @DomName('SVGStringList.clear')
4912 @DocsEditable 5028 @DocsEditable
4913 void clear() native; 5029 void clear() native;
4914 5030
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
5875 5991
5876 5992
5877 @DocsEditable 5993 @DocsEditable
5878 @DomName('SVGTransformList') 5994 @DomName('SVGTransformList')
5879 class TransformList extends Object with ListMixin<Transform>, ImmutableListMixin <Transform> implements List<Transform>, JavaScriptIndexingBehavior native "SVGTr ansformList" { 5995 class TransformList extends Object with ListMixin<Transform>, ImmutableListMixin <Transform> implements List<Transform>, JavaScriptIndexingBehavior native "SVGTr ansformList" {
5880 5996
5881 @DomName('SVGTransformList.numberOfItems') 5997 @DomName('SVGTransformList.numberOfItems')
5882 @DocsEditable 5998 @DocsEditable
5883 final int numberOfItems; 5999 final int numberOfItems;
5884 6000
5885 Transform operator[](int index) => this.getItem(index); 6001 Transform operator[](int index) {
5886 6002 if (JS("bool", "# >>> 0 !== # || # >= #", index,
6003 index, index, length))
6004 throw new RangeError.range(index, 0, length);
6005 return this.getItem(index);
6006 }
5887 void operator[]=(int index, Transform value) { 6007 void operator[]=(int index, Transform value) {
5888 throw new UnsupportedError("Cannot assign element of immutable List."); 6008 throw new UnsupportedError("Cannot assign element of immutable List.");
5889 } 6009 }
5890 // -- start List<Transform> mixins. 6010 // -- start List<Transform> mixins.
5891 // Transform is the element type. 6011 // Transform is the element type.
5892 6012
5893 // SVG Collections expose numberOfItems rather than length. 6013 // SVG Collections expose numberOfItems rather than length.
5894 int get length => numberOfItems; 6014 int get length => numberOfItems;
5895 6015
5896 void set length(int value) { 6016 void set length(int value) {
5897 throw new UnsupportedError("Cannot resize immutable List."); 6017 throw new UnsupportedError("Cannot resize immutable List.");
5898 } 6018 }
5899 6019
6020 Transform get first {
6021 if (this.length > 0) {
6022 return JS('Transform', '#[0]', this);
6023 }
6024 throw new StateError("No elements");
6025 }
6026
6027 Transform get last {
6028 int len = this.length;
6029 if (len > 0) {
6030 return JS('Transform', '#[#]', this, len - 1);
6031 }
6032 throw new StateError("No elements");
6033 }
6034
6035 Transform get single {
6036 int len = this.length;
6037 if (len == 1) {
6038 return JS('Transform', '#[0]', this);
6039 }
6040 if (len == 0) throw new StateError("No elements");
6041 throw new StateError("More than one element");
6042 }
6043
6044 Transform elementAt(int index) => this[index];
5900 // -- end List<Transform> mixins. 6045 // -- end List<Transform> mixins.
5901 6046
5902 @DomName('SVGTransformList.appendItem') 6047 @DomName('SVGTransformList.appendItem')
5903 @DocsEditable 6048 @DocsEditable
5904 Transform appendItem(Transform item) native; 6049 Transform appendItem(Transform item) native;
5905 6050
5906 @DomName('SVGTransformList.clear') 6051 @DomName('SVGTransformList.clear')
5907 @DocsEditable 6052 @DocsEditable
5908 void clear() native; 6053 void clear() native;
5909 6054
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
6231 6376
6232 6377
6233 @DocsEditable 6378 @DocsEditable
6234 @DomName('SVGElementInstanceList') 6379 @DomName('SVGElementInstanceList')
6235 class _ElementInstanceList extends Object with ListMixin<ElementInstance>, Immut ableListMixin<ElementInstance> implements JavaScriptIndexingBehavior, List<Eleme ntInstance> native "SVGElementInstanceList" { 6380 class _ElementInstanceList extends Object with ListMixin<ElementInstance>, Immut ableListMixin<ElementInstance> implements JavaScriptIndexingBehavior, List<Eleme ntInstance> native "SVGElementInstanceList" {
6236 6381
6237 @DomName('SVGElementInstanceList.length') 6382 @DomName('SVGElementInstanceList.length')
6238 @DocsEditable 6383 @DocsEditable
6239 int get length => JS("int", "#.length", this); 6384 int get length => JS("int", "#.length", this);
6240 6385
6241 ElementInstance operator[](int index) => this.item(index); 6386 ElementInstance operator[](int index) {
6242 6387 if (JS("bool", "# >>> 0 !== # || # >= #", index,
6388 index, index, length))
6389 throw new RangeError.range(index, 0, length);
6390 return this.item(index);
6391 }
6243 void operator[]=(int index, ElementInstance value) { 6392 void operator[]=(int index, ElementInstance value) {
6244 throw new UnsupportedError("Cannot assign element of immutable List."); 6393 throw new UnsupportedError("Cannot assign element of immutable List.");
6245 } 6394 }
6246 // -- start List<ElementInstance> mixins. 6395 // -- start List<ElementInstance> mixins.
6247 // ElementInstance is the element type. 6396 // ElementInstance is the element type.
6248 6397
6249 6398
6250 void set length(int value) { 6399 void set length(int value) {
6251 throw new UnsupportedError("Cannot resize immutable List."); 6400 throw new UnsupportedError("Cannot resize immutable List.");
6252 } 6401 }
6253 6402
6403 ElementInstance get first {
6404 if (this.length > 0) {
6405 return JS('ElementInstance', '#[0]', this);
6406 }
6407 throw new StateError("No elements");
6408 }
6409
6410 ElementInstance get last {
6411 int len = this.length;
6412 if (len > 0) {
6413 return JS('ElementInstance', '#[#]', this, len - 1);
6414 }
6415 throw new StateError("No elements");
6416 }
6417
6418 ElementInstance get single {
6419 int len = this.length;
6420 if (len == 1) {
6421 return JS('ElementInstance', '#[0]', this);
6422 }
6423 if (len == 0) throw new StateError("No elements");
6424 throw new StateError("More than one element");
6425 }
6426
6427 ElementInstance elementAt(int index) => this[index];
6254 // -- end List<ElementInstance> mixins. 6428 // -- end List<ElementInstance> mixins.
6255 6429
6256 @DomName('SVGElementInstanceList.item') 6430 @DomName('SVGElementInstanceList.item')
6257 @DocsEditable 6431 @DocsEditable
6258 ElementInstance item(int index) native; 6432 ElementInstance item(int index) native;
6259 } 6433 }
6260 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 6434 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
6261 // for details. All rights reserved. Use of this source code is governed by a 6435 // for details. All rights reserved. Use of this source code is governed by a
6262 // BSD-style license that can be found in the LICENSE file. 6436 // BSD-style license that can be found in the LICENSE file.
6263 6437
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
6526 6700
6527 6701
6528 @DocsEditable 6702 @DocsEditable
6529 @DomName('SVGVKernElement') 6703 @DomName('SVGVKernElement')
6530 abstract class _SVGVKernElement extends SvgElement native "SVGVKernElement" { 6704 abstract class _SVGVKernElement extends SvgElement native "SVGVKernElement" {
6531 6705
6532 @DomName('SVGVKernElement.SVGVKernElement') 6706 @DomName('SVGVKernElement.SVGVKernElement')
6533 @DocsEditable 6707 @DocsEditable
6534 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag( "vkern"); 6708 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag( "vkern");
6535 } 6709 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | sdk/lib/svg/dartium/svg_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698