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

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
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, index, index, length)) thro w new RangeError.range(index, 0, length);
3017 return this.getItem(index);
3018 }
3017 void operator[]=(int index, Length value) { 3019 void operator[]=(int index, Length value) {
3018 throw new UnsupportedError("Cannot assign element of immutable List."); 3020 throw new UnsupportedError("Cannot assign element of immutable List.");
3019 } 3021 }
3020 // -- start List<Length> mixins. 3022 // -- start List<Length> mixins.
3021 // Length is the element type. 3023 // Length is the element type.
3022 3024
3023 // SVG Collections expose numberOfItems rather than length. 3025 // SVG Collections expose numberOfItems rather than length.
3024 int get length => numberOfItems; 3026 int get length => numberOfItems;
3025 3027
3026 void set length(int value) { 3028 void set length(int value) {
3027 throw new UnsupportedError("Cannot resize immutable List."); 3029 throw new UnsupportedError("Cannot resize immutable List.");
3028 } 3030 }
3029 3031
3032 Length get first {
3033 if (this.length > 0) {
3034 return JS('Length', '#[0]', this);
3035 }
3036 throw new StateError("No elements");
3037 }
3038
3039 Length get last {
3040 int len = this.length;
3041 if (len > 0) {
3042 return JS('Length', '#[#]', this, len - 1);
3043 }
3044 throw new StateError("No elements");
3045 }
3046
3047 Length get single {
3048 int len = this.length;
3049 if (len == 1) {
3050 return JS('Length', '#[0]', this);
3051 }
3052 if (len == 0) throw new StateError("No elements");
3053 throw new StateError("More than one element");
3054 }
3055
3056 Length elementAt(int index) {
3057 return this[index];
3058 }
3059
3030 // -- end List<Length> mixins. 3060 // -- end List<Length> mixins.
3031 3061
3032 @DomName('SVGLengthList.appendItem') 3062 @DomName('SVGLengthList.appendItem')
3033 @DocsEditable 3063 @DocsEditable
3034 Length appendItem(Length item) native; 3064 Length appendItem(Length item) native;
3035 3065
3036 @DomName('SVGLengthList.clear') 3066 @DomName('SVGLengthList.clear')
3037 @DocsEditable 3067 @DocsEditable
3038 void clear() native; 3068 void clear() native;
3039 3069
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
3466 3496
3467 3497
3468 @DocsEditable 3498 @DocsEditable
3469 @DomName('SVGNumberList') 3499 @DomName('SVGNumberList')
3470 class NumberList extends Object with ListMixin<Number>, ImmutableListMixin<Numbe r> implements JavaScriptIndexingBehavior, List<Number> native "SVGNumberList" { 3500 class NumberList extends Object with ListMixin<Number>, ImmutableListMixin<Numbe r> implements JavaScriptIndexingBehavior, List<Number> native "SVGNumberList" {
3471 3501
3472 @DomName('SVGNumberList.numberOfItems') 3502 @DomName('SVGNumberList.numberOfItems')
3473 @DocsEditable 3503 @DocsEditable
3474 final int numberOfItems; 3504 final int numberOfItems;
3475 3505
3476 Number operator[](int index) => this.getItem(index); 3506 Number operator[](int index) {
3477 3507 if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) thro w new RangeError.range(index, 0, length);
3508 return this.getItem(index);
3509 }
3478 void operator[]=(int index, Number value) { 3510 void operator[]=(int index, Number value) {
3479 throw new UnsupportedError("Cannot assign element of immutable List."); 3511 throw new UnsupportedError("Cannot assign element of immutable List.");
3480 } 3512 }
3481 // -- start List<Number> mixins. 3513 // -- start List<Number> mixins.
3482 // Number is the element type. 3514 // Number is the element type.
3483 3515
3484 // SVG Collections expose numberOfItems rather than length. 3516 // SVG Collections expose numberOfItems rather than length.
3485 int get length => numberOfItems; 3517 int get length => numberOfItems;
3486 3518
3487 void set length(int value) { 3519 void set length(int value) {
3488 throw new UnsupportedError("Cannot resize immutable List."); 3520 throw new UnsupportedError("Cannot resize immutable List.");
3489 } 3521 }
3490 3522
3523 Number get first {
3524 if (this.length > 0) {
3525 return JS('Number', '#[0]', this);
3526 }
3527 throw new StateError("No elements");
3528 }
3529
3530 Number get last {
3531 int len = this.length;
3532 if (len > 0) {
3533 return JS('Number', '#[#]', this, len - 1);
3534 }
3535 throw new StateError("No elements");
3536 }
3537
3538 Number get single {
3539 int len = this.length;
3540 if (len == 1) {
3541 return JS('Number', '#[0]', this);
3542 }
3543 if (len == 0) throw new StateError("No elements");
3544 throw new StateError("More than one element");
3545 }
3546
3547 Number elementAt(int index) {
3548 return this[index];
3549 }
3550
3491 // -- end List<Number> mixins. 3551 // -- end List<Number> mixins.
3492 3552
3493 @DomName('SVGNumberList.appendItem') 3553 @DomName('SVGNumberList.appendItem')
3494 @DocsEditable 3554 @DocsEditable
3495 Number appendItem(Number item) native; 3555 Number appendItem(Number item) native;
3496 3556
3497 @DomName('SVGNumberList.clear') 3557 @DomName('SVGNumberList.clear')
3498 @DocsEditable 3558 @DocsEditable
3499 void clear() native; 3559 void clear() native;
3500 3560
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
4158 4218
4159 4219
4160 @DocsEditable 4220 @DocsEditable
4161 @DomName('SVGPathSegList') 4221 @DomName('SVGPathSegList')
4162 class PathSegList extends Object with ListMixin<PathSeg>, ImmutableListMixin<Pat hSeg> implements JavaScriptIndexingBehavior, List<PathSeg> native "SVGPathSegLis t" { 4222 class PathSegList extends Object with ListMixin<PathSeg>, ImmutableListMixin<Pat hSeg> implements JavaScriptIndexingBehavior, List<PathSeg> native "SVGPathSegLis t" {
4163 4223
4164 @DomName('SVGPathSegList.numberOfItems') 4224 @DomName('SVGPathSegList.numberOfItems')
4165 @DocsEditable 4225 @DocsEditable
4166 final int numberOfItems; 4226 final int numberOfItems;
4167 4227
4168 PathSeg operator[](int index) => this.getItem(index); 4228 PathSeg operator[](int index) {
4169 4229 if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) thro w 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) {
4270 return this[index];
4271 }
4272
4183 // -- end List<PathSeg> mixins. 4273 // -- end List<PathSeg> mixins.
4184 4274
4185 @DomName('SVGPathSegList.appendItem') 4275 @DomName('SVGPathSegList.appendItem')
4186 @DocsEditable 4276 @DocsEditable
4187 PathSeg appendItem(PathSeg newItem) native; 4277 PathSeg appendItem(PathSeg newItem) native;
4188 4278
4189 @DomName('SVGPathSegList.clear') 4279 @DomName('SVGPathSegList.clear')
4190 @DocsEditable 4280 @DocsEditable
4191 void clear() native; 4281 void clear() native;
4192 4282
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
4880 4970
4881 4971
4882 @DocsEditable 4972 @DocsEditable
4883 @DomName('SVGStringList') 4973 @DomName('SVGStringList')
4884 class StringList extends Object with ListMixin<String>, ImmutableListMixin<Strin g> implements JavaScriptIndexingBehavior, List<String> native "SVGStringList" { 4974 class StringList extends Object with ListMixin<String>, ImmutableListMixin<Strin g> implements JavaScriptIndexingBehavior, List<String> native "SVGStringList" {
4885 4975
4886 @DomName('SVGStringList.numberOfItems') 4976 @DomName('SVGStringList.numberOfItems')
4887 @DocsEditable 4977 @DocsEditable
4888 final int numberOfItems; 4978 final int numberOfItems;
4889 4979
4890 String operator[](int index) => this.getItem(index); 4980 String operator[](int index) {
4891 4981 if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) thro w new RangeError.range(index, 0, length);
4982 return this.getItem(index);
4983 }
4892 void operator[]=(int index, String value) { 4984 void operator[]=(int index, String value) {
4893 throw new UnsupportedError("Cannot assign element of immutable List."); 4985 throw new UnsupportedError("Cannot assign element of immutable List.");
4894 } 4986 }
4895 // -- start List<String> mixins. 4987 // -- start List<String> mixins.
4896 // String is the element type. 4988 // String is the element type.
4897 4989
4898 // SVG Collections expose numberOfItems rather than length. 4990 // SVG Collections expose numberOfItems rather than length.
4899 int get length => numberOfItems; 4991 int get length => numberOfItems;
4900 4992
4901 void set length(int value) { 4993 void set length(int value) {
4902 throw new UnsupportedError("Cannot resize immutable List."); 4994 throw new UnsupportedError("Cannot resize immutable List.");
4903 } 4995 }
4904 4996
4997 String get first {
4998 if (this.length > 0) {
4999 return JS('String', '#[0]', this);
5000 }
5001 throw new StateError("No elements");
5002 }
5003
5004 String get last {
5005 int len = this.length;
5006 if (len > 0) {
5007 return JS('String', '#[#]', this, len - 1);
5008 }
5009 throw new StateError("No elements");
5010 }
5011
5012 String get single {
5013 int len = this.length;
5014 if (len == 1) {
5015 return JS('String', '#[0]', this);
5016 }
5017 if (len == 0) throw new StateError("No elements");
5018 throw new StateError("More than one element");
5019 }
5020
5021 String elementAt(int index) {
5022 return this[index];
5023 }
5024
4905 // -- end List<String> mixins. 5025 // -- end List<String> mixins.
4906 5026
4907 @DomName('SVGStringList.appendItem') 5027 @DomName('SVGStringList.appendItem')
4908 @DocsEditable 5028 @DocsEditable
4909 String appendItem(String item) native; 5029 String appendItem(String item) native;
4910 5030
4911 @DomName('SVGStringList.clear') 5031 @DomName('SVGStringList.clear')
4912 @DocsEditable 5032 @DocsEditable
4913 void clear() native; 5033 void clear() native;
4914 5034
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
5875 5995
5876 5996
5877 @DocsEditable 5997 @DocsEditable
5878 @DomName('SVGTransformList') 5998 @DomName('SVGTransformList')
5879 class TransformList extends Object with ListMixin<Transform>, ImmutableListMixin <Transform> implements List<Transform>, JavaScriptIndexingBehavior native "SVGTr ansformList" { 5999 class TransformList extends Object with ListMixin<Transform>, ImmutableListMixin <Transform> implements List<Transform>, JavaScriptIndexingBehavior native "SVGTr ansformList" {
5880 6000
5881 @DomName('SVGTransformList.numberOfItems') 6001 @DomName('SVGTransformList.numberOfItems')
5882 @DocsEditable 6002 @DocsEditable
5883 final int numberOfItems; 6003 final int numberOfItems;
5884 6004
5885 Transform operator[](int index) => this.getItem(index); 6005 Transform operator[](int index) {
5886 6006 if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) thro w new RangeError.range(index, 0, length);
6007 return this.getItem(index);
6008 }
5887 void operator[]=(int index, Transform value) { 6009 void operator[]=(int index, Transform value) {
5888 throw new UnsupportedError("Cannot assign element of immutable List."); 6010 throw new UnsupportedError("Cannot assign element of immutable List.");
5889 } 6011 }
5890 // -- start List<Transform> mixins. 6012 // -- start List<Transform> mixins.
5891 // Transform is the element type. 6013 // Transform is the element type.
5892 6014
5893 // SVG Collections expose numberOfItems rather than length. 6015 // SVG Collections expose numberOfItems rather than length.
5894 int get length => numberOfItems; 6016 int get length => numberOfItems;
5895 6017
5896 void set length(int value) { 6018 void set length(int value) {
5897 throw new UnsupportedError("Cannot resize immutable List."); 6019 throw new UnsupportedError("Cannot resize immutable List.");
5898 } 6020 }
5899 6021
6022 Transform get first {
6023 if (this.length > 0) {
6024 return JS('Transform', '#[0]', this);
6025 }
6026 throw new StateError("No elements");
6027 }
6028
6029 Transform get last {
6030 int len = this.length;
6031 if (len > 0) {
6032 return JS('Transform', '#[#]', this, len - 1);
6033 }
6034 throw new StateError("No elements");
6035 }
6036
6037 Transform get single {
6038 int len = this.length;
6039 if (len == 1) {
6040 return JS('Transform', '#[0]', this);
6041 }
6042 if (len == 0) throw new StateError("No elements");
6043 throw new StateError("More than one element");
6044 }
6045
6046 Transform elementAt(int index) {
6047 return this[index];
6048 }
6049
5900 // -- end List<Transform> mixins. 6050 // -- end List<Transform> mixins.
5901 6051
5902 @DomName('SVGTransformList.appendItem') 6052 @DomName('SVGTransformList.appendItem')
5903 @DocsEditable 6053 @DocsEditable
5904 Transform appendItem(Transform item) native; 6054 Transform appendItem(Transform item) native;
5905 6055
5906 @DomName('SVGTransformList.clear') 6056 @DomName('SVGTransformList.clear')
5907 @DocsEditable 6057 @DocsEditable
5908 void clear() native; 6058 void clear() native;
5909 6059
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
6231 6381
6232 6382
6233 @DocsEditable 6383 @DocsEditable
6234 @DomName('SVGElementInstanceList') 6384 @DomName('SVGElementInstanceList')
6235 class _ElementInstanceList extends Object with ListMixin<ElementInstance>, Immut ableListMixin<ElementInstance> implements JavaScriptIndexingBehavior, List<Eleme ntInstance> native "SVGElementInstanceList" { 6385 class _ElementInstanceList extends Object with ListMixin<ElementInstance>, Immut ableListMixin<ElementInstance> implements JavaScriptIndexingBehavior, List<Eleme ntInstance> native "SVGElementInstanceList" {
6236 6386
6237 @DomName('SVGElementInstanceList.length') 6387 @DomName('SVGElementInstanceList.length')
6238 @DocsEditable 6388 @DocsEditable
6239 int get length => JS("int", "#.length", this); 6389 int get length => JS("int", "#.length", this);
6240 6390
6241 ElementInstance operator[](int index) => this.item(index); 6391 ElementInstance operator[](int index) {
6242 6392 if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) thro w new RangeError.range(index, 0, length);
6393 return this.item(index);
6394 }
6243 void operator[]=(int index, ElementInstance value) { 6395 void operator[]=(int index, ElementInstance value) {
6244 throw new UnsupportedError("Cannot assign element of immutable List."); 6396 throw new UnsupportedError("Cannot assign element of immutable List.");
6245 } 6397 }
6246 // -- start List<ElementInstance> mixins. 6398 // -- start List<ElementInstance> mixins.
6247 // ElementInstance is the element type. 6399 // ElementInstance is the element type.
6248 6400
6249 6401
6250 void set length(int value) { 6402 void set length(int value) {
6251 throw new UnsupportedError("Cannot resize immutable List."); 6403 throw new UnsupportedError("Cannot resize immutable List.");
6252 } 6404 }
6253 6405
6406 ElementInstance get first {
6407 if (this.length > 0) {
6408 return JS('ElementInstance', '#[0]', this);
6409 }
6410 throw new StateError("No elements");
6411 }
6412
6413 ElementInstance get last {
6414 int len = this.length;
6415 if (len > 0) {
6416 return JS('ElementInstance', '#[#]', this, len - 1);
6417 }
6418 throw new StateError("No elements");
6419 }
6420
6421 ElementInstance get single {
6422 int len = this.length;
6423 if (len == 1) {
6424 return JS('ElementInstance', '#[0]', this);
6425 }
6426 if (len == 0) throw new StateError("No elements");
6427 throw new StateError("More than one element");
6428 }
6429
6430 ElementInstance elementAt(int index) {
6431 return this[index];
6432 }
6433
6254 // -- end List<ElementInstance> mixins. 6434 // -- end List<ElementInstance> mixins.
6255 6435
6256 @DomName('SVGElementInstanceList.item') 6436 @DomName('SVGElementInstanceList.item')
6257 @DocsEditable 6437 @DocsEditable
6258 ElementInstance item(int index) native; 6438 ElementInstance item(int index) native;
6259 } 6439 }
6260 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 6440 // 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 6441 // 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. 6442 // BSD-style license that can be found in the LICENSE file.
6263 6443
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
6526 6706
6527 6707
6528 @DocsEditable 6708 @DocsEditable
6529 @DomName('SVGVKernElement') 6709 @DomName('SVGVKernElement')
6530 abstract class _SVGVKernElement extends SvgElement native "SVGVKernElement" { 6710 abstract class _SVGVKernElement extends SvgElement native "SVGVKernElement" {
6531 6711
6532 @DomName('SVGVKernElement.SVGVKernElement') 6712 @DomName('SVGVKernElement.SVGVKernElement')
6533 @DocsEditable 6713 @DocsEditable
6534 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag( "vkern"); 6714 factory _SVGVKernElement() => _SvgElementFactoryProvider.createSvgElement_tag( "vkern");
6535 } 6715 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698