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

Side by Side Diff: lib/runtime/dart/html_common.js

Issue 1879373004: Implement modular compilation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « lib/runtime/dart/core.js ('k') | lib/runtime/dart/indexed_db.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 dart_library.library('dart/html_common', null, /* Imports */[
2 'dart/_runtime',
3 'dart/_metadata',
4 'dart/core',
5 'dart/html',
6 'dart/typed_data',
7 'dart/_js_helper',
8 'dart/_native_typed_data',
9 'dart/async',
10 'dart/_internal',
11 'dart/collection'
12 ], /* Lazy imports */[
13 'dart/web_gl'
14 ], function(exports, dart, _metadata, core, html, typed_data, _js_helper, _nativ e_typed_data, async, _internal, collection, web_gl) {
15 'use strict';
16 let dartx = dart.dartx;
17 dart.export(exports, _metadata);
18 const _validateToken = Symbol('_validateToken');
19 class CssClassSetImpl extends core.Object {
20 [_validateToken](value) {
21 if (dart.notNull(CssClassSetImpl._validTokenRE.hasMatch(value))) return va lue;
22 dart.throw(new core.ArgumentError.value(value, 'value', 'Not a valid class token'));
23 }
24 toString() {
25 return this.readClasses().join(' ');
26 }
27 toggle(value, shouldAdd) {
28 if (shouldAdd === void 0) shouldAdd = null;
29 this[_validateToken](value);
30 let s = this.readClasses();
31 let result = false;
32 if (shouldAdd == null) shouldAdd = !dart.notNull(s.contains(value));
33 if (dart.notNull(shouldAdd)) {
34 s.add(value);
35 result = true;
36 } else {
37 s.remove(value);
38 }
39 this.writeClasses(s);
40 return result;
41 }
42 get frozen() {
43 return false;
44 }
45 get iterator() {
46 return this.readClasses().iterator;
47 }
48 [Symbol.iterator]() {
49 return new dart.JsIterator(this.iterator);
50 }
51 forEach(f) {
52 this.readClasses().forEach(f);
53 }
54 join(separator) {
55 if (separator === void 0) separator = "";
56 return this.readClasses().join(separator);
57 }
58 map(f) {
59 return this.readClasses().map(f);
60 }
61 where(f) {
62 return this.readClasses().where(f);
63 }
64 expand(f) {
65 return this.readClasses().expand(f);
66 }
67 every(f) {
68 return this.readClasses().every(f);
69 }
70 any(f) {
71 return this.readClasses().any(f);
72 }
73 get isEmpty() {
74 return this.readClasses().isEmpty;
75 }
76 get isNotEmpty() {
77 return this.readClasses().isNotEmpty;
78 }
79 get length() {
80 return this.readClasses().length;
81 }
82 reduce(combine) {
83 return this.readClasses().reduce(combine);
84 }
85 fold(initialValue, combine) {
86 return this.readClasses().fold(initialValue, combine);
87 }
88 contains(value) {
89 if (!(typeof value == 'string')) return false;
90 this[_validateToken](dart.as(value, core.String));
91 return this.readClasses().contains(value);
92 }
93 lookup(value) {
94 return dart.as(dart.notNull(this.contains(value)) ? value : null, core.Str ing);
95 }
96 add(value) {
97 this[_validateToken](value);
98 return dart.as(this.modify(dart.fn(s => s.add(value), core.bool, [core.Set $(core.String)])), core.bool);
99 }
100 remove(value) {
101 this[_validateToken](dart.as(value, core.String));
102 if (!(typeof value == 'string')) return false;
103 let s = this.readClasses();
104 let result = s.remove(value);
105 this.writeClasses(s);
106 return result;
107 }
108 addAll(iterable) {
109 this.modify(dart.fn(s => s.addAll(iterable[dartx.map](dart.bind(this, _val idateToken))), dart.void, [core.Set$(core.String)]));
110 }
111 removeAll(iterable) {
112 this.modify(dart.fn(s => s.removeAll(iterable[dartx.map](dart.as(dart.bind (this, _validateToken), dart.functionType(core.String, [core.Object])))), dart.v oid, [core.Set$(core.String)]));
113 }
114 toggleAll(iterable, shouldAdd) {
115 if (shouldAdd === void 0) shouldAdd = null;
116 iterable[dartx.forEach](dart.fn(e => this.toggle(e, shouldAdd), core.bool, [core.String]));
117 }
118 retainAll(iterable) {
119 this.modify(dart.fn(s => s.retainAll(iterable), dart.void, [core.Set$(core .String)]));
120 }
121 removeWhere(test) {
122 this.modify(dart.fn(s => s.removeWhere(test), dart.void, [core.Set$(core.S tring)]));
123 }
124 retainWhere(test) {
125 this.modify(dart.fn(s => s.retainWhere(test), dart.void, [core.Set$(core.S tring)]));
126 }
127 containsAll(collection) {
128 return this.readClasses().containsAll(collection);
129 }
130 intersection(other) {
131 return this.readClasses().intersection(other);
132 }
133 union(other) {
134 return this.readClasses().union(other);
135 }
136 difference(other) {
137 return this.readClasses().difference(other);
138 }
139 get first() {
140 return this.readClasses().first;
141 }
142 get last() {
143 return this.readClasses().last;
144 }
145 get single() {
146 return this.readClasses().single;
147 }
148 toList(opts) {
149 let growable = opts && 'growable' in opts ? opts.growable : true;
150 return this.readClasses().toList({growable: growable});
151 }
152 toSet() {
153 return this.readClasses().toSet();
154 }
155 take(n) {
156 return this.readClasses().take(n);
157 }
158 takeWhile(test) {
159 return this.readClasses().takeWhile(test);
160 }
161 skip(n) {
162 return this.readClasses().skip(n);
163 }
164 skipWhile(test) {
165 return this.readClasses().skipWhile(test);
166 }
167 firstWhere(test, opts) {
168 let orElse = opts && 'orElse' in opts ? opts.orElse : null;
169 return this.readClasses().firstWhere(test, {orElse: orElse});
170 }
171 lastWhere(test, opts) {
172 let orElse = opts && 'orElse' in opts ? opts.orElse : null;
173 return this.readClasses().lastWhere(test, {orElse: orElse});
174 }
175 singleWhere(test) {
176 return this.readClasses().singleWhere(test);
177 }
178 elementAt(index) {
179 return this.readClasses().elementAt(index);
180 }
181 clear() {
182 this.modify(dart.fn(s => s.clear(), dart.void, [core.Set$(core.String)]));
183 }
184 modify(f) {
185 let s = this.readClasses();
186 let ret = f(s);
187 this.writeClasses(s);
188 return ret;
189 }
190 }
191 CssClassSetImpl[dart.implements] = () => [html.CssClassSet];
192 dart.setSignature(CssClassSetImpl, {
193 methods: () => ({
194 [_validateToken]: [core.String, [core.String]],
195 toggle: [core.bool, [core.String], [core.bool]],
196 forEach: [dart.void, [dart.functionType(dart.void, [core.String])]],
197 join: [core.String, [], [core.String]],
198 map: [core.Iterable, [dart.functionType(dart.dynamic, [core.String])]],
199 where: [core.Iterable$(core.String), [dart.functionType(core.bool, [core.S tring])]],
200 expand: [core.Iterable, [dart.functionType(core.Iterable, [core.String])]] ,
201 every: [core.bool, [dart.functionType(core.bool, [core.String])]],
202 any: [core.bool, [dart.functionType(core.bool, [core.String])]],
203 reduce: [core.String, [dart.functionType(core.String, [core.String, core.S tring])]],
204 fold: [dart.dynamic, [dart.dynamic, dart.functionType(dart.dynamic, [dart. dynamic, core.String])]],
205 contains: [core.bool, [core.Object]],
206 lookup: [core.String, [core.Object]],
207 add: [core.bool, [core.String]],
208 remove: [core.bool, [core.Object]],
209 addAll: [dart.void, [core.Iterable$(core.String)]],
210 removeAll: [dart.void, [core.Iterable$(core.Object)]],
211 toggleAll: [dart.void, [core.Iterable$(core.String)], [core.bool]],
212 retainAll: [dart.void, [core.Iterable$(core.Object)]],
213 removeWhere: [dart.void, [dart.functionType(core.bool, [core.String])]],
214 retainWhere: [dart.void, [dart.functionType(core.bool, [core.String])]],
215 containsAll: [core.bool, [core.Iterable$(core.Object)]],
216 intersection: [core.Set$(core.String), [core.Set$(core.Object)]],
217 union: [core.Set$(core.String), [core.Set$(core.String)]],
218 difference: [core.Set$(core.String), [core.Set$(core.String)]],
219 toList: [core.List$(core.String), [], {growable: core.bool}],
220 toSet: [core.Set$(core.String), []],
221 take: [core.Iterable$(core.String), [core.int]],
222 takeWhile: [core.Iterable$(core.String), [dart.functionType(core.bool, [co re.String])]],
223 skip: [core.Iterable$(core.String), [core.int]],
224 skipWhile: [core.Iterable$(core.String), [dart.functionType(core.bool, [co re.String])]],
225 firstWhere: [core.String, [dart.functionType(core.bool, [core.String])], { orElse: dart.functionType(core.String, [])}],
226 lastWhere: [core.String, [dart.functionType(core.bool, [core.String])], {o rElse: dart.functionType(core.String, [])}],
227 singleWhere: [core.String, [dart.functionType(core.bool, [core.String])]],
228 elementAt: [core.String, [core.int]],
229 clear: [dart.void, []],
230 modify: [dart.dynamic, [dart.functionType(dart.dynamic, [core.Set$(core.St ring)])]]
231 })
232 });
233 dart.defineExtensionMembers(CssClassSetImpl, [
234 'forEach',
235 'join',
236 'map',
237 'where',
238 'expand',
239 'every',
240 'any',
241 'reduce',
242 'fold',
243 'contains',
244 'toList',
245 'toSet',
246 'take',
247 'takeWhile',
248 'skip',
249 'skipWhile',
250 'firstWhere',
251 'lastWhere',
252 'singleWhere',
253 'elementAt',
254 'iterator',
255 'isEmpty',
256 'isNotEmpty',
257 'length',
258 'first',
259 'last',
260 'single'
261 ]);
262 dart.defineLazyProperties(CssClassSetImpl, {
263 get _validTokenRE() {
264 return core.RegExp.new('^\\S+$');
265 }
266 });
267 function convertDartToNative_SerializedScriptValue(value) {
268 return convertDartToNative_PrepareForStructuredClone(value);
269 }
270 dart.fn(convertDartToNative_SerializedScriptValue);
271 function convertNativeToDart_SerializedScriptValue(object) {
272 return convertNativeToDart_AcceptStructuredClone(object, {mustCopy: true});
273 }
274 dart.fn(convertNativeToDart_SerializedScriptValue);
275 class _StructuredClone extends core.Object {
276 _StructuredClone() {
277 this.values = [];
278 this.copies = [];
279 }
280 findSlot(value) {
281 let length = this.values[dartx.length];
282 for (let i = 0; i < dart.notNull(length); i++) {
283 if (core.identical(this.values[dartx.get](i), value)) return i;
284 }
285 this.values[dartx.add](value);
286 this.copies[dartx.add](null);
287 return length;
288 }
289 readSlot(i) {
290 return this.copies[dartx.get](i);
291 }
292 writeSlot(i, x) {
293 this.copies[dartx.set](i, x);
294 }
295 cleanupSlots() {}
296 walk(e) {
297 if (e == null) return e;
298 if (typeof e == 'boolean') return e;
299 if (typeof e == 'number') return e;
300 if (typeof e == 'string') return e;
301 if (dart.is(e, core.DateTime)) {
302 return convertDartToNative_DateTime(e);
303 }
304 if (dart.is(e, core.RegExp)) {
305 dart.throw(new core.UnimplementedError('structured clone of RegExp'));
306 }
307 if (dart.is(e, html.File)) return e;
308 if (dart.is(e, html.Blob)) return e;
309 if (dart.is(e, html.FileList)) return e;
310 if (dart.is(e, html.ImageData)) return e;
311 if (dart.notNull(this.cloneNotRequired(e))) return e;
312 if (dart.is(e, core.Map)) {
313 let slot = this.findSlot(e);
314 let copy = this.readSlot(slot);
315 if (copy != null) return copy;
316 copy = this.newJsMap();
317 this.writeSlot(slot, copy);
318 e[dartx.forEach](dart.fn((key, value) => {
319 this.putIntoMap(copy, key, this.walk(value));
320 }, dart.void, [dart.dynamic, dart.dynamic]));
321 return copy;
322 }
323 if (dart.is(e, core.List)) {
324 let slot = this.findSlot(e);
325 let copy = this.readSlot(slot);
326 if (copy != null) return copy;
327 copy = this.copyList(e, slot);
328 return copy;
329 }
330 dart.throw(new core.UnimplementedError('structured clone of other type'));
331 }
332 copyList(e, slot) {
333 let i = 0;
334 let length = e[dartx.length];
335 let copy = this.newJsList(length);
336 this.writeSlot(slot, copy);
337 for (; i < dart.notNull(length); i++) {
338 dart.dsetindex(copy, i, this.walk(e[dartx.get](i)));
339 }
340 return copy;
341 }
342 convertDartToNative_PrepareForStructuredClone(value) {
343 let copy = this.walk(value);
344 this.cleanupSlots();
345 return copy;
346 }
347 }
348 dart.setSignature(_StructuredClone, {
349 methods: () => ({
350 findSlot: [core.int, [dart.dynamic]],
351 readSlot: [dart.dynamic, [core.int]],
352 writeSlot: [dart.dynamic, [core.int, dart.dynamic]],
353 cleanupSlots: [dart.dynamic, []],
354 walk: [dart.dynamic, [dart.dynamic]],
355 copyList: [dart.dynamic, [core.List, core.int]],
356 convertDartToNative_PrepareForStructuredClone: [dart.dynamic, [dart.dynami c]]
357 })
358 });
359 class _AcceptStructuredClone extends core.Object {
360 _AcceptStructuredClone() {
361 this.values = [];
362 this.copies = [];
363 this.mustCopy = false;
364 }
365 findSlot(value) {
366 let length = this.values[dartx.length];
367 for (let i = 0; i < dart.notNull(length); i++) {
368 if (dart.notNull(this.identicalInJs(this.values[dartx.get](i), value))) return i;
369 }
370 this.values[dartx.add](value);
371 this.copies[dartx.add](null);
372 return length;
373 }
374 readSlot(i) {
375 return this.copies[dartx.get](i);
376 }
377 writeSlot(i, x) {
378 this.copies[dartx.set](i, x);
379 }
380 walk(e) {
381 if (e == null) return e;
382 if (typeof e == 'boolean') return e;
383 if (typeof e == 'number') return e;
384 if (typeof e == 'string') return e;
385 if (dart.notNull(isJavaScriptDate(e))) {
386 return convertNativeToDart_DateTime(e);
387 }
388 if (dart.notNull(isJavaScriptRegExp(e))) {
389 dart.throw(new core.UnimplementedError('structured clone of RegExp'));
390 }
391 if (dart.notNull(isJavaScriptPromise(e))) {
392 return convertNativePromiseToDartFuture(e);
393 }
394 if (dart.notNull(isJavaScriptSimpleObject(e))) {
395 let slot = this.findSlot(e);
396 let copy = this.readSlot(slot);
397 if (copy != null) return copy;
398 copy = dart.map();
399 this.writeSlot(slot, copy);
400 this.forEachJsField(e, dart.fn((key, value) => dart.dsetindex(copy, key, this.walk(value))));
401 return copy;
402 }
403 if (dart.notNull(isJavaScriptArray(e))) {
404 let slot = this.findSlot(e);
405 let copy = this.readSlot(slot);
406 if (copy != null) return copy;
407 let length = dart.as(dart.dload(e, 'length'), core.int);
408 copy = dart.notNull(this.mustCopy) ? this.newDartList(length) : e;
409 this.writeSlot(slot, copy);
410 for (let i = 0; i < dart.notNull(length); i++) {
411 dart.dsetindex(copy, i, this.walk(dart.dindex(e, i)));
412 }
413 return copy;
414 }
415 return e;
416 }
417 convertNativeToDart_AcceptStructuredClone(object, opts) {
418 let mustCopy = opts && 'mustCopy' in opts ? opts.mustCopy : false;
419 this.mustCopy = dart.as(mustCopy, core.bool);
420 let copy = this.walk(object);
421 return copy;
422 }
423 }
424 dart.setSignature(_AcceptStructuredClone, {
425 methods: () => ({
426 findSlot: [core.int, [dart.dynamic]],
427 readSlot: [dart.dynamic, [core.int]],
428 writeSlot: [dart.dynamic, [core.int, dart.dynamic]],
429 walk: [dart.dynamic, [dart.dynamic]],
430 convertNativeToDart_AcceptStructuredClone: [dart.dynamic, [dart.dynamic], {mustCopy: dart.dynamic}]
431 })
432 });
433 class _TypedContextAttributes extends core.Object {
434 _TypedContextAttributes(alpha, antialias, depth, failIfMajorPerformanceCavea t, premultipliedAlpha, preserveDrawingBuffer, stencil) {
435 this.alpha = alpha;
436 this.antialias = antialias;
437 this.depth = depth;
438 this.failIfMajorPerformanceCaveat = failIfMajorPerformanceCaveat;
439 this.premultipliedAlpha = premultipliedAlpha;
440 this.preserveDrawingBuffer = preserveDrawingBuffer;
441 this.stencil = stencil;
442 }
443 }
444 _TypedContextAttributes[dart.implements] = () => [web_gl.ContextAttributes];
445 dart.setSignature(_TypedContextAttributes, {
446 constructors: () => ({_TypedContextAttributes: [_TypedContextAttributes, [co re.bool, core.bool, core.bool, core.bool, core.bool, core.bool, core.bool]]})
447 });
448 dart.defineExtensionMembers(_TypedContextAttributes, [
449 'alpha',
450 'alpha',
451 'antialias',
452 'antialias',
453 'depth',
454 'depth',
455 'premultipliedAlpha',
456 'premultipliedAlpha',
457 'preserveDrawingBuffer',
458 'preserveDrawingBuffer',
459 'stencil',
460 'stencil',
461 'failIfMajorPerformanceCaveat',
462 'failIfMajorPerformanceCaveat'
463 ]);
464 function convertNativeToDart_ContextAttributes(nativeContextAttributes) {
465 if (dart.is(nativeContextAttributes, web_gl.ContextAttributes)) {
466 return nativeContextAttributes;
467 }
468 return new _TypedContextAttributes(dart.as(nativeContextAttributes.alpha, co re.bool), dart.as(nativeContextAttributes.antialias, core.bool), dart.as(nativeC ontextAttributes.depth, core.bool), dart.as(nativeContextAttributes.failIfMajorP erformanceCaveat, core.bool), dart.as(nativeContextAttributes.premultipliedAlpha , core.bool), dart.as(nativeContextAttributes.preserveDrawingBuffer, core.bool), dart.as(nativeContextAttributes.stencil, core.bool));
469 }
470 dart.fn(convertNativeToDart_ContextAttributes, () => dart.definiteFunctionType (web_gl.ContextAttributes, [dart.dynamic]));
471 class _TypedImageData extends core.Object {
472 _TypedImageData(data, height, width) {
473 this.data = data;
474 this.height = height;
475 this.width = width;
476 }
477 }
478 _TypedImageData[dart.implements] = () => [html.ImageData];
479 dart.setSignature(_TypedImageData, {
480 constructors: () => ({_TypedImageData: [_TypedImageData, [typed_data.Uint8Cl ampedList, core.int, core.int]]})
481 });
482 dart.defineExtensionMembers(_TypedImageData, ['data', 'height', 'width']);
483 function convertNativeToDart_ImageData(nativeImageData) {
484 0;
485 if (dart.is(nativeImageData, html.ImageData)) {
486 let data = nativeImageData[dartx.data];
487 if (data.constructor === Array) {
488 if (typeof CanvasPixelArray !== "undefined") {
489 data.constructor = CanvasPixelArray;
490 data.BYTES_PER_ELEMENT = 1;
491 }
492 }
493 return nativeImageData;
494 }
495 return new _TypedImageData(dart.as(nativeImageData.data, typed_data.Uint8Cla mpedList), dart.as(nativeImageData.height, core.int), dart.as(nativeImageData.wi dth, core.int));
496 }
497 dart.fn(convertNativeToDart_ImageData, html.ImageData, [dart.dynamic]);
498 function convertDartToNative_ImageData(imageData) {
499 if (dart.is(imageData, _TypedImageData)) {
500 return {data: imageData.data, height: imageData.height, width: imageData.w idth};
501 }
502 return imageData;
503 }
504 dart.fn(convertDartToNative_ImageData, dart.dynamic, [html.ImageData]);
505 const _serializedScriptValue = 'num|String|bool|' + 'JSExtendableArray|=Object |' + 'Blob|File|NativeByteBuffer|NativeTypedData';
506 const annotation_Creates_SerializedScriptValue = dart.const(new _js_helper.Cre ates(_serializedScriptValue));
507 const annotation_Returns_SerializedScriptValue = dart.const(new _js_helper.Ret urns(_serializedScriptValue));
508 function convertNativeToDart_Dictionary(object) {
509 if (object == null) return null;
510 let dict = dart.map();
511 let keys = Object.getOwnPropertyNames(object);
512 for (let key of dart.as(keys, core.Iterable)) {
513 dict[dartx.set](key, object[key]);
514 }
515 return dict;
516 }
517 dart.fn(convertNativeToDart_Dictionary, core.Map, [dart.dynamic]);
518 function convertDartToNative_Dictionary(dict, postCreate) {
519 if (postCreate === void 0) postCreate = null;
520 if (dict == null) return null;
521 let object = {};
522 if (postCreate != null) {
523 dart.dcall(postCreate, object);
524 }
525 dict[dartx.forEach](dart.fn((key, value) => {
526 object[key] = value;
527 }, dart.void, [core.String, dart.dynamic]));
528 return object;
529 }
530 dart.fn(convertDartToNative_Dictionary, dart.dynamic, [core.Map], [dart.functi onType(dart.void, [dart.dynamic])]);
531 function convertDartToNative_StringArray(input) {
532 return input;
533 }
534 dart.fn(convertDartToNative_StringArray, core.List, [core.List$(core.String)]) ;
535 function convertNativeToDart_DateTime(date) {
536 let millisSinceEpoch = date.getTime();
537 return new core.DateTime.fromMillisecondsSinceEpoch(millisSinceEpoch, {isUtc : true});
538 }
539 dart.fn(convertNativeToDart_DateTime, core.DateTime, [dart.dynamic]);
540 function convertDartToNative_DateTime(date) {
541 return new Date(date.millisecondsSinceEpoch);
542 }
543 dart.fn(convertDartToNative_DateTime, dart.dynamic, [core.DateTime]);
544 function convertDartToNative_PrepareForStructuredClone(value) {
545 return new _StructuredCloneDart2Js().convertDartToNative_PrepareForStructure dClone(value);
546 }
547 dart.fn(convertDartToNative_PrepareForStructuredClone);
548 function convertNativeToDart_AcceptStructuredClone(object, opts) {
549 let mustCopy = opts && 'mustCopy' in opts ? opts.mustCopy : false;
550 return new _AcceptStructuredCloneDart2Js().convertNativeToDart_AcceptStructu redClone(object, {mustCopy: mustCopy});
551 }
552 dart.fn(convertNativeToDart_AcceptStructuredClone, dart.dynamic, [dart.dynamic ], {mustCopy: dart.dynamic});
553 class _StructuredCloneDart2Js extends _StructuredClone {
554 _StructuredCloneDart2Js() {
555 super._StructuredClone();
556 }
557 newJsMap() {
558 return {};
559 }
560 putIntoMap(map, key, value) {
561 return map[key] = value;
562 }
563 newJsList(length) {
564 return new Array(length);
565 }
566 cloneNotRequired(e) {
567 return dart.is(e, _native_typed_data.NativeByteBuffer) || dart.is(e, _nati ve_typed_data.NativeTypedData);
568 }
569 }
570 dart.setSignature(_StructuredCloneDart2Js, {
571 methods: () => ({
572 newJsMap: [dart.dynamic, []],
573 putIntoMap: [dart.void, [dart.dynamic, dart.dynamic, dart.dynamic]],
574 newJsList: [dart.dynamic, [dart.dynamic]],
575 cloneNotRequired: [core.bool, [dart.dynamic]]
576 })
577 });
578 class _AcceptStructuredCloneDart2Js extends _AcceptStructuredClone {
579 _AcceptStructuredCloneDart2Js() {
580 super._AcceptStructuredClone();
581 }
582 newJsList(length) {
583 return new Array(length);
584 }
585 newDartList(length) {
586 return this.newJsList(length);
587 }
588 identicalInJs(a, b) {
589 return core.identical(a, b);
590 }
591 forEachJsField(object, action) {
592 for (let key of dart.as(Object.keys(object), core.Iterable)) {
593 dart.dcall(action, key, object[key]);
594 }
595 }
596 }
597 dart.setSignature(_AcceptStructuredCloneDart2Js, {
598 methods: () => ({
599 newJsList: [dart.dynamic, [dart.dynamic]],
600 newDartList: [dart.dynamic, [dart.dynamic]],
601 identicalInJs: [core.bool, [dart.dynamic, dart.dynamic]],
602 forEachJsField: [dart.void, [dart.dynamic, dart.dynamic]]
603 })
604 });
605 function isJavaScriptDate(value) {
606 return value instanceof Date;
607 }
608 dart.fn(isJavaScriptDate, core.bool, [dart.dynamic]);
609 function isJavaScriptRegExp(value) {
610 return value instanceof RegExp;
611 }
612 dart.fn(isJavaScriptRegExp, core.bool, [dart.dynamic]);
613 function isJavaScriptArray(value) {
614 return value instanceof Array;
615 }
616 dart.fn(isJavaScriptArray, core.bool, [dart.dynamic]);
617 function isJavaScriptSimpleObject(value) {
618 let proto = Object.getPrototypeOf(value);
619 return proto === Object.prototype || proto === null;
620 }
621 dart.fn(isJavaScriptSimpleObject, core.bool, [dart.dynamic]);
622 function isImmutableJavaScriptArray(value) {
623 return !!value.immutable$list;
624 }
625 dart.fn(isImmutableJavaScriptArray, core.bool, [dart.dynamic]);
626 function isJavaScriptPromise(value) {
627 return typeof Promise != "undefined" && value instanceof Promise;
628 }
629 dart.fn(isJavaScriptPromise, core.bool, [dart.dynamic]);
630 function convertNativePromiseToDartFuture(promise) {
631 let completer = async.Completer.new();
632 let then = dart.dcall(/* Unimplemented unknown name */convertDartClosureToJS , dart.fn(result => completer.complete(result), dart.void, [dart.dynamic]), 1);
633 let error = dart.dcall(/* Unimplemented unknown name */convertDartClosureToJ S, dart.fn(result => completer.completeError(result), dart.void, [dart.dynamic]) , 1);
634 let newPromise = promise.then(then).catch(error);
635 return completer.future;
636 }
637 dart.fn(convertNativePromiseToDartFuture, async.Future, [dart.dynamic]);
638 function wrap_jso(jsObject) {
639 return jsObject;
640 }
641 dart.fn(wrap_jso);
642 function unwrap_jso(dartClass_instance) {
643 return dartClass_instance;
644 }
645 dart.fn(unwrap_jso);
646 class Device extends core.Object {
647 static get userAgent() {
648 return html.window[dartx.navigator][dartx.userAgent];
649 }
650 static get isOpera() {
651 if (Device._isOpera == null) {
652 Device._isOpera = Device.userAgent[dartx.contains]("Opera", 0);
653 }
654 return Device._isOpera;
655 }
656 static get isIE() {
657 if (Device._isIE == null) {
658 Device._isIE = !dart.notNull(Device.isOpera) && dart.notNull(Device.user Agent[dartx.contains]("Trident/", 0));
659 }
660 return Device._isIE;
661 }
662 static get isFirefox() {
663 if (Device._isFirefox == null) {
664 Device._isFirefox = Device.userAgent[dartx.contains]("Firefox", 0);
665 }
666 return Device._isFirefox;
667 }
668 static get isWebKit() {
669 if (Device._isWebKit == null) {
670 Device._isWebKit = !dart.notNull(Device.isOpera) && dart.notNull(Device. userAgent[dartx.contains]("WebKit", 0));
671 }
672 return Device._isWebKit;
673 }
674 static get cssPrefix() {
675 let prefix = Device._cachedCssPrefix;
676 if (prefix != null) return prefix;
677 if (dart.notNull(Device.isFirefox)) {
678 prefix = '-moz-';
679 } else if (dart.notNull(Device.isIE)) {
680 prefix = '-ms-';
681 } else if (dart.notNull(Device.isOpera)) {
682 prefix = '-o-';
683 } else {
684 prefix = '-webkit-';
685 }
686 return Device._cachedCssPrefix = prefix;
687 }
688 static get propertyPrefix() {
689 let prefix = Device._cachedPropertyPrefix;
690 if (prefix != null) return prefix;
691 if (dart.notNull(Device.isFirefox)) {
692 prefix = 'moz';
693 } else if (dart.notNull(Device.isIE)) {
694 prefix = 'ms';
695 } else if (dart.notNull(Device.isOpera)) {
696 prefix = 'o';
697 } else {
698 prefix = 'webkit';
699 }
700 return Device._cachedPropertyPrefix = prefix;
701 }
702 static isEventTypeSupported(eventType) {
703 try {
704 let e = html.Event.eventType(eventType, '');
705 return dart.is(e, html.Event);
706 } catch (_) {
707 }
708
709 return false;
710 }
711 }
712 dart.setSignature(Device, {
713 statics: () => ({isEventTypeSupported: [core.bool, [core.String]]}),
714 names: ['isEventTypeSupported']
715 });
716 Device._isOpera = null;
717 Device._isIE = null;
718 Device._isFirefox = null;
719 Device._isWebKit = null;
720 Device._cachedCssPrefix = null;
721 Device._cachedPropertyPrefix = null;
722 const _childNodes = Symbol('_childNodes');
723 const _node = Symbol('_node');
724 const _iterable = Symbol('_iterable');
725 const _filtered = Symbol('_filtered');
726 class FilteredElementList extends collection.ListBase$(html.Element) {
727 FilteredElementList(node) {
728 this[_childNodes] = node[dartx.nodes];
729 this[_node] = node;
730 }
731 get [_iterable]() {
732 return new (_internal.WhereIterable$(html.Element))(this[_childNodes], dar t.fn(n => dart.is(n, html.Element), core.bool, [html.Element]));
733 }
734 get [_filtered]() {
735 return core.List$(html.Element).from(this[_iterable], {growable: false});
736 }
737 forEach(f) {
738 this[_filtered][dartx.forEach](f);
739 }
740 set(index, value) {
741 this.get(index)[dartx.replaceWith](value);
742 return value;
743 }
744 set length(newLength) {
745 let len = this.length;
746 if (dart.notNull(newLength) >= dart.notNull(len)) {
747 return;
748 } else if (dart.notNull(newLength) < 0) {
749 dart.throw(new core.ArgumentError("Invalid list length"));
750 }
751 this.removeRange(newLength, len);
752 }
753 add(value) {
754 this[_childNodes][dartx.add](value);
755 }
756 addAll(iterable) {
757 for (let element of iterable) {
758 this.add(element);
759 }
760 }
761 contains(needle) {
762 if (!dart.is(needle, html.Element)) return false;
763 let element = dart.as(needle, html.Element);
764 return dart.equals(element[dartx.parentNode], this[_node]);
765 }
766 get reversed() {
767 return this[_filtered][dartx.reversed];
768 }
769 sort(compare) {
770 if (compare === void 0) compare = null;
771 dart.throw(new core.UnsupportedError('Cannot sort filtered list'));
772 }
773 setRange(start, end, iterable, skipCount) {
774 if (skipCount === void 0) skipCount = 0;
775 dart.throw(new core.UnsupportedError('Cannot setRange on filtered list'));
776 }
777 fillRange(start, end, fillValue) {
778 if (fillValue === void 0) fillValue = null;
779 dart.throw(new core.UnsupportedError('Cannot fillRange on filtered list')) ;
780 }
781 replaceRange(start, end, iterable) {
782 dart.throw(new core.UnsupportedError('Cannot replaceRange on filtered list '));
783 }
784 removeRange(start, end) {
785 core.List.from(this[_iterable][dartx.skip](start)[dartx.take](dart.notNull (end) - dart.notNull(start)))[dartx.forEach](dart.fn(el => dart.dsend(el, 'remov e'), dart.void, [dart.dynamic]));
786 }
787 clear() {
788 this[_childNodes][dartx.clear]();
789 }
790 removeLast() {
791 let result = this[_iterable][dartx.last];
792 if (result != null) {
793 result[dartx.remove]();
794 }
795 return result;
796 }
797 insert(index, value) {
798 if (index == this.length) {
799 this.add(value);
800 } else {
801 let element = this[_iterable][dartx.elementAt](index);
802 element[dartx.parentNode][dartx.insertBefore](value, element);
803 }
804 }
805 insertAll(index, iterable) {
806 if (index == this.length) {
807 this.addAll(iterable);
808 } else {
809 let element = this[_iterable][dartx.elementAt](index);
810 element[dartx.parentNode][dartx.insertAllBefore](iterable, element);
811 }
812 }
813 removeAt(index) {
814 let result = this.get(index);
815 result[dartx.remove]();
816 return result;
817 }
818 remove(element) {
819 if (!dart.is(element, html.Element)) return false;
820 if (dart.notNull(this.contains(element))) {
821 dart.as(element, html.Element)[dartx.remove]();
822 return true;
823 } else {
824 return false;
825 }
826 }
827 get length() {
828 return this[_iterable][dartx.length];
829 }
830 get(index) {
831 return this[_iterable][dartx.elementAt](index);
832 }
833 get iterator() {
834 return this[_filtered][dartx.iterator];
835 }
836 get rawList() {
837 return this[_node][dartx.childNodes];
838 }
839 }
840 FilteredElementList[dart.implements] = () => [NodeListWrapper];
841 dart.setSignature(FilteredElementList, {
842 constructors: () => ({FilteredElementList: [FilteredElementList, [html.Node] ]}),
843 methods: () => ({
844 forEach: [dart.void, [dart.functionType(dart.void, [html.Element])]],
845 set: [dart.void, [core.int, html.Element]],
846 add: [dart.void, [html.Element]],
847 addAll: [dart.void, [core.Iterable$(html.Element)]],
848 sort: [dart.void, [], [dart.functionType(core.int, [html.Element, html.Ele ment])]],
849 setRange: [dart.void, [core.int, core.int, core.Iterable$(html.Element)], [core.int]],
850 fillRange: [dart.void, [core.int, core.int], [html.Element]],
851 replaceRange: [dart.void, [core.int, core.int, core.Iterable$(html.Element )]],
852 removeLast: [html.Element, []],
853 insert: [dart.void, [core.int, html.Element]],
854 insertAll: [dart.void, [core.int, core.Iterable$(html.Element)]],
855 removeAt: [html.Element, [core.int]],
856 get: [html.Element, [core.int]]
857 })
858 });
859 dart.defineExtensionMembers(FilteredElementList, [
860 'forEach',
861 'set',
862 'add',
863 'addAll',
864 'contains',
865 'sort',
866 'setRange',
867 'fillRange',
868 'replaceRange',
869 'removeRange',
870 'clear',
871 'removeLast',
872 'insert',
873 'insertAll',
874 'removeAt',
875 'remove',
876 'get',
877 'length',
878 'reversed',
879 'length',
880 'iterator'
881 ]);
882 class Lists extends core.Object {
883 static indexOf(a, element, startIndex, endIndex) {
884 if (dart.notNull(startIndex) >= dart.notNull(a[dartx.length])) {
885 return -1;
886 }
887 if (dart.notNull(startIndex) < 0) {
888 startIndex = 0;
889 }
890 for (let i = startIndex; dart.notNull(i) < dart.notNull(endIndex); i = dar t.notNull(i) + 1) {
891 if (dart.equals(a[dartx.get](i), element)) {
892 return i;
893 }
894 }
895 return -1;
896 }
897 static lastIndexOf(a, element, startIndex) {
898 if (dart.notNull(startIndex) < 0) {
899 return -1;
900 }
901 if (dart.notNull(startIndex) >= dart.notNull(a[dartx.length])) {
902 startIndex = dart.notNull(a[dartx.length]) - 1;
903 }
904 for (let i = startIndex; dart.notNull(i) >= 0; i = dart.notNull(i) - 1) {
905 if (dart.equals(a[dartx.get](i), element)) {
906 return i;
907 }
908 }
909 return -1;
910 }
911 static getRange(a, start, end, accumulator) {
912 if (dart.notNull(start) < 0) dart.throw(new core.RangeError.value(start));
913 if (dart.notNull(end) < dart.notNull(start)) dart.throw(new core.RangeErro r.value(end));
914 if (dart.notNull(end) > dart.notNull(a[dartx.length])) dart.throw(new core .RangeError.value(end));
915 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
916 accumulator[dartx.add](a[dartx.get](i));
917 }
918 return accumulator;
919 }
920 }
921 dart.setSignature(Lists, {
922 statics: () => ({
923 indexOf: [core.int, [core.List, core.Object, core.int, core.int]],
924 lastIndexOf: [core.int, [core.List, core.Object, core.int]],
925 getRange: [core.List, [core.List, core.int, core.int, core.List]]
926 }),
927 names: ['indexOf', 'lastIndexOf', 'getRange']
928 });
929 class NodeListWrapper extends core.Object {}
930 // Exports:
931 exports.CssClassSetImpl = CssClassSetImpl;
932 exports.convertDartToNative_SerializedScriptValue = convertDartToNative_Serial izedScriptValue;
933 exports.convertNativeToDart_SerializedScriptValue = convertNativeToDart_Serial izedScriptValue;
934 exports.convertNativeToDart_ContextAttributes = convertNativeToDart_ContextAtt ributes;
935 exports.convertNativeToDart_ImageData = convertNativeToDart_ImageData;
936 exports.convertDartToNative_ImageData = convertDartToNative_ImageData;
937 exports.annotation_Creates_SerializedScriptValue = annotation_Creates_Serializ edScriptValue;
938 exports.annotation_Returns_SerializedScriptValue = annotation_Returns_Serializ edScriptValue;
939 exports.convertNativeToDart_Dictionary = convertNativeToDart_Dictionary;
940 exports.convertDartToNative_Dictionary = convertDartToNative_Dictionary;
941 exports.convertDartToNative_StringArray = convertDartToNative_StringArray;
942 exports.convertNativeToDart_DateTime = convertNativeToDart_DateTime;
943 exports.convertDartToNative_DateTime = convertDartToNative_DateTime;
944 exports.convertDartToNative_PrepareForStructuredClone = convertDartToNative_Pr epareForStructuredClone;
945 exports.convertNativeToDart_AcceptStructuredClone = convertNativeToDart_Accept StructuredClone;
946 exports.isJavaScriptDate = isJavaScriptDate;
947 exports.isJavaScriptRegExp = isJavaScriptRegExp;
948 exports.isJavaScriptArray = isJavaScriptArray;
949 exports.isJavaScriptSimpleObject = isJavaScriptSimpleObject;
950 exports.isImmutableJavaScriptArray = isImmutableJavaScriptArray;
951 exports.isJavaScriptPromise = isJavaScriptPromise;
952 exports.convertNativePromiseToDartFuture = convertNativePromiseToDartFuture;
953 exports.wrap_jso = wrap_jso;
954 exports.unwrap_jso = unwrap_jso;
955 exports.Device = Device;
956 exports.FilteredElementList = FilteredElementList;
957 exports.Lists = Lists;
958 exports.NodeListWrapper = NodeListWrapper;
959 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/core.js ('k') | lib/runtime/dart/indexed_db.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698