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

Side by Side Diff: tool/input_sdk/lib/html/ddc/html_ddc.dart

Issue 1528613004: First cut of mini dart:html. (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Fix build_sdk Created 5 years 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
OLDNEW
(Empty)
1 /**
2 * HTML elements and other resources for web-based applications that need to
3 * interact with the browser and the DOM (Document Object Model).
4 *
5 * This library includes DOM element types, CSS styling, local storage,
6 * media, speech, events, and more.
7 * To get started,
8 * check out the [Element] class, the base class for many of the HTML
9 * DOM types.
10 *
11 * ## Other resources
12 *
13 * * If you've never written a web app before, try our
14 * tutorials—[A Game of Darts](http://dartlang.org/docs/tutorials).
15 *
16 * * To see some web-based Dart apps in action and to play with the code,
17 * download
18 * [Dart Editor](http://www.dartlang.org/#get-started)
19 * and run its built-in examples.
20 *
21 * * For even more examples, see
22 * [Dart HTML5 Samples](https://github.com/dart-lang/dart-html5-samples)
23 * on Github.
24 */
25 library dart.dom.html;
26
27 import 'dart:async';
28 import 'dart:collection';
29 import 'dart:_internal' hide Symbol;
30 import 'dart:html_common';
31 import 'dart:isolate';
32 import "dart:convert";
33 import 'dart:math';
34 import 'dart:_native_typed_data';
35 import 'dart:typed_data';
36 import 'dart:_isolate_helper' show IsolateNatives;
37 import 'dart:_foreign_helper' show JS, JS_INTERCEPTOR_CONSTANT, JS_CONST;
38 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
39 // for details. All rights reserved. Use of this source code is governed by a
40 // BSD-style license that can be found in the LICENSE file.
41
42
43 @DocsEditable()
44 @DomName('HTMLAnchorElement')
45 @Native("HTMLAnchorElement")
46 class AnchorElement extends HtmlElement implements UrlUtils {
47 // To suppress missing implicit constructor warnings.
48 factory AnchorElement._() { throw new UnsupportedError("Not supported"); }
49
50 @DomName('HTMLAnchorElement.HTMLAnchorElement')
51 @DocsEditable()
52 factory AnchorElement({String href}) {
53 AnchorElement e = document.createElement("a");
54 if (href != null) e.href = href;
55 return e;
56 }
57
58
59 @Deprecated("Internal Use Only")
60 static AnchorElement internalCreateAnchorElement() {
61 return new AnchorElement.internal_();
62 }
63
64 @Deprecated("Internal Use Only")
65 AnchorElement.internal_() : super.internal_();
66
67
68 @DomName('HTMLAnchorElement.download')
69 @DocsEditable()
70 String get download => wrap_jso(JS("String", "#.download", this.raw));
71 @DomName('HTMLAnchorElement.download')
72 @DocsEditable()
73 void set download(String val) => JS("void", "#.download = #", this.raw, unwrap _jso(val));
74
75 @DomName('HTMLAnchorElement.hreflang')
76 @DocsEditable()
77 String get hreflang => wrap_jso(JS("String", "#.hreflang", this.raw));
78 @DomName('HTMLAnchorElement.hreflang')
79 @DocsEditable()
80 void set hreflang(String val) => JS("void", "#.hreflang = #", this.raw, unwrap _jso(val));
81
82 @DomName('HTMLAnchorElement.integrity')
83 @DocsEditable()
84 @Experimental() // untriaged
85 String get integrity => wrap_jso(JS("String", "#.integrity", this.raw));
86 @DomName('HTMLAnchorElement.integrity')
87 @DocsEditable()
88 @Experimental() // untriaged
89 void set integrity(String val) => JS("void", "#.integrity = #", this.raw, unwr ap_jso(val));
90
91 @DomName('HTMLAnchorElement.rel')
92 @DocsEditable()
93 String get rel => wrap_jso(JS("String", "#.rel", this.raw));
94 @DomName('HTMLAnchorElement.rel')
95 @DocsEditable()
96 void set rel(String val) => JS("void", "#.rel = #", this.raw, unwrap_jso(val)) ;
97
98 @DomName('HTMLAnchorElement.target')
99 @DocsEditable()
100 String get target => wrap_jso(JS("String", "#.target", this.raw));
101 @DomName('HTMLAnchorElement.target')
102 @DocsEditable()
103 void set target(String val) => JS("void", "#.target = #", this.raw, unwrap_jso (val));
104
105 @DomName('HTMLAnchorElement.type')
106 @DocsEditable()
107 String get type => wrap_jso(JS("String", "#.type", this.raw));
108 @DomName('HTMLAnchorElement.type')
109 @DocsEditable()
110 void set type(String val) => JS("void", "#.type = #", this.raw, unwrap_jso(val ));
111
112 // From URLUtils
113
114 @DomName('HTMLAnchorElement.hash')
115 @DocsEditable()
116 String get hash => wrap_jso(JS("String", "#.hash", this.raw));
117 @DomName('HTMLAnchorElement.hash')
118 @DocsEditable()
119 void set hash(String val) => JS("void", "#.hash = #", this.raw, unwrap_jso(val ));
120
121 @DomName('HTMLAnchorElement.host')
122 @DocsEditable()
123 String get host => wrap_jso(JS("String", "#.host", this.raw));
124 @DomName('HTMLAnchorElement.host')
125 @DocsEditable()
126 void set host(String val) => JS("void", "#.host = #", this.raw, unwrap_jso(val ));
127
128 @DomName('HTMLAnchorElement.hostname')
129 @DocsEditable()
130 String get hostname => wrap_jso(JS("String", "#.hostname", this.raw));
131 @DomName('HTMLAnchorElement.hostname')
132 @DocsEditable()
133 void set hostname(String val) => JS("void", "#.hostname = #", this.raw, unwrap _jso(val));
134
135 @DomName('HTMLAnchorElement.href')
136 @DocsEditable()
137 String get href => wrap_jso(JS("String", "#.href", this.raw));
138 @DomName('HTMLAnchorElement.href')
139 @DocsEditable()
140 void set href(String val) => JS("void", "#.href = #", this.raw, unwrap_jso(val ));
141
142 @DomName('HTMLAnchorElement.origin')
143 @DocsEditable()
144 // WebKit only
145 @Experimental() // non-standard
146 String get origin => wrap_jso(JS("String", "#.origin", this.raw));
147
148 @DomName('HTMLAnchorElement.password')
149 @DocsEditable()
150 @Experimental() // untriaged
151 String get password => wrap_jso(JS("String", "#.password", this.raw));
152 @DomName('HTMLAnchorElement.password')
153 @DocsEditable()
154 @Experimental() // untriaged
155 void set password(String val) => JS("void", "#.password = #", this.raw, unwrap _jso(val));
156
157 @DomName('HTMLAnchorElement.pathname')
158 @DocsEditable()
159 String get pathname => wrap_jso(JS("String", "#.pathname", this.raw));
160 @DomName('HTMLAnchorElement.pathname')
161 @DocsEditable()
162 void set pathname(String val) => JS("void", "#.pathname = #", this.raw, unwrap _jso(val));
163
164 @DomName('HTMLAnchorElement.port')
165 @DocsEditable()
166 String get port => wrap_jso(JS("String", "#.port", this.raw));
167 @DomName('HTMLAnchorElement.port')
168 @DocsEditable()
169 void set port(String val) => JS("void", "#.port = #", this.raw, unwrap_jso(val ));
170
171 @DomName('HTMLAnchorElement.protocol')
172 @DocsEditable()
173 String get protocol => wrap_jso(JS("String", "#.protocol", this.raw));
174 @DomName('HTMLAnchorElement.protocol')
175 @DocsEditable()
176 void set protocol(String val) => JS("void", "#.protocol = #", this.raw, unwrap _jso(val));
177
178 @DomName('HTMLAnchorElement.search')
179 @DocsEditable()
180 String get search => wrap_jso(JS("String", "#.search", this.raw));
181 @DomName('HTMLAnchorElement.search')
182 @DocsEditable()
183 void set search(String val) => JS("void", "#.search = #", this.raw, unwrap_jso (val));
184
185 @DomName('HTMLAnchorElement.username')
186 @DocsEditable()
187 @Experimental() // untriaged
188 String get username => wrap_jso(JS("String", "#.username", this.raw));
189 @DomName('HTMLAnchorElement.username')
190 @DocsEditable()
191 @Experimental() // untriaged
192 void set username(String val) => JS("void", "#.username = #", this.raw, unwrap _jso(val));
193 }
194 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
195 // for details. All rights reserved. Use of this source code is governed by a
196 // BSD-style license that can be found in the LICENSE file.
197
198
199 @DocsEditable()
200 @DomName('HTMLBaseElement')
201 @Native("HTMLBaseElement")
202 class BaseElement extends HtmlElement {
203 // To suppress missing implicit constructor warnings.
204 factory BaseElement._() { throw new UnsupportedError("Not supported"); }
205
206 @DomName('HTMLBaseElement.HTMLBaseElement')
207 @DocsEditable()
208 factory BaseElement() => document.createElement("base");
209
210
211 @Deprecated("Internal Use Only")
212 static BaseElement internalCreateBaseElement() {
213 return new BaseElement.internal_();
214 }
215
216 @Deprecated("Internal Use Only")
217 BaseElement.internal_() : super.internal_();
218
219
220 @DomName('HTMLBaseElement.href')
221 @DocsEditable()
222 String get href => wrap_jso(JS("String", "#.href", this.raw));
223 @DomName('HTMLBaseElement.href')
224 @DocsEditable()
225 void set href(String val) => JS("void", "#.href = #", this.raw, unwrap_jso(val ));
226
227 @DomName('HTMLBaseElement.target')
228 @DocsEditable()
229 String get target => wrap_jso(JS("String", "#.target", this.raw));
230 @DomName('HTMLBaseElement.target')
231 @DocsEditable()
232 void set target(String val) => JS("void", "#.target = #", this.raw, unwrap_jso (val));
233 }
234 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
235 // for details. All rights reserved. Use of this source code is governed by a
236 // BSD-style license that can be found in the LICENSE file.
237
238
239 @DocsEditable()
240 @DomName('HTMLBodyElement')
241 @Native("HTMLBodyElement")
242 class BodyElement extends HtmlElement {
243 // To suppress missing implicit constructor warnings.
244 factory BodyElement._() { throw new UnsupportedError("Not supported"); }
245
246 /**
247 * Static factory designed to expose `blur` events to event
248 * handlers that are not necessarily instances of [BodyElement].
249 *
250 * See [EventStreamProvider] for usage information.
251 */
252 @DomName('HTMLBodyElement.blurEvent')
253 @DocsEditable()
254 static const EventStreamProvider<Event> blurEvent = const EventStreamProvider< Event>('blur');
255
256 /**
257 * Static factory designed to expose `error` events to event
258 * handlers that are not necessarily instances of [BodyElement].
259 *
260 * See [EventStreamProvider] for usage information.
261 */
262 @DomName('HTMLBodyElement.errorEvent')
263 @DocsEditable()
264 static const EventStreamProvider<Event> errorEvent = const EventStreamProvider <Event>('error');
265
266 /**
267 * Static factory designed to expose `focus` events to event
268 * handlers that are not necessarily instances of [BodyElement].
269 *
270 * See [EventStreamProvider] for usage information.
271 */
272 @DomName('HTMLBodyElement.focusEvent')
273 @DocsEditable()
274 static const EventStreamProvider<Event> focusEvent = const EventStreamProvider <Event>('focus');
275
276 /**
277 * Static factory designed to expose `load` events to event
278 * handlers that are not necessarily instances of [BodyElement].
279 *
280 * See [EventStreamProvider] for usage information.
281 */
282 @DomName('HTMLBodyElement.loadEvent')
283 @DocsEditable()
284 static const EventStreamProvider<Event> loadEvent = const EventStreamProvider< Event>('load');
285
286 /**
287 * Static factory designed to expose `resize` events to event
288 * handlers that are not necessarily instances of [BodyElement].
289 *
290 * See [EventStreamProvider] for usage information.
291 */
292 @DomName('HTMLBodyElement.resizeEvent')
293 @DocsEditable()
294 static const EventStreamProvider<Event> resizeEvent = const EventStreamProvide r<Event>('resize');
295
296 @DomName('HTMLBodyElement.scrollEvent')
297 @DocsEditable()
298 @Experimental() // untriaged
299 static const EventStreamProvider<Event> scrollEvent = const EventStreamProvide r<Event>('scroll');
300
301 @DomName('HTMLBodyElement.HTMLBodyElement')
302 @DocsEditable()
303 factory BodyElement() => document.createElement("body");
304
305
306 @Deprecated("Internal Use Only")
307 static BodyElement internalCreateBodyElement() {
308 return new BodyElement.internal_();
309 }
310
311 @Deprecated("Internal Use Only")
312 BodyElement.internal_() : super.internal_();
313
314
315 /// Stream of `blur` events handled by this [BodyElement].
316 @DomName('HTMLBodyElement.onblur')
317 @DocsEditable()
318 ElementStream<Event> get onBlur => blurEvent.forElement(this);
319
320 /// Stream of `error` events handled by this [BodyElement].
321 @DomName('HTMLBodyElement.onerror')
322 @DocsEditable()
323 ElementStream<Event> get onError => errorEvent.forElement(this);
324
325 /// Stream of `focus` events handled by this [BodyElement].
326 @DomName('HTMLBodyElement.onfocus')
327 @DocsEditable()
328 ElementStream<Event> get onFocus => focusEvent.forElement(this);
329
330 /// Stream of `load` events handled by this [BodyElement].
331 @DomName('HTMLBodyElement.onload')
332 @DocsEditable()
333 ElementStream<Event> get onLoad => loadEvent.forElement(this);
334
335 /// Stream of `resize` events handled by this [BodyElement].
336 @DomName('HTMLBodyElement.onresize')
337 @DocsEditable()
338 ElementStream<Event> get onResize => resizeEvent.forElement(this);
339
340 @DomName('HTMLBodyElement.onscroll')
341 @DocsEditable()
342 @Experimental() // untriaged
343 ElementStream<Event> get onScroll => scrollEvent.forElement(this);
344 }
345 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
346 // for details. All rights reserved. Use of this source code is governed by a
347 // BSD-style license that can be found in the LICENSE file.
348
349
350 @DocsEditable()
351 @DomName('CharacterData')
352 @Native("CharacterData")
353 class CharacterData extends Node implements ChildNode {
354 // To suppress missing implicit constructor warnings.
355 factory CharacterData._() { throw new UnsupportedError("Not supported"); }
356
357
358 @Deprecated("Internal Use Only")
359 static CharacterData internalCreateCharacterData() {
360 return new CharacterData.internal_();
361 }
362
363 @Deprecated("Internal Use Only")
364 CharacterData.internal_() : super.internal_();
365
366
367 @DomName('CharacterData.data')
368 @DocsEditable()
369 String get data => wrap_jso(JS("String", "#.data", this.raw));
370 @DomName('CharacterData.data')
371 @DocsEditable()
372 void set data(String val) => JS("void", "#.data = #", this.raw, unwrap_jso(val ));
373
374 @DomName('CharacterData.length')
375 @DocsEditable()
376 int get length => wrap_jso(JS("int", "#.length", this.raw));
377
378 @DomName('CharacterData.appendData')
379 @DocsEditable()
380 void appendData(String data) {
381 _appendData_1(data);
382 return;
383 }
384 @JSName('appendData')
385 @DomName('CharacterData.appendData')
386 @DocsEditable()
387 void _appendData_1(data) => wrap_jso(JS("void ", "#.raw.appendData(#)", this, unwrap_jso(data)));
388
389 @DomName('CharacterData.deleteData')
390 @DocsEditable()
391 void deleteData(int offset, int length) {
392 _deleteData_1(offset, length);
393 return;
394 }
395 @JSName('deleteData')
396 @DomName('CharacterData.deleteData')
397 @DocsEditable()
398 void _deleteData_1(offset, length) => wrap_jso(JS("void ", "#.raw.deleteData(# , #)", this, unwrap_jso(offset), unwrap_jso(length)));
399
400 @DomName('CharacterData.insertData')
401 @DocsEditable()
402 void insertData(int offset, String data) {
403 _insertData_1(offset, data);
404 return;
405 }
406 @JSName('insertData')
407 @DomName('CharacterData.insertData')
408 @DocsEditable()
409 void _insertData_1(offset, data) => wrap_jso(JS("void ", "#.raw.insertData(#, #)", this, unwrap_jso(offset), unwrap_jso(data)));
410
411 @DomName('CharacterData.replaceData')
412 @DocsEditable()
413 void replaceData(int offset, int length, String data) {
414 _replaceData_1(offset, length, data);
415 return;
416 }
417 @JSName('replaceData')
418 @DomName('CharacterData.replaceData')
419 @DocsEditable()
420 void _replaceData_1(offset, length, data) => wrap_jso(JS("void ", "#.raw.repla ceData(#, #, #)", this, unwrap_jso(offset), unwrap_jso(length), unwrap_jso(data) ));
421
422 @DomName('CharacterData.substringData')
423 @DocsEditable()
424 String substringData(int offset, int length) {
425 return _substringData_1(offset, length);
426 }
427 @JSName('substringData')
428 @DomName('CharacterData.substringData')
429 @DocsEditable()
430 String _substringData_1(offset, length) => wrap_jso(JS("String ", "#.raw.subst ringData(#, #)", this, unwrap_jso(offset), unwrap_jso(length)));
431
432 // From ChildNode
433
434 @DomName('CharacterData.nextElementSibling')
435 @DocsEditable()
436 Element get nextElementSibling => wrap_jso(JS("Element", "#.nextElementSibling ", this.raw));
437
438 @DomName('CharacterData.previousElementSibling')
439 @DocsEditable()
440 Element get previousElementSibling => wrap_jso(JS("Element", "#.previousElemen tSibling", this.raw));
441 }
442 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
443 // for details. All rights reserved. Use of this source code is governed by a
444 // BSD-style license that can be found in the LICENSE file.
445
446
447 @DocsEditable()
448 @DomName('ChildNode')
449 @Experimental() // untriaged
450 abstract class ChildNode extends DartHtmlDomObject {
451 // To suppress missing implicit constructor warnings.
452 factory ChildNode._() { throw new UnsupportedError("Not supported"); }
453
454 Element get nextElementSibling => wrap_jso(JS("Element", "#.nextElementSibling ", this.raw));
455
456 Element get previousElementSibling => wrap_jso(JS("Element", "#.previousElemen tSibling", this.raw));
457
458 void remove() => wrap_jso(JS("void", "#.raw.remove()", this));
459 }
460 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
461 // for details. All rights reserved. Use of this source code is governed by a
462 // BSD-style license that can be found in the LICENSE file.
463
464
465 @DomName('Console')
466 class Console extends DartHtmlDomObject {
467
468 Console._safe();
469
470 static final Console _safeConsole = new Console._safe();
471
472 bool get _isConsoleDefined => JS('bool', 'typeof console != "undefined"');
473
474 @DomName('Console.assertCondition')
475 void assertCondition(bool condition, Object arg) => _isConsoleDefined ?
476 JS('void', 'console.assertCondition(#, #)', condition, arg) : null;
477
478 @DomName('Console.clear')
479 void clear(Object arg) => _isConsoleDefined ?
480 JS('void', 'console.clear(#)', arg) : null;
481
482 @DomName('Console.count')
483 void count(Object arg) => _isConsoleDefined ?
484 JS('void', 'console.count(#)', arg) : null;
485
486 @DomName('Console.debug')
487 void debug(Object arg) => _isConsoleDefined ?
488 JS('void', 'console.debug(#)', arg) : null;
489
490 @DomName('Console.dir')
491 void dir(Object arg) => _isConsoleDefined ?
492 JS('void', 'console.dir(#)', arg) : null;
493
494 @DomName('Console.dirxml')
495 void dirxml(Object arg) => _isConsoleDefined ?
496 JS('void', 'console.dirxml(#)', arg) : null;
497
498 @DomName('Console.error')
499 void error(Object arg) => _isConsoleDefined ?
500 JS('void', 'console.error(#)', arg) : null;
501
502 @DomName('Console.group')
503 void group(Object arg) => _isConsoleDefined ?
504 JS('void', 'console.group(#)', arg) : null;
505
506 @DomName('Console.groupCollapsed')
507 void groupCollapsed(Object arg) => _isConsoleDefined ?
508 JS('void', 'console.groupCollapsed(#)', arg) : null;
509
510 @DomName('Console.groupEnd')
511 void groupEnd() => _isConsoleDefined ?
512 JS('void', 'console.groupEnd()') : null;
513
514 @DomName('Console.info')
515 void info(Object arg) => _isConsoleDefined ?
516 JS('void', 'console.info(#)', arg) : null;
517
518 @DomName('Console.log')
519 void log(Object arg) => _isConsoleDefined ?
520 JS('void', 'console.log(#)', arg) : null;
521
522 @DomName('Console.markTimeline')
523 void markTimeline(Object arg) => _isConsoleDefined ?
524 JS('void', 'console.markTimeline(#)', arg) : null;
525
526 @DomName('Console.profile')
527 void profile(String title) => _isConsoleDefined ?
528 JS('void', 'console.profile(#)', title) : null;
529
530 @DomName('Console.profileEnd')
531 void profileEnd(String title) => _isConsoleDefined ?
532 JS('void', 'console.profileEnd(#)', title) : null;
533
534 @DomName('Console.table')
535 void table(Object arg) => _isConsoleDefined ?
536 JS('void', 'console.table(#)', arg) : null;
537
538 @DomName('Console.time')
539 void time(String title) => _isConsoleDefined ?
540 JS('void', 'console.time(#)', title) : null;
541
542 @DomName('Console.timeEnd')
543 void timeEnd(String title) => _isConsoleDefined ?
544 JS('void', 'console.timeEnd(#)', title) : null;
545
546 @DomName('Console.timeStamp')
547 void timeStamp(Object arg) => _isConsoleDefined ?
548 JS('void', 'console.timeStamp(#)', arg) : null;
549
550 @DomName('Console.trace')
551 void trace(Object arg) => _isConsoleDefined ?
552 JS('void', 'console.trace(#)', arg) : null;
553
554 @DomName('Console.warn')
555 void warn(Object arg) => _isConsoleDefined ?
556 JS('void', 'console.warn(#)', arg) : null;
557 // To suppress missing implicit constructor warnings.
558 factory Console._() { throw new UnsupportedError("Not supported"); }
559
560
561 @Deprecated("Internal Use Only")
562 static Console internalCreateConsole() {
563 return new Console.internal_();
564 }
565
566 @Deprecated("Internal Use Only")
567 Console.internal_() : super.internal_();
568
569
570 }
571 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
572 // for details. All rights reserved. Use of this source code is governed by a
573 // BSD-style license that can be found in the LICENSE file.
574
575
576 @DocsEditable()
577 @DomName('ConsoleBase')
578 @Experimental() // untriaged
579 @Native("ConsoleBase")
580 class ConsoleBase extends DartHtmlDomObject {
581 // To suppress missing implicit constructor warnings.
582 factory ConsoleBase._() { throw new UnsupportedError("Not supported"); }
583
584 @Deprecated("Internal Use Only")
585 static ConsoleBase internalCreateConsoleBase() {
586 return new ConsoleBase.internal_();
587 }
588
589 @Deprecated("Internal Use Only")
590 ConsoleBase.internal_() { }
591
592 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
593 int get hashCode => unwrap_jso(this).hashCode;
594
595 @DomName('ConsoleBase.timeline')
596 @DocsEditable()
597 @Experimental() // untriaged
598 void timeline(String title) {
599 _timeline_1(title);
600 return;
601 }
602 @JSName('timeline')
603 @DomName('ConsoleBase.timeline')
604 @DocsEditable()
605 @Experimental() // untriaged
606 void _timeline_1(title) => wrap_jso(JS("void ", "#.raw.timeline(#)", this, unw rap_jso(title)));
607
608 @DomName('ConsoleBase.timelineEnd')
609 @DocsEditable()
610 @Experimental() // untriaged
611 void timelineEnd(String title) {
612 _timelineEnd_1(title);
613 return;
614 }
615 @JSName('timelineEnd')
616 @DomName('ConsoleBase.timelineEnd')
617 @DocsEditable()
618 @Experimental() // untriaged
619 void _timelineEnd_1(title) => wrap_jso(JS("void ", "#.raw.timelineEnd(#)", thi s, unwrap_jso(title)));
620 }
621
622 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
623 // for details. All rights reserved. Use of this source code is governed by a
624 // BSD-style license that can be found in the LICENSE file.
625
626 // WARNING: DO NOT EDIT THIS TEMPLATE FILE.
627 // The template file was generated by scripts/css_code_generator.py
628
629 // Source of CSS properties:
630 // CSSPropertyNames.in
631
632
633 @DomName('CSSStyleDeclaration')
634 @Native("CSSStyleDeclaration,MSStyleCSSProperties,CSS2Properties")
635 class CssStyleDeclaration extends DartHtmlDomObject with
636 CssStyleDeclarationBase {
637 factory CssStyleDeclaration() => new CssStyleDeclaration.css('');
638
639 factory CssStyleDeclaration.css(String css) {
640 final style = new Element.tag('div').style;
641 style.cssText = css;
642 return style;
643 }
644
645 String getPropertyValue(String propertyName) {
646 var propValue = _getPropertyValueHelper(propertyName);
647 return propValue != null ? propValue : '';
648 }
649
650 String _getPropertyValueHelper(String propertyName) {
651 if (_supportsProperty(_camelCase(propertyName))) {
652 return _getPropertyValue(propertyName);
653 } else {
654 return _getPropertyValue(Device.cssPrefix + propertyName);
655 }
656 }
657
658 /**
659 * Returns true if the provided *CSS* property name is supported on this
660 * element.
661 *
662 * Please note the property name camelCase, not-hyphens. This
663 * method returns true if the property is accessible via an unprefixed _or_
664 * prefixed property.
665 */
666 bool supportsProperty(String propertyName) {
667 return _supportsProperty(propertyName) ||
668 _supportsProperty(_camelCase(Device.cssPrefix + propertyName));
669 }
670
671 bool _supportsProperty(String propertyName) {
672 return JS('bool', '# in #', propertyName, this.raw);
673 }
674
675
676 @DomName('CSSStyleDeclaration.setProperty')
677 void setProperty(String propertyName, String value, [String priority]) {
678 return _setPropertyHelper(_browserPropertyName(propertyName),
679 value, priority);
680 }
681
682 String _browserPropertyName(String propertyName) {
683 String name = _readCache(propertyName);
684 if (name is String) return name;
685 if (_supportsProperty(_camelCase(propertyName))) {
686 name = propertyName;
687 } else {
688 name = Device.cssPrefix + propertyName;
689 }
690 _writeCache(propertyName, name);
691 return name;
692 }
693
694 static String _readCache(String key) => null;
695 static void _writeCache(String key, value) {}
696
697 static String _camelCase(String hyphenated) {
698 // The "ms" prefix is always lowercased.
699 return hyphenated.replaceFirst(new RegExp('^-ms-'), 'ms-').replaceAllMapped(
700 new RegExp('-([a-z]+)', caseSensitive: false),
701 (match) => match[0][1].toUpperCase() + match[0].substring(2));
702 }
703
704 void _setPropertyHelper(String propertyName, String value, [String priority]) {
705 if (value == null) value = '';
706 if (priority == null) priority = '';
707 JS('void', '#.setProperty(#, #, #)', this.raw, propertyName, value, priority );
708 }
709
710 /**
711 * Checks to see if CSS Transitions are supported.
712 */
713 static bool get supportsTransitions {
714 return document.body.style.supportsProperty('transition');
715 }
716 // To suppress missing implicit constructor warnings.
717 factory CssStyleDeclaration._() { throw new UnsupportedError("Not supported"); }
718
719 @Deprecated("Internal Use Only")
720 static CssStyleDeclaration internalCreateCssStyleDeclaration() {
721 return new CssStyleDeclaration.internal_();
722 }
723
724 @Deprecated("Internal Use Only")
725 CssStyleDeclaration.internal_() { }
726
727 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
728 int get hashCode => unwrap_jso(this).hashCode;
729
730 @DomName('CSSStyleDeclaration.cssText')
731 @DocsEditable()
732 String get cssText => wrap_jso(JS("String", "#.cssText", this.raw));
733 @DomName('CSSStyleDeclaration.cssText')
734 @DocsEditable()
735 void set cssText(String val) => JS("void", "#.cssText = #", this.raw, unwrap_j so(val));
736
737 @DomName('CSSStyleDeclaration.length')
738 @DocsEditable()
739 int get length => wrap_jso(JS("int", "#.length", this.raw));
740
741 @DomName('CSSStyleDeclaration.__getter__')
742 @DocsEditable()
743 @Experimental() // untriaged
744 Object __getter__(String name) {
745 return __getter___1(name);
746 }
747 @JSName('__getter__')
748 @DomName('CSSStyleDeclaration.__getter__')
749 @DocsEditable()
750 @Experimental() // untriaged
751 Object __getter___1(name) => wrap_jso(JS("Object ", "#.raw.__getter__(#)", thi s, unwrap_jso(name)));
752
753 @DomName('CSSStyleDeclaration.__setter__')
754 @DocsEditable()
755 void __setter__(String propertyName, String propertyValue) {
756 __setter___1(propertyName, propertyValue);
757 return;
758 }
759 @JSName('__setter__')
760 @DomName('CSSStyleDeclaration.__setter__')
761 @DocsEditable()
762 void __setter___1(propertyName, propertyValue) => wrap_jso(JS("void ", "#.raw. __setter__(#, #)", this, unwrap_jso(propertyName), unwrap_jso(propertyValue)));
763
764 @DomName('CSSStyleDeclaration.getPropertyPriority')
765 @DocsEditable()
766 String getPropertyPriority(String propertyName) {
767 return _getPropertyPriority_1(propertyName);
768 }
769 @JSName('getPropertyPriority')
770 @DomName('CSSStyleDeclaration.getPropertyPriority')
771 @DocsEditable()
772 String _getPropertyPriority_1(propertyName) => wrap_jso(JS("String ", "#.raw.g etPropertyPriority(#)", this, unwrap_jso(propertyName)));
773
774 @DomName('CSSStyleDeclaration.getPropertyValue')
775 @DocsEditable()
776 String _getPropertyValue(String propertyName) {
777 return _getPropertyValue_1(propertyName);
778 }
779 @JSName('getPropertyValue')
780 @DomName('CSSStyleDeclaration.getPropertyValue')
781 @DocsEditable()
782 String _getPropertyValue_1(propertyName) => wrap_jso(JS("String ", "#.raw.getP ropertyValue(#)", this, unwrap_jso(propertyName)));
783
784 @DomName('CSSStyleDeclaration.item')
785 @DocsEditable()
786 String item(int index) {
787 return _item_1(index);
788 }
789 @JSName('item')
790 @DomName('CSSStyleDeclaration.item')
791 @DocsEditable()
792 String _item_1(index) => wrap_jso(JS("String ", "#.raw.item(#)", this, unwrap_ jso(index)));
793
794 @DomName('CSSStyleDeclaration.removeProperty')
795 @DocsEditable()
796 String removeProperty(String propertyName) {
797 return _removeProperty_1(propertyName);
798 }
799 @JSName('removeProperty')
800 @DomName('CSSStyleDeclaration.removeProperty')
801 @DocsEditable()
802 String _removeProperty_1(propertyName) => wrap_jso(JS("String ", "#.raw.remove Property(#)", this, unwrap_jso(propertyName)));
803
804 }
805
806 class _CssStyleDeclarationSet extends Object with CssStyleDeclarationBase {
807 final Iterable<Element> _elementIterable;
808 Iterable<CssStyleDeclaration> _elementCssStyleDeclarationSetIterable;
809
810 _CssStyleDeclarationSet(this._elementIterable) {
811 _elementCssStyleDeclarationSetIterable = new List.from(
812 _elementIterable).map((e) => e.style);
813 }
814
815 String getPropertyValue(String propertyName) =>
816 _elementCssStyleDeclarationSetIterable.first.getPropertyValue(
817 propertyName);
818
819 void setProperty(String propertyName, String value, [String priority]) {
820 _elementCssStyleDeclarationSetIterable.forEach((e) =>
821 e.setProperty(propertyName, value, priority));
822 }
823
824
825
826 // Important note: CssStyleDeclarationSet does NOT implement every method
827 // available in CssStyleDeclaration. Some of the methods don't make so much
828 // sense in terms of having a resonable value to return when you're
829 // considering a list of Elements. You will need to manually add any of the
830 // items in the MEMBERS set if you want that functionality.
831 }
832
833 class CssStyleDeclarationBase {
834 String getPropertyValue(String propertyName) =>
835 throw new StateError('getProperty not overridden in dart:html');
836 void setProperty(String propertyName, String value, [String priority]) =>
837 throw new StateError('setProperty not overridden in dart:html');
838
839 /** Gets the value of "align-content" */
840 String get alignContent =>
841 getPropertyValue('align-content');
842
843 /** Sets the value of "align-content" */
844 set alignContent(String value) {
845 setProperty('align-content', value, '');
846 }
847
848 /** Gets the value of "align-items" */
849 String get alignItems =>
850 getPropertyValue('align-items');
851
852 /** Sets the value of "align-items" */
853 set alignItems(String value) {
854 setProperty('align-items', value, '');
855 }
856
857 /** Gets the value of "align-self" */
858 String get alignSelf =>
859 getPropertyValue('align-self');
860
861 /** Sets the value of "align-self" */
862 set alignSelf(String value) {
863 setProperty('align-self', value, '');
864 }
865
866 /** Gets the value of "animation" */
867 String get animation =>
868 getPropertyValue('animation');
869
870 /** Sets the value of "animation" */
871 set animation(String value) {
872 setProperty('animation', value, '');
873 }
874
875 /** Gets the value of "animation-delay" */
876 String get animationDelay =>
877 getPropertyValue('animation-delay');
878
879 /** Sets the value of "animation-delay" */
880 set animationDelay(String value) {
881 setProperty('animation-delay', value, '');
882 }
883
884 /** Gets the value of "animation-direction" */
885 String get animationDirection =>
886 getPropertyValue('animation-direction');
887
888 /** Sets the value of "animation-direction" */
889 set animationDirection(String value) {
890 setProperty('animation-direction', value, '');
891 }
892
893 /** Gets the value of "animation-duration" */
894 String get animationDuration =>
895 getPropertyValue('animation-duration');
896
897 /** Sets the value of "animation-duration" */
898 set animationDuration(String value) {
899 setProperty('animation-duration', value, '');
900 }
901
902 /** Gets the value of "animation-fill-mode" */
903 String get animationFillMode =>
904 getPropertyValue('animation-fill-mode');
905
906 /** Sets the value of "animation-fill-mode" */
907 set animationFillMode(String value) {
908 setProperty('animation-fill-mode', value, '');
909 }
910
911 /** Gets the value of "animation-iteration-count" */
912 String get animationIterationCount =>
913 getPropertyValue('animation-iteration-count');
914
915 /** Sets the value of "animation-iteration-count" */
916 set animationIterationCount(String value) {
917 setProperty('animation-iteration-count', value, '');
918 }
919
920 /** Gets the value of "animation-name" */
921 String get animationName =>
922 getPropertyValue('animation-name');
923
924 /** Sets the value of "animation-name" */
925 set animationName(String value) {
926 setProperty('animation-name', value, '');
927 }
928
929 /** Gets the value of "animation-play-state" */
930 String get animationPlayState =>
931 getPropertyValue('animation-play-state');
932
933 /** Sets the value of "animation-play-state" */
934 set animationPlayState(String value) {
935 setProperty('animation-play-state', value, '');
936 }
937
938 /** Gets the value of "animation-timing-function" */
939 String get animationTimingFunction =>
940 getPropertyValue('animation-timing-function');
941
942 /** Sets the value of "animation-timing-function" */
943 set animationTimingFunction(String value) {
944 setProperty('animation-timing-function', value, '');
945 }
946
947 /** Gets the value of "app-region" */
948 String get appRegion =>
949 getPropertyValue('app-region');
950
951 /** Sets the value of "app-region" */
952 set appRegion(String value) {
953 setProperty('app-region', value, '');
954 }
955
956 /** Gets the value of "appearance" */
957 String get appearance =>
958 getPropertyValue('appearance');
959
960 /** Sets the value of "appearance" */
961 set appearance(String value) {
962 setProperty('appearance', value, '');
963 }
964
965 /** Gets the value of "aspect-ratio" */
966 String get aspectRatio =>
967 getPropertyValue('aspect-ratio');
968
969 /** Sets the value of "aspect-ratio" */
970 set aspectRatio(String value) {
971 setProperty('aspect-ratio', value, '');
972 }
973
974 /** Gets the value of "backface-visibility" */
975 String get backfaceVisibility =>
976 getPropertyValue('backface-visibility');
977
978 /** Sets the value of "backface-visibility" */
979 set backfaceVisibility(String value) {
980 setProperty('backface-visibility', value, '');
981 }
982
983 /** Gets the value of "background" */
984 String get background =>
985 getPropertyValue('background');
986
987 /** Sets the value of "background" */
988 set background(String value) {
989 setProperty('background', value, '');
990 }
991
992 /** Gets the value of "background-attachment" */
993 String get backgroundAttachment =>
994 getPropertyValue('background-attachment');
995
996 /** Sets the value of "background-attachment" */
997 set backgroundAttachment(String value) {
998 setProperty('background-attachment', value, '');
999 }
1000
1001 /** Gets the value of "background-blend-mode" */
1002 String get backgroundBlendMode =>
1003 getPropertyValue('background-blend-mode');
1004
1005 /** Sets the value of "background-blend-mode" */
1006 set backgroundBlendMode(String value) {
1007 setProperty('background-blend-mode', value, '');
1008 }
1009
1010 /** Gets the value of "background-clip" */
1011 String get backgroundClip =>
1012 getPropertyValue('background-clip');
1013
1014 /** Sets the value of "background-clip" */
1015 set backgroundClip(String value) {
1016 setProperty('background-clip', value, '');
1017 }
1018
1019 /** Gets the value of "background-color" */
1020 String get backgroundColor =>
1021 getPropertyValue('background-color');
1022
1023 /** Sets the value of "background-color" */
1024 set backgroundColor(String value) {
1025 setProperty('background-color', value, '');
1026 }
1027
1028 /** Gets the value of "background-composite" */
1029 String get backgroundComposite =>
1030 getPropertyValue('background-composite');
1031
1032 /** Sets the value of "background-composite" */
1033 set backgroundComposite(String value) {
1034 setProperty('background-composite', value, '');
1035 }
1036
1037 /** Gets the value of "background-image" */
1038 String get backgroundImage =>
1039 getPropertyValue('background-image');
1040
1041 /** Sets the value of "background-image" */
1042 set backgroundImage(String value) {
1043 setProperty('background-image', value, '');
1044 }
1045
1046 /** Gets the value of "background-origin" */
1047 String get backgroundOrigin =>
1048 getPropertyValue('background-origin');
1049
1050 /** Sets the value of "background-origin" */
1051 set backgroundOrigin(String value) {
1052 setProperty('background-origin', value, '');
1053 }
1054
1055 /** Gets the value of "background-position" */
1056 String get backgroundPosition =>
1057 getPropertyValue('background-position');
1058
1059 /** Sets the value of "background-position" */
1060 set backgroundPosition(String value) {
1061 setProperty('background-position', value, '');
1062 }
1063
1064 /** Gets the value of "background-position-x" */
1065 String get backgroundPositionX =>
1066 getPropertyValue('background-position-x');
1067
1068 /** Sets the value of "background-position-x" */
1069 set backgroundPositionX(String value) {
1070 setProperty('background-position-x', value, '');
1071 }
1072
1073 /** Gets the value of "background-position-y" */
1074 String get backgroundPositionY =>
1075 getPropertyValue('background-position-y');
1076
1077 /** Sets the value of "background-position-y" */
1078 set backgroundPositionY(String value) {
1079 setProperty('background-position-y', value, '');
1080 }
1081
1082 /** Gets the value of "background-repeat" */
1083 String get backgroundRepeat =>
1084 getPropertyValue('background-repeat');
1085
1086 /** Sets the value of "background-repeat" */
1087 set backgroundRepeat(String value) {
1088 setProperty('background-repeat', value, '');
1089 }
1090
1091 /** Gets the value of "background-repeat-x" */
1092 String get backgroundRepeatX =>
1093 getPropertyValue('background-repeat-x');
1094
1095 /** Sets the value of "background-repeat-x" */
1096 set backgroundRepeatX(String value) {
1097 setProperty('background-repeat-x', value, '');
1098 }
1099
1100 /** Gets the value of "background-repeat-y" */
1101 String get backgroundRepeatY =>
1102 getPropertyValue('background-repeat-y');
1103
1104 /** Sets the value of "background-repeat-y" */
1105 set backgroundRepeatY(String value) {
1106 setProperty('background-repeat-y', value, '');
1107 }
1108
1109 /** Gets the value of "background-size" */
1110 String get backgroundSize =>
1111 getPropertyValue('background-size');
1112
1113 /** Sets the value of "background-size" */
1114 set backgroundSize(String value) {
1115 setProperty('background-size', value, '');
1116 }
1117
1118 /** Gets the value of "border" */
1119 String get border =>
1120 getPropertyValue('border');
1121
1122 /** Sets the value of "border" */
1123 set border(String value) {
1124 setProperty('border', value, '');
1125 }
1126
1127 /** Gets the value of "border-after" */
1128 String get borderAfter =>
1129 getPropertyValue('border-after');
1130
1131 /** Sets the value of "border-after" */
1132 set borderAfter(String value) {
1133 setProperty('border-after', value, '');
1134 }
1135
1136 /** Gets the value of "border-after-color" */
1137 String get borderAfterColor =>
1138 getPropertyValue('border-after-color');
1139
1140 /** Sets the value of "border-after-color" */
1141 set borderAfterColor(String value) {
1142 setProperty('border-after-color', value, '');
1143 }
1144
1145 /** Gets the value of "border-after-style" */
1146 String get borderAfterStyle =>
1147 getPropertyValue('border-after-style');
1148
1149 /** Sets the value of "border-after-style" */
1150 set borderAfterStyle(String value) {
1151 setProperty('border-after-style', value, '');
1152 }
1153
1154 /** Gets the value of "border-after-width" */
1155 String get borderAfterWidth =>
1156 getPropertyValue('border-after-width');
1157
1158 /** Sets the value of "border-after-width" */
1159 set borderAfterWidth(String value) {
1160 setProperty('border-after-width', value, '');
1161 }
1162
1163 /** Gets the value of "border-before" */
1164 String get borderBefore =>
1165 getPropertyValue('border-before');
1166
1167 /** Sets the value of "border-before" */
1168 set borderBefore(String value) {
1169 setProperty('border-before', value, '');
1170 }
1171
1172 /** Gets the value of "border-before-color" */
1173 String get borderBeforeColor =>
1174 getPropertyValue('border-before-color');
1175
1176 /** Sets the value of "border-before-color" */
1177 set borderBeforeColor(String value) {
1178 setProperty('border-before-color', value, '');
1179 }
1180
1181 /** Gets the value of "border-before-style" */
1182 String get borderBeforeStyle =>
1183 getPropertyValue('border-before-style');
1184
1185 /** Sets the value of "border-before-style" */
1186 set borderBeforeStyle(String value) {
1187 setProperty('border-before-style', value, '');
1188 }
1189
1190 /** Gets the value of "border-before-width" */
1191 String get borderBeforeWidth =>
1192 getPropertyValue('border-before-width');
1193
1194 /** Sets the value of "border-before-width" */
1195 set borderBeforeWidth(String value) {
1196 setProperty('border-before-width', value, '');
1197 }
1198
1199 /** Gets the value of "border-bottom" */
1200 String get borderBottom =>
1201 getPropertyValue('border-bottom');
1202
1203 /** Sets the value of "border-bottom" */
1204 set borderBottom(String value) {
1205 setProperty('border-bottom', value, '');
1206 }
1207
1208 /** Gets the value of "border-bottom-color" */
1209 String get borderBottomColor =>
1210 getPropertyValue('border-bottom-color');
1211
1212 /** Sets the value of "border-bottom-color" */
1213 set borderBottomColor(String value) {
1214 setProperty('border-bottom-color', value, '');
1215 }
1216
1217 /** Gets the value of "border-bottom-left-radius" */
1218 String get borderBottomLeftRadius =>
1219 getPropertyValue('border-bottom-left-radius');
1220
1221 /** Sets the value of "border-bottom-left-radius" */
1222 set borderBottomLeftRadius(String value) {
1223 setProperty('border-bottom-left-radius', value, '');
1224 }
1225
1226 /** Gets the value of "border-bottom-right-radius" */
1227 String get borderBottomRightRadius =>
1228 getPropertyValue('border-bottom-right-radius');
1229
1230 /** Sets the value of "border-bottom-right-radius" */
1231 set borderBottomRightRadius(String value) {
1232 setProperty('border-bottom-right-radius', value, '');
1233 }
1234
1235 /** Gets the value of "border-bottom-style" */
1236 String get borderBottomStyle =>
1237 getPropertyValue('border-bottom-style');
1238
1239 /** Sets the value of "border-bottom-style" */
1240 set borderBottomStyle(String value) {
1241 setProperty('border-bottom-style', value, '');
1242 }
1243
1244 /** Gets the value of "border-bottom-width" */
1245 String get borderBottomWidth =>
1246 getPropertyValue('border-bottom-width');
1247
1248 /** Sets the value of "border-bottom-width" */
1249 set borderBottomWidth(String value) {
1250 setProperty('border-bottom-width', value, '');
1251 }
1252
1253 /** Gets the value of "border-collapse" */
1254 String get borderCollapse =>
1255 getPropertyValue('border-collapse');
1256
1257 /** Sets the value of "border-collapse" */
1258 set borderCollapse(String value) {
1259 setProperty('border-collapse', value, '');
1260 }
1261
1262 /** Gets the value of "border-color" */
1263 String get borderColor =>
1264 getPropertyValue('border-color');
1265
1266 /** Sets the value of "border-color" */
1267 set borderColor(String value) {
1268 setProperty('border-color', value, '');
1269 }
1270
1271 /** Gets the value of "border-end" */
1272 String get borderEnd =>
1273 getPropertyValue('border-end');
1274
1275 /** Sets the value of "border-end" */
1276 set borderEnd(String value) {
1277 setProperty('border-end', value, '');
1278 }
1279
1280 /** Gets the value of "border-end-color" */
1281 String get borderEndColor =>
1282 getPropertyValue('border-end-color');
1283
1284 /** Sets the value of "border-end-color" */
1285 set borderEndColor(String value) {
1286 setProperty('border-end-color', value, '');
1287 }
1288
1289 /** Gets the value of "border-end-style" */
1290 String get borderEndStyle =>
1291 getPropertyValue('border-end-style');
1292
1293 /** Sets the value of "border-end-style" */
1294 set borderEndStyle(String value) {
1295 setProperty('border-end-style', value, '');
1296 }
1297
1298 /** Gets the value of "border-end-width" */
1299 String get borderEndWidth =>
1300 getPropertyValue('border-end-width');
1301
1302 /** Sets the value of "border-end-width" */
1303 set borderEndWidth(String value) {
1304 setProperty('border-end-width', value, '');
1305 }
1306
1307 /** Gets the value of "border-fit" */
1308 String get borderFit =>
1309 getPropertyValue('border-fit');
1310
1311 /** Sets the value of "border-fit" */
1312 set borderFit(String value) {
1313 setProperty('border-fit', value, '');
1314 }
1315
1316 /** Gets the value of "border-horizontal-spacing" */
1317 String get borderHorizontalSpacing =>
1318 getPropertyValue('border-horizontal-spacing');
1319
1320 /** Sets the value of "border-horizontal-spacing" */
1321 set borderHorizontalSpacing(String value) {
1322 setProperty('border-horizontal-spacing', value, '');
1323 }
1324
1325 /** Gets the value of "border-image" */
1326 String get borderImage =>
1327 getPropertyValue('border-image');
1328
1329 /** Sets the value of "border-image" */
1330 set borderImage(String value) {
1331 setProperty('border-image', value, '');
1332 }
1333
1334 /** Gets the value of "border-image-outset" */
1335 String get borderImageOutset =>
1336 getPropertyValue('border-image-outset');
1337
1338 /** Sets the value of "border-image-outset" */
1339 set borderImageOutset(String value) {
1340 setProperty('border-image-outset', value, '');
1341 }
1342
1343 /** Gets the value of "border-image-repeat" */
1344 String get borderImageRepeat =>
1345 getPropertyValue('border-image-repeat');
1346
1347 /** Sets the value of "border-image-repeat" */
1348 set borderImageRepeat(String value) {
1349 setProperty('border-image-repeat', value, '');
1350 }
1351
1352 /** Gets the value of "border-image-slice" */
1353 String get borderImageSlice =>
1354 getPropertyValue('border-image-slice');
1355
1356 /** Sets the value of "border-image-slice" */
1357 set borderImageSlice(String value) {
1358 setProperty('border-image-slice', value, '');
1359 }
1360
1361 /** Gets the value of "border-image-source" */
1362 String get borderImageSource =>
1363 getPropertyValue('border-image-source');
1364
1365 /** Sets the value of "border-image-source" */
1366 set borderImageSource(String value) {
1367 setProperty('border-image-source', value, '');
1368 }
1369
1370 /** Gets the value of "border-image-width" */
1371 String get borderImageWidth =>
1372 getPropertyValue('border-image-width');
1373
1374 /** Sets the value of "border-image-width" */
1375 set borderImageWidth(String value) {
1376 setProperty('border-image-width', value, '');
1377 }
1378
1379 /** Gets the value of "border-left" */
1380 String get borderLeft =>
1381 getPropertyValue('border-left');
1382
1383 /** Sets the value of "border-left" */
1384 set borderLeft(String value) {
1385 setProperty('border-left', value, '');
1386 }
1387
1388 /** Gets the value of "border-left-color" */
1389 String get borderLeftColor =>
1390 getPropertyValue('border-left-color');
1391
1392 /** Sets the value of "border-left-color" */
1393 set borderLeftColor(String value) {
1394 setProperty('border-left-color', value, '');
1395 }
1396
1397 /** Gets the value of "border-left-style" */
1398 String get borderLeftStyle =>
1399 getPropertyValue('border-left-style');
1400
1401 /** Sets the value of "border-left-style" */
1402 set borderLeftStyle(String value) {
1403 setProperty('border-left-style', value, '');
1404 }
1405
1406 /** Gets the value of "border-left-width" */
1407 String get borderLeftWidth =>
1408 getPropertyValue('border-left-width');
1409
1410 /** Sets the value of "border-left-width" */
1411 set borderLeftWidth(String value) {
1412 setProperty('border-left-width', value, '');
1413 }
1414
1415 /** Gets the value of "border-radius" */
1416 String get borderRadius =>
1417 getPropertyValue('border-radius');
1418
1419 /** Sets the value of "border-radius" */
1420 set borderRadius(String value) {
1421 setProperty('border-radius', value, '');
1422 }
1423
1424 /** Gets the value of "border-right" */
1425 String get borderRight =>
1426 getPropertyValue('border-right');
1427
1428 /** Sets the value of "border-right" */
1429 set borderRight(String value) {
1430 setProperty('border-right', value, '');
1431 }
1432
1433 /** Gets the value of "border-right-color" */
1434 String get borderRightColor =>
1435 getPropertyValue('border-right-color');
1436
1437 /** Sets the value of "border-right-color" */
1438 set borderRightColor(String value) {
1439 setProperty('border-right-color', value, '');
1440 }
1441
1442 /** Gets the value of "border-right-style" */
1443 String get borderRightStyle =>
1444 getPropertyValue('border-right-style');
1445
1446 /** Sets the value of "border-right-style" */
1447 set borderRightStyle(String value) {
1448 setProperty('border-right-style', value, '');
1449 }
1450
1451 /** Gets the value of "border-right-width" */
1452 String get borderRightWidth =>
1453 getPropertyValue('border-right-width');
1454
1455 /** Sets the value of "border-right-width" */
1456 set borderRightWidth(String value) {
1457 setProperty('border-right-width', value, '');
1458 }
1459
1460 /** Gets the value of "border-spacing" */
1461 String get borderSpacing =>
1462 getPropertyValue('border-spacing');
1463
1464 /** Sets the value of "border-spacing" */
1465 set borderSpacing(String value) {
1466 setProperty('border-spacing', value, '');
1467 }
1468
1469 /** Gets the value of "border-start" */
1470 String get borderStart =>
1471 getPropertyValue('border-start');
1472
1473 /** Sets the value of "border-start" */
1474 set borderStart(String value) {
1475 setProperty('border-start', value, '');
1476 }
1477
1478 /** Gets the value of "border-start-color" */
1479 String get borderStartColor =>
1480 getPropertyValue('border-start-color');
1481
1482 /** Sets the value of "border-start-color" */
1483 set borderStartColor(String value) {
1484 setProperty('border-start-color', value, '');
1485 }
1486
1487 /** Gets the value of "border-start-style" */
1488 String get borderStartStyle =>
1489 getPropertyValue('border-start-style');
1490
1491 /** Sets the value of "border-start-style" */
1492 set borderStartStyle(String value) {
1493 setProperty('border-start-style', value, '');
1494 }
1495
1496 /** Gets the value of "border-start-width" */
1497 String get borderStartWidth =>
1498 getPropertyValue('border-start-width');
1499
1500 /** Sets the value of "border-start-width" */
1501 set borderStartWidth(String value) {
1502 setProperty('border-start-width', value, '');
1503 }
1504
1505 /** Gets the value of "border-style" */
1506 String get borderStyle =>
1507 getPropertyValue('border-style');
1508
1509 /** Sets the value of "border-style" */
1510 set borderStyle(String value) {
1511 setProperty('border-style', value, '');
1512 }
1513
1514 /** Gets the value of "border-top" */
1515 String get borderTop =>
1516 getPropertyValue('border-top');
1517
1518 /** Sets the value of "border-top" */
1519 set borderTop(String value) {
1520 setProperty('border-top', value, '');
1521 }
1522
1523 /** Gets the value of "border-top-color" */
1524 String get borderTopColor =>
1525 getPropertyValue('border-top-color');
1526
1527 /** Sets the value of "border-top-color" */
1528 set borderTopColor(String value) {
1529 setProperty('border-top-color', value, '');
1530 }
1531
1532 /** Gets the value of "border-top-left-radius" */
1533 String get borderTopLeftRadius =>
1534 getPropertyValue('border-top-left-radius');
1535
1536 /** Sets the value of "border-top-left-radius" */
1537 set borderTopLeftRadius(String value) {
1538 setProperty('border-top-left-radius', value, '');
1539 }
1540
1541 /** Gets the value of "border-top-right-radius" */
1542 String get borderTopRightRadius =>
1543 getPropertyValue('border-top-right-radius');
1544
1545 /** Sets the value of "border-top-right-radius" */
1546 set borderTopRightRadius(String value) {
1547 setProperty('border-top-right-radius', value, '');
1548 }
1549
1550 /** Gets the value of "border-top-style" */
1551 String get borderTopStyle =>
1552 getPropertyValue('border-top-style');
1553
1554 /** Sets the value of "border-top-style" */
1555 set borderTopStyle(String value) {
1556 setProperty('border-top-style', value, '');
1557 }
1558
1559 /** Gets the value of "border-top-width" */
1560 String get borderTopWidth =>
1561 getPropertyValue('border-top-width');
1562
1563 /** Sets the value of "border-top-width" */
1564 set borderTopWidth(String value) {
1565 setProperty('border-top-width', value, '');
1566 }
1567
1568 /** Gets the value of "border-vertical-spacing" */
1569 String get borderVerticalSpacing =>
1570 getPropertyValue('border-vertical-spacing');
1571
1572 /** Sets the value of "border-vertical-spacing" */
1573 set borderVerticalSpacing(String value) {
1574 setProperty('border-vertical-spacing', value, '');
1575 }
1576
1577 /** Gets the value of "border-width" */
1578 String get borderWidth =>
1579 getPropertyValue('border-width');
1580
1581 /** Sets the value of "border-width" */
1582 set borderWidth(String value) {
1583 setProperty('border-width', value, '');
1584 }
1585
1586 /** Gets the value of "bottom" */
1587 String get bottom =>
1588 getPropertyValue('bottom');
1589
1590 /** Sets the value of "bottom" */
1591 set bottom(String value) {
1592 setProperty('bottom', value, '');
1593 }
1594
1595 /** Gets the value of "box-align" */
1596 String get boxAlign =>
1597 getPropertyValue('box-align');
1598
1599 /** Sets the value of "box-align" */
1600 set boxAlign(String value) {
1601 setProperty('box-align', value, '');
1602 }
1603
1604 /** Gets the value of "box-decoration-break" */
1605 String get boxDecorationBreak =>
1606 getPropertyValue('box-decoration-break');
1607
1608 /** Sets the value of "box-decoration-break" */
1609 set boxDecorationBreak(String value) {
1610 setProperty('box-decoration-break', value, '');
1611 }
1612
1613 /** Gets the value of "box-direction" */
1614 String get boxDirection =>
1615 getPropertyValue('box-direction');
1616
1617 /** Sets the value of "box-direction" */
1618 set boxDirection(String value) {
1619 setProperty('box-direction', value, '');
1620 }
1621
1622 /** Gets the value of "box-flex" */
1623 String get boxFlex =>
1624 getPropertyValue('box-flex');
1625
1626 /** Sets the value of "box-flex" */
1627 set boxFlex(String value) {
1628 setProperty('box-flex', value, '');
1629 }
1630
1631 /** Gets the value of "box-flex-group" */
1632 String get boxFlexGroup =>
1633 getPropertyValue('box-flex-group');
1634
1635 /** Sets the value of "box-flex-group" */
1636 set boxFlexGroup(String value) {
1637 setProperty('box-flex-group', value, '');
1638 }
1639
1640 /** Gets the value of "box-lines" */
1641 String get boxLines =>
1642 getPropertyValue('box-lines');
1643
1644 /** Sets the value of "box-lines" */
1645 set boxLines(String value) {
1646 setProperty('box-lines', value, '');
1647 }
1648
1649 /** Gets the value of "box-ordinal-group" */
1650 String get boxOrdinalGroup =>
1651 getPropertyValue('box-ordinal-group');
1652
1653 /** Sets the value of "box-ordinal-group" */
1654 set boxOrdinalGroup(String value) {
1655 setProperty('box-ordinal-group', value, '');
1656 }
1657
1658 /** Gets the value of "box-orient" */
1659 String get boxOrient =>
1660 getPropertyValue('box-orient');
1661
1662 /** Sets the value of "box-orient" */
1663 set boxOrient(String value) {
1664 setProperty('box-orient', value, '');
1665 }
1666
1667 /** Gets the value of "box-pack" */
1668 String get boxPack =>
1669 getPropertyValue('box-pack');
1670
1671 /** Sets the value of "box-pack" */
1672 set boxPack(String value) {
1673 setProperty('box-pack', value, '');
1674 }
1675
1676 /** Gets the value of "box-reflect" */
1677 String get boxReflect =>
1678 getPropertyValue('box-reflect');
1679
1680 /** Sets the value of "box-reflect" */
1681 set boxReflect(String value) {
1682 setProperty('box-reflect', value, '');
1683 }
1684
1685 /** Gets the value of "box-shadow" */
1686 String get boxShadow =>
1687 getPropertyValue('box-shadow');
1688
1689 /** Sets the value of "box-shadow" */
1690 set boxShadow(String value) {
1691 setProperty('box-shadow', value, '');
1692 }
1693
1694 /** Gets the value of "box-sizing" */
1695 String get boxSizing =>
1696 getPropertyValue('box-sizing');
1697
1698 /** Sets the value of "box-sizing" */
1699 set boxSizing(String value) {
1700 setProperty('box-sizing', value, '');
1701 }
1702
1703 /** Gets the value of "caption-side" */
1704 String get captionSide =>
1705 getPropertyValue('caption-side');
1706
1707 /** Sets the value of "caption-side" */
1708 set captionSide(String value) {
1709 setProperty('caption-side', value, '');
1710 }
1711
1712 /** Gets the value of "clear" */
1713 String get clear =>
1714 getPropertyValue('clear');
1715
1716 /** Sets the value of "clear" */
1717 set clear(String value) {
1718 setProperty('clear', value, '');
1719 }
1720
1721 /** Gets the value of "clip" */
1722 String get clip =>
1723 getPropertyValue('clip');
1724
1725 /** Sets the value of "clip" */
1726 set clip(String value) {
1727 setProperty('clip', value, '');
1728 }
1729
1730 /** Gets the value of "clip-path" */
1731 String get clipPath =>
1732 getPropertyValue('clip-path');
1733
1734 /** Sets the value of "clip-path" */
1735 set clipPath(String value) {
1736 setProperty('clip-path', value, '');
1737 }
1738
1739 /** Gets the value of "color" */
1740 String get color =>
1741 getPropertyValue('color');
1742
1743 /** Sets the value of "color" */
1744 set color(String value) {
1745 setProperty('color', value, '');
1746 }
1747
1748 /** Gets the value of "column-break-after" */
1749 String get columnBreakAfter =>
1750 getPropertyValue('column-break-after');
1751
1752 /** Sets the value of "column-break-after" */
1753 set columnBreakAfter(String value) {
1754 setProperty('column-break-after', value, '');
1755 }
1756
1757 /** Gets the value of "column-break-before" */
1758 String get columnBreakBefore =>
1759 getPropertyValue('column-break-before');
1760
1761 /** Sets the value of "column-break-before" */
1762 set columnBreakBefore(String value) {
1763 setProperty('column-break-before', value, '');
1764 }
1765
1766 /** Gets the value of "column-break-inside" */
1767 String get columnBreakInside =>
1768 getPropertyValue('column-break-inside');
1769
1770 /** Sets the value of "column-break-inside" */
1771 set columnBreakInside(String value) {
1772 setProperty('column-break-inside', value, '');
1773 }
1774
1775 /** Gets the value of "column-count" */
1776 String get columnCount =>
1777 getPropertyValue('column-count');
1778
1779 /** Sets the value of "column-count" */
1780 set columnCount(String value) {
1781 setProperty('column-count', value, '');
1782 }
1783
1784 /** Gets the value of "column-fill" */
1785 String get columnFill =>
1786 getPropertyValue('column-fill');
1787
1788 /** Sets the value of "column-fill" */
1789 set columnFill(String value) {
1790 setProperty('column-fill', value, '');
1791 }
1792
1793 /** Gets the value of "column-gap" */
1794 String get columnGap =>
1795 getPropertyValue('column-gap');
1796
1797 /** Sets the value of "column-gap" */
1798 set columnGap(String value) {
1799 setProperty('column-gap', value, '');
1800 }
1801
1802 /** Gets the value of "column-rule" */
1803 String get columnRule =>
1804 getPropertyValue('column-rule');
1805
1806 /** Sets the value of "column-rule" */
1807 set columnRule(String value) {
1808 setProperty('column-rule', value, '');
1809 }
1810
1811 /** Gets the value of "column-rule-color" */
1812 String get columnRuleColor =>
1813 getPropertyValue('column-rule-color');
1814
1815 /** Sets the value of "column-rule-color" */
1816 set columnRuleColor(String value) {
1817 setProperty('column-rule-color', value, '');
1818 }
1819
1820 /** Gets the value of "column-rule-style" */
1821 String get columnRuleStyle =>
1822 getPropertyValue('column-rule-style');
1823
1824 /** Sets the value of "column-rule-style" */
1825 set columnRuleStyle(String value) {
1826 setProperty('column-rule-style', value, '');
1827 }
1828
1829 /** Gets the value of "column-rule-width" */
1830 String get columnRuleWidth =>
1831 getPropertyValue('column-rule-width');
1832
1833 /** Sets the value of "column-rule-width" */
1834 set columnRuleWidth(String value) {
1835 setProperty('column-rule-width', value, '');
1836 }
1837
1838 /** Gets the value of "column-span" */
1839 String get columnSpan =>
1840 getPropertyValue('column-span');
1841
1842 /** Sets the value of "column-span" */
1843 set columnSpan(String value) {
1844 setProperty('column-span', value, '');
1845 }
1846
1847 /** Gets the value of "column-width" */
1848 String get columnWidth =>
1849 getPropertyValue('column-width');
1850
1851 /** Sets the value of "column-width" */
1852 set columnWidth(String value) {
1853 setProperty('column-width', value, '');
1854 }
1855
1856 /** Gets the value of "columns" */
1857 String get columns =>
1858 getPropertyValue('columns');
1859
1860 /** Sets the value of "columns" */
1861 set columns(String value) {
1862 setProperty('columns', value, '');
1863 }
1864
1865 /** Gets the value of "content" */
1866 String get content =>
1867 getPropertyValue('content');
1868
1869 /** Sets the value of "content" */
1870 set content(String value) {
1871 setProperty('content', value, '');
1872 }
1873
1874 /** Gets the value of "counter-increment" */
1875 String get counterIncrement =>
1876 getPropertyValue('counter-increment');
1877
1878 /** Sets the value of "counter-increment" */
1879 set counterIncrement(String value) {
1880 setProperty('counter-increment', value, '');
1881 }
1882
1883 /** Gets the value of "counter-reset" */
1884 String get counterReset =>
1885 getPropertyValue('counter-reset');
1886
1887 /** Sets the value of "counter-reset" */
1888 set counterReset(String value) {
1889 setProperty('counter-reset', value, '');
1890 }
1891
1892 /** Gets the value of "cursor" */
1893 String get cursor =>
1894 getPropertyValue('cursor');
1895
1896 /** Sets the value of "cursor" */
1897 set cursor(String value) {
1898 setProperty('cursor', value, '');
1899 }
1900
1901 /** Gets the value of "direction" */
1902 String get direction =>
1903 getPropertyValue('direction');
1904
1905 /** Sets the value of "direction" */
1906 set direction(String value) {
1907 setProperty('direction', value, '');
1908 }
1909
1910 /** Gets the value of "display" */
1911 String get display =>
1912 getPropertyValue('display');
1913
1914 /** Sets the value of "display" */
1915 set display(String value) {
1916 setProperty('display', value, '');
1917 }
1918
1919 /** Gets the value of "empty-cells" */
1920 String get emptyCells =>
1921 getPropertyValue('empty-cells');
1922
1923 /** Sets the value of "empty-cells" */
1924 set emptyCells(String value) {
1925 setProperty('empty-cells', value, '');
1926 }
1927
1928 /** Gets the value of "filter" */
1929 String get filter =>
1930 getPropertyValue('filter');
1931
1932 /** Sets the value of "filter" */
1933 set filter(String value) {
1934 setProperty('filter', value, '');
1935 }
1936
1937 /** Gets the value of "flex" */
1938 String get flex =>
1939 getPropertyValue('flex');
1940
1941 /** Sets the value of "flex" */
1942 set flex(String value) {
1943 setProperty('flex', value, '');
1944 }
1945
1946 /** Gets the value of "flex-basis" */
1947 String get flexBasis =>
1948 getPropertyValue('flex-basis');
1949
1950 /** Sets the value of "flex-basis" */
1951 set flexBasis(String value) {
1952 setProperty('flex-basis', value, '');
1953 }
1954
1955 /** Gets the value of "flex-direction" */
1956 String get flexDirection =>
1957 getPropertyValue('flex-direction');
1958
1959 /** Sets the value of "flex-direction" */
1960 set flexDirection(String value) {
1961 setProperty('flex-direction', value, '');
1962 }
1963
1964 /** Gets the value of "flex-flow" */
1965 String get flexFlow =>
1966 getPropertyValue('flex-flow');
1967
1968 /** Sets the value of "flex-flow" */
1969 set flexFlow(String value) {
1970 setProperty('flex-flow', value, '');
1971 }
1972
1973 /** Gets the value of "flex-grow" */
1974 String get flexGrow =>
1975 getPropertyValue('flex-grow');
1976
1977 /** Sets the value of "flex-grow" */
1978 set flexGrow(String value) {
1979 setProperty('flex-grow', value, '');
1980 }
1981
1982 /** Gets the value of "flex-shrink" */
1983 String get flexShrink =>
1984 getPropertyValue('flex-shrink');
1985
1986 /** Sets the value of "flex-shrink" */
1987 set flexShrink(String value) {
1988 setProperty('flex-shrink', value, '');
1989 }
1990
1991 /** Gets the value of "flex-wrap" */
1992 String get flexWrap =>
1993 getPropertyValue('flex-wrap');
1994
1995 /** Sets the value of "flex-wrap" */
1996 set flexWrap(String value) {
1997 setProperty('flex-wrap', value, '');
1998 }
1999
2000 /** Gets the value of "float" */
2001 String get float =>
2002 getPropertyValue('float');
2003
2004 /** Sets the value of "float" */
2005 set float(String value) {
2006 setProperty('float', value, '');
2007 }
2008
2009 /** Gets the value of "font" */
2010 String get font =>
2011 getPropertyValue('font');
2012
2013 /** Sets the value of "font" */
2014 set font(String value) {
2015 setProperty('font', value, '');
2016 }
2017
2018 /** Gets the value of "font-family" */
2019 String get fontFamily =>
2020 getPropertyValue('font-family');
2021
2022 /** Sets the value of "font-family" */
2023 set fontFamily(String value) {
2024 setProperty('font-family', value, '');
2025 }
2026
2027 /** Gets the value of "font-feature-settings" */
2028 String get fontFeatureSettings =>
2029 getPropertyValue('font-feature-settings');
2030
2031 /** Sets the value of "font-feature-settings" */
2032 set fontFeatureSettings(String value) {
2033 setProperty('font-feature-settings', value, '');
2034 }
2035
2036 /** Gets the value of "font-kerning" */
2037 String get fontKerning =>
2038 getPropertyValue('font-kerning');
2039
2040 /** Sets the value of "font-kerning" */
2041 set fontKerning(String value) {
2042 setProperty('font-kerning', value, '');
2043 }
2044
2045 /** Gets the value of "font-size" */
2046 String get fontSize =>
2047 getPropertyValue('font-size');
2048
2049 /** Sets the value of "font-size" */
2050 set fontSize(String value) {
2051 setProperty('font-size', value, '');
2052 }
2053
2054 /** Gets the value of "font-size-delta" */
2055 String get fontSizeDelta =>
2056 getPropertyValue('font-size-delta');
2057
2058 /** Sets the value of "font-size-delta" */
2059 set fontSizeDelta(String value) {
2060 setProperty('font-size-delta', value, '');
2061 }
2062
2063 /** Gets the value of "font-smoothing" */
2064 String get fontSmoothing =>
2065 getPropertyValue('font-smoothing');
2066
2067 /** Sets the value of "font-smoothing" */
2068 set fontSmoothing(String value) {
2069 setProperty('font-smoothing', value, '');
2070 }
2071
2072 /** Gets the value of "font-stretch" */
2073 String get fontStretch =>
2074 getPropertyValue('font-stretch');
2075
2076 /** Sets the value of "font-stretch" */
2077 set fontStretch(String value) {
2078 setProperty('font-stretch', value, '');
2079 }
2080
2081 /** Gets the value of "font-style" */
2082 String get fontStyle =>
2083 getPropertyValue('font-style');
2084
2085 /** Sets the value of "font-style" */
2086 set fontStyle(String value) {
2087 setProperty('font-style', value, '');
2088 }
2089
2090 /** Gets the value of "font-variant" */
2091 String get fontVariant =>
2092 getPropertyValue('font-variant');
2093
2094 /** Sets the value of "font-variant" */
2095 set fontVariant(String value) {
2096 setProperty('font-variant', value, '');
2097 }
2098
2099 /** Gets the value of "font-variant-ligatures" */
2100 String get fontVariantLigatures =>
2101 getPropertyValue('font-variant-ligatures');
2102
2103 /** Sets the value of "font-variant-ligatures" */
2104 set fontVariantLigatures(String value) {
2105 setProperty('font-variant-ligatures', value, '');
2106 }
2107
2108 /** Gets the value of "font-weight" */
2109 String get fontWeight =>
2110 getPropertyValue('font-weight');
2111
2112 /** Sets the value of "font-weight" */
2113 set fontWeight(String value) {
2114 setProperty('font-weight', value, '');
2115 }
2116
2117 /** Gets the value of "grid" */
2118 String get grid =>
2119 getPropertyValue('grid');
2120
2121 /** Sets the value of "grid" */
2122 set grid(String value) {
2123 setProperty('grid', value, '');
2124 }
2125
2126 /** Gets the value of "grid-area" */
2127 String get gridArea =>
2128 getPropertyValue('grid-area');
2129
2130 /** Sets the value of "grid-area" */
2131 set gridArea(String value) {
2132 setProperty('grid-area', value, '');
2133 }
2134
2135 /** Gets the value of "grid-auto-columns" */
2136 String get gridAutoColumns =>
2137 getPropertyValue('grid-auto-columns');
2138
2139 /** Sets the value of "grid-auto-columns" */
2140 set gridAutoColumns(String value) {
2141 setProperty('grid-auto-columns', value, '');
2142 }
2143
2144 /** Gets the value of "grid-auto-flow" */
2145 String get gridAutoFlow =>
2146 getPropertyValue('grid-auto-flow');
2147
2148 /** Sets the value of "grid-auto-flow" */
2149 set gridAutoFlow(String value) {
2150 setProperty('grid-auto-flow', value, '');
2151 }
2152
2153 /** Gets the value of "grid-auto-rows" */
2154 String get gridAutoRows =>
2155 getPropertyValue('grid-auto-rows');
2156
2157 /** Sets the value of "grid-auto-rows" */
2158 set gridAutoRows(String value) {
2159 setProperty('grid-auto-rows', value, '');
2160 }
2161
2162 /** Gets the value of "grid-column" */
2163 String get gridColumn =>
2164 getPropertyValue('grid-column');
2165
2166 /** Sets the value of "grid-column" */
2167 set gridColumn(String value) {
2168 setProperty('grid-column', value, '');
2169 }
2170
2171 /** Gets the value of "grid-column-end" */
2172 String get gridColumnEnd =>
2173 getPropertyValue('grid-column-end');
2174
2175 /** Sets the value of "grid-column-end" */
2176 set gridColumnEnd(String value) {
2177 setProperty('grid-column-end', value, '');
2178 }
2179
2180 /** Gets the value of "grid-column-start" */
2181 String get gridColumnStart =>
2182 getPropertyValue('grid-column-start');
2183
2184 /** Sets the value of "grid-column-start" */
2185 set gridColumnStart(String value) {
2186 setProperty('grid-column-start', value, '');
2187 }
2188
2189 /** Gets the value of "grid-row" */
2190 String get gridRow =>
2191 getPropertyValue('grid-row');
2192
2193 /** Sets the value of "grid-row" */
2194 set gridRow(String value) {
2195 setProperty('grid-row', value, '');
2196 }
2197
2198 /** Gets the value of "grid-row-end" */
2199 String get gridRowEnd =>
2200 getPropertyValue('grid-row-end');
2201
2202 /** Sets the value of "grid-row-end" */
2203 set gridRowEnd(String value) {
2204 setProperty('grid-row-end', value, '');
2205 }
2206
2207 /** Gets the value of "grid-row-start" */
2208 String get gridRowStart =>
2209 getPropertyValue('grid-row-start');
2210
2211 /** Sets the value of "grid-row-start" */
2212 set gridRowStart(String value) {
2213 setProperty('grid-row-start', value, '');
2214 }
2215
2216 /** Gets the value of "grid-template" */
2217 String get gridTemplate =>
2218 getPropertyValue('grid-template');
2219
2220 /** Sets the value of "grid-template" */
2221 set gridTemplate(String value) {
2222 setProperty('grid-template', value, '');
2223 }
2224
2225 /** Gets the value of "grid-template-areas" */
2226 String get gridTemplateAreas =>
2227 getPropertyValue('grid-template-areas');
2228
2229 /** Sets the value of "grid-template-areas" */
2230 set gridTemplateAreas(String value) {
2231 setProperty('grid-template-areas', value, '');
2232 }
2233
2234 /** Gets the value of "grid-template-columns" */
2235 String get gridTemplateColumns =>
2236 getPropertyValue('grid-template-columns');
2237
2238 /** Sets the value of "grid-template-columns" */
2239 set gridTemplateColumns(String value) {
2240 setProperty('grid-template-columns', value, '');
2241 }
2242
2243 /** Gets the value of "grid-template-rows" */
2244 String get gridTemplateRows =>
2245 getPropertyValue('grid-template-rows');
2246
2247 /** Sets the value of "grid-template-rows" */
2248 set gridTemplateRows(String value) {
2249 setProperty('grid-template-rows', value, '');
2250 }
2251
2252 /** Gets the value of "height" */
2253 String get height =>
2254 getPropertyValue('height');
2255
2256 /** Sets the value of "height" */
2257 set height(String value) {
2258 setProperty('height', value, '');
2259 }
2260
2261 /** Gets the value of "highlight" */
2262 String get highlight =>
2263 getPropertyValue('highlight');
2264
2265 /** Sets the value of "highlight" */
2266 set highlight(String value) {
2267 setProperty('highlight', value, '');
2268 }
2269
2270 /** Gets the value of "hyphenate-character" */
2271 String get hyphenateCharacter =>
2272 getPropertyValue('hyphenate-character');
2273
2274 /** Sets the value of "hyphenate-character" */
2275 set hyphenateCharacter(String value) {
2276 setProperty('hyphenate-character', value, '');
2277 }
2278
2279 /** Gets the value of "image-rendering" */
2280 String get imageRendering =>
2281 getPropertyValue('image-rendering');
2282
2283 /** Sets the value of "image-rendering" */
2284 set imageRendering(String value) {
2285 setProperty('image-rendering', value, '');
2286 }
2287
2288 /** Gets the value of "isolation" */
2289 String get isolation =>
2290 getPropertyValue('isolation');
2291
2292 /** Sets the value of "isolation" */
2293 set isolation(String value) {
2294 setProperty('isolation', value, '');
2295 }
2296
2297 /** Gets the value of "justify-content" */
2298 String get justifyContent =>
2299 getPropertyValue('justify-content');
2300
2301 /** Sets the value of "justify-content" */
2302 set justifyContent(String value) {
2303 setProperty('justify-content', value, '');
2304 }
2305
2306 /** Gets the value of "justify-self" */
2307 String get justifySelf =>
2308 getPropertyValue('justify-self');
2309
2310 /** Sets the value of "justify-self" */
2311 set justifySelf(String value) {
2312 setProperty('justify-self', value, '');
2313 }
2314
2315 /** Gets the value of "left" */
2316 String get left =>
2317 getPropertyValue('left');
2318
2319 /** Sets the value of "left" */
2320 set left(String value) {
2321 setProperty('left', value, '');
2322 }
2323
2324 /** Gets the value of "letter-spacing" */
2325 String get letterSpacing =>
2326 getPropertyValue('letter-spacing');
2327
2328 /** Sets the value of "letter-spacing" */
2329 set letterSpacing(String value) {
2330 setProperty('letter-spacing', value, '');
2331 }
2332
2333 /** Gets the value of "line-box-contain" */
2334 String get lineBoxContain =>
2335 getPropertyValue('line-box-contain');
2336
2337 /** Sets the value of "line-box-contain" */
2338 set lineBoxContain(String value) {
2339 setProperty('line-box-contain', value, '');
2340 }
2341
2342 /** Gets the value of "line-break" */
2343 String get lineBreak =>
2344 getPropertyValue('line-break');
2345
2346 /** Sets the value of "line-break" */
2347 set lineBreak(String value) {
2348 setProperty('line-break', value, '');
2349 }
2350
2351 /** Gets the value of "line-clamp" */
2352 String get lineClamp =>
2353 getPropertyValue('line-clamp');
2354
2355 /** Sets the value of "line-clamp" */
2356 set lineClamp(String value) {
2357 setProperty('line-clamp', value, '');
2358 }
2359
2360 /** Gets the value of "line-height" */
2361 String get lineHeight =>
2362 getPropertyValue('line-height');
2363
2364 /** Sets the value of "line-height" */
2365 set lineHeight(String value) {
2366 setProperty('line-height', value, '');
2367 }
2368
2369 /** Gets the value of "list-style" */
2370 String get listStyle =>
2371 getPropertyValue('list-style');
2372
2373 /** Sets the value of "list-style" */
2374 set listStyle(String value) {
2375 setProperty('list-style', value, '');
2376 }
2377
2378 /** Gets the value of "list-style-image" */
2379 String get listStyleImage =>
2380 getPropertyValue('list-style-image');
2381
2382 /** Sets the value of "list-style-image" */
2383 set listStyleImage(String value) {
2384 setProperty('list-style-image', value, '');
2385 }
2386
2387 /** Gets the value of "list-style-position" */
2388 String get listStylePosition =>
2389 getPropertyValue('list-style-position');
2390
2391 /** Sets the value of "list-style-position" */
2392 set listStylePosition(String value) {
2393 setProperty('list-style-position', value, '');
2394 }
2395
2396 /** Gets the value of "list-style-type" */
2397 String get listStyleType =>
2398 getPropertyValue('list-style-type');
2399
2400 /** Sets the value of "list-style-type" */
2401 set listStyleType(String value) {
2402 setProperty('list-style-type', value, '');
2403 }
2404
2405 /** Gets the value of "locale" */
2406 String get locale =>
2407 getPropertyValue('locale');
2408
2409 /** Sets the value of "locale" */
2410 set locale(String value) {
2411 setProperty('locale', value, '');
2412 }
2413
2414 /** Gets the value of "logical-height" */
2415 String get logicalHeight =>
2416 getPropertyValue('logical-height');
2417
2418 /** Sets the value of "logical-height" */
2419 set logicalHeight(String value) {
2420 setProperty('logical-height', value, '');
2421 }
2422
2423 /** Gets the value of "logical-width" */
2424 String get logicalWidth =>
2425 getPropertyValue('logical-width');
2426
2427 /** Sets the value of "logical-width" */
2428 set logicalWidth(String value) {
2429 setProperty('logical-width', value, '');
2430 }
2431
2432 /** Gets the value of "margin" */
2433 String get margin =>
2434 getPropertyValue('margin');
2435
2436 /** Sets the value of "margin" */
2437 set margin(String value) {
2438 setProperty('margin', value, '');
2439 }
2440
2441 /** Gets the value of "margin-after" */
2442 String get marginAfter =>
2443 getPropertyValue('margin-after');
2444
2445 /** Sets the value of "margin-after" */
2446 set marginAfter(String value) {
2447 setProperty('margin-after', value, '');
2448 }
2449
2450 /** Gets the value of "margin-after-collapse" */
2451 String get marginAfterCollapse =>
2452 getPropertyValue('margin-after-collapse');
2453
2454 /** Sets the value of "margin-after-collapse" */
2455 set marginAfterCollapse(String value) {
2456 setProperty('margin-after-collapse', value, '');
2457 }
2458
2459 /** Gets the value of "margin-before" */
2460 String get marginBefore =>
2461 getPropertyValue('margin-before');
2462
2463 /** Sets the value of "margin-before" */
2464 set marginBefore(String value) {
2465 setProperty('margin-before', value, '');
2466 }
2467
2468 /** Gets the value of "margin-before-collapse" */
2469 String get marginBeforeCollapse =>
2470 getPropertyValue('margin-before-collapse');
2471
2472 /** Sets the value of "margin-before-collapse" */
2473 set marginBeforeCollapse(String value) {
2474 setProperty('margin-before-collapse', value, '');
2475 }
2476
2477 /** Gets the value of "margin-bottom" */
2478 String get marginBottom =>
2479 getPropertyValue('margin-bottom');
2480
2481 /** Sets the value of "margin-bottom" */
2482 set marginBottom(String value) {
2483 setProperty('margin-bottom', value, '');
2484 }
2485
2486 /** Gets the value of "margin-bottom-collapse" */
2487 String get marginBottomCollapse =>
2488 getPropertyValue('margin-bottom-collapse');
2489
2490 /** Sets the value of "margin-bottom-collapse" */
2491 set marginBottomCollapse(String value) {
2492 setProperty('margin-bottom-collapse', value, '');
2493 }
2494
2495 /** Gets the value of "margin-collapse" */
2496 String get marginCollapse =>
2497 getPropertyValue('margin-collapse');
2498
2499 /** Sets the value of "margin-collapse" */
2500 set marginCollapse(String value) {
2501 setProperty('margin-collapse', value, '');
2502 }
2503
2504 /** Gets the value of "margin-end" */
2505 String get marginEnd =>
2506 getPropertyValue('margin-end');
2507
2508 /** Sets the value of "margin-end" */
2509 set marginEnd(String value) {
2510 setProperty('margin-end', value, '');
2511 }
2512
2513 /** Gets the value of "margin-left" */
2514 String get marginLeft =>
2515 getPropertyValue('margin-left');
2516
2517 /** Sets the value of "margin-left" */
2518 set marginLeft(String value) {
2519 setProperty('margin-left', value, '');
2520 }
2521
2522 /** Gets the value of "margin-right" */
2523 String get marginRight =>
2524 getPropertyValue('margin-right');
2525
2526 /** Sets the value of "margin-right" */
2527 set marginRight(String value) {
2528 setProperty('margin-right', value, '');
2529 }
2530
2531 /** Gets the value of "margin-start" */
2532 String get marginStart =>
2533 getPropertyValue('margin-start');
2534
2535 /** Sets the value of "margin-start" */
2536 set marginStart(String value) {
2537 setProperty('margin-start', value, '');
2538 }
2539
2540 /** Gets the value of "margin-top" */
2541 String get marginTop =>
2542 getPropertyValue('margin-top');
2543
2544 /** Sets the value of "margin-top" */
2545 set marginTop(String value) {
2546 setProperty('margin-top', value, '');
2547 }
2548
2549 /** Gets the value of "margin-top-collapse" */
2550 String get marginTopCollapse =>
2551 getPropertyValue('margin-top-collapse');
2552
2553 /** Sets the value of "margin-top-collapse" */
2554 set marginTopCollapse(String value) {
2555 setProperty('margin-top-collapse', value, '');
2556 }
2557
2558 /** Gets the value of "mask" */
2559 String get mask =>
2560 getPropertyValue('mask');
2561
2562 /** Sets the value of "mask" */
2563 set mask(String value) {
2564 setProperty('mask', value, '');
2565 }
2566
2567 /** Gets the value of "mask-box-image" */
2568 String get maskBoxImage =>
2569 getPropertyValue('mask-box-image');
2570
2571 /** Sets the value of "mask-box-image" */
2572 set maskBoxImage(String value) {
2573 setProperty('mask-box-image', value, '');
2574 }
2575
2576 /** Gets the value of "mask-box-image-outset" */
2577 String get maskBoxImageOutset =>
2578 getPropertyValue('mask-box-image-outset');
2579
2580 /** Sets the value of "mask-box-image-outset" */
2581 set maskBoxImageOutset(String value) {
2582 setProperty('mask-box-image-outset', value, '');
2583 }
2584
2585 /** Gets the value of "mask-box-image-repeat" */
2586 String get maskBoxImageRepeat =>
2587 getPropertyValue('mask-box-image-repeat');
2588
2589 /** Sets the value of "mask-box-image-repeat" */
2590 set maskBoxImageRepeat(String value) {
2591 setProperty('mask-box-image-repeat', value, '');
2592 }
2593
2594 /** Gets the value of "mask-box-image-slice" */
2595 String get maskBoxImageSlice =>
2596 getPropertyValue('mask-box-image-slice');
2597
2598 /** Sets the value of "mask-box-image-slice" */
2599 set maskBoxImageSlice(String value) {
2600 setProperty('mask-box-image-slice', value, '');
2601 }
2602
2603 /** Gets the value of "mask-box-image-source" */
2604 String get maskBoxImageSource =>
2605 getPropertyValue('mask-box-image-source');
2606
2607 /** Sets the value of "mask-box-image-source" */
2608 set maskBoxImageSource(String value) {
2609 setProperty('mask-box-image-source', value, '');
2610 }
2611
2612 /** Gets the value of "mask-box-image-width" */
2613 String get maskBoxImageWidth =>
2614 getPropertyValue('mask-box-image-width');
2615
2616 /** Sets the value of "mask-box-image-width" */
2617 set maskBoxImageWidth(String value) {
2618 setProperty('mask-box-image-width', value, '');
2619 }
2620
2621 /** Gets the value of "mask-clip" */
2622 String get maskClip =>
2623 getPropertyValue('mask-clip');
2624
2625 /** Sets the value of "mask-clip" */
2626 set maskClip(String value) {
2627 setProperty('mask-clip', value, '');
2628 }
2629
2630 /** Gets the value of "mask-composite" */
2631 String get maskComposite =>
2632 getPropertyValue('mask-composite');
2633
2634 /** Sets the value of "mask-composite" */
2635 set maskComposite(String value) {
2636 setProperty('mask-composite', value, '');
2637 }
2638
2639 /** Gets the value of "mask-image" */
2640 String get maskImage =>
2641 getPropertyValue('mask-image');
2642
2643 /** Sets the value of "mask-image" */
2644 set maskImage(String value) {
2645 setProperty('mask-image', value, '');
2646 }
2647
2648 /** Gets the value of "mask-origin" */
2649 String get maskOrigin =>
2650 getPropertyValue('mask-origin');
2651
2652 /** Sets the value of "mask-origin" */
2653 set maskOrigin(String value) {
2654 setProperty('mask-origin', value, '');
2655 }
2656
2657 /** Gets the value of "mask-position" */
2658 String get maskPosition =>
2659 getPropertyValue('mask-position');
2660
2661 /** Sets the value of "mask-position" */
2662 set maskPosition(String value) {
2663 setProperty('mask-position', value, '');
2664 }
2665
2666 /** Gets the value of "mask-position-x" */
2667 String get maskPositionX =>
2668 getPropertyValue('mask-position-x');
2669
2670 /** Sets the value of "mask-position-x" */
2671 set maskPositionX(String value) {
2672 setProperty('mask-position-x', value, '');
2673 }
2674
2675 /** Gets the value of "mask-position-y" */
2676 String get maskPositionY =>
2677 getPropertyValue('mask-position-y');
2678
2679 /** Sets the value of "mask-position-y" */
2680 set maskPositionY(String value) {
2681 setProperty('mask-position-y', value, '');
2682 }
2683
2684 /** Gets the value of "mask-repeat" */
2685 String get maskRepeat =>
2686 getPropertyValue('mask-repeat');
2687
2688 /** Sets the value of "mask-repeat" */
2689 set maskRepeat(String value) {
2690 setProperty('mask-repeat', value, '');
2691 }
2692
2693 /** Gets the value of "mask-repeat-x" */
2694 String get maskRepeatX =>
2695 getPropertyValue('mask-repeat-x');
2696
2697 /** Sets the value of "mask-repeat-x" */
2698 set maskRepeatX(String value) {
2699 setProperty('mask-repeat-x', value, '');
2700 }
2701
2702 /** Gets the value of "mask-repeat-y" */
2703 String get maskRepeatY =>
2704 getPropertyValue('mask-repeat-y');
2705
2706 /** Sets the value of "mask-repeat-y" */
2707 set maskRepeatY(String value) {
2708 setProperty('mask-repeat-y', value, '');
2709 }
2710
2711 /** Gets the value of "mask-size" */
2712 String get maskSize =>
2713 getPropertyValue('mask-size');
2714
2715 /** Sets the value of "mask-size" */
2716 set maskSize(String value) {
2717 setProperty('mask-size', value, '');
2718 }
2719
2720 /** Gets the value of "mask-source-type" */
2721 String get maskSourceType =>
2722 getPropertyValue('mask-source-type');
2723
2724 /** Sets the value of "mask-source-type" */
2725 set maskSourceType(String value) {
2726 setProperty('mask-source-type', value, '');
2727 }
2728
2729 /** Gets the value of "max-height" */
2730 String get maxHeight =>
2731 getPropertyValue('max-height');
2732
2733 /** Sets the value of "max-height" */
2734 set maxHeight(String value) {
2735 setProperty('max-height', value, '');
2736 }
2737
2738 /** Gets the value of "max-logical-height" */
2739 String get maxLogicalHeight =>
2740 getPropertyValue('max-logical-height');
2741
2742 /** Sets the value of "max-logical-height" */
2743 set maxLogicalHeight(String value) {
2744 setProperty('max-logical-height', value, '');
2745 }
2746
2747 /** Gets the value of "max-logical-width" */
2748 String get maxLogicalWidth =>
2749 getPropertyValue('max-logical-width');
2750
2751 /** Sets the value of "max-logical-width" */
2752 set maxLogicalWidth(String value) {
2753 setProperty('max-logical-width', value, '');
2754 }
2755
2756 /** Gets the value of "max-width" */
2757 String get maxWidth =>
2758 getPropertyValue('max-width');
2759
2760 /** Sets the value of "max-width" */
2761 set maxWidth(String value) {
2762 setProperty('max-width', value, '');
2763 }
2764
2765 /** Gets the value of "max-zoom" */
2766 String get maxZoom =>
2767 getPropertyValue('max-zoom');
2768
2769 /** Sets the value of "max-zoom" */
2770 set maxZoom(String value) {
2771 setProperty('max-zoom', value, '');
2772 }
2773
2774 /** Gets the value of "min-height" */
2775 String get minHeight =>
2776 getPropertyValue('min-height');
2777
2778 /** Sets the value of "min-height" */
2779 set minHeight(String value) {
2780 setProperty('min-height', value, '');
2781 }
2782
2783 /** Gets the value of "min-logical-height" */
2784 String get minLogicalHeight =>
2785 getPropertyValue('min-logical-height');
2786
2787 /** Sets the value of "min-logical-height" */
2788 set minLogicalHeight(String value) {
2789 setProperty('min-logical-height', value, '');
2790 }
2791
2792 /** Gets the value of "min-logical-width" */
2793 String get minLogicalWidth =>
2794 getPropertyValue('min-logical-width');
2795
2796 /** Sets the value of "min-logical-width" */
2797 set minLogicalWidth(String value) {
2798 setProperty('min-logical-width', value, '');
2799 }
2800
2801 /** Gets the value of "min-width" */
2802 String get minWidth =>
2803 getPropertyValue('min-width');
2804
2805 /** Sets the value of "min-width" */
2806 set minWidth(String value) {
2807 setProperty('min-width', value, '');
2808 }
2809
2810 /** Gets the value of "min-zoom" */
2811 String get minZoom =>
2812 getPropertyValue('min-zoom');
2813
2814 /** Sets the value of "min-zoom" */
2815 set minZoom(String value) {
2816 setProperty('min-zoom', value, '');
2817 }
2818
2819 /** Gets the value of "mix-blend-mode" */
2820 String get mixBlendMode =>
2821 getPropertyValue('mix-blend-mode');
2822
2823 /** Sets the value of "mix-blend-mode" */
2824 set mixBlendMode(String value) {
2825 setProperty('mix-blend-mode', value, '');
2826 }
2827
2828 /** Gets the value of "object-fit" */
2829 String get objectFit =>
2830 getPropertyValue('object-fit');
2831
2832 /** Sets the value of "object-fit" */
2833 set objectFit(String value) {
2834 setProperty('object-fit', value, '');
2835 }
2836
2837 /** Gets the value of "object-position" */
2838 String get objectPosition =>
2839 getPropertyValue('object-position');
2840
2841 /** Sets the value of "object-position" */
2842 set objectPosition(String value) {
2843 setProperty('object-position', value, '');
2844 }
2845
2846 /** Gets the value of "opacity" */
2847 String get opacity =>
2848 getPropertyValue('opacity');
2849
2850 /** Sets the value of "opacity" */
2851 set opacity(String value) {
2852 setProperty('opacity', value, '');
2853 }
2854
2855 /** Gets the value of "order" */
2856 String get order =>
2857 getPropertyValue('order');
2858
2859 /** Sets the value of "order" */
2860 set order(String value) {
2861 setProperty('order', value, '');
2862 }
2863
2864 /** Gets the value of "orientation" */
2865 String get orientation =>
2866 getPropertyValue('orientation');
2867
2868 /** Sets the value of "orientation" */
2869 set orientation(String value) {
2870 setProperty('orientation', value, '');
2871 }
2872
2873 /** Gets the value of "orphans" */
2874 String get orphans =>
2875 getPropertyValue('orphans');
2876
2877 /** Sets the value of "orphans" */
2878 set orphans(String value) {
2879 setProperty('orphans', value, '');
2880 }
2881
2882 /** Gets the value of "outline" */
2883 String get outline =>
2884 getPropertyValue('outline');
2885
2886 /** Sets the value of "outline" */
2887 set outline(String value) {
2888 setProperty('outline', value, '');
2889 }
2890
2891 /** Gets the value of "outline-color" */
2892 String get outlineColor =>
2893 getPropertyValue('outline-color');
2894
2895 /** Sets the value of "outline-color" */
2896 set outlineColor(String value) {
2897 setProperty('outline-color', value, '');
2898 }
2899
2900 /** Gets the value of "outline-offset" */
2901 String get outlineOffset =>
2902 getPropertyValue('outline-offset');
2903
2904 /** Sets the value of "outline-offset" */
2905 set outlineOffset(String value) {
2906 setProperty('outline-offset', value, '');
2907 }
2908
2909 /** Gets the value of "outline-style" */
2910 String get outlineStyle =>
2911 getPropertyValue('outline-style');
2912
2913 /** Sets the value of "outline-style" */
2914 set outlineStyle(String value) {
2915 setProperty('outline-style', value, '');
2916 }
2917
2918 /** Gets the value of "outline-width" */
2919 String get outlineWidth =>
2920 getPropertyValue('outline-width');
2921
2922 /** Sets the value of "outline-width" */
2923 set outlineWidth(String value) {
2924 setProperty('outline-width', value, '');
2925 }
2926
2927 /** Gets the value of "overflow" */
2928 String get overflow =>
2929 getPropertyValue('overflow');
2930
2931 /** Sets the value of "overflow" */
2932 set overflow(String value) {
2933 setProperty('overflow', value, '');
2934 }
2935
2936 /** Gets the value of "overflow-wrap" */
2937 String get overflowWrap =>
2938 getPropertyValue('overflow-wrap');
2939
2940 /** Sets the value of "overflow-wrap" */
2941 set overflowWrap(String value) {
2942 setProperty('overflow-wrap', value, '');
2943 }
2944
2945 /** Gets the value of "overflow-x" */
2946 String get overflowX =>
2947 getPropertyValue('overflow-x');
2948
2949 /** Sets the value of "overflow-x" */
2950 set overflowX(String value) {
2951 setProperty('overflow-x', value, '');
2952 }
2953
2954 /** Gets the value of "overflow-y" */
2955 String get overflowY =>
2956 getPropertyValue('overflow-y');
2957
2958 /** Sets the value of "overflow-y" */
2959 set overflowY(String value) {
2960 setProperty('overflow-y', value, '');
2961 }
2962
2963 /** Gets the value of "padding" */
2964 String get padding =>
2965 getPropertyValue('padding');
2966
2967 /** Sets the value of "padding" */
2968 set padding(String value) {
2969 setProperty('padding', value, '');
2970 }
2971
2972 /** Gets the value of "padding-after" */
2973 String get paddingAfter =>
2974 getPropertyValue('padding-after');
2975
2976 /** Sets the value of "padding-after" */
2977 set paddingAfter(String value) {
2978 setProperty('padding-after', value, '');
2979 }
2980
2981 /** Gets the value of "padding-before" */
2982 String get paddingBefore =>
2983 getPropertyValue('padding-before');
2984
2985 /** Sets the value of "padding-before" */
2986 set paddingBefore(String value) {
2987 setProperty('padding-before', value, '');
2988 }
2989
2990 /** Gets the value of "padding-bottom" */
2991 String get paddingBottom =>
2992 getPropertyValue('padding-bottom');
2993
2994 /** Sets the value of "padding-bottom" */
2995 set paddingBottom(String value) {
2996 setProperty('padding-bottom', value, '');
2997 }
2998
2999 /** Gets the value of "padding-end" */
3000 String get paddingEnd =>
3001 getPropertyValue('padding-end');
3002
3003 /** Sets the value of "padding-end" */
3004 set paddingEnd(String value) {
3005 setProperty('padding-end', value, '');
3006 }
3007
3008 /** Gets the value of "padding-left" */
3009 String get paddingLeft =>
3010 getPropertyValue('padding-left');
3011
3012 /** Sets the value of "padding-left" */
3013 set paddingLeft(String value) {
3014 setProperty('padding-left', value, '');
3015 }
3016
3017 /** Gets the value of "padding-right" */
3018 String get paddingRight =>
3019 getPropertyValue('padding-right');
3020
3021 /** Sets the value of "padding-right" */
3022 set paddingRight(String value) {
3023 setProperty('padding-right', value, '');
3024 }
3025
3026 /** Gets the value of "padding-start" */
3027 String get paddingStart =>
3028 getPropertyValue('padding-start');
3029
3030 /** Sets the value of "padding-start" */
3031 set paddingStart(String value) {
3032 setProperty('padding-start', value, '');
3033 }
3034
3035 /** Gets the value of "padding-top" */
3036 String get paddingTop =>
3037 getPropertyValue('padding-top');
3038
3039 /** Sets the value of "padding-top" */
3040 set paddingTop(String value) {
3041 setProperty('padding-top', value, '');
3042 }
3043
3044 /** Gets the value of "page" */
3045 String get page =>
3046 getPropertyValue('page');
3047
3048 /** Sets the value of "page" */
3049 set page(String value) {
3050 setProperty('page', value, '');
3051 }
3052
3053 /** Gets the value of "page-break-after" */
3054 String get pageBreakAfter =>
3055 getPropertyValue('page-break-after');
3056
3057 /** Sets the value of "page-break-after" */
3058 set pageBreakAfter(String value) {
3059 setProperty('page-break-after', value, '');
3060 }
3061
3062 /** Gets the value of "page-break-before" */
3063 String get pageBreakBefore =>
3064 getPropertyValue('page-break-before');
3065
3066 /** Sets the value of "page-break-before" */
3067 set pageBreakBefore(String value) {
3068 setProperty('page-break-before', value, '');
3069 }
3070
3071 /** Gets the value of "page-break-inside" */
3072 String get pageBreakInside =>
3073 getPropertyValue('page-break-inside');
3074
3075 /** Sets the value of "page-break-inside" */
3076 set pageBreakInside(String value) {
3077 setProperty('page-break-inside', value, '');
3078 }
3079
3080 /** Gets the value of "perspective" */
3081 String get perspective =>
3082 getPropertyValue('perspective');
3083
3084 /** Sets the value of "perspective" */
3085 set perspective(String value) {
3086 setProperty('perspective', value, '');
3087 }
3088
3089 /** Gets the value of "perspective-origin" */
3090 String get perspectiveOrigin =>
3091 getPropertyValue('perspective-origin');
3092
3093 /** Sets the value of "perspective-origin" */
3094 set perspectiveOrigin(String value) {
3095 setProperty('perspective-origin', value, '');
3096 }
3097
3098 /** Gets the value of "perspective-origin-x" */
3099 String get perspectiveOriginX =>
3100 getPropertyValue('perspective-origin-x');
3101
3102 /** Sets the value of "perspective-origin-x" */
3103 set perspectiveOriginX(String value) {
3104 setProperty('perspective-origin-x', value, '');
3105 }
3106
3107 /** Gets the value of "perspective-origin-y" */
3108 String get perspectiveOriginY =>
3109 getPropertyValue('perspective-origin-y');
3110
3111 /** Sets the value of "perspective-origin-y" */
3112 set perspectiveOriginY(String value) {
3113 setProperty('perspective-origin-y', value, '');
3114 }
3115
3116 /** Gets the value of "pointer-events" */
3117 String get pointerEvents =>
3118 getPropertyValue('pointer-events');
3119
3120 /** Sets the value of "pointer-events" */
3121 set pointerEvents(String value) {
3122 setProperty('pointer-events', value, '');
3123 }
3124
3125 /** Gets the value of "position" */
3126 String get position =>
3127 getPropertyValue('position');
3128
3129 /** Sets the value of "position" */
3130 set position(String value) {
3131 setProperty('position', value, '');
3132 }
3133
3134 /** Gets the value of "print-color-adjust" */
3135 String get printColorAdjust =>
3136 getPropertyValue('print-color-adjust');
3137
3138 /** Sets the value of "print-color-adjust" */
3139 set printColorAdjust(String value) {
3140 setProperty('print-color-adjust', value, '');
3141 }
3142
3143 /** Gets the value of "quotes" */
3144 String get quotes =>
3145 getPropertyValue('quotes');
3146
3147 /** Sets the value of "quotes" */
3148 set quotes(String value) {
3149 setProperty('quotes', value, '');
3150 }
3151
3152 /** Gets the value of "resize" */
3153 String get resize =>
3154 getPropertyValue('resize');
3155
3156 /** Sets the value of "resize" */
3157 set resize(String value) {
3158 setProperty('resize', value, '');
3159 }
3160
3161 /** Gets the value of "right" */
3162 String get right =>
3163 getPropertyValue('right');
3164
3165 /** Sets the value of "right" */
3166 set right(String value) {
3167 setProperty('right', value, '');
3168 }
3169
3170 /** Gets the value of "rtl-ordering" */
3171 String get rtlOrdering =>
3172 getPropertyValue('rtl-ordering');
3173
3174 /** Sets the value of "rtl-ordering" */
3175 set rtlOrdering(String value) {
3176 setProperty('rtl-ordering', value, '');
3177 }
3178
3179 /** Gets the value of "ruby-position" */
3180 String get rubyPosition =>
3181 getPropertyValue('ruby-position');
3182
3183 /** Sets the value of "ruby-position" */
3184 set rubyPosition(String value) {
3185 setProperty('ruby-position', value, '');
3186 }
3187
3188 /** Gets the value of "scroll-behavior" */
3189 String get scrollBehavior =>
3190 getPropertyValue('scroll-behavior');
3191
3192 /** Sets the value of "scroll-behavior" */
3193 set scrollBehavior(String value) {
3194 setProperty('scroll-behavior', value, '');
3195 }
3196
3197 /** Gets the value of "shape-image-threshold" */
3198 String get shapeImageThreshold =>
3199 getPropertyValue('shape-image-threshold');
3200
3201 /** Sets the value of "shape-image-threshold" */
3202 set shapeImageThreshold(String value) {
3203 setProperty('shape-image-threshold', value, '');
3204 }
3205
3206 /** Gets the value of "shape-margin" */
3207 String get shapeMargin =>
3208 getPropertyValue('shape-margin');
3209
3210 /** Sets the value of "shape-margin" */
3211 set shapeMargin(String value) {
3212 setProperty('shape-margin', value, '');
3213 }
3214
3215 /** Gets the value of "shape-outside" */
3216 String get shapeOutside =>
3217 getPropertyValue('shape-outside');
3218
3219 /** Sets the value of "shape-outside" */
3220 set shapeOutside(String value) {
3221 setProperty('shape-outside', value, '');
3222 }
3223
3224 /** Gets the value of "size" */
3225 String get size =>
3226 getPropertyValue('size');
3227
3228 /** Sets the value of "size" */
3229 set size(String value) {
3230 setProperty('size', value, '');
3231 }
3232
3233 /** Gets the value of "speak" */
3234 String get speak =>
3235 getPropertyValue('speak');
3236
3237 /** Sets the value of "speak" */
3238 set speak(String value) {
3239 setProperty('speak', value, '');
3240 }
3241
3242 /** Gets the value of "src" */
3243 String get src =>
3244 getPropertyValue('src');
3245
3246 /** Sets the value of "src" */
3247 set src(String value) {
3248 setProperty('src', value, '');
3249 }
3250
3251 /** Gets the value of "tab-size" */
3252 String get tabSize =>
3253 getPropertyValue('tab-size');
3254
3255 /** Sets the value of "tab-size" */
3256 set tabSize(String value) {
3257 setProperty('tab-size', value, '');
3258 }
3259
3260 /** Gets the value of "table-layout" */
3261 String get tableLayout =>
3262 getPropertyValue('table-layout');
3263
3264 /** Sets the value of "table-layout" */
3265 set tableLayout(String value) {
3266 setProperty('table-layout', value, '');
3267 }
3268
3269 /** Gets the value of "tap-highlight-color" */
3270 String get tapHighlightColor =>
3271 getPropertyValue('tap-highlight-color');
3272
3273 /** Sets the value of "tap-highlight-color" */
3274 set tapHighlightColor(String value) {
3275 setProperty('tap-highlight-color', value, '');
3276 }
3277
3278 /** Gets the value of "text-align" */
3279 String get textAlign =>
3280 getPropertyValue('text-align');
3281
3282 /** Sets the value of "text-align" */
3283 set textAlign(String value) {
3284 setProperty('text-align', value, '');
3285 }
3286
3287 /** Gets the value of "text-align-last" */
3288 String get textAlignLast =>
3289 getPropertyValue('text-align-last');
3290
3291 /** Sets the value of "text-align-last" */
3292 set textAlignLast(String value) {
3293 setProperty('text-align-last', value, '');
3294 }
3295
3296 /** Gets the value of "text-combine" */
3297 String get textCombine =>
3298 getPropertyValue('text-combine');
3299
3300 /** Sets the value of "text-combine" */
3301 set textCombine(String value) {
3302 setProperty('text-combine', value, '');
3303 }
3304
3305 /** Gets the value of "text-decoration" */
3306 String get textDecoration =>
3307 getPropertyValue('text-decoration');
3308
3309 /** Sets the value of "text-decoration" */
3310 set textDecoration(String value) {
3311 setProperty('text-decoration', value, '');
3312 }
3313
3314 /** Gets the value of "text-decoration-color" */
3315 String get textDecorationColor =>
3316 getPropertyValue('text-decoration-color');
3317
3318 /** Sets the value of "text-decoration-color" */
3319 set textDecorationColor(String value) {
3320 setProperty('text-decoration-color', value, '');
3321 }
3322
3323 /** Gets the value of "text-decoration-line" */
3324 String get textDecorationLine =>
3325 getPropertyValue('text-decoration-line');
3326
3327 /** Sets the value of "text-decoration-line" */
3328 set textDecorationLine(String value) {
3329 setProperty('text-decoration-line', value, '');
3330 }
3331
3332 /** Gets the value of "text-decoration-style" */
3333 String get textDecorationStyle =>
3334 getPropertyValue('text-decoration-style');
3335
3336 /** Sets the value of "text-decoration-style" */
3337 set textDecorationStyle(String value) {
3338 setProperty('text-decoration-style', value, '');
3339 }
3340
3341 /** Gets the value of "text-decorations-in-effect" */
3342 String get textDecorationsInEffect =>
3343 getPropertyValue('text-decorations-in-effect');
3344
3345 /** Sets the value of "text-decorations-in-effect" */
3346 set textDecorationsInEffect(String value) {
3347 setProperty('text-decorations-in-effect', value, '');
3348 }
3349
3350 /** Gets the value of "text-emphasis" */
3351 String get textEmphasis =>
3352 getPropertyValue('text-emphasis');
3353
3354 /** Sets the value of "text-emphasis" */
3355 set textEmphasis(String value) {
3356 setProperty('text-emphasis', value, '');
3357 }
3358
3359 /** Gets the value of "text-emphasis-color" */
3360 String get textEmphasisColor =>
3361 getPropertyValue('text-emphasis-color');
3362
3363 /** Sets the value of "text-emphasis-color" */
3364 set textEmphasisColor(String value) {
3365 setProperty('text-emphasis-color', value, '');
3366 }
3367
3368 /** Gets the value of "text-emphasis-position" */
3369 String get textEmphasisPosition =>
3370 getPropertyValue('text-emphasis-position');
3371
3372 /** Sets the value of "text-emphasis-position" */
3373 set textEmphasisPosition(String value) {
3374 setProperty('text-emphasis-position', value, '');
3375 }
3376
3377 /** Gets the value of "text-emphasis-style" */
3378 String get textEmphasisStyle =>
3379 getPropertyValue('text-emphasis-style');
3380
3381 /** Sets the value of "text-emphasis-style" */
3382 set textEmphasisStyle(String value) {
3383 setProperty('text-emphasis-style', value, '');
3384 }
3385
3386 /** Gets the value of "text-fill-color" */
3387 String get textFillColor =>
3388 getPropertyValue('text-fill-color');
3389
3390 /** Sets the value of "text-fill-color" */
3391 set textFillColor(String value) {
3392 setProperty('text-fill-color', value, '');
3393 }
3394
3395 /** Gets the value of "text-indent" */
3396 String get textIndent =>
3397 getPropertyValue('text-indent');
3398
3399 /** Sets the value of "text-indent" */
3400 set textIndent(String value) {
3401 setProperty('text-indent', value, '');
3402 }
3403
3404 /** Gets the value of "text-justify" */
3405 String get textJustify =>
3406 getPropertyValue('text-justify');
3407
3408 /** Sets the value of "text-justify" */
3409 set textJustify(String value) {
3410 setProperty('text-justify', value, '');
3411 }
3412
3413 /** Gets the value of "text-line-through-color" */
3414 String get textLineThroughColor =>
3415 getPropertyValue('text-line-through-color');
3416
3417 /** Sets the value of "text-line-through-color" */
3418 set textLineThroughColor(String value) {
3419 setProperty('text-line-through-color', value, '');
3420 }
3421
3422 /** Gets the value of "text-line-through-mode" */
3423 String get textLineThroughMode =>
3424 getPropertyValue('text-line-through-mode');
3425
3426 /** Sets the value of "text-line-through-mode" */
3427 set textLineThroughMode(String value) {
3428 setProperty('text-line-through-mode', value, '');
3429 }
3430
3431 /** Gets the value of "text-line-through-style" */
3432 String get textLineThroughStyle =>
3433 getPropertyValue('text-line-through-style');
3434
3435 /** Sets the value of "text-line-through-style" */
3436 set textLineThroughStyle(String value) {
3437 setProperty('text-line-through-style', value, '');
3438 }
3439
3440 /** Gets the value of "text-line-through-width" */
3441 String get textLineThroughWidth =>
3442 getPropertyValue('text-line-through-width');
3443
3444 /** Sets the value of "text-line-through-width" */
3445 set textLineThroughWidth(String value) {
3446 setProperty('text-line-through-width', value, '');
3447 }
3448
3449 /** Gets the value of "text-orientation" */
3450 String get textOrientation =>
3451 getPropertyValue('text-orientation');
3452
3453 /** Sets the value of "text-orientation" */
3454 set textOrientation(String value) {
3455 setProperty('text-orientation', value, '');
3456 }
3457
3458 /** Gets the value of "text-overflow" */
3459 String get textOverflow =>
3460 getPropertyValue('text-overflow');
3461
3462 /** Sets the value of "text-overflow" */
3463 set textOverflow(String value) {
3464 setProperty('text-overflow', value, '');
3465 }
3466
3467 /** Gets the value of "text-overline-color" */
3468 String get textOverlineColor =>
3469 getPropertyValue('text-overline-color');
3470
3471 /** Sets the value of "text-overline-color" */
3472 set textOverlineColor(String value) {
3473 setProperty('text-overline-color', value, '');
3474 }
3475
3476 /** Gets the value of "text-overline-mode" */
3477 String get textOverlineMode =>
3478 getPropertyValue('text-overline-mode');
3479
3480 /** Sets the value of "text-overline-mode" */
3481 set textOverlineMode(String value) {
3482 setProperty('text-overline-mode', value, '');
3483 }
3484
3485 /** Gets the value of "text-overline-style" */
3486 String get textOverlineStyle =>
3487 getPropertyValue('text-overline-style');
3488
3489 /** Sets the value of "text-overline-style" */
3490 set textOverlineStyle(String value) {
3491 setProperty('text-overline-style', value, '');
3492 }
3493
3494 /** Gets the value of "text-overline-width" */
3495 String get textOverlineWidth =>
3496 getPropertyValue('text-overline-width');
3497
3498 /** Sets the value of "text-overline-width" */
3499 set textOverlineWidth(String value) {
3500 setProperty('text-overline-width', value, '');
3501 }
3502
3503 /** Gets the value of "text-rendering" */
3504 String get textRendering =>
3505 getPropertyValue('text-rendering');
3506
3507 /** Sets the value of "text-rendering" */
3508 set textRendering(String value) {
3509 setProperty('text-rendering', value, '');
3510 }
3511
3512 /** Gets the value of "text-security" */
3513 String get textSecurity =>
3514 getPropertyValue('text-security');
3515
3516 /** Sets the value of "text-security" */
3517 set textSecurity(String value) {
3518 setProperty('text-security', value, '');
3519 }
3520
3521 /** Gets the value of "text-shadow" */
3522 String get textShadow =>
3523 getPropertyValue('text-shadow');
3524
3525 /** Sets the value of "text-shadow" */
3526 set textShadow(String value) {
3527 setProperty('text-shadow', value, '');
3528 }
3529
3530 /** Gets the value of "text-stroke" */
3531 String get textStroke =>
3532 getPropertyValue('text-stroke');
3533
3534 /** Sets the value of "text-stroke" */
3535 set textStroke(String value) {
3536 setProperty('text-stroke', value, '');
3537 }
3538
3539 /** Gets the value of "text-stroke-color" */
3540 String get textStrokeColor =>
3541 getPropertyValue('text-stroke-color');
3542
3543 /** Sets the value of "text-stroke-color" */
3544 set textStrokeColor(String value) {
3545 setProperty('text-stroke-color', value, '');
3546 }
3547
3548 /** Gets the value of "text-stroke-width" */
3549 String get textStrokeWidth =>
3550 getPropertyValue('text-stroke-width');
3551
3552 /** Sets the value of "text-stroke-width" */
3553 set textStrokeWidth(String value) {
3554 setProperty('text-stroke-width', value, '');
3555 }
3556
3557 /** Gets the value of "text-transform" */
3558 String get textTransform =>
3559 getPropertyValue('text-transform');
3560
3561 /** Sets the value of "text-transform" */
3562 set textTransform(String value) {
3563 setProperty('text-transform', value, '');
3564 }
3565
3566 /** Gets the value of "text-underline-color" */
3567 String get textUnderlineColor =>
3568 getPropertyValue('text-underline-color');
3569
3570 /** Sets the value of "text-underline-color" */
3571 set textUnderlineColor(String value) {
3572 setProperty('text-underline-color', value, '');
3573 }
3574
3575 /** Gets the value of "text-underline-mode" */
3576 String get textUnderlineMode =>
3577 getPropertyValue('text-underline-mode');
3578
3579 /** Sets the value of "text-underline-mode" */
3580 set textUnderlineMode(String value) {
3581 setProperty('text-underline-mode', value, '');
3582 }
3583
3584 /** Gets the value of "text-underline-position" */
3585 String get textUnderlinePosition =>
3586 getPropertyValue('text-underline-position');
3587
3588 /** Sets the value of "text-underline-position" */
3589 set textUnderlinePosition(String value) {
3590 setProperty('text-underline-position', value, '');
3591 }
3592
3593 /** Gets the value of "text-underline-style" */
3594 String get textUnderlineStyle =>
3595 getPropertyValue('text-underline-style');
3596
3597 /** Sets the value of "text-underline-style" */
3598 set textUnderlineStyle(String value) {
3599 setProperty('text-underline-style', value, '');
3600 }
3601
3602 /** Gets the value of "text-underline-width" */
3603 String get textUnderlineWidth =>
3604 getPropertyValue('text-underline-width');
3605
3606 /** Sets the value of "text-underline-width" */
3607 set textUnderlineWidth(String value) {
3608 setProperty('text-underline-width', value, '');
3609 }
3610
3611 /** Gets the value of "top" */
3612 String get top =>
3613 getPropertyValue('top');
3614
3615 /** Sets the value of "top" */
3616 set top(String value) {
3617 setProperty('top', value, '');
3618 }
3619
3620 /** Gets the value of "touch-action" */
3621 String get touchAction =>
3622 getPropertyValue('touch-action');
3623
3624 /** Sets the value of "touch-action" */
3625 set touchAction(String value) {
3626 setProperty('touch-action', value, '');
3627 }
3628
3629 /** Gets the value of "touch-action-delay" */
3630 String get touchActionDelay =>
3631 getPropertyValue('touch-action-delay');
3632
3633 /** Sets the value of "touch-action-delay" */
3634 set touchActionDelay(String value) {
3635 setProperty('touch-action-delay', value, '');
3636 }
3637
3638 /** Gets the value of "transform" */
3639 String get transform =>
3640 getPropertyValue('transform');
3641
3642 /** Sets the value of "transform" */
3643 set transform(String value) {
3644 setProperty('transform', value, '');
3645 }
3646
3647 /** Gets the value of "transform-origin" */
3648 String get transformOrigin =>
3649 getPropertyValue('transform-origin');
3650
3651 /** Sets the value of "transform-origin" */
3652 set transformOrigin(String value) {
3653 setProperty('transform-origin', value, '');
3654 }
3655
3656 /** Gets the value of "transform-origin-x" */
3657 String get transformOriginX =>
3658 getPropertyValue('transform-origin-x');
3659
3660 /** Sets the value of "transform-origin-x" */
3661 set transformOriginX(String value) {
3662 setProperty('transform-origin-x', value, '');
3663 }
3664
3665 /** Gets the value of "transform-origin-y" */
3666 String get transformOriginY =>
3667 getPropertyValue('transform-origin-y');
3668
3669 /** Sets the value of "transform-origin-y" */
3670 set transformOriginY(String value) {
3671 setProperty('transform-origin-y', value, '');
3672 }
3673
3674 /** Gets the value of "transform-origin-z" */
3675 String get transformOriginZ =>
3676 getPropertyValue('transform-origin-z');
3677
3678 /** Sets the value of "transform-origin-z" */
3679 set transformOriginZ(String value) {
3680 setProperty('transform-origin-z', value, '');
3681 }
3682
3683 /** Gets the value of "transform-style" */
3684 String get transformStyle =>
3685 getPropertyValue('transform-style');
3686
3687 /** Sets the value of "transform-style" */
3688 set transformStyle(String value) {
3689 setProperty('transform-style', value, '');
3690 }
3691
3692 /** Gets the value of "transition" */@SupportedBrowser(SupportedBrowser.CHROME )
3693 @SupportedBrowser(SupportedBrowser.FIREFOX)
3694 @SupportedBrowser(SupportedBrowser.IE, '10')
3695 @SupportedBrowser(SupportedBrowser.SAFARI)
3696 String get transition =>
3697 getPropertyValue('transition');
3698
3699 /** Sets the value of "transition" */@SupportedBrowser(SupportedBrowser.CHROME )
3700 @SupportedBrowser(SupportedBrowser.FIREFOX)
3701 @SupportedBrowser(SupportedBrowser.IE, '10')
3702 @SupportedBrowser(SupportedBrowser.SAFARI)
3703 set transition(String value) {
3704 setProperty('transition', value, '');
3705 }
3706
3707 /** Gets the value of "transition-delay" */
3708 String get transitionDelay =>
3709 getPropertyValue('transition-delay');
3710
3711 /** Sets the value of "transition-delay" */
3712 set transitionDelay(String value) {
3713 setProperty('transition-delay', value, '');
3714 }
3715
3716 /** Gets the value of "transition-duration" */
3717 String get transitionDuration =>
3718 getPropertyValue('transition-duration');
3719
3720 /** Sets the value of "transition-duration" */
3721 set transitionDuration(String value) {
3722 setProperty('transition-duration', value, '');
3723 }
3724
3725 /** Gets the value of "transition-property" */
3726 String get transitionProperty =>
3727 getPropertyValue('transition-property');
3728
3729 /** Sets the value of "transition-property" */
3730 set transitionProperty(String value) {
3731 setProperty('transition-property', value, '');
3732 }
3733
3734 /** Gets the value of "transition-timing-function" */
3735 String get transitionTimingFunction =>
3736 getPropertyValue('transition-timing-function');
3737
3738 /** Sets the value of "transition-timing-function" */
3739 set transitionTimingFunction(String value) {
3740 setProperty('transition-timing-function', value, '');
3741 }
3742
3743 /** Gets the value of "unicode-bidi" */
3744 String get unicodeBidi =>
3745 getPropertyValue('unicode-bidi');
3746
3747 /** Sets the value of "unicode-bidi" */
3748 set unicodeBidi(String value) {
3749 setProperty('unicode-bidi', value, '');
3750 }
3751
3752 /** Gets the value of "unicode-range" */
3753 String get unicodeRange =>
3754 getPropertyValue('unicode-range');
3755
3756 /** Sets the value of "unicode-range" */
3757 set unicodeRange(String value) {
3758 setProperty('unicode-range', value, '');
3759 }
3760
3761 /** Gets the value of "user-drag" */
3762 String get userDrag =>
3763 getPropertyValue('user-drag');
3764
3765 /** Sets the value of "user-drag" */
3766 set userDrag(String value) {
3767 setProperty('user-drag', value, '');
3768 }
3769
3770 /** Gets the value of "user-modify" */
3771 String get userModify =>
3772 getPropertyValue('user-modify');
3773
3774 /** Sets the value of "user-modify" */
3775 set userModify(String value) {
3776 setProperty('user-modify', value, '');
3777 }
3778
3779 /** Gets the value of "user-select" */
3780 String get userSelect =>
3781 getPropertyValue('user-select');
3782
3783 /** Sets the value of "user-select" */
3784 set userSelect(String value) {
3785 setProperty('user-select', value, '');
3786 }
3787
3788 /** Gets the value of "user-zoom" */
3789 String get userZoom =>
3790 getPropertyValue('user-zoom');
3791
3792 /** Sets the value of "user-zoom" */
3793 set userZoom(String value) {
3794 setProperty('user-zoom', value, '');
3795 }
3796
3797 /** Gets the value of "vertical-align" */
3798 String get verticalAlign =>
3799 getPropertyValue('vertical-align');
3800
3801 /** Sets the value of "vertical-align" */
3802 set verticalAlign(String value) {
3803 setProperty('vertical-align', value, '');
3804 }
3805
3806 /** Gets the value of "visibility" */
3807 String get visibility =>
3808 getPropertyValue('visibility');
3809
3810 /** Sets the value of "visibility" */
3811 set visibility(String value) {
3812 setProperty('visibility', value, '');
3813 }
3814
3815 /** Gets the value of "white-space" */
3816 String get whiteSpace =>
3817 getPropertyValue('white-space');
3818
3819 /** Sets the value of "white-space" */
3820 set whiteSpace(String value) {
3821 setProperty('white-space', value, '');
3822 }
3823
3824 /** Gets the value of "widows" */
3825 String get widows =>
3826 getPropertyValue('widows');
3827
3828 /** Sets the value of "widows" */
3829 set widows(String value) {
3830 setProperty('widows', value, '');
3831 }
3832
3833 /** Gets the value of "width" */
3834 String get width =>
3835 getPropertyValue('width');
3836
3837 /** Sets the value of "width" */
3838 set width(String value) {
3839 setProperty('width', value, '');
3840 }
3841
3842 /** Gets the value of "will-change" */
3843 String get willChange =>
3844 getPropertyValue('will-change');
3845
3846 /** Sets the value of "will-change" */
3847 set willChange(String value) {
3848 setProperty('will-change', value, '');
3849 }
3850
3851 /** Gets the value of "word-break" */
3852 String get wordBreak =>
3853 getPropertyValue('word-break');
3854
3855 /** Sets the value of "word-break" */
3856 set wordBreak(String value) {
3857 setProperty('word-break', value, '');
3858 }
3859
3860 /** Gets the value of "word-spacing" */
3861 String get wordSpacing =>
3862 getPropertyValue('word-spacing');
3863
3864 /** Sets the value of "word-spacing" */
3865 set wordSpacing(String value) {
3866 setProperty('word-spacing', value, '');
3867 }
3868
3869 /** Gets the value of "word-wrap" */
3870 String get wordWrap =>
3871 getPropertyValue('word-wrap');
3872
3873 /** Sets the value of "word-wrap" */
3874 set wordWrap(String value) {
3875 setProperty('word-wrap', value, '');
3876 }
3877
3878 /** Gets the value of "wrap-flow" */
3879 String get wrapFlow =>
3880 getPropertyValue('wrap-flow');
3881
3882 /** Sets the value of "wrap-flow" */
3883 set wrapFlow(String value) {
3884 setProperty('wrap-flow', value, '');
3885 }
3886
3887 /** Gets the value of "wrap-through" */
3888 String get wrapThrough =>
3889 getPropertyValue('wrap-through');
3890
3891 /** Sets the value of "wrap-through" */
3892 set wrapThrough(String value) {
3893 setProperty('wrap-through', value, '');
3894 }
3895
3896 /** Gets the value of "writing-mode" */
3897 String get writingMode =>
3898 getPropertyValue('writing-mode');
3899
3900 /** Sets the value of "writing-mode" */
3901 set writingMode(String value) {
3902 setProperty('writing-mode', value, '');
3903 }
3904
3905 /** Gets the value of "z-index" */
3906 String get zIndex =>
3907 getPropertyValue('z-index');
3908
3909 /** Sets the value of "z-index" */
3910 set zIndex(String value) {
3911 setProperty('z-index', value, '');
3912 }
3913
3914 /** Gets the value of "zoom" */
3915 String get zoom =>
3916 getPropertyValue('zoom');
3917
3918 /** Sets the value of "zoom" */
3919 set zoom(String value) {
3920 setProperty('zoom', value, '');
3921 }
3922 }
3923 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3924 // for details. All rights reserved. Use of this source code is governed by a
3925 // BSD-style license that can be found in the LICENSE file.
3926
3927
3928 @DocsEditable()
3929 /**
3930 * A generic container for content on an HTML page;
3931 * corresponds to the &lt;div&gt; tag.
3932 *
3933 * The [DivElement] is a generic container and does not have any semantic
3934 * significance. It is functionally similar to [SpanElement].
3935 *
3936 * The [DivElement] is a block-level element, as opposed to [SpanElement],
3937 * which is an inline-level element.
3938 *
3939 * Example usage:
3940 *
3941 * DivElement div = new DivElement();
3942 * div.text = 'Here's my new DivElem
3943 * document.body.elements.add(elem);
3944 *
3945 * See also:
3946 *
3947 * * [HTML <div> element](http://www.w3.org/TR/html-markup/div.html) from W3C.
3948 * * [Block-level element](http://www.w3.org/TR/CSS2/visuren.html#block-boxes) f rom W3C.
3949 * * [Inline-level element](http://www.w3.org/TR/CSS2/visuren.html#inline-boxes) from W3C.
3950 */
3951 @DomName('HTMLDivElement')
3952 @Native("HTMLDivElement")
3953 class DivElement extends HtmlElement {
3954 // To suppress missing implicit constructor warnings.
3955 factory DivElement._() { throw new UnsupportedError("Not supported"); }
3956
3957 @DomName('HTMLDivElement.HTMLDivElement')
3958 @DocsEditable()
3959 factory DivElement() => document.createElement("div");
3960
3961
3962 @Deprecated("Internal Use Only")
3963 static DivElement internalCreateDivElement() {
3964 return new DivElement.internal_();
3965 }
3966
3967 @Deprecated("Internal Use Only")
3968 DivElement.internal_() : super.internal_();
3969
3970 }
3971 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3972 // for details. All rights reserved. Use of this source code is governed by a
3973 // BSD-style license that can be found in the LICENSE file.
3974
3975
3976 @DocsEditable()
3977 /**
3978 * The base class for all documents.
3979 *
3980 * Each web page loaded in the browser has its own [Document] object, which is
3981 * typically an [HtmlDocument].
3982 *
3983 * If you aren't comfortable with DOM concepts, see the Dart tutorial
3984 * [Target 2: Connect Dart & HTML](http://www.dartlang.org/docs/tutorials/connec t-dart-html/).
3985 */
3986 @DomName('Document')
3987 @Native("Document")
3988 class Document extends Node
3989 {
3990
3991 // To suppress missing implicit constructor warnings.
3992 factory Document._() { throw new UnsupportedError("Not supported"); }
3993
3994 @DomName('Document.pointerlockchangeEvent')
3995 @DocsEditable()
3996 @Experimental() // untriaged
3997 static const EventStreamProvider<Event> pointerLockChangeEvent = const EventSt reamProvider<Event>('pointerlockchange');
3998
3999 @DomName('Document.pointerlockerrorEvent')
4000 @DocsEditable()
4001 @Experimental() // untriaged
4002 static const EventStreamProvider<Event> pointerLockErrorEvent = const EventStr eamProvider<Event>('pointerlockerror');
4003
4004 /**
4005 * Static factory designed to expose `readystatechange` events to event
4006 * handlers that are not necessarily instances of [Document].
4007 *
4008 * See [EventStreamProvider] for usage information.
4009 */
4010 @DomName('Document.readystatechangeEvent')
4011 @DocsEditable()
4012 static const EventStreamProvider<Event> readyStateChangeEvent = const EventStr eamProvider<Event>('readystatechange');
4013
4014 /**
4015 * Static factory designed to expose `selectionchange` events to event
4016 * handlers that are not necessarily instances of [Document].
4017 *
4018 * See [EventStreamProvider] for usage information.
4019 */
4020 @DomName('Document.selectionchangeEvent')
4021 @DocsEditable()
4022 static const EventStreamProvider<Event> selectionChangeEvent = const EventStre amProvider<Event>('selectionchange');
4023
4024
4025 @Deprecated("Internal Use Only")
4026 static Document internalCreateDocument() {
4027 return new Document.internal_();
4028 }
4029
4030 @Deprecated("Internal Use Only")
4031 Document.internal_() : super.internal_();
4032
4033
4034 @DomName('Document.activeElement')
4035 @DocsEditable()
4036 @Experimental() // untriaged
4037 Element get activeElement => wrap_jso(JS("Element", "#.activeElement", this.ra w));
4038
4039 @JSName('body')
4040 @DomName('Document.body')
4041 @DocsEditable()
4042 HtmlElement get _body => wrap_jso(JS("HtmlElement", "#.body", this.raw));
4043 @JSName('body')
4044 @DomName('Document.body')
4045 @DocsEditable()
4046 void set _body(HtmlElement val) => JS("void", "#.body = #", this.raw, unwrap_j so(val));
4047
4048 @DomName('Document.contentType')
4049 @DocsEditable()
4050 @Experimental() // untriaged
4051 String get contentType => wrap_jso(JS("String", "#.contentType", this.raw));
4052
4053 @DomName('Document.cookie')
4054 @DocsEditable()
4055 String get cookie => wrap_jso(JS("String", "#.cookie", this.raw));
4056 @DomName('Document.cookie')
4057 @DocsEditable()
4058 void set cookie(String val) => JS("void", "#.cookie = #", this.raw, unwrap_jso (val));
4059
4060 @DomName('Document.currentScript')
4061 @DocsEditable()
4062 @Experimental() // untriaged
4063 HtmlElement get currentScript => wrap_jso(JS("HtmlElement", "#.currentScript", this.raw));
4064
4065 @DomName('Document.window')
4066 @DocsEditable()
4067 @Experimental() // untriaged
4068 WindowBase get window => _convertNativeToDart_Window(this._get_window);
4069 @JSName('defaultView')
4070 @DomName('Document.window')
4071 @DocsEditable()
4072 @Experimental() // untriaged
4073 @Creates('Window|=Object')
4074 @Returns('Window|=Object')
4075 @Creates('Window|=Object|Null')
4076 @Returns('Window|=Object|Null')
4077 dynamic get _get_window => wrap_jso(JS("dynamic", "#.defaultView", this.raw));
4078
4079 @DomName('Document.documentElement')
4080 @DocsEditable()
4081 Element get documentElement => wrap_jso(JS("Element", "#.documentElement", thi s.raw));
4082
4083 @DomName('Document.domain')
4084 @DocsEditable()
4085 String get domain => wrap_jso(JS("String", "#.domain", this.raw));
4086
4087 @DomName('Document.fullscreenElement')
4088 @DocsEditable()
4089 @Experimental() // untriaged
4090 Element get fullscreenElement => wrap_jso(JS("Element", "#.fullscreenElement", this.raw));
4091
4092 @DomName('Document.fullscreenEnabled')
4093 @DocsEditable()
4094 @Experimental() // untriaged
4095 bool get fullscreenEnabled => wrap_jso(JS("bool", "#.fullscreenEnabled", this. raw));
4096
4097 @JSName('head')
4098 @DomName('Document.head')
4099 @DocsEditable()
4100 HeadElement get _head => wrap_jso(JS("HeadElement", "#.head", this.raw));
4101
4102 @DomName('Document.hidden')
4103 @DocsEditable()
4104 @Experimental() // untriaged
4105 bool get hidden => wrap_jso(JS("bool", "#.hidden", this.raw));
4106
4107 @DomName('Document.implementation')
4108 @DocsEditable()
4109 DomImplementation get implementation => wrap_jso(JS("DomImplementation", "#.im plementation", this.raw));
4110
4111 @JSName('lastModified')
4112 @DomName('Document.lastModified')
4113 @DocsEditable()
4114 String get _lastModified => wrap_jso(JS("String", "#.lastModified", this.raw)) ;
4115
4116 @DomName('Document.pointerLockElement')
4117 @DocsEditable()
4118 @Experimental() // untriaged
4119 Element get pointerLockElement => wrap_jso(JS("Element", "#.pointerLockElement ", this.raw));
4120
4121 @JSName('preferredStylesheetSet')
4122 @DomName('Document.preferredStylesheetSet')
4123 @DocsEditable()
4124 String get _preferredStylesheetSet => wrap_jso(JS("String", "#.preferredStyles heetSet", this.raw));
4125
4126 @DomName('Document.readyState')
4127 @DocsEditable()
4128 String get readyState => wrap_jso(JS("String", "#.readyState", this.raw));
4129
4130 @JSName('referrer')
4131 @DomName('Document.referrer')
4132 @DocsEditable()
4133 String get _referrer => wrap_jso(JS("String", "#.referrer", this.raw));
4134
4135 @DomName('Document.rootElement')
4136 @DocsEditable()
4137 @Experimental() // untriaged
4138 Element get rootElement => wrap_jso(JS("Element", "#.rootElement", this.raw));
4139
4140 @JSName('selectedStylesheetSet')
4141 @DomName('Document.selectedStylesheetSet')
4142 @DocsEditable()
4143 String get _selectedStylesheetSet => wrap_jso(JS("String", "#.selectedStyleshe etSet", this.raw));
4144 @JSName('selectedStylesheetSet')
4145 @DomName('Document.selectedStylesheetSet')
4146 @DocsEditable()
4147 void set _selectedStylesheetSet(String val) => JS("void", "#.selectedStyleshee tSet = #", this.raw, unwrap_jso(val));
4148
4149 @JSName('title')
4150 @DomName('Document.title')
4151 @DocsEditable()
4152 String get _title => wrap_jso(JS("String", "#.title", this.raw));
4153 @JSName('title')
4154 @DomName('Document.title')
4155 @DocsEditable()
4156 void set _title(String val) => JS("void", "#.title = #", this.raw, unwrap_jso( val));
4157
4158 @DomName('Document.visibilityState')
4159 @DocsEditable()
4160 @Experimental() // untriaged
4161 String get visibilityState => wrap_jso(JS("String", "#.visibilityState", this. raw));
4162
4163 @JSName('webkitFullscreenElement')
4164 @DomName('Document.webkitFullscreenElement')
4165 @DocsEditable()
4166 @SupportedBrowser(SupportedBrowser.CHROME)
4167 @SupportedBrowser(SupportedBrowser.SAFARI)
4168 @Experimental()
4169 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#dom-document-f ullscreenelement
4170 Element get _webkitFullscreenElement => wrap_jso(JS("Element", "#.webkitFullsc reenElement", this.raw));
4171
4172 @JSName('webkitFullscreenEnabled')
4173 @DomName('Document.webkitFullscreenEnabled')
4174 @DocsEditable()
4175 @SupportedBrowser(SupportedBrowser.CHROME)
4176 @SupportedBrowser(SupportedBrowser.SAFARI)
4177 @Experimental()
4178 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#dom-document-f ullscreenenabled
4179 bool get _webkitFullscreenEnabled => wrap_jso(JS("bool", "#.webkitFullscreenEn abled", this.raw));
4180
4181 @JSName('webkitHidden')
4182 @DomName('Document.webkitHidden')
4183 @DocsEditable()
4184 @SupportedBrowser(SupportedBrowser.CHROME)
4185 @SupportedBrowser(SupportedBrowser.SAFARI)
4186 @Experimental()
4187 // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.h tml#document
4188 bool get _webkitHidden => wrap_jso(JS("bool", "#.webkitHidden", this.raw));
4189
4190 @JSName('webkitVisibilityState')
4191 @DomName('Document.webkitVisibilityState')
4192 @DocsEditable()
4193 @SupportedBrowser(SupportedBrowser.CHROME)
4194 @SupportedBrowser(SupportedBrowser.SAFARI)
4195 @Experimental()
4196 // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.h tml#dom-document-visibilitystate
4197 String get _webkitVisibilityState => wrap_jso(JS("String", "#.webkitVisibility State", this.raw));
4198
4199 @DomName('Document.adoptNode')
4200 @DocsEditable()
4201 Node adoptNode(Node node) {
4202 return _adoptNode_1(node);
4203 }
4204 @JSName('adoptNode')
4205 @DomName('Document.adoptNode')
4206 @DocsEditable()
4207 Node _adoptNode_1(Node node) => wrap_jso(JS("Node ", "#.raw.adoptNode(#)", thi s, unwrap_jso(node)));
4208
4209 @DomName('Document.caretRangeFromPoint')
4210 @DocsEditable()
4211 // http://www.w3.org/TR/2009/WD-cssom-view-20090804/#dom-documentview-caretran gefrompoint
4212 @Experimental()
4213 Range _caretRangeFromPoint(int x, int y) {
4214 return _caretRangeFromPoint_1(x, y);
4215 }
4216 @JSName('caretRangeFromPoint')
4217 @DomName('Document.caretRangeFromPoint')
4218 @DocsEditable()
4219 // http://www.w3.org/TR/2009/WD-cssom-view-20090804/#dom-documentview-caretran gefrompoint
4220 @Experimental()
4221 Range _caretRangeFromPoint_1(x, y) => wrap_jso(JS("Range ", "#.raw.caretRangeF romPoint(#, #)", this, unwrap_jso(x), unwrap_jso(y)));
4222
4223 @DomName('Document.createDocumentFragment')
4224 @DocsEditable()
4225 DocumentFragment createDocumentFragment() {
4226 return _createDocumentFragment_1();
4227 }
4228 @JSName('createDocumentFragment')
4229 @DomName('Document.createDocumentFragment')
4230 @DocsEditable()
4231 DocumentFragment _createDocumentFragment_1() => wrap_jso(JS("DocumentFragment ", "#.raw.createDocumentFragment()", this));
4232
4233 @DomName('Document.createElement')
4234 @DocsEditable()
4235 Element _createElement(String localName_OR_tagName, [String typeExtension]) {
4236 if (typeExtension == null) {
4237 return _createElement_1(localName_OR_tagName);
4238 }
4239 if (typeExtension != null) {
4240 return _createElement_2(localName_OR_tagName, typeExtension);
4241 }
4242 throw new ArgumentError("Incorrect number or type of arguments");
4243 }
4244 @JSName('createElement')
4245 @DomName('Document.createElement')
4246 @DocsEditable()
4247 Element _createElement_1(tagName) => wrap_jso(JS("Element ", "#.raw.createElem ent(#)", this, unwrap_jso(tagName)));
4248 @JSName('createElement')
4249 @DomName('Document.createElement')
4250 @DocsEditable()
4251 Element _createElement_2(localName, typeExtension) => wrap_jso(JS("Element ", "#.raw.createElement(#, #)", this, unwrap_jso(localName), unwrap_jso(typeExtensi on)));
4252
4253 @DomName('Document.createElementNS')
4254 @DocsEditable()
4255 Element _createElementNS(String namespaceURI, String qualifiedName, [String ty peExtension]) {
4256 if (typeExtension == null) {
4257 return _createElementNS_1(namespaceURI, qualifiedName);
4258 }
4259 if (typeExtension != null) {
4260 return _createElementNS_2(namespaceURI, qualifiedName, typeExtension);
4261 }
4262 throw new ArgumentError("Incorrect number or type of arguments");
4263 }
4264 @JSName('createElementNS')
4265 @DomName('Document.createElementNS')
4266 @DocsEditable()
4267 Element _createElementNS_1(namespaceURI, qualifiedName) => wrap_jso(JS("Elemen t ", "#.raw.createElementNS(#, #)", this, unwrap_jso(namespaceURI), unwrap_jso(q ualifiedName)));
4268 @JSName('createElementNS')
4269 @DomName('Document.createElementNS')
4270 @DocsEditable()
4271 Element _createElementNS_2(namespaceURI, qualifiedName, typeExtension) => wrap _jso(JS("Element ", "#.raw.createElementNS(#, #, #)", this, unwrap_jso(namespace URI), unwrap_jso(qualifiedName), unwrap_jso(typeExtension)));
4272
4273 @DomName('Document.createEvent')
4274 @DocsEditable()
4275 Event _createEvent(String eventType) {
4276 return _createEvent_1(eventType);
4277 }
4278 @JSName('createEvent')
4279 @DomName('Document.createEvent')
4280 @DocsEditable()
4281 Event _createEvent_1(eventType) => wrap_jso(JS("Event ", "#.raw.createEvent(#) ", this, unwrap_jso(eventType)));
4282
4283 @DomName('Document.createRange')
4284 @DocsEditable()
4285 Range createRange() {
4286 return _createRange_1();
4287 }
4288 @JSName('createRange')
4289 @DomName('Document.createRange')
4290 @DocsEditable()
4291 Range _createRange_1() => wrap_jso(JS("Range ", "#.raw.createRange()", this));
4292
4293 @DomName('Document.createTextNode')
4294 @DocsEditable()
4295 Text _createTextNode(String data) {
4296 return _createTextNode_1(data);
4297 }
4298 @JSName('createTextNode')
4299 @DomName('Document.createTextNode')
4300 @DocsEditable()
4301 Text _createTextNode_1(data) => wrap_jso(JS("Text ", "#.raw.createTextNode(#)" , this, unwrap_jso(data)));
4302
4303 @DomName('Document.elementFromPoint')
4304 @DocsEditable()
4305 Element _elementFromPoint(int x, int y) {
4306 return _elementFromPoint_1(x, y);
4307 }
4308 @JSName('elementFromPoint')
4309 @DomName('Document.elementFromPoint')
4310 @DocsEditable()
4311 Element _elementFromPoint_1(x, y) => wrap_jso(JS("Element ", "#.raw.elementFro mPoint(#, #)", this, unwrap_jso(x), unwrap_jso(y)));
4312
4313 @DomName('Document.execCommand')
4314 @DocsEditable()
4315 bool execCommand(String command, bool userInterface, String value) {
4316 return _execCommand_1(command, userInterface, value);
4317 }
4318 @JSName('execCommand')
4319 @DomName('Document.execCommand')
4320 @DocsEditable()
4321 bool _execCommand_1(command, userInterface, value) => wrap_jso(JS("bool ", "#. raw.execCommand(#, #, #)", this, unwrap_jso(command), unwrap_jso(userInterface), unwrap_jso(value)));
4322
4323 @DomName('Document.exitFullscreen')
4324 @DocsEditable()
4325 @Experimental() // untriaged
4326 void exitFullscreen() {
4327 _exitFullscreen_1();
4328 return;
4329 }
4330 @JSName('exitFullscreen')
4331 @DomName('Document.exitFullscreen')
4332 @DocsEditable()
4333 @Experimental() // untriaged
4334 void _exitFullscreen_1() => wrap_jso(JS("void ", "#.raw.exitFullscreen()", thi s));
4335
4336 @DomName('Document.exitPointerLock')
4337 @DocsEditable()
4338 @Experimental() // untriaged
4339 void exitPointerLock() {
4340 _exitPointerLock_1();
4341 return;
4342 }
4343 @JSName('exitPointerLock')
4344 @DomName('Document.exitPointerLock')
4345 @DocsEditable()
4346 @Experimental() // untriaged
4347 void _exitPointerLock_1() => wrap_jso(JS("void ", "#.raw.exitPointerLock()", t his));
4348
4349 @DomName('Document.getCSSCanvasContext')
4350 @DocsEditable()
4351 // https://developer.apple.com/library/safari/#documentation/AppleApplications /Reference/SafariCSSRef/Articles/Functions.html
4352 @Experimental() // non-standard
4353 Object _getCssCanvasContext(String contextId, String name, int width, int heig ht) {
4354 return _getCssCanvasContext_1(contextId, name, width, height);
4355 }
4356 @JSName('getCSSCanvasContext')
4357 @DomName('Document.getCSSCanvasContext')
4358 @DocsEditable()
4359 // https://developer.apple.com/library/safari/#documentation/AppleApplications /Reference/SafariCSSRef/Articles/Functions.html
4360 @Experimental() // non-standard
4361 Object _getCssCanvasContext_1(contextId, name, width, height) => wrap_jso(JS(" Object ", "#.raw.getCSSCanvasContext(#, #, #, #)", this, unwrap_jso(contextId), unwrap_jso(name), unwrap_jso(width), unwrap_jso(height)));
4362
4363 @DomName('Document.getElementById')
4364 @DocsEditable()
4365 Element getElementById(String elementId) {
4366 return _getElementById_1(elementId);
4367 }
4368 @JSName('getElementById')
4369 @DomName('Document.getElementById')
4370 @DocsEditable()
4371 Element _getElementById_1(elementId) => wrap_jso(JS("Element ", "#.raw.getElem entById(#)", this, unwrap_jso(elementId)));
4372
4373 @DomName('Document.getElementsByClassName')
4374 @DocsEditable()
4375 @Creates('NodeList|HtmlCollection')
4376 @Returns('NodeList|HtmlCollection')
4377 HtmlCollection getElementsByClassName(String classNames) {
4378 return _getElementsByClassName_1(classNames);
4379 }
4380 @JSName('getElementsByClassName')
4381 @DomName('Document.getElementsByClassName')
4382 @DocsEditable()
4383 @Creates('NodeList|HtmlCollection')
4384 @Returns('NodeList|HtmlCollection')
4385 HtmlCollection _getElementsByClassName_1(classNames) => wrap_jso(JS("HtmlColle ction ", "#.raw.getElementsByClassName(#)", this, unwrap_jso(classNames)));
4386
4387 @DomName('Document.getElementsByName')
4388 @DocsEditable()
4389 @Creates('NodeList|HtmlCollection')
4390 @Returns('NodeList|HtmlCollection')
4391 NodeList getElementsByName(String elementName) {
4392 return _getElementsByName_1(elementName);
4393 }
4394 @JSName('getElementsByName')
4395 @DomName('Document.getElementsByName')
4396 @DocsEditable()
4397 @Creates('NodeList|HtmlCollection')
4398 @Returns('NodeList|HtmlCollection')
4399 NodeList _getElementsByName_1(elementName) => wrap_jso(JS("NodeList ", "#.raw. getElementsByName(#)", this, unwrap_jso(elementName)));
4400
4401 @DomName('Document.getElementsByTagName')
4402 @DocsEditable()
4403 @Creates('NodeList|HtmlCollection')
4404 @Returns('NodeList|HtmlCollection')
4405 HtmlCollection getElementsByTagName(String localName) {
4406 return _getElementsByTagName_1(localName);
4407 }
4408 @JSName('getElementsByTagName')
4409 @DomName('Document.getElementsByTagName')
4410 @DocsEditable()
4411 @Creates('NodeList|HtmlCollection')
4412 @Returns('NodeList|HtmlCollection')
4413 HtmlCollection _getElementsByTagName_1(localName) => wrap_jso(JS("HtmlCollecti on ", "#.raw.getElementsByTagName(#)", this, unwrap_jso(localName)));
4414
4415 @DomName('Document.importNode')
4416 @DocsEditable()
4417 Node importNode(Node node, [bool deep]) {
4418 if (deep != null) {
4419 return _importNode_1(node, deep);
4420 }
4421 return _importNode_2(node);
4422 }
4423 @JSName('importNode')
4424 @DomName('Document.importNode')
4425 @DocsEditable()
4426 Node _importNode_1(Node node, deep) => wrap_jso(JS("Node ", "#.raw.importNode( #, #)", this, unwrap_jso(node), unwrap_jso(deep)));
4427 @JSName('importNode')
4428 @DomName('Document.importNode')
4429 @DocsEditable()
4430 Node _importNode_2(Node node) => wrap_jso(JS("Node ", "#.raw.importNode(#)", t his, unwrap_jso(node)));
4431
4432 @DomName('Document.queryCommandEnabled')
4433 @DocsEditable()
4434 bool queryCommandEnabled(String command) {
4435 return _queryCommandEnabled_1(command);
4436 }
4437 @JSName('queryCommandEnabled')
4438 @DomName('Document.queryCommandEnabled')
4439 @DocsEditable()
4440 bool _queryCommandEnabled_1(command) => wrap_jso(JS("bool ", "#.raw.queryComma ndEnabled(#)", this, unwrap_jso(command)));
4441
4442 @DomName('Document.queryCommandIndeterm')
4443 @DocsEditable()
4444 bool queryCommandIndeterm(String command) {
4445 return _queryCommandIndeterm_1(command);
4446 }
4447 @JSName('queryCommandIndeterm')
4448 @DomName('Document.queryCommandIndeterm')
4449 @DocsEditable()
4450 bool _queryCommandIndeterm_1(command) => wrap_jso(JS("bool ", "#.raw.queryComm andIndeterm(#)", this, unwrap_jso(command)));
4451
4452 @DomName('Document.queryCommandState')
4453 @DocsEditable()
4454 bool queryCommandState(String command) {
4455 return _queryCommandState_1(command);
4456 }
4457 @JSName('queryCommandState')
4458 @DomName('Document.queryCommandState')
4459 @DocsEditable()
4460 bool _queryCommandState_1(command) => wrap_jso(JS("bool ", "#.raw.queryCommand State(#)", this, unwrap_jso(command)));
4461
4462 @DomName('Document.queryCommandSupported')
4463 @DocsEditable()
4464 bool queryCommandSupported(String command) {
4465 return _queryCommandSupported_1(command);
4466 }
4467 @JSName('queryCommandSupported')
4468 @DomName('Document.queryCommandSupported')
4469 @DocsEditable()
4470 bool _queryCommandSupported_1(command) => wrap_jso(JS("bool ", "#.raw.queryCom mandSupported(#)", this, unwrap_jso(command)));
4471
4472 @DomName('Document.queryCommandValue')
4473 @DocsEditable()
4474 String queryCommandValue(String command) {
4475 return _queryCommandValue_1(command);
4476 }
4477 @JSName('queryCommandValue')
4478 @DomName('Document.queryCommandValue')
4479 @DocsEditable()
4480 String _queryCommandValue_1(command) => wrap_jso(JS("String ", "#.raw.queryCom mandValue(#)", this, unwrap_jso(command)));
4481
4482 @DomName('Document.transformDocumentToTreeView')
4483 @DocsEditable()
4484 @Experimental() // untriaged
4485 void transformDocumentToTreeView(String noStyleMessage) {
4486 _transformDocumentToTreeView_1(noStyleMessage);
4487 return;
4488 }
4489 @JSName('transformDocumentToTreeView')
4490 @DomName('Document.transformDocumentToTreeView')
4491 @DocsEditable()
4492 @Experimental() // untriaged
4493 void _transformDocumentToTreeView_1(noStyleMessage) => wrap_jso(JS("void ", "# .raw.transformDocumentToTreeView(#)", this, unwrap_jso(noStyleMessage)));
4494
4495 @DomName('Document.webkitExitFullscreen')
4496 @DocsEditable()
4497 @SupportedBrowser(SupportedBrowser.CHROME)
4498 @SupportedBrowser(SupportedBrowser.SAFARI)
4499 @Experimental()
4500 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#dom-document-e xitfullscreen
4501 void _webkitExitFullscreen() {
4502 _webkitExitFullscreen_1();
4503 return;
4504 }
4505 @JSName('webkitExitFullscreen')
4506 @DomName('Document.webkitExitFullscreen')
4507 @DocsEditable()
4508 @SupportedBrowser(SupportedBrowser.CHROME)
4509 @SupportedBrowser(SupportedBrowser.SAFARI)
4510 @Experimental()
4511 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#dom-document-e xitfullscreen
4512 void _webkitExitFullscreen_1() => wrap_jso(JS("void ", "#.raw.webkitExitFullsc reen()", this));
4513
4514 // From ParentNode
4515
4516 @JSName('childElementCount')
4517 @DomName('Document.childElementCount')
4518 @DocsEditable()
4519 int get _childElementCount => wrap_jso(JS("int", "#.childElementCount", this.r aw));
4520
4521 @JSName('children')
4522 @DomName('Document.children')
4523 @DocsEditable()
4524 @Returns('HtmlCollection')
4525 @Creates('HtmlCollection')
4526 List<Node> get _children => wrap_jso(JS("List<Node>", "#.children", this.raw)) ;
4527
4528 @JSName('firstElementChild')
4529 @DomName('Document.firstElementChild')
4530 @DocsEditable()
4531 Element get _firstElementChild => wrap_jso(JS("Element", "#.firstElementChild" , this.raw));
4532
4533 @JSName('lastElementChild')
4534 @DomName('Document.lastElementChild')
4535 @DocsEditable()
4536 Element get _lastElementChild => wrap_jso(JS("Element", "#.lastElementChild", this.raw));
4537
4538 /**
4539 * Finds the first descendant element of this document that matches the
4540 * specified group of selectors.
4541 *
4542 * Unless your webpage contains multiple documents, the top-level
4543 * [querySelector]
4544 * method behaves the same as this method, so you should use it instead to
4545 * save typing a few characters.
4546 *
4547 * [selectors] should be a string using CSS selector syntax.
4548 *
4549 * var element1 = document.querySelector('.className');
4550 * var element2 = document.querySelector('#id');
4551 *
4552 * For details about CSS selector syntax, see the
4553 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
4554 */
4555 @DomName('Document.querySelector')
4556 @DocsEditable()
4557 Element querySelector(String selectors) {
4558 return _querySelector_1(selectors);
4559 }
4560 @JSName('querySelector')
4561 /**
4562 * Finds the first descendant element of this document that matches the
4563 * specified group of selectors.
4564 *
4565 * Unless your webpage contains multiple documents, the top-level
4566 * [querySelector]
4567 * method behaves the same as this method, so you should use it instead to
4568 * save typing a few characters.
4569 *
4570 * [selectors] should be a string using CSS selector syntax.
4571 *
4572 * var element1 = document.querySelector('.className');
4573 * var element2 = document.querySelector('#id');
4574 *
4575 * For details about CSS selector syntax, see the
4576 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
4577 */
4578 @DomName('Document.querySelector')
4579 @DocsEditable()
4580 Element _querySelector_1(selectors) => wrap_jso(JS("Element ", "#.raw.querySel ector(#)", this, unwrap_jso(selectors)));
4581
4582 @DomName('Document.querySelectorAll')
4583 @DocsEditable()
4584 @Returns('NodeList')
4585 @Creates('NodeList')
4586 NodeList _querySelectorAll(String selectors) {
4587 return _querySelectorAll_1(selectors);
4588 }
4589 @JSName('querySelectorAll')
4590 @DomName('Document.querySelectorAll')
4591 @DocsEditable()
4592 @Returns('NodeList')
4593 @Creates('NodeList')
4594 NodeList _querySelectorAll_1(selectors) => wrap_jso(JS("NodeList ", "#.raw.que rySelectorAll(#)", this, unwrap_jso(selectors)));
4595
4596 /// Stream of `beforecopy` events handled by this [Document].
4597 @DomName('Document.onbeforecopy')
4598 @DocsEditable()
4599 Stream<Event> get onBeforeCopy => Element.beforeCopyEvent.forTarget(this);
4600
4601 /// Stream of `beforecut` events handled by this [Document].
4602 @DomName('Document.onbeforecut')
4603 @DocsEditable()
4604 Stream<Event> get onBeforeCut => Element.beforeCutEvent.forTarget(this);
4605
4606 /// Stream of `beforepaste` events handled by this [Document].
4607 @DomName('Document.onbeforepaste')
4608 @DocsEditable()
4609 Stream<Event> get onBeforePaste => Element.beforePasteEvent.forTarget(this);
4610
4611 /// Stream of `copy` events handled by this [Document].
4612 @DomName('Document.oncopy')
4613 @DocsEditable()
4614 Stream<Event> get onCopy => Element.copyEvent.forTarget(this);
4615
4616 /// Stream of `cut` events handled by this [Document].
4617 @DomName('Document.oncut')
4618 @DocsEditable()
4619 Stream<Event> get onCut => Element.cutEvent.forTarget(this);
4620
4621 /// Stream of `paste` events handled by this [Document].
4622 @DomName('Document.onpaste')
4623 @DocsEditable()
4624 Stream<Event> get onPaste => Element.pasteEvent.forTarget(this);
4625
4626 @DomName('Document.onpointerlockchange')
4627 @DocsEditable()
4628 @Experimental() // untriaged
4629 Stream<Event> get onPointerLockChange => pointerLockChangeEvent.forTarget(this );
4630
4631 @DomName('Document.onpointerlockerror')
4632 @DocsEditable()
4633 @Experimental() // untriaged
4634 Stream<Event> get onPointerLockError => pointerLockErrorEvent.forTarget(this);
4635
4636 /// Stream of `readystatechange` events handled by this [Document].
4637 @DomName('Document.onreadystatechange')
4638 @DocsEditable()
4639 Stream<Event> get onReadyStateChange => readyStateChangeEvent.forTarget(this);
4640
4641 /// Stream of `search` events handled by this [Document].
4642 @DomName('Document.onsearch')
4643 @DocsEditable()
4644 // http://www.w3.org/TR/html-markup/input.search.html
4645 @Experimental()
4646 Stream<Event> get onSearch => Element.searchEvent.forTarget(this);
4647
4648 /// Stream of `selectionchange` events handled by this [Document].
4649 @DomName('Document.onselectionchange')
4650 @DocsEditable()
4651 Stream<Event> get onSelectionChange => selectionChangeEvent.forTarget(this);
4652
4653 /// Stream of `selectstart` events handled by this [Document].
4654 @DomName('Document.onselectstart')
4655 @DocsEditable()
4656 Stream<Event> get onSelectStart => Element.selectStartEvent.forTarget(this);
4657
4658 /// Stream of `fullscreenchange` events handled by this [Document].
4659 @DomName('Document.onwebkitfullscreenchange')
4660 @DocsEditable()
4661 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
4662 @Experimental()
4663 Stream<Event> get onFullscreenChange => Element.fullscreenChangeEvent.forTarge t(this);
4664
4665 /// Stream of `fullscreenerror` events handled by this [Document].
4666 @DomName('Document.onwebkitfullscreenerror')
4667 @DocsEditable()
4668 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
4669 @Experimental()
4670 Stream<Event> get onFullscreenError => Element.fullscreenErrorEvent.forTarget( this);
4671
4672 /**
4673 * Finds all descendant elements of this document that match the specified
4674 * group of selectors.
4675 *
4676 * Unless your webpage contains multiple documents, the top-level
4677 * [querySelectorAll]
4678 * method behaves the same as this method, so you should use it instead to
4679 * save typing a few characters.
4680 *
4681 * [selectors] should be a string using CSS selector syntax.
4682 *
4683 * var items = document.querySelectorAll('.itemClassName');
4684 *
4685 * For details about CSS selector syntax, see the
4686 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
4687 */
4688 ElementList<Element> querySelectorAll(String selectors) {
4689 return new _FrozenElementList._wrap(_querySelectorAll(selectors));
4690 }
4691
4692 /**
4693 * Alias for [querySelector]. Note this function is deprecated because its
4694 * semantics will be changing in the future.
4695 */
4696 @deprecated
4697 @Experimental()
4698 @DomName('Document.querySelector')
4699 Element query(String relativeSelectors) => querySelector(relativeSelectors);
4700
4701 /**
4702 * Alias for [querySelectorAll]. Note this function is deprecated because its
4703 * semantics will be changing in the future.
4704 */
4705 @deprecated
4706 @Experimental()
4707 @DomName('Document.querySelectorAll')
4708 ElementList<Element> queryAll(String relativeSelectors) =>
4709 querySelectorAll(relativeSelectors);
4710
4711 /// Checks if [registerElement] is supported on the current platform.
4712 bool get supportsRegisterElement {
4713 return true;
4714 }
4715
4716 /// *Deprecated*: use [supportsRegisterElement] instead.
4717 @deprecated
4718 bool get supportsRegister => supportsRegisterElement;
4719
4720 @DomName('Document.createElement')
4721 Element createElement(String tagName, [String typeExtension]) {
4722 return _createElement(tagName, typeExtension);
4723 }
4724
4725 @DomName('Document.createElementNS')
4726 @DocsEditable()
4727 Element createElementNS(String namespaceURI, String qualifiedName, [String typ eExtension]) {
4728 return _createElementNS(namespaceURI, qualifiedName, typeExtension);
4729 }
4730
4731 }
4732 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
4733 // for details. All rights reserved. Use of this source code is governed by a
4734 // BSD-style license that can be found in the LICENSE file.
4735
4736
4737 @DomName('DocumentFragment')
4738 @Native("DocumentFragment")
4739 class DocumentFragment extends Node implements ParentNode {
4740 factory DocumentFragment() => document.createDocumentFragment();
4741
4742 factory DocumentFragment.html(String html,
4743 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
4744
4745 return document.body.createFragment(html,
4746 validator: validator, treeSanitizer: treeSanitizer);
4747 }
4748
4749 factory DocumentFragment.svg(String svgContent,
4750 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
4751 throw 'SVG not supported in DDC';
4752 }
4753
4754 HtmlCollection get _children => throw new UnimplementedError(
4755 'Use _docChildren instead');
4756
4757 List<Element> _docChildren;
4758
4759 List<Element> get children {
4760 if (_docChildren == null) {
4761 _docChildren = new FilteredElementList(this);
4762 }
4763 return _docChildren;
4764 }
4765
4766 set children(List<Element> value) {
4767 // Copy list first since we don't want liveness during iteration.
4768 List copy = new List.from(value);
4769 var children = this.children;
4770 children.clear();
4771 children.addAll(copy);
4772 }
4773
4774 /**
4775 * Finds all descendant elements of this document fragment that match the
4776 * specified group of selectors.
4777 *
4778 * [selectors] should be a string using CSS selector syntax.
4779 *
4780 * var items = document.querySelectorAll('.itemClassName');
4781 *
4782 * For details about CSS selector syntax, see the
4783 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
4784 */
4785 ElementList<Element> querySelectorAll(String selectors) =>
4786 new _FrozenElementList._wrap(_querySelectorAll(selectors));
4787
4788 String get innerHtml {
4789 final e = new Element.tag("div");
4790 e.append(this.clone(true));
4791 return e.innerHtml;
4792 }
4793
4794 set innerHtml(String value) {
4795 this.setInnerHtml(value);
4796 }
4797
4798 void setInnerHtml(String html,
4799 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
4800
4801 this.nodes.clear();
4802 append(document.body.createFragment(
4803 html, validator: validator, treeSanitizer: treeSanitizer));
4804 }
4805
4806 /**
4807 * Adds the specified text as a text node after the last child of this
4808 * document fragment.
4809 */
4810 void appendText(String text) {
4811 this.append(new Text(text));
4812 }
4813
4814
4815 /**
4816 * Parses the specified text as HTML and adds the resulting node after the
4817 * last child of this document fragment.
4818 */
4819 void appendHtml(String text, {NodeValidator validator,
4820 NodeTreeSanitizer, treeSanitizer}) {
4821 this.append(new DocumentFragment.html(text, validator: validator,
4822 treeSanitizer: treeSanitizer));
4823 }
4824
4825 /**
4826 * Alias for [querySelector]. Note this function is deprecated because its
4827 * semantics will be changing in the future.
4828 */
4829 @deprecated
4830 @Experimental()
4831 @DomName('DocumentFragment.querySelector')
4832 Element query(String relativeSelectors) {
4833 return querySelector(relativeSelectors);
4834 }
4835
4836 /**
4837 * Alias for [querySelectorAll]. Note this function is deprecated because its
4838 * semantics will be changing in the future.
4839 */
4840 @deprecated
4841 @Experimental()
4842 @DomName('DocumentFragment.querySelectorAll')
4843 ElementList<Element> queryAll(String relativeSelectors) {
4844 return querySelectorAll(relativeSelectors);
4845 }
4846 // To suppress missing implicit constructor warnings.
4847 factory DocumentFragment._() { throw new UnsupportedError("Not supported"); }
4848
4849
4850 @Deprecated("Internal Use Only")
4851 static DocumentFragment internalCreateDocumentFragment() {
4852 return new DocumentFragment.internal_();
4853 }
4854
4855 @Deprecated("Internal Use Only")
4856 DocumentFragment.internal_() : super.internal_();
4857
4858
4859 @DomName('DocumentFragment.getElementById')
4860 @DocsEditable()
4861 @Experimental() // untriaged
4862 Element getElementById(String elementId) {
4863 return _getElementById_1(elementId);
4864 }
4865 @JSName('getElementById')
4866 @DomName('DocumentFragment.getElementById')
4867 @DocsEditable()
4868 @Experimental() // untriaged
4869 Element _getElementById_1(elementId) => wrap_jso(JS("Element ", "#.raw.getElem entById(#)", this, unwrap_jso(elementId)));
4870
4871 // From ParentNode
4872
4873 @JSName('childElementCount')
4874 @DomName('DocumentFragment.childElementCount')
4875 @DocsEditable()
4876 int get _childElementCount => wrap_jso(JS("int", "#.childElementCount", this.r aw));
4877
4878 @JSName('firstElementChild')
4879 @DomName('DocumentFragment.firstElementChild')
4880 @DocsEditable()
4881 Element get _firstElementChild => wrap_jso(JS("Element", "#.firstElementChild" , this.raw));
4882
4883 @JSName('lastElementChild')
4884 @DomName('DocumentFragment.lastElementChild')
4885 @DocsEditable()
4886 Element get _lastElementChild => wrap_jso(JS("Element", "#.lastElementChild", this.raw));
4887
4888 /**
4889 * Finds the first descendant element of this document fragment that matches
4890 * the specified group of selectors.
4891 *
4892 * [selectors] should be a string using CSS selector syntax.
4893 *
4894 * var element1 = fragment.querySelector('.className');
4895 * var element2 = fragment.querySelector('#id');
4896 *
4897 * For details about CSS selector syntax, see the
4898 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
4899 */
4900 @DomName('DocumentFragment.querySelector')
4901 @DocsEditable()
4902 Element querySelector(String selectors) {
4903 return _querySelector_1(selectors);
4904 }
4905 @JSName('querySelector')
4906 /**
4907 * Finds the first descendant element of this document fragment that matches
4908 * the specified group of selectors.
4909 *
4910 * [selectors] should be a string using CSS selector syntax.
4911 *
4912 * var element1 = fragment.querySelector('.className');
4913 * var element2 = fragment.querySelector('#id');
4914 *
4915 * For details about CSS selector syntax, see the
4916 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
4917 */
4918 @DomName('DocumentFragment.querySelector')
4919 @DocsEditable()
4920 Element _querySelector_1(selectors) => wrap_jso(JS("Element ", "#.raw.querySel ector(#)", this, unwrap_jso(selectors)));
4921
4922 @DomName('DocumentFragment.querySelectorAll')
4923 @DocsEditable()
4924 @Returns('NodeList')
4925 @Creates('NodeList')
4926 NodeList _querySelectorAll(String selectors) {
4927 return _querySelectorAll_1(selectors);
4928 }
4929 @JSName('querySelectorAll')
4930 @DomName('DocumentFragment.querySelectorAll')
4931 @DocsEditable()
4932 @Returns('NodeList')
4933 @Creates('NodeList')
4934 NodeList _querySelectorAll_1(selectors) => wrap_jso(JS("NodeList ", "#.raw.que rySelectorAll(#)", this, unwrap_jso(selectors)));
4935
4936 }
4937 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4938 // for details. All rights reserved. Use of this source code is governed by a
4939 // BSD-style license that can be found in the LICENSE file.
4940
4941
4942 @DocsEditable()
4943 @DomName('DOMImplementation')
4944 @Native("DOMImplementation")
4945 class DomImplementation extends DartHtmlDomObject {
4946 // To suppress missing implicit constructor warnings.
4947 factory DomImplementation._() { throw new UnsupportedError("Not supported"); }
4948
4949 @Deprecated("Internal Use Only")
4950 static DomImplementation internalCreateDomImplementation() {
4951 return new DomImplementation.internal_();
4952 }
4953
4954 @Deprecated("Internal Use Only")
4955 DomImplementation.internal_() { }
4956
4957 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
4958 int get hashCode => unwrap_jso(this).hashCode;
4959
4960 @DomName('DOMImplementation.createDocument')
4961 @DocsEditable()
4962 Document createDocument(String namespaceURI, String qualifiedName, Node doctyp e) {
4963 return _createDocument_1(namespaceURI, qualifiedName, doctype);
4964 }
4965 @JSName('createDocument')
4966 @DomName('DOMImplementation.createDocument')
4967 @DocsEditable()
4968 Document _createDocument_1(namespaceURI, qualifiedName, Node doctype) => wrap_ jso(JS("Document ", "#.raw.createDocument(#, #, #)", this, unwrap_jso(namespaceU RI), unwrap_jso(qualifiedName), unwrap_jso(doctype)));
4969
4970 @DomName('DOMImplementation.createDocumentType')
4971 @DocsEditable()
4972 Node createDocumentType(String qualifiedName, String publicId, String systemId ) {
4973 return _createDocumentType_1(qualifiedName, publicId, systemId);
4974 }
4975 @JSName('createDocumentType')
4976 @DomName('DOMImplementation.createDocumentType')
4977 @DocsEditable()
4978 Node _createDocumentType_1(qualifiedName, publicId, systemId) => wrap_jso(JS(" Node ", "#.raw.createDocumentType(#, #, #)", this, unwrap_jso(qualifiedName), un wrap_jso(publicId), unwrap_jso(systemId)));
4979
4980 @DomName('DOMImplementation.createHTMLDocument')
4981 @DocsEditable()
4982 HtmlDocument createHtmlDocument(String title) {
4983 return _createHtmlDocument_1(title);
4984 }
4985 @JSName('createHTMLDocument')
4986 @DomName('DOMImplementation.createHTMLDocument')
4987 @DocsEditable()
4988 HtmlDocument _createHtmlDocument_1(title) => wrap_jso(JS("HtmlDocument ", "#.r aw.createHTMLDocument(#)", this, unwrap_jso(title)));
4989
4990 @DomName('DOMImplementation.hasFeature')
4991 @DocsEditable()
4992 bool hasFeature(String feature, String version) {
4993 return _hasFeature_1(feature, version);
4994 }
4995 @JSName('hasFeature')
4996 @DomName('DOMImplementation.hasFeature')
4997 @DocsEditable()
4998 bool _hasFeature_1(feature, version) => wrap_jso(JS("bool ", "#.raw.hasFeature (#, #)", this, unwrap_jso(feature), unwrap_jso(version)));
4999 }
5000 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
5001 // for details. All rights reserved. Use of this source code is governed by a
5002 // BSD-style license that can be found in the LICENSE file.
5003
5004
5005 @DocsEditable()
5006 @DomName('DOMTokenList')
5007 @Native("DOMTokenList")
5008 class DomTokenList extends DartHtmlDomObject {
5009 // To suppress missing implicit constructor warnings.
5010 factory DomTokenList._() { throw new UnsupportedError("Not supported"); }
5011
5012 @Deprecated("Internal Use Only")
5013 static DomTokenList internalCreateDomTokenList() {
5014 return new DomTokenList.internal_();
5015 }
5016
5017 @Deprecated("Internal Use Only")
5018 DomTokenList.internal_() { }
5019
5020 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
5021 int get hashCode => unwrap_jso(this).hashCode;
5022
5023 @DomName('DOMTokenList.length')
5024 @DocsEditable()
5025 int get length => wrap_jso(JS("int", "#.length", this.raw));
5026
5027 @DomName('DOMTokenList.add')
5028 @DocsEditable()
5029 @Experimental() // untriaged
5030 void add(String tokens) {
5031 _add_1(tokens);
5032 return;
5033 }
5034 @JSName('add')
5035 @DomName('DOMTokenList.add')
5036 @DocsEditable()
5037 @Experimental() // untriaged
5038 void _add_1(tokens) => wrap_jso(JS("void ", "#.raw.add(#)", this, unwrap_jso(t okens)));
5039
5040 @DomName('DOMTokenList.contains')
5041 @DocsEditable()
5042 bool contains(String token) {
5043 return _contains_1(token);
5044 }
5045 @JSName('contains')
5046 @DomName('DOMTokenList.contains')
5047 @DocsEditable()
5048 bool _contains_1(token) => wrap_jso(JS("bool ", "#.raw.contains(#)", this, unw rap_jso(token)));
5049
5050 @DomName('DOMTokenList.item')
5051 @DocsEditable()
5052 String item(int index) {
5053 return _item_1(index);
5054 }
5055 @JSName('item')
5056 @DomName('DOMTokenList.item')
5057 @DocsEditable()
5058 String _item_1(index) => wrap_jso(JS("String ", "#.raw.item(#)", this, unwrap_ jso(index)));
5059
5060 @DomName('DOMTokenList.remove')
5061 @DocsEditable()
5062 @Experimental() // untriaged
5063 void remove(String tokens) {
5064 _remove_1(tokens);
5065 return;
5066 }
5067 @JSName('remove')
5068 @DomName('DOMTokenList.remove')
5069 @DocsEditable()
5070 @Experimental() // untriaged
5071 void _remove_1(tokens) => wrap_jso(JS("void ", "#.raw.remove(#)", this, unwrap _jso(tokens)));
5072
5073 @DomName('DOMTokenList.toggle')
5074 @DocsEditable()
5075 bool toggle(String token, [bool force]) {
5076 if (force != null) {
5077 return _toggle_1(token, force);
5078 }
5079 return _toggle_2(token);
5080 }
5081 @JSName('toggle')
5082 @DomName('DOMTokenList.toggle')
5083 @DocsEditable()
5084 bool _toggle_1(token, force) => wrap_jso(JS("bool ", "#.raw.toggle(#, #)", thi s, unwrap_jso(token), unwrap_jso(force)));
5085 @JSName('toggle')
5086 @DomName('DOMTokenList.toggle')
5087 @DocsEditable()
5088 bool _toggle_2(token) => wrap_jso(JS("bool ", "#.raw.toggle(#)", this, unwrap_ jso(token)));
5089 }
5090 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
5091 // for details. All rights reserved. Use of this source code is governed by a
5092 // BSD-style license that can be found in the LICENSE file.
5093
5094
5095 class _ChildrenElementList extends ListBase<Element>
5096 implements NodeListWrapper {
5097 // Raw Element.
5098 final Element _element;
5099 final HtmlCollection _childElements;
5100
5101 _ChildrenElementList._wrap(Element element)
5102 : _childElements = element._children,
5103 _element = element;
5104
5105 bool contains(Object element) => _childElements.contains(element);
5106
5107
5108 bool get isEmpty {
5109 return _element._firstElementChild == null;
5110 }
5111
5112 int get length {
5113 return _childElements.length;
5114 }
5115
5116 Element operator [](int index) {
5117 return _childElements[index];
5118 }
5119
5120 void operator []=(int index, Element value) {
5121 _element._replaceChild(value, _childElements[index]);
5122 }
5123
5124 set length(int newLength) {
5125 // TODO(jacobr): remove children when length is reduced.
5126 throw new UnsupportedError('Cannot resize element lists');
5127 }
5128
5129 Element add(Element value) {
5130 _element.append(value);
5131 return value;
5132 }
5133
5134 Iterator<Element> get iterator => toList().iterator;
5135
5136 void addAll(Iterable<Element> iterable) {
5137 if (iterable is _ChildNodeListLazy) {
5138 iterable = new List.from(iterable);
5139 }
5140
5141 for (Element element in iterable) {
5142 _element.append(element);
5143 }
5144 }
5145
5146 void sort([int compare(Element a, Element b)]) {
5147 throw new UnsupportedError('Cannot sort element lists');
5148 }
5149
5150 void shuffle([Random random]) {
5151 throw new UnsupportedError('Cannot shuffle element lists');
5152 }
5153
5154 void removeWhere(bool test(Element element)) {
5155 _filter(test, false);
5156 }
5157
5158 void retainWhere(bool test(Element element)) {
5159 _filter(test, true);
5160 }
5161
5162 void _filter(bool test(var element), bool retainMatching) {
5163 var removed;
5164 if (retainMatching) {
5165 removed = _element.children.where((e) => !test(e));
5166 } else {
5167 removed = _element.children.where(test);
5168 }
5169 for (var e in removed) e.remove();
5170 }
5171
5172 void setRange(int start, int end, Iterable<Element> iterable,
5173 [int skipCount = 0]) {
5174 throw new UnimplementedError();
5175 }
5176
5177 void replaceRange(int start, int end, Iterable<Element> iterable) {
5178 throw new UnimplementedError();
5179 }
5180
5181 void fillRange(int start, int end, [Element fillValue]) {
5182 throw new UnimplementedError();
5183 }
5184
5185 bool remove(Object object) {
5186 if (object is Element) {
5187 Element element = object;
5188 // We aren't preserving identity of nodes in JSINTEROP mode
5189 if (element.parentNode == _element) {
5190 _element._removeChild(element);
5191 return true;
5192 }
5193 }
5194 return false;
5195 }
5196
5197 void insert(int index, Element element) {
5198 if (index < 0 || index > length) {
5199 throw new RangeError.range(index, 0, length);
5200 }
5201 if (index == length) {
5202 _element.append(element);
5203 } else {
5204 _element.insertBefore(element, this[index]);
5205 }
5206 }
5207
5208 void setAll(int index, Iterable<Element> iterable) {
5209 throw new UnimplementedError();
5210 }
5211
5212 void clear() {
5213 _element._clearChildren();
5214 }
5215
5216 Element removeAt(int index) {
5217 final result = this[index];
5218 if (result != null) {
5219 _element._removeChild(result);
5220 }
5221 return result;
5222 }
5223
5224 Element removeLast() {
5225 final result = this.last;
5226 if (result != null) {
5227 _element._removeChild(result);
5228 }
5229 return result;
5230 }
5231
5232 Element get first {
5233 Element result = _element._firstElementChild;
5234 if (result == null) throw new StateError("No elements");
5235 return result;
5236 }
5237
5238
5239 Element get last {
5240 Element result = _element._lastElementChild;
5241 if (result == null) throw new StateError("No elements");
5242 return result;
5243 }
5244
5245 Element get single {
5246 if (length > 1) throw new StateError("More than one element");
5247 return first;
5248 }
5249
5250 List<Node> get rawList => _childElements;
5251 }
5252
5253 /**
5254 * An immutable list containing HTML elements. This list contains some
5255 * additional methods when compared to regular lists for ease of CSS
5256 * manipulation on a group of elements.
5257 */
5258 abstract class ElementList<T extends Element> extends ListBase<T> {
5259 /**
5260 * The union of all CSS classes applied to the elements in this list.
5261 *
5262 * This set makes it easy to add, remove or toggle (add if not present, remove
5263 * if present) the classes applied to a collection of elements.
5264 *
5265 * htmlList.classes.add('selected');
5266 * htmlList.classes.toggle('isOnline');
5267 * htmlList.classes.remove('selected');
5268 */
5269 CssClassSet get classes;
5270
5271 /** Replace the classes with `value` for every element in this list. */
5272 set classes(Iterable<String> value);
5273
5274 /**
5275 * Access the union of all [CssStyleDeclaration]s that are associated with an
5276 * [ElementList].
5277 *
5278 * Grouping the style objects all together provides easy editing of specific
5279 * properties of a collection of elements. Setting a specific property value
5280 * will set that property in all [Element]s in the [ElementList]. Getting a
5281 * specific property value will return the value of the property of the first
5282 * element in the [ElementList].
5283 */
5284 CssStyleDeclarationBase get style;
5285
5286 /**
5287 * Access dimensions and position of the Elements in this list.
5288 *
5289 * Setting the height or width properties will set the height or width
5290 * property for all elements in the list. This returns a rectangle with the
5291 * dimenions actually available for content
5292 * in this element, in pixels, regardless of this element's box-sizing
5293 * property. Getting the height or width returns the height or width of the
5294 * first Element in this list.
5295 *
5296 * Unlike [getBoundingClientRect], the dimensions of this rectangle
5297 * will return the same numerical height if the element is hidden or not.
5298 */
5299 @Experimental()
5300 CssRect get contentEdge;
5301
5302 /**
5303 * Access dimensions and position of the first Element's content + padding box
5304 * in this list.
5305 *
5306 * This returns a rectangle with the dimenions actually available for content
5307 * in this element, in pixels, regardless of this element's box-sizing
5308 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
5309 * will return the same numerical height if the element is hidden or not. This
5310 * can be used to retrieve jQuery's `innerHeight` value for an element. This
5311 * is also a rectangle equalling the dimensions of clientHeight and
5312 * clientWidth.
5313 */
5314 @Experimental()
5315 CssRect get paddingEdge;
5316
5317 /**
5318 * Access dimensions and position of the first Element's content + padding +
5319 * border box in this list.
5320 *
5321 * This returns a rectangle with the dimenions actually available for content
5322 * in this element, in pixels, regardless of this element's box-sizing
5323 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
5324 * will return the same numerical height if the element is hidden or not. This
5325 * can be used to retrieve jQuery's `outerHeight` value for an element.
5326 */
5327 @Experimental()
5328 CssRect get borderEdge;
5329
5330 /**
5331 * Access dimensions and position of the first Element's content + padding +
5332 * border + margin box in this list.
5333 *
5334 * This returns a rectangle with the dimenions actually available for content
5335 * in this element, in pixels, regardless of this element's box-sizing
5336 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
5337 * will return the same numerical height if the element is hidden or not. This
5338 * can be used to retrieve jQuery's `outerHeight` value for an element.
5339 */
5340 @Experimental()
5341 CssRect get marginEdge;
5342
5343 /// Stream of `beforecopy` events handled by this [Element].
5344 @DomName('Element.onbeforecopy')
5345 @DocsEditable()
5346 ElementStream<Event> get onBeforeCopy;
5347
5348 /// Stream of `beforecut` events handled by this [Element].
5349 @DomName('Element.onbeforecut')
5350 @DocsEditable()
5351 ElementStream<Event> get onBeforeCut;
5352
5353 /// Stream of `beforepaste` events handled by this [Element].
5354 @DomName('Element.onbeforepaste')
5355 @DocsEditable()
5356 ElementStream<Event> get onBeforePaste;
5357
5358 /// Stream of `copy` events handled by this [Element].
5359 @DomName('Element.oncopy')
5360 @DocsEditable()
5361 ElementStream<Event> get onCopy;
5362
5363 /// Stream of `cut` events handled by this [Element].
5364 @DomName('Element.oncut')
5365 @DocsEditable()
5366 ElementStream<Event> get onCut;
5367
5368 /// Stream of `paste` events handled by this [Element].
5369 @DomName('Element.onpaste')
5370 @DocsEditable()
5371 ElementStream<Event> get onPaste;
5372
5373 /// Stream of `search` events handled by this [Element].
5374 @DomName('Element.onsearch')
5375 @DocsEditable()
5376 // http://www.w3.org/TR/html-markup/input.search.html
5377 @Experimental()
5378 ElementStream<Event> get onSearch;
5379
5380 /// Stream of `selectstart` events handled by this [Element].
5381 @DomName('Element.onselectstart')
5382 @DocsEditable()
5383 @Experimental() // nonstandard
5384 ElementStream<Event> get onSelectStart;
5385
5386 /// Stream of `fullscreenchange` events handled by this [Element].
5387 @DomName('Element.onwebkitfullscreenchange')
5388 @DocsEditable()
5389 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
5390 @Experimental()
5391 ElementStream<Event> get onFullscreenChange;
5392
5393 /// Stream of `fullscreenerror` events handled by this [Element].
5394 @DomName('Element.onwebkitfullscreenerror')
5395 @DocsEditable()
5396 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
5397 @Experimental()
5398 ElementStream<Event> get onFullscreenError;
5399
5400 }
5401
5402 // Wrapper over an immutable NodeList to make it implement ElementList.
5403 //
5404 // Clients are {`Document`, `DocumentFragment`}.`querySelectorAll` which are
5405 // declared to return `ElementList`. This provides all the static analysis
5406 // benefit so there is no need for this class have a constrained type parameter.
5407 //
5408 class _FrozenElementList extends ListBase<Element>
5409 implements ElementList<Element>, NodeListWrapper {
5410 final List<Node> _nodeList;
5411
5412 var dartClass_instance;
5413
5414 _FrozenElementList._wrap(this._nodeList) {
5415 this.dartClass_instance = this._nodeList;
5416 }
5417
5418 int get length => _nodeList.length;
5419
5420 Element operator [](int index) => _nodeList[index];
5421
5422 void operator []=(int index, Element value) {
5423 throw new UnsupportedError('Cannot modify list');
5424 }
5425
5426 set length(int newLength) {
5427 throw new UnsupportedError('Cannot modify list');
5428 }
5429
5430 void sort([Comparator<Element> compare]) {
5431 throw new UnsupportedError('Cannot sort list');
5432 }
5433
5434 void shuffle([Random random]) {
5435 throw new UnsupportedError('Cannot shuffle list');
5436 }
5437
5438 Element get first => _nodeList.first;
5439
5440 Element get last => _nodeList.last;
5441
5442 Element get single => _nodeList.single;
5443
5444 CssClassSet get classes => new _MultiElementCssClassSet(this);
5445
5446 CssStyleDeclarationBase get style =>
5447 new _CssStyleDeclarationSet(this);
5448
5449 set classes(Iterable<String> value) {
5450 // TODO(sra): This might be faster for Sets:
5451 //
5452 // new _MultiElementCssClassSet(this).writeClasses(value)
5453 //
5454 // as the code below converts the Iterable[value] to a string multiple
5455 // times. Maybe compute the string and set className here.
5456 _nodeList.forEach((e) => e.classes = value);
5457 }
5458
5459 CssRect get contentEdge => new _ContentCssListRect(this);
5460
5461 CssRect get paddingEdge => this.first.paddingEdge;
5462
5463 CssRect get borderEdge => this.first.borderEdge;
5464
5465 CssRect get marginEdge => this.first.marginEdge;
5466
5467 List<Node> get rawList => _nodeList;
5468
5469
5470 /// Stream of `beforecopy` events handled by this [Element].
5471 @DomName('Element.onbeforecopy')
5472 @DocsEditable()
5473 ElementStream<Event> get onBeforeCopy => Element.beforeCopyEvent._forElementLi st(this);
5474
5475 /// Stream of `beforecut` events handled by this [Element].
5476 @DomName('Element.onbeforecut')
5477 @DocsEditable()
5478 ElementStream<Event> get onBeforeCut => Element.beforeCutEvent._forElementList (this);
5479
5480 /// Stream of `beforepaste` events handled by this [Element].
5481 @DomName('Element.onbeforepaste')
5482 @DocsEditable()
5483 ElementStream<Event> get onBeforePaste => Element.beforePasteEvent._forElement List(this);
5484
5485 /// Stream of `copy` events handled by this [Element].
5486 @DomName('Element.oncopy')
5487 @DocsEditable()
5488 ElementStream<Event> get onCopy => Element.copyEvent._forElementList(this);
5489
5490 /// Stream of `cut` events handled by this [Element].
5491 @DomName('Element.oncut')
5492 @DocsEditable()
5493 ElementStream<Event> get onCut => Element.cutEvent._forElementList(this);
5494
5495 /// Stream of `paste` events handled by this [Element].
5496 @DomName('Element.onpaste')
5497 @DocsEditable()
5498 ElementStream<Event> get onPaste => Element.pasteEvent._forElementList(this);
5499
5500 /// Stream of `search` events handled by this [Element].
5501 @DomName('Element.onsearch')
5502 @DocsEditable()
5503 // http://www.w3.org/TR/html-markup/input.search.html
5504 @Experimental()
5505 ElementStream<Event> get onSearch => Element.searchEvent._forElementList(this) ;
5506
5507 /// Stream of `selectstart` events handled by this [Element].
5508 @DomName('Element.onselectstart')
5509 @DocsEditable()
5510 @Experimental() // nonstandard
5511 ElementStream<Event> get onSelectStart => Element.selectStartEvent._forElement List(this);
5512
5513 /// Stream of `fullscreenchange` events handled by this [Element].
5514 @DomName('Element.onwebkitfullscreenchange')
5515 @DocsEditable()
5516 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
5517 @Experimental()
5518 ElementStream<Event> get onFullscreenChange => Element.fullscreenChangeEvent._ forElementList(this);
5519
5520 /// Stream of `fullscreenerror` events handled by this [Element].
5521 @DomName('Element.onwebkitfullscreenerror')
5522 @DocsEditable()
5523 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
5524 @Experimental()
5525 ElementStream<Event> get onFullscreenError => Element.fullscreenErrorEvent._fo rElementList(this);
5526
5527 }
5528
5529 @DocsEditable()
5530 /**
5531 * An abstract class, which all HTML elements extend.
5532 */
5533 @DomName('Element')
5534 @Native("Element")
5535 class Element extends Node implements ParentNode, ChildNode {
5536
5537 /**
5538 * Creates an HTML element from a valid fragment of HTML.
5539 *
5540 * var element = new Element.html('<div class="foo">content</div>');
5541 *
5542 * The HTML fragment should contain only one single root element, any
5543 * leading or trailing text nodes will be removed.
5544 *
5545 * The HTML fragment is parsed as if it occurred within the context of a
5546 * `<body>` tag, this means that special elements such as `<caption>` which
5547 * must be parsed within the scope of a `<table>` element will be dropped. Use
5548 * [createFragment] to parse contextual HTML fragments.
5549 *
5550 * Unless a validator is provided this will perform the default validation
5551 * and remove all scriptable elements and attributes.
5552 *
5553 * See also:
5554 *
5555 * * [NodeValidator]
5556 *
5557 */
5558 factory Element.html(String html,
5559 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
5560 var fragment = document.body.createFragment(html, validator: validator,
5561 treeSanitizer: treeSanitizer);
5562
5563 return fragment.nodes.where((e) => e is Element).single;
5564 }
5565
5566 /**
5567 * Custom element creation constructor.
5568 *
5569 * This constructor is used by the DOM when a custom element has been
5570 * created. It can only be invoked by subclasses of Element from
5571 * that classes created constructor.
5572 *
5573 * class CustomElement extends Element {
5574 * factory CustomElement() => new Element.tag('x-custom');
5575 *
5576 * CustomElement.created() : super.created() {
5577 * // Perform any element initialization.
5578 * }
5579 * }
5580 * document.registerElement('x-custom', CustomElement);
5581 */
5582 Element.created() : super._created();
5583
5584 /**
5585 * Creates the HTML element specified by the tag name.
5586 *
5587 * This is similar to [Document.createElement].
5588 * [tag] should be a valid HTML tag name. If [tag] is an unknown tag then
5589 * this will create an [UnknownElement].
5590 *
5591 * var divElement = new Element.tag('div');
5592 * print(divElement is DivElement); // 'true'
5593 * var myElement = new Element.tag('unknownTag');
5594 * print(myElement is UnknownElement); // 'true'
5595 *
5596 * For standard elements it is more preferable to use the type constructors:
5597 * var element = new DivElement();
5598 *
5599 * See also:
5600 *
5601 * * [isTagSupported]
5602 */
5603 factory Element.tag(String tag, [String typeExtention]) =>
5604 _ElementFactoryProvider.createElement_tag(tag, typeExtention);
5605
5606 /// Creates a new `<a>` element.
5607 ///
5608 /// This is identical to calling `new Element.tag('a')`.
5609 factory Element.a() => new Element.tag('a');
5610
5611 /// Creates a new `<article>` element.
5612 ///
5613 /// This is identical to calling `new Element.tag('article')`.
5614 factory Element.article() => new Element.tag('article');
5615
5616 /// Creates a new `<aside>` element.
5617 ///
5618 /// This is identical to calling `new Element.tag('aside')`.
5619 factory Element.aside() => new Element.tag('aside');
5620
5621 /// Creates a new `<audio>` element.
5622 ///
5623 /// This is identical to calling `new Element.tag('audio')`.
5624 factory Element.audio() => new Element.tag('audio');
5625
5626 /// Creates a new `<br>` element.
5627 ///
5628 /// This is identical to calling `new Element.tag('br')`.
5629 factory Element.br() => new Element.tag('br');
5630
5631 /// Creates a new `<canvas>` element.
5632 ///
5633 /// This is identical to calling `new Element.tag('canvas')`.
5634 factory Element.canvas() => new Element.tag('canvas');
5635
5636 /// Creates a new `<div>` element.
5637 ///
5638 /// This is identical to calling `new Element.tag('div')`.
5639 factory Element.div() => new Element.tag('div');
5640
5641 /// Creates a new `<footer>` element.
5642 ///
5643 /// This is identical to calling `new Element.tag('footer')`.
5644 factory Element.footer() => new Element.tag('footer');
5645
5646 /// Creates a new `<header>` element.
5647 ///
5648 /// This is identical to calling `new Element.tag('header')`.
5649 factory Element.header() => new Element.tag('header');
5650
5651 /// Creates a new `<hr>` element.
5652 ///
5653 /// This is identical to calling `new Element.tag('hr')`.
5654 factory Element.hr() => new Element.tag('hr');
5655
5656 /// Creates a new `<iframe>` element.
5657 ///
5658 /// This is identical to calling `new Element.tag('iframe')`.
5659 factory Element.iframe() => new Element.tag('iframe');
5660
5661 /// Creates a new `<img>` element.
5662 ///
5663 /// This is identical to calling `new Element.tag('img')`.
5664 factory Element.img() => new Element.tag('img');
5665
5666 /// Creates a new `<li>` element.
5667 ///
5668 /// This is identical to calling `new Element.tag('li')`.
5669 factory Element.li() => new Element.tag('li');
5670
5671 /// Creates a new `<nav>` element.
5672 ///
5673 /// This is identical to calling `new Element.tag('nav')`.
5674 factory Element.nav() => new Element.tag('nav');
5675
5676 /// Creates a new `<ol>` element.
5677 ///
5678 /// This is identical to calling `new Element.tag('ol')`.
5679 factory Element.ol() => new Element.tag('ol');
5680
5681 /// Creates a new `<option>` element.
5682 ///
5683 /// This is identical to calling `new Element.tag('option')`.
5684 factory Element.option() => new Element.tag('option');
5685
5686 /// Creates a new `<p>` element.
5687 ///
5688 /// This is identical to calling `new Element.tag('p')`.
5689 factory Element.p() => new Element.tag('p');
5690
5691 /// Creates a new `<pre>` element.
5692 ///
5693 /// This is identical to calling `new Element.tag('pre')`.
5694 factory Element.pre() => new Element.tag('pre');
5695
5696 /// Creates a new `<section>` element.
5697 ///
5698 /// This is identical to calling `new Element.tag('section')`.
5699 factory Element.section() => new Element.tag('section');
5700
5701 /// Creates a new `<select>` element.
5702 ///
5703 /// This is identical to calling `new Element.tag('select')`.
5704 factory Element.select() => new Element.tag('select');
5705
5706 /// Creates a new `<span>` element.
5707 ///
5708 /// This is identical to calling `new Element.tag('span')`.
5709 factory Element.span() => new Element.tag('span');
5710
5711 /// Creates a new `<svg>` element.
5712 ///
5713 /// This is identical to calling `new Element.tag('svg')`.
5714 factory Element.svg() => new Element.tag('svg');
5715
5716 /// Creates a new `<table>` element.
5717 ///
5718 /// This is identical to calling `new Element.tag('table')`.
5719 factory Element.table() => new Element.tag('table');
5720
5721 /// Creates a new `<td>` element.
5722 ///
5723 /// This is identical to calling `new Element.tag('td')`.
5724 factory Element.td() => new Element.tag('td');
5725
5726 /// Creates a new `<textarea>` element.
5727 ///
5728 /// This is identical to calling `new Element.tag('textarea')`.
5729 factory Element.textarea() => new Element.tag('textarea');
5730
5731 /// Creates a new `<th>` element.
5732 ///
5733 /// This is identical to calling `new Element.tag('th')`.
5734 factory Element.th() => new Element.tag('th');
5735
5736 /// Creates a new `<tr>` element.
5737 ///
5738 /// This is identical to calling `new Element.tag('tr')`.
5739 factory Element.tr() => new Element.tag('tr');
5740
5741 /// Creates a new `<ul>` element.
5742 ///
5743 /// This is identical to calling `new Element.tag('ul')`.
5744 factory Element.ul() => new Element.tag('ul');
5745
5746 /// Creates a new `<video>` element.
5747 ///
5748 /// This is identical to calling `new Element.tag('video')`.
5749 factory Element.video() => new Element.tag('video');
5750
5751 /**
5752 * All attributes on this element.
5753 *
5754 * Any modifications to the attribute map will automatically be applied to
5755 * this element.
5756 *
5757 * This only includes attributes which are not in a namespace
5758 * (such as 'xlink:href'), additional attributes can be accessed via
5759 * [getNamespacedAttributes].
5760 */
5761 Map<String, String> get attributes => new _ElementAttributeMap(this);
5762
5763 set attributes(Map<String, String> value) {
5764 Map<String, String> attributes = this.attributes;
5765 attributes.clear();
5766 for (String key in value.keys) {
5767 attributes[key] = value[key];
5768 }
5769 }
5770
5771 /**
5772 * List of the direct children of this element.
5773 *
5774 * This collection can be used to add and remove elements from the document.
5775 *
5776 * var item = new DivElement();
5777 * item.text = 'Something';
5778 * document.body.children.add(item) // Item is now displayed on the page.
5779 * for (var element in document.body.children) {
5780 * element.style.background = 'red'; // Turns every child of body red.
5781 * }
5782 */
5783 List<Element> get children => new _ChildrenElementList._wrap(this);
5784
5785 set children(List<Element> value) {
5786 // Copy list first since we don't want liveness during iteration.
5787 List copy = new List.from(value);
5788 var children = this.children;
5789 children.clear();
5790 children.addAll(copy);
5791 }
5792
5793 /**
5794 * Finds all descendent elements of this element that match the specified
5795 * group of selectors.
5796 *
5797 * [selectors] should be a string using CSS selector syntax.
5798 *
5799 * var items = element.querySelectorAll('.itemClassName');
5800 *
5801 * For details about CSS selector syntax, see the
5802 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
5803 */
5804 @DomName('Element.querySelectorAll')
5805 ElementList<Element> querySelectorAll(String selectors) =>
5806 new _FrozenElementList._wrap(_querySelectorAll(selectors));
5807
5808 /**
5809 * Alias for [querySelector]. Note this function is deprecated because its
5810 * semantics will be changing in the future.
5811 */
5812 @deprecated
5813 @DomName('Element.querySelector')
5814 @Experimental()
5815 Element query(String relativeSelectors) => querySelector(relativeSelectors);
5816
5817 /**
5818 * Alias for [querySelectorAll]. Note this function is deprecated because its
5819 * semantics will be changing in the future.
5820 */
5821 @deprecated
5822 @DomName('Element.querySelectorAll')
5823 @Experimental()
5824 ElementList<Element> queryAll(String relativeSelectors) =>
5825 querySelectorAll(relativeSelectors);
5826
5827 /**
5828 * The set of CSS classes applied to this element.
5829 *
5830 * This set makes it easy to add, remove or toggle the classes applied to
5831 * this element.
5832 *
5833 * element.classes.add('selected');
5834 * element.classes.toggle('isOnline');
5835 * element.classes.remove('selected');
5836 */
5837 CssClassSet get classes => new _ElementCssClassSet(this);
5838
5839 set classes(Iterable<String> value) {
5840 // TODO(sra): Do this without reading the classes in clear() and addAll(),
5841 // or writing the classes in clear().
5842 CssClassSet classSet = classes;
5843 classSet.clear();
5844 classSet.addAll(value);
5845 }
5846
5847 /**
5848 * Allows access to all custom data attributes (data-*) set on this element.
5849 *
5850 * The keys for the map must follow these rules:
5851 *
5852 * * The name must not begin with 'xml'.
5853 * * The name cannot contain a semi-colon (';').
5854 * * The name cannot contain any capital letters.
5855 *
5856 * Any keys from markup will be converted to camel-cased keys in the map.
5857 *
5858 * For example, HTML specified as:
5859 *
5860 * <div data-my-random-value='value'></div>
5861 *
5862 * Would be accessed in Dart as:
5863 *
5864 * var value = element.dataset['myRandomValue'];
5865 *
5866 * See also:
5867 *
5868 * * [Custom data attributes](http://www.w3.org/TR/html5/global-attributes.htm l#custom-data-attribute)
5869 */
5870 Map<String, String> get dataset =>
5871 new _DataAttributeMap(attributes);
5872
5873 set dataset(Map<String, String> value) {
5874 final data = this.dataset;
5875 data.clear();
5876 for (String key in value.keys) {
5877 data[key] = value[key];
5878 }
5879 }
5880
5881 /**
5882 * Gets a map for manipulating the attributes of a particular namespace.
5883 *
5884 * This is primarily useful for SVG attributes such as xref:link.
5885 */
5886 Map<String, String> getNamespacedAttributes(String namespace) {
5887 return new _NamespacedAttributeMap(this, namespace);
5888 }
5889
5890 /**
5891 * The set of all CSS values applied to this element, including inherited
5892 * and default values.
5893 *
5894 * The computedStyle contains values that are inherited from other
5895 * sources, such as parent elements or stylesheets. This differs from the
5896 * [style] property, which contains only the values specified directly on this
5897 * element.
5898 *
5899 * PseudoElement can be values such as `::after`, `::before`, `::marker`,
5900 * `::line-marker`.
5901 *
5902 * See also:
5903 *
5904 * * [CSS Inheritance and Cascade](http://docs.webplatform.org/wiki/tutorials/ inheritance_and_cascade)
5905 * * [Pseudo-elements](http://docs.webplatform.org/wiki/css/selectors/pseudo-e lements)
5906 */
5907 CssStyleDeclaration getComputedStyle([String pseudoElement]) {
5908 if (pseudoElement == null) {
5909 pseudoElement = '';
5910 }
5911 // TODO(jacobr): last param should be null, see b/5045788
5912 return window._getComputedStyle(this, pseudoElement);
5913 }
5914
5915 /**
5916 * Gets the position of this element relative to the client area of the page.
5917 */
5918 Rectangle get client => new Rectangle(clientLeft, clientTop, clientWidth,
5919 clientHeight);
5920
5921 /**
5922 * Gets the offset of this element relative to its offsetParent.
5923 */
5924 Rectangle get offset => new Rectangle(offsetLeft, offsetTop, offsetWidth,
5925 offsetHeight);
5926
5927 /**
5928 * Adds the specified text after the last child of this element.
5929 */
5930 void appendText(String text) {
5931 this.append(new Text(text));
5932 }
5933
5934 /**
5935 * Parses the specified text as HTML and adds the resulting node after the
5936 * last child of this element.
5937 */
5938 void appendHtml(String text, {NodeValidator validator,
5939 NodeTreeSanitizer treeSanitizer}) {
5940 this.insertAdjacentHtml('beforeend', text, validator: validator,
5941 treeSanitizer: treeSanitizer);
5942 }
5943
5944 /**
5945 * Checks to see if the tag name is supported by the current platform.
5946 *
5947 * The tag should be a valid HTML tag name.
5948 */
5949 static bool isTagSupported(String tag) {
5950 var e = _ElementFactoryProvider.createElement_tag(tag, null);
5951 return e is Element && !(JS('bool', '#.constructor.name == "HTMLUnknownEleme nt"', e));
5952 }
5953
5954 /**
5955 * Called by the DOM when this element has been inserted into the live
5956 * document.
5957 *
5958 * More information can be found in the
5959 * [Custom Elements](http://w3c.github.io/webcomponents/spec/custom/#dfn-attac hed-callback)
5960 * draft specification.
5961 */
5962 @Experimental()
5963 void attached() {
5964 // For the deprecation period, call the old callback.
5965 enteredView();
5966 }
5967
5968 /**
5969 * Called by the DOM when this element has been removed from the live
5970 * document.
5971 *
5972 * More information can be found in the
5973 * [Custom Elements](http://w3c.github.io/webcomponents/spec/custom/#dfn-detac hed-callback)
5974 * draft specification.
5975 */
5976 @Experimental()
5977 void detached() {
5978 // For the deprecation period, call the old callback.
5979 leftView();
5980 }
5981
5982 /** *Deprecated*: override [attached] instead. */
5983 @Experimental()
5984 @deprecated
5985 void enteredView() {}
5986
5987 /** *Deprecated*: override [detached] instead. */
5988 @Experimental()
5989 @deprecated
5990 void leftView() {}
5991
5992
5993 /**
5994 * Called by the DOM whenever an attribute on this has been changed.
5995 */
5996 void attributeChanged(String name, String oldValue, String newValue) {}
5997
5998 // Hooks to support custom WebComponents.
5999
6000 Element _xtag;
6001
6002 /**
6003 * Experimental support for [web components][wc]. This field stores a
6004 * reference to the component implementation. It was inspired by Mozilla's
6005 * [x-tags][] project. Please note: in the future it may be possible to
6006 * `extend Element` from your class, in which case this field will be
6007 * deprecated.
6008 *
6009 * If xtag has not been set, it will simply return `this` [Element].
6010 *
6011 * [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html
6012 * [x-tags]: http://x-tags.org/
6013 */
6014 // Note: return type is `dynamic` for convenience to suppress warnings when
6015 // members of the component are used. The actual type is a subtype of Element.
6016 get xtag => _xtag != null ? _xtag : this;
6017
6018 set xtag(Element value) {
6019 _xtag = value;
6020 }
6021
6022 @DomName('Element.localName')
6023 @DocsEditable()
6024 String get localName => _localName;
6025
6026 /**
6027 * A URI that identifies the XML namespace of this element.
6028 *
6029 * `null` if no namespace URI is specified.
6030 *
6031 * ## Other resources
6032 *
6033 * * [Node.namespaceURI]
6034 * (http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-NodeNSname) from W3C.
6035 */
6036 @DomName('Element.namespaceUri')
6037 String get namespaceUri => _namespaceUri;
6038
6039 /**
6040 * The string representation of this element.
6041 *
6042 * This is equivalent to reading the [localName] property.
6043 */
6044 String toString() => localName;
6045
6046 /**
6047 * Scrolls this element into view.
6048 *
6049 * Only one of of the alignment options may be specified at a time.
6050 *
6051 * If no options are specified then this will attempt to scroll the minimum
6052 * amount needed to bring the element into view.
6053 *
6054 * Note that alignCenter is currently only supported on WebKit platforms. If
6055 * alignCenter is specified but not supported then this will fall back to
6056 * alignTop.
6057 *
6058 * See also:
6059 *
6060 * * [scrollIntoView](http://docs.webplatform.org/wiki/dom/methods/scrollIntoV iew)
6061 * * [scrollIntoViewIfNeeded](http://docs.webplatform.org/wiki/dom/methods/scr ollIntoViewIfNeeded)
6062 */
6063 void scrollIntoView([ScrollAlignment alignment]) {
6064 var hasScrollIntoViewIfNeeded = true;
6065 if (alignment == ScrollAlignment.TOP) {
6066 this._scrollIntoView(true);
6067 } else if (alignment == ScrollAlignment.BOTTOM) {
6068 this._scrollIntoView(false);
6069 } else if (hasScrollIntoViewIfNeeded) {
6070 if (alignment == ScrollAlignment.CENTER) {
6071 this._scrollIntoViewIfNeeded(true);
6072 } else {
6073 this._scrollIntoViewIfNeeded();
6074 }
6075 } else {
6076 this._scrollIntoView();
6077 }
6078 }
6079
6080
6081 /**
6082 * Parses text as an HTML fragment and inserts it into the DOM at the
6083 * specified location.
6084 *
6085 * The [where] parameter indicates where to insert the HTML fragment:
6086 *
6087 * * 'beforeBegin': Immediately before this element.
6088 * * 'afterBegin': As the first child of this element.
6089 * * 'beforeEnd': As the last child of this element.
6090 * * 'afterEnd': Immediately after this element.
6091 *
6092 * var html = '<div class="something">content</div>';
6093 * // Inserts as the first child
6094 * document.body.insertAdjacentHtml('afterBegin', html);
6095 * var createdElement = document.body.children[0];
6096 * print(createdElement.classes[0]); // Prints 'something'
6097 *
6098 * See also:
6099 *
6100 * * [insertAdjacentText]
6101 * * [insertAdjacentElement]
6102 */
6103 void insertAdjacentHtml(String where, String html, {NodeValidator validator,
6104 NodeTreeSanitizer treeSanitizer}) {
6105 if (treeSanitizer is _TrustedHtmlTreeSanitizer) {
6106 _insertAdjacentHtml(where, html);
6107 } else {
6108 _insertAdjacentNode(where, createFragment(html,
6109 validator: validator, treeSanitizer: treeSanitizer));
6110 }
6111 }
6112
6113 @JSName('insertAdjacentHTML')
6114 void _insertAdjacentHtml(String where, String text) => JS('void', '#.insertAdj acentHTML(#,#)', this.raw, where, text);
6115
6116
6117 void _insertAdjacentNode(String where, Node node) {
6118 switch (where.toLowerCase()) {
6119 case 'beforebegin':
6120 this.parentNode.insertBefore(node, this);
6121 break;
6122 case 'afterbegin':
6123 var first = this.nodes.length > 0 ? this.nodes[0] : null;
6124 this.insertBefore(node, first);
6125 break;
6126 case 'beforeend':
6127 this.append(node);
6128 break;
6129 case 'afterend':
6130 this.parentNode.insertBefore(node, this.nextNode);
6131 break;
6132 default:
6133 throw new ArgumentError("Invalid position ${where}");
6134 }
6135 }
6136
6137 bool matches(String selectors) => JS('bool', '#.matches(#)', this.raw, selecto rs);
6138
6139 /** Checks if this element or any of its parents match the CSS selectors. */
6140 @Experimental()
6141 bool matchesWithAncestors(String selectors) {
6142 var elem = this;
6143 do {
6144 if (elem.matches(selectors)) return true;
6145 elem = elem.parent;
6146 } while(elem != null);
6147 return false;
6148 }
6149
6150
6151 /**
6152 * Access this element's content position.
6153 *
6154 * This returns a rectangle with the dimenions actually available for content
6155 * in this element, in pixels, regardless of this element's box-sizing
6156 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
6157 * will return the same numerical height if the element is hidden or not.
6158 *
6159 * _Important_ _note_: use of this method _will_ perform CSS calculations that
6160 * can trigger a browser reflow. Therefore, use of this property _during_ an
6161 * animation frame is discouraged. See also:
6162 * [Browser Reflow](https://developers.google.com/speed/articles/reflow)
6163 */
6164 @Experimental()
6165 CssRect get contentEdge => new _ContentCssRect(this);
6166
6167 /**
6168 * Access the dimensions and position of this element's content + padding box.
6169 *
6170 * This returns a rectangle with the dimenions actually available for content
6171 * in this element, in pixels, regardless of this element's box-sizing
6172 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
6173 * will return the same numerical height if the element is hidden or not. This
6174 * can be used to retrieve jQuery's
6175 * [innerHeight](http://api.jquery.com/innerHeight/) value for an element.
6176 * This is also a rectangle equalling the dimensions of clientHeight and
6177 * clientWidth.
6178 *
6179 * _Important_ _note_: use of this method _will_ perform CSS calculations that
6180 * can trigger a browser reflow. Therefore, use of this property _during_ an
6181 * animation frame is discouraged. See also:
6182 * [Browser Reflow](https://developers.google.com/speed/articles/reflow)
6183 */
6184 @Experimental()
6185 CssRect get paddingEdge => new _PaddingCssRect(this);
6186
6187 /**
6188 * Access the dimensions and position of this element's content + padding +
6189 * border box.
6190 *
6191 * This returns a rectangle with the dimenions actually available for content
6192 * in this element, in pixels, regardless of this element's box-sizing
6193 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
6194 * will return the same numerical height if the element is hidden or not. This
6195 * can be used to retrieve jQuery's
6196 * [outerHeight](http://api.jquery.com/outerHeight/) value for an element.
6197 *
6198 * _Important_ _note_: use of this method _will_ perform CSS calculations that
6199 * can trigger a browser reflow. Therefore, use of this property _during_ an
6200 * animation frame is discouraged. See also:
6201 * [Browser Reflow](https://developers.google.com/speed/articles/reflow)
6202 */
6203 @Experimental()
6204 CssRect get borderEdge => new _BorderCssRect(this);
6205
6206 /**
6207 * Access the dimensions and position of this element's content + padding +
6208 * border + margin box.
6209 *
6210 * This returns a rectangle with the dimenions actually available for content
6211 * in this element, in pixels, regardless of this element's box-sizing
6212 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
6213 * will return the same numerical height if the element is hidden or not. This
6214 * can be used to retrieve jQuery's
6215 * [outerHeight](http://api.jquery.com/outerHeight/) value for an element.
6216 *
6217 * _Important_ _note_: use of this method will perform CSS calculations that
6218 * can trigger a browser reflow. Therefore, use of this property _during_ an
6219 * animation frame is discouraged. See also:
6220 * [Browser Reflow](https://developers.google.com/speed/articles/reflow)
6221 */
6222 @Experimental()
6223 CssRect get marginEdge => new _MarginCssRect(this);
6224
6225 /**
6226 * Provides the coordinates of the element relative to the top of the
6227 * document.
6228 *
6229 * This method is the Dart equivalent to jQuery's
6230 * [offset](http://api.jquery.com/offset/) method.
6231 */
6232 @Experimental()
6233 Point get documentOffset => offsetTo(document.documentElement);
6234
6235 /**
6236 * Provides the offset of this element's [borderEdge] relative to the
6237 * specified [parent].
6238 *
6239 * This is the Dart equivalent of jQuery's
6240 * [position](http://api.jquery.com/position/) method. Unlike jQuery's
6241 * position, however, [parent] can be any parent element of `this`,
6242 * rather than only `this`'s immediate [offsetParent]. If the specified
6243 * element is _not_ an offset parent or transitive offset parent to this
6244 * element, an [ArgumentError] is thrown.
6245 */
6246 @Experimental()
6247 Point offsetTo(Element parent) {
6248 return Element._offsetToHelper(this, parent);
6249 }
6250
6251 static Point _offsetToHelper(Element current, Element parent) {
6252 // We're hopping from _offsetParent_ to offsetParent (not just parent), so
6253 // offsetParent, "tops out" at BODY. But people could conceivably pass in
6254 // the document.documentElement and I want it to return an absolute offset,
6255 // so we have the special case checking for HTML.
6256 bool sameAsParent = current == parent;
6257 bool foundAsParent = sameAsParent || parent.tagName == 'HTML';
6258 if (current == null || sameAsParent) {
6259 if (foundAsParent) return new Point(0, 0);
6260 throw new ArgumentError("Specified element is not a transitive offset "
6261 "parent of this element.");
6262 }
6263 Element parentOffset = current.offsetParent;
6264 Point p = Element._offsetToHelper(parentOffset, parent);
6265 return new Point(p.x + current.offsetLeft, p.y + current.offsetTop);
6266 }
6267
6268 static HtmlDocument _parseDocument;
6269 static Range _parseRange;
6270 static NodeValidatorBuilder _defaultValidator;
6271 static _ValidatingTreeSanitizer _defaultSanitizer;
6272
6273 /**
6274 * Create a DocumentFragment from the HTML fragment and ensure that it follows
6275 * the sanitization rules specified by the validator or treeSanitizer.
6276 *
6277 * If the default validation behavior is too restrictive then a new
6278 * NodeValidator should be created, either extending or wrapping a default
6279 * validator and overriding the validation APIs.
6280 *
6281 * The treeSanitizer is used to walk the generated node tree and sanitize it.
6282 * A custom treeSanitizer can also be provided to perform special validation
6283 * rules but since the API is more complex to implement this is discouraged.
6284 *
6285 * The returned tree is guaranteed to only contain nodes and attributes which
6286 * are allowed by the provided validator.
6287 *
6288 * See also:
6289 *
6290 * * [NodeValidator]
6291 * * [NodeTreeSanitizer]
6292 */
6293 DocumentFragment createFragment(String html,
6294 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
6295 if (treeSanitizer == null) {
6296 if (validator == null) {
6297 if (_defaultValidator == null) {
6298 _defaultValidator = new NodeValidatorBuilder.common();
6299 }
6300 validator = _defaultValidator;
6301 }
6302 if (_defaultSanitizer == null) {
6303 _defaultSanitizer = new _ValidatingTreeSanitizer(validator);
6304 } else {
6305 _defaultSanitizer.validator = validator;
6306 }
6307 treeSanitizer = _defaultSanitizer;
6308 } else if (validator != null) {
6309 throw new ArgumentError(
6310 'validator can only be passed if treeSanitizer is null');
6311 }
6312
6313 if (_parseDocument == null) {
6314 _parseDocument = document.implementation.createHtmlDocument('');
6315 _parseRange = _parseDocument.createRange();
6316
6317 // Workaround for Safari bug. Was also previously Chrome bug 229142
6318 // - URIs are not resolved in new doc.
6319 BaseElement base = _parseDocument.createElement('base');
6320 base.href = document.baseUri;
6321 _parseDocument.head.append(base);
6322 }
6323 var contextElement;
6324 if (this is BodyElement) {
6325 contextElement = _parseDocument.body;
6326 } else {
6327 contextElement = _parseDocument.createElement(tagName);
6328 _parseDocument.body.append(contextElement);
6329 }
6330 var fragment;
6331 if (Range.supportsCreateContextualFragment &&
6332 _canBeUsedToCreateContextualFragment) {
6333 _parseRange.selectNodeContents(contextElement);
6334 fragment = _parseRange.createContextualFragment(html);
6335 } else {
6336 contextElement._innerHtml = html;
6337
6338 fragment = _parseDocument.createDocumentFragment();
6339 while (contextElement.firstChild != null) {
6340 fragment.append(contextElement.firstChild);
6341 }
6342 }
6343 if (contextElement != _parseDocument.body) {
6344 contextElement.remove();
6345 }
6346
6347 treeSanitizer.sanitizeTree(fragment);
6348 // Copy the fragment over to the main document (fix for 14184)
6349 document.adoptNode(fragment);
6350
6351 return fragment;
6352 }
6353
6354 /** Test if createContextualFragment is supported for this element type */
6355 bool get _canBeUsedToCreateContextualFragment =>
6356 !_cannotBeUsedToCreateContextualFragment;
6357
6358 /** Test if createContextualFragment is NOT supported for this element type */
6359 bool get _cannotBeUsedToCreateContextualFragment =>
6360 _tagsForWhichCreateContextualFragmentIsNotSupported.contains(tagName);
6361
6362 /**
6363 * A hard-coded list of the tag names for which createContextualFragment
6364 * isn't supported.
6365 */
6366 static const _tagsForWhichCreateContextualFragmentIsNotSupported =
6367 const ['HEAD', 'AREA',
6368 'BASE', 'BASEFONT', 'BR', 'COL', 'COLGROUP', 'EMBED', 'FRAME', 'FRAMESET',
6369 'HR', 'IMAGE', 'IMG', 'INPUT', 'ISINDEX', 'LINK', 'META', 'PARAM',
6370 'SOURCE', 'STYLE', 'TITLE', 'WBR'];
6371
6372 /**
6373 * Parses the HTML fragment and sets it as the contents of this element.
6374 *
6375 * This uses the default sanitization behavior to sanitize the HTML fragment,
6376 * use [setInnerHtml] to override the default behavior.
6377 */
6378 set innerHtml(String html) {
6379 this.setInnerHtml(html);
6380 }
6381
6382 /**
6383 * Parses the HTML fragment and sets it as the contents of this element.
6384 * This ensures that the generated content follows the sanitization rules
6385 * specified by the validator or treeSanitizer.
6386 *
6387 * If the default validation behavior is too restrictive then a new
6388 * NodeValidator should be created, either extending or wrapping a default
6389 * validator and overriding the validation APIs.
6390 *
6391 * The treeSanitizer is used to walk the generated node tree and sanitize it.
6392 * A custom treeSanitizer can also be provided to perform special validation
6393 * rules but since the API is more complex to implement this is discouraged.
6394 *
6395 * The resulting tree is guaranteed to only contain nodes and attributes which
6396 * are allowed by the provided validator.
6397 *
6398 * See also:
6399 *
6400 * * [NodeValidator]
6401 * * [NodeTreeSanitizer]
6402 */
6403 void setInnerHtml(String html,
6404 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
6405 text = null;
6406 if (treeSanitizer is _TrustedHtmlTreeSanitizer) {
6407 _innerHtml = html;
6408 } else {
6409 append(createFragment(
6410 html, validator: validator, treeSanitizer: treeSanitizer));
6411 }
6412 }
6413 String get innerHtml => _innerHtml;
6414
6415 /**
6416 * This is an ease-of-use accessor for event streams which should only be
6417 * used when an explicit accessor is not available.
6418 */
6419 ElementEvents get on => new ElementEvents(this);
6420
6421 /**
6422 * Verify if any of the attributes that we use in the sanitizer look unexpecte d,
6423 * possibly indicating DOM clobbering attacks.
6424 *
6425 * Those attributes are: attributes, lastChild, children, previousNode and tag Name.
6426 */
6427 static bool _hasCorruptedAttributes(Element element) {
6428 return JS('bool', r'''
6429 (function(element) {
6430 if (!(element.attributes instanceof NamedNodeMap)) {
6431 return true;
6432 }
6433 var childNodes = element.childNodes;
6434 if (element.lastChild &&
6435 element.lastChild !== childNodes[childNodes.length -1]) {
6436 return true;
6437 }
6438 if (element.children) { // On Safari, children can apparently be null.
6439 if (!((element.children instanceof HTMLCollection) ||
6440 (element.children instanceof NodeList))) {
6441 return true;
6442 }
6443 }
6444 var length = 0;
6445 if (element.children) {
6446 length = element.children.length;
6447 }
6448 for (var i = 0; i < length; i++) {
6449 var child = element.children[i];
6450 // On IE it seems like we sometimes don't see the clobbered attribute ,
6451 // perhaps as a result of an over-optimization. Also use another rout e
6452 // to check of attributes, children, or lastChild are clobbered. It m ay
6453 // seem silly to check children as we rely on children to do this ite ration,
6454 // but it seems possible that the access to children might see the re al thing,
6455 // allowing us to check for clobbering that may show up in other acce sses.
6456 if (child["id"] == 'attributes' || child["name"] == 'attributes' ||
6457 child["id"] == 'lastChild' || child["name"] == 'lastChild' ||
6458 child["id"] == 'children' || child["name"] == 'children') {
6459 return true;
6460 }
6461 }
6462 return false;
6463 })(#)''',
6464 element.raw
6465 );
6466 }
6467
6468 /// A secondary check for corruption, needed on IE
6469 static bool _hasCorruptedAttributesAdditionalCheck(Element element) {
6470 return JS('bool', r'!(#.attributes instanceof NamedNodeMap)',
6471 element.raw
6472 );
6473 }
6474
6475 static String _safeTagName(element) {
6476 String result = 'element tag unavailable';
6477 try {
6478 if (element.tagName is String) {
6479 result = element.tagName;
6480 }
6481 } catch (e) {}
6482 return result;
6483 }
6484
6485 @DomName('Element.offsetHeight')
6486 @DocsEditable()
6487 int get offsetHeight => JS('num', '#.offsetHeight', this.raw).round();
6488
6489 @DomName('Element.offsetLeft')
6490 @DocsEditable()
6491 int get offsetLeft => JS('num', '#.offsetLeft', this.raw).round();
6492
6493 @DomName('Element.offsetTop')
6494 @DocsEditable()
6495 int get offsetTop => JS('num', '#.offsetTop', this.raw).round();
6496
6497 @DomName('Element.offsetWidth')
6498 @DocsEditable()
6499 int get offsetWidth => JS('num', '#.offsetWidth', this.raw).round();
6500
6501 @DomName('Element.clientHeight')
6502 @DocsEditable()
6503 int get clientHeight => JS('num', '#.clientHeight', this.raw).round();
6504
6505 @DomName('Element.clientLeft')
6506 @DocsEditable()
6507 int get clientLeft => JS('num', '#.clientLeft', this.raw).round();
6508
6509 @DomName('Element.clientTop')
6510 @DocsEditable()
6511 int get clientTop => JS('num', '#.clientTop', this.raw).round();
6512
6513 @DomName('Element.clientWidth')
6514 @DocsEditable()
6515 int get clientWidth => JS('num', '#.clientWidth', this.raw).round();
6516
6517 @DomName('Element.scrollHeight')
6518 @DocsEditable()
6519 int get scrollHeight => JS('num', '#.scrollHeight', this.raw).round();
6520
6521 @DomName('Element.scrollLeft')
6522 @DocsEditable()
6523 int get scrollLeft => JS('num', '#.scrollLeft', this.raw).round();
6524
6525 @DomName('Element.scrollLeft')
6526 @DocsEditable()
6527 set scrollLeft(int value) {
6528 JS("void", "#.scrollLeft = #", this.raw, value.round());
6529 }
6530
6531 @DomName('Element.scrollTop')
6532 @DocsEditable()
6533 int get scrollTop => JS('num', '#.scrollTop', this.raw).round();
6534
6535 @DomName('Element.scrollTop')
6536 @DocsEditable()
6537 set scrollTop(int value) {
6538 JS("void", "#.scrollTop = #", this.raw, value.round());
6539 }
6540
6541 @DomName('Element.scrollWidth')
6542 @DocsEditable()
6543 int get scrollWidth => JS('num', '#.scrollWidth', this.raw).round();
6544
6545 // To suppress missing implicit constructor warnings.
6546 factory Element._() { throw new UnsupportedError("Not supported"); }
6547
6548 /**
6549 * Static factory designed to expose `beforecopy` events to event
6550 * handlers that are not necessarily instances of [Element].
6551 *
6552 * See [EventStreamProvider] for usage information.
6553 */
6554 @DomName('Element.beforecopyEvent')
6555 @DocsEditable()
6556 static const EventStreamProvider<Event> beforeCopyEvent = const EventStreamPro vider<Event>('beforecopy');
6557
6558 /**
6559 * Static factory designed to expose `beforecut` events to event
6560 * handlers that are not necessarily instances of [Element].
6561 *
6562 * See [EventStreamProvider] for usage information.
6563 */
6564 @DomName('Element.beforecutEvent')
6565 @DocsEditable()
6566 static const EventStreamProvider<Event> beforeCutEvent = const EventStreamProv ider<Event>('beforecut');
6567
6568 /**
6569 * Static factory designed to expose `beforepaste` events to event
6570 * handlers that are not necessarily instances of [Element].
6571 *
6572 * See [EventStreamProvider] for usage information.
6573 */
6574 @DomName('Element.beforepasteEvent')
6575 @DocsEditable()
6576 static const EventStreamProvider<Event> beforePasteEvent = const EventStreamPr ovider<Event>('beforepaste');
6577
6578 /**
6579 * Static factory designed to expose `copy` events to event
6580 * handlers that are not necessarily instances of [Element].
6581 *
6582 * See [EventStreamProvider] for usage information.
6583 */
6584 @DomName('Element.copyEvent')
6585 @DocsEditable()
6586 static const EventStreamProvider<Event> copyEvent = const EventStreamProvider< Event>('copy');
6587
6588 /**
6589 * Static factory designed to expose `cut` events to event
6590 * handlers that are not necessarily instances of [Element].
6591 *
6592 * See [EventStreamProvider] for usage information.
6593 */
6594 @DomName('Element.cutEvent')
6595 @DocsEditable()
6596 static const EventStreamProvider<Event> cutEvent = const EventStreamProvider<E vent>('cut');
6597
6598 /**
6599 * Static factory designed to expose `paste` events to event
6600 * handlers that are not necessarily instances of [Element].
6601 *
6602 * See [EventStreamProvider] for usage information.
6603 */
6604 @DomName('Element.pasteEvent')
6605 @DocsEditable()
6606 static const EventStreamProvider<Event> pasteEvent = const EventStreamProvider <Event>('paste');
6607
6608 /**
6609 * Static factory designed to expose `search` events to event
6610 * handlers that are not necessarily instances of [Element].
6611 *
6612 * See [EventStreamProvider] for usage information.
6613 */
6614 @DomName('Element.searchEvent')
6615 @DocsEditable()
6616 // http://www.w3.org/TR/html-markup/input.search.html
6617 @Experimental()
6618 static const EventStreamProvider<Event> searchEvent = const EventStreamProvide r<Event>('search');
6619
6620 /**
6621 * Static factory designed to expose `selectstart` events to event
6622 * handlers that are not necessarily instances of [Element].
6623 *
6624 * See [EventStreamProvider] for usage information.
6625 */
6626 @DomName('Element.selectstartEvent')
6627 @DocsEditable()
6628 @Experimental() // nonstandard
6629 static const EventStreamProvider<Event> selectStartEvent = const EventStreamPr ovider<Event>('selectstart');
6630
6631 /**
6632 * Static factory designed to expose `fullscreenchange` events to event
6633 * handlers that are not necessarily instances of [Element].
6634 *
6635 * See [EventStreamProvider] for usage information.
6636 */
6637 @DomName('Element.webkitfullscreenchangeEvent')
6638 @DocsEditable()
6639 @SupportedBrowser(SupportedBrowser.CHROME)
6640 @SupportedBrowser(SupportedBrowser.SAFARI)
6641 @Experimental()
6642 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
6643 static const EventStreamProvider<Event> fullscreenChangeEvent = const EventStr eamProvider<Event>('webkitfullscreenchange');
6644
6645 /**
6646 * Static factory designed to expose `fullscreenerror` events to event
6647 * handlers that are not necessarily instances of [Element].
6648 *
6649 * See [EventStreamProvider] for usage information.
6650 */
6651 @DomName('Element.webkitfullscreenerrorEvent')
6652 @DocsEditable()
6653 @SupportedBrowser(SupportedBrowser.CHROME)
6654 @SupportedBrowser(SupportedBrowser.SAFARI)
6655 @Experimental()
6656 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
6657 static const EventStreamProvider<Event> fullscreenErrorEvent = const EventStre amProvider<Event>('webkitfullscreenerror');
6658
6659
6660 @Deprecated("Internal Use Only")
6661 static Element internalCreateElement() {
6662 return new Element.internal_();
6663 }
6664
6665 @Deprecated("Internal Use Only")
6666 Element.internal_() : super.internal_();
6667
6668
6669 @DomName('Element.contentEditable')
6670 @DocsEditable()
6671 String get contentEditable => wrap_jso(JS("String", "#.contentEditable", this. raw));
6672 @DomName('Element.contentEditable')
6673 @DocsEditable()
6674 void set contentEditable(String val) => JS("void", "#.contentEditable = #", th is.raw, unwrap_jso(val));
6675
6676 @DomName('Element.contextMenu')
6677 @DocsEditable()
6678 @Experimental() // untriaged
6679 HtmlElement get contextMenu => wrap_jso(JS("HtmlElement", "#.contextMenu", thi s.raw));
6680 @DomName('Element.contextMenu')
6681 @DocsEditable()
6682 @Experimental() // untriaged
6683 void set contextMenu(HtmlElement val) => JS("void", "#.contextMenu = #", this. raw, unwrap_jso(val));
6684
6685 @DomName('Element.dir')
6686 @DocsEditable()
6687 String get dir => wrap_jso(JS("String", "#.dir", this.raw));
6688 @DomName('Element.dir')
6689 @DocsEditable()
6690 void set dir(String val) => JS("void", "#.dir = #", this.raw, unwrap_jso(val)) ;
6691
6692 /**
6693 * Indicates whether the element can be dragged and dropped.
6694 *
6695 * ## Other resources
6696 *
6697 * * [Drag and drop sample]
6698 * (https://github.com/dart-lang/dart-samples/tree/master/web/html5/dnd/basics )
6699 * based on [the tutorial](http://www.html5rocks.com/en/tutorials/dnd/basics/)
6700 * from HTML5Rocks.
6701 * * [Drag and drop specification]
6702 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dnd)
6703 * from WHATWG.
6704 */
6705 @DomName('Element.draggable')
6706 @DocsEditable()
6707 bool get draggable => wrap_jso(JS("bool", "#.draggable", this.raw));
6708 /**
6709 * Indicates whether the element can be dragged and dropped.
6710 *
6711 * ## Other resources
6712 *
6713 * * [Drag and drop sample]
6714 * (https://github.com/dart-lang/dart-samples/tree/master/web/html5/dnd/basics )
6715 * based on [the tutorial](http://www.html5rocks.com/en/tutorials/dnd/basics/)
6716 * from HTML5Rocks.
6717 * * [Drag and drop specification]
6718 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dnd)
6719 * from WHATWG.
6720 */
6721 @DomName('Element.draggable')
6722 @DocsEditable()
6723 void set draggable(bool val) => JS("void", "#.draggable = #", this.raw, unwrap _jso(val));
6724
6725 /**
6726 * Indicates whether the element is not relevant to the page's current state.
6727 *
6728 * ## Other resources
6729 *
6730 * * [Hidden attribute specification]
6731 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#t he-hidden-attribute)
6732 * from WHATWG.
6733 */
6734 @DomName('Element.hidden')
6735 @DocsEditable()
6736 bool get hidden => wrap_jso(JS("bool", "#.hidden", this.raw));
6737 /**
6738 * Indicates whether the element is not relevant to the page's current state.
6739 *
6740 * ## Other resources
6741 *
6742 * * [Hidden attribute specification]
6743 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#t he-hidden-attribute)
6744 * from WHATWG.
6745 */
6746 @DomName('Element.hidden')
6747 @DocsEditable()
6748 void set hidden(bool val) => JS("void", "#.hidden = #", this.raw, unwrap_jso(v al));
6749
6750 @DomName('Element.isContentEditable')
6751 @DocsEditable()
6752 bool get isContentEditable => wrap_jso(JS("bool", "#.isContentEditable", this. raw));
6753
6754 @DomName('Element.lang')
6755 @DocsEditable()
6756 String get lang => wrap_jso(JS("String", "#.lang", this.raw));
6757 @DomName('Element.lang')
6758 @DocsEditable()
6759 void set lang(String val) => JS("void", "#.lang = #", this.raw, unwrap_jso(val ));
6760
6761 @DomName('Element.spellcheck')
6762 @DocsEditable()
6763 // http://blog.whatwg.org/the-road-to-html-5-spellchecking
6764 @Experimental() // nonstandard
6765 bool get spellcheck => wrap_jso(JS("bool", "#.spellcheck", this.raw));
6766 @DomName('Element.spellcheck')
6767 @DocsEditable()
6768 // http://blog.whatwg.org/the-road-to-html-5-spellchecking
6769 @Experimental() // nonstandard
6770 void set spellcheck(bool val) => JS("void", "#.spellcheck = #", this.raw, unwr ap_jso(val));
6771
6772 @DomName('Element.tabIndex')
6773 @DocsEditable()
6774 int get tabIndex => wrap_jso(JS("int", "#.tabIndex", this.raw));
6775 @DomName('Element.tabIndex')
6776 @DocsEditable()
6777 void set tabIndex(int val) => JS("void", "#.tabIndex = #", this.raw, unwrap_js o(val));
6778
6779 @DomName('Element.title')
6780 @DocsEditable()
6781 String get title => wrap_jso(JS("String", "#.title", this.raw));
6782 @DomName('Element.title')
6783 @DocsEditable()
6784 void set title(String val) => JS("void", "#.title = #", this.raw, unwrap_jso(v al));
6785
6786 /**
6787 * Specifies whether this element's text content changes when the page is
6788 * localized.
6789 *
6790 * ## Other resources
6791 *
6792 * * [The translate attribute]
6793 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html# the-translate-attribute)
6794 * from WHATWG.
6795 */
6796 @DomName('Element.translate')
6797 @DocsEditable()
6798 // http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#t he-translate-attribute
6799 @Experimental()
6800 bool get translate => wrap_jso(JS("bool", "#.translate", this.raw));
6801 /**
6802 * Specifies whether this element's text content changes when the page is
6803 * localized.
6804 *
6805 * ## Other resources
6806 *
6807 * * [The translate attribute]
6808 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html# the-translate-attribute)
6809 * from WHATWG.
6810 */
6811 @DomName('Element.translate')
6812 @DocsEditable()
6813 // http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#t he-translate-attribute
6814 @Experimental()
6815 void set translate(bool val) => JS("void", "#.translate = #", this.raw, unwrap _jso(val));
6816
6817 @JSName('webkitdropzone')
6818 /**
6819 * A set of space-separated keywords that specify what kind of data this
6820 * Element accepts on drop and what to do with that data.
6821 *
6822 * ## Other resources
6823 *
6824 * * [Drag and drop sample]
6825 * (https://github.com/dart-lang/dart-samples/tree/master/web/html5/dnd/basics )
6826 * based on [the tutorial](http://www.html5rocks.com/en/tutorials/dnd/basics/)
6827 * from HTML5Rocks.
6828 * * [Drag and drop specification]
6829 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dnd)
6830 * from WHATWG.
6831 */
6832 @DomName('Element.webkitdropzone')
6833 @DocsEditable()
6834 @SupportedBrowser(SupportedBrowser.CHROME)
6835 @SupportedBrowser(SupportedBrowser.SAFARI)
6836 @Experimental()
6837 // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#the-dr opzone-attribute
6838 String get dropzone => wrap_jso(JS("String", "#.webkitdropzone", this.raw));
6839 @JSName('webkitdropzone')
6840 /**
6841 * A set of space-separated keywords that specify what kind of data this
6842 * Element accepts on drop and what to do with that data.
6843 *
6844 * ## Other resources
6845 *
6846 * * [Drag and drop sample]
6847 * (https://github.com/dart-lang/dart-samples/tree/master/web/html5/dnd/basics )
6848 * based on [the tutorial](http://www.html5rocks.com/en/tutorials/dnd/basics/)
6849 * from HTML5Rocks.
6850 * * [Drag and drop specification]
6851 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dnd)
6852 * from WHATWG.
6853 */
6854 @DomName('Element.webkitdropzone')
6855 @DocsEditable()
6856 @SupportedBrowser(SupportedBrowser.CHROME)
6857 @SupportedBrowser(SupportedBrowser.SAFARI)
6858 @Experimental()
6859 // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#the-dr opzone-attribute
6860 void set dropzone(String val) => JS("void", "#.webkitdropzone = #", this.raw, unwrap_jso(val));
6861
6862 @DomName('Element.click')
6863 @DocsEditable()
6864 void click() {
6865 _click_1();
6866 return;
6867 }
6868 @JSName('click')
6869 @DomName('Element.click')
6870 @DocsEditable()
6871 void _click_1() => wrap_jso(JS("void ", "#.raw.click()", this));
6872
6873 @JSName('attributes')
6874 @DomName('Element.attributes')
6875 @DocsEditable()
6876 _NamedNodeMap get _attributes => wrap_jso(JS("_NamedNodeMap", "#.attributes", this.raw));
6877
6878 @DomName('Element.className')
6879 @DocsEditable()
6880 String get className => wrap_jso(JS("String", "#.className", this.raw));
6881 @DomName('Element.className')
6882 @DocsEditable()
6883 void set className(String val) => JS("void", "#.className = #", this.raw, unwr ap_jso(val));
6884
6885 @JSName('clientHeight')
6886 @DomName('Element.clientHeight')
6887 @DocsEditable()
6888 int get _clientHeight => wrap_jso(JS("int", "#.clientHeight", this.raw));
6889
6890 @JSName('clientLeft')
6891 @DomName('Element.clientLeft')
6892 @DocsEditable()
6893 int get _clientLeft => wrap_jso(JS("int", "#.clientLeft", this.raw));
6894
6895 @JSName('clientTop')
6896 @DomName('Element.clientTop')
6897 @DocsEditable()
6898 int get _clientTop => wrap_jso(JS("int", "#.clientTop", this.raw));
6899
6900 @JSName('clientWidth')
6901 @DomName('Element.clientWidth')
6902 @DocsEditable()
6903 int get _clientWidth => wrap_jso(JS("int", "#.clientWidth", this.raw));
6904
6905 @DomName('Element.id')
6906 @DocsEditable()
6907 String get id => wrap_jso(JS("String", "#.id", this.raw));
6908 @DomName('Element.id')
6909 @DocsEditable()
6910 void set id(String val) => JS("void", "#.id = #", this.raw, unwrap_jso(val));
6911
6912 @JSName('innerHTML')
6913 @DomName('Element.innerHTML')
6914 @DocsEditable()
6915 String get _innerHtml => wrap_jso(JS("String", "#.innerHTML", this.raw));
6916 @JSName('innerHTML')
6917 @DomName('Element.innerHTML')
6918 @DocsEditable()
6919 void set _innerHtml(String val) => JS("void", "#.innerHTML = #", this.raw, unw rap_jso(val));
6920
6921 // Use implementation from Node.
6922 // final String _localName;
6923
6924 // Use implementation from Node.
6925 // final String _namespaceUri;
6926
6927 @JSName('offsetHeight')
6928 @DomName('Element.offsetHeight')
6929 @DocsEditable()
6930 int get _offsetHeight => wrap_jso(JS("int", "#.offsetHeight", this.raw));
6931
6932 @JSName('offsetLeft')
6933 @DomName('Element.offsetLeft')
6934 @DocsEditable()
6935 int get _offsetLeft => wrap_jso(JS("int", "#.offsetLeft", this.raw));
6936
6937 @DomName('Element.offsetParent')
6938 @DocsEditable()
6939 Element get offsetParent => wrap_jso(JS("Element", "#.offsetParent", this.raw) );
6940
6941 @JSName('offsetTop')
6942 @DomName('Element.offsetTop')
6943 @DocsEditable()
6944 int get _offsetTop => wrap_jso(JS("int", "#.offsetTop", this.raw));
6945
6946 @JSName('offsetWidth')
6947 @DomName('Element.offsetWidth')
6948 @DocsEditable()
6949 int get _offsetWidth => wrap_jso(JS("int", "#.offsetWidth", this.raw));
6950
6951 @JSName('outerHTML')
6952 @DomName('Element.outerHTML')
6953 @DocsEditable()
6954 String get outerHtml => wrap_jso(JS("String", "#.outerHTML", this.raw));
6955
6956 @JSName('scrollHeight')
6957 @DomName('Element.scrollHeight')
6958 @DocsEditable()
6959 int get _scrollHeight => wrap_jso(JS("int", "#.scrollHeight", this.raw));
6960
6961 @JSName('scrollLeft')
6962 @DomName('Element.scrollLeft')
6963 @DocsEditable()
6964 num get _scrollLeft => wrap_jso(JS("num", "#.scrollLeft", this.raw));
6965 @JSName('scrollLeft')
6966 @DomName('Element.scrollLeft')
6967 @DocsEditable()
6968 void set _scrollLeft(num val) => JS("void", "#.scrollLeft = #", this.raw, unwr ap_jso(val));
6969
6970 @JSName('scrollTop')
6971 @DomName('Element.scrollTop')
6972 @DocsEditable()
6973 num get _scrollTop => wrap_jso(JS("num", "#.scrollTop", this.raw));
6974 @JSName('scrollTop')
6975 @DomName('Element.scrollTop')
6976 @DocsEditable()
6977 void set _scrollTop(num val) => JS("void", "#.scrollTop = #", this.raw, unwrap _jso(val));
6978
6979 @JSName('scrollWidth')
6980 @DomName('Element.scrollWidth')
6981 @DocsEditable()
6982 int get _scrollWidth => wrap_jso(JS("int", "#.scrollWidth", this.raw));
6983
6984 @DomName('Element.style')
6985 @DocsEditable()
6986 CssStyleDeclaration get style => wrap_jso(JS("CssStyleDeclaration", "#.style", this.raw));
6987
6988 @DomName('Element.tagName')
6989 @DocsEditable()
6990 String get tagName => wrap_jso(JS("String", "#.tagName", this.raw));
6991
6992 @DomName('Element.blur')
6993 @DocsEditable()
6994 void blur() {
6995 _blur_1();
6996 return;
6997 }
6998 @JSName('blur')
6999 @DomName('Element.blur')
7000 @DocsEditable()
7001 void _blur_1() => wrap_jso(JS("void ", "#.raw.blur()", this));
7002
7003 @DomName('Element.focus')
7004 @DocsEditable()
7005 void focus() {
7006 _focus_1();
7007 return;
7008 }
7009 @JSName('focus')
7010 @DomName('Element.focus')
7011 @DocsEditable()
7012 void _focus_1() => wrap_jso(JS("void ", "#.raw.focus()", this));
7013
7014 @DomName('Element.getAttribute')
7015 @DocsEditable()
7016 @Experimental() // untriaged
7017 String getAttribute(String name) {
7018 return _getAttribute_1(name);
7019 }
7020 @JSName('getAttribute')
7021 @DomName('Element.getAttribute')
7022 @DocsEditable()
7023 @Experimental() // untriaged
7024 String _getAttribute_1(name) => wrap_jso(JS("String ", "#.raw.getAttribute(#)" , this, unwrap_jso(name)));
7025
7026 @DomName('Element.getAttributeNS')
7027 @DocsEditable()
7028 @Experimental() // untriaged
7029 String getAttributeNS(String namespaceURI, String localName) {
7030 return _getAttributeNS_1(namespaceURI, localName);
7031 }
7032 @JSName('getAttributeNS')
7033 @DomName('Element.getAttributeNS')
7034 @DocsEditable()
7035 @Experimental() // untriaged
7036 String _getAttributeNS_1(namespaceURI, localName) => wrap_jso(JS("String ", "# .raw.getAttributeNS(#, #)", this, unwrap_jso(namespaceURI), unwrap_jso(localName )));
7037
7038 /**
7039 * Returns the smallest bounding rectangle that encompasses this element's
7040 * padding, scrollbar, and border.
7041 *
7042 * ## Other resources
7043 *
7044 * * [Element.getBoundingClientRect]
7045 * (https://developer.mozilla.org/en-US/docs/Web/API/Element.getBoundingClient Rect)
7046 * from MDN.
7047 * * [The getBoundingClientRect() method]
7048 * (http://www.w3.org/TR/cssom-view/#the-getclientrects-and-getboundingclientr ect-methods)
7049 * from W3C.
7050 */
7051 @DomName('Element.getBoundingClientRect')
7052 @DocsEditable()
7053 Rectangle getBoundingClientRect() {
7054 return _getBoundingClientRect_1();
7055 }
7056 @JSName('getBoundingClientRect')
7057 /**
7058 * Returns the smallest bounding rectangle that encompasses this element's
7059 * padding, scrollbar, and border.
7060 *
7061 * ## Other resources
7062 *
7063 * * [Element.getBoundingClientRect]
7064 * (https://developer.mozilla.org/en-US/docs/Web/API/Element.getBoundingClient Rect)
7065 * from MDN.
7066 * * [The getBoundingClientRect() method]
7067 * (http://www.w3.org/TR/cssom-view/#the-getclientrects-and-getboundingclientr ect-methods)
7068 * from W3C.
7069 */
7070 @DomName('Element.getBoundingClientRect')
7071 @DocsEditable()
7072 Rectangle _getBoundingClientRect_1() => wrap_jso(JS("Rectangle ", "#.raw.getBo undingClientRect()", this));
7073
7074 /**
7075 * Returns a list of shadow DOM insertion points to which this element is
7076 * distributed.
7077 *
7078 * ## Other resources
7079 *
7080 * * [Shadow DOM specification]
7081 * (https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html)
7082 * from W3C.
7083 */
7084 @DomName('Element.getDestinationInsertionPoints')
7085 @DocsEditable()
7086 @Experimental() // untriaged
7087 @Returns('NodeList')
7088 @Creates('NodeList')
7089 NodeList getDestinationInsertionPoints() {
7090 return _getDestinationInsertionPoints_1();
7091 }
7092 @JSName('getDestinationInsertionPoints')
7093 /**
7094 * Returns a list of shadow DOM insertion points to which this element is
7095 * distributed.
7096 *
7097 * ## Other resources
7098 *
7099 * * [Shadow DOM specification]
7100 * (https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html)
7101 * from W3C.
7102 */
7103 @DomName('Element.getDestinationInsertionPoints')
7104 @DocsEditable()
7105 @Experimental() // untriaged
7106 @Returns('NodeList')
7107 @Creates('NodeList')
7108 NodeList _getDestinationInsertionPoints_1() => wrap_jso(JS("NodeList ", "#.raw .getDestinationInsertionPoints()", this));
7109
7110 /**
7111 * Returns a list of nodes with the given class name inside this element.
7112 *
7113 * ## Other resources
7114 *
7115 * * [getElementsByClassName]
7116 * (https://developer.mozilla.org/en-US/docs/Web/API/document.getElementsByCla ssName)
7117 * from MDN.
7118 * * [DOM specification]
7119 * (http://www.w3.org/TR/domcore/) from W3C.
7120 */
7121 @DomName('Element.getElementsByClassName')
7122 @DocsEditable()
7123 @Creates('NodeList|HtmlCollection')
7124 @Returns('NodeList|HtmlCollection')
7125 HtmlCollection getElementsByClassName(String classNames) {
7126 return _getElementsByClassName_1(classNames);
7127 }
7128 @JSName('getElementsByClassName')
7129 /**
7130 * Returns a list of nodes with the given class name inside this element.
7131 *
7132 * ## Other resources
7133 *
7134 * * [getElementsByClassName]
7135 * (https://developer.mozilla.org/en-US/docs/Web/API/document.getElementsByCla ssName)
7136 * from MDN.
7137 * * [DOM specification]
7138 * (http://www.w3.org/TR/domcore/) from W3C.
7139 */
7140 @DomName('Element.getElementsByClassName')
7141 @DocsEditable()
7142 @Creates('NodeList|HtmlCollection')
7143 @Returns('NodeList|HtmlCollection')
7144 HtmlCollection _getElementsByClassName_1(classNames) => wrap_jso(JS("HtmlColle ction ", "#.raw.getElementsByClassName(#)", this, unwrap_jso(classNames)));
7145
7146 @DomName('Element.getElementsByTagName')
7147 @DocsEditable()
7148 @Creates('NodeList|HtmlCollection')
7149 @Returns('NodeList|HtmlCollection')
7150 HtmlCollection _getElementsByTagName(String name) {
7151 return _getElementsByTagName_1(name);
7152 }
7153 @JSName('getElementsByTagName')
7154 @DomName('Element.getElementsByTagName')
7155 @DocsEditable()
7156 @Creates('NodeList|HtmlCollection')
7157 @Returns('NodeList|HtmlCollection')
7158 HtmlCollection _getElementsByTagName_1(name) => wrap_jso(JS("HtmlCollection ", "#.raw.getElementsByTagName(#)", this, unwrap_jso(name)));
7159
7160 @DomName('Element.hasAttribute')
7161 @DocsEditable()
7162 bool _hasAttribute(String name) {
7163 return _hasAttribute_1(name);
7164 }
7165 @JSName('hasAttribute')
7166 @DomName('Element.hasAttribute')
7167 @DocsEditable()
7168 bool _hasAttribute_1(name) => wrap_jso(JS("bool ", "#.raw.hasAttribute(#)", th is, unwrap_jso(name)));
7169
7170 @DomName('Element.hasAttributeNS')
7171 @DocsEditable()
7172 bool _hasAttributeNS(String namespaceURI, String localName) {
7173 return _hasAttributeNS_1(namespaceURI, localName);
7174 }
7175 @JSName('hasAttributeNS')
7176 @DomName('Element.hasAttributeNS')
7177 @DocsEditable()
7178 bool _hasAttributeNS_1(namespaceURI, localName) => wrap_jso(JS("bool ", "#.raw .hasAttributeNS(#, #)", this, unwrap_jso(namespaceURI), unwrap_jso(localName)));
7179
7180 @DomName('Element.removeAttribute')
7181 @DocsEditable()
7182 void _removeAttribute(String name) {
7183 _removeAttribute_1(name);
7184 return;
7185 }
7186 @JSName('removeAttribute')
7187 @DomName('Element.removeAttribute')
7188 @DocsEditable()
7189 void _removeAttribute_1(name) => wrap_jso(JS("void ", "#.raw.removeAttribute(# )", this, unwrap_jso(name)));
7190
7191 @DomName('Element.removeAttributeNS')
7192 @DocsEditable()
7193 void _removeAttributeNS(String namespaceURI, String localName) {
7194 _removeAttributeNS_1(namespaceURI, localName);
7195 return;
7196 }
7197 @JSName('removeAttributeNS')
7198 @DomName('Element.removeAttributeNS')
7199 @DocsEditable()
7200 void _removeAttributeNS_1(namespaceURI, localName) => wrap_jso(JS("void ", "#. raw.removeAttributeNS(#, #)", this, unwrap_jso(namespaceURI), unwrap_jso(localNa me)));
7201
7202 @DomName('Element.requestFullscreen')
7203 @DocsEditable()
7204 @Experimental() // untriaged
7205 void requestFullscreen() {
7206 _requestFullscreen_1();
7207 return;
7208 }
7209 @JSName('requestFullscreen')
7210 @DomName('Element.requestFullscreen')
7211 @DocsEditable()
7212 @Experimental() // untriaged
7213 void _requestFullscreen_1() => wrap_jso(JS("void ", "#.raw.requestFullscreen() ", this));
7214
7215 @DomName('Element.requestPointerLock')
7216 @DocsEditable()
7217 @Experimental() // untriaged
7218 void requestPointerLock() {
7219 _requestPointerLock_1();
7220 return;
7221 }
7222 @JSName('requestPointerLock')
7223 @DomName('Element.requestPointerLock')
7224 @DocsEditable()
7225 @Experimental() // untriaged
7226 void _requestPointerLock_1() => wrap_jso(JS("void ", "#.raw.requestPointerLock ()", this));
7227
7228 @DomName('Element.scrollIntoView')
7229 @DocsEditable()
7230 void _scrollIntoView([bool alignWithTop]) {
7231 if (alignWithTop != null) {
7232 _scrollIntoView_1(alignWithTop);
7233 return;
7234 }
7235 _scrollIntoView_2();
7236 return;
7237 }
7238 @JSName('scrollIntoView')
7239 @DomName('Element.scrollIntoView')
7240 @DocsEditable()
7241 void _scrollIntoView_1(alignWithTop) => wrap_jso(JS("void ", "#.raw.scrollInto View(#)", this, unwrap_jso(alignWithTop)));
7242 @JSName('scrollIntoView')
7243 @DomName('Element.scrollIntoView')
7244 @DocsEditable()
7245 void _scrollIntoView_2() => wrap_jso(JS("void ", "#.raw.scrollIntoView()", thi s));
7246
7247 @DomName('Element.scrollIntoViewIfNeeded')
7248 @DocsEditable()
7249 // http://docs.webplatform.org/wiki/dom/methods/scrollIntoViewIfNeeded
7250 @Experimental() // non-standard
7251 void _scrollIntoViewIfNeeded([bool centerIfNeeded]) {
7252 if (centerIfNeeded != null) {
7253 _scrollIntoViewIfNeeded_1(centerIfNeeded);
7254 return;
7255 }
7256 _scrollIntoViewIfNeeded_2();
7257 return;
7258 }
7259 @JSName('scrollIntoViewIfNeeded')
7260 @DomName('Element.scrollIntoViewIfNeeded')
7261 @DocsEditable()
7262 // http://docs.webplatform.org/wiki/dom/methods/scrollIntoViewIfNeeded
7263 @Experimental() // non-standard
7264 void _scrollIntoViewIfNeeded_1(centerIfNeeded) => wrap_jso(JS("void ", "#.raw. scrollIntoViewIfNeeded(#)", this, unwrap_jso(centerIfNeeded)));
7265 @JSName('scrollIntoViewIfNeeded')
7266 @DomName('Element.scrollIntoViewIfNeeded')
7267 @DocsEditable()
7268 // http://docs.webplatform.org/wiki/dom/methods/scrollIntoViewIfNeeded
7269 @Experimental() // non-standard
7270 void _scrollIntoViewIfNeeded_2() => wrap_jso(JS("void ", "#.raw.scrollIntoView IfNeeded()", this));
7271
7272 @DomName('Element.setAttribute')
7273 @DocsEditable()
7274 void setAttribute(String name, String value) {
7275 _setAttribute_1(name, value);
7276 return;
7277 }
7278 @JSName('setAttribute')
7279 @DomName('Element.setAttribute')
7280 @DocsEditable()
7281 void _setAttribute_1(name, value) => wrap_jso(JS("void ", "#.raw.setAttribute( #, #)", this, unwrap_jso(name), unwrap_jso(value)));
7282
7283 @DomName('Element.setAttributeNS')
7284 @DocsEditable()
7285 void setAttributeNS(String namespaceURI, String qualifiedName, String value) {
7286 _setAttributeNS_1(namespaceURI, qualifiedName, value);
7287 return;
7288 }
7289 @JSName('setAttributeNS')
7290 @DomName('Element.setAttributeNS')
7291 @DocsEditable()
7292 void _setAttributeNS_1(namespaceURI, qualifiedName, value) => wrap_jso(JS("voi d ", "#.raw.setAttributeNS(#, #, #)", this, unwrap_jso(namespaceURI), unwrap_jso (qualifiedName), unwrap_jso(value)));
7293
7294 // From ChildNode
7295
7296 @DomName('Element.nextElementSibling')
7297 @DocsEditable()
7298 Element get nextElementSibling => wrap_jso(JS("Element", "#.nextElementSibling ", this.raw));
7299
7300 @DomName('Element.previousElementSibling')
7301 @DocsEditable()
7302 Element get previousElementSibling => wrap_jso(JS("Element", "#.previousElemen tSibling", this.raw));
7303
7304 // From ParentNode
7305
7306 @JSName('childElementCount')
7307 @DomName('Element.childElementCount')
7308 @DocsEditable()
7309 int get _childElementCount => wrap_jso(JS("int", "#.childElementCount", this.r aw));
7310
7311 @JSName('children')
7312 @DomName('Element.children')
7313 @DocsEditable()
7314 @Returns('HtmlCollection')
7315 @Creates('HtmlCollection')
7316 List<Node> get _children => wrap_jso(JS("List<Node>", "#.children", this.raw)) ;
7317
7318 @JSName('firstElementChild')
7319 @DomName('Element.firstElementChild')
7320 @DocsEditable()
7321 Element get _firstElementChild => wrap_jso(JS("Element", "#.firstElementChild" , this.raw));
7322
7323 @JSName('lastElementChild')
7324 @DomName('Element.lastElementChild')
7325 @DocsEditable()
7326 Element get _lastElementChild => wrap_jso(JS("Element", "#.lastElementChild", this.raw));
7327
7328 /**
7329 * Finds the first descendant element of this element that matches the
7330 * specified group of selectors.
7331 *
7332 * [selectors] should be a string using CSS selector syntax.
7333 *
7334 * // Gets the first descendant with the class 'classname'
7335 * var element = element.querySelector('.className');
7336 * // Gets the element with id 'id'
7337 * var element = element.querySelector('#id');
7338 * // Gets the first descendant [ImageElement]
7339 * var img = element.querySelector('img');
7340 *
7341 * For details about CSS selector syntax, see the
7342 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
7343 */
7344 @DomName('Element.querySelector')
7345 @DocsEditable()
7346 Element querySelector(String selectors) {
7347 return _querySelector_1(selectors);
7348 }
7349 @JSName('querySelector')
7350 /**
7351 * Finds the first descendant element of this element that matches the
7352 * specified group of selectors.
7353 *
7354 * [selectors] should be a string using CSS selector syntax.
7355 *
7356 * // Gets the first descendant with the class 'classname'
7357 * var element = element.querySelector('.className');
7358 * // Gets the element with id 'id'
7359 * var element = element.querySelector('#id');
7360 * // Gets the first descendant [ImageElement]
7361 * var img = element.querySelector('img');
7362 *
7363 * For details about CSS selector syntax, see the
7364 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
7365 */
7366 @DomName('Element.querySelector')
7367 @DocsEditable()
7368 Element _querySelector_1(selectors) => wrap_jso(JS("Element ", "#.raw.querySel ector(#)", this, unwrap_jso(selectors)));
7369
7370 @DomName('Element.querySelectorAll')
7371 @DocsEditable()
7372 @Returns('NodeList')
7373 @Creates('NodeList')
7374 NodeList _querySelectorAll(String selectors) {
7375 return _querySelectorAll_1(selectors);
7376 }
7377 @JSName('querySelectorAll')
7378 @DomName('Element.querySelectorAll')
7379 @DocsEditable()
7380 @Returns('NodeList')
7381 @Creates('NodeList')
7382 NodeList _querySelectorAll_1(selectors) => wrap_jso(JS("NodeList ", "#.raw.que rySelectorAll(#)", this, unwrap_jso(selectors)));
7383
7384 /// Stream of `beforecopy` events handled by this [Element].
7385 @DomName('Element.onbeforecopy')
7386 @DocsEditable()
7387 ElementStream<Event> get onBeforeCopy => beforeCopyEvent.forElement(this);
7388
7389 /// Stream of `beforecut` events handled by this [Element].
7390 @DomName('Element.onbeforecut')
7391 @DocsEditable()
7392 ElementStream<Event> get onBeforeCut => beforeCutEvent.forElement(this);
7393
7394 /// Stream of `beforepaste` events handled by this [Element].
7395 @DomName('Element.onbeforepaste')
7396 @DocsEditable()
7397 ElementStream<Event> get onBeforePaste => beforePasteEvent.forElement(this);
7398
7399 /// Stream of `copy` events handled by this [Element].
7400 @DomName('Element.oncopy')
7401 @DocsEditable()
7402 ElementStream<Event> get onCopy => copyEvent.forElement(this);
7403
7404 /// Stream of `cut` events handled by this [Element].
7405 @DomName('Element.oncut')
7406 @DocsEditable()
7407 ElementStream<Event> get onCut => cutEvent.forElement(this);
7408
7409 /// Stream of `paste` events handled by this [Element].
7410 @DomName('Element.onpaste')
7411 @DocsEditable()
7412 ElementStream<Event> get onPaste => pasteEvent.forElement(this);
7413
7414 /// Stream of `search` events handled by this [Element].
7415 @DomName('Element.onsearch')
7416 @DocsEditable()
7417 // http://www.w3.org/TR/html-markup/input.search.html
7418 @Experimental()
7419 ElementStream<Event> get onSearch => searchEvent.forElement(this);
7420
7421 /// Stream of `selectstart` events handled by this [Element].
7422 @DomName('Element.onselectstart')
7423 @DocsEditable()
7424 @Experimental() // nonstandard
7425 ElementStream<Event> get onSelectStart => selectStartEvent.forElement(this);
7426
7427 /// Stream of `fullscreenchange` events handled by this [Element].
7428 @DomName('Element.onwebkitfullscreenchange')
7429 @DocsEditable()
7430 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
7431 @Experimental()
7432 ElementStream<Event> get onFullscreenChange => fullscreenChangeEvent.forElemen t(this);
7433
7434 /// Stream of `fullscreenerror` events handled by this [Element].
7435 @DomName('Element.onwebkitfullscreenerror')
7436 @DocsEditable()
7437 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
7438 @Experimental()
7439 ElementStream<Event> get onFullscreenError => fullscreenErrorEvent.forElement( this);
7440
7441 }
7442
7443
7444 class _ElementFactoryProvider {
7445
7446 @DomName('Document.createElement')
7447 static Element createElement_tag(String tag, String typeExtension) =>
7448 document.createElement(tag, typeExtension);
7449 }
7450
7451
7452 /**
7453 * Options for Element.scrollIntoView.
7454 */
7455 class ScrollAlignment {
7456 final _value;
7457 const ScrollAlignment._internal(this._value);
7458 toString() => 'ScrollAlignment.$_value';
7459
7460 /// Attempt to align the element to the top of the scrollable area.
7461 static const TOP = const ScrollAlignment._internal('TOP');
7462 /// Attempt to center the element in the scrollable area.
7463 static const CENTER = const ScrollAlignment._internal('CENTER');
7464 /// Attempt to align the element to the bottom of the scrollable area.
7465 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
7466 }
7467 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
7468 // for details. All rights reserved. Use of this source code is governed by a
7469 // BSD-style license that can be found in the LICENSE file.
7470
7471 // WARNING: Do not edit - generated code.
7472
7473
7474 @DomName('Event')
7475 @Native("Event,InputEvent,ClipboardEvent")
7476 class Event extends DartHtmlDomObject {
7477 // In JS, canBubble and cancelable are technically required parameters to
7478 // init*Event. In practice, though, if they aren't provided they simply
7479 // default to false (since that's Boolean(undefined)).
7480 //
7481 // Contrary to JS, we default canBubble and cancelable to true, since that's
7482 // what people want most of the time anyway.
7483 factory Event(String type,
7484 {bool canBubble: true, bool cancelable: true}) {
7485 return new Event.eventType('Event', type, canBubble: canBubble,
7486 cancelable: cancelable);
7487 }
7488
7489 /**
7490 * Creates a new Event object of the specified type.
7491 *
7492 * This is analogous to document.createEvent.
7493 * Normally events should be created via their constructors, if available.
7494 *
7495 * var e = new Event.type('MouseEvent', 'mousedown', true, true);
7496 */
7497 factory Event.eventType(String type, String name, {bool canBubble: true,
7498 bool cancelable: true}) {
7499 final Event e = document._createEvent(type);
7500 e._initEvent(name, canBubble, cancelable);
7501 return e;
7502 }
7503
7504 /** The CSS selector involved with event delegation. */
7505 String _selector;
7506
7507 /**
7508 * A pointer to the element whose CSS selector matched within which an event
7509 * was fired. If this Event was not associated with any Event delegation,
7510 * accessing this value will throw an [UnsupportedError].
7511 */
7512 Element get matchingTarget {
7513 if (_selector == null) {
7514 throw new UnsupportedError('Cannot call matchingTarget if this Event did'
7515 ' not arise as a result of event delegation.');
7516 }
7517 Element currentTarget = this.currentTarget;
7518 Element target = this.target;
7519 var matchedTarget;
7520 do {
7521 if (target.matches(_selector)) return target;
7522 target = target.parent;
7523 } while (target != null && target != currentTarget.parent);
7524 throw new StateError('No selector matched for populating matchedTarget.');
7525 }
7526 // To suppress missing implicit constructor warnings.
7527 factory Event._() { throw new UnsupportedError("Not supported"); }
7528
7529 @Deprecated("Internal Use Only")
7530 static Event internalCreateEvent() {
7531 return new Event.internal_();
7532 }
7533
7534 @Deprecated("Internal Use Only")
7535 Event.internal_() { }
7536
7537 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
7538 int get hashCode => unwrap_jso(this).hashCode;
7539
7540 /**
7541 * This event is being handled by the event target.
7542 *
7543 * ## Other resources
7544 *
7545 * * [Target phase] (http://www.w3.org/TR/DOM-Level-3-Events/#target-phase)
7546 * from W3C.
7547 */
7548 @DomName('Event.AT_TARGET')
7549 @DocsEditable()
7550 static const int AT_TARGET = 2;
7551
7552 /**
7553 * This event is bubbling up through the target's ancestors.
7554 *
7555 * ## Other resources
7556 *
7557 * * [Bubble phase] (http://www.w3.org/TR/DOM-Level-3-Events/#bubble-phase)
7558 * from W3C.
7559 */
7560 @DomName('Event.BUBBLING_PHASE')
7561 @DocsEditable()
7562 static const int BUBBLING_PHASE = 3;
7563
7564 /**
7565 * This event is propagating through the target's ancestors, starting from the
7566 * document.
7567 *
7568 * ## Other resources
7569 *
7570 * * [Bubble phase] (http://www.w3.org/TR/DOM-Level-3-Events/#bubble-phase)
7571 * from W3C.
7572 */
7573 @DomName('Event.CAPTURING_PHASE')
7574 @DocsEditable()
7575 static const int CAPTURING_PHASE = 1;
7576
7577 @DomName('Event.bubbles')
7578 @DocsEditable()
7579 bool get bubbles => wrap_jso(JS("bool", "#.bubbles", this.raw));
7580
7581 @DomName('Event.cancelable')
7582 @DocsEditable()
7583 bool get cancelable => wrap_jso(JS("bool", "#.cancelable", this.raw));
7584
7585 @DomName('Event.currentTarget')
7586 @DocsEditable()
7587 EventTarget get currentTarget => _convertNativeToDart_EventTarget(this._get_cu rrentTarget);
7588 @JSName('currentTarget')
7589 @DomName('Event.currentTarget')
7590 @DocsEditable()
7591 @Creates('Null')
7592 @Returns('EventTarget|=Object')
7593 dynamic get _get_currentTarget => wrap_jso(JS("dynamic", "#.currentTarget", th is.raw));
7594
7595 @DomName('Event.defaultPrevented')
7596 @DocsEditable()
7597 bool get defaultPrevented => wrap_jso(JS("bool", "#.defaultPrevented", this.ra w));
7598
7599 @DomName('Event.eventPhase')
7600 @DocsEditable()
7601 int get eventPhase => wrap_jso(JS("int", "#.eventPhase", this.raw));
7602
7603 /**
7604 * This event's path, taking into account shadow DOM.
7605 *
7606 * ## Other resources
7607 *
7608 * * [Shadow DOM extensions to Event]
7609 * (http://w3c.github.io/webcomponents/spec/shadow/#extensions-to-event) from
7610 * W3C.
7611 */
7612 @DomName('Event.path')
7613 @DocsEditable()
7614 // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#ex tensions-to-event
7615 @Experimental()
7616 @Returns('NodeList')
7617 @Creates('NodeList')
7618 List<Node> get path => wrap_jso(JS("List<Node>", "#.path", this.raw));
7619
7620 @DomName('Event.target')
7621 @DocsEditable()
7622 EventTarget get target => _convertNativeToDart_EventTarget(this._get_target);
7623 @JSName('target')
7624 @DomName('Event.target')
7625 @DocsEditable()
7626 @Creates('Node')
7627 @Returns('EventTarget|=Object')
7628 dynamic get _get_target => wrap_jso(JS("dynamic", "#.target", this.raw));
7629
7630 @DomName('Event.timeStamp')
7631 @DocsEditable()
7632 int get timeStamp => wrap_jso(JS("int", "#.timeStamp", this.raw));
7633
7634 @DomName('Event.type')
7635 @DocsEditable()
7636 String get type => wrap_jso(JS("String", "#.type", this.raw));
7637
7638 @DomName('Event.initEvent')
7639 @DocsEditable()
7640 void _initEvent(String eventTypeArg, bool canBubbleArg, bool cancelableArg) {
7641 _initEvent_1(eventTypeArg, canBubbleArg, cancelableArg);
7642 return;
7643 }
7644 @JSName('initEvent')
7645 @DomName('Event.initEvent')
7646 @DocsEditable()
7647 void _initEvent_1(eventTypeArg, canBubbleArg, cancelableArg) => wrap_jso(JS("v oid ", "#.raw.initEvent(#, #, #)", this, unwrap_jso(eventTypeArg), unwrap_jso(ca nBubbleArg), unwrap_jso(cancelableArg)));
7648
7649 @DomName('Event.preventDefault')
7650 @DocsEditable()
7651 void preventDefault() {
7652 _preventDefault_1();
7653 return;
7654 }
7655 @JSName('preventDefault')
7656 @DomName('Event.preventDefault')
7657 @DocsEditable()
7658 void _preventDefault_1() => wrap_jso(JS("void ", "#.raw.preventDefault()", thi s));
7659
7660 @DomName('Event.stopImmediatePropagation')
7661 @DocsEditable()
7662 void stopImmediatePropagation() {
7663 _stopImmediatePropagation_1();
7664 return;
7665 }
7666 @JSName('stopImmediatePropagation')
7667 @DomName('Event.stopImmediatePropagation')
7668 @DocsEditable()
7669 void _stopImmediatePropagation_1() => wrap_jso(JS("void ", "#.raw.stopImmediat ePropagation()", this));
7670
7671 @DomName('Event.stopPropagation')
7672 @DocsEditable()
7673 void stopPropagation() {
7674 _stopPropagation_1();
7675 return;
7676 }
7677 @JSName('stopPropagation')
7678 @DomName('Event.stopPropagation')
7679 @DocsEditable()
7680 void _stopPropagation_1() => wrap_jso(JS("void ", "#.raw.stopPropagation()", t his));
7681
7682 }
7683 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
7684 // for details. All rights reserved. Use of this source code is governed by a
7685 // BSD-style license that can be found in the LICENSE file.
7686
7687
7688 /**
7689 * Base class that supports listening for and dispatching browser events.
7690 *
7691 * Normally events are accessed via the Stream getter:
7692 *
7693 * element.onMouseOver.listen((e) => print('Mouse over!'));
7694 *
7695 * To access bubbling events which are declared on one element, but may bubble
7696 * up to another element type (common for MediaElement events):
7697 *
7698 * MediaElement.pauseEvent.forTarget(document.body).listen(...);
7699 *
7700 * To useCapture on events:
7701 *
7702 * Element.keyDownEvent.forTarget(element, useCapture: true).listen(...);
7703 *
7704 * Custom events can be declared as:
7705 *
7706 * class DataGenerator {
7707 * static EventStreamProvider<Event> dataEvent =
7708 * new EventStreamProvider('data');
7709 * }
7710 *
7711 * Then listeners should access the event with:
7712 *
7713 * DataGenerator.dataEvent.forTarget(element).listen(...);
7714 *
7715 * Custom events can also be accessed as:
7716 *
7717 * element.on['some_event'].listen(...);
7718 *
7719 * This approach is generally discouraged as it loses the event typing and
7720 * some DOM events may have multiple platform-dependent event names under the
7721 * covers. By using the standard Stream getters you will get the platform
7722 * specific event name automatically.
7723 */
7724 class Events {
7725 /* Raw event target. */
7726 final EventTarget _ptr;
7727
7728 Events(this._ptr);
7729
7730 Stream operator [](String type) {
7731 return new _EventStream(_ptr, type, false);
7732 }
7733 }
7734
7735 class ElementEvents extends Events {
7736 /* Raw event target. */
7737 static final webkitEvents = {
7738 'animationend' : 'webkitAnimationEnd',
7739 'animationiteration' : 'webkitAnimationIteration',
7740 'animationstart' : 'webkitAnimationStart',
7741 'fullscreenchange' : 'webkitfullscreenchange',
7742 'fullscreenerror' : 'webkitfullscreenerror',
7743 'keyadded' : 'webkitkeyadded',
7744 'keyerror' : 'webkitkeyerror',
7745 'keymessage' : 'webkitkeymessage',
7746 'needkey' : 'webkitneedkey',
7747 'pointerlockchange' : 'webkitpointerlockchange',
7748 'pointerlockerror' : 'webkitpointerlockerror',
7749 'resourcetimingbufferfull' : 'webkitresourcetimingbufferfull',
7750 'transitionend': 'webkitTransitionEnd',
7751 'speechchange' : 'webkitSpeechChange'
7752 };
7753
7754 ElementEvents(Element ptr) : super(ptr);
7755
7756 Stream operator [](String type) {
7757 if (webkitEvents.keys.contains(type.toLowerCase())) {
7758 if (Device.isWebKit) {
7759 return new _ElementEventStreamImpl(
7760 _ptr, webkitEvents[type.toLowerCase()], false);
7761 }
7762 }
7763 return new _ElementEventStreamImpl(_ptr, type, false);
7764 }
7765 }
7766
7767 /**
7768 * Base class for all browser objects that support events.
7769 *
7770 * Use the [on] property to add, and remove events
7771 * for compile-time type checks and a more concise API.
7772 */
7773 @DomName('EventTarget')
7774 @Native("EventTarget")
7775 class EventTarget extends DartHtmlDomObject {
7776
7777 // Custom element created callback.
7778 EventTarget._created();
7779
7780 /**
7781 * This is an ease-of-use accessor for event streams which should only be
7782 * used when an explicit accessor is not available.
7783 */
7784 Events get on => new Events(this);
7785
7786 void addEventListener(String type, EventListener listener, [bool useCapture]) {
7787 // TODO(leafp): This check is avoid a bug in our dispatch code when
7788 // listener is null. The browser treats this call as a no-op in this
7789 // case, so it's fine to short-circuit it, but we should not have to.
7790 if (listener != null) {
7791 _addEventListener(type, listener, useCapture);
7792 }
7793 }
7794
7795 void removeEventListener(String type, EventListener listener, [bool useCapture ]) {
7796 // TODO(leafp): This check is avoid a bug in our dispatch code when
7797 // listener is null. The browser treats this call as a no-op in this
7798 // case, so it's fine to short-circuit it, but we should not have to.
7799 if (listener != null) {
7800 _removeEventListener(type, listener, useCapture);
7801 }
7802 }
7803
7804 // To suppress missing implicit constructor warnings.
7805 factory EventTarget._() { throw new UnsupportedError("Not supported"); }
7806
7807 @Deprecated("Internal Use Only")
7808 static EventTarget internalCreateEventTarget() {
7809 return new EventTarget.internal_();
7810 }
7811
7812 @Deprecated("Internal Use Only")
7813 EventTarget.internal_() { }
7814
7815 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
7816 int get hashCode => unwrap_jso(this).hashCode;
7817
7818 @DomName('EventTarget.addEventListener')
7819 @DocsEditable()
7820 void _addEventListener([String type, EventListener listener, bool useCapture]) {
7821 if (useCapture != null) {
7822 _addEventListener_1(type, listener, useCapture);
7823 return;
7824 }
7825 if (listener != null) {
7826 _addEventListener_2(type, listener);
7827 return;
7828 }
7829 if (type != null) {
7830 _addEventListener_3(type);
7831 return;
7832 }
7833 _addEventListener_4();
7834 return;
7835 }
7836 @JSName('addEventListener')
7837 @DomName('EventTarget.addEventListener')
7838 @DocsEditable()
7839 void _addEventListener_1(type, EventListener listener, useCapture) => wrap_jso (JS("void ", "#.raw.addEventListener(#, #, #)", this, unwrap_jso(type), unwrap_j so(listener), unwrap_jso(useCapture)));
7840 @JSName('addEventListener')
7841 @DomName('EventTarget.addEventListener')
7842 @DocsEditable()
7843 void _addEventListener_2(type, EventListener listener) => wrap_jso(JS("void ", "#.raw.addEventListener(#, #)", this, unwrap_jso(type), unwrap_jso(listener)));
7844 @JSName('addEventListener')
7845 @DomName('EventTarget.addEventListener')
7846 @DocsEditable()
7847 void _addEventListener_3(type) => wrap_jso(JS("void ", "#.raw.addEventListener (#)", this, unwrap_jso(type)));
7848 @JSName('addEventListener')
7849 @DomName('EventTarget.addEventListener')
7850 @DocsEditable()
7851 void _addEventListener_4() => wrap_jso(JS("void ", "#.raw.addEventListener()", this));
7852
7853 @DomName('EventTarget.dispatchEvent')
7854 @DocsEditable()
7855 bool dispatchEvent(Event event) {
7856 return _dispatchEvent_1(event);
7857 }
7858 @JSName('dispatchEvent')
7859 @DomName('EventTarget.dispatchEvent')
7860 @DocsEditable()
7861 bool _dispatchEvent_1(Event event) => wrap_jso(JS("bool ", "#.raw.dispatchEven t(#)", this, unwrap_jso(event)));
7862
7863 @DomName('EventTarget.removeEventListener')
7864 @DocsEditable()
7865 void _removeEventListener([String type, EventListener listener, bool useCaptur e]) {
7866 if (useCapture != null) {
7867 _removeEventListener_1(type, listener, useCapture);
7868 return;
7869 }
7870 if (listener != null) {
7871 _removeEventListener_2(type, listener);
7872 return;
7873 }
7874 if (type != null) {
7875 _removeEventListener_3(type);
7876 return;
7877 }
7878 _removeEventListener_4();
7879 return;
7880 }
7881 @JSName('removeEventListener')
7882 @DomName('EventTarget.removeEventListener')
7883 @DocsEditable()
7884 void _removeEventListener_1(type, EventListener listener, useCapture) => wrap_ jso(JS("void ", "#.raw.removeEventListener(#, #, #)", this, unwrap_jso(type), un wrap_jso(listener), unwrap_jso(useCapture)));
7885 @JSName('removeEventListener')
7886 @DomName('EventTarget.removeEventListener')
7887 @DocsEditable()
7888 void _removeEventListener_2(type, EventListener listener) => wrap_jso(JS("void ", "#.raw.removeEventListener(#, #)", this, unwrap_jso(type), unwrap_jso(listen er)));
7889 @JSName('removeEventListener')
7890 @DomName('EventTarget.removeEventListener')
7891 @DocsEditable()
7892 void _removeEventListener_3(type) => wrap_jso(JS("void ", "#.raw.removeEventLi stener(#)", this, unwrap_jso(type)));
7893 @JSName('removeEventListener')
7894 @DomName('EventTarget.removeEventListener')
7895 @DocsEditable()
7896 void _removeEventListener_4() => wrap_jso(JS("void ", "#.raw.removeEventListen er()", this));
7897
7898 }
7899 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
7900 // for details. All rights reserved. Use of this source code is governed by a
7901 // BSD-style license that can be found in the LICENSE file.
7902
7903
7904 @DocsEditable()
7905 @DomName('HTMLHeadElement')
7906 @Native("HTMLHeadElement")
7907 class HeadElement extends HtmlElement {
7908 // To suppress missing implicit constructor warnings.
7909 factory HeadElement._() { throw new UnsupportedError("Not supported"); }
7910
7911 @DomName('HTMLHeadElement.HTMLHeadElement')
7912 @DocsEditable()
7913 factory HeadElement() => document.createElement("head");
7914
7915
7916 @Deprecated("Internal Use Only")
7917 static HeadElement internalCreateHeadElement() {
7918 return new HeadElement.internal_();
7919 }
7920
7921 @Deprecated("Internal Use Only")
7922 HeadElement.internal_() : super.internal_();
7923
7924 }
7925 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
7926 // for details. All rights reserved. Use of this source code is governed by a
7927 // BSD-style license that can be found in the LICENSE file.
7928
7929
7930 @DomName('History')
7931 @Native("History")
7932 class History extends DartHtmlDomObject implements HistoryBase {
7933
7934 /**
7935 * Checks if the State APIs are supported on the current platform.
7936 *
7937 * See also:
7938 *
7939 * * [pushState]
7940 * * [replaceState]
7941 * * [state]
7942 */
7943 static bool get supportsState => true;
7944 // To suppress missing implicit constructor warnings.
7945 factory History._() { throw new UnsupportedError("Not supported"); }
7946
7947 @Deprecated("Internal Use Only")
7948 static History internalCreateHistory() {
7949 return new History.internal_();
7950 }
7951
7952 @Deprecated("Internal Use Only")
7953 History.internal_() { }
7954
7955 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
7956 int get hashCode => unwrap_jso(this).hashCode;
7957
7958 @DomName('History.length')
7959 @DocsEditable()
7960 int get length => wrap_jso(JS("int", "#.length", this.raw));
7961
7962 @DomName('History.state')
7963 @DocsEditable()
7964 dynamic get state => convertNativeToDart_SerializedScriptValue(this._get_state );
7965 @JSName('state')
7966 @DomName('History.state')
7967 @DocsEditable()
7968 @annotation_Creates_SerializedScriptValue
7969 @annotation_Returns_SerializedScriptValue
7970 dynamic get _get_state => wrap_jso(JS("dynamic", "#.state", this.raw));
7971
7972 @DomName('History.back')
7973 @DocsEditable()
7974 void back() {
7975 _back_1();
7976 return;
7977 }
7978 @JSName('back')
7979 @DomName('History.back')
7980 @DocsEditable()
7981 void _back_1() => wrap_jso(JS("void ", "#.raw.back()", this));
7982
7983 @DomName('History.forward')
7984 @DocsEditable()
7985 void forward() {
7986 _forward_1();
7987 return;
7988 }
7989 @JSName('forward')
7990 @DomName('History.forward')
7991 @DocsEditable()
7992 void _forward_1() => wrap_jso(JS("void ", "#.raw.forward()", this));
7993
7994 @DomName('History.go')
7995 @DocsEditable()
7996 void go(int distance) {
7997 _go_1(distance);
7998 return;
7999 }
8000 @JSName('go')
8001 @DomName('History.go')
8002 @DocsEditable()
8003 void _go_1(distance) => wrap_jso(JS("void ", "#.raw.go(#)", this, unwrap_jso(d istance)));
8004
8005 @DomName('History.pushState')
8006 @DocsEditable()
8007 @SupportedBrowser(SupportedBrowser.CHROME)
8008 @SupportedBrowser(SupportedBrowser.FIREFOX)
8009 @SupportedBrowser(SupportedBrowser.IE, '10')
8010 @SupportedBrowser(SupportedBrowser.SAFARI)
8011 void pushState(/*any*/ data, String title, [String url]) {
8012 if (url != null) {
8013 var data_1 = convertDartToNative_SerializedScriptValue(data);
8014 _pushState_1(data_1, title, url);
8015 return;
8016 }
8017 var data_1 = convertDartToNative_SerializedScriptValue(data);
8018 _pushState_2(data_1, title);
8019 return;
8020 }
8021 @JSName('pushState')
8022 @DomName('History.pushState')
8023 @DocsEditable()
8024 @SupportedBrowser(SupportedBrowser.CHROME)
8025 @SupportedBrowser(SupportedBrowser.FIREFOX)
8026 @SupportedBrowser(SupportedBrowser.IE, '10')
8027 @SupportedBrowser(SupportedBrowser.SAFARI)
8028 void _pushState_1(data, title, url) => wrap_jso(JS("void ", "#.raw.pushState(# , #, #)", this, unwrap_jso(data), unwrap_jso(title), unwrap_jso(url)));
8029 @JSName('pushState')
8030 @DomName('History.pushState')
8031 @DocsEditable()
8032 @SupportedBrowser(SupportedBrowser.CHROME)
8033 @SupportedBrowser(SupportedBrowser.FIREFOX)
8034 @SupportedBrowser(SupportedBrowser.IE, '10')
8035 @SupportedBrowser(SupportedBrowser.SAFARI)
8036 void _pushState_2(data, title) => wrap_jso(JS("void ", "#.raw.pushState(#, #)" , this, unwrap_jso(data), unwrap_jso(title)));
8037
8038 @DomName('History.replaceState')
8039 @DocsEditable()
8040 @SupportedBrowser(SupportedBrowser.CHROME)
8041 @SupportedBrowser(SupportedBrowser.FIREFOX)
8042 @SupportedBrowser(SupportedBrowser.IE, '10')
8043 @SupportedBrowser(SupportedBrowser.SAFARI)
8044 void replaceState(/*any*/ data, String title, [String url]) {
8045 if (url != null) {
8046 var data_1 = convertDartToNative_SerializedScriptValue(data);
8047 _replaceState_1(data_1, title, url);
8048 return;
8049 }
8050 var data_1 = convertDartToNative_SerializedScriptValue(data);
8051 _replaceState_2(data_1, title);
8052 return;
8053 }
8054 @JSName('replaceState')
8055 @DomName('History.replaceState')
8056 @DocsEditable()
8057 @SupportedBrowser(SupportedBrowser.CHROME)
8058 @SupportedBrowser(SupportedBrowser.FIREFOX)
8059 @SupportedBrowser(SupportedBrowser.IE, '10')
8060 @SupportedBrowser(SupportedBrowser.SAFARI)
8061 void _replaceState_1(data, title, url) => wrap_jso(JS("void ", "#.raw.replaceS tate(#, #, #)", this, unwrap_jso(data), unwrap_jso(title), unwrap_jso(url)));
8062 @JSName('replaceState')
8063 @DomName('History.replaceState')
8064 @DocsEditable()
8065 @SupportedBrowser(SupportedBrowser.CHROME)
8066 @SupportedBrowser(SupportedBrowser.FIREFOX)
8067 @SupportedBrowser(SupportedBrowser.IE, '10')
8068 @SupportedBrowser(SupportedBrowser.SAFARI)
8069 void _replaceState_2(data, title) => wrap_jso(JS("void ", "#.raw.replaceState( #, #)", this, unwrap_jso(data), unwrap_jso(title)));
8070 }
8071 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
8072 // for details. All rights reserved. Use of this source code is governed by a
8073 // BSD-style license that can be found in the LICENSE file.
8074
8075
8076 @DocsEditable()
8077 @DomName('HTMLCollection')
8078 @Native("HTMLCollection")
8079 class HtmlCollection extends DartHtmlDomObject with ListMixin<Node>, ImmutableLi stMixin<Node> implements JavaScriptIndexingBehavior, List<Node> {
8080 // To suppress missing implicit constructor warnings.
8081 factory HtmlCollection._() { throw new UnsupportedError("Not supported"); }
8082
8083 @Deprecated("Internal Use Only")
8084 static HtmlCollection internalCreateHtmlCollection() {
8085 return new HtmlCollection.internal_();
8086 }
8087
8088 @Deprecated("Internal Use Only")
8089 HtmlCollection.internal_() { }
8090
8091 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
8092 int get hashCode => unwrap_jso(this).hashCode;
8093
8094 @DomName('HTMLCollection.length')
8095 @DocsEditable()
8096 int get length => wrap_jso(JS("int", "#.length", this.raw));
8097
8098 Node operator[](int index) {
8099 if (JS("bool", "# >>> 0 !== # || # >= #", index,
8100 index, index, length))
8101 throw new RangeError.index(index, this);
8102 return wrap_jso(JS("Node", "#[#]", this.raw, index));
8103 }
8104 void operator[]=(int index, Node value) {
8105 throw new UnsupportedError("Cannot assign element of immutable List.");
8106 }
8107 // -- start List<Node> mixins.
8108 // Node is the element type.
8109
8110
8111 set length(int value) {
8112 throw new UnsupportedError("Cannot resize immutable List.");
8113 }
8114
8115 Node get first {
8116 if (this.length > 0) {
8117 return wrap_jso(JS('Node', '#[0]', this.raw));
8118 }
8119 throw new StateError("No elements");
8120 }
8121
8122 Node get last {
8123 int len = this.length;
8124 if (len > 0) {
8125 return wrap_jso(JS('Node', '#[#]', this.raw, len - 1));
8126 }
8127 throw new StateError("No elements");
8128 }
8129
8130 Node get single {
8131 int len = this.length;
8132 if (len == 1) {
8133 return wrap_jso(JS('Node', '#[0]', this.raw));
8134 }
8135 if (len == 0) throw new StateError("No elements");
8136 throw new StateError("More than one element");
8137 }
8138
8139 Node elementAt(int index) => this[index];
8140 // -- end List<Node> mixins.
8141
8142 @DomName('HTMLCollection.item')
8143 @DocsEditable()
8144 Element item(int index) {
8145 return _item_1(index);
8146 }
8147 @JSName('item')
8148 @DomName('HTMLCollection.item')
8149 @DocsEditable()
8150 Element _item_1(index) => wrap_jso(JS("Element ", "#.raw.item(#)", this, unwra p_jso(index)));
8151
8152 @DomName('HTMLCollection.namedItem')
8153 @DocsEditable()
8154 Element namedItem(String name) {
8155 return _namedItem_1(name);
8156 }
8157 @JSName('namedItem')
8158 @DomName('HTMLCollection.namedItem')
8159 @DocsEditable()
8160 Element _namedItem_1(name) => wrap_jso(JS("Element ", "#.raw.namedItem(#)", th is, unwrap_jso(name)));
8161 }
8162 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
8163 // for details. All rights reserved. Use of this source code is governed by a
8164 // BSD-style license that can be found in the LICENSE file.
8165
8166 // WARNING: Do not edit - generated code.
8167
8168
8169 @DomName('HTMLDocument')
8170 @Native("HTMLDocument")
8171 class HtmlDocument extends Document {
8172 // To suppress missing implicit constructor warnings.
8173 factory HtmlDocument._() { throw new UnsupportedError("Not supported"); }
8174
8175
8176 @Deprecated("Internal Use Only")
8177 static HtmlDocument internalCreateHtmlDocument() {
8178 return new HtmlDocument.internal_();
8179 }
8180
8181 @Deprecated("Internal Use Only")
8182 HtmlDocument.internal_() : super.internal_();
8183
8184
8185
8186 @DomName('Document.body')
8187 BodyElement get body => _body;
8188
8189 @DomName('Document.body')
8190 set body(BodyElement value) {
8191 _body = value;
8192 }
8193
8194 @DomName('Document.caretRangeFromPoint')
8195 Range caretRangeFromPoint(int x, int y) {
8196 return _caretRangeFromPoint(x, y);
8197 }
8198
8199 @DomName('Document.elementFromPoint')
8200 Element elementFromPoint(int x, int y) {
8201 return _elementFromPoint(x, y);
8202 }
8203
8204 /**
8205 * Checks if the getCssCanvasContext API is supported on the current platform.
8206 *
8207 * See also:
8208 *
8209 * * [getCssCanvasContext]
8210 */
8211 static bool get supportsCssCanvasContext =>
8212 JS('bool', '!!(document.getCSSCanvasContext)');
8213
8214
8215 @DomName('Document.head')
8216 HeadElement get head => _head;
8217
8218 @DomName('Document.lastModified')
8219 String get lastModified => _lastModified;
8220
8221 @DomName('Document.preferredStylesheetSet')
8222 String get preferredStylesheetSet => _preferredStylesheetSet;
8223
8224 @DomName('Document.referrer')
8225 String get referrer => _referrer;
8226
8227 @DomName('Document.selectedStylesheetSet')
8228 String get selectedStylesheetSet => _selectedStylesheetSet;
8229 set selectedStylesheetSet(String value) {
8230 _selectedStylesheetSet = value;
8231 }
8232
8233
8234 @DomName('Document.title')
8235 String get title => _title;
8236
8237 @DomName('Document.title')
8238 set title(String value) {
8239 _title = value;
8240 }
8241
8242 /**
8243 * Returns page to standard layout.
8244 *
8245 * Has no effect if the page is not in fullscreen mode.
8246 *
8247 * ## Other resources
8248 *
8249 * * [Using the fullscreen API]
8250 * (http://docs.webplatform.org/wiki/tutorials/using_the_full-screen_api) from
8251 * WebPlatform.org.
8252 * * [Fullscreen specification]
8253 * (http://www.w3.org/TR/fullscreen/) from W3C.
8254 */
8255 @DomName('Document.webkitExitFullscreen')
8256 @SupportedBrowser(SupportedBrowser.CHROME)
8257 @SupportedBrowser(SupportedBrowser.SAFARI)
8258 @Experimental()
8259 void exitFullscreen() {
8260 _webkitExitFullscreen();
8261 }
8262
8263 /**
8264 * Returns the element, if any, that is currently displayed in fullscreen.
8265 *
8266 * Returns null if there is currently no fullscreen element. You can use
8267 * this to determine if the page is in fullscreen mode.
8268 *
8269 * myVideo = new VideoElement();
8270 * if (document.fullscreenElement == null) {
8271 * myVideo.requestFullscreen();
8272 * print(document.fullscreenElement == myVideo); // true
8273 * }
8274 *
8275 * ## Other resources
8276 *
8277 * * [Using the fullscreen API]
8278 * (http://docs.webplatform.org/wiki/tutorials/using_the_full-screen_api) from
8279 * WebPlatform.org.
8280 * * [Fullscreen specification]
8281 * (http://www.w3.org/TR/fullscreen/) from W3C.
8282 */
8283 @DomName('Document.webkitFullscreenElement')
8284 @SupportedBrowser(SupportedBrowser.CHROME)
8285 @SupportedBrowser(SupportedBrowser.SAFARI)
8286 @Experimental()
8287 Element get fullscreenElement => _webkitFullscreenElement;
8288
8289 /**
8290 * Returns true if this document can display elements in fullscreen mode.
8291 *
8292 * ## Other resources
8293 *
8294 * * [Using the fullscreen API]
8295 * (http://docs.webplatform.org/wiki/tutorials/using_the_full-screen_api) from
8296 * WebPlatform.org.
8297 * * [Fullscreen specification]
8298 * (http://www.w3.org/TR/fullscreen/) from W3C.
8299 */
8300 @DomName('Document.webkitFullscreenEnabled')
8301 @SupportedBrowser(SupportedBrowser.CHROME)
8302 @SupportedBrowser(SupportedBrowser.SAFARI)
8303 @Experimental()
8304 bool get fullscreenEnabled => _webkitFullscreenEnabled;
8305
8306 @DomName('Document.webkitHidden')
8307 @SupportedBrowser(SupportedBrowser.CHROME)
8308 @SupportedBrowser(SupportedBrowser.SAFARI)
8309 @Experimental()
8310 bool get hidden => _webkitHidden;
8311
8312 @DomName('Document.visibilityState')
8313 @SupportedBrowser(SupportedBrowser.CHROME)
8314 @SupportedBrowser(SupportedBrowser.FIREFOX)
8315 @SupportedBrowser(SupportedBrowser.IE, '10')
8316 @Experimental()
8317 String get visibilityState => _webkitVisibilityState;
8318
8319 @Experimental()
8320 /**
8321 * Register a custom subclass of Element to be instantiatable by the DOM.
8322 *
8323 * This is necessary to allow the construction of any custom elements.
8324 *
8325 * The class being registered must either subclass HtmlElement or SvgElement.
8326 * If they subclass these directly then they can be used as:
8327 *
8328 * class FooElement extends HtmlElement{
8329 * void created() {
8330 * print('FooElement created!');
8331 * }
8332 * }
8333 *
8334 * main() {
8335 * document.registerElement('x-foo', FooElement);
8336 * var myFoo = new Element.tag('x-foo');
8337 * // prints 'FooElement created!' to the console.
8338 * }
8339 *
8340 * The custom element can also be instantiated via HTML using the syntax
8341 * `<x-foo></x-foo>`
8342 *
8343 * Other elements can be subclassed as well:
8344 *
8345 * class BarElement extends InputElement{
8346 * void created() {
8347 * print('BarElement created!');
8348 * }
8349 * }
8350 *
8351 * main() {
8352 * document.registerElement('x-bar', BarElement);
8353 * var myBar = new Element.tag('input', 'x-bar');
8354 * // prints 'BarElement created!' to the console.
8355 * }
8356 *
8357 * This custom element can also be instantiated via HTML using the syntax
8358 * `<input is="x-bar"></input>`
8359 *
8360 */
8361 void registerElement(String tag, Type customElementClass,
8362 {String extendsTag}) {
8363 _registerCustomElement(JS('', 'window'), this, tag, customElementClass,
8364 extendsTag);
8365 }
8366
8367 /** *Deprecated*: use [registerElement] instead. */
8368 @deprecated
8369 @Experimental()
8370 void register(String tag, Type customElementClass, {String extendsTag}) {
8371 return registerElement(tag, customElementClass, extendsTag: extendsTag);
8372 }
8373
8374 /**
8375 * Static factory designed to expose `visibilitychange` events to event
8376 * handlers that are not necessarily instances of [Document].
8377 *
8378 * See [EventStreamProvider] for usage information.
8379 */
8380 @DomName('Document.visibilityChange')
8381 @SupportedBrowser(SupportedBrowser.CHROME)
8382 @SupportedBrowser(SupportedBrowser.FIREFOX)
8383 @SupportedBrowser(SupportedBrowser.IE, '10')
8384 @Experimental()
8385 static const EventStreamProvider<Event> visibilityChangeEvent =
8386 const _CustomEventStreamProvider<Event>(
8387 _determineVisibilityChangeEventType);
8388
8389 static String _determineVisibilityChangeEventType(EventTarget e) {
8390 return 'webkitvisibilitychange';
8391 }
8392
8393 @SupportedBrowser(SupportedBrowser.CHROME)
8394 @SupportedBrowser(SupportedBrowser.FIREFOX)
8395 @SupportedBrowser(SupportedBrowser.IE, '10')
8396 @Experimental()
8397 Stream<Event> get onVisibilityChange =>
8398 visibilityChangeEvent.forTarget(this);
8399
8400 /// Creates an element upgrader which can be used to change the Dart wrapper
8401 /// type for elements.
8402 ///
8403 /// The type specified must be a subclass of HtmlElement, when an element is
8404 /// upgraded then the created constructor will be invoked on that element.
8405 ///
8406 /// If the type is not a direct subclass of HtmlElement then the extendsTag
8407 /// parameter must be provided.
8408 @Experimental()
8409 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) {
8410 throw 'ElementUpgrader not yet supported on DDC';
8411 }
8412 }
8413 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
8414 // for details. All rights reserved. Use of this source code is governed by a
8415 // BSD-style license that can be found in the LICENSE file.
8416
8417
8418 /**
8419 * A client-side XHR request for getting data from a URL,
8420 * formally known as XMLHttpRequest.
8421 *
8422 * HttpRequest can be used to obtain data from HTTP and FTP protocols,
8423 * and is useful for AJAX-style page updates.
8424 *
8425 * The simplest way to get the contents of a text file, such as a
8426 * JSON-formatted file, is with [getString].
8427 * For example, the following code gets the contents of a JSON file
8428 * and prints its length:
8429 *
8430 * var path = 'myData.json';
8431 * HttpRequest.getString(path)
8432 * .then((String fileContents) {
8433 * print(fileContents.length);
8434 * })
8435 * .catchError((Error error) {
8436 * print(error.toString());
8437 * });
8438 *
8439 * ## Fetching data from other servers
8440 *
8441 * For security reasons, browsers impose restrictions on requests
8442 * made by embedded apps.
8443 * With the default behavior of this class,
8444 * the code making the request must be served from the same origin
8445 * (domain name, port, and application layer protocol)
8446 * as the requested resource.
8447 * In the example above, the myData.json file must be co-located with the
8448 * app that uses it.
8449 * You might be able to
8450 * [get around this restriction](http://www.dartlang.org/articles/json-web-serv ice/#a-note-on-cors-and-httprequest)
8451 * by using CORS headers or JSONP.
8452 *
8453 * ## Other resources
8454 *
8455 * * [Fetch Data Dynamically](https://www.dartlang.org/docs/tutorials/fetchdata /),
8456 * a tutorial from _A Game of Darts_,
8457 * shows two different ways to use HttpRequest to get a JSON file.
8458 * * [Get Input from a Form](https://www.dartlang.org/docs/tutorials/forms/),
8459 * another tutorial from _A Game of Darts_,
8460 * shows using HttpRequest with a custom server.
8461 * * [Dart article on using HttpRequests](http://www.dartlang.org/articles/json -web-service/#getting-data)
8462 * * [JS XMLHttpRequest](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRe quest)
8463 * * [Using XMLHttpRequest](https://developer.mozilla.org/en-US/docs/DOM/XMLHtt pRequest/Using_XMLHttpRequest)
8464 */
8465 @DomName('XMLHttpRequest')
8466 @Native("XMLHttpRequest")
8467 class HttpRequest extends HttpRequestEventTarget {
8468
8469 /**
8470 * Creates a GET request for the specified [url].
8471 *
8472 * The server response must be a `text/` mime type for this request to
8473 * succeed.
8474 *
8475 * This is similar to [request] but specialized for HTTP GET requests which
8476 * return text content.
8477 *
8478 * To add query parameters, append them to the [url] following a `?`,
8479 * joining each key to its value with `=` and separating key-value pairs with
8480 * `&`.
8481 *
8482 * var name = Uri.encodeQueryComponent('John');
8483 * var id = Uri.encodeQueryComponent('42');
8484 * HttpRequest.getString('users.json?name=$name&id=$id')
8485 * .then((HttpRequest resp) {
8486 * // Do something with the response.
8487 * });
8488 *
8489 * See also:
8490 *
8491 * * [request]
8492 */
8493 static Future<String> getString(String url,
8494 {bool withCredentials, void onProgress(ProgressEvent e)}) {
8495 return request(url, withCredentials: withCredentials,
8496 onProgress: onProgress).then((HttpRequest xhr) => xhr.responseText);
8497 }
8498
8499 /**
8500 * Makes a server POST request with the specified data encoded as form data.
8501 *
8502 * This is roughly the POST equivalent of getString. This method is similar
8503 * to sending a FormData object with broader browser support but limited to
8504 * String values.
8505 *
8506 * If [data] is supplied, the key/value pairs are URI encoded with
8507 * [Uri.encodeQueryComponent] and converted into an HTTP query string.
8508 *
8509 * Unless otherwise specified, this method appends the following header:
8510 *
8511 * Content-Type: application/x-www-form-urlencoded; charset=UTF-8
8512 *
8513 * Here's an example of using this method:
8514 *
8515 * var data = { 'firstName' : 'John', 'lastName' : 'Doe' };
8516 * HttpRequest.postFormData('/send', data).then((HttpRequest resp) {
8517 * // Do something with the response.
8518 * });
8519 *
8520 * See also:
8521 *
8522 * * [request]
8523 */
8524 static Future<HttpRequest> postFormData(String url, Map<String, String> data,
8525 {bool withCredentials, String responseType,
8526 Map<String, String> requestHeaders,
8527 void onProgress(ProgressEvent e)}) {
8528
8529 var parts = [];
8530 data.forEach((key, value) {
8531 parts.add('${Uri.encodeQueryComponent(key)}='
8532 '${Uri.encodeQueryComponent(value)}');
8533 });
8534 var formData = parts.join('&');
8535
8536 if (requestHeaders == null) {
8537 requestHeaders = <String, String>{};
8538 }
8539 requestHeaders.putIfAbsent('Content-Type',
8540 () => 'application/x-www-form-urlencoded; charset=UTF-8');
8541
8542 return request(url, method: 'POST', withCredentials: withCredentials,
8543 responseType: responseType,
8544 requestHeaders: requestHeaders, sendData: formData,
8545 onProgress: onProgress);
8546 }
8547
8548 /**
8549 * Creates and sends a URL request for the specified [url].
8550 *
8551 * By default `request` will perform an HTTP GET request, but a different
8552 * method (`POST`, `PUT`, `DELETE`, etc) can be used by specifying the
8553 * [method] parameter. (See also [HttpRequest.postFormData] for `POST`
8554 * requests only.
8555 *
8556 * The Future is completed when the response is available.
8557 *
8558 * If specified, `sendData` will send data in the form of a [ByteBuffer],
8559 * [Blob], [Document], [String], or [FormData] along with the HttpRequest.
8560 *
8561 * If specified, [responseType] sets the desired response format for the
8562 * request. By default it is [String], but can also be 'arraybuffer', 'blob',
8563 * 'document', 'json', or 'text'. See also [HttpRequest.responseType]
8564 * for more information.
8565 *
8566 * The [withCredentials] parameter specified that credentials such as a cookie
8567 * (already) set in the header or
8568 * [authorization headers](http://tools.ietf.org/html/rfc1945#section-10.2)
8569 * should be specified for the request. Details to keep in mind when using
8570 * credentials:
8571 *
8572 * * Using credentials is only useful for cross-origin requests.
8573 * * The `Access-Control-Allow-Origin` header of `url` cannot contain a wildca rd (*).
8574 * * The `Access-Control-Allow-Credentials` header of `url` must be set to tru e.
8575 * * If `Access-Control-Expose-Headers` has not been set to true, only a subse t of all the response headers will be returned when calling [getAllRequestHeader s].
8576 *
8577 * The following is equivalent to the [getString] sample above:
8578 *
8579 * var name = Uri.encodeQueryComponent('John');
8580 * var id = Uri.encodeQueryComponent('42');
8581 * HttpRequest.request('users.json?name=$name&id=$id')
8582 * .then((HttpRequest resp) {
8583 * // Do something with the response.
8584 * });
8585 *
8586 * Here's an example of submitting an entire form with [FormData].
8587 *
8588 * var myForm = querySelector('form#myForm');
8589 * var data = new FormData(myForm);
8590 * HttpRequest.request('/submit', method: 'POST', sendData: data)
8591 * .then((HttpRequest resp) {
8592 * // Do something with the response.
8593 * });
8594 *
8595 * Note that requests for file:// URIs are only supported by Chrome extensions
8596 * with appropriate permissions in their manifest. Requests to file:// URIs
8597 * will also never fail- the Future will always complete successfully, even
8598 * when the file cannot be found.
8599 *
8600 * See also: [authorization headers](http://en.wikipedia.org/wiki/Basic_access _authentication).
8601 */
8602 static Future<HttpRequest> request(String url,
8603 {String method, bool withCredentials, String responseType,
8604 String mimeType, Map<String, String> requestHeaders, sendData,
8605 void onProgress(ProgressEvent e)}) {
8606 var completer = new Completer<HttpRequest>();
8607
8608 var xhr = new HttpRequest();
8609 if (method == null) {
8610 method = 'GET';
8611 }
8612 xhr.open(method, url, async: true);
8613
8614 if (withCredentials != null) {
8615 xhr.withCredentials = withCredentials;
8616 }
8617
8618 if (responseType != null) {
8619 xhr.responseType = responseType;
8620 }
8621
8622 if (mimeType != null) {
8623 xhr.overrideMimeType(mimeType);
8624 }
8625
8626 if (requestHeaders != null) {
8627 requestHeaders.forEach((header, value) {
8628 xhr.setRequestHeader(header, value);
8629 });
8630 }
8631
8632 if (onProgress != null) {
8633 xhr.onProgress.listen(onProgress);
8634 }
8635
8636 xhr.onLoad.listen((e) {
8637 var accepted = xhr.status >= 200 && xhr.status < 300;
8638 var fileUri = xhr.status == 0; // file:// URIs have status of 0.
8639 var notModified = xhr.status == 304;
8640 // Redirect status is specified up to 307, but others have been used in
8641 // practice. Notably Google Drive uses 308 Resume Incomplete for
8642 // resumable uploads, and it's also been used as a redirect. The
8643 // redirect case will be handled by the browser before it gets to us,
8644 // so if we see it we should pass it through to the user.
8645 var unknownRedirect = xhr.status > 307 && xhr.status < 400;
8646
8647 if (accepted || fileUri || notModified || unknownRedirect) {
8648 completer.complete(xhr);
8649 } else {
8650 completer.completeError(e);
8651 }
8652 });
8653
8654 xhr.onError.listen(completer.completeError);
8655
8656 if (sendData != null) {
8657 xhr.send(sendData);
8658 } else {
8659 xhr.send();
8660 }
8661
8662 return completer.future;
8663 }
8664
8665 /**
8666 * Checks to see if the Progress event is supported on the current platform.
8667 */
8668 static bool get supportsProgressEvent {
8669 return true;
8670 }
8671
8672 /**
8673 * Checks to see if the current platform supports making cross origin
8674 * requests.
8675 *
8676 * Note that even if cross origin requests are supported, they still may fail
8677 * if the destination server does not support CORS requests.
8678 */
8679 static bool get supportsCrossOrigin {
8680 return true;
8681 }
8682
8683 /**
8684 * Checks to see if the LoadEnd event is supported on the current platform.
8685 */
8686 static bool get supportsLoadEndEvent {
8687 return true;
8688 }
8689
8690 /**
8691 * Checks to see if the overrideMimeType method is supported on the current
8692 * platform.
8693 */
8694 static bool get supportsOverrideMimeType {
8695 return true;
8696 }
8697
8698 /**
8699 * Makes a cross-origin request to the specified URL.
8700 *
8701 * This API provides a subset of [request] which works on IE9. If IE9
8702 * cross-origin support is not required then [request] should be used instead.
8703 */
8704 @Experimental()
8705 static Future<String> requestCrossOrigin(String url,
8706 {String method, String sendData}) {
8707 if (supportsCrossOrigin) {
8708 return request(url, method: method, sendData: sendData).then((xhr) {
8709 return xhr.responseText;
8710 });
8711 }
8712 }
8713
8714 /**
8715 * Returns all response headers as a key-value map.
8716 *
8717 * Multiple values for the same header key can be combined into one,
8718 * separated by a comma and a space.
8719 *
8720 * See: http://www.w3.org/TR/XMLHttpRequest/#the-getresponseheader()-method
8721 */
8722 Map<String, String> get responseHeaders {
8723 // from Closure's goog.net.Xhrio.getResponseHeaders.
8724 var headers = <String, String>{};
8725 var headersString = this.getAllResponseHeaders();
8726 if (headersString == null) {
8727 return headers;
8728 }
8729 var headersList = headersString.split('\r\n');
8730 for (var header in headersList) {
8731 if (header.isEmpty) {
8732 continue;
8733 }
8734
8735 var splitIdx = header.indexOf(': ');
8736 if (splitIdx == -1) {
8737 continue;
8738 }
8739 var key = header.substring(0, splitIdx).toLowerCase();
8740 var value = header.substring(splitIdx + 2);
8741 if (headers.containsKey(key)) {
8742 headers[key] = '${headers[key]}, $value';
8743 } else {
8744 headers[key] = value;
8745 }
8746 }
8747 return headers;
8748 }
8749
8750 /**
8751 * Specify the desired `url`, and `method` to use in making the request.
8752 *
8753 * By default the request is done asyncronously, with no user or password
8754 * authentication information. If `async` is false, the request will be send
8755 * synchronously.
8756 *
8757 * Calling `open` again on a currently active request is equivalent to
8758 * calling `abort`.
8759 *
8760 * Note: Most simple HTTP requests can be accomplished using the [getString],
8761 * [request], [requestCrossOrigin], or [postFormData] methods. Use of this
8762 * `open` method is intended only for more complext HTTP requests where
8763 * finer-grained control is needed.
8764 */
8765 @DomName('XMLHttpRequest.open')
8766 @DocsEditable()
8767 void open(String method, String url, {bool async, String user, String password }) {
8768 if (async == null && user == null && password == null) {
8769 JS('void', '#.open(#, #)', this.raw, method, url);
8770 } else {
8771 JS('void', '#.open(#, #, #, #, #)', this.raw, method, url, async, user, p assword);
8772 }
8773 }
8774
8775 String get responseType => JS('String', '#.responseType', this.raw);
8776 void set responseType(String value) { JS('void', '#.responseType = #', this.ra w, value); }
8777
8778 // To suppress missing implicit constructor warnings.
8779 factory HttpRequest._() { throw new UnsupportedError("Not supported"); }
8780
8781 /**
8782 * Static factory designed to expose `readystatechange` events to event
8783 * handlers that are not necessarily instances of [HttpRequest].
8784 *
8785 * See [EventStreamProvider] for usage information.
8786 */
8787 @DomName('XMLHttpRequest.readystatechangeEvent')
8788 @DocsEditable()
8789 static const EventStreamProvider<ProgressEvent> readyStateChangeEvent = const EventStreamProvider<ProgressEvent>('readystatechange');
8790
8791 /**
8792 * General constructor for any type of request (GET, POST, etc).
8793 *
8794 * This call is used in conjunction with [open]:
8795 *
8796 * var request = new HttpRequest();
8797 * request.open('GET', 'http://dartlang.org');
8798 * request.onLoad.listen((event) => print(
8799 * 'Request complete ${event.target.reponseText}'));
8800 * request.send();
8801 *
8802 * is the (more verbose) equivalent of
8803 *
8804 * HttpRequest.getString('http://dartlang.org').then(
8805 * (result) => print('Request complete: $result'));
8806 */
8807 @DomName('XMLHttpRequest.XMLHttpRequest')
8808 @DocsEditable()
8809 factory HttpRequest() {
8810 return HttpRequest._create_1();
8811 }
8812 static HttpRequest _create_1() => wrap_jso(JS('HttpRequest', 'new XMLHttpReque st()'));
8813
8814
8815 @Deprecated("Internal Use Only")
8816 static HttpRequest internalCreateHttpRequest() {
8817 return new HttpRequest.internal_();
8818 }
8819
8820 @Deprecated("Internal Use Only")
8821 HttpRequest.internal_() : super.internal_();
8822
8823
8824 @DomName('XMLHttpRequest.DONE')
8825 @DocsEditable()
8826 static const int DONE = 4;
8827
8828 @DomName('XMLHttpRequest.HEADERS_RECEIVED')
8829 @DocsEditable()
8830 static const int HEADERS_RECEIVED = 2;
8831
8832 @DomName('XMLHttpRequest.LOADING')
8833 @DocsEditable()
8834 static const int LOADING = 3;
8835
8836 @DomName('XMLHttpRequest.OPENED')
8837 @DocsEditable()
8838 static const int OPENED = 1;
8839
8840 @DomName('XMLHttpRequest.UNSENT')
8841 @DocsEditable()
8842 static const int UNSENT = 0;
8843
8844 /**
8845 * Indicator of the current state of the request:
8846 *
8847 * <table>
8848 * <tr>
8849 * <td>Value</td>
8850 * <td>State</td>
8851 * <td>Meaning</td>
8852 * </tr>
8853 * <tr>
8854 * <td>0</td>
8855 * <td>unsent</td>
8856 * <td><code>open()</code> has not yet been called</td>
8857 * </tr>
8858 * <tr>
8859 * <td>1</td>
8860 * <td>opened</td>
8861 * <td><code>send()</code> has not yet been called</td>
8862 * </tr>
8863 * <tr>
8864 * <td>2</td>
8865 * <td>headers received</td>
8866 * <td><code>sent()</code> has been called; response headers and <code>sta tus</code> are available</td>
8867 * </tr>
8868 * <tr>
8869 * <td>3</td> <td>loading</td> <td><code>responseText</code> holds some da ta</td>
8870 * </tr>
8871 * <tr>
8872 * <td>4</td> <td>done</td> <td>request is complete</td>
8873 * </tr>
8874 * </table>
8875 */
8876 @DomName('XMLHttpRequest.readyState')
8877 @DocsEditable()
8878 int get readyState => wrap_jso(JS("int", "#.readyState", this.raw));
8879
8880 /**
8881 * The data received as a reponse from the request.
8882 *
8883 * The data could be in the
8884 * form of a [String], [ByteBuffer], [Document], [Blob], or json (also a
8885 * [String]). `null` indicates request failure.
8886 */
8887 @DomName('XMLHttpRequest.response')
8888 @DocsEditable()
8889 @SupportedBrowser(SupportedBrowser.CHROME)
8890 @SupportedBrowser(SupportedBrowser.FIREFOX)
8891 @SupportedBrowser(SupportedBrowser.IE, '10')
8892 @SupportedBrowser(SupportedBrowser.SAFARI)
8893 dynamic get response => _convertNativeToDart_XHR_Response(this._get_response);
8894 @JSName('response')
8895 /**
8896 * The data received as a reponse from the request.
8897 *
8898 * The data could be in the
8899 * form of a [String], [ByteBuffer], [Document], [Blob], or json (also a
8900 * [String]). `null` indicates request failure.
8901 */
8902 @DomName('XMLHttpRequest.response')
8903 @DocsEditable()
8904 @SupportedBrowser(SupportedBrowser.CHROME)
8905 @SupportedBrowser(SupportedBrowser.FIREFOX)
8906 @SupportedBrowser(SupportedBrowser.IE, '10')
8907 @SupportedBrowser(SupportedBrowser.SAFARI)
8908 @Creates('NativeByteBuffer|Blob|Document|=Object|JSExtendableArray|String|num' )
8909 dynamic get _get_response => wrap_jso(JS("dynamic", "#.response", this.raw));
8910
8911 /**
8912 * The response in String form or empty String on failure.
8913 */
8914 @DomName('XMLHttpRequest.responseText')
8915 @DocsEditable()
8916 String get responseText => wrap_jso(JS("String", "#.responseText", this.raw));
8917
8918 @JSName('responseURL')
8919 @DomName('XMLHttpRequest.responseURL')
8920 @DocsEditable()
8921 @Experimental() // untriaged
8922 String get responseUrl => wrap_jso(JS("String", "#.responseURL", this.raw));
8923
8924 @JSName('responseXML')
8925 /**
8926 * The request response, or null on failure.
8927 *
8928 * The response is processed as
8929 * `text/xml` stream, unless responseType = 'document' and the request is
8930 * synchronous.
8931 */
8932 @DomName('XMLHttpRequest.responseXML')
8933 @DocsEditable()
8934 Document get responseXml => wrap_jso(JS("Document", "#.responseXML", this.raw) );
8935
8936 /**
8937 * The http result code from the request (200, 404, etc).
8938 * See also: [Http Status Codes](http://en.wikipedia.org/wiki/List_of_HTTP_sta tus_codes)
8939 */
8940 @DomName('XMLHttpRequest.status')
8941 @DocsEditable()
8942 int get status => wrap_jso(JS("int", "#.status", this.raw));
8943
8944 /**
8945 * The request response string (such as \"200 OK\").
8946 * See also: [Http Status Codes](http://en.wikipedia.org/wiki/List_of_HTTP_sta tus_codes)
8947 */
8948 @DomName('XMLHttpRequest.statusText')
8949 @DocsEditable()
8950 String get statusText => wrap_jso(JS("String", "#.statusText", this.raw));
8951
8952 /**
8953 * Length of time before a request is automatically terminated.
8954 *
8955 * When the time has passed, a [TimeoutEvent] is dispatched.
8956 *
8957 * If [timeout] is set to 0, then the request will not time out.
8958 *
8959 * ## Other resources
8960 *
8961 * * [XMLHttpRequest.timeout]
8962 * (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#timeout)
8963 * from MDN.
8964 * * [The timeout attribute]
8965 * (http://www.w3.org/TR/XMLHttpRequest/#the-timeout-attribute)
8966 * from W3C.
8967 */
8968 @DomName('XMLHttpRequest.timeout')
8969 @DocsEditable()
8970 @Experimental() // untriaged
8971 int get timeout => wrap_jso(JS("int", "#.timeout", this.raw));
8972 /**
8973 * Length of time before a request is automatically terminated.
8974 *
8975 * When the time has passed, a [TimeoutEvent] is dispatched.
8976 *
8977 * If [timeout] is set to 0, then the request will not time out.
8978 *
8979 * ## Other resources
8980 *
8981 * * [XMLHttpRequest.timeout]
8982 * (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#timeout)
8983 * from MDN.
8984 * * [The timeout attribute]
8985 * (http://www.w3.org/TR/XMLHttpRequest/#the-timeout-attribute)
8986 * from W3C.
8987 */
8988 @DomName('XMLHttpRequest.timeout')
8989 @DocsEditable()
8990 @Experimental() // untriaged
8991 void set timeout(int val) => JS("void", "#.timeout = #", this.raw, unwrap_jso( val));
8992
8993 /**
8994 * [EventTarget] that can hold listeners to track the progress of the request.
8995 * The events fired will be members of [HttpRequestUploadEvents].
8996 */
8997 @DomName('XMLHttpRequest.upload')
8998 @DocsEditable()
8999 @Unstable()
9000 HttpRequestEventTarget get upload => wrap_jso(JS("HttpRequestEventTarget", "#. upload", this.raw));
9001
9002 /**
9003 * True if cross-site requests should use credentials such as cookies
9004 * or authorization headers; false otherwise.
9005 *
9006 * This value is ignored for same-site requests.
9007 */
9008 @DomName('XMLHttpRequest.withCredentials')
9009 @DocsEditable()
9010 bool get withCredentials => wrap_jso(JS("bool", "#.withCredentials", this.raw) );
9011 /**
9012 * True if cross-site requests should use credentials such as cookies
9013 * or authorization headers; false otherwise.
9014 *
9015 * This value is ignored for same-site requests.
9016 */
9017 @DomName('XMLHttpRequest.withCredentials')
9018 @DocsEditable()
9019 void set withCredentials(bool val) => JS("void", "#.withCredentials = #", this .raw, unwrap_jso(val));
9020
9021 /**
9022 * Stop the current request.
9023 *
9024 * The request can only be stopped if readyState is `HEADERS_RECIEVED` or
9025 * `LOADING`. If this method is not in the process of being sent, the method
9026 * has no effect.
9027 */
9028 @DomName('XMLHttpRequest.abort')
9029 @DocsEditable()
9030 void abort() {
9031 _abort_1();
9032 return;
9033 }
9034 @JSName('abort')
9035 /**
9036 * Stop the current request.
9037 *
9038 * The request can only be stopped if readyState is `HEADERS_RECIEVED` or
9039 * `LOADING`. If this method is not in the process of being sent, the method
9040 * has no effect.
9041 */
9042 @DomName('XMLHttpRequest.abort')
9043 @DocsEditable()
9044 void _abort_1() => wrap_jso(JS("void ", "#.raw.abort()", this));
9045
9046 /**
9047 * Retrieve all the response headers from a request.
9048 *
9049 * `null` if no headers have been received. For multipart requests,
9050 * `getAllResponseHeaders` will return the response headers for the current
9051 * part of the request.
9052 *
9053 * See also [HTTP response headers](http://en.wikipedia.org/wiki/List_of_HTTP_ header_fields#Responses)
9054 * for a list of common response headers.
9055 */
9056 @DomName('XMLHttpRequest.getAllResponseHeaders')
9057 @DocsEditable()
9058 @Unstable()
9059 String getAllResponseHeaders() {
9060 return _getAllResponseHeaders_1();
9061 }
9062 @JSName('getAllResponseHeaders')
9063 /**
9064 * Retrieve all the response headers from a request.
9065 *
9066 * `null` if no headers have been received. For multipart requests,
9067 * `getAllResponseHeaders` will return the response headers for the current
9068 * part of the request.
9069 *
9070 * See also [HTTP response headers](http://en.wikipedia.org/wiki/List_of_HTTP_ header_fields#Responses)
9071 * for a list of common response headers.
9072 */
9073 @DomName('XMLHttpRequest.getAllResponseHeaders')
9074 @DocsEditable()
9075 @Unstable()
9076 String _getAllResponseHeaders_1() => wrap_jso(JS("String ", "#.raw.getAllRespo nseHeaders()", this));
9077
9078 /**
9079 * Return the response header named `header`, or null if not found.
9080 *
9081 * See also [HTTP response headers](http://en.wikipedia.org/wiki/List_of_HTTP_ header_fields#Responses)
9082 * for a list of common response headers.
9083 */
9084 @DomName('XMLHttpRequest.getResponseHeader')
9085 @DocsEditable()
9086 @Unstable()
9087 String getResponseHeader(String header) {
9088 return _getResponseHeader_1(header);
9089 }
9090 @JSName('getResponseHeader')
9091 /**
9092 * Return the response header named `header`, or null if not found.
9093 *
9094 * See also [HTTP response headers](http://en.wikipedia.org/wiki/List_of_HTTP_ header_fields#Responses)
9095 * for a list of common response headers.
9096 */
9097 @DomName('XMLHttpRequest.getResponseHeader')
9098 @DocsEditable()
9099 @Unstable()
9100 String _getResponseHeader_1(header) => wrap_jso(JS("String ", "#.raw.getRespon seHeader(#)", this, unwrap_jso(header)));
9101
9102 /**
9103 * Specify a particular MIME type (such as `text/xml`) desired for the
9104 * response.
9105 *
9106 * This value must be set before the request has been sent. See also the list
9107 * of [common MIME types](http://en.wikipedia.org/wiki/Internet_media_type#Lis t_of_common_media_types)
9108 */
9109 @DomName('XMLHttpRequest.overrideMimeType')
9110 @DocsEditable()
9111 @SupportedBrowser(SupportedBrowser.CHROME)
9112 @SupportedBrowser(SupportedBrowser.FIREFOX)
9113 @SupportedBrowser(SupportedBrowser.SAFARI)
9114 void overrideMimeType(String override) {
9115 _overrideMimeType_1(override);
9116 return;
9117 }
9118 @JSName('overrideMimeType')
9119 /**
9120 * Specify a particular MIME type (such as `text/xml`) desired for the
9121 * response.
9122 *
9123 * This value must be set before the request has been sent. See also the list
9124 * of [common MIME types](http://en.wikipedia.org/wiki/Internet_media_type#Lis t_of_common_media_types)
9125 */
9126 @DomName('XMLHttpRequest.overrideMimeType')
9127 @DocsEditable()
9128 @SupportedBrowser(SupportedBrowser.CHROME)
9129 @SupportedBrowser(SupportedBrowser.FIREFOX)
9130 @SupportedBrowser(SupportedBrowser.SAFARI)
9131 void _overrideMimeType_1(override) => wrap_jso(JS("void ", "#.raw.overrideMime Type(#)", this, unwrap_jso(override)));
9132
9133 /**
9134 * Send the request with any given `data`.
9135 *
9136 * Note: Most simple HTTP requests can be accomplished using the [getString],
9137 * [request], [requestCrossOrigin], or [postFormData] methods. Use of this
9138 * `send` method is intended only for more complext HTTP requests where
9139 * finer-grained control is needed.
9140 *
9141 * ## Other resources
9142 *
9143 * * [XMLHttpRequest.send]
9144 * (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#send%28%29)
9145 * from MDN.
9146 */
9147 @DomName('XMLHttpRequest.send')
9148 @DocsEditable()
9149 void send([data]) {
9150 if (data == null) {
9151 _send_1();
9152 return;
9153 }
9154 if ((data is Document || data == null)) {
9155 _send_2(data);
9156 return;
9157 }
9158 if ((data is String || data == null)) {
9159 _send_3(data);
9160 return;
9161 }
9162 throw new ArgumentError("Incorrect number or type of arguments");
9163 }
9164 @JSName('send')
9165 /**
9166 * Send the request with any given `data`.
9167 *
9168 * Note: Most simple HTTP requests can be accomplished using the [getString],
9169 * [request], [requestCrossOrigin], or [postFormData] methods. Use of this
9170 * `send` method is intended only for more complext HTTP requests where
9171 * finer-grained control is needed.
9172 *
9173 * ## Other resources
9174 *
9175 * * [XMLHttpRequest.send]
9176 * (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#send%28%29)
9177 * from MDN.
9178 */
9179 @DomName('XMLHttpRequest.send')
9180 @DocsEditable()
9181 void _send_1() => wrap_jso(JS("void ", "#.raw.send()", this));
9182 @JSName('send')
9183 /**
9184 * Send the request with any given `data`.
9185 *
9186 * Note: Most simple HTTP requests can be accomplished using the [getString],
9187 * [request], [requestCrossOrigin], or [postFormData] methods. Use of this
9188 * `send` method is intended only for more complext HTTP requests where
9189 * finer-grained control is needed.
9190 *
9191 * ## Other resources
9192 *
9193 * * [XMLHttpRequest.send]
9194 * (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#send%28%29)
9195 * from MDN.
9196 */
9197 @DomName('XMLHttpRequest.send')
9198 @DocsEditable()
9199 void _send_2(Document data) => wrap_jso(JS("void ", "#.raw.send(#)", this, unw rap_jso(data)));
9200 @JSName('send')
9201 /**
9202 * Send the request with any given `data`.
9203 *
9204 * Note: Most simple HTTP requests can be accomplished using the [getString],
9205 * [request], [requestCrossOrigin], or [postFormData] methods. Use of this
9206 * `send` method is intended only for more complext HTTP requests where
9207 * finer-grained control is needed.
9208 *
9209 * ## Other resources
9210 *
9211 * * [XMLHttpRequest.send]
9212 * (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#send%28%29)
9213 * from MDN.
9214 */
9215 @DomName('XMLHttpRequest.send')
9216 @DocsEditable()
9217 void _send_3(String data) => wrap_jso(JS("void ", "#.raw.send(#)", this, unwra p_jso(data)));
9218
9219 /**
9220 * Sets the value of an HTTP requst header.
9221 *
9222 * This method should be called after the request is opened, but before
9223 * the request is sent.
9224 *
9225 * Multiple calls with the same header will combine all their values into a
9226 * single header.
9227 *
9228 * ## Other resources
9229 *
9230 * * [XMLHttpRequest.setRequestHeader]
9231 * (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#send%28%29)
9232 * from MDN.
9233 * * [The setRequestHeader() method]
9234 * (http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader()-method) from
9235 * W3C.
9236 */
9237 @DomName('XMLHttpRequest.setRequestHeader')
9238 @DocsEditable()
9239 void setRequestHeader(String header, String value) {
9240 _setRequestHeader_1(header, value);
9241 return;
9242 }
9243 @JSName('setRequestHeader')
9244 /**
9245 * Sets the value of an HTTP requst header.
9246 *
9247 * This method should be called after the request is opened, but before
9248 * the request is sent.
9249 *
9250 * Multiple calls with the same header will combine all their values into a
9251 * single header.
9252 *
9253 * ## Other resources
9254 *
9255 * * [XMLHttpRequest.setRequestHeader]
9256 * (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#send%28%29)
9257 * from MDN.
9258 * * [The setRequestHeader() method]
9259 * (http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader()-method) from
9260 * W3C.
9261 */
9262 @DomName('XMLHttpRequest.setRequestHeader')
9263 @DocsEditable()
9264 void _setRequestHeader_1(header, value) => wrap_jso(JS("void ", "#.raw.setRequ estHeader(#, #)", this, unwrap_jso(header), unwrap_jso(value)));
9265
9266 /// Stream of `readystatechange` events handled by this [HttpRequest].
9267 /**
9268 * Event listeners to be notified every time the [HttpRequest]
9269 * object's `readyState` changes values.
9270 */
9271 @DomName('XMLHttpRequest.onreadystatechange')
9272 @DocsEditable()
9273 Stream<ProgressEvent> get onReadyStateChange => readyStateChangeEvent.forTarge t(this);
9274
9275 }
9276 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
9277 // for details. All rights reserved. Use of this source code is governed by a
9278 // BSD-style license that can be found in the LICENSE file.
9279
9280
9281 @DocsEditable()
9282 @DomName('XMLHttpRequestEventTarget')
9283 @Experimental() // untriaged
9284 @Native("XMLHttpRequestEventTarget")
9285 class HttpRequestEventTarget extends EventTarget {
9286 // To suppress missing implicit constructor warnings.
9287 factory HttpRequestEventTarget._() { throw new UnsupportedError("Not supported "); }
9288
9289 /**
9290 * Static factory designed to expose `abort` events to event
9291 * handlers that are not necessarily instances of [HttpRequestEventTarget].
9292 *
9293 * See [EventStreamProvider] for usage information.
9294 */
9295 @DomName('XMLHttpRequestEventTarget.abortEvent')
9296 @DocsEditable()
9297 @Experimental() // untriaged
9298 static const EventStreamProvider<ProgressEvent> abortEvent = const EventStream Provider<ProgressEvent>('abort');
9299
9300 /**
9301 * Static factory designed to expose `error` events to event
9302 * handlers that are not necessarily instances of [HttpRequestEventTarget].
9303 *
9304 * See [EventStreamProvider] for usage information.
9305 */
9306 @DomName('XMLHttpRequestEventTarget.errorEvent')
9307 @DocsEditable()
9308 @Experimental() // untriaged
9309 static const EventStreamProvider<ProgressEvent> errorEvent = const EventStream Provider<ProgressEvent>('error');
9310
9311 /**
9312 * Static factory designed to expose `load` events to event
9313 * handlers that are not necessarily instances of [HttpRequestEventTarget].
9314 *
9315 * See [EventStreamProvider] for usage information.
9316 */
9317 @DomName('XMLHttpRequestEventTarget.loadEvent')
9318 @DocsEditable()
9319 @Experimental() // untriaged
9320 static const EventStreamProvider<ProgressEvent> loadEvent = const EventStreamP rovider<ProgressEvent>('load');
9321
9322 /**
9323 * Static factory designed to expose `loadend` events to event
9324 * handlers that are not necessarily instances of [HttpRequestEventTarget].
9325 *
9326 * See [EventStreamProvider] for usage information.
9327 */
9328 @DomName('XMLHttpRequestEventTarget.loadendEvent')
9329 @DocsEditable()
9330 @Experimental() // untriaged
9331 static const EventStreamProvider<ProgressEvent> loadEndEvent = const EventStre amProvider<ProgressEvent>('loadend');
9332
9333 /**
9334 * Static factory designed to expose `loadstart` events to event
9335 * handlers that are not necessarily instances of [HttpRequestEventTarget].
9336 *
9337 * See [EventStreamProvider] for usage information.
9338 */
9339 @DomName('XMLHttpRequestEventTarget.loadstartEvent')
9340 @DocsEditable()
9341 @Experimental() // untriaged
9342 static const EventStreamProvider<ProgressEvent> loadStartEvent = const EventSt reamProvider<ProgressEvent>('loadstart');
9343
9344 /**
9345 * Static factory designed to expose `progress` events to event
9346 * handlers that are not necessarily instances of [HttpRequestEventTarget].
9347 *
9348 * See [EventStreamProvider] for usage information.
9349 */
9350 @DomName('XMLHttpRequestEventTarget.progressEvent')
9351 @DocsEditable()
9352 @Experimental() // untriaged
9353 static const EventStreamProvider<ProgressEvent> progressEvent = const EventStr eamProvider<ProgressEvent>('progress');
9354
9355 /**
9356 * Static factory designed to expose `timeout` events to event
9357 * handlers that are not necessarily instances of [HttpRequestEventTarget].
9358 *
9359 * See [EventStreamProvider] for usage information.
9360 */
9361 @DomName('XMLHttpRequestEventTarget.timeoutEvent')
9362 @DocsEditable()
9363 @Experimental() // untriaged
9364 static const EventStreamProvider<ProgressEvent> timeoutEvent = const EventStre amProvider<ProgressEvent>('timeout');
9365
9366
9367 @Deprecated("Internal Use Only")
9368 static HttpRequestEventTarget internalCreateHttpRequestEventTarget() {
9369 return new HttpRequestEventTarget.internal_();
9370 }
9371
9372 @Deprecated("Internal Use Only")
9373 HttpRequestEventTarget.internal_() : super.internal_();
9374
9375
9376 /// Stream of `abort` events handled by this [HttpRequestEventTarget].
9377 @DomName('XMLHttpRequestEventTarget.onabort')
9378 @DocsEditable()
9379 @Experimental() // untriaged
9380 Stream<ProgressEvent> get onAbort => abortEvent.forTarget(this);
9381
9382 /// Stream of `error` events handled by this [HttpRequestEventTarget].
9383 @DomName('XMLHttpRequestEventTarget.onerror')
9384 @DocsEditable()
9385 @Experimental() // untriaged
9386 Stream<ProgressEvent> get onError => errorEvent.forTarget(this);
9387
9388 /// Stream of `load` events handled by this [HttpRequestEventTarget].
9389 @DomName('XMLHttpRequestEventTarget.onload')
9390 @DocsEditable()
9391 @Experimental() // untriaged
9392 Stream<ProgressEvent> get onLoad => loadEvent.forTarget(this);
9393
9394 /// Stream of `loadend` events handled by this [HttpRequestEventTarget].
9395 @DomName('XMLHttpRequestEventTarget.onloadend')
9396 @DocsEditable()
9397 @SupportedBrowser(SupportedBrowser.CHROME)
9398 @SupportedBrowser(SupportedBrowser.FIREFOX)
9399 @SupportedBrowser(SupportedBrowser.IE, '10')
9400 @SupportedBrowser(SupportedBrowser.SAFARI)
9401 @Experimental() // untriaged
9402 Stream<ProgressEvent> get onLoadEnd => loadEndEvent.forTarget(this);
9403
9404 /// Stream of `loadstart` events handled by this [HttpRequestEventTarget].
9405 @DomName('XMLHttpRequestEventTarget.onloadstart')
9406 @DocsEditable()
9407 @Experimental() // untriaged
9408 Stream<ProgressEvent> get onLoadStart => loadStartEvent.forTarget(this);
9409
9410 /// Stream of `progress` events handled by this [HttpRequestEventTarget].
9411 @DomName('XMLHttpRequestEventTarget.onprogress')
9412 @DocsEditable()
9413 @SupportedBrowser(SupportedBrowser.CHROME)
9414 @SupportedBrowser(SupportedBrowser.FIREFOX)
9415 @SupportedBrowser(SupportedBrowser.IE, '10')
9416 @SupportedBrowser(SupportedBrowser.SAFARI)
9417 @Experimental() // untriaged
9418 Stream<ProgressEvent> get onProgress => progressEvent.forTarget(this);
9419
9420 /// Stream of `timeout` events handled by this [HttpRequestEventTarget].
9421 @DomName('XMLHttpRequestEventTarget.ontimeout')
9422 @DocsEditable()
9423 @Experimental() // untriaged
9424 Stream<ProgressEvent> get onTimeout => timeoutEvent.forTarget(this);
9425 }
9426 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
9427 // for details. All rights reserved. Use of this source code is governed by a
9428 // BSD-style license that can be found in the LICENSE file.
9429
9430
9431 @DomName('HTMLInputElement')
9432 @Native("HTMLInputElement")
9433 class InputElement extends HtmlElement implements
9434 HiddenInputElement,
9435 SearchInputElement,
9436 TextInputElement,
9437 UrlInputElement,
9438 TelephoneInputElement,
9439 EmailInputElement,
9440 PasswordInputElement,
9441 DateInputElement,
9442 MonthInputElement,
9443 WeekInputElement,
9444 TimeInputElement,
9445 LocalDateTimeInputElement,
9446 NumberInputElement,
9447 RangeInputElement,
9448 CheckboxInputElement,
9449 RadioButtonInputElement,
9450 FileUploadInputElement,
9451 SubmitButtonInputElement,
9452 ImageButtonInputElement,
9453 ResetButtonInputElement,
9454 ButtonInputElement {
9455
9456 factory InputElement({String type}) {
9457 InputElement e = document.createElement("input");
9458 if (type != null) {
9459 try {
9460 // IE throws an exception for unknown types.
9461 e.type = type;
9462 } catch(_) {}
9463 }
9464 return e;
9465 }
9466
9467 // To suppress missing implicit constructor warnings.
9468 factory InputElement._() { throw new UnsupportedError("Not supported"); }
9469
9470
9471 @Deprecated("Internal Use Only")
9472 static InputElement internalCreateInputElement() {
9473 return new InputElement.internal_();
9474 }
9475
9476 @Deprecated("Internal Use Only")
9477 InputElement.internal_() : super.internal_();
9478
9479
9480 @DomName('HTMLInputElement.accept')
9481 @DocsEditable()
9482 String get accept => wrap_jso(JS("String", "#.accept", this.raw));
9483 @DomName('HTMLInputElement.accept')
9484 @DocsEditable()
9485 void set accept(String val) => JS("void", "#.accept = #", this.raw, unwrap_jso (val));
9486
9487 @DomName('HTMLInputElement.alt')
9488 @DocsEditable()
9489 String get alt => wrap_jso(JS("String", "#.alt", this.raw));
9490 @DomName('HTMLInputElement.alt')
9491 @DocsEditable()
9492 void set alt(String val) => JS("void", "#.alt = #", this.raw, unwrap_jso(val)) ;
9493
9494 @DomName('HTMLInputElement.autocomplete')
9495 @DocsEditable()
9496 String get autocomplete => wrap_jso(JS("String", "#.autocomplete", this.raw));
9497 @DomName('HTMLInputElement.autocomplete')
9498 @DocsEditable()
9499 void set autocomplete(String val) => JS("void", "#.autocomplete = #", this.raw , unwrap_jso(val));
9500
9501 @DomName('HTMLInputElement.autofocus')
9502 @DocsEditable()
9503 bool get autofocus => wrap_jso(JS("bool", "#.autofocus", this.raw));
9504 @DomName('HTMLInputElement.autofocus')
9505 @DocsEditable()
9506 void set autofocus(bool val) => JS("void", "#.autofocus = #", this.raw, unwrap _jso(val));
9507
9508 @DomName('HTMLInputElement.capture')
9509 @DocsEditable()
9510 @Experimental() // untriaged
9511 bool get capture => wrap_jso(JS("bool", "#.capture", this.raw));
9512 @DomName('HTMLInputElement.capture')
9513 @DocsEditable()
9514 @Experimental() // untriaged
9515 void set capture(bool val) => JS("void", "#.capture = #", this.raw, unwrap_jso (val));
9516
9517 @DomName('HTMLInputElement.checked')
9518 @DocsEditable()
9519 bool get checked => wrap_jso(JS("bool", "#.checked", this.raw));
9520 @DomName('HTMLInputElement.checked')
9521 @DocsEditable()
9522 void set checked(bool val) => JS("void", "#.checked = #", this.raw, unwrap_jso (val));
9523
9524 @DomName('HTMLInputElement.defaultChecked')
9525 @DocsEditable()
9526 bool get defaultChecked => wrap_jso(JS("bool", "#.defaultChecked", this.raw));
9527 @DomName('HTMLInputElement.defaultChecked')
9528 @DocsEditable()
9529 void set defaultChecked(bool val) => JS("void", "#.defaultChecked = #", this.r aw, unwrap_jso(val));
9530
9531 @DomName('HTMLInputElement.defaultValue')
9532 @DocsEditable()
9533 String get defaultValue => wrap_jso(JS("String", "#.defaultValue", this.raw));
9534 @DomName('HTMLInputElement.defaultValue')
9535 @DocsEditable()
9536 void set defaultValue(String val) => JS("void", "#.defaultValue = #", this.raw , unwrap_jso(val));
9537
9538 @DomName('HTMLInputElement.dirName')
9539 @DocsEditable()
9540 String get dirName => wrap_jso(JS("String", "#.dirName", this.raw));
9541 @DomName('HTMLInputElement.dirName')
9542 @DocsEditable()
9543 void set dirName(String val) => JS("void", "#.dirName = #", this.raw, unwrap_j so(val));
9544
9545 @DomName('HTMLInputElement.disabled')
9546 @DocsEditable()
9547 bool get disabled => wrap_jso(JS("bool", "#.disabled", this.raw));
9548 @DomName('HTMLInputElement.disabled')
9549 @DocsEditable()
9550 void set disabled(bool val) => JS("void", "#.disabled = #", this.raw, unwrap_j so(val));
9551
9552 @DomName('HTMLInputElement.form')
9553 @DocsEditable()
9554 HtmlElement get form => wrap_jso(JS("HtmlElement", "#.form", this.raw));
9555
9556 @DomName('HTMLInputElement.formAction')
9557 @DocsEditable()
9558 String get formAction => wrap_jso(JS("String", "#.formAction", this.raw));
9559 @DomName('HTMLInputElement.formAction')
9560 @DocsEditable()
9561 void set formAction(String val) => JS("void", "#.formAction = #", this.raw, un wrap_jso(val));
9562
9563 @DomName('HTMLInputElement.formEnctype')
9564 @DocsEditable()
9565 String get formEnctype => wrap_jso(JS("String", "#.formEnctype", this.raw));
9566 @DomName('HTMLInputElement.formEnctype')
9567 @DocsEditable()
9568 void set formEnctype(String val) => JS("void", "#.formEnctype = #", this.raw, unwrap_jso(val));
9569
9570 @DomName('HTMLInputElement.formMethod')
9571 @DocsEditable()
9572 String get formMethod => wrap_jso(JS("String", "#.formMethod", this.raw));
9573 @DomName('HTMLInputElement.formMethod')
9574 @DocsEditable()
9575 void set formMethod(String val) => JS("void", "#.formMethod = #", this.raw, un wrap_jso(val));
9576
9577 @DomName('HTMLInputElement.formNoValidate')
9578 @DocsEditable()
9579 bool get formNoValidate => wrap_jso(JS("bool", "#.formNoValidate", this.raw));
9580 @DomName('HTMLInputElement.formNoValidate')
9581 @DocsEditable()
9582 void set formNoValidate(bool val) => JS("void", "#.formNoValidate = #", this.r aw, unwrap_jso(val));
9583
9584 @DomName('HTMLInputElement.formTarget')
9585 @DocsEditable()
9586 String get formTarget => wrap_jso(JS("String", "#.formTarget", this.raw));
9587 @DomName('HTMLInputElement.formTarget')
9588 @DocsEditable()
9589 void set formTarget(String val) => JS("void", "#.formTarget = #", this.raw, un wrap_jso(val));
9590
9591 @DomName('HTMLInputElement.height')
9592 @DocsEditable()
9593 int get height => wrap_jso(JS("int", "#.height", this.raw));
9594 @DomName('HTMLInputElement.height')
9595 @DocsEditable()
9596 void set height(int val) => JS("void", "#.height = #", this.raw, unwrap_jso(va l));
9597
9598 @DomName('HTMLInputElement.incremental')
9599 @DocsEditable()
9600 // http://www.w3.org/TR/html-markup/input.search.html
9601 @Experimental()
9602 bool get incremental => wrap_jso(JS("bool", "#.incremental", this.raw));
9603 @DomName('HTMLInputElement.incremental')
9604 @DocsEditable()
9605 // http://www.w3.org/TR/html-markup/input.search.html
9606 @Experimental()
9607 void set incremental(bool val) => JS("void", "#.incremental = #", this.raw, un wrap_jso(val));
9608
9609 @DomName('HTMLInputElement.indeterminate')
9610 @DocsEditable()
9611 bool get indeterminate => wrap_jso(JS("bool", "#.indeterminate", this.raw));
9612 @DomName('HTMLInputElement.indeterminate')
9613 @DocsEditable()
9614 void set indeterminate(bool val) => JS("void", "#.indeterminate = #", this.raw , unwrap_jso(val));
9615
9616 @DomName('HTMLInputElement.inputMode')
9617 @DocsEditable()
9618 @Experimental() // untriaged
9619 String get inputMode => wrap_jso(JS("String", "#.inputMode", this.raw));
9620 @DomName('HTMLInputElement.inputMode')
9621 @DocsEditable()
9622 @Experimental() // untriaged
9623 void set inputMode(String val) => JS("void", "#.inputMode = #", this.raw, unwr ap_jso(val));
9624
9625 @DomName('HTMLInputElement.labels')
9626 @DocsEditable()
9627 @Returns('NodeList')
9628 @Creates('NodeList')
9629 List<Node> get labels => wrap_jso(JS("List<Node>", "#.labels", this.raw));
9630
9631 @DomName('HTMLInputElement.list')
9632 @DocsEditable()
9633 HtmlElement get list => wrap_jso(JS("HtmlElement", "#.list", this.raw));
9634
9635 @DomName('HTMLInputElement.max')
9636 @DocsEditable()
9637 String get max => wrap_jso(JS("String", "#.max", this.raw));
9638 @DomName('HTMLInputElement.max')
9639 @DocsEditable()
9640 void set max(String val) => JS("void", "#.max = #", this.raw, unwrap_jso(val)) ;
9641
9642 @DomName('HTMLInputElement.maxLength')
9643 @DocsEditable()
9644 int get maxLength => wrap_jso(JS("int", "#.maxLength", this.raw));
9645 @DomName('HTMLInputElement.maxLength')
9646 @DocsEditable()
9647 void set maxLength(int val) => JS("void", "#.maxLength = #", this.raw, unwrap_ jso(val));
9648
9649 @DomName('HTMLInputElement.min')
9650 @DocsEditable()
9651 String get min => wrap_jso(JS("String", "#.min", this.raw));
9652 @DomName('HTMLInputElement.min')
9653 @DocsEditable()
9654 void set min(String val) => JS("void", "#.min = #", this.raw, unwrap_jso(val)) ;
9655
9656 @DomName('HTMLInputElement.multiple')
9657 @DocsEditable()
9658 bool get multiple => wrap_jso(JS("bool", "#.multiple", this.raw));
9659 @DomName('HTMLInputElement.multiple')
9660 @DocsEditable()
9661 void set multiple(bool val) => JS("void", "#.multiple = #", this.raw, unwrap_j so(val));
9662
9663 @DomName('HTMLInputElement.name')
9664 @DocsEditable()
9665 String get name => wrap_jso(JS("String", "#.name", this.raw));
9666 @DomName('HTMLInputElement.name')
9667 @DocsEditable()
9668 void set name(String val) => JS("void", "#.name = #", this.raw, unwrap_jso(val ));
9669
9670 @DomName('HTMLInputElement.pattern')
9671 @DocsEditable()
9672 String get pattern => wrap_jso(JS("String", "#.pattern", this.raw));
9673 @DomName('HTMLInputElement.pattern')
9674 @DocsEditable()
9675 void set pattern(String val) => JS("void", "#.pattern = #", this.raw, unwrap_j so(val));
9676
9677 @DomName('HTMLInputElement.placeholder')
9678 @DocsEditable()
9679 String get placeholder => wrap_jso(JS("String", "#.placeholder", this.raw));
9680 @DomName('HTMLInputElement.placeholder')
9681 @DocsEditable()
9682 void set placeholder(String val) => JS("void", "#.placeholder = #", this.raw, unwrap_jso(val));
9683
9684 @DomName('HTMLInputElement.readOnly')
9685 @DocsEditable()
9686 bool get readOnly => wrap_jso(JS("bool", "#.readOnly", this.raw));
9687 @DomName('HTMLInputElement.readOnly')
9688 @DocsEditable()
9689 void set readOnly(bool val) => JS("void", "#.readOnly = #", this.raw, unwrap_j so(val));
9690
9691 @DomName('HTMLInputElement.required')
9692 @DocsEditable()
9693 bool get required => wrap_jso(JS("bool", "#.required", this.raw));
9694 @DomName('HTMLInputElement.required')
9695 @DocsEditable()
9696 void set required(bool val) => JS("void", "#.required = #", this.raw, unwrap_j so(val));
9697
9698 @DomName('HTMLInputElement.selectionDirection')
9699 @DocsEditable()
9700 String get selectionDirection => wrap_jso(JS("String", "#.selectionDirection", this.raw));
9701 @DomName('HTMLInputElement.selectionDirection')
9702 @DocsEditable()
9703 void set selectionDirection(String val) => JS("void", "#.selectionDirection = #", this.raw, unwrap_jso(val));
9704
9705 @DomName('HTMLInputElement.selectionEnd')
9706 @DocsEditable()
9707 int get selectionEnd => wrap_jso(JS("int", "#.selectionEnd", this.raw));
9708 @DomName('HTMLInputElement.selectionEnd')
9709 @DocsEditable()
9710 void set selectionEnd(int val) => JS("void", "#.selectionEnd = #", this.raw, u nwrap_jso(val));
9711
9712 @DomName('HTMLInputElement.selectionStart')
9713 @DocsEditable()
9714 int get selectionStart => wrap_jso(JS("int", "#.selectionStart", this.raw));
9715 @DomName('HTMLInputElement.selectionStart')
9716 @DocsEditable()
9717 void set selectionStart(int val) => JS("void", "#.selectionStart = #", this.ra w, unwrap_jso(val));
9718
9719 @DomName('HTMLInputElement.size')
9720 @DocsEditable()
9721 int get size => wrap_jso(JS("int", "#.size", this.raw));
9722 @DomName('HTMLInputElement.size')
9723 @DocsEditable()
9724 void set size(int val) => JS("void", "#.size = #", this.raw, unwrap_jso(val));
9725
9726 @DomName('HTMLInputElement.src')
9727 @DocsEditable()
9728 String get src => wrap_jso(JS("String", "#.src", this.raw));
9729 @DomName('HTMLInputElement.src')
9730 @DocsEditable()
9731 void set src(String val) => JS("void", "#.src = #", this.raw, unwrap_jso(val)) ;
9732
9733 @DomName('HTMLInputElement.step')
9734 @DocsEditable()
9735 String get step => wrap_jso(JS("String", "#.step", this.raw));
9736 @DomName('HTMLInputElement.step')
9737 @DocsEditable()
9738 void set step(String val) => JS("void", "#.step = #", this.raw, unwrap_jso(val ));
9739
9740 @DomName('HTMLInputElement.type')
9741 @DocsEditable()
9742 String get type => wrap_jso(JS("String", "#.type", this.raw));
9743 @DomName('HTMLInputElement.type')
9744 @DocsEditable()
9745 void set type(String val) => JS("void", "#.type = #", this.raw, unwrap_jso(val ));
9746
9747 @DomName('HTMLInputElement.validationMessage')
9748 @DocsEditable()
9749 String get validationMessage => wrap_jso(JS("String", "#.validationMessage", t his.raw));
9750
9751 @DomName('HTMLInputElement.value')
9752 @DocsEditable()
9753 String get value => wrap_jso(JS("String", "#.value", this.raw));
9754 @DomName('HTMLInputElement.value')
9755 @DocsEditable()
9756 void set value(String val) => JS("void", "#.value = #", this.raw, unwrap_jso(v al));
9757
9758 @DomName('HTMLInputElement.valueAsDate')
9759 @DocsEditable()
9760 DateTime get valueAsDate => convertNativeToDart_DateTime(this._get_valueAsDate );
9761 @JSName('valueAsDate')
9762 @DomName('HTMLInputElement.valueAsDate')
9763 @DocsEditable()
9764 @Creates('Null')
9765 dynamic get _get_valueAsDate => wrap_jso(JS("dynamic", "#.valueAsDate", this.r aw));
9766
9767 set valueAsDate(DateTime value) {
9768 this._set_valueAsDate = convertDartToNative_DateTime(value);
9769 }
9770 set _set_valueAsDate(/*dynamic*/ value) {
9771 JS("void", "#.raw.valueAsDate = #", this, unwrap_jso(value));
9772 }
9773
9774 @DomName('HTMLInputElement.valueAsNumber')
9775 @DocsEditable()
9776 num get valueAsNumber => wrap_jso(JS("num", "#.valueAsNumber", this.raw));
9777 @DomName('HTMLInputElement.valueAsNumber')
9778 @DocsEditable()
9779 void set valueAsNumber(num val) => JS("void", "#.valueAsNumber = #", this.raw, unwrap_jso(val));
9780
9781 @JSName('webkitdirectory')
9782 @DomName('HTMLInputElement.webkitdirectory')
9783 @DocsEditable()
9784 @SupportedBrowser(SupportedBrowser.CHROME)
9785 @SupportedBrowser(SupportedBrowser.SAFARI)
9786 @Experimental()
9787 // https://plus.sandbox.google.com/+AddyOsmani/posts/Dk5UhZ6zfF3
9788 bool get directory => wrap_jso(JS("bool", "#.webkitdirectory", this.raw));
9789 @JSName('webkitdirectory')
9790 @DomName('HTMLInputElement.webkitdirectory')
9791 @DocsEditable()
9792 @SupportedBrowser(SupportedBrowser.CHROME)
9793 @SupportedBrowser(SupportedBrowser.SAFARI)
9794 @Experimental()
9795 // https://plus.sandbox.google.com/+AddyOsmani/posts/Dk5UhZ6zfF3
9796 void set directory(bool val) => JS("void", "#.webkitdirectory = #", this.raw, unwrap_jso(val));
9797
9798 @DomName('HTMLInputElement.width')
9799 @DocsEditable()
9800 int get width => wrap_jso(JS("int", "#.width", this.raw));
9801 @DomName('HTMLInputElement.width')
9802 @DocsEditable()
9803 void set width(int val) => JS("void", "#.width = #", this.raw, unwrap_jso(val) );
9804
9805 @DomName('HTMLInputElement.willValidate')
9806 @DocsEditable()
9807 bool get willValidate => wrap_jso(JS("bool", "#.willValidate", this.raw));
9808
9809 @DomName('HTMLInputElement.checkValidity')
9810 @DocsEditable()
9811 bool checkValidity() {
9812 return _checkValidity_1();
9813 }
9814 @JSName('checkValidity')
9815 @DomName('HTMLInputElement.checkValidity')
9816 @DocsEditable()
9817 bool _checkValidity_1() => wrap_jso(JS("bool ", "#.raw.checkValidity()", this) );
9818
9819 @DomName('HTMLInputElement.select')
9820 @DocsEditable()
9821 void select() {
9822 _select_1();
9823 return;
9824 }
9825 @JSName('select')
9826 @DomName('HTMLInputElement.select')
9827 @DocsEditable()
9828 void _select_1() => wrap_jso(JS("void ", "#.raw.select()", this));
9829
9830 @DomName('HTMLInputElement.setCustomValidity')
9831 @DocsEditable()
9832 void setCustomValidity(String error) {
9833 _setCustomValidity_1(error);
9834 return;
9835 }
9836 @JSName('setCustomValidity')
9837 @DomName('HTMLInputElement.setCustomValidity')
9838 @DocsEditable()
9839 void _setCustomValidity_1(error) => wrap_jso(JS("void ", "#.raw.setCustomValid ity(#)", this, unwrap_jso(error)));
9840
9841 @DomName('HTMLInputElement.setRangeText')
9842 @DocsEditable()
9843 // http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of- controls-and-forms.html#dom-textarea/input-setrangetext
9844 @Experimental() // experimental
9845 void setRangeText(String replacement, {int start, int end, String selectionMod e}) {
9846 if (start == null && end == null && selectionMode == null) {
9847 _setRangeText_1(replacement);
9848 return;
9849 }
9850 if (end != null && start != null && selectionMode == null) {
9851 _setRangeText_2(replacement, start, end);
9852 return;
9853 }
9854 if (selectionMode != null && end != null && start != null) {
9855 _setRangeText_3(replacement, start, end, selectionMode);
9856 return;
9857 }
9858 throw new ArgumentError("Incorrect number or type of arguments");
9859 }
9860 @JSName('setRangeText')
9861 @DomName('HTMLInputElement.setRangeText')
9862 @DocsEditable()
9863 // http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of- controls-and-forms.html#dom-textarea/input-setrangetext
9864 @Experimental() // experimental
9865 void _setRangeText_1(replacement) => wrap_jso(JS("void ", "#.raw.setRangeText( #)", this, unwrap_jso(replacement)));
9866 @JSName('setRangeText')
9867 @DomName('HTMLInputElement.setRangeText')
9868 @DocsEditable()
9869 // http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of- controls-and-forms.html#dom-textarea/input-setrangetext
9870 @Experimental() // experimental
9871 void _setRangeText_2(replacement, start, end) => wrap_jso(JS("void ", "#.raw.s etRangeText(#, #, #)", this, unwrap_jso(replacement), unwrap_jso(start), unwrap_ jso(end)));
9872 @JSName('setRangeText')
9873 @DomName('HTMLInputElement.setRangeText')
9874 @DocsEditable()
9875 // http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of- controls-and-forms.html#dom-textarea/input-setrangetext
9876 @Experimental() // experimental
9877 void _setRangeText_3(replacement, start, end, selectionMode) => wrap_jso(JS("v oid ", "#.raw.setRangeText(#, #, #, #)", this, unwrap_jso(replacement), unwrap_j so(start), unwrap_jso(end), unwrap_jso(selectionMode)));
9878
9879 @DomName('HTMLInputElement.setSelectionRange')
9880 @DocsEditable()
9881 void setSelectionRange(int start, int end, [String direction]) {
9882 if (direction != null) {
9883 _setSelectionRange_1(start, end, direction);
9884 return;
9885 }
9886 _setSelectionRange_2(start, end);
9887 return;
9888 }
9889 @JSName('setSelectionRange')
9890 @DomName('HTMLInputElement.setSelectionRange')
9891 @DocsEditable()
9892 void _setSelectionRange_1(start, end, direction) => wrap_jso(JS("void ", "#.ra w.setSelectionRange(#, #, #)", this, unwrap_jso(start), unwrap_jso(end), unwrap_ jso(direction)));
9893 @JSName('setSelectionRange')
9894 @DomName('HTMLInputElement.setSelectionRange')
9895 @DocsEditable()
9896 void _setSelectionRange_2(start, end) => wrap_jso(JS("void ", "#.raw.setSelect ionRange(#, #)", this, unwrap_jso(start), unwrap_jso(end)));
9897
9898 @DomName('HTMLInputElement.stepDown')
9899 @DocsEditable()
9900 void stepDown([int n]) {
9901 if (n != null) {
9902 _stepDown_1(n);
9903 return;
9904 }
9905 _stepDown_2();
9906 return;
9907 }
9908 @JSName('stepDown')
9909 @DomName('HTMLInputElement.stepDown')
9910 @DocsEditable()
9911 void _stepDown_1(n) => wrap_jso(JS("void ", "#.raw.stepDown(#)", this, unwrap_ jso(n)));
9912 @JSName('stepDown')
9913 @DomName('HTMLInputElement.stepDown')
9914 @DocsEditable()
9915 void _stepDown_2() => wrap_jso(JS("void ", "#.raw.stepDown()", this));
9916
9917 @DomName('HTMLInputElement.stepUp')
9918 @DocsEditable()
9919 void stepUp([int n]) {
9920 if (n != null) {
9921 _stepUp_1(n);
9922 return;
9923 }
9924 _stepUp_2();
9925 return;
9926 }
9927 @JSName('stepUp')
9928 @DomName('HTMLInputElement.stepUp')
9929 @DocsEditable()
9930 void _stepUp_1(n) => wrap_jso(JS("void ", "#.raw.stepUp(#)", this, unwrap_jso( n)));
9931 @JSName('stepUp')
9932 @DomName('HTMLInputElement.stepUp')
9933 @DocsEditable()
9934 void _stepUp_2() => wrap_jso(JS("void ", "#.raw.stepUp()", this));
9935
9936 }
9937
9938
9939 // Interfaces representing the InputElement APIs which are supported
9940 // for the various types of InputElement. From:
9941 // http://www.w3.org/html/wg/drafts/html/master/forms.html#the-input-element.
9942
9943 /**
9944 * Exposes the functionality common between all InputElement types.
9945 */
9946 abstract class InputElementBase implements Element {
9947 @DomName('HTMLInputElement.autofocus')
9948 bool autofocus;
9949
9950 @DomName('HTMLInputElement.disabled')
9951 bool disabled;
9952
9953 @DomName('HTMLInputElement.incremental')
9954 bool incremental;
9955
9956 @DomName('HTMLInputElement.indeterminate')
9957 bool indeterminate;
9958
9959 @DomName('HTMLInputElement.labels')
9960 List<Node> get labels;
9961
9962 @DomName('HTMLInputElement.name')
9963 String name;
9964
9965 @DomName('HTMLInputElement.validationMessage')
9966 String get validationMessage;
9967
9968
9969 @DomName('HTMLInputElement.value')
9970 String value;
9971
9972 @DomName('HTMLInputElement.willValidate')
9973 bool get willValidate;
9974
9975 @DomName('HTMLInputElement.checkValidity')
9976 bool checkValidity();
9977
9978 @DomName('HTMLInputElement.setCustomValidity')
9979 void setCustomValidity(String error);
9980 }
9981
9982 /**
9983 * Hidden input which is not intended to be seen or edited by the user.
9984 */
9985 abstract class HiddenInputElement implements InputElementBase {
9986 factory HiddenInputElement() => new InputElement(type: 'hidden');
9987 }
9988
9989
9990 /**
9991 * Base interface for all inputs which involve text editing.
9992 */
9993 abstract class TextInputElementBase implements InputElementBase {
9994 @DomName('HTMLInputElement.autocomplete')
9995 String autocomplete;
9996
9997 @DomName('HTMLInputElement.maxLength')
9998 int maxLength;
9999
10000 @DomName('HTMLInputElement.pattern')
10001 String pattern;
10002
10003 @DomName('HTMLInputElement.placeholder')
10004 String placeholder;
10005
10006 @DomName('HTMLInputElement.readOnly')
10007 bool readOnly;
10008
10009 @DomName('HTMLInputElement.required')
10010 bool required;
10011
10012 @DomName('HTMLInputElement.size')
10013 int size;
10014
10015 @DomName('HTMLInputElement.select')
10016 void select();
10017
10018 @DomName('HTMLInputElement.selectionDirection')
10019 String selectionDirection;
10020
10021 @DomName('HTMLInputElement.selectionEnd')
10022 int selectionEnd;
10023
10024 @DomName('HTMLInputElement.selectionStart')
10025 int selectionStart;
10026
10027 @DomName('HTMLInputElement.setSelectionRange')
10028 void setSelectionRange(int start, int end, [String direction]);
10029 }
10030
10031 /**
10032 * Similar to [TextInputElement], but on platforms where search is styled
10033 * differently this will get the search style.
10034 *
10035 * Use [supported] to check if this is supported on the current platform.
10036 */
10037 @SupportedBrowser(SupportedBrowser.CHROME)
10038 @SupportedBrowser(SupportedBrowser.FIREFOX)
10039 @SupportedBrowser(SupportedBrowser.IE, '10')
10040 @SupportedBrowser(SupportedBrowser.SAFARI)
10041 abstract class SearchInputElement implements TextInputElementBase {
10042 factory SearchInputElement() => new InputElement(type: 'search');
10043
10044 @DomName('HTMLInputElement.dirName')
10045 String dirName;
10046
10047 @DomName('HTMLInputElement.list')
10048 Element get list;
10049
10050 /// Returns true if this input type is supported on the current platform.
10051 static bool get supported {
10052 return (new InputElement(type: 'search')).type == 'search';
10053 }
10054 }
10055
10056 /**
10057 * A basic text input editor control.
10058 */
10059 abstract class TextInputElement implements TextInputElementBase {
10060 factory TextInputElement() => new InputElement(type: 'text');
10061
10062 @DomName('HTMLInputElement.dirName')
10063 String dirName;
10064
10065 @DomName('HTMLInputElement.list')
10066 Element get list;
10067 }
10068
10069 /**
10070 * A control for editing an absolute URL.
10071 *
10072 * Use [supported] to check if this is supported on the current platform.
10073 */
10074 @SupportedBrowser(SupportedBrowser.CHROME)
10075 @SupportedBrowser(SupportedBrowser.FIREFOX)
10076 @SupportedBrowser(SupportedBrowser.IE, '10')
10077 @SupportedBrowser(SupportedBrowser.SAFARI)
10078 abstract class UrlInputElement implements TextInputElementBase {
10079 factory UrlInputElement() => new InputElement(type: 'url');
10080
10081 @DomName('HTMLInputElement.list')
10082 Element get list;
10083
10084 /// Returns true if this input type is supported on the current platform.
10085 static bool get supported {
10086 return (new InputElement(type: 'url')).type == 'url';
10087 }
10088 }
10089
10090 /**
10091 * Represents a control for editing a telephone number.
10092 *
10093 * This provides a single line of text with minimal formatting help since
10094 * there is a wide variety of telephone numbers.
10095 *
10096 * Use [supported] to check if this is supported on the current platform.
10097 */
10098 @SupportedBrowser(SupportedBrowser.CHROME)
10099 @SupportedBrowser(SupportedBrowser.FIREFOX)
10100 @SupportedBrowser(SupportedBrowser.IE, '10')
10101 @SupportedBrowser(SupportedBrowser.SAFARI)
10102 abstract class TelephoneInputElement implements TextInputElementBase {
10103 factory TelephoneInputElement() => new InputElement(type: 'tel');
10104
10105 @DomName('HTMLInputElement.list')
10106 Element get list;
10107
10108 /// Returns true if this input type is supported on the current platform.
10109 static bool get supported {
10110 return (new InputElement(type: 'tel')).type == 'tel';
10111 }
10112 }
10113
10114 /**
10115 * An e-mail address or list of e-mail addresses.
10116 *
10117 * Use [supported] to check if this is supported on the current platform.
10118 */
10119 @SupportedBrowser(SupportedBrowser.CHROME)
10120 @SupportedBrowser(SupportedBrowser.FIREFOX)
10121 @SupportedBrowser(SupportedBrowser.IE, '10')
10122 @SupportedBrowser(SupportedBrowser.SAFARI)
10123 abstract class EmailInputElement implements TextInputElementBase {
10124 factory EmailInputElement() => new InputElement(type: 'email');
10125
10126 @DomName('HTMLInputElement.autocomplete')
10127 String autocomplete;
10128
10129 @DomName('HTMLInputElement.autofocus')
10130 bool autofocus;
10131
10132 @DomName('HTMLInputElement.list')
10133 Element get list;
10134
10135 @DomName('HTMLInputElement.maxLength')
10136 int maxLength;
10137
10138 @DomName('HTMLInputElement.multiple')
10139 bool multiple;
10140
10141 @DomName('HTMLInputElement.pattern')
10142 String pattern;
10143
10144 @DomName('HTMLInputElement.placeholder')
10145 String placeholder;
10146
10147 @DomName('HTMLInputElement.readOnly')
10148 bool readOnly;
10149
10150 @DomName('HTMLInputElement.required')
10151 bool required;
10152
10153 @DomName('HTMLInputElement.size')
10154 int size;
10155
10156 /// Returns true if this input type is supported on the current platform.
10157 static bool get supported {
10158 return (new InputElement(type: 'email')).type == 'email';
10159 }
10160 }
10161
10162 /**
10163 * Text with no line breaks (sensitive information).
10164 */
10165 abstract class PasswordInputElement implements TextInputElementBase {
10166 factory PasswordInputElement() => new InputElement(type: 'password');
10167 }
10168
10169 /**
10170 * Base interface for all input element types which involve ranges.
10171 */
10172 abstract class RangeInputElementBase implements InputElementBase {
10173
10174 @DomName('HTMLInputElement.list')
10175 Element get list;
10176
10177 @DomName('HTMLInputElement.max')
10178 String max;
10179
10180 @DomName('HTMLInputElement.min')
10181 String min;
10182
10183 @DomName('HTMLInputElement.step')
10184 String step;
10185
10186 @DomName('HTMLInputElement.valueAsNumber')
10187 num valueAsNumber;
10188
10189 @DomName('HTMLInputElement.stepDown')
10190 void stepDown([int n]);
10191
10192 @DomName('HTMLInputElement.stepUp')
10193 void stepUp([int n]);
10194 }
10195
10196 /**
10197 * A date (year, month, day) with no time zone.
10198 *
10199 * Use [supported] to check if this is supported on the current platform.
10200 */
10201 @SupportedBrowser(SupportedBrowser.CHROME, '25')
10202 @Experimental()
10203 abstract class DateInputElement implements RangeInputElementBase {
10204 factory DateInputElement() => new InputElement(type: 'date');
10205
10206 @DomName('HTMLInputElement.valueAsDate')
10207 DateTime valueAsDate;
10208
10209 @DomName('HTMLInputElement.readOnly')
10210 bool readOnly;
10211
10212 @DomName('HTMLInputElement.required')
10213 bool required;
10214
10215 /// Returns true if this input type is supported on the current platform.
10216 static bool get supported {
10217 return (new InputElement(type: 'date')).type == 'date';
10218 }
10219 }
10220
10221 /**
10222 * A date consisting of a year and a month with no time zone.
10223 *
10224 * Use [supported] to check if this is supported on the current platform.
10225 */
10226 @SupportedBrowser(SupportedBrowser.CHROME, '25')
10227 @Experimental()
10228 abstract class MonthInputElement implements RangeInputElementBase {
10229 factory MonthInputElement() => new InputElement(type: 'month');
10230
10231 @DomName('HTMLInputElement.valueAsDate')
10232 DateTime valueAsDate;
10233
10234 @DomName('HTMLInputElement.readOnly')
10235 bool readOnly;
10236
10237 @DomName('HTMLInputElement.required')
10238 bool required;
10239
10240 /// Returns true if this input type is supported on the current platform.
10241 static bool get supported {
10242 return (new InputElement(type: 'month')).type == 'month';
10243 }
10244 }
10245
10246 /**
10247 * A date consisting of a week-year number and a week number with no time zone.
10248 *
10249 * Use [supported] to check if this is supported on the current platform.
10250 */
10251 @SupportedBrowser(SupportedBrowser.CHROME, '25')
10252 @Experimental()
10253 abstract class WeekInputElement implements RangeInputElementBase {
10254 factory WeekInputElement() => new InputElement(type: 'week');
10255
10256 @DomName('HTMLInputElement.valueAsDate')
10257 DateTime valueAsDate;
10258
10259 @DomName('HTMLInputElement.readOnly')
10260 bool readOnly;
10261
10262 @DomName('HTMLInputElement.required')
10263 bool required;
10264
10265 /// Returns true if this input type is supported on the current platform.
10266 static bool get supported {
10267 return (new InputElement(type: 'week')).type == 'week';
10268 }
10269 }
10270
10271 /**
10272 * A time (hour, minute, seconds, fractional seconds) with no time zone.
10273 *
10274 * Use [supported] to check if this is supported on the current platform.
10275 */
10276 @SupportedBrowser(SupportedBrowser.CHROME)
10277 @Experimental()
10278 abstract class TimeInputElement implements RangeInputElementBase {
10279 factory TimeInputElement() => new InputElement(type: 'time');
10280
10281 @DomName('HTMLInputElement.valueAsDate')
10282 DateTime valueAsDate;
10283
10284 @DomName('HTMLInputElement.readOnly')
10285 bool readOnly;
10286
10287 @DomName('HTMLInputElement.required')
10288 bool required;
10289
10290 /// Returns true if this input type is supported on the current platform.
10291 static bool get supported {
10292 return (new InputElement(type: 'time')).type == 'time';
10293 }
10294 }
10295
10296 /**
10297 * A date and time (year, month, day, hour, minute, second, fraction of a
10298 * second) with no time zone.
10299 *
10300 * Use [supported] to check if this is supported on the current platform.
10301 */
10302 @SupportedBrowser(SupportedBrowser.CHROME, '25')
10303 @Experimental()
10304 abstract class LocalDateTimeInputElement implements RangeInputElementBase {
10305 factory LocalDateTimeInputElement() =>
10306 new InputElement(type: 'datetime-local');
10307
10308 @DomName('HTMLInputElement.readOnly')
10309 bool readOnly;
10310
10311 @DomName('HTMLInputElement.required')
10312 bool required;
10313
10314 /// Returns true if this input type is supported on the current platform.
10315 static bool get supported {
10316 return (new InputElement(type: 'datetime-local')).type == 'datetime-local';
10317 }
10318 }
10319
10320 /**
10321 * A numeric editor control.
10322 */
10323 @SupportedBrowser(SupportedBrowser.CHROME)
10324 @SupportedBrowser(SupportedBrowser.IE)
10325 @SupportedBrowser(SupportedBrowser.SAFARI)
10326 @Experimental()
10327 abstract class NumberInputElement implements RangeInputElementBase {
10328 factory NumberInputElement() => new InputElement(type: 'number');
10329
10330 @DomName('HTMLInputElement.placeholder')
10331 String placeholder;
10332
10333 @DomName('HTMLInputElement.readOnly')
10334 bool readOnly;
10335
10336 @DomName('HTMLInputElement.required')
10337 bool required;
10338
10339 /// Returns true if this input type is supported on the current platform.
10340 static bool get supported {
10341 return (new InputElement(type: 'number')).type == 'number';
10342 }
10343 }
10344
10345 /**
10346 * Similar to [NumberInputElement] but the browser may provide more optimal
10347 * styling (such as a slider control).
10348 *
10349 * Use [supported] to check if this is supported on the current platform.
10350 */
10351 @SupportedBrowser(SupportedBrowser.CHROME)
10352 @SupportedBrowser(SupportedBrowser.IE, '10')
10353 @Experimental()
10354 abstract class RangeInputElement implements RangeInputElementBase {
10355 factory RangeInputElement() => new InputElement(type: 'range');
10356
10357 /// Returns true if this input type is supported on the current platform.
10358 static bool get supported {
10359 return (new InputElement(type: 'range')).type == 'range';
10360 }
10361 }
10362
10363 /**
10364 * A boolean editor control.
10365 *
10366 * Note that if [indeterminate] is set then this control is in a third
10367 * indeterminate state.
10368 */
10369 abstract class CheckboxInputElement implements InputElementBase {
10370 factory CheckboxInputElement() => new InputElement(type: 'checkbox');
10371
10372 @DomName('HTMLInputElement.checked')
10373 bool checked;
10374
10375 @DomName('HTMLInputElement.required')
10376 bool required;
10377 }
10378
10379
10380 /**
10381 * A control that when used with other [ReadioButtonInputElement] controls
10382 * forms a radio button group in which only one control can be checked at a
10383 * time.
10384 *
10385 * Radio buttons are considered to be in the same radio button group if:
10386 *
10387 * * They are all of type 'radio'.
10388 * * They all have either the same [FormElement] owner, or no owner.
10389 * * Their name attributes contain the same name.
10390 */
10391 abstract class RadioButtonInputElement implements InputElementBase {
10392 factory RadioButtonInputElement() => new InputElement(type: 'radio');
10393
10394 @DomName('HTMLInputElement.checked')
10395 bool checked;
10396
10397 @DomName('HTMLInputElement.required')
10398 bool required;
10399 }
10400
10401 /**
10402 * A control for picking files from the user's computer.
10403 */
10404 abstract class FileUploadInputElement implements InputElementBase {
10405 factory FileUploadInputElement() => new InputElement(type: 'file');
10406
10407 @DomName('HTMLInputElement.accept')
10408 String accept;
10409
10410 @DomName('HTMLInputElement.multiple')
10411 bool multiple;
10412
10413 @DomName('HTMLInputElement.required')
10414 bool required;
10415
10416 }
10417
10418 /**
10419 * A button, which when clicked, submits the form.
10420 */
10421 abstract class SubmitButtonInputElement implements InputElementBase {
10422 factory SubmitButtonInputElement() => new InputElement(type: 'submit');
10423
10424 @DomName('HTMLInputElement.formAction')
10425 String formAction;
10426
10427 @DomName('HTMLInputElement.formEnctype')
10428 String formEnctype;
10429
10430 @DomName('HTMLInputElement.formMethod')
10431 String formMethod;
10432
10433 @DomName('HTMLInputElement.formNoValidate')
10434 bool formNoValidate;
10435
10436 @DomName('HTMLInputElement.formTarget')
10437 String formTarget;
10438 }
10439
10440 /**
10441 * Either an image which the user can select a coordinate to or a form
10442 * submit button.
10443 */
10444 abstract class ImageButtonInputElement implements InputElementBase {
10445 factory ImageButtonInputElement() => new InputElement(type: 'image');
10446
10447 @DomName('HTMLInputElement.alt')
10448 String alt;
10449
10450 @DomName('HTMLInputElement.formAction')
10451 String formAction;
10452
10453 @DomName('HTMLInputElement.formEnctype')
10454 String formEnctype;
10455
10456 @DomName('HTMLInputElement.formMethod')
10457 String formMethod;
10458
10459 @DomName('HTMLInputElement.formNoValidate')
10460 bool formNoValidate;
10461
10462 @DomName('HTMLInputElement.formTarget')
10463 String formTarget;
10464
10465 @DomName('HTMLInputElement.height')
10466 int height;
10467
10468 @DomName('HTMLInputElement.src')
10469 String src;
10470
10471 @DomName('HTMLInputElement.width')
10472 int width;
10473 }
10474
10475 /**
10476 * A button, which when clicked, resets the form.
10477 */
10478 abstract class ResetButtonInputElement implements InputElementBase {
10479 factory ResetButtonInputElement() => new InputElement(type: 'reset');
10480 }
10481
10482 /**
10483 * A button, with no default behavior.
10484 */
10485 abstract class ButtonInputElement implements InputElementBase {
10486 factory ButtonInputElement() => new InputElement(type: 'button');
10487 }
10488 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
10489 // for details. All rights reserved. Use of this source code is governed by a
10490 // BSD-style license that can be found in the LICENSE file.
10491
10492
10493 /**
10494 * An event that describes user interaction with the keyboard.
10495 *
10496 * The [type] of the event identifies what kind of interaction occurred.
10497 *
10498 * See also:
10499 *
10500 * * [KeyboardEvent](https://developer.mozilla.org/en/DOM/KeyboardEvent) at MDN.
10501 */
10502 @DomName('KeyboardEvent')
10503 @Native("KeyboardEvent")
10504 class KeyboardEvent extends UIEvent {
10505
10506 /**
10507 * Programmatically create a KeyboardEvent.
10508 *
10509 * Due to browser differences, keyCode, charCode, or keyIdentifier values
10510 * cannot be specified in this base level constructor. This constructor
10511 * enables the user to programmatically create and dispatch a [KeyboardEvent],
10512 * but it will not contain any particular key content. For programmatically
10513 * creating keyboard events with specific key value contents, see the custom
10514 * Event [KeyEvent].
10515 */
10516 factory KeyboardEvent(String type,
10517 {Window view, bool canBubble: true, bool cancelable: true,
10518 int keyLocation: 1, bool ctrlKey: false,
10519 bool altKey: false, bool shiftKey: false, bool metaKey: false}) {
10520 if (view == null) {
10521 view = window;
10522 }
10523 KeyboardEvent e = document._createEvent("KeyboardEvent");
10524 e._initKeyboardEvent(type, canBubble, cancelable, view, "",
10525 keyLocation, ctrlKey, altKey, shiftKey, metaKey);
10526 return e;
10527 }
10528
10529 @DomName('KeyboardEvent.initKeyboardEvent')
10530 void _initKeyboardEvent(String type, bool canBubble, bool cancelable,
10531 Window view, String keyIdentifier, int keyLocation, bool ctrlKey,
10532 bool altKey, bool shiftKey, bool metaKey) {
10533 if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this.raw)) {
10534 // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has
10535 // a slightly different signature, and allows you to specify keyCode and
10536 // charCode as the last two arguments, but we just set them as the default
10537 // since they can't be specified in other browsers.
10538 JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this.raw,
10539 type, canBubble, cancelable, unwrap_jso(view),
10540 ctrlKey, altKey, shiftKey, metaKey);
10541 } else {
10542 // initKeyboardEvent is for all other browsers.
10543 JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #)', this.raw,
10544 type, canBubble, cancelable, unwrap_jso(view), keyIdentifier, keyLocat ion,
10545 ctrlKey, altKey, shiftKey, metaKey);
10546 }
10547 }
10548
10549 @DomName('KeyboardEvent.keyCode')
10550 int get keyCode => _keyCode;
10551
10552 @DomName('KeyboardEvent.charCode')
10553 int get charCode => _charCode;
10554 // To suppress missing implicit constructor warnings.
10555 factory KeyboardEvent._() { throw new UnsupportedError("Not supported"); }
10556
10557
10558 @Deprecated("Internal Use Only")
10559 static KeyboardEvent internalCreateKeyboardEvent() {
10560 return new KeyboardEvent.internal_();
10561 }
10562
10563 @Deprecated("Internal Use Only")
10564 KeyboardEvent.internal_() : super.internal_();
10565
10566
10567 @DomName('KeyboardEvent.DOM_KEY_LOCATION_LEFT')
10568 @DocsEditable()
10569 @Experimental() // untriaged
10570 static const int DOM_KEY_LOCATION_LEFT = 0x01;
10571
10572 @DomName('KeyboardEvent.DOM_KEY_LOCATION_NUMPAD')
10573 @DocsEditable()
10574 @Experimental() // untriaged
10575 static const int DOM_KEY_LOCATION_NUMPAD = 0x03;
10576
10577 @DomName('KeyboardEvent.DOM_KEY_LOCATION_RIGHT')
10578 @DocsEditable()
10579 @Experimental() // untriaged
10580 static const int DOM_KEY_LOCATION_RIGHT = 0x02;
10581
10582 @DomName('KeyboardEvent.DOM_KEY_LOCATION_STANDARD')
10583 @DocsEditable()
10584 @Experimental() // untriaged
10585 static const int DOM_KEY_LOCATION_STANDARD = 0x00;
10586
10587 @DomName('KeyboardEvent.altKey')
10588 @DocsEditable()
10589 bool get altKey => wrap_jso(JS("bool", "#.altKey", this.raw));
10590
10591 @DomName('KeyboardEvent.ctrlKey')
10592 @DocsEditable()
10593 bool get ctrlKey => wrap_jso(JS("bool", "#.ctrlKey", this.raw));
10594
10595 @JSName('keyIdentifier')
10596 @DomName('KeyboardEvent.keyIdentifier')
10597 @DocsEditable()
10598 @Experimental() // nonstandard
10599 String get _keyIdentifier => wrap_jso(JS("String", "#.keyIdentifier", this.raw ));
10600
10601 @DomName('KeyboardEvent.keyLocation')
10602 @DocsEditable()
10603 @Experimental() // nonstandard
10604 int get keyLocation => wrap_jso(JS("int", "#.keyLocation", this.raw));
10605
10606 @DomName('KeyboardEvent.location')
10607 @DocsEditable()
10608 @Experimental() // untriaged
10609 int get location => wrap_jso(JS("int", "#.location", this.raw));
10610
10611 @DomName('KeyboardEvent.metaKey')
10612 @DocsEditable()
10613 bool get metaKey => wrap_jso(JS("bool", "#.metaKey", this.raw));
10614
10615 @DomName('KeyboardEvent.repeat')
10616 @DocsEditable()
10617 @Experimental() // untriaged
10618 bool get repeat => wrap_jso(JS("bool", "#.repeat", this.raw));
10619
10620 @DomName('KeyboardEvent.shiftKey')
10621 @DocsEditable()
10622 bool get shiftKey => wrap_jso(JS("bool", "#.shiftKey", this.raw));
10623
10624 @DomName('KeyboardEvent.getModifierState')
10625 @DocsEditable()
10626 @Experimental() // untriaged
10627 bool getModifierState(String keyArgument) {
10628 return _getModifierState_1(keyArgument);
10629 }
10630 @JSName('getModifierState')
10631 @DomName('KeyboardEvent.getModifierState')
10632 @DocsEditable()
10633 @Experimental() // untriaged
10634 bool _getModifierState_1(keyArgument) => wrap_jso(JS("bool ", "#.raw.getModifi erState(#)", this, unwrap_jso(keyArgument)));
10635
10636 }
10637 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
10638 // for details. All rights reserved. Use of this source code is governed by a
10639 // BSD-style license that can be found in the LICENSE file.
10640
10641
10642 @DocsEditable()
10643 @DomName('Location')
10644 @Native("Location")
10645 class Location extends DartHtmlDomObject implements LocationBase {
10646 // To suppress missing implicit constructor warnings.
10647 factory Location._() { throw new UnsupportedError("Not supported"); }
10648
10649 @Deprecated("Internal Use Only")
10650 static Location internalCreateLocation() {
10651 return new Location.internal_();
10652 }
10653
10654 @Deprecated("Internal Use Only")
10655 Location.internal_() { }
10656
10657 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
10658 int get hashCode => unwrap_jso(this).hashCode;
10659
10660 @DomName('Location.hash')
10661 @DocsEditable()
10662 String get hash => wrap_jso(JS("String", "#.hash", this.raw));
10663 @DomName('Location.hash')
10664 @DocsEditable()
10665 void set hash(String val) => JS("void", "#.hash = #", this.raw, unwrap_jso(val ));
10666
10667 @DomName('Location.host')
10668 @DocsEditable()
10669 String get host => wrap_jso(JS("String", "#.host", this.raw));
10670 @DomName('Location.host')
10671 @DocsEditable()
10672 void set host(String val) => JS("void", "#.host = #", this.raw, unwrap_jso(val ));
10673
10674 @DomName('Location.hostname')
10675 @DocsEditable()
10676 String get hostname => wrap_jso(JS("String", "#.hostname", this.raw));
10677 @DomName('Location.hostname')
10678 @DocsEditable()
10679 void set hostname(String val) => JS("void", "#.hostname = #", this.raw, unwrap _jso(val));
10680
10681 @DomName('Location.href')
10682 @DocsEditable()
10683 String get href => wrap_jso(JS("String", "#.href", this.raw));
10684 @DomName('Location.href')
10685 @DocsEditable()
10686 void set href(String val) => JS("void", "#.href = #", this.raw, unwrap_jso(val ));
10687
10688 @DomName('Location.pathname')
10689 @DocsEditable()
10690 String get pathname => wrap_jso(JS("String", "#.pathname", this.raw));
10691 @DomName('Location.pathname')
10692 @DocsEditable()
10693 void set pathname(String val) => JS("void", "#.pathname = #", this.raw, unwrap _jso(val));
10694
10695 @DomName('Location.port')
10696 @DocsEditable()
10697 String get port => wrap_jso(JS("String", "#.port", this.raw));
10698 @DomName('Location.port')
10699 @DocsEditable()
10700 void set port(String val) => JS("void", "#.port = #", this.raw, unwrap_jso(val ));
10701
10702 @DomName('Location.protocol')
10703 @DocsEditable()
10704 String get protocol => wrap_jso(JS("String", "#.protocol", this.raw));
10705 @DomName('Location.protocol')
10706 @DocsEditable()
10707 void set protocol(String val) => JS("void", "#.protocol = #", this.raw, unwrap _jso(val));
10708
10709 @DomName('Location.search')
10710 @DocsEditable()
10711 String get search => wrap_jso(JS("String", "#.search", this.raw));
10712 @DomName('Location.search')
10713 @DocsEditable()
10714 void set search(String val) => JS("void", "#.search = #", this.raw, unwrap_jso (val));
10715
10716 @DomName('Location.assign')
10717 @DocsEditable()
10718 void assign([String url]) {
10719 if (url != null) {
10720 _assign_1(url);
10721 return;
10722 }
10723 _assign_2();
10724 return;
10725 }
10726 @JSName('assign')
10727 @DomName('Location.assign')
10728 @DocsEditable()
10729 void _assign_1(url) => wrap_jso(JS("void ", "#.raw.assign(#)", this, unwrap_js o(url)));
10730 @JSName('assign')
10731 @DomName('Location.assign')
10732 @DocsEditable()
10733 void _assign_2() => wrap_jso(JS("void ", "#.raw.assign()", this));
10734
10735 @DomName('Location.reload')
10736 @DocsEditable()
10737 void reload() {
10738 _reload_1();
10739 return;
10740 }
10741 @JSName('reload')
10742 @DomName('Location.reload')
10743 @DocsEditable()
10744 void _reload_1() => wrap_jso(JS("void ", "#.raw.reload()", this));
10745
10746 @DomName('Location.replace')
10747 @DocsEditable()
10748 void replace(String url) {
10749 _replace_1(url);
10750 return;
10751 }
10752 @JSName('replace')
10753 @DomName('Location.replace')
10754 @DocsEditable()
10755 void _replace_1(url) => wrap_jso(JS("void ", "#.raw.replace(#)", this, unwrap_ jso(url)));
10756
10757
10758
10759 }
10760 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
10761 // for details. All rights reserved. Use of this source code is governed by a
10762 // BSD-style license that can be found in the LICENSE file.
10763
10764
10765 @DocsEditable()
10766 @DomName('MouseEvent')
10767 @Native("MouseEvent,DragEvent,PointerEvent,MSPointerEvent")
10768 class MouseEvent extends UIEvent {
10769 // To suppress missing implicit constructor warnings.
10770 factory MouseEvent._() { throw new UnsupportedError("Not supported"); }
10771
10772
10773 @Deprecated("Internal Use Only")
10774 static MouseEvent internalCreateMouseEvent() {
10775 return new MouseEvent.internal_();
10776 }
10777
10778 @Deprecated("Internal Use Only")
10779 MouseEvent.internal_() : super.internal_();
10780
10781
10782 @DomName('MouseEvent.altKey')
10783 @DocsEditable()
10784 bool get altKey => wrap_jso(JS("bool", "#.altKey", this.raw));
10785
10786 @DomName('MouseEvent.button')
10787 @DocsEditable()
10788 int get button => wrap_jso(JS("int", "#.button", this.raw));
10789
10790 @JSName('clientX')
10791 @DomName('MouseEvent.clientX')
10792 @DocsEditable()
10793 int get _clientX => wrap_jso(JS("int", "#.clientX", this.raw));
10794
10795 @JSName('clientY')
10796 @DomName('MouseEvent.clientY')
10797 @DocsEditable()
10798 int get _clientY => wrap_jso(JS("int", "#.clientY", this.raw));
10799
10800 @DomName('MouseEvent.ctrlKey')
10801 @DocsEditable()
10802 bool get ctrlKey => wrap_jso(JS("bool", "#.ctrlKey", this.raw));
10803
10804 /**
10805 * The nonstandard way to access the element that the mouse comes
10806 * from in the case of a `mouseover` event.
10807 *
10808 * This member is deprecated and not cross-browser compatible; use
10809 * relatedTarget to get the same information in the standard way.
10810 */
10811 @DomName('MouseEvent.fromElement')
10812 @DocsEditable()
10813 @deprecated
10814 Node get fromElement => wrap_jso(JS("Node", "#.fromElement", this.raw));
10815
10816 @DomName('MouseEvent.metaKey')
10817 @DocsEditable()
10818 bool get metaKey => wrap_jso(JS("bool", "#.metaKey", this.raw));
10819
10820 @JSName('movementX')
10821 @DomName('MouseEvent.movementX')
10822 @DocsEditable()
10823 @Experimental() // untriaged
10824 int get _movementX => wrap_jso(JS("int", "#.movementX", this.raw));
10825
10826 @JSName('movementY')
10827 @DomName('MouseEvent.movementY')
10828 @DocsEditable()
10829 @Experimental() // untriaged
10830 int get _movementY => wrap_jso(JS("int", "#.movementY", this.raw));
10831
10832 @DomName('MouseEvent.region')
10833 @DocsEditable()
10834 @Experimental() // untriaged
10835 String get region => wrap_jso(JS("String", "#.region", this.raw));
10836
10837 @DomName('MouseEvent.relatedTarget')
10838 @DocsEditable()
10839 EventTarget get relatedTarget => _convertNativeToDart_EventTarget(this._get_re latedTarget);
10840 @JSName('relatedTarget')
10841 @DomName('MouseEvent.relatedTarget')
10842 @DocsEditable()
10843 @Creates('Node')
10844 @Returns('EventTarget|=Object')
10845 dynamic get _get_relatedTarget => wrap_jso(JS("dynamic", "#.relatedTarget", th is.raw));
10846
10847 @JSName('screenX')
10848 @DomName('MouseEvent.screenX')
10849 @DocsEditable()
10850 int get _screenX => wrap_jso(JS("int", "#.screenX", this.raw));
10851
10852 @JSName('screenY')
10853 @DomName('MouseEvent.screenY')
10854 @DocsEditable()
10855 int get _screenY => wrap_jso(JS("int", "#.screenY", this.raw));
10856
10857 @DomName('MouseEvent.shiftKey')
10858 @DocsEditable()
10859 bool get shiftKey => wrap_jso(JS("bool", "#.shiftKey", this.raw));
10860
10861 /**
10862 * The nonstandard way to access the element that the mouse goes
10863 * to in the case of a `mouseout` event.
10864 *
10865 * This member is deprecated and not cross-browser compatible; use
10866 * relatedTarget to get the same information in the standard way.
10867 */
10868 @DomName('MouseEvent.toElement')
10869 @DocsEditable()
10870 @deprecated
10871 Node get toElement => wrap_jso(JS("Node", "#.toElement", this.raw));
10872
10873 @JSName('webkitMovementX')
10874 @DomName('MouseEvent.webkitMovementX')
10875 @DocsEditable()
10876 @SupportedBrowser(SupportedBrowser.CHROME)
10877 @SupportedBrowser(SupportedBrowser.SAFARI)
10878 @Experimental()
10879 int get _webkitMovementX => wrap_jso(JS("int", "#.webkitMovementX", this.raw)) ;
10880
10881 @JSName('webkitMovementY')
10882 @DomName('MouseEvent.webkitMovementY')
10883 @DocsEditable()
10884 @SupportedBrowser(SupportedBrowser.CHROME)
10885 @SupportedBrowser(SupportedBrowser.SAFARI)
10886 @Experimental()
10887 int get _webkitMovementY => wrap_jso(JS("int", "#.webkitMovementY", this.raw)) ;
10888
10889 @DomName('MouseEvent.initMouseEvent')
10890 @DocsEditable()
10891 void _initMouseEvent(String type, bool canBubble, bool cancelable, Window view , int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, int button, EventTarget relatedTarget) {
10892 var relatedTarget_1 = _convertDartToNative_EventTarget(relatedTarget);
10893 _initMouseEvent_1(type, canBubble, cancelable, view, detail, screenX, screen Y, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget_1 );
10894 return;
10895 }
10896 @JSName('initMouseEvent')
10897 @DomName('MouseEvent.initMouseEvent')
10898 @DocsEditable()
10899 void _initMouseEvent_1(type, canBubble, cancelable, Window view, detail, scree nX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relat edTarget) => wrap_jso(JS("void ", "#.raw.initMouseEvent(#, #, #, #, #, #, #, #, #, #, #, #, #, #, #)", this, unwrap_jso(type), unwrap_jso(canBubble), unwrap_jso (cancelable), unwrap_jso(view), unwrap_jso(detail), unwrap_jso(screenX), unwrap_ jso(screenY), unwrap_jso(clientX), unwrap_jso(clientY), unwrap_jso(ctrlKey), unw rap_jso(altKey), unwrap_jso(shiftKey), unwrap_jso(metaKey), unwrap_jso(button), unwrap_jso(relatedTarget)));
10900 }
10901 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
10902 // for details. All rights reserved. Use of this source code is governed by a
10903 // BSD-style license that can be found in the LICENSE file.
10904
10905
10906 @DomName('Navigator')
10907 @Native("Navigator")
10908 class Navigator extends DartHtmlDomObject implements NavigatorCpu {
10909
10910
10911
10912
10913 // To suppress missing implicit constructor warnings.
10914 factory Navigator._() { throw new UnsupportedError("Not supported"); }
10915
10916 @Deprecated("Internal Use Only")
10917 static Navigator internalCreateNavigator() {
10918 return new Navigator.internal_();
10919 }
10920
10921 @Deprecated("Internal Use Only")
10922 Navigator.internal_() { }
10923
10924 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
10925 int get hashCode => unwrap_jso(this).hashCode;
10926
10927 @DomName('Navigator.cookieEnabled')
10928 @DocsEditable()
10929 @Unstable()
10930 bool get cookieEnabled => wrap_jso(JS("bool", "#.cookieEnabled", this.raw));
10931
10932 @DomName('Navigator.doNotTrack')
10933 @DocsEditable()
10934 // http://www.w3.org/2011/tracking-protection/drafts/tracking-dnt.html#js-dom
10935 @Experimental() // experimental
10936 String get doNotTrack => wrap_jso(JS("String", "#.doNotTrack", this.raw));
10937
10938 @DomName('Navigator.maxTouchPoints')
10939 @DocsEditable()
10940 @Experimental() // untriaged
10941 int get maxTouchPoints => wrap_jso(JS("int", "#.maxTouchPoints", this.raw));
10942
10943 @DomName('Navigator.productSub')
10944 @DocsEditable()
10945 @Unstable()
10946 String get productSub => wrap_jso(JS("String", "#.productSub", this.raw));
10947
10948 @DomName('Navigator.vendor')
10949 @DocsEditable()
10950 @Unstable()
10951 String get vendor => wrap_jso(JS("String", "#.vendor", this.raw));
10952
10953 @DomName('Navigator.vendorSub')
10954 @DocsEditable()
10955 @Unstable()
10956 String get vendorSub => wrap_jso(JS("String", "#.vendorSub", this.raw));
10957
10958 @DomName('Navigator.getBattery')
10959 @DocsEditable()
10960 @Experimental() // untriaged
10961 Future getBattery() {
10962 return _getBattery_1();
10963 }
10964 @JSName('getBattery')
10965 @DomName('Navigator.getBattery')
10966 @DocsEditable()
10967 @Experimental() // untriaged
10968 Future _getBattery_1() => wrap_jso(JS("Future ", "#.raw.getBattery()", this));
10969
10970 @DomName('Navigator.getStorageUpdates')
10971 @DocsEditable()
10972 // http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#nav igatorstorageutils
10973 @Experimental()
10974 void getStorageUpdates() {
10975 _getStorageUpdates_1();
10976 return;
10977 }
10978 @JSName('getStorageUpdates')
10979 @DomName('Navigator.getStorageUpdates')
10980 @DocsEditable()
10981 // http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#nav igatorstorageutils
10982 @Experimental()
10983 void _getStorageUpdates_1() => wrap_jso(JS("void ", "#.raw.getStorageUpdates() ", this));
10984
10985 @DomName('Navigator.registerProtocolHandler')
10986 @DocsEditable()
10987 @Unstable()
10988 void registerProtocolHandler(String scheme, String url, String title) {
10989 _registerProtocolHandler_1(scheme, url, title);
10990 return;
10991 }
10992 @JSName('registerProtocolHandler')
10993 @DomName('Navigator.registerProtocolHandler')
10994 @DocsEditable()
10995 @Unstable()
10996 void _registerProtocolHandler_1(scheme, url, title) => wrap_jso(JS("void ", "# .raw.registerProtocolHandler(#, #, #)", this, unwrap_jso(scheme), unwrap_jso(url ), unwrap_jso(title)));
10997
10998 @DomName('Navigator.sendBeacon')
10999 @DocsEditable()
11000 @Experimental() // untriaged
11001 bool sendBeacon(String url, String data) {
11002 return _sendBeacon_1(url, data);
11003 }
11004 @JSName('sendBeacon')
11005 @DomName('Navigator.sendBeacon')
11006 @DocsEditable()
11007 @Experimental() // untriaged
11008 bool _sendBeacon_1(url, data) => wrap_jso(JS("bool ", "#.raw.sendBeacon(#, #)" , this, unwrap_jso(url), unwrap_jso(data)));
11009
11010 // From NavigatorCPU
11011
11012 @DomName('Navigator.hardwareConcurrency')
11013 @DocsEditable()
11014 @Experimental() // untriaged
11015 int get hardwareConcurrency => wrap_jso(JS("int", "#.hardwareConcurrency", thi s.raw));
11016
11017 }
11018 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
11019 // for details. All rights reserved. Use of this source code is governed by a
11020 // BSD-style license that can be found in the LICENSE file.
11021
11022
11023 @DocsEditable()
11024 @DomName('NavigatorCPU')
11025 @Experimental() // untriaged
11026 abstract class NavigatorCpu extends DartHtmlDomObject {
11027 // To suppress missing implicit constructor warnings.
11028 factory NavigatorCpu._() { throw new UnsupportedError("Not supported"); }
11029
11030 int get hardwareConcurrency => wrap_jso(JS("int", "#.hardwareConcurrency", thi s.raw));
11031 }
11032 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
11033 // for details. All rights reserved. Use of this source code is governed by a
11034 // BSD-style license that can be found in the LICENSE file.
11035
11036
11037 /**
11038 * Lazy implementation of the child nodes of an element that does not request
11039 * the actual child nodes of an element until strictly necessary greatly
11040 * improving performance for the typical cases where it is not required.
11041 */
11042 class _ChildNodeListLazy extends ListBase<Node> implements NodeListWrapper {
11043 final Node _this;
11044
11045 _ChildNodeListLazy(this._this);
11046
11047
11048 Node get first {
11049 Node result = _this.firstChild;
11050 if (result == null) throw new StateError("No elements");
11051 return result;
11052 }
11053 Node get last {
11054 Node result = _this.lastChild;
11055 if (result == null) throw new StateError("No elements");
11056 return result;
11057 }
11058 Node get single {
11059 int l = this.length;
11060 if (l == 0) throw new StateError("No elements");
11061 if (l > 1) throw new StateError("More than one element");
11062 return _this.firstChild;
11063 }
11064
11065 void add(Node value) {
11066 _this.append(value);
11067 }
11068
11069 void addAll(Iterable<Node> iterable) {
11070 if (iterable is _ChildNodeListLazy) {
11071 _ChildNodeListLazy otherList = iterable;
11072 if (!identical(otherList._this, _this)) {
11073 // Optimized route for copying between nodes.
11074 for (var i = 0, len = otherList.length; i < len; ++i) {
11075 _this.append(otherList._this.firstChild);
11076 }
11077 }
11078 return;
11079 }
11080 for (Node node in iterable) {
11081 _this.append(node);
11082 }
11083 }
11084
11085 void insert(int index, Node node) {
11086 if (index < 0 || index > length) {
11087 throw new RangeError.range(index, 0, length);
11088 }
11089 if (index == length) {
11090 _this.append(node);
11091 } else {
11092 _this.insertBefore(node, this[index]);
11093 }
11094 }
11095
11096 void insertAll(int index, Iterable<Node> iterable) {
11097 if (index == length) {
11098 addAll(iterable);
11099 } else {
11100 var item = this[index];
11101 _this.insertAllBefore(iterable, item);
11102 }
11103 }
11104
11105 void setAll(int index, Iterable<Node> iterable) {
11106 throw new UnsupportedError("Cannot setAll on Node list");
11107 }
11108
11109 Node removeLast() {
11110 final result = last;
11111 if (result != null) {
11112 _this._removeChild(result);
11113 }
11114 return result;
11115 }
11116
11117 Node removeAt(int index) {
11118 var result = this[index];
11119 if (result != null) {
11120 _this._removeChild(result);
11121 }
11122 return result;
11123 }
11124
11125 bool remove(Object object) {
11126 if (object is! Node) return false;
11127 Node node = object;
11128 // We aren't preserving identity of nodes in JSINTEROP mode
11129 if (_this != node.parentNode) return false;
11130 _this._removeChild(node);
11131 return true;
11132 }
11133
11134 void _filter(bool test(Node node), bool removeMatching) {
11135 // This implementation of removeWhere/retainWhere is more efficient
11136 // than the default in ListBase. Child nodes can be removed in constant
11137 // time.
11138 Node child = _this.firstChild;
11139 while (child != null) {
11140 Node nextChild = child.nextNode;
11141 if (test(child) == removeMatching) {
11142 _this._removeChild(child);
11143 }
11144 child = nextChild;
11145 }
11146 }
11147
11148 void removeWhere(bool test(Node node)) {
11149 _filter(test, true);
11150 }
11151
11152 void retainWhere(bool test(Node node)) {
11153 _filter(test, false);
11154 }
11155
11156 void clear() {
11157 _this._clearChildren();
11158 }
11159
11160 void operator []=(int index, Node value) {
11161 _this._replaceChild(value, this[index]);
11162 }
11163
11164 Iterator<Node> get iterator => _this.childNodes.iterator;
11165
11166 // From List<Node>:
11167
11168 // TODO(jacobr): this could be implemented for child node lists.
11169 // The exception we throw here is misleading.
11170 void sort([Comparator<Node> compare]) {
11171 throw new UnsupportedError("Cannot sort Node list");
11172 }
11173
11174 void shuffle([Random random]) {
11175 throw new UnsupportedError("Cannot shuffle Node list");
11176 }
11177
11178 // FIXME: implement these.
11179 void setRange(int start, int end, Iterable<Node> iterable,
11180 [int skipCount = 0]) {
11181 throw new UnsupportedError("Cannot setRange on Node list");
11182 }
11183
11184 void fillRange(int start, int end, [Node fill]) {
11185 throw new UnsupportedError("Cannot fillRange on Node list");
11186 }
11187 // -- end List<Node> mixins.
11188
11189 // TODO(jacobr): benchmark whether this is more efficient or whether caching
11190 // a local copy of childNodes is more efficient.
11191 int get length => _this.childNodes.length;
11192
11193 set length(int value) {
11194 throw new UnsupportedError(
11195 "Cannot set length on immutable List.");
11196 }
11197
11198 Node operator[](int index) => _this.childNodes[index];
11199
11200 List<Node> get rawList => _this.childNodes;
11201 }
11202
11203
11204 @DomName('Node')
11205 @Native("Node")
11206 class Node extends EventTarget {
11207
11208 // Custom element created callback.
11209 Node._created() : super._created();
11210
11211 /**
11212 * A modifiable list of this node's children.
11213 */
11214 List<Node> get nodes {
11215 return new _ChildNodeListLazy(this);
11216 }
11217
11218 set nodes(Iterable<Node> value) {
11219 // Copy list first since we don't want liveness during iteration.
11220 // TODO(jacobr): there is a better way to do this.
11221 List copy = new List.from(value);
11222 text = '';
11223 for (Node node in copy) {
11224 append(node);
11225 }
11226 }
11227
11228 /**
11229 * Removes this node from the DOM.
11230 */
11231 @DomName('Node.removeChild')
11232 void remove() {
11233 // TODO(jacobr): should we throw an exception if parent is already null?
11234 // TODO(vsm): Use the native remove when available.
11235 if (this.parentNode != null) {
11236 final Node parent = this.parentNode;
11237 parentNode._removeChild(this);
11238 }
11239 }
11240
11241 /**
11242 * Replaces this node with another node.
11243 */
11244 @DomName('Node.replaceChild')
11245 Node replaceWith(Node otherNode) {
11246 try {
11247 final Node parent = this.parentNode;
11248 parent._replaceChild(otherNode, this);
11249 } catch (e) {
11250
11251 };
11252 return this;
11253 }
11254
11255 /**
11256 * Inserts all of the nodes into this node directly before refChild.
11257 *
11258 * See also:
11259 *
11260 * * [insertBefore]
11261 */
11262 Node insertAllBefore(Iterable<Node> newNodes, Node refChild) {
11263 if (newNodes is _ChildNodeListLazy) {
11264 _ChildNodeListLazy otherList = newNodes;
11265 if (identical(otherList._this, this)) {
11266 throw new ArgumentError(newNodes);
11267 }
11268
11269 // Optimized route for copying between nodes.
11270 for (var i = 0, len = otherList.length; i < len; ++i) {
11271 this.insertBefore(otherList._this.firstChild, refChild);
11272 }
11273 } else {
11274 for (var node in newNodes) {
11275 this.insertBefore(node, refChild);
11276 }
11277 }
11278 }
11279
11280 void _clearChildren() {
11281 while (firstChild != null) {
11282 _removeChild(firstChild);
11283 }
11284 }
11285
11286 /**
11287 * Print out a String representation of this Node.
11288 */
11289 String toString() {
11290 String value = nodeValue; // Fetch DOM Node property once.
11291 return value == null ? super.toString() : value;
11292 }
11293
11294 /**
11295 * A list of this node's children.
11296 *
11297 * ## Other resources
11298 *
11299 * * [Node.childNodes]
11300 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.childNodes)
11301 * from MDN.
11302 */
11303 @DomName('Node.childNodes')
11304 @DocsEditable()
11305 List<Node> get childNodes => wrap_jso(JS('List', '#.childNodes', this.raw));
11306 // To suppress missing implicit constructor warnings.
11307 factory Node._() { throw new UnsupportedError("Not supported"); }
11308
11309
11310 @Deprecated("Internal Use Only")
11311 static Node internalCreateNode() {
11312 return new Node.internal_();
11313 }
11314
11315 @Deprecated("Internal Use Only")
11316 Node.internal_() : super.internal_();
11317
11318
11319 @DomName('Node.ATTRIBUTE_NODE')
11320 @DocsEditable()
11321 static const int ATTRIBUTE_NODE = 2;
11322
11323 @DomName('Node.CDATA_SECTION_NODE')
11324 @DocsEditable()
11325 static const int CDATA_SECTION_NODE = 4;
11326
11327 @DomName('Node.COMMENT_NODE')
11328 @DocsEditable()
11329 static const int COMMENT_NODE = 8;
11330
11331 @DomName('Node.DOCUMENT_FRAGMENT_NODE')
11332 @DocsEditable()
11333 static const int DOCUMENT_FRAGMENT_NODE = 11;
11334
11335 @DomName('Node.DOCUMENT_NODE')
11336 @DocsEditable()
11337 static const int DOCUMENT_NODE = 9;
11338
11339 @DomName('Node.DOCUMENT_TYPE_NODE')
11340 @DocsEditable()
11341 static const int DOCUMENT_TYPE_NODE = 10;
11342
11343 @DomName('Node.ELEMENT_NODE')
11344 @DocsEditable()
11345 static const int ELEMENT_NODE = 1;
11346
11347 @DomName('Node.ENTITY_NODE')
11348 @DocsEditable()
11349 static const int ENTITY_NODE = 6;
11350
11351 @DomName('Node.ENTITY_REFERENCE_NODE')
11352 @DocsEditable()
11353 static const int ENTITY_REFERENCE_NODE = 5;
11354
11355 @DomName('Node.NOTATION_NODE')
11356 @DocsEditable()
11357 static const int NOTATION_NODE = 12;
11358
11359 @DomName('Node.PROCESSING_INSTRUCTION_NODE')
11360 @DocsEditable()
11361 static const int PROCESSING_INSTRUCTION_NODE = 7;
11362
11363 @DomName('Node.TEXT_NODE')
11364 @DocsEditable()
11365 static const int TEXT_NODE = 3;
11366
11367 @JSName('baseURI')
11368 @DomName('Node.baseURI')
11369 @DocsEditable()
11370 String get baseUri => wrap_jso(JS("String", "#.baseURI", this.raw));
11371
11372 /**
11373 * The first child of this node.
11374 *
11375 * ## Other resources
11376 *
11377 * * [Node.firstChild]
11378 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.firstChild)
11379 * from MDN.
11380 */
11381 @DomName('Node.firstChild')
11382 @DocsEditable()
11383 Node get firstChild => wrap_jso(JS("Node", "#.firstChild", this.raw));
11384
11385 /**
11386 * The last child of this node.
11387 *
11388 * ## Other resources
11389 *
11390 * * [Node.lastChild]
11391 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.lastChild)
11392 * from MDN.
11393 */
11394 @DomName('Node.lastChild')
11395 @DocsEditable()
11396 Node get lastChild => wrap_jso(JS("Node", "#.lastChild", this.raw));
11397
11398 @JSName('localName')
11399 @DomName('Node.localName')
11400 @DocsEditable()
11401 String get _localName => wrap_jso(JS("String", "#.localName", this.raw));
11402
11403 @JSName('namespaceURI')
11404 @DomName('Node.namespaceURI')
11405 @DocsEditable()
11406 String get _namespaceUri => wrap_jso(JS("String", "#.namespaceURI", this.raw)) ;
11407
11408 @JSName('nextSibling')
11409 /**
11410 * The next sibling node.
11411 *
11412 * ## Other resources
11413 *
11414 * * [Node.nextSibling]
11415 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.nextSibling)
11416 * from MDN.
11417 */
11418 @DomName('Node.nextSibling')
11419 @DocsEditable()
11420 Node get nextNode => wrap_jso(JS("Node", "#.nextSibling", this.raw));
11421
11422 /**
11423 * The name of this node.
11424 *
11425 * This varies by this node's [nodeType].
11426 *
11427 * ## Other resources
11428 *
11429 * * [Node.nodeName]
11430 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.nodeName)
11431 * from MDN. This page contains a table of [nodeName] values for each
11432 * [nodeType].
11433 */
11434 @DomName('Node.nodeName')
11435 @DocsEditable()
11436 String get nodeName => wrap_jso(JS("String", "#.nodeName", this.raw));
11437
11438 /**
11439 * The type of node.
11440 *
11441 * This value is one of:
11442 *
11443 * * [ATTRIBUTE_NODE] if this node is an attribute.
11444 * * [CDATA_SECTION_NODE] if this node is a [CDataSection].
11445 * * [COMMENT_NODE] if this node is a [Comment].
11446 * * [DOCUMENT_FRAGMENT_NODE] if this node is a [DocumentFragment].
11447 * * [DOCUMENT_NODE] if this node is a [Document].
11448 * * [DOCUMENT_TYPE_NODE] if this node is a [DocumentType] node.
11449 * * [ELEMENT_NODE] if this node is an [Element].
11450 * * [ENTITY_NODE] if this node is an entity.
11451 * * [ENTITY_REFERENCE_NODE] if this node is an entity reference.
11452 * * [NOTATION_NODE] if this node is a notation.
11453 * * [PROCESSING_INSTRUCTION_NODE] if this node is a [ProcessingInstruction].
11454 * * [TEXT_NODE] if this node is a [Text] node.
11455 *
11456 * ## Other resources
11457 *
11458 * * [Node.nodeType]
11459 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.nodeType) from MDN.
11460 */
11461 @DomName('Node.nodeType')
11462 @DocsEditable()
11463 int get nodeType => wrap_jso(JS("int", "#.nodeType", this.raw));
11464
11465 /**
11466 * The value of this node.
11467 *
11468 * This varies by this type's [nodeType].
11469 *
11470 * ## Other resources
11471 *
11472 * * [Node.nodeValue]
11473 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.nodeValue)
11474 * from MDN. This page contains a table of [nodeValue] values for each
11475 * [nodeType].
11476 */
11477 @DomName('Node.nodeValue')
11478 @DocsEditable()
11479 String get nodeValue => wrap_jso(JS("String", "#.nodeValue", this.raw));
11480
11481 /**
11482 * The document this node belongs to.
11483 *
11484 * Returns null if this node does not belong to any document.
11485 *
11486 * ## Other resources
11487 *
11488 * * [Node.ownerDocument]
11489 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.ownerDocument) from
11490 * MDN.
11491 */
11492 @DomName('Node.ownerDocument')
11493 @DocsEditable()
11494 Document get ownerDocument => wrap_jso(JS("Document", "#.ownerDocument", this. raw));
11495
11496 @JSName('parentElement')
11497 /**
11498 * The parent element of this node.
11499 *
11500 * Returns null if this node either does not have a parent or its parent is
11501 * not an element.
11502 *
11503 * ## Other resources
11504 *
11505 * * [Node.parentElement]
11506 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.parentElement) from
11507 * W3C.
11508 */
11509 @DomName('Node.parentElement')
11510 @DocsEditable()
11511 Element get parent => wrap_jso(JS("Element", "#.parentElement", this.raw));
11512
11513 /**
11514 * The parent node of this node.
11515 *
11516 * ## Other resources
11517 *
11518 * * [Node.parentNode]
11519 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.parentNode) from
11520 * MDN.
11521 */
11522 @DomName('Node.parentNode')
11523 @DocsEditable()
11524 Node get parentNode => wrap_jso(JS("Node", "#.parentNode", this.raw));
11525
11526 @JSName('previousSibling')
11527 /**
11528 * The previous sibling node.
11529 *
11530 * ## Other resources
11531 *
11532 * * [Node.previousSibling]
11533 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.previousSibling)
11534 * from MDN.
11535 */
11536 @DomName('Node.previousSibling')
11537 @DocsEditable()
11538 Node get previousNode => wrap_jso(JS("Node", "#.previousSibling", this.raw));
11539
11540 @JSName('textContent')
11541 /**
11542 * All text within this node and its decendents.
11543 *
11544 * ## Other resources
11545 *
11546 * * [Node.textContent]
11547 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.textContent) from
11548 * MDN.
11549 */
11550 @DomName('Node.textContent')
11551 @DocsEditable()
11552 String get text => wrap_jso(JS("String", "#.textContent", this.raw));
11553 @JSName('textContent')
11554 /**
11555 * All text within this node and its decendents.
11556 *
11557 * ## Other resources
11558 *
11559 * * [Node.textContent]
11560 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.textContent) from
11561 * MDN.
11562 */
11563 @DomName('Node.textContent')
11564 @DocsEditable()
11565 void set text(String val) => JS("void", "#.textContent = #", this.raw, unwrap_ jso(val));
11566
11567 /**
11568 * Adds a node to the end of the child [nodes] list of this node.
11569 *
11570 * If the node already exists in this document, it will be removed from its
11571 * current parent node, then added to this node.
11572 *
11573 * This method is more efficient than `nodes.add`, and is the preferred
11574 * way of appending a child node.
11575 */
11576 @DomName('Node.appendChild')
11577 @DocsEditable()
11578 Node append(Node newChild) {
11579 return _append_1(newChild);
11580 }
11581 @JSName('appendChild')
11582 /**
11583 * Adds a node to the end of the child [nodes] list of this node.
11584 *
11585 * If the node already exists in this document, it will be removed from its
11586 * current parent node, then added to this node.
11587 *
11588 * This method is more efficient than `nodes.add`, and is the preferred
11589 * way of appending a child node.
11590 */
11591 @DomName('Node.appendChild')
11592 @DocsEditable()
11593 Node _append_1(Node newChild) => wrap_jso(JS("Node ", "#.raw.appendChild(#)", this, unwrap_jso(newChild)));
11594
11595 /**
11596 * Returns a copy of this node.
11597 *
11598 * If [deep] is `true`, then all of this node's children and decendents are
11599 * copied as well. If [deep] is `false`, then only this node is copied.
11600 *
11601 * ## Other resources
11602 *
11603 * * [Node.cloneNode]
11604 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.cloneNode) from
11605 * MDN.
11606 */
11607 @DomName('Node.cloneNode')
11608 @DocsEditable()
11609 Node clone(bool deep) {
11610 return _clone_1(deep);
11611 }
11612 @JSName('cloneNode')
11613 /**
11614 * Returns a copy of this node.
11615 *
11616 * If [deep] is `true`, then all of this node's children and decendents are
11617 * copied as well. If [deep] is `false`, then only this node is copied.
11618 *
11619 * ## Other resources
11620 *
11621 * * [Node.cloneNode]
11622 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.cloneNode) from
11623 * MDN.
11624 */
11625 @DomName('Node.cloneNode')
11626 @DocsEditable()
11627 Node _clone_1(deep) => wrap_jso(JS("Node ", "#.raw.cloneNode(#)", this, unwrap _jso(deep)));
11628
11629 /**
11630 * Returns true if this node contains the specified node.
11631 *
11632 * ## Other resources
11633 *
11634 * * [Node.contains]
11635 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.contains) from MDN.
11636 */
11637 @DomName('Node.contains')
11638 @DocsEditable()
11639 bool contains(Node other) {
11640 return _contains_1(other);
11641 }
11642 @JSName('contains')
11643 /**
11644 * Returns true if this node contains the specified node.
11645 *
11646 * ## Other resources
11647 *
11648 * * [Node.contains]
11649 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.contains) from MDN.
11650 */
11651 @DomName('Node.contains')
11652 @DocsEditable()
11653 bool _contains_1(Node other) => wrap_jso(JS("bool ", "#.raw.contains(#)", this , unwrap_jso(other)));
11654
11655 /**
11656 * Returns true if this node has any children.
11657 *
11658 * ## Other resources
11659 *
11660 * * [Node.hasChildNodes]
11661 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.hasChildNodes) from
11662 * MDN.
11663 */
11664 @DomName('Node.hasChildNodes')
11665 @DocsEditable()
11666 bool hasChildNodes() {
11667 return _hasChildNodes_1();
11668 }
11669 @JSName('hasChildNodes')
11670 /**
11671 * Returns true if this node has any children.
11672 *
11673 * ## Other resources
11674 *
11675 * * [Node.hasChildNodes]
11676 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.hasChildNodes) from
11677 * MDN.
11678 */
11679 @DomName('Node.hasChildNodes')
11680 @DocsEditable()
11681 bool _hasChildNodes_1() => wrap_jso(JS("bool ", "#.raw.hasChildNodes()", this) );
11682
11683 /**
11684 * Inserts all of the nodes into this node directly before refChild.
11685 *
11686 * ## Other resources
11687 *
11688 * * [Node.insertBefore]
11689 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.insertBefore) from
11690 * MDN.
11691 */
11692 @DomName('Node.insertBefore')
11693 @DocsEditable()
11694 Node insertBefore(Node newChild, Node refChild) {
11695 return _insertBefore_1(newChild, refChild);
11696 }
11697 @JSName('insertBefore')
11698 /**
11699 * Inserts all of the nodes into this node directly before refChild.
11700 *
11701 * ## Other resources
11702 *
11703 * * [Node.insertBefore]
11704 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.insertBefore) from
11705 * MDN.
11706 */
11707 @DomName('Node.insertBefore')
11708 @DocsEditable()
11709 Node _insertBefore_1(Node newChild, Node refChild) => wrap_jso(JS("Node ", "#. raw.insertBefore(#, #)", this, unwrap_jso(newChild), unwrap_jso(refChild)));
11710
11711 @DomName('Node.removeChild')
11712 @DocsEditable()
11713 Node _removeChild(Node oldChild) {
11714 return _removeChild_1(oldChild);
11715 }
11716 @JSName('removeChild')
11717 @DomName('Node.removeChild')
11718 @DocsEditable()
11719 Node _removeChild_1(Node oldChild) => wrap_jso(JS("Node ", "#.raw.removeChild( #)", this, unwrap_jso(oldChild)));
11720
11721 @DomName('Node.replaceChild')
11722 @DocsEditable()
11723 Node _replaceChild(Node newChild, Node oldChild) {
11724 return _replaceChild_1(newChild, oldChild);
11725 }
11726 @JSName('replaceChild')
11727 @DomName('Node.replaceChild')
11728 @DocsEditable()
11729 Node _replaceChild_1(Node newChild, Node oldChild) => wrap_jso(JS("Node ", "#. raw.replaceChild(#, #)", this, unwrap_jso(newChild), unwrap_jso(oldChild)));
11730
11731 }
11732 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
11733 // for details. All rights reserved. Use of this source code is governed by a
11734 // BSD-style license that can be found in the LICENSE file.
11735
11736
11737 @DocsEditable()
11738 @DomName('NodeList')
11739 @Native("NodeList,RadioNodeList")
11740 class NodeList extends DartHtmlDomObject with ListMixin<Node>, ImmutableListMixi n<Node> implements JavaScriptIndexingBehavior, List<Node> {
11741 // To suppress missing implicit constructor warnings.
11742 factory NodeList._() { throw new UnsupportedError("Not supported"); }
11743
11744 @Deprecated("Internal Use Only")
11745 static NodeList internalCreateNodeList() {
11746 return new NodeList.internal_();
11747 }
11748
11749 @Deprecated("Internal Use Only")
11750 NodeList.internal_() { }
11751
11752 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
11753 int get hashCode => unwrap_jso(this).hashCode;
11754
11755 @DomName('NodeList.length')
11756 @DocsEditable()
11757 int get length => wrap_jso(JS("int", "#.length", this.raw));
11758
11759 Node operator[](int index) {
11760 if (JS("bool", "# >>> 0 !== # || # >= #", index,
11761 index, index, length))
11762 throw new RangeError.index(index, this);
11763 return wrap_jso(JS("Node", "#[#]", this.raw, index));
11764 }
11765 void operator[]=(int index, Node value) {
11766 throw new UnsupportedError("Cannot assign element of immutable List.");
11767 }
11768 // -- start List<Node> mixins.
11769 // Node is the element type.
11770
11771
11772 set length(int value) {
11773 throw new UnsupportedError("Cannot resize immutable List.");
11774 }
11775
11776 Node get first {
11777 if (this.length > 0) {
11778 return wrap_jso(JS('Node', '#[0]', this.raw));
11779 }
11780 throw new StateError("No elements");
11781 }
11782
11783 Node get last {
11784 int len = this.length;
11785 if (len > 0) {
11786 return wrap_jso(JS('Node', '#[#]', this.raw, len - 1));
11787 }
11788 throw new StateError("No elements");
11789 }
11790
11791 Node get single {
11792 int len = this.length;
11793 if (len == 1) {
11794 return wrap_jso(JS('Node', '#[0]', this.raw));
11795 }
11796 if (len == 0) throw new StateError("No elements");
11797 throw new StateError("More than one element");
11798 }
11799
11800 Node elementAt(int index) => this[index];
11801 // -- end List<Node> mixins.
11802
11803 @DomName('NodeList.item')
11804 @DocsEditable()
11805 Node _item(int index) {
11806 return _item_1(index);
11807 }
11808 @JSName('item')
11809 @DomName('NodeList.item')
11810 @DocsEditable()
11811 Node _item_1(index) => wrap_jso(JS("Node ", "#.raw.item(#)", this, unwrap_jso( index)));
11812 }
11813 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
11814 // for details. All rights reserved. Use of this source code is governed by a
11815 // BSD-style license that can be found in the LICENSE file.
11816
11817
11818 @DocsEditable()
11819 @DomName('ParentNode')
11820 @Experimental() // untriaged
11821 abstract class ParentNode extends DartHtmlDomObject {
11822 // To suppress missing implicit constructor warnings.
11823 factory ParentNode._() { throw new UnsupportedError("Not supported"); }
11824
11825 int get _childElementCount => wrap_jso(JS("int", "#.childElementCount", this.r aw));
11826
11827 List<Node> get _children => wrap_jso(JS("List<Node>", "#.children", this.raw)) ;
11828
11829 Element get _firstElementChild => wrap_jso(JS("Element", "#.firstElementChild" , this.raw));
11830
11831 Element get _lastElementChild => wrap_jso(JS("Element", "#.lastElementChild", this.raw));
11832
11833 Element querySelector(String selectors) => wrap_jso(JS("Element", "#.raw.query Selector(#)", this, unwrap_jso(selectors)));
11834
11835 List<Node> _querySelectorAll(String selectors) => wrap_jso(JS("List<Node>", "# .raw.querySelectorAll(#)", this, unwrap_jso(selectors)));
11836 }
11837 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
11838 // for details. All rights reserved. Use of this source code is governed by a
11839 // BSD-style license that can be found in the LICENSE file.
11840
11841
11842 @DocsEditable()
11843 @DomName('ProgressEvent')
11844 @Native("ProgressEvent")
11845 class ProgressEvent extends Event {
11846 // To suppress missing implicit constructor warnings.
11847 factory ProgressEvent._() { throw new UnsupportedError("Not supported"); }
11848
11849
11850 @Deprecated("Internal Use Only")
11851 static ProgressEvent internalCreateProgressEvent() {
11852 return new ProgressEvent.internal_();
11853 }
11854
11855 @Deprecated("Internal Use Only")
11856 ProgressEvent.internal_() : super.internal_();
11857
11858
11859 @DomName('ProgressEvent.lengthComputable')
11860 @DocsEditable()
11861 bool get lengthComputable => wrap_jso(JS("bool", "#.lengthComputable", this.ra w));
11862
11863 @DomName('ProgressEvent.loaded')
11864 @DocsEditable()
11865 int get loaded => wrap_jso(JS("int", "#.loaded", this.raw));
11866
11867 @DomName('ProgressEvent.total')
11868 @DocsEditable()
11869 int get total => wrap_jso(JS("int", "#.total", this.raw));
11870 }
11871 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
11872 // for details. All rights reserved. Use of this source code is governed by a
11873 // BSD-style license that can be found in the LICENSE file.
11874
11875 // WARNING: Do not edit - generated code.
11876
11877
11878 @DomName('Range')
11879 @Unstable()
11880 @Native("Range")
11881 class Range extends DartHtmlDomObject {
11882 factory Range() => document.createRange();
11883
11884 factory Range.fromPoint(Point point) =>
11885 document._caretRangeFromPoint(point.x, point.y);
11886 // To suppress missing implicit constructor warnings.
11887 factory Range._() { throw new UnsupportedError("Not supported"); }
11888
11889 @Deprecated("Internal Use Only")
11890 static Range internalCreateRange() {
11891 return new Range.internal_();
11892 }
11893
11894 @Deprecated("Internal Use Only")
11895 Range.internal_() { }
11896
11897 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
11898 int get hashCode => unwrap_jso(this).hashCode;
11899
11900 @DomName('Range.END_TO_END')
11901 @DocsEditable()
11902 static const int END_TO_END = 2;
11903
11904 @DomName('Range.END_TO_START')
11905 @DocsEditable()
11906 static const int END_TO_START = 3;
11907
11908 @DomName('Range.NODE_AFTER')
11909 @DocsEditable()
11910 @Experimental() // nonstandard
11911 static const int NODE_AFTER = 1;
11912
11913 @DomName('Range.NODE_BEFORE')
11914 @DocsEditable()
11915 @Experimental() // nonstandard
11916 static const int NODE_BEFORE = 0;
11917
11918 @DomName('Range.NODE_BEFORE_AND_AFTER')
11919 @DocsEditable()
11920 @Experimental() // nonstandard
11921 static const int NODE_BEFORE_AND_AFTER = 2;
11922
11923 @DomName('Range.NODE_INSIDE')
11924 @DocsEditable()
11925 @Experimental() // nonstandard
11926 static const int NODE_INSIDE = 3;
11927
11928 @DomName('Range.START_TO_END')
11929 @DocsEditable()
11930 static const int START_TO_END = 1;
11931
11932 @DomName('Range.START_TO_START')
11933 @DocsEditable()
11934 static const int START_TO_START = 0;
11935
11936 @DomName('Range.collapsed')
11937 @DocsEditable()
11938 bool get collapsed => wrap_jso(JS("bool", "#.collapsed", this.raw));
11939
11940 @DomName('Range.commonAncestorContainer')
11941 @DocsEditable()
11942 Node get commonAncestorContainer => wrap_jso(JS("Node", "#.commonAncestorConta iner", this.raw));
11943
11944 @DomName('Range.endContainer')
11945 @DocsEditable()
11946 Node get endContainer => wrap_jso(JS("Node", "#.endContainer", this.raw));
11947
11948 @DomName('Range.endOffset')
11949 @DocsEditable()
11950 int get endOffset => wrap_jso(JS("int", "#.endOffset", this.raw));
11951
11952 @DomName('Range.startContainer')
11953 @DocsEditable()
11954 Node get startContainer => wrap_jso(JS("Node", "#.startContainer", this.raw));
11955
11956 @DomName('Range.startOffset')
11957 @DocsEditable()
11958 int get startOffset => wrap_jso(JS("int", "#.startOffset", this.raw));
11959
11960 @DomName('Range.cloneContents')
11961 @DocsEditable()
11962 DocumentFragment cloneContents() {
11963 return _cloneContents_1();
11964 }
11965 @JSName('cloneContents')
11966 @DomName('Range.cloneContents')
11967 @DocsEditable()
11968 DocumentFragment _cloneContents_1() => wrap_jso(JS("DocumentFragment ", "#.raw .cloneContents()", this));
11969
11970 @DomName('Range.cloneRange')
11971 @DocsEditable()
11972 Range cloneRange() {
11973 return _cloneRange_1();
11974 }
11975 @JSName('cloneRange')
11976 @DomName('Range.cloneRange')
11977 @DocsEditable()
11978 Range _cloneRange_1() => wrap_jso(JS("Range ", "#.raw.cloneRange()", this));
11979
11980 @DomName('Range.collapse')
11981 @DocsEditable()
11982 void collapse([bool toStart]) {
11983 if (toStart != null) {
11984 _collapse_1(toStart);
11985 return;
11986 }
11987 _collapse_2();
11988 return;
11989 }
11990 @JSName('collapse')
11991 @DomName('Range.collapse')
11992 @DocsEditable()
11993 void _collapse_1(toStart) => wrap_jso(JS("void ", "#.raw.collapse(#)", this, u nwrap_jso(toStart)));
11994 @JSName('collapse')
11995 @DomName('Range.collapse')
11996 @DocsEditable()
11997 void _collapse_2() => wrap_jso(JS("void ", "#.raw.collapse()", this));
11998
11999 @DomName('Range.compareBoundaryPoints')
12000 @DocsEditable()
12001 @Experimental() // untriaged
12002 int compareBoundaryPoints(int how, Range sourceRange) {
12003 return _compareBoundaryPoints_1(how, sourceRange);
12004 }
12005 @JSName('compareBoundaryPoints')
12006 @DomName('Range.compareBoundaryPoints')
12007 @DocsEditable()
12008 @Experimental() // untriaged
12009 int _compareBoundaryPoints_1(how, Range sourceRange) => wrap_jso(JS("int ", "# .raw.compareBoundaryPoints(#, #)", this, unwrap_jso(how), unwrap_jso(sourceRange )));
12010
12011 @DomName('Range.comparePoint')
12012 @DocsEditable()
12013 int comparePoint(Node refNode, int offset) {
12014 return _comparePoint_1(refNode, offset);
12015 }
12016 @JSName('comparePoint')
12017 @DomName('Range.comparePoint')
12018 @DocsEditable()
12019 int _comparePoint_1(Node refNode, offset) => wrap_jso(JS("int ", "#.raw.compar ePoint(#, #)", this, unwrap_jso(refNode), unwrap_jso(offset)));
12020
12021 @DomName('Range.createContextualFragment')
12022 @DocsEditable()
12023 DocumentFragment createContextualFragment(String html) {
12024 return _createContextualFragment_1(html);
12025 }
12026 @JSName('createContextualFragment')
12027 @DomName('Range.createContextualFragment')
12028 @DocsEditable()
12029 DocumentFragment _createContextualFragment_1(html) => wrap_jso(JS("DocumentFra gment ", "#.raw.createContextualFragment(#)", this, unwrap_jso(html)));
12030
12031 @DomName('Range.deleteContents')
12032 @DocsEditable()
12033 void deleteContents() {
12034 _deleteContents_1();
12035 return;
12036 }
12037 @JSName('deleteContents')
12038 @DomName('Range.deleteContents')
12039 @DocsEditable()
12040 void _deleteContents_1() => wrap_jso(JS("void ", "#.raw.deleteContents()", thi s));
12041
12042 @DomName('Range.detach')
12043 @DocsEditable()
12044 void detach() {
12045 _detach_1();
12046 return;
12047 }
12048 @JSName('detach')
12049 @DomName('Range.detach')
12050 @DocsEditable()
12051 void _detach_1() => wrap_jso(JS("void ", "#.raw.detach()", this));
12052
12053 @DomName('Range.expand')
12054 @DocsEditable()
12055 @Experimental() // non-standard
12056 void expand(String unit) {
12057 _expand_1(unit);
12058 return;
12059 }
12060 @JSName('expand')
12061 @DomName('Range.expand')
12062 @DocsEditable()
12063 @Experimental() // non-standard
12064 void _expand_1(unit) => wrap_jso(JS("void ", "#.raw.expand(#)", this, unwrap_j so(unit)));
12065
12066 @DomName('Range.extractContents')
12067 @DocsEditable()
12068 DocumentFragment extractContents() {
12069 return _extractContents_1();
12070 }
12071 @JSName('extractContents')
12072 @DomName('Range.extractContents')
12073 @DocsEditable()
12074 DocumentFragment _extractContents_1() => wrap_jso(JS("DocumentFragment ", "#.r aw.extractContents()", this));
12075
12076 @DomName('Range.getBoundingClientRect')
12077 @DocsEditable()
12078 Rectangle getBoundingClientRect() {
12079 return _getBoundingClientRect_1();
12080 }
12081 @JSName('getBoundingClientRect')
12082 @DomName('Range.getBoundingClientRect')
12083 @DocsEditable()
12084 Rectangle _getBoundingClientRect_1() => wrap_jso(JS("Rectangle ", "#.raw.getBo undingClientRect()", this));
12085
12086 @DomName('Range.insertNode')
12087 @DocsEditable()
12088 void insertNode(Node newNode) {
12089 _insertNode_1(newNode);
12090 return;
12091 }
12092 @JSName('insertNode')
12093 @DomName('Range.insertNode')
12094 @DocsEditable()
12095 void _insertNode_1(Node newNode) => wrap_jso(JS("void ", "#.raw.insertNode(#)" , this, unwrap_jso(newNode)));
12096
12097 @DomName('Range.isPointInRange')
12098 @DocsEditable()
12099 bool isPointInRange(Node refNode, int offset) {
12100 return _isPointInRange_1(refNode, offset);
12101 }
12102 @JSName('isPointInRange')
12103 @DomName('Range.isPointInRange')
12104 @DocsEditable()
12105 bool _isPointInRange_1(Node refNode, offset) => wrap_jso(JS("bool ", "#.raw.is PointInRange(#, #)", this, unwrap_jso(refNode), unwrap_jso(offset)));
12106
12107 @DomName('Range.selectNode')
12108 @DocsEditable()
12109 void selectNode(Node refNode) {
12110 _selectNode_1(refNode);
12111 return;
12112 }
12113 @JSName('selectNode')
12114 @DomName('Range.selectNode')
12115 @DocsEditable()
12116 void _selectNode_1(Node refNode) => wrap_jso(JS("void ", "#.raw.selectNode(#)" , this, unwrap_jso(refNode)));
12117
12118 @DomName('Range.selectNodeContents')
12119 @DocsEditable()
12120 void selectNodeContents(Node refNode) {
12121 _selectNodeContents_1(refNode);
12122 return;
12123 }
12124 @JSName('selectNodeContents')
12125 @DomName('Range.selectNodeContents')
12126 @DocsEditable()
12127 void _selectNodeContents_1(Node refNode) => wrap_jso(JS("void ", "#.raw.select NodeContents(#)", this, unwrap_jso(refNode)));
12128
12129 @DomName('Range.setEnd')
12130 @DocsEditable()
12131 void setEnd(Node refNode, int offset) {
12132 _setEnd_1(refNode, offset);
12133 return;
12134 }
12135 @JSName('setEnd')
12136 @DomName('Range.setEnd')
12137 @DocsEditable()
12138 void _setEnd_1(Node refNode, offset) => wrap_jso(JS("void ", "#.raw.setEnd(#, #)", this, unwrap_jso(refNode), unwrap_jso(offset)));
12139
12140 @DomName('Range.setEndAfter')
12141 @DocsEditable()
12142 void setEndAfter(Node refNode) {
12143 _setEndAfter_1(refNode);
12144 return;
12145 }
12146 @JSName('setEndAfter')
12147 @DomName('Range.setEndAfter')
12148 @DocsEditable()
12149 void _setEndAfter_1(Node refNode) => wrap_jso(JS("void ", "#.raw.setEndAfter(# )", this, unwrap_jso(refNode)));
12150
12151 @DomName('Range.setEndBefore')
12152 @DocsEditable()
12153 void setEndBefore(Node refNode) {
12154 _setEndBefore_1(refNode);
12155 return;
12156 }
12157 @JSName('setEndBefore')
12158 @DomName('Range.setEndBefore')
12159 @DocsEditable()
12160 void _setEndBefore_1(Node refNode) => wrap_jso(JS("void ", "#.raw.setEndBefore (#)", this, unwrap_jso(refNode)));
12161
12162 @DomName('Range.setStart')
12163 @DocsEditable()
12164 void setStart(Node refNode, int offset) {
12165 _setStart_1(refNode, offset);
12166 return;
12167 }
12168 @JSName('setStart')
12169 @DomName('Range.setStart')
12170 @DocsEditable()
12171 void _setStart_1(Node refNode, offset) => wrap_jso(JS("void ", "#.raw.setStart (#, #)", this, unwrap_jso(refNode), unwrap_jso(offset)));
12172
12173 @DomName('Range.setStartAfter')
12174 @DocsEditable()
12175 void setStartAfter(Node refNode) {
12176 _setStartAfter_1(refNode);
12177 return;
12178 }
12179 @JSName('setStartAfter')
12180 @DomName('Range.setStartAfter')
12181 @DocsEditable()
12182 void _setStartAfter_1(Node refNode) => wrap_jso(JS("void ", "#.raw.setStartAft er(#)", this, unwrap_jso(refNode)));
12183
12184 @DomName('Range.setStartBefore')
12185 @DocsEditable()
12186 void setStartBefore(Node refNode) {
12187 _setStartBefore_1(refNode);
12188 return;
12189 }
12190 @JSName('setStartBefore')
12191 @DomName('Range.setStartBefore')
12192 @DocsEditable()
12193 void _setStartBefore_1(Node refNode) => wrap_jso(JS("void ", "#.raw.setStartBe fore(#)", this, unwrap_jso(refNode)));
12194
12195 @DomName('Range.surroundContents')
12196 @DocsEditable()
12197 void surroundContents(Node newParent) {
12198 _surroundContents_1(newParent);
12199 return;
12200 }
12201 @JSName('surroundContents')
12202 @DomName('Range.surroundContents')
12203 @DocsEditable()
12204 void _surroundContents_1(Node newParent) => wrap_jso(JS("void ", "#.raw.surrou ndContents(#)", this, unwrap_jso(newParent)));
12205
12206
12207 /**
12208 * Checks if createContextualFragment is supported.
12209 *
12210 * See also:
12211 *
12212 * * [createContextualFragment]
12213 */
12214 static bool get supportsCreateContextualFragment => true;
12215 }
12216 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
12217 // for details. All rights reserved. Use of this source code is governed by a
12218 // BSD-style license that can be found in the LICENSE file.
12219
12220 // WARNING: Do not edit - generated code.
12221
12222
12223 @DomName('RequestAnimationFrameCallback')
12224 typedef void RequestAnimationFrameCallback(num highResTime);
12225 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
12226 // for details. All rights reserved. Use of this source code is governed by a
12227 // BSD-style license that can be found in the LICENSE file.
12228
12229 // WARNING: Do not edit - generated code.
12230
12231
12232 @DomName('ShadowRoot')
12233 @SupportedBrowser(SupportedBrowser.CHROME, '26')
12234 @Experimental()
12235 // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#api- shadow-root
12236 @Native("ShadowRoot")
12237 class ShadowRoot extends DocumentFragment {
12238 // To suppress missing implicit constructor warnings.
12239 factory ShadowRoot._() { throw new UnsupportedError("Not supported"); }
12240
12241
12242 @Deprecated("Internal Use Only")
12243 static ShadowRoot internalCreateShadowRoot() {
12244 return new ShadowRoot.internal_();
12245 }
12246
12247 @Deprecated("Internal Use Only")
12248 ShadowRoot.internal_() : super.internal_();
12249
12250
12251 @DomName('ShadowRoot.activeElement')
12252 @DocsEditable()
12253 Element get activeElement => wrap_jso(JS("Element", "#.activeElement", this.ra w));
12254
12255 @DomName('ShadowRoot.host')
12256 @DocsEditable()
12257 @Experimental() // untriaged
12258 Element get host => wrap_jso(JS("Element", "#.host", this.raw));
12259
12260 @JSName('innerHTML')
12261 @DomName('ShadowRoot.innerHTML')
12262 @DocsEditable()
12263 String get innerHtml => wrap_jso(JS("String", "#.innerHTML", this.raw));
12264 @JSName('innerHTML')
12265 @DomName('ShadowRoot.innerHTML')
12266 @DocsEditable()
12267 void set innerHtml(String val) => JS("void", "#.innerHTML = #", this.raw, unwr ap_jso(val));
12268
12269 @DomName('ShadowRoot.olderShadowRoot')
12270 @DocsEditable()
12271 @Experimental() // untriaged
12272 ShadowRoot get olderShadowRoot => wrap_jso(JS("ShadowRoot", "#.olderShadowRoot ", this.raw));
12273
12274 @DomName('ShadowRoot.cloneNode')
12275 @DocsEditable()
12276 Node clone(bool deep) {
12277 return _clone_1(deep);
12278 }
12279 @JSName('cloneNode')
12280 @DomName('ShadowRoot.cloneNode')
12281 @DocsEditable()
12282 Node _clone_1(deep) => wrap_jso(JS("Node ", "#.raw.cloneNode(#)", this, unwrap _jso(deep)));
12283
12284 @DomName('ShadowRoot.elementFromPoint')
12285 @DocsEditable()
12286 Element elementFromPoint(int x, int y) {
12287 return _elementFromPoint_1(x, y);
12288 }
12289 @JSName('elementFromPoint')
12290 @DomName('ShadowRoot.elementFromPoint')
12291 @DocsEditable()
12292 Element _elementFromPoint_1(x, y) => wrap_jso(JS("Element ", "#.raw.elementFro mPoint(#, #)", this, unwrap_jso(x), unwrap_jso(y)));
12293
12294 @DomName('ShadowRoot.getElementsByClassName')
12295 @DocsEditable()
12296 @Creates('NodeList|HtmlCollection')
12297 @Returns('NodeList|HtmlCollection')
12298 HtmlCollection getElementsByClassName(String className) {
12299 return _getElementsByClassName_1(className);
12300 }
12301 @JSName('getElementsByClassName')
12302 @DomName('ShadowRoot.getElementsByClassName')
12303 @DocsEditable()
12304 @Creates('NodeList|HtmlCollection')
12305 @Returns('NodeList|HtmlCollection')
12306 HtmlCollection _getElementsByClassName_1(className) => wrap_jso(JS("HtmlCollec tion ", "#.raw.getElementsByClassName(#)", this, unwrap_jso(className)));
12307
12308 @DomName('ShadowRoot.getElementsByTagName')
12309 @DocsEditable()
12310 @Creates('NodeList|HtmlCollection')
12311 @Returns('NodeList|HtmlCollection')
12312 HtmlCollection getElementsByTagName(String tagName) {
12313 return _getElementsByTagName_1(tagName);
12314 }
12315 @JSName('getElementsByTagName')
12316 @DomName('ShadowRoot.getElementsByTagName')
12317 @DocsEditable()
12318 @Creates('NodeList|HtmlCollection')
12319 @Returns('NodeList|HtmlCollection')
12320 HtmlCollection _getElementsByTagName_1(tagName) => wrap_jso(JS("HtmlCollection ", "#.raw.getElementsByTagName(#)", this, unwrap_jso(tagName)));
12321
12322 static final bool supported = true;
12323
12324 static bool _shadowRootDeprecationReported = false;
12325 static void _shadowRootDeprecationReport() {
12326 if (!_shadowRootDeprecationReported) {
12327 window.console.warn('''
12328 ShadowRoot.resetStyleInheritance and ShadowRoot.applyAuthorStyles now deprecated in dart:html.
12329 Please remove them from your code.
12330 ''');
12331 _shadowRootDeprecationReported = true;
12332 }
12333 }
12334
12335 @deprecated
12336 bool get resetStyleInheritance {
12337 _shadowRootDeprecationReport();
12338 // Default value from when it was specified.
12339 return false;
12340 }
12341
12342 @deprecated
12343 set resetStyleInheritance(bool value) {
12344 _shadowRootDeprecationReport();
12345 }
12346
12347 @deprecated
12348 bool get applyAuthorStyles {
12349 _shadowRootDeprecationReport();
12350 // Default value from when it was specified.
12351 return false;
12352 }
12353
12354 @deprecated
12355 set applyAuthorStyles(bool value) {
12356 _shadowRootDeprecationReport();
12357 }
12358 }
12359 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
12360 // for details. All rights reserved. Use of this source code is governed by a
12361 // BSD-style license that can be found in the LICENSE file.
12362
12363
12364 @DocsEditable()
12365 @DomName('HTMLStyleElement')
12366 @Native("HTMLStyleElement")
12367 class StyleElement extends HtmlElement {
12368 // To suppress missing implicit constructor warnings.
12369 factory StyleElement._() { throw new UnsupportedError("Not supported"); }
12370
12371 @DomName('HTMLStyleElement.HTMLStyleElement')
12372 @DocsEditable()
12373 factory StyleElement() => document.createElement("style");
12374
12375
12376 @Deprecated("Internal Use Only")
12377 static StyleElement internalCreateStyleElement() {
12378 return new StyleElement.internal_();
12379 }
12380
12381 @Deprecated("Internal Use Only")
12382 StyleElement.internal_() : super.internal_();
12383
12384
12385 @DomName('HTMLStyleElement.disabled')
12386 @DocsEditable()
12387 bool get disabled => wrap_jso(JS("bool", "#.disabled", this.raw));
12388 @DomName('HTMLStyleElement.disabled')
12389 @DocsEditable()
12390 void set disabled(bool val) => JS("void", "#.disabled = #", this.raw, unwrap_j so(val));
12391
12392 @DomName('HTMLStyleElement.media')
12393 @DocsEditable()
12394 String get media => wrap_jso(JS("String", "#.media", this.raw));
12395 @DomName('HTMLStyleElement.media')
12396 @DocsEditable()
12397 void set media(String val) => JS("void", "#.media = #", this.raw, unwrap_jso(v al));
12398
12399 @DomName('HTMLStyleElement.type')
12400 @DocsEditable()
12401 String get type => wrap_jso(JS("String", "#.type", this.raw));
12402 @DomName('HTMLStyleElement.type')
12403 @DocsEditable()
12404 void set type(String val) => JS("void", "#.type = #", this.raw, unwrap_jso(val ));
12405 }
12406 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
12407 // for details. All rights reserved. Use of this source code is governed by a
12408 // BSD-style license that can be found in the LICENSE file.
12409
12410 // WARNING: Do not edit - generated code.
12411
12412
12413 @Experimental()
12414 @DomName('HTMLTemplateElement')
12415 @SupportedBrowser(SupportedBrowser.CHROME)
12416 @Experimental()
12417 // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#t emplate-element
12418 @Native("HTMLTemplateElement")
12419 class TemplateElement extends HtmlElement {
12420 // To suppress missing implicit constructor warnings.
12421 factory TemplateElement._() { throw new UnsupportedError("Not supported"); }
12422
12423 @DomName('HTMLTemplateElement.HTMLTemplateElement')
12424 @DocsEditable()
12425 factory TemplateElement() => document.createElement("template");
12426
12427
12428 @Deprecated("Internal Use Only")
12429 static TemplateElement internalCreateTemplateElement() {
12430 return new TemplateElement.internal_();
12431 }
12432
12433 @Deprecated("Internal Use Only")
12434 TemplateElement.internal_() : super.internal_();
12435
12436
12437 /// Checks if this type is supported on the current platform.
12438 static bool get supported => Element.isTagSupported('template');
12439
12440 @DomName('HTMLTemplateElement.content')
12441 @DocsEditable()
12442 DocumentFragment get content => wrap_jso(JS("DocumentFragment", "#.content", t his.raw));
12443
12444
12445 /**
12446 * An override to place the contents into content rather than as child nodes.
12447 *
12448 * See also:
12449 *
12450 * * <https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.h tml#innerhtml-on-templates>
12451 */
12452 void setInnerHtml(String html,
12453 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
12454 text = null;
12455 var fragment = createFragment(
12456 html, validator: validator, treeSanitizer: treeSanitizer);
12457
12458 content.append(fragment);
12459 }
12460 }
12461 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
12462 // for details. All rights reserved. Use of this source code is governed by a
12463 // BSD-style license that can be found in the LICENSE file.
12464
12465 // WARNING: Do not edit - generated code.
12466
12467
12468 @DomName('Text')
12469 @Native("Text")
12470 class Text extends CharacterData {
12471 factory Text(String data) => document._createTextNode(data);
12472 // To suppress missing implicit constructor warnings.
12473 factory Text._() { throw new UnsupportedError("Not supported"); }
12474
12475
12476 @Deprecated("Internal Use Only")
12477 static Text internalCreateText() {
12478 return new Text.internal_();
12479 }
12480
12481 @Deprecated("Internal Use Only")
12482 Text.internal_() : super.internal_();
12483
12484
12485 @DomName('Text.wholeText')
12486 @DocsEditable()
12487 String get wholeText => wrap_jso(JS("String", "#.wholeText", this.raw));
12488
12489 @DomName('Text.getDestinationInsertionPoints')
12490 @DocsEditable()
12491 @Experimental() // untriaged
12492 @Returns('NodeList')
12493 @Creates('NodeList')
12494 NodeList getDestinationInsertionPoints() {
12495 return _getDestinationInsertionPoints_1();
12496 }
12497 @JSName('getDestinationInsertionPoints')
12498 @DomName('Text.getDestinationInsertionPoints')
12499 @DocsEditable()
12500 @Experimental() // untriaged
12501 @Returns('NodeList')
12502 @Creates('NodeList')
12503 NodeList _getDestinationInsertionPoints_1() => wrap_jso(JS("NodeList ", "#.raw .getDestinationInsertionPoints()", this));
12504
12505 @DomName('Text.splitText')
12506 @DocsEditable()
12507 Text splitText(int offset) {
12508 return _splitText_1(offset);
12509 }
12510 @JSName('splitText')
12511 @DomName('Text.splitText')
12512 @DocsEditable()
12513 Text _splitText_1(offset) => wrap_jso(JS("Text ", "#.raw.splitText(#)", this, unwrap_jso(offset)));
12514
12515 }
12516 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
12517 // for details. All rights reserved. Use of this source code is governed by a
12518 // BSD-style license that can be found in the LICENSE file.
12519
12520 // WARNING: Do not edit - generated code.
12521
12522
12523 @DomName('UIEvent')
12524 @Native("UIEvent")
12525 class UIEvent extends Event {
12526 // In JS, canBubble and cancelable are technically required parameters to
12527 // init*Event. In practice, though, if they aren't provided they simply
12528 // default to false (since that's Boolean(undefined)).
12529 //
12530 // Contrary to JS, we default canBubble and cancelable to true, since that's
12531 // what people want most of the time anyway.
12532 factory UIEvent(String type,
12533 {Window view, int detail: 0, bool canBubble: true,
12534 bool cancelable: true}) {
12535 if (view == null) {
12536 view = window;
12537 }
12538 UIEvent e = document._createEvent("UIEvent");
12539 e._initUIEvent(type, canBubble, cancelable, view, detail);
12540 return e;
12541 }
12542 // To suppress missing implicit constructor warnings.
12543 factory UIEvent._() { throw new UnsupportedError("Not supported"); }
12544
12545
12546 @Deprecated("Internal Use Only")
12547 static UIEvent internalCreateUIEvent() {
12548 return new UIEvent.internal_();
12549 }
12550
12551 @Deprecated("Internal Use Only")
12552 UIEvent.internal_() : super.internal_();
12553
12554
12555 @JSName('charCode')
12556 @DomName('UIEvent.charCode')
12557 @DocsEditable()
12558 @Unstable()
12559 int get _charCode => wrap_jso(JS("int", "#.charCode", this.raw));
12560
12561 @DomName('UIEvent.detail')
12562 @DocsEditable()
12563 int get detail => wrap_jso(JS("int", "#.detail", this.raw));
12564
12565 @JSName('keyCode')
12566 @DomName('UIEvent.keyCode')
12567 @DocsEditable()
12568 @Unstable()
12569 int get _keyCode => wrap_jso(JS("int", "#.keyCode", this.raw));
12570
12571 @JSName('layerX')
12572 @DomName('UIEvent.layerX')
12573 @DocsEditable()
12574 // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#even ts-mouseevents
12575 @Experimental() // nonstandard
12576 int get _layerX => wrap_jso(JS("int", "#.layerX", this.raw));
12577
12578 @JSName('layerY')
12579 @DomName('UIEvent.layerY')
12580 @DocsEditable()
12581 // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#even ts-mouseevents
12582 @Experimental() // nonstandard
12583 int get _layerY => wrap_jso(JS("int", "#.layerY", this.raw));
12584
12585 @JSName('pageX')
12586 @DomName('UIEvent.pageX')
12587 @DocsEditable()
12588 // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#even ts-mouseevents
12589 @Experimental() // nonstandard
12590 int get _pageX => wrap_jso(JS("int", "#.pageX", this.raw));
12591
12592 @JSName('pageY')
12593 @DomName('UIEvent.pageY')
12594 @DocsEditable()
12595 // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#even ts-mouseevents
12596 @Experimental() // nonstandard
12597 int get _pageY => wrap_jso(JS("int", "#.pageY", this.raw));
12598
12599 @DomName('UIEvent.view')
12600 @DocsEditable()
12601 WindowBase get view => _convertNativeToDart_Window(this._get_view);
12602 @JSName('view')
12603 @DomName('UIEvent.view')
12604 @DocsEditable()
12605 @Creates('Window|=Object')
12606 @Returns('Window|=Object')
12607 dynamic get _get_view => wrap_jso(JS("dynamic", "#.view", this.raw));
12608
12609 @DomName('UIEvent.which')
12610 @DocsEditable()
12611 @Unstable()
12612 int get which => wrap_jso(JS("int", "#.which", this.raw));
12613
12614 @DomName('UIEvent.initUIEvent')
12615 @DocsEditable()
12616 void _initUIEvent(String type, bool canBubble, bool cancelable, Window view, i nt detail) {
12617 _initUIEvent_1(type, canBubble, cancelable, view, detail);
12618 return;
12619 }
12620 @JSName('initUIEvent')
12621 @DomName('UIEvent.initUIEvent')
12622 @DocsEditable()
12623 void _initUIEvent_1(type, canBubble, cancelable, Window view, detail) => wrap_ jso(JS("void ", "#.raw.initUIEvent(#, #, #, #, #)", this, unwrap_jso(type), unwr ap_jso(canBubble), unwrap_jso(cancelable), unwrap_jso(view), unwrap_jso(detail)) );
12624
12625
12626 @DomName('UIEvent.layerX')
12627 @DomName('UIEvent.layerY')
12628 Point get layer => new Point(_layerX, _layerY);
12629
12630 @DomName('UIEvent.pageX')
12631 @DomName('UIEvent.pageY')
12632 Point get page => new Point(_pageX, _pageY);
12633 }
12634 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
12635 // for details. All rights reserved. Use of this source code is governed by a
12636 // BSD-style license that can be found in the LICENSE file.
12637
12638
12639 @DocsEditable()
12640 @DomName('URLUtils')
12641 @Experimental() // untriaged
12642 abstract class UrlUtils extends DartHtmlDomObject {
12643 // To suppress missing implicit constructor warnings.
12644 factory UrlUtils._() { throw new UnsupportedError("Not supported"); }
12645
12646 String get hash => wrap_jso(JS("String", "#.hash", this.raw));
12647 void set hash(String val) => JS("void", "#.hash = #", this.raw, unwrap_jso(val ));
12648
12649 String get host => wrap_jso(JS("String", "#.host", this.raw));
12650 void set host(String val) => JS("void", "#.host = #", this.raw, unwrap_jso(val ));
12651
12652 String get hostname => wrap_jso(JS("String", "#.hostname", this.raw));
12653 void set hostname(String val) => JS("void", "#.hostname = #", this.raw, unwrap _jso(val));
12654
12655 String get href => wrap_jso(JS("String", "#.href", this.raw));
12656 void set href(String val) => JS("void", "#.href = #", this.raw, unwrap_jso(val ));
12657
12658 String get origin => wrap_jso(JS("String", "#.origin", this.raw));
12659
12660 String get password => wrap_jso(JS("String", "#.password", this.raw));
12661 void set password(String val) => JS("void", "#.password = #", this.raw, unwrap _jso(val));
12662
12663 String get pathname => wrap_jso(JS("String", "#.pathname", this.raw));
12664 void set pathname(String val) => JS("void", "#.pathname = #", this.raw, unwrap _jso(val));
12665
12666 String get port => wrap_jso(JS("String", "#.port", this.raw));
12667 void set port(String val) => JS("void", "#.port = #", this.raw, unwrap_jso(val ));
12668
12669 String get protocol => wrap_jso(JS("String", "#.protocol", this.raw));
12670 void set protocol(String val) => JS("void", "#.protocol = #", this.raw, unwrap _jso(val));
12671
12672 String get search => wrap_jso(JS("String", "#.search", this.raw));
12673 void set search(String val) => JS("void", "#.search = #", this.raw, unwrap_jso (val));
12674
12675 String get username => wrap_jso(JS("String", "#.username", this.raw));
12676 void set username(String val) => JS("void", "#.username = #", this.raw, unwrap _jso(val));
12677
12678 String toString() => wrap_jso(JS("String", "#.raw.toString()", this));
12679 }
12680 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
12681 // for details. All rights reserved. Use of this source code is governed by a
12682 // BSD-style license that can be found in the LICENSE file.
12683
12684
12685 @DocsEditable()
12686 /**
12687 * Top-level container for the current browser tab or window.
12688 *
12689 * In a web browser, each window has a [Window] object, but within the context
12690 * of a script, this object represents only the current window.
12691 * Each other window, tab, and iframe has its own [Window] object.
12692 *
12693 * Each window contains a [Document] object, which contains all of the window's
12694 * content.
12695 *
12696 * Use the top-level `window` object to access the current window.
12697 * For example:
12698 *
12699 * // Draw a scene when the window repaints.
12700 * drawScene(num delta) {...}
12701 * window.animationFrame.then(drawScene);.
12702 *
12703 * // Write to the console.
12704 * window.console.log('Jinkies!');
12705 * window.console.error('Jeepers!');
12706 *
12707 * **Note:** This class represents only the current window, while [WindowBase]
12708 * is a representation of any window, including other tabs, windows, and frames.
12709 *
12710 * ## See also
12711 *
12712 * * [WindowBase]
12713 *
12714 * ## Other resources
12715 *
12716 * * [DOM Window](https://developer.mozilla.org/en-US/docs/DOM/window) from MDN.
12717 * * [Window](http://www.w3.org/TR/Window/) from the W3C.
12718 */
12719 @DomName('Window')
12720 @Native("Window")
12721 class Window extends EventTarget implements WindowBase {
12722
12723 /**
12724 * Returns a Future that completes just before the window is about to
12725 * repaint so the user can draw an animation frame.
12726 *
12727 * If you need to later cancel this animation, use [requestAnimationFrame]
12728 * instead.
12729 *
12730 * The [Future] completes to a timestamp that represents a floating
12731 * point value of the number of milliseconds that have elapsed since the page
12732 * started to load (which is also the timestamp at this call to
12733 * animationFrame).
12734 *
12735 * Note: The code that runs when the future completes should call
12736 * [animationFrame] again for the animation to continue.
12737 */
12738 Future<num> get animationFrame {
12739 var completer = new Completer<num>.sync();
12740 requestAnimationFrame((time) {
12741 completer.complete(time);
12742 });
12743 return completer.future;
12744 }
12745
12746 /**
12747 * The newest document in this window.
12748 *
12749 * ## Other resources
12750 *
12751 * * [Loading web pages]
12752 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html)
12753 * from WHATWG.
12754 */
12755 Document get document => wrap_jso(JS('Document', '#.document', this.raw));
12756
12757 WindowBase _open2(url, name) => wrap_jso(JS('Window', '#.open(#,#)', this.raw, url, name));
12758
12759 WindowBase _open3(url, name, options) =>
12760 wrap_jso(JS('Window', '#.open(#,#,#)', this.raw, url, name, options));
12761
12762 /**
12763 * Opens a new window.
12764 *
12765 * ## Other resources
12766 *
12767 * * [Window.open]
12768 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.open) from MDN.
12769 * * [Window open]
12770 * (http://docs.webplatform.org/wiki/dom/methods/open) from WebPlatform.org.
12771 */
12772 WindowBase open(String url, String name, [String options]) {
12773 if (options == null) {
12774 return _DOMWindowCrossFrame._createSafe(_open2(url, name));
12775 } else {
12776 return _DOMWindowCrossFrame._createSafe(_open3(url, name, options));
12777 }
12778 }
12779
12780 // API level getter and setter for Location.
12781 // TODO: The cross domain safe wrapper can be inserted here.
12782 /**
12783 * The current location of this window.
12784 *
12785 * Location currentLocation = window.location;
12786 * print(currentLocation.href); // 'http://www.example.com:80/'
12787 */
12788 Location get location => _location;
12789
12790 // TODO: consider forcing users to do: window.location.assign('string').
12791 /**
12792 * Sets the window's location, which causes the browser to navigate to the new
12793 * location. [value] may be a Location object or a String.
12794 */
12795 set location(value) {
12796 _location = value;
12797 }
12798
12799 // Native getter and setter to access raw Location object.
12800 dynamic get _location => wrap_jso(JS('Location|Null', '#.location', this.raw)) ;
12801 set _location(value) {
12802 JS('void', '#.location = #', this.raw, unwrap_jso(value));
12803 }
12804
12805 /**
12806 * Called to draw an animation frame and then request the window to repaint
12807 * after [callback] has finished (creating the animation).
12808 *
12809 * Use this method only if you need to later call [cancelAnimationFrame]. If
12810 * not, the preferred Dart idiom is to set animation frames by calling
12811 * [animationFrame], which returns a Future.
12812 *
12813 * Returns a non-zero valued integer to represent the request id for this
12814 * request. This value only needs to be saved if you intend to call
12815 * [cancelAnimationFrame] so you can specify the particular animation to
12816 * cancel.
12817 *
12818 * Note: The supplied [callback] needs to call [requestAnimationFrame] again
12819 * for the animation to continue.
12820 */
12821 @DomName('Window.requestAnimationFrame')
12822 int requestAnimationFrame(RequestAnimationFrameCallback callback) {
12823 _ensureRequestAnimationFrame();
12824 return _requestAnimationFrame(_wrapZone(callback));
12825 }
12826
12827 /**
12828 * Cancels an animation frame request.
12829 *
12830 * ## Other resources
12831 *
12832 * * [Window.cancelAnimationFrame]
12833 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.cancelAnimationFra me) from MDN.
12834 */
12835 void cancelAnimationFrame(int id) {
12836 _ensureRequestAnimationFrame();
12837 _cancelAnimationFrame(id);
12838 }
12839
12840 @JSName('requestAnimationFrame')
12841 int _requestAnimationFrame(RequestAnimationFrameCallback callback)
12842 => JS('int', '#.requestAnimationFrame', this.raw);
12843
12844 @JSName('cancelAnimationFrame')
12845 void _cancelAnimationFrame(int id)
12846 { JS('void', '#.cancelAnimationFrame(#)', this.raw, id); }
12847
12848 _ensureRequestAnimationFrame() {
12849 if (JS('bool',
12850 '!!(#.requestAnimationFrame && #.cancelAnimationFrame)', this.raw, th is.raw))
12851 return;
12852
12853 JS('void',
12854 r"""
12855 (function($this) {
12856 var vendors = ['ms', 'moz', 'webkit', 'o'];
12857 for (var i = 0; i < vendors.length && !$this.requestAnimationFrame; ++i) {
12858 $this.requestAnimationFrame = $this[vendors[i] + 'RequestAnimationFrame'];
12859 $this.cancelAnimationFrame =
12860 $this[vendors[i]+'CancelAnimationFrame'] ||
12861 $this[vendors[i]+'CancelRequestAnimationFrame'];
12862 }
12863 if ($this.requestAnimationFrame && $this.cancelAnimationFrame) return;
12864 $this.requestAnimationFrame = function(callback) {
12865 return window.setTimeout(function() {
12866 callback(Date.now());
12867 }, 16 /* 16ms ~= 60fps */);
12868 };
12869 $this.cancelAnimationFrame = function(id) { clearTimeout(id); }
12870 })(#)""",
12871 this.raw);
12872 }
12873
12874 /// The debugging console for this window.
12875 @DomName('Window.console')
12876 Console get console => Console._safeConsole;
12877
12878 // To suppress missing implicit constructor warnings.
12879 factory Window._() { throw new UnsupportedError("Not supported"); }
12880
12881 /**
12882 * Static factory designed to expose `contentloaded` events to event
12883 * handlers that are not necessarily instances of [Window].
12884 *
12885 * See [EventStreamProvider] for usage information.
12886 */
12887 @DomName('Window.DOMContentLoadedEvent')
12888 @DocsEditable()
12889 static const EventStreamProvider<Event> contentLoadedEvent = const EventStream Provider<Event>('DOMContentLoaded');
12890
12891
12892 @Deprecated("Internal Use Only")
12893 static Window internalCreateWindow() {
12894 return new Window.internal_();
12895 }
12896
12897 @Deprecated("Internal Use Only")
12898 Window.internal_() : super.internal_();
12899
12900
12901 /**
12902 * Indicates that file system data cannot be cleared unless given user
12903 * permission.
12904 *
12905 * ## Other resources
12906 *
12907 * * [Exploring the FileSystem APIs]
12908 * (http://www.html5rocks.com/en/tutorials/file/filesystem/) from HTML5Rocks.
12909 * * [File API]
12910 * (http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem) from W3C.
12911 */
12912 @DomName('Window.PERSISTENT')
12913 @DocsEditable()
12914 // http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem
12915 @Experimental()
12916 static const int PERSISTENT = 1;
12917
12918 /**
12919 * Indicates that file system data can be cleared at any time.
12920 *
12921 * ## Other resources
12922 *
12923 * * [Exploring the FileSystem APIs]
12924 * (http://www.html5rocks.com/en/tutorials/file/filesystem/) from HTML5Rocks.
12925 * * [File API]
12926 * (http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem) from W3C.
12927 */
12928 @DomName('Window.TEMPORARY')
12929 @DocsEditable()
12930 // http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem
12931 @Experimental()
12932 static const int TEMPORARY = 0;
12933
12934 @DomName('Window.closed')
12935 @DocsEditable()
12936 bool get closed => wrap_jso(JS("bool", "#.closed", this.raw));
12937
12938 /// *Deprecated*.
12939 @DomName('Window.defaultStatus')
12940 @DocsEditable()
12941 @Experimental() // non-standard
12942 String get defaultStatus => wrap_jso(JS("String", "#.defaultStatus", this.raw) );
12943 /// *Deprecated*.
12944 @DomName('Window.defaultStatus')
12945 @DocsEditable()
12946 @Experimental() // non-standard
12947 void set defaultStatus(String val) => JS("void", "#.defaultStatus = #", this.r aw, unwrap_jso(val));
12948
12949 /// *Deprecated*.
12950 @DomName('Window.defaultstatus')
12951 @DocsEditable()
12952 @Experimental() // non-standard
12953 String get defaultstatus => wrap_jso(JS("String", "#.defaultstatus", this.raw) );
12954 /// *Deprecated*.
12955 @DomName('Window.defaultstatus')
12956 @DocsEditable()
12957 @Experimental() // non-standard
12958 void set defaultstatus(String val) => JS("void", "#.defaultstatus = #", this.r aw, unwrap_jso(val));
12959
12960 /**
12961 * The ratio between physical pixels and logical CSS pixels.
12962 *
12963 * ## Other resources
12964 *
12965 * * [devicePixelRatio]
12966 * (http://www.quirksmode.org/blog/archives/2012/06/devicepixelrati.html) from
12967 * quirksmode.
12968 * * [More about devicePixelRatio]
12969 * (http://www.quirksmode.org/blog/archives/2012/07/more_about_devi.html) from
12970 * quirksmode.
12971 */
12972 @DomName('Window.devicePixelRatio')
12973 @DocsEditable()
12974 // http://www.quirksmode.org/blog/archives/2012/06/devicepixelrati.html
12975 @Experimental() // non-standard
12976 double get devicePixelRatio => wrap_jso(JS("double", "#.devicePixelRatio", thi s.raw));
12977
12978 /**
12979 * The current session history for this window's newest document.
12980 *
12981 * ## Other resources
12982 *
12983 * * [Loading web pages]
12984 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html)
12985 * from WHATWG.
12986 */
12987 @DomName('Window.history')
12988 @DocsEditable()
12989 History get history => wrap_jso(JS("History", "#.history", this.raw));
12990
12991 /**
12992 * The height of the viewport including scrollbars.
12993 *
12994 * ## Other resources
12995 *
12996 * * [innerHeight]
12997 * (http://docs.webplatform.org/wiki/css/cssom/properties/innerHeight) from
12998 * WebPlatform.org.
12999 */
13000 @DomName('Window.innerHeight')
13001 @DocsEditable()
13002 int get innerHeight => wrap_jso(JS("int", "#.innerHeight", this.raw));
13003
13004 /**
13005 * The width of the viewport including scrollbars.
13006 *
13007 * ## Other resources
13008 *
13009 * * [innerWidth]
13010 * (http://docs.webplatform.org/wiki/css/cssom/properties/innerWidth) from
13011 * WebPlatform.org.
13012 */
13013 @DomName('Window.innerWidth')
13014 @DocsEditable()
13015 int get innerWidth => wrap_jso(JS("int", "#.innerWidth", this.raw));
13016
13017 /**
13018 * The name of this window.
13019 *
13020 * ## Other resources
13021 *
13022 * * [Window name]
13023 * (http://docs.webplatform.org/wiki/html/attributes/name_(window)) from
13024 * WebPlatform.org.
13025 */
13026 @DomName('Window.name')
13027 @DocsEditable()
13028 String get name => wrap_jso(JS("String", "#.name", this.raw));
13029 /**
13030 * The name of this window.
13031 *
13032 * ## Other resources
13033 *
13034 * * [Window name]
13035 * (http://docs.webplatform.org/wiki/html/attributes/name_(window)) from
13036 * WebPlatform.org.
13037 */
13038 @DomName('Window.name')
13039 @DocsEditable()
13040 void set name(String val) => JS("void", "#.name = #", this.raw, unwrap_jso(val ));
13041
13042 /**
13043 * The user agent accessing this window.
13044 *
13045 * ## Other resources
13046 *
13047 * * [The navigator object]
13048 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#th e-navigator-object)
13049 * from WHATWG.
13050 */
13051 @DomName('Window.navigator')
13052 @DocsEditable()
13053 Navigator get navigator => wrap_jso(JS("Navigator", "#.navigator", this.raw));
13054
13055 /**
13056 * Whether objects are drawn offscreen before being displayed.
13057 *
13058 * ## Other resources
13059 *
13060 * * [offscreenBuffering]
13061 * (http://docs.webplatform.org/wiki/dom/properties/offscreenBuffering) from
13062 * WebPlatform.org.
13063 */
13064 @DomName('Window.offscreenBuffering')
13065 @DocsEditable()
13066 @Experimental() // non-standard
13067 bool get offscreenBuffering => wrap_jso(JS("bool", "#.offscreenBuffering", thi s.raw));
13068
13069 @DomName('Window.opener')
13070 @DocsEditable()
13071 WindowBase get opener => _convertNativeToDart_Window(this._get_opener);
13072 @JSName('opener')
13073 @DomName('Window.opener')
13074 @DocsEditable()
13075 @Creates('Window|=Object')
13076 @Returns('Window|=Object')
13077 dynamic get _get_opener => wrap_jso(JS("dynamic", "#.opener", this.raw));
13078
13079 set opener(Window value) {
13080 JS("void", "#.raw.opener = #", this, unwrap_jso(value));
13081 }
13082
13083 @DomName('Window.orientation')
13084 @DocsEditable()
13085 @Experimental() // untriaged
13086 int get orientation => wrap_jso(JS("int", "#.orientation", this.raw));
13087
13088 /**
13089 * The height of this window including all user interface elements.
13090 *
13091 * ## Other resources
13092 *
13093 * * [outerHeight]
13094 * (http://docs.webplatform.org/wiki/css/cssom/properties/outerHeight) from
13095 * WebPlatform.org.
13096 */
13097 @DomName('Window.outerHeight')
13098 @DocsEditable()
13099 int get outerHeight => wrap_jso(JS("int", "#.outerHeight", this.raw));
13100
13101 /**
13102 * The width of the window including all user interface elements.
13103 *
13104 * ## Other resources
13105 *
13106 * * [outerWidth]
13107 * (http://docs.webplatform.org/wiki/css/cssom/properties/outerWidth) from
13108 * WebPlatform.org.
13109 */
13110 @DomName('Window.outerWidth')
13111 @DocsEditable()
13112 int get outerWidth => wrap_jso(JS("int", "#.outerWidth", this.raw));
13113
13114 @JSName('pageXOffset')
13115 /**
13116 * The distance this window has been scrolled horizontally.
13117 *
13118 * This attribute is an alias for [scrollX].
13119 *
13120 * ## Other resources
13121 *
13122 * * [The Screen interface specification]
13123 * (http://www.w3.org/TR/cssom-view/#screen) from W3C.
13124 * * [scrollX and pageXOffset]
13125 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollX) from MDN.
13126 */
13127 @DomName('Window.pageXOffset')
13128 @DocsEditable()
13129 double get _pageXOffset => wrap_jso(JS("double", "#.pageXOffset", this.raw));
13130
13131 @JSName('pageYOffset')
13132 /**
13133 * The distance this window has been scrolled vertically.
13134 *
13135 * This attribute is an alias for [scrollY].
13136 *
13137 * ## Other resources
13138 *
13139 * * [The Screen interface specification]
13140 * (http://www.w3.org/TR/cssom-view/#screen) from W3C.
13141 * * [scrollY and pageYOffset]
13142 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY) from MDN.
13143 */
13144 @DomName('Window.pageYOffset')
13145 @DocsEditable()
13146 double get _pageYOffset => wrap_jso(JS("double", "#.pageYOffset", this.raw));
13147
13148 @DomName('Window.parent')
13149 @DocsEditable()
13150 WindowBase get parent => _convertNativeToDart_Window(this._get_parent);
13151 @JSName('parent')
13152 @DomName('Window.parent')
13153 @DocsEditable()
13154 @Creates('Window|=Object')
13155 @Returns('Window|=Object')
13156 dynamic get _get_parent => wrap_jso(JS("dynamic", "#.parent", this.raw));
13157
13158 /**
13159 * The distance from the left side of the screen to the left side of this
13160 * window.
13161 *
13162 * ## Other resources
13163 *
13164 * * [The Screen interface specification]
13165 * (http://www.w3.org/TR/cssom-view/#screen) from W3C.
13166 */
13167 @DomName('Window.screenLeft')
13168 @DocsEditable()
13169 int get screenLeft => wrap_jso(JS("int", "#.screenLeft", this.raw));
13170
13171 /**
13172 * The distance from the top of the screen to the top of this window.
13173 *
13174 * ## Other resources
13175 *
13176 * * [The Screen interface specification]
13177 * (http://www.w3.org/TR/cssom-view/#screen) from W3C.
13178 */
13179 @DomName('Window.screenTop')
13180 @DocsEditable()
13181 int get screenTop => wrap_jso(JS("int", "#.screenTop", this.raw));
13182
13183 /**
13184 * The distance from the left side of the screen to the mouse pointer.
13185 *
13186 * ## Other resources
13187 *
13188 * * [The Screen interface specification]
13189 * (http://www.w3.org/TR/cssom-view/#screen) from W3C.
13190 */
13191 @DomName('Window.screenX')
13192 @DocsEditable()
13193 int get screenX => wrap_jso(JS("int", "#.screenX", this.raw));
13194
13195 /**
13196 * The distance from the top of the screen to the mouse pointer.
13197 *
13198 * ## Other resources
13199 *
13200 * * [The Screen interface specification]
13201 * (http://www.w3.org/TR/cssom-view/#screen) from W3C.
13202 */
13203 @DomName('Window.screenY')
13204 @DocsEditable()
13205 int get screenY => wrap_jso(JS("int", "#.screenY", this.raw));
13206
13207 /**
13208 * The current window.
13209 *
13210 * ## Other resources
13211 *
13212 * * [Window.self]
13213 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.self) from MDN.
13214 */
13215 @DomName('Window.self')
13216 @DocsEditable()
13217 WindowBase get self => _convertNativeToDart_Window(this._get_self);
13218 @JSName('self')
13219 /**
13220 * The current window.
13221 *
13222 * ## Other resources
13223 *
13224 * * [Window.self]
13225 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.self) from MDN.
13226 */
13227 @DomName('Window.self')
13228 @DocsEditable()
13229 @Creates('Window|=Object')
13230 @Returns('Window|=Object')
13231 dynamic get _get_self => wrap_jso(JS("dynamic", "#.self", this.raw));
13232
13233 /// *Deprecated*.
13234 @DomName('Window.status')
13235 @DocsEditable()
13236 String get status => wrap_jso(JS("String", "#.status", this.raw));
13237 /// *Deprecated*.
13238 @DomName('Window.status')
13239 @DocsEditable()
13240 void set status(String val) => JS("void", "#.status = #", this.raw, unwrap_jso (val));
13241
13242 @DomName('Window.top')
13243 @DocsEditable()
13244 WindowBase get top => _convertNativeToDart_Window(this._get_top);
13245 @JSName('top')
13246 @DomName('Window.top')
13247 @DocsEditable()
13248 @Creates('Window|=Object')
13249 @Returns('Window|=Object')
13250 dynamic get _get_top => wrap_jso(JS("dynamic", "#.top", this.raw));
13251
13252 /**
13253 * The current window.
13254 *
13255 * ## Other resources
13256 *
13257 * * [Window.window]
13258 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.window) from MDN.
13259 */
13260 @DomName('Window.window')
13261 @DocsEditable()
13262 WindowBase get window => _convertNativeToDart_Window(this._get_window);
13263 @JSName('window')
13264 /**
13265 * The current window.
13266 *
13267 * ## Other resources
13268 *
13269 * * [Window.window]
13270 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.window) from MDN.
13271 */
13272 @DomName('Window.window')
13273 @DocsEditable()
13274 @Creates('Window|=Object')
13275 @Returns('Window|=Object')
13276 dynamic get _get_window => wrap_jso(JS("dynamic", "#.window", this.raw));
13277
13278 @DomName('Window.__getter__')
13279 @DocsEditable()
13280 @Creates('Window|=Object')
13281 @Returns('Window|=Object')
13282 WindowBase __getter__(index_OR_name) {
13283 if ((index_OR_name is int)) {
13284 return _convertNativeToDart_Window(__getter___1(index_OR_name));
13285 }
13286 if ((index_OR_name is String)) {
13287 return _convertNativeToDart_Window(__getter___2(index_OR_name));
13288 }
13289 throw new ArgumentError("Incorrect number or type of arguments");
13290 }
13291 @JSName('__getter__')
13292 @DomName('Window.__getter__')
13293 @DocsEditable()
13294 @Creates('Window|=Object')
13295 @Returns('Window|=Object')
13296 __getter___1(int index) => wrap_jso(JS("", "#.raw.__getter__(#)", this, unwrap _jso(index)));
13297 @JSName('__getter__')
13298 @DomName('Window.__getter__')
13299 @DocsEditable()
13300 @Creates('Window|=Object')
13301 @Returns('Window|=Object')
13302 __getter___2(String name) => wrap_jso(JS("", "#.raw.__getter__(#)", this, unwr ap_jso(name)));
13303
13304 /**
13305 * Displays a modal alert to the user.
13306 *
13307 * ## Other resources
13308 *
13309 * * [User prompts]
13310 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#us er-prompts)
13311 * from WHATWG.
13312 */
13313 @DomName('Window.alert')
13314 @DocsEditable()
13315 void alert([String message]) {
13316 if (message != null) {
13317 _alert_1(message);
13318 return;
13319 }
13320 _alert_2();
13321 return;
13322 }
13323 @JSName('alert')
13324 /**
13325 * Displays a modal alert to the user.
13326 *
13327 * ## Other resources
13328 *
13329 * * [User prompts]
13330 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#us er-prompts)
13331 * from WHATWG.
13332 */
13333 @DomName('Window.alert')
13334 @DocsEditable()
13335 void _alert_1(message) => wrap_jso(JS("void ", "#.raw.alert(#)", this, unwrap_ jso(message)));
13336 @JSName('alert')
13337 /**
13338 * Displays a modal alert to the user.
13339 *
13340 * ## Other resources
13341 *
13342 * * [User prompts]
13343 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#us er-prompts)
13344 * from WHATWG.
13345 */
13346 @DomName('Window.alert')
13347 @DocsEditable()
13348 void _alert_2() => wrap_jso(JS("void ", "#.raw.alert()", this));
13349
13350 @DomName('Window.close')
13351 @DocsEditable()
13352 void close() {
13353 _close_1();
13354 return;
13355 }
13356 @JSName('close')
13357 @DomName('Window.close')
13358 @DocsEditable()
13359 void _close_1() => wrap_jso(JS("void ", "#.raw.close()", this));
13360
13361 /**
13362 * Displays a modal OK/Cancel prompt to the user.
13363 *
13364 * ## Other resources
13365 *
13366 * * [User prompts]
13367 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#us er-prompts)
13368 * from WHATWG.
13369 */
13370 @DomName('Window.confirm')
13371 @DocsEditable()
13372 bool confirm([String message]) {
13373 if (message != null) {
13374 return _confirm_1(message);
13375 }
13376 return _confirm_2();
13377 }
13378 @JSName('confirm')
13379 /**
13380 * Displays a modal OK/Cancel prompt to the user.
13381 *
13382 * ## Other resources
13383 *
13384 * * [User prompts]
13385 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#us er-prompts)
13386 * from WHATWG.
13387 */
13388 @DomName('Window.confirm')
13389 @DocsEditable()
13390 bool _confirm_1(message) => wrap_jso(JS("bool ", "#.raw.confirm(#)", this, unw rap_jso(message)));
13391 @JSName('confirm')
13392 /**
13393 * Displays a modal OK/Cancel prompt to the user.
13394 *
13395 * ## Other resources
13396 *
13397 * * [User prompts]
13398 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#us er-prompts)
13399 * from WHATWG.
13400 */
13401 @DomName('Window.confirm')
13402 @DocsEditable()
13403 bool _confirm_2() => wrap_jso(JS("bool ", "#.raw.confirm()", this));
13404
13405 /**
13406 * Finds text in this window.
13407 *
13408 * ## Other resources
13409 *
13410 * * [Window.find]
13411 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.find) from MDN.
13412 */
13413 @DomName('Window.find')
13414 @DocsEditable()
13415 @Experimental() // non-standard
13416 bool find(String string, bool caseSensitive, bool backwards, bool wrap, bool w holeWord, bool searchInFrames, bool showDialog) {
13417 return _find_1(string, caseSensitive, backwards, wrap, wholeWord, searchInFr ames, showDialog);
13418 }
13419 @JSName('find')
13420 /**
13421 * Finds text in this window.
13422 *
13423 * ## Other resources
13424 *
13425 * * [Window.find]
13426 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.find) from MDN.
13427 */
13428 @DomName('Window.find')
13429 @DocsEditable()
13430 @Experimental() // non-standard
13431 bool _find_1(string, caseSensitive, backwards, wrap, wholeWord, searchInFrames , showDialog) => wrap_jso(JS("bool ", "#.raw.find(#, #, #, #, #, #, #)", this, u nwrap_jso(string), unwrap_jso(caseSensitive), unwrap_jso(backwards), unwrap_jso( wrap), unwrap_jso(wholeWord), unwrap_jso(searchInFrames), unwrap_jso(showDialog) ));
13432
13433 @DomName('Window.getComputedStyle')
13434 @DocsEditable()
13435 CssStyleDeclaration _getComputedStyle(Element element, String pseudoElement) {
13436 return _getComputedStyle_1(element, pseudoElement);
13437 }
13438 @JSName('getComputedStyle')
13439 @DomName('Window.getComputedStyle')
13440 @DocsEditable()
13441 CssStyleDeclaration _getComputedStyle_1(Element element, pseudoElement) => wra p_jso(JS("CssStyleDeclaration ", "#.raw.getComputedStyle(#, #)", this, unwrap_js o(element), unwrap_jso(pseudoElement)));
13442
13443 /**
13444 * Moves this window.
13445 *
13446 * x and y can be negative.
13447 *
13448 * ## Other resources
13449 *
13450 * * [Window.moveBy]
13451 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.moveBy) from MDN.
13452 * * [Window.moveBy]
13453 * (http://dev.w3.org/csswg/cssom-view/#dom-window-moveby) from W3C.
13454 */
13455 @DomName('Window.moveBy')
13456 @DocsEditable()
13457 void moveBy(num x, num y) {
13458 _moveBy_1(x, y);
13459 return;
13460 }
13461 @JSName('moveBy')
13462 /**
13463 * Moves this window.
13464 *
13465 * x and y can be negative.
13466 *
13467 * ## Other resources
13468 *
13469 * * [Window.moveBy]
13470 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.moveBy) from MDN.
13471 * * [Window.moveBy]
13472 * (http://dev.w3.org/csswg/cssom-view/#dom-window-moveby) from W3C.
13473 */
13474 @DomName('Window.moveBy')
13475 @DocsEditable()
13476 void _moveBy_1(x, y) => wrap_jso(JS("void ", "#.raw.moveBy(#, #)", this, unwra p_jso(x), unwrap_jso(y)));
13477
13478 @DomName('Window.moveTo')
13479 @DocsEditable()
13480 void _moveTo(num x, num y) {
13481 _moveTo_1(x, y);
13482 return;
13483 }
13484 @JSName('moveTo')
13485 @DomName('Window.moveTo')
13486 @DocsEditable()
13487 void _moveTo_1(x, y) => wrap_jso(JS("void ", "#.raw.moveTo(#, #)", this, unwra p_jso(x), unwrap_jso(y)));
13488
13489 /**
13490 * Opens the print dialog for this window.
13491 *
13492 * ## Other resources
13493 *
13494 * * [Window.print]
13495 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.print) from MDN.
13496 */
13497 @DomName('Window.print')
13498 @DocsEditable()
13499 void print() {
13500 _print_1();
13501 return;
13502 }
13503 @JSName('print')
13504 /**
13505 * Opens the print dialog for this window.
13506 *
13507 * ## Other resources
13508 *
13509 * * [Window.print]
13510 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.print) from MDN.
13511 */
13512 @DomName('Window.print')
13513 @DocsEditable()
13514 void _print_1() => wrap_jso(JS("void ", "#.raw.print()", this));
13515
13516 /**
13517 * Resizes this window by an offset.
13518 *
13519 * ## Other resources
13520 *
13521 * * [Window resizeBy] (http://docs.webplatform.org/wiki/dom/methods/resizeBy)
13522 * from WebPlatform.org.
13523 */
13524 @DomName('Window.resizeBy')
13525 @DocsEditable()
13526 void resizeBy(num x, num y) {
13527 _resizeBy_1(x, y);
13528 return;
13529 }
13530 @JSName('resizeBy')
13531 /**
13532 * Resizes this window by an offset.
13533 *
13534 * ## Other resources
13535 *
13536 * * [Window resizeBy] (http://docs.webplatform.org/wiki/dom/methods/resizeBy)
13537 * from WebPlatform.org.
13538 */
13539 @DomName('Window.resizeBy')
13540 @DocsEditable()
13541 void _resizeBy_1(x, y) => wrap_jso(JS("void ", "#.raw.resizeBy(#, #)", this, u nwrap_jso(x), unwrap_jso(y)));
13542
13543 /**
13544 * Resizes this window to a specific width and height.
13545 *
13546 * ## Other resources
13547 *
13548 * * [Window resizeTo] (http://docs.webplatform.org/wiki/dom/methods/resizeTo)
13549 * from WebPlatform.org.
13550 */
13551 @DomName('Window.resizeTo')
13552 @DocsEditable()
13553 void resizeTo(num width, num height) {
13554 _resizeTo_1(width, height);
13555 return;
13556 }
13557 @JSName('resizeTo')
13558 /**
13559 * Resizes this window to a specific width and height.
13560 *
13561 * ## Other resources
13562 *
13563 * * [Window resizeTo] (http://docs.webplatform.org/wiki/dom/methods/resizeTo)
13564 * from WebPlatform.org.
13565 */
13566 @DomName('Window.resizeTo')
13567 @DocsEditable()
13568 void _resizeTo_1(width, height) => wrap_jso(JS("void ", "#.raw.resizeTo(#, #)" , this, unwrap_jso(width), unwrap_jso(height)));
13569
13570 /**
13571 * Scrolls the page horizontally and vertically to a specific point.
13572 *
13573 * This method is identical to [scrollTo].
13574 *
13575 * ## Other resources
13576 *
13577 * * [Window scroll] (http://docs.webplatform.org/wiki/dom/methods/scroll)
13578 * from WebPlatform.org.
13579 */
13580 @DomName('Window.scroll')
13581 @DocsEditable()
13582 void scroll(x, y, [Map scrollOptions]) {
13583 if ((y is num) && (x is num) && scrollOptions == null) {
13584 _scroll_1(x, y);
13585 return;
13586 }
13587 if (scrollOptions != null && (y is num) && (x is num)) {
13588 var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions);
13589 _scroll_2(x, y, scrollOptions_1);
13590 return;
13591 }
13592 if ((y is int) && (x is int) && scrollOptions == null) {
13593 _scroll_3(x, y);
13594 return;
13595 }
13596 if (scrollOptions != null && (y is int) && (x is int)) {
13597 var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions);
13598 _scroll_4(x, y, scrollOptions_1);
13599 return;
13600 }
13601 throw new ArgumentError("Incorrect number or type of arguments");
13602 }
13603 @JSName('scroll')
13604 /**
13605 * Scrolls the page horizontally and vertically to a specific point.
13606 *
13607 * This method is identical to [scrollTo].
13608 *
13609 * ## Other resources
13610 *
13611 * * [Window scroll] (http://docs.webplatform.org/wiki/dom/methods/scroll)
13612 * from WebPlatform.org.
13613 */
13614 @DomName('Window.scroll')
13615 @DocsEditable()
13616 void _scroll_1(num x, num y) => wrap_jso(JS("void ", "#.raw.scroll(#, #)", thi s, unwrap_jso(x), unwrap_jso(y)));
13617 @JSName('scroll')
13618 /**
13619 * Scrolls the page horizontally and vertically to a specific point.
13620 *
13621 * This method is identical to [scrollTo].
13622 *
13623 * ## Other resources
13624 *
13625 * * [Window scroll] (http://docs.webplatform.org/wiki/dom/methods/scroll)
13626 * from WebPlatform.org.
13627 */
13628 @DomName('Window.scroll')
13629 @DocsEditable()
13630 void _scroll_2(num x, num y, scrollOptions) => wrap_jso(JS("void ", "#.raw.scr oll(#, #, #)", this, unwrap_jso(x), unwrap_jso(y), unwrap_jso(scrollOptions)));
13631 @JSName('scroll')
13632 /**
13633 * Scrolls the page horizontally and vertically to a specific point.
13634 *
13635 * This method is identical to [scrollTo].
13636 *
13637 * ## Other resources
13638 *
13639 * * [Window scroll] (http://docs.webplatform.org/wiki/dom/methods/scroll)
13640 * from WebPlatform.org.
13641 */
13642 @DomName('Window.scroll')
13643 @DocsEditable()
13644 void _scroll_3(int x, int y) => wrap_jso(JS("void ", "#.raw.scroll(#, #)", thi s, unwrap_jso(x), unwrap_jso(y)));
13645 @JSName('scroll')
13646 /**
13647 * Scrolls the page horizontally and vertically to a specific point.
13648 *
13649 * This method is identical to [scrollTo].
13650 *
13651 * ## Other resources
13652 *
13653 * * [Window scroll] (http://docs.webplatform.org/wiki/dom/methods/scroll)
13654 * from WebPlatform.org.
13655 */
13656 @DomName('Window.scroll')
13657 @DocsEditable()
13658 void _scroll_4(int x, int y, scrollOptions) => wrap_jso(JS("void ", "#.raw.scr oll(#, #, #)", this, unwrap_jso(x), unwrap_jso(y), unwrap_jso(scrollOptions)));
13659
13660 /**
13661 * Scrolls the page horizontally and vertically by an offset.
13662 *
13663 * ## Other resources
13664 *
13665 * * [Window scrollBy] (http://docs.webplatform.org/wiki/dom/methods/scrollBy)
13666 * from WebPlatform.org.
13667 */
13668 @DomName('Window.scrollBy')
13669 @DocsEditable()
13670 void scrollBy(x, y, [Map scrollOptions]) {
13671 if ((y is num) && (x is num) && scrollOptions == null) {
13672 _scrollBy_1(x, y);
13673 return;
13674 }
13675 if (scrollOptions != null && (y is num) && (x is num)) {
13676 var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions);
13677 _scrollBy_2(x, y, scrollOptions_1);
13678 return;
13679 }
13680 if ((y is int) && (x is int) && scrollOptions == null) {
13681 _scrollBy_3(x, y);
13682 return;
13683 }
13684 if (scrollOptions != null && (y is int) && (x is int)) {
13685 var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions);
13686 _scrollBy_4(x, y, scrollOptions_1);
13687 return;
13688 }
13689 throw new ArgumentError("Incorrect number or type of arguments");
13690 }
13691 @JSName('scrollBy')
13692 /**
13693 * Scrolls the page horizontally and vertically by an offset.
13694 *
13695 * ## Other resources
13696 *
13697 * * [Window scrollBy] (http://docs.webplatform.org/wiki/dom/methods/scrollBy)
13698 * from WebPlatform.org.
13699 */
13700 @DomName('Window.scrollBy')
13701 @DocsEditable()
13702 void _scrollBy_1(num x, num y) => wrap_jso(JS("void ", "#.raw.scrollBy(#, #)", this, unwrap_jso(x), unwrap_jso(y)));
13703 @JSName('scrollBy')
13704 /**
13705 * Scrolls the page horizontally and vertically by an offset.
13706 *
13707 * ## Other resources
13708 *
13709 * * [Window scrollBy] (http://docs.webplatform.org/wiki/dom/methods/scrollBy)
13710 * from WebPlatform.org.
13711 */
13712 @DomName('Window.scrollBy')
13713 @DocsEditable()
13714 void _scrollBy_2(num x, num y, scrollOptions) => wrap_jso(JS("void ", "#.raw.s crollBy(#, #, #)", this, unwrap_jso(x), unwrap_jso(y), unwrap_jso(scrollOptions) ));
13715 @JSName('scrollBy')
13716 /**
13717 * Scrolls the page horizontally and vertically by an offset.
13718 *
13719 * ## Other resources
13720 *
13721 * * [Window scrollBy] (http://docs.webplatform.org/wiki/dom/methods/scrollBy)
13722 * from WebPlatform.org.
13723 */
13724 @DomName('Window.scrollBy')
13725 @DocsEditable()
13726 void _scrollBy_3(int x, int y) => wrap_jso(JS("void ", "#.raw.scrollBy(#, #)", this, unwrap_jso(x), unwrap_jso(y)));
13727 @JSName('scrollBy')
13728 /**
13729 * Scrolls the page horizontally and vertically by an offset.
13730 *
13731 * ## Other resources
13732 *
13733 * * [Window scrollBy] (http://docs.webplatform.org/wiki/dom/methods/scrollBy)
13734 * from WebPlatform.org.
13735 */
13736 @DomName('Window.scrollBy')
13737 @DocsEditable()
13738 void _scrollBy_4(int x, int y, scrollOptions) => wrap_jso(JS("void ", "#.raw.s crollBy(#, #, #)", this, unwrap_jso(x), unwrap_jso(y), unwrap_jso(scrollOptions) ));
13739
13740 /**
13741 * Scrolls the page horizontally and vertically to a specific point.
13742 *
13743 * This method is identical to [scroll].
13744 *
13745 * ## Other resources
13746 *
13747 * * [Window scrollTo] (http://docs.webplatform.org/wiki/dom/methods/scrollTo)
13748 * from WebPlatform.org.
13749 */
13750 @DomName('Window.scrollTo')
13751 @DocsEditable()
13752 void scrollTo(x, y, [Map scrollOptions]) {
13753 if ((y is num) && (x is num) && scrollOptions == null) {
13754 _scrollTo_1(x, y);
13755 return;
13756 }
13757 if (scrollOptions != null && (y is num) && (x is num)) {
13758 var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions);
13759 _scrollTo_2(x, y, scrollOptions_1);
13760 return;
13761 }
13762 if ((y is int) && (x is int) && scrollOptions == null) {
13763 _scrollTo_3(x, y);
13764 return;
13765 }
13766 if (scrollOptions != null && (y is int) && (x is int)) {
13767 var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions);
13768 _scrollTo_4(x, y, scrollOptions_1);
13769 return;
13770 }
13771 throw new ArgumentError("Incorrect number or type of arguments");
13772 }
13773 @JSName('scrollTo')
13774 /**
13775 * Scrolls the page horizontally and vertically to a specific point.
13776 *
13777 * This method is identical to [scroll].
13778 *
13779 * ## Other resources
13780 *
13781 * * [Window scrollTo] (http://docs.webplatform.org/wiki/dom/methods/scrollTo)
13782 * from WebPlatform.org.
13783 */
13784 @DomName('Window.scrollTo')
13785 @DocsEditable()
13786 void _scrollTo_1(num x, num y) => wrap_jso(JS("void ", "#.raw.scrollTo(#, #)", this, unwrap_jso(x), unwrap_jso(y)));
13787 @JSName('scrollTo')
13788 /**
13789 * Scrolls the page horizontally and vertically to a specific point.
13790 *
13791 * This method is identical to [scroll].
13792 *
13793 * ## Other resources
13794 *
13795 * * [Window scrollTo] (http://docs.webplatform.org/wiki/dom/methods/scrollTo)
13796 * from WebPlatform.org.
13797 */
13798 @DomName('Window.scrollTo')
13799 @DocsEditable()
13800 void _scrollTo_2(num x, num y, scrollOptions) => wrap_jso(JS("void ", "#.raw.s crollTo(#, #, #)", this, unwrap_jso(x), unwrap_jso(y), unwrap_jso(scrollOptions) ));
13801 @JSName('scrollTo')
13802 /**
13803 * Scrolls the page horizontally and vertically to a specific point.
13804 *
13805 * This method is identical to [scroll].
13806 *
13807 * ## Other resources
13808 *
13809 * * [Window scrollTo] (http://docs.webplatform.org/wiki/dom/methods/scrollTo)
13810 * from WebPlatform.org.
13811 */
13812 @DomName('Window.scrollTo')
13813 @DocsEditable()
13814 void _scrollTo_3(int x, int y) => wrap_jso(JS("void ", "#.raw.scrollTo(#, #)", this, unwrap_jso(x), unwrap_jso(y)));
13815 @JSName('scrollTo')
13816 /**
13817 * Scrolls the page horizontally and vertically to a specific point.
13818 *
13819 * This method is identical to [scroll].
13820 *
13821 * ## Other resources
13822 *
13823 * * [Window scrollTo] (http://docs.webplatform.org/wiki/dom/methods/scrollTo)
13824 * from WebPlatform.org.
13825 */
13826 @DomName('Window.scrollTo')
13827 @DocsEditable()
13828 void _scrollTo_4(int x, int y, scrollOptions) => wrap_jso(JS("void ", "#.raw.s crollTo(#, #, #)", this, unwrap_jso(x), unwrap_jso(y), unwrap_jso(scrollOptions) ));
13829
13830 /**
13831 * Opens a new page as a modal dialog.
13832 *
13833 * ## Other resources
13834 *
13835 * * [Dialogs implemented using separate documents]
13836 * (http://www.w3.org/html/wg/drafts/html/master/webappapis.html#dialogs-imple mented-using-separate-documents)
13837 * from W3C.
13838 */
13839 @DomName('Window.showModalDialog')
13840 @DocsEditable()
13841 @Creates('Null')
13842 Object showModalDialog(String url, [Object dialogArgs, String featureArgs]) {
13843 if (featureArgs != null) {
13844 return _showModalDialog_1(url, dialogArgs, featureArgs);
13845 }
13846 if (dialogArgs != null) {
13847 return _showModalDialog_2(url, dialogArgs);
13848 }
13849 return _showModalDialog_3(url);
13850 }
13851 @JSName('showModalDialog')
13852 /**
13853 * Opens a new page as a modal dialog.
13854 *
13855 * ## Other resources
13856 *
13857 * * [Dialogs implemented using separate documents]
13858 * (http://www.w3.org/html/wg/drafts/html/master/webappapis.html#dialogs-imple mented-using-separate-documents)
13859 * from W3C.
13860 */
13861 @DomName('Window.showModalDialog')
13862 @DocsEditable()
13863 @Creates('Null')
13864 Object _showModalDialog_1(url, dialogArgs, featureArgs) => wrap_jso(JS("Object ", "#.raw.showModalDialog(#, #, #)", this, unwrap_jso(url), unwrap_jso(dialogAr gs), unwrap_jso(featureArgs)));
13865 @JSName('showModalDialog')
13866 /**
13867 * Opens a new page as a modal dialog.
13868 *
13869 * ## Other resources
13870 *
13871 * * [Dialogs implemented using separate documents]
13872 * (http://www.w3.org/html/wg/drafts/html/master/webappapis.html#dialogs-imple mented-using-separate-documents)
13873 * from W3C.
13874 */
13875 @DomName('Window.showModalDialog')
13876 @DocsEditable()
13877 @Creates('Null')
13878 Object _showModalDialog_2(url, dialogArgs) => wrap_jso(JS("Object ", "#.raw.sh owModalDialog(#, #)", this, unwrap_jso(url), unwrap_jso(dialogArgs)));
13879 @JSName('showModalDialog')
13880 /**
13881 * Opens a new page as a modal dialog.
13882 *
13883 * ## Other resources
13884 *
13885 * * [Dialogs implemented using separate documents]
13886 * (http://www.w3.org/html/wg/drafts/html/master/webappapis.html#dialogs-imple mented-using-separate-documents)
13887 * from W3C.
13888 */
13889 @DomName('Window.showModalDialog')
13890 @DocsEditable()
13891 @Creates('Null')
13892 Object _showModalDialog_3(url) => wrap_jso(JS("Object ", "#.raw.showModalDialo g(#)", this, unwrap_jso(url)));
13893
13894 /**
13895 * Stops the window from loading.
13896 *
13897 * ## Other resources
13898 *
13899 * * [The Window object]
13900 * (http://www.w3.org/html/wg/drafts/html/master/browsers.html#the-window-obje ct)
13901 * from W3C.
13902 */
13903 @DomName('Window.stop')
13904 @DocsEditable()
13905 void stop() {
13906 _stop_1();
13907 return;
13908 }
13909 @JSName('stop')
13910 /**
13911 * Stops the window from loading.
13912 *
13913 * ## Other resources
13914 *
13915 * * [The Window object]
13916 * (http://www.w3.org/html/wg/drafts/html/master/browsers.html#the-window-obje ct)
13917 * from W3C.
13918 */
13919 @DomName('Window.stop')
13920 @DocsEditable()
13921 void _stop_1() => wrap_jso(JS("void ", "#.raw.stop()", this));
13922
13923 /// Stream of `contentloaded` events handled by this [Window].
13924 @DomName('Window.onDOMContentLoaded')
13925 @DocsEditable()
13926 Stream<Event> get onContentLoaded => contentLoadedEvent.forTarget(this);
13927
13928 /// Stream of `search` events handled by this [Window].
13929 @DomName('Window.onsearch')
13930 @DocsEditable()
13931 // http://www.w3.org/TR/html-markup/input.search.html
13932 @Experimental()
13933 Stream<Event> get onSearch => Element.searchEvent.forTarget(this);
13934
13935
13936
13937 /**
13938 * Moves this window to a specific position.
13939 *
13940 * x and y can be negative.
13941 *
13942 * ## Other resources
13943 *
13944 * * [Window.moveTo]
13945 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.moveTo) from MDN.
13946 * * [Window.moveTo]
13947 * (http://dev.w3.org/csswg/cssom-view/#dom-window-moveto) from W3C.
13948 */
13949 void moveTo(Point p) {
13950 _moveTo(p.x, p.y);
13951 }
13952
13953 @DomName('Window.pageXOffset')
13954 @DocsEditable()
13955 int get pageXOffset => JS('num', '#.pageXOffset', this.raw).round();
13956
13957 @DomName('Window.pageYOffset')
13958 @DocsEditable()
13959 int get pageYOffset => JS('num', '#.pageYOffset', this.raw).round();
13960
13961 /**
13962 * The distance this window has been scrolled horizontally.
13963 *
13964 * ## Other resources
13965 *
13966 * * [The Screen interface specification]
13967 * (http://www.w3.org/TR/cssom-view/#screen) from W3C.
13968 * * [scrollX]
13969 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollX) from MDN.
13970 */
13971 @DomName('Window.scrollX')
13972 @DocsEditable()
13973 int get scrollX => JS('bool', '("scrollX" in #)', this.raw) ?
13974 JS('num', '#.scrollX', this.raw).round() :
13975 document.documentElement.scrollLeft;
13976
13977 /**
13978 * The distance this window has been scrolled vertically.
13979 *
13980 * ## Other resources
13981 *
13982 * * [The Screen interface specification]
13983 * (http://www.w3.org/TR/cssom-view/#screen) from W3C.
13984 * * [scrollY]
13985 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY) from MDN.
13986 */
13987 @DomName('Window.scrollY')
13988 @DocsEditable()
13989 int get scrollY => JS('bool', '("scrollY" in #)', this.raw) ?
13990 JS('num', '#.scrollY', this.raw).round() :
13991 document.documentElement.scrollTop;
13992
13993 void postMessage(var message, String targetOrigin, [List messagePorts]) {
13994 if (messagePorts != null) {
13995 throw 'postMessage unsupported';
13996 }
13997 JS('void', '#.postMessage(#, #)', this.raw, message, targetOrigin);
13998 }
13999 }
14000
14001
14002 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
14003 // for details. All rights reserved. Use of this source code is governed by a
14004 // BSD-style license that can be found in the LICENSE file.
14005
14006
14007 @DocsEditable()
14008 @DomName('Attr')
14009 @Native("Attr")
14010 class _Attr extends Node {
14011 // To suppress missing implicit constructor warnings.
14012 factory _Attr._() { throw new UnsupportedError("Not supported"); }
14013
14014
14015 @Deprecated("Internal Use Only")
14016 static _Attr internalCreate_Attr() {
14017 return new _Attr.internal_();
14018 }
14019
14020 @Deprecated("Internal Use Only")
14021 _Attr.internal_() : super.internal_();
14022
14023
14024 // Use implementation from Node.
14025 // final String _localName;
14026
14027 @DomName('Attr.name')
14028 @DocsEditable()
14029 String get name => wrap_jso(JS("String", "#.name", this.raw));
14030
14031 // Use implementation from Node.
14032 // final String _namespaceUri;
14033
14034 // Use implementation from Node.
14035 // final String nodeValue;
14036
14037 // Shadowing definition.
14038 String get text => wrap_jso(JS("String", "#.raw.textContent", this));
14039
14040 set text(String value) {
14041 JS("void", "#.raw.textContent = #", this, unwrap_jso(value));
14042 }
14043
14044 @DomName('Attr.value')
14045 @DocsEditable()
14046 String get value => wrap_jso(JS("String", "#.value", this.raw));
14047 @DomName('Attr.value')
14048 @DocsEditable()
14049 void set value(String val) => JS("void", "#.value = #", this.raw, unwrap_jso(v al));
14050 }
14051 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
14052 // for details. All rights reserved. Use of this source code is governed by a
14053 // BSD-style license that can be found in the LICENSE file.
14054
14055
14056 @DocsEditable()
14057 @DomName('ClientRect')
14058 @Native("ClientRect")
14059 class _ClientRect extends DartHtmlDomObject implements Rectangle {
14060
14061 // NOTE! All code below should be common with RectangleBase.
14062 String toString() {
14063 return 'Rectangle ($left, $top) $width x $height';
14064 }
14065
14066 bool operator ==(other) {
14067 if (other is !Rectangle) return false;
14068 return left == other.left && top == other.top && width == other.width &&
14069 height == other.height;
14070 }
14071
14072 int get hashCode => _JenkinsSmiHash.hash4(left.hashCode, top.hashCode,
14073 width.hashCode, height.hashCode);
14074
14075 /**
14076 * Computes the intersection of `this` and [other].
14077 *
14078 * The intersection of two axis-aligned rectangles, if any, is always another
14079 * axis-aligned rectangle.
14080 *
14081 * Returns the intersection of this and `other`, or null if they don't
14082 * intersect.
14083 */
14084 Rectangle intersection(Rectangle other) {
14085 var x0 = max(left, other.left);
14086 var x1 = min(left + width, other.left + other.width);
14087
14088 if (x0 <= x1) {
14089 var y0 = max(top, other.top);
14090 var y1 = min(top + height, other.top + other.height);
14091
14092 if (y0 <= y1) {
14093 return new Rectangle(x0, y0, x1 - x0, y1 - y0);
14094 }
14095 }
14096 return null;
14097 }
14098
14099
14100 /**
14101 * Returns true if `this` intersects [other].
14102 */
14103 bool intersects(Rectangle<num> other) {
14104 return (left <= other.left + other.width &&
14105 other.left <= left + width &&
14106 top <= other.top + other.height &&
14107 other.top <= top + height);
14108 }
14109
14110 /**
14111 * Returns a new rectangle which completely contains `this` and [other].
14112 */
14113 Rectangle boundingBox(Rectangle other) {
14114 var right = max(this.left + this.width, other.left + other.width);
14115 var bottom = max(this.top + this.height, other.top + other.height);
14116
14117 var left = min(this.left, other.left);
14118 var top = min(this.top, other.top);
14119
14120 return new Rectangle(left, top, right - left, bottom - top);
14121 }
14122
14123 /**
14124 * Tests whether `this` entirely contains [another].
14125 */
14126 bool containsRectangle(Rectangle<num> another) {
14127 return left <= another.left &&
14128 left + width >= another.left + another.width &&
14129 top <= another.top &&
14130 top + height >= another.top + another.height;
14131 }
14132
14133 /**
14134 * Tests whether [another] is inside or along the edges of `this`.
14135 */
14136 bool containsPoint(Point<num> another) {
14137 return another.x >= left &&
14138 another.x <= left + width &&
14139 another.y >= top &&
14140 another.y <= top + height;
14141 }
14142
14143 Point get topLeft => new Point(this.left, this.top);
14144 Point get topRight => new Point(this.left + this.width, this.top);
14145 Point get bottomRight => new Point(this.left + this.width,
14146 this.top + this.height);
14147 Point get bottomLeft => new Point(this.left,
14148 this.top + this.height);
14149
14150 // To suppress missing implicit constructor warnings.
14151 factory _ClientRect._() { throw new UnsupportedError("Not supported"); }
14152
14153 @Deprecated("Internal Use Only")
14154 static _ClientRect internalCreate_ClientRect() {
14155 return new _ClientRect.internal_();
14156 }
14157
14158 @Deprecated("Internal Use Only")
14159 _ClientRect.internal_() { }
14160
14161
14162 @DomName('ClientRect.bottom')
14163 @DocsEditable()
14164 double get bottom => wrap_jso(JS("double", "#.bottom", this.raw));
14165
14166 @DomName('ClientRect.height')
14167 @DocsEditable()
14168 double get height => wrap_jso(JS("double", "#.height", this.raw));
14169
14170 @DomName('ClientRect.left')
14171 @DocsEditable()
14172 double get left => wrap_jso(JS("double", "#.left", this.raw));
14173
14174 @DomName('ClientRect.right')
14175 @DocsEditable()
14176 double get right => wrap_jso(JS("double", "#.right", this.raw));
14177
14178 @DomName('ClientRect.top')
14179 @DocsEditable()
14180 double get top => wrap_jso(JS("double", "#.top", this.raw));
14181
14182 @DomName('ClientRect.width')
14183 @DocsEditable()
14184 double get width => wrap_jso(JS("double", "#.width", this.raw));
14185 }
14186
14187 /**
14188 * This is the [Jenkins hash function][1] but using masking to keep
14189 * values in SMI range.
14190 *
14191 * [1]: http://en.wikipedia.org/wiki/Jenkins_hash_function
14192 *
14193 * Use:
14194 * Hash each value with the hash of the previous value, then get the final
14195 * hash by calling finish.
14196 *
14197 * var hash = 0;
14198 * for (var value in values) {
14199 * hash = JenkinsSmiHash.combine(hash, value.hashCode);
14200 * }
14201 * hash = JenkinsSmiHash.finish(hash);
14202 */
14203 class _JenkinsSmiHash {
14204 // TODO(11617): This class should be optimized and standardized elsewhere.
14205
14206 static int combine(int hash, int value) {
14207 hash = 0x1fffffff & (hash + value);
14208 hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
14209 return hash ^ (hash >> 6);
14210 }
14211
14212 static int finish(int hash) {
14213 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
14214 hash = hash ^ (hash >> 11);
14215 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
14216 }
14217
14218 static int hash2(a, b) => finish(combine(combine(0, a), b));
14219
14220 static int hash4(a, b, c, d) =>
14221 finish(combine(combine(combine(combine(0, a), b), c), d));
14222 }
14223 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
14224 // for details. All rights reserved. Use of this source code is governed by a
14225 // BSD-style license that can be found in the LICENSE file.
14226
14227
14228 @DocsEditable()
14229 @DomName('NamedNodeMap')
14230 // http://dom.spec.whatwg.org/#namednodemap
14231 @deprecated // deprecated
14232 @Native("NamedNodeMap,MozNamedAttrMap")
14233 class _NamedNodeMap extends DartHtmlDomObject with ListMixin<Node>, ImmutableLis tMixin<Node> implements JavaScriptIndexingBehavior, List<Node> {
14234 // To suppress missing implicit constructor warnings.
14235 factory _NamedNodeMap._() { throw new UnsupportedError("Not supported"); }
14236
14237 @Deprecated("Internal Use Only")
14238 static _NamedNodeMap internalCreate_NamedNodeMap() {
14239 return new _NamedNodeMap.internal_();
14240 }
14241
14242 @Deprecated("Internal Use Only")
14243 _NamedNodeMap.internal_() { }
14244
14245 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical( this, other);
14246 int get hashCode => unwrap_jso(this).hashCode;
14247
14248 @DomName('NamedNodeMap.length')
14249 @DocsEditable()
14250 int get length => wrap_jso(JS("int", "#.length", this.raw));
14251
14252 Node operator[](int index) {
14253 if (JS("bool", "# >>> 0 !== # || # >= #", index,
14254 index, index, length))
14255 throw new RangeError.index(index, this);
14256 return wrap_jso(JS("Node", "#[#]", this.raw, index));
14257 }
14258 void operator[]=(int index, Node value) {
14259 throw new UnsupportedError("Cannot assign element of immutable List.");
14260 }
14261 // -- start List<Node> mixins.
14262 // Node is the element type.
14263
14264
14265 set length(int value) {
14266 throw new UnsupportedError("Cannot resize immutable List.");
14267 }
14268
14269 Node get first {
14270 if (this.length > 0) {
14271 return wrap_jso(JS('Node', '#[0]', this.raw));
14272 }
14273 throw new StateError("No elements");
14274 }
14275
14276 Node get last {
14277 int len = this.length;
14278 if (len > 0) {
14279 return wrap_jso(JS('Node', '#[#]', this.raw, len - 1));
14280 }
14281 throw new StateError("No elements");
14282 }
14283
14284 Node get single {
14285 int len = this.length;
14286 if (len == 1) {
14287 return wrap_jso(JS('Node', '#[0]', this.raw));
14288 }
14289 if (len == 0) throw new StateError("No elements");
14290 throw new StateError("More than one element");
14291 }
14292
14293 Node elementAt(int index) => this[index];
14294 // -- end List<Node> mixins.
14295
14296 @DomName('NamedNodeMap.__getter__')
14297 @DocsEditable()
14298 Node __getter__(String name) {
14299 return __getter___1(name);
14300 }
14301 @JSName('__getter__')
14302 @DomName('NamedNodeMap.__getter__')
14303 @DocsEditable()
14304 Node __getter___1(name) => wrap_jso(JS("Node ", "#.raw.__getter__(#)", this, u nwrap_jso(name)));
14305
14306 @DomName('NamedNodeMap.getNamedItem')
14307 @DocsEditable()
14308 Node getNamedItem(String name) {
14309 return _getNamedItem_1(name);
14310 }
14311 @JSName('getNamedItem')
14312 @DomName('NamedNodeMap.getNamedItem')
14313 @DocsEditable()
14314 Node _getNamedItem_1(name) => wrap_jso(JS("Node ", "#.raw.getNamedItem(#)", th is, unwrap_jso(name)));
14315
14316 @DomName('NamedNodeMap.getNamedItemNS')
14317 @DocsEditable()
14318 Node getNamedItemNS(String namespaceURI, String localName) {
14319 return _getNamedItemNS_1(namespaceURI, localName);
14320 }
14321 @JSName('getNamedItemNS')
14322 @DomName('NamedNodeMap.getNamedItemNS')
14323 @DocsEditable()
14324 Node _getNamedItemNS_1(namespaceURI, localName) => wrap_jso(JS("Node ", "#.raw .getNamedItemNS(#, #)", this, unwrap_jso(namespaceURI), unwrap_jso(localName)));
14325
14326 @DomName('NamedNodeMap.item')
14327 @DocsEditable()
14328 Node item(int index) {
14329 return _item_1(index);
14330 }
14331 @JSName('item')
14332 @DomName('NamedNodeMap.item')
14333 @DocsEditable()
14334 Node _item_1(index) => wrap_jso(JS("Node ", "#.raw.item(#)", this, unwrap_jso( index)));
14335
14336 @DomName('NamedNodeMap.removeNamedItem')
14337 @DocsEditable()
14338 Node removeNamedItem(String name) {
14339 return _removeNamedItem_1(name);
14340 }
14341 @JSName('removeNamedItem')
14342 @DomName('NamedNodeMap.removeNamedItem')
14343 @DocsEditable()
14344 Node _removeNamedItem_1(name) => wrap_jso(JS("Node ", "#.raw.removeNamedItem(# )", this, unwrap_jso(name)));
14345
14346 @DomName('NamedNodeMap.removeNamedItemNS')
14347 @DocsEditable()
14348 Node removeNamedItemNS(String namespaceURI, String localName) {
14349 return _removeNamedItemNS_1(namespaceURI, localName);
14350 }
14351 @JSName('removeNamedItemNS')
14352 @DomName('NamedNodeMap.removeNamedItemNS')
14353 @DocsEditable()
14354 Node _removeNamedItemNS_1(namespaceURI, localName) => wrap_jso(JS("Node ", "#. raw.removeNamedItemNS(#, #)", this, unwrap_jso(namespaceURI), unwrap_jso(localNa me)));
14355
14356 @DomName('NamedNodeMap.setNamedItem')
14357 @DocsEditable()
14358 Node setNamedItem(Node node) {
14359 return _setNamedItem_1(node);
14360 }
14361 @JSName('setNamedItem')
14362 @DomName('NamedNodeMap.setNamedItem')
14363 @DocsEditable()
14364 Node _setNamedItem_1(Node node) => wrap_jso(JS("Node ", "#.raw.setNamedItem(#) ", this, unwrap_jso(node)));
14365
14366 @DomName('NamedNodeMap.setNamedItemNS')
14367 @DocsEditable()
14368 Node setNamedItemNS(Node node) {
14369 return _setNamedItemNS_1(node);
14370 }
14371 @JSName('setNamedItemNS')
14372 @DomName('NamedNodeMap.setNamedItemNS')
14373 @DocsEditable()
14374 Node _setNamedItemNS_1(Node node) => wrap_jso(JS("Node ", "#.raw.setNamedItemN S(#)", this, unwrap_jso(node)));
14375 }
14376 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
14377 // for details. All rights reserved. Use of this source code is governed by a
14378 // BSD-style license that can be found in the LICENSE file.
14379
14380
14381 @DocsEditable()
14382 @DomName('XMLHttpRequestProgressEvent')
14383 @Experimental() // nonstandard
14384 @Native("XMLHttpRequestProgressEvent")
14385 class _XMLHttpRequestProgressEvent extends ProgressEvent {
14386 // To suppress missing implicit constructor warnings.
14387 factory _XMLHttpRequestProgressEvent._() { throw new UnsupportedError("Not sup ported"); }
14388
14389
14390 @Deprecated("Internal Use Only")
14391 static _XMLHttpRequestProgressEvent internalCreate_XMLHttpRequestProgressEvent () {
14392 return new _XMLHttpRequestProgressEvent.internal_();
14393 }
14394
14395 @Deprecated("Internal Use Only")
14396 _XMLHttpRequestProgressEvent.internal_() : super.internal_();
14397
14398 }
14399 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
14400 // for details. All rights reserved. Use of this source code is governed by a
14401 // BSD-style license that can be found in the LICENSE file.
14402
14403
14404 abstract class _AttributeMap implements Map<String, String> {
14405 final Element _element;
14406
14407 _AttributeMap(this._element);
14408
14409 void addAll(Map<String, String> other) {
14410 other.forEach((k, v) { this[k] = v; });
14411 }
14412
14413 bool containsValue(Object value) {
14414 for (var v in this.values) {
14415 if (value == v) {
14416 return true;
14417 }
14418 }
14419 return false;
14420 }
14421
14422 String putIfAbsent(String key, String ifAbsent()) {
14423 if (!containsKey(key)) {
14424 this[key] = ifAbsent();
14425 }
14426 return this[key];
14427 }
14428
14429 void clear() {
14430 for (var key in keys) {
14431 remove(key);
14432 }
14433 }
14434
14435 void forEach(void f(String key, String value)) {
14436 for (var key in keys) {
14437 var value = this[key];
14438 f(key, value);
14439 }
14440 }
14441
14442 Iterable<String> get keys {
14443 // TODO: generate a lazy collection instead.
14444 var attributes = _element._attributes;
14445 var keys = new List<String>();
14446 for (int i = 0, len = attributes.length; i < len; i++) {
14447 if (_matches(attributes[i])) {
14448 keys.add(attributes[i].name);
14449 }
14450 }
14451 return keys;
14452 }
14453
14454 Iterable<String> get values {
14455 // TODO: generate a lazy collection instead.
14456 var attributes = _element._attributes;
14457 var values = new List<String>();
14458 for (int i = 0, len = attributes.length; i < len; i++) {
14459 if (_matches(attributes[i])) {
14460 values.add(attributes[i].value);
14461 }
14462 }
14463 return values;
14464 }
14465
14466 /**
14467 * Returns true if there is no {key, value} pair in the map.
14468 */
14469 bool get isEmpty {
14470 return length == 0;
14471 }
14472
14473 /**
14474 * Returns true if there is at least one {key, value} pair in the map.
14475 */
14476 bool get isNotEmpty => !isEmpty;
14477
14478 /**
14479 * Checks to see if the node should be included in this map.
14480 */
14481 bool _matches(Node node);
14482 }
14483
14484 /**
14485 * Wrapper to expose [Element.attributes] as a typed map.
14486 */
14487 class _ElementAttributeMap extends _AttributeMap {
14488
14489 _ElementAttributeMap(Element element): super(element);
14490
14491 bool containsKey(Object key) {
14492 return _element._hasAttribute(key);
14493 }
14494
14495 String operator [](Object key) {
14496 return _element.getAttribute(key);
14497 }
14498
14499 void operator []=(String key, String value) {
14500 _element.setAttribute(key, value);
14501 }
14502
14503 String remove(Object key) {
14504 String value = _element.getAttribute(key);
14505 _element._removeAttribute(key);
14506 return value;
14507 }
14508
14509 /**
14510 * The number of {key, value} pairs in the map.
14511 */
14512 int get length {
14513 return keys.length;
14514 }
14515
14516 bool _matches(Node node) => node._namespaceUri == null;
14517 }
14518
14519 /**
14520 * Wrapper to expose namespaced attributes as a typed map.
14521 */
14522 class _NamespacedAttributeMap extends _AttributeMap {
14523
14524 final String _namespace;
14525
14526 _NamespacedAttributeMap(Element element, this._namespace): super(element);
14527
14528 bool containsKey(Object key) {
14529 return _element._hasAttributeNS(_namespace, key);
14530 }
14531
14532 String operator [](Object key) {
14533 return _element.getAttributeNS(_namespace, key);
14534 }
14535
14536 void operator []=(String key, String value) {
14537 _element.setAttributeNS(_namespace, key, value);
14538 }
14539
14540 String remove(Object key) {
14541 String value = this[key];
14542 _element._removeAttributeNS(_namespace, key);
14543 return value;
14544 }
14545
14546 /**
14547 * The number of {key, value} pairs in the map.
14548 */
14549 int get length {
14550 return keys.length;
14551 }
14552
14553 bool _matches(Node node) => node._namespaceUri == _namespace;
14554 }
14555
14556
14557 /**
14558 * Provides a Map abstraction on top of data-* attributes, similar to the
14559 * dataSet in the old DOM.
14560 */
14561 class _DataAttributeMap implements Map<String, String> {
14562
14563 final Map<String, String> _attributes;
14564
14565 _DataAttributeMap(this._attributes);
14566
14567 // interface Map
14568
14569 void addAll(Map<String, String> other) {
14570 other.forEach((k, v) { this[k] = v; });
14571 }
14572
14573 // TODO: Use lazy iterator when it is available on Map.
14574 bool containsValue(Object value) => values.any((v) => v == value);
14575
14576 bool containsKey(Object key) => _attributes.containsKey(_attr(key));
14577
14578 String operator [](Object key) => _attributes[_attr(key)];
14579
14580 void operator []=(String key, String value) {
14581 _attributes[_attr(key)] = value;
14582 }
14583
14584 String putIfAbsent(String key, String ifAbsent()) =>
14585 _attributes.putIfAbsent(_attr(key), ifAbsent);
14586
14587 String remove(Object key) => _attributes.remove(_attr(key));
14588
14589 void clear() {
14590 // Needs to operate on a snapshot since we are mutating the collection.
14591 for (String key in keys) {
14592 remove(key);
14593 }
14594 }
14595
14596 void forEach(void f(String key, String value)) {
14597 _attributes.forEach((String key, String value) {
14598 if (_matches(key)) {
14599 f(_strip(key), value);
14600 }
14601 });
14602 }
14603
14604 Iterable<String> get keys {
14605 final keys = new List<String>();
14606 _attributes.forEach((String key, String value) {
14607 if (_matches(key)) {
14608 keys.add(_strip(key));
14609 }
14610 });
14611 return keys;
14612 }
14613
14614 Iterable<String> get values {
14615 final values = new List<String>();
14616 _attributes.forEach((String key, String value) {
14617 if (_matches(key)) {
14618 values.add(value);
14619 }
14620 });
14621 return values;
14622 }
14623
14624 int get length => keys.length;
14625
14626 // TODO: Use lazy iterator when it is available on Map.
14627 bool get isEmpty => length == 0;
14628
14629 bool get isNotEmpty => !isEmpty;
14630
14631 // Helpers.
14632 String _attr(String key) => 'data-${_toHyphenedName(key)}';
14633 bool _matches(String key) => key.startsWith('data-');
14634 String _strip(String key) => _toCamelCase(key.substring(5));
14635
14636 /**
14637 * Converts a string name with hyphens into an identifier, by removing hyphens
14638 * and capitalizing the following letter. Optionally [startUppercase] to
14639 * captialize the first letter.
14640 */
14641 String _toCamelCase(String hyphenedName, {bool startUppercase: false}) {
14642 var segments = hyphenedName.split('-');
14643 int start = startUppercase ? 0 : 1;
14644 for (int i = start; i < segments.length; i++) {
14645 var segment = segments[i];
14646 if (segment.length > 0) {
14647 // Character between 'a'..'z' mapped to 'A'..'Z'
14648 segments[i] = '${segment[0].toUpperCase()}${segment.substring(1)}';
14649 }
14650 }
14651 return segments.join('');
14652 }
14653
14654 /** Reverse of [toCamelCase]. */
14655 String _toHyphenedName(String word) {
14656 var sb = new StringBuffer();
14657 for (int i = 0; i < word.length; i++) {
14658 var lower = word[i].toLowerCase();
14659 if (word[i] != lower && i > 0) sb.write('-');
14660 sb.write(lower);
14661 }
14662 return sb.toString();
14663 }
14664 }
14665 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
14666 // for details. All rights reserved. Use of this source code is governed by a
14667 // BSD-style license that can be found in the LICENSE file.
14668
14669
14670 /**
14671 * An object that can be drawn to a 2D canvas rendering context.
14672 *
14673 * The image drawn to the canvas depends on the type of this object:
14674 *
14675 * * If this object is an [ImageElement], then this element's image is
14676 * drawn to the canvas. If this element is an animated image, then this
14677 * element's poster frame is drawn. If this element has no poster frame, then
14678 * the first frame of animation is drawn.
14679 *
14680 * * If this object is a [VideoElement], then the frame at this element's curren t
14681 * playback position is drawn to the canvas.
14682 *
14683 * * If this object is a [CanvasElement], then this element's bitmap is drawn to
14684 * the canvas.
14685 *
14686 * **Note:** Currently all versions of Internet Explorer do not support
14687 * drawing a video element to a canvas. You may also encounter problems drawing
14688 * a video to a canvas in Firefox if the source of the video is a data URL.
14689 *
14690 * ## See also
14691 *
14692 * * [CanvasRenderingContext2D.drawImage]
14693 * * [CanvasRenderingContext2D.drawImageToRect]
14694 * * [CanvasRenderingContext2D.drawImageScaled]
14695 * * [CanvasRenderingContext2D.drawImageScaledFromSource]
14696 *
14697 * ## Other resources
14698 *
14699 * * [Image sources for 2D rendering contexts]
14700 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-eleme nt.html#image-sources-for-2d-rendering-contexts)
14701 * from WHATWG.
14702 * * [Drawing images]
14703 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-eleme nt.html#dom-context-2d-drawimage)
14704 * from WHATWG.
14705 */
14706 abstract class CanvasImageSource {}
14707 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
14708 // for details. All rights reserved. Use of this source code is governed by a
14709 // BSD-style license that can be found in the LICENSE file.
14710
14711
14712 /**
14713 * Top-level container for a browser tab or window.
14714 *
14715 * In a web browser, a [WindowBase] object represents any browser window. This
14716 * object contains the window's state and its relation to other
14717 * windows, such as which window opened this window.
14718 *
14719 * **Note:** This class represents any window, while [Window] is
14720 * used to access the properties and content of the current window or tab.
14721 *
14722 * ## See also
14723 *
14724 * * [Window]
14725 *
14726 * ## Other resources
14727 *
14728 * * [DOM Window](https://developer.mozilla.org/en-US/docs/DOM/window) from MDN.
14729 * * [Window](http://www.w3.org/TR/Window/) from the W3C.
14730 */
14731 abstract class WindowBase implements EventTarget {
14732 // Fields.
14733
14734 /**
14735 * The current location of this window.
14736 *
14737 * Location currentLocation = window.location;
14738 * print(currentLocation.href); // 'http://www.example.com:80/'
14739 */
14740 LocationBase get location;
14741
14742 /**
14743 * The current session history for this window.
14744 *
14745 * ## Other resources
14746 *
14747 * * [Session history and navigation specification]
14748 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html)
14749 * from WHATWG.
14750 */
14751 HistoryBase get history;
14752
14753 /**
14754 * Indicates whether this window has been closed.
14755 *
14756 * print(window.closed); // 'false'
14757 * window.close();
14758 * print(window.closed); // 'true'
14759 */
14760 bool get closed;
14761
14762 /**
14763 * A reference to the window that opened this one.
14764 *
14765 * Window thisWindow = window;
14766 * WindowBase otherWindow = thisWindow.open('http://www.example.com/', 'fo o');
14767 * print(otherWindow.opener == thisWindow); // 'true'
14768 */
14769 WindowBase get opener;
14770
14771 /**
14772 * A reference to the parent of this window.
14773 *
14774 * If this [WindowBase] has no parent, [parent] will return a reference to
14775 * the [WindowBase] itself.
14776 *
14777 * IFrameElement myIFrame = new IFrameElement();
14778 * window.document.body.elements.add(myIFrame);
14779 * print(myIframe.contentWindow.parent == window) // 'true'
14780 *
14781 * print(window.parent == window) // 'true'
14782 */
14783 WindowBase get parent;
14784
14785 /**
14786 * A reference to the topmost window in the window hierarchy.
14787 *
14788 * If this [WindowBase] is the topmost [WindowBase], [top] will return a
14789 * reference to the [WindowBase] itself.
14790 *
14791 * // Add an IFrame to the current window.
14792 * IFrameElement myIFrame = new IFrameElement();
14793 * window.document.body.elements.add(myIFrame);
14794 *
14795 * // Add an IFrame inside of the other IFrame.
14796 * IFrameElement innerIFrame = new IFrameElement();
14797 * myIFrame.elements.add(innerIFrame);
14798 *
14799 * print(myIframe.contentWindow.top == window) // 'true'
14800 * print(innerIFrame.contentWindow.top == window) // 'true'
14801 *
14802 * print(window.top == window) // 'true'
14803 */
14804 WindowBase get top;
14805
14806 // Methods.
14807 /**
14808 * Closes the window.
14809 *
14810 * This method should only succeed if the [WindowBase] object is
14811 * **script-closeable** and the window calling [close] is allowed to navigate
14812 * the window.
14813 *
14814 * A window is script-closeable if it is either a window
14815 * that was opened by another window, or if it is a window with only one
14816 * document in its history.
14817 *
14818 * A window might not be allowed to navigate, and therefore close, another
14819 * window due to browser security features.
14820 *
14821 * var other = window.open('http://www.example.com', 'foo');
14822 * // Closes other window, as it is script-closeable.
14823 * other.close();
14824 * print(other.closed()); // 'true'
14825 *
14826 * window.location('http://www.mysite.com', 'foo');
14827 * // Does not close this window, as the history has changed.
14828 * window.close();
14829 * print(window.closed()); // 'false'
14830 *
14831 * See also:
14832 *
14833 * * [Window close discussion](http://www.w3.org/TR/html5/browsers.html#dom-wi ndow-close) from the W3C
14834 */
14835 void close();
14836
14837 /**
14838 * Sends a cross-origin message.
14839 *
14840 * ## Other resources
14841 *
14842 * * [window.postMessage]
14843 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage) from
14844 * MDN.
14845 * * [Cross-document messaging]
14846 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging. html)
14847 * from WHATWG.
14848 */
14849 void postMessage(var message, String targetOrigin, [List messagePorts]);
14850 }
14851
14852 abstract class LocationBase {
14853 void set href(String val);
14854 }
14855
14856 abstract class HistoryBase {
14857 void back();
14858 void forward();
14859 void go(int distance);
14860 }
14861 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
14862 // for details. All rights reserved. Use of this source code is governed by a
14863 // BSD-style license that can be found in the LICENSE file.
14864
14865
14866 /** A Set that stores the CSS class names for an element. */
14867 abstract class CssClassSet implements Set<String> {
14868
14869 /**
14870 * Adds the class [value] to the element if it is not on it, removes it if it
14871 * is.
14872 *
14873 * If [shouldAdd] is true, then we always add that [value] to the element. If
14874 * [shouldAdd] is false then we always remove [value] from the element.
14875 *
14876 * If this corresponds to one element, returns `true` if [value] is present
14877 * after the operation, and returns `false` if [value] is absent after the
14878 * operation.
14879 *
14880 * If this corresponds to many elements, `null` is always returned.
14881 *
14882 * [value] must be a valid 'token' representing a single class, i.e. a
14883 * non-empty string containing no whitespace. To toggle multiple classes, use
14884 * [toggleAll].
14885 */
14886 bool toggle(String value, [bool shouldAdd]);
14887
14888 /**
14889 * Returns [:true:] if classes cannot be added or removed from this
14890 * [:CssClassSet:].
14891 */
14892 bool get frozen;
14893
14894 /**
14895 * Determine if this element contains the class [value].
14896 *
14897 * This is the Dart equivalent of jQuery's
14898 * [hasClass](http://api.jquery.com/hasClass/).
14899 *
14900 * [value] must be a valid 'token' representing a single class, i.e. a
14901 * non-empty string containing no whitespace.
14902 */
14903 bool contains(Object value);
14904
14905 /**
14906 * Add the class [value] to element.
14907 *
14908 * [add] and [addAll] are the Dart equivalent of jQuery's
14909 * [addClass](http://api.jquery.com/addClass/).
14910 *
14911 * If this CssClassSet corresponds to one element. Returns true if [value] was
14912 * added to the set, otherwise false.
14913 *
14914 * If this corresponds to many elements, `null` is always returned.
14915 *
14916 * [value] must be a valid 'token' representing a single class, i.e. a
14917 * non-empty string containing no whitespace. To add multiple classes use
14918 * [addAll].
14919 */
14920 bool add(String value);
14921
14922 /**
14923 * Remove the class [value] from element, and return true on successful
14924 * removal.
14925 *
14926 * [remove] and [removeAll] are the Dart equivalent of jQuery's
14927 * [removeClass](http://api.jquery.com/removeClass/).
14928 *
14929 * [value] must be a valid 'token' representing a single class, i.e. a
14930 * non-empty string containing no whitespace. To remove multiple classes, use
14931 * [removeAll].
14932 */
14933 bool remove(Object value);
14934
14935 /**
14936 * Add all classes specified in [iterable] to element.
14937 *
14938 * [add] and [addAll] are the Dart equivalent of jQuery's
14939 * [addClass](http://api.jquery.com/addClass/).
14940 *
14941 * Each element of [iterable] must be a valid 'token' representing a single
14942 * class, i.e. a non-empty string containing no whitespace.
14943 */
14944 void addAll(Iterable<String> iterable);
14945
14946 /**
14947 * Remove all classes specified in [iterable] from element.
14948 *
14949 * [remove] and [removeAll] are the Dart equivalent of jQuery's
14950 * [removeClass](http://api.jquery.com/removeClass/).
14951 *
14952 * Each element of [iterable] must be a valid 'token' representing a single
14953 * class, i.e. a non-empty string containing no whitespace.
14954 */
14955 void removeAll(Iterable<Object> iterable);
14956
14957 /**
14958 * Toggles all classes specified in [iterable] on element.
14959 *
14960 * Iterate through [iterable]'s items, and add it if it is not on it, or
14961 * remove it if it is. This is the Dart equivalent of jQuery's
14962 * [toggleClass](http://api.jquery.com/toggleClass/).
14963 * If [shouldAdd] is true, then we always add all the classes in [iterable]
14964 * element. If [shouldAdd] is false then we always remove all the classes in
14965 * [iterable] from the element.
14966 *
14967 * Each element of [iterable] must be a valid 'token' representing a single
14968 * class, i.e. a non-empty string containing no whitespace.
14969 */
14970 void toggleAll(Iterable<String> iterable, [bool shouldAdd]);
14971 }
14972 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
14973 // for details. All rights reserved. Use of this source code is governed by a
14974 // BSD-style license that can be found in the LICENSE file.
14975
14976
14977 /**
14978 * A rectangle representing all the content of the element in the
14979 * [box model](http://www.w3.org/TR/CSS2/box.html).
14980 */
14981 class _ContentCssRect extends CssRect {
14982
14983 _ContentCssRect(element) : super(element);
14984
14985 num get height => _element.offsetHeight +
14986 _addOrSubtractToBoxModel(_HEIGHT, _CONTENT);
14987
14988 num get width => _element.offsetWidth +
14989 _addOrSubtractToBoxModel(_WIDTH, _CONTENT);
14990
14991 /**
14992 * Set the height to `newHeight`.
14993 *
14994 * newHeight can be either a [num] representing the height in pixels or a
14995 * [Dimension] object. Values of newHeight that are less than zero are
14996 * converted to effectively setting the height to 0. This is equivalent to the
14997 * `height` function in jQuery and the calculated `height` CSS value,
14998 * converted to a num in pixels.
14999 */
15000 set height(Object newHeight) {
15001 if (newHeight is Dimension) {
15002 var result = (newHeight.value < 0) ? new Dimension.px(0) : newHeight;
15003 _element.style.height = result.toString();
15004 } else {
15005 var result = ((newHeight as int) < 0) ? 0 : newHeight;
15006 _element.style.height = '${result}px';
15007 }
15008 }
15009
15010 /**
15011 * Set the current computed width in pixels of this element.
15012 *
15013 * newWidth can be either a [num] representing the width in pixels or a
15014 * [Dimension] object. This is equivalent to the `width` function in jQuery
15015 * and the calculated
15016 * `width` CSS value, converted to a dimensionless num in pixels.
15017 */
15018 set width(Object newWidth) {
15019 if (newWidth is Dimension) {
15020 var result = (newWidth.value < 0) ? new Dimension.px(0) : newWidth;
15021 _element.style.width = result.toString();
15022 } else {
15023 var result = ((newWidth as int) < 0) ? 0 : newWidth;
15024 _element.style.width = '${result}px';
15025 }
15026 }
15027
15028 num get left => _element.getBoundingClientRect().left -
15029 _addOrSubtractToBoxModel(['left'], _CONTENT);
15030 num get top => _element.getBoundingClientRect().top -
15031 _addOrSubtractToBoxModel(['top'], _CONTENT);
15032 }
15033
15034 /**
15035 * A list of element content rectangles in the
15036 * [box model](http://www.w3.org/TR/CSS2/box.html).
15037 */
15038 class _ContentCssListRect extends _ContentCssRect {
15039 List<Element> _elementList;
15040
15041 _ContentCssListRect(elementList) : super(elementList.first) {
15042 _elementList = elementList;
15043 }
15044
15045 /**
15046 * Set the height to `newHeight`.
15047 *
15048 * Values of newHeight that are less than zero are converted to effectively
15049 * setting the height to 0. This is equivalent to the `height`
15050 * function in jQuery and the calculated `height` CSS value, converted to a
15051 * num in pixels.
15052 */
15053 set height(newHeight) {
15054 _elementList.forEach((e) => e.contentEdge.height = newHeight);
15055 }
15056
15057 /**
15058 * Set the current computed width in pixels of this element.
15059 *
15060 * This is equivalent to the `width` function in jQuery and the calculated
15061 * `width` CSS value, converted to a dimensionless num in pixels.
15062 */
15063 set width(newWidth) {
15064 _elementList.forEach((e) => e.contentEdge.width = newWidth);
15065 }
15066 }
15067
15068 /**
15069 * A rectangle representing the dimensions of the space occupied by the
15070 * element's content + padding in the
15071 * [box model](http://www.w3.org/TR/CSS2/box.html).
15072 */
15073 class _PaddingCssRect extends CssRect {
15074 _PaddingCssRect(element) : super(element);
15075 num get height => _element.offsetHeight +
15076 _addOrSubtractToBoxModel(_HEIGHT, _PADDING);
15077 num get width => _element.offsetWidth +
15078 _addOrSubtractToBoxModel(_WIDTH, _PADDING);
15079
15080 num get left => _element.getBoundingClientRect().left -
15081 _addOrSubtractToBoxModel(['left'], _PADDING);
15082 num get top => _element.getBoundingClientRect().top -
15083 _addOrSubtractToBoxModel(['top'], _PADDING);
15084 }
15085
15086 /**
15087 * A rectangle representing the dimensions of the space occupied by the
15088 * element's content + padding + border in the
15089 * [box model](http://www.w3.org/TR/CSS2/box.html).
15090 */
15091 class _BorderCssRect extends CssRect {
15092 _BorderCssRect(element) : super(element);
15093 num get height => _element.offsetHeight;
15094 num get width => _element.offsetWidth;
15095
15096 num get left => _element.getBoundingClientRect().left;
15097 num get top => _element.getBoundingClientRect().top;
15098 }
15099
15100 /**
15101 * A rectangle representing the dimensions of the space occupied by the
15102 * element's content + padding + border + margin in the
15103 * [box model](http://www.w3.org/TR/CSS2/box.html).
15104 */
15105 class _MarginCssRect extends CssRect {
15106 _MarginCssRect(element) : super(element);
15107 num get height => _element.offsetHeight +
15108 _addOrSubtractToBoxModel(_HEIGHT, _MARGIN);
15109 num get width =>
15110 _element.offsetWidth + _addOrSubtractToBoxModel(_WIDTH, _MARGIN);
15111
15112 num get left => _element.getBoundingClientRect().left -
15113 _addOrSubtractToBoxModel(['left'], _MARGIN);
15114 num get top => _element.getBoundingClientRect().top -
15115 _addOrSubtractToBoxModel(['top'], _MARGIN);
15116 }
15117
15118 /**
15119 * A class for representing CSS dimensions.
15120 *
15121 * In contrast to the more general purpose [Rectangle] class, this class's
15122 * values are mutable, so one can change the height of an element
15123 * programmatically.
15124 *
15125 * _Important_ _note_: use of these methods will perform CSS calculations that
15126 * can trigger a browser reflow. Therefore, use of these properties _during_ an
15127 * animation frame is discouraged. See also:
15128 * [Browser Reflow](https://developers.google.com/speed/articles/reflow)
15129 */
15130 abstract class CssRect extends MutableRectangle<num> {
15131 Element _element;
15132
15133 CssRect(this._element) : super(0, 0, 0, 0);
15134
15135 num get left;
15136
15137 num get top;
15138
15139 /**
15140 * The height of this rectangle.
15141 *
15142 * This is equivalent to the `height` function in jQuery and the calculated
15143 * `height` CSS value, converted to a dimensionless num in pixels. Unlike
15144 * [getBoundingClientRect], `height` will return the same numerical width if
15145 * the element is hidden or not.
15146 */
15147 num get height;
15148
15149 /**
15150 * The width of this rectangle.
15151 *
15152 * This is equivalent to the `width` function in jQuery and the calculated
15153 * `width` CSS value, converted to a dimensionless num in pixels. Unlike
15154 * [getBoundingClientRect], `width` will return the same numerical width if
15155 * the element is hidden or not.
15156 */
15157 num get width;
15158
15159 /**
15160 * Set the height to `newHeight`.
15161 *
15162 * newHeight can be either a [num] representing the height in pixels or a
15163 * [Dimension] object. Values of newHeight that are less than zero are
15164 * converted to effectively setting the height to 0. This is equivalent to the
15165 * `height` function in jQuery and the calculated `height` CSS value,
15166 * converted to a num in pixels.
15167 *
15168 * Note that only the content height can actually be set via this method.
15169 */
15170 set height(newHeight) {
15171 throw new UnsupportedError("Can only set height for content rect.");
15172 }
15173
15174 /**
15175 * Set the current computed width in pixels of this element.
15176 *
15177 * newWidth can be either a [num] representing the width in pixels or a
15178 * [Dimension] object. This is equivalent to the `width` function in jQuery
15179 * and the calculated
15180 * `width` CSS value, converted to a dimensionless num in pixels.
15181 *
15182 * Note that only the content width can be set via this method.
15183 */
15184 set width(newWidth) {
15185 throw new UnsupportedError("Can only set width for content rect.");
15186 }
15187
15188 /**
15189 * Return a value that is used to modify the initial height or width
15190 * measurement of an element. Depending on the value (ideally an enum) passed
15191 * to augmentingMeasurement, we may need to add or subtract margin, padding,
15192 * or border values, depending on the measurement we're trying to obtain.
15193 */
15194 num _addOrSubtractToBoxModel(List<String> dimensions,
15195 String augmentingMeasurement) {
15196 // getComputedStyle always returns pixel values (hence, computed), so we're
15197 // always dealing with pixels in this method.
15198 var styles = _element.getComputedStyle();
15199
15200 var val = 0;
15201
15202 for (String measurement in dimensions) {
15203 // The border-box and default box model both exclude margin in the regular
15204 // height/width calculation, so add it if we want it for this measurement.
15205 if (augmentingMeasurement == _MARGIN) {
15206 val += new Dimension.css(styles.getPropertyValue(
15207 '$augmentingMeasurement-$measurement')).value;
15208 }
15209
15210 // The border-box includes padding and border, so remove it if we want
15211 // just the content itself.
15212 if (augmentingMeasurement == _CONTENT) {
15213 val -= new Dimension.css(
15214 styles.getPropertyValue('${_PADDING}-$measurement')).value;
15215 }
15216
15217 // At this point, we don't wan't to augment with border or margin,
15218 // so remove border.
15219 if (augmentingMeasurement != _MARGIN) {
15220 val -= new Dimension.css(styles.getPropertyValue(
15221 'border-${measurement}-width')).value;
15222 }
15223 }
15224 return val;
15225 }
15226 }
15227
15228 final _HEIGHT = ['top', 'bottom'];
15229 final _WIDTH = ['right', 'left'];
15230 final _CONTENT = 'content';
15231 final _PADDING = 'padding';
15232 final _MARGIN = 'margin';
15233 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
15234 // for details. All rights reserved. Use of this source code is governed by a
15235 // BSD-style license that can be found in the LICENSE file.
15236
15237
15238 /**
15239 * A set (union) of the CSS classes that are present in a set of elements.
15240 * Implemented separately from _ElementCssClassSet for performance.
15241 */
15242 class _MultiElementCssClassSet extends CssClassSetImpl {
15243 final Iterable<Element> _elementIterable;
15244
15245 // TODO(sra): Perhaps we should store the DomTokenList instead.
15246 final List<CssClassSetImpl> _sets;
15247
15248 factory _MultiElementCssClassSet(Iterable<Element> elements) {
15249 return new _MultiElementCssClassSet._(elements,
15250 elements.map((Element e) => e.classes).toList());
15251 }
15252
15253 _MultiElementCssClassSet._(this._elementIterable, this._sets);
15254
15255 Set<String> readClasses() {
15256 var s = new LinkedHashSet<String>();
15257 _sets.forEach((CssClassSetImpl e) => s.addAll(e.readClasses()));
15258 return s;
15259 }
15260
15261 void writeClasses(Set<String> s) {
15262 var classes = s.join(' ');
15263 for (Element e in _elementIterable) {
15264 e.className = classes;
15265 }
15266 }
15267
15268 /**
15269 * Helper method used to modify the set of css classes on this element.
15270 *
15271 * f - callback with:
15272 * s - a Set of all the css class name currently on this element.
15273 *
15274 * After f returns, the modified set is written to the
15275 * className property of this element.
15276 */
15277 modify( f(Set<String> s)) {
15278 _sets.forEach((CssClassSetImpl e) => e.modify(f));
15279 }
15280
15281 /**
15282 * Adds the class [value] to the element if it is not on it, removes it if it
15283 * is.
15284 *
15285 * TODO(sra): It seems wrong to collect a 'changed' flag like this when the
15286 * underlying toggle returns an 'is set' flag.
15287 */
15288 bool toggle(String value, [bool shouldAdd]) =>
15289 _sets.fold(false,
15290 (bool changed, CssClassSetImpl e) =>
15291 e.toggle(value, shouldAdd) || changed);
15292
15293 /**
15294 * Remove the class [value] from element, and return true on successful
15295 * removal.
15296 *
15297 * This is the Dart equivalent of jQuery's
15298 * [removeClass](http://api.jquery.com/removeClass/).
15299 */
15300 bool remove(Object value) => _sets.fold(false,
15301 (bool changed, CssClassSetImpl e) => e.remove(value) || changed);
15302 }
15303
15304 class _ElementCssClassSet extends CssClassSetImpl {
15305 final Element _element;
15306
15307 _ElementCssClassSet(this._element);
15308
15309 Set<String> readClasses() {
15310 var s = new LinkedHashSet<String>();
15311 var classname = _element.className;
15312
15313 for (String name in classname.split(' ')) {
15314 String trimmed = name.trim();
15315 if (!trimmed.isEmpty) {
15316 s.add(trimmed);
15317 }
15318 }
15319 return s;
15320 }
15321
15322 void writeClasses(Set<String> s) {
15323 _element.className = s.join(' ');
15324 }
15325
15326 int get length => _classListLength(_classListOf(_element));
15327 bool get isEmpty => length == 0;
15328 bool get isNotEmpty => length != 0;
15329
15330 void clear() {
15331 _element.className = '';
15332 }
15333
15334 bool contains(Object value) {
15335 return _contains(_element, value);
15336 }
15337
15338 bool add(String value) {
15339 return _add(_element, value);
15340 }
15341
15342 bool remove(Object value) {
15343 return value is String && _remove(_element, value);
15344 }
15345
15346 bool toggle(String value, [bool shouldAdd]) {
15347 return _toggle(_element, value, shouldAdd);
15348 }
15349
15350 void addAll(Iterable<String> iterable) {
15351 _addAll(_element, iterable);
15352 }
15353
15354 void removeAll(Iterable<Object> iterable) {
15355 _removeAll(_element, iterable);
15356 }
15357
15358 void retainAll(Iterable<Object> iterable) {
15359 _removeWhere(_element, iterable.toSet().contains, false);
15360 }
15361
15362 void removeWhere(bool test(String name)) {
15363 _removeWhere(_element, test, true);
15364 }
15365
15366 void retainWhere(bool test(String name)) {
15367 _removeWhere(_element, test, false);
15368 }
15369
15370 static bool _contains(Element _element, Object value) {
15371 return value is String && _classListContains(_classListOf(_element), value);
15372 }
15373
15374 static bool _add(Element _element, String value) {
15375 DomTokenList list = _classListOf(_element);
15376 // Compute returned result independently of action upon the set.
15377 bool added = !_classListContainsBeforeAddOrRemove(list, value);
15378 _classListAdd(list, value);
15379 return added;
15380 }
15381
15382 static bool _remove(Element _element, String value) {
15383 DomTokenList list = _classListOf(_element);
15384 bool removed = _classListContainsBeforeAddOrRemove(list, value);
15385 _classListRemove(list, value);
15386 return removed;
15387 }
15388
15389 static bool _toggle(Element _element, String value, bool shouldAdd) {
15390 // There is no value that can be passed as the second argument of
15391 // DomTokenList.toggle that behaves the same as passing one argument.
15392 // `null` is seen as false, meaning 'remove'.
15393 return shouldAdd == null
15394 ? _toggleDefault(_element, value)
15395 : _toggleOnOff(_element, value, shouldAdd);
15396 }
15397
15398 static bool _toggleDefault(Element _element, String value) {
15399 DomTokenList list = _classListOf(_element);
15400 return _classListToggle1(list, value);
15401 }
15402
15403 static bool _toggleOnOff(Element _element, String value, bool shouldAdd) {
15404 DomTokenList list = _classListOf(_element);
15405 // IE's toggle does not take a second parameter. We would prefer:
15406 //
15407 // return _classListToggle2(list, value, shouldAdd);
15408 //
15409 if (shouldAdd) {
15410 _classListAdd(list, value);
15411 return true;
15412 } else {
15413 _classListRemove(list, value);
15414 return false;
15415 }
15416 }
15417
15418 static void _addAll(Element _element, Iterable<String> iterable) {
15419 DomTokenList list = _classListOf(_element);
15420 for (String value in iterable) {
15421 _classListAdd(list, value);
15422 }
15423 }
15424
15425 static void _removeAll(Element _element, Iterable<String> iterable) {
15426 DomTokenList list = _classListOf(_element);
15427 for (var value in iterable) {
15428 _classListRemove(list, value);
15429 }
15430 }
15431
15432 static void _removeWhere(
15433 Element _element, bool test(String name), bool doRemove) {
15434 DomTokenList list = _classListOf(_element);
15435 int i = 0;
15436 while (i < _classListLength(list)) {
15437 String item = list.item(i);
15438 if (doRemove == test(item)) {
15439 _classListRemove(list, item);
15440 } else {
15441 ++i;
15442 }
15443 }
15444 }
15445
15446 // A collection of static methods for DomTokenList. These methods are a
15447 // work-around for the lack of annotations to express the full behaviour of
15448 // the DomTokenList methods.
15449
15450 static DomTokenList _classListOf(Element e) =>
15451 wrap_jso(JS('returns:DomTokenList;creates:DomTokenList;effects:none;depends: all;',
15452 '#.classList', e.raw));
15453
15454 static int _classListLength(DomTokenList list) =>
15455 JS('returns:JSUInt31;effects:none;depends:all;', '#.length', list.raw);
15456
15457 static bool _classListContains(DomTokenList list, String value) =>
15458 JS('returns:bool;effects:none;depends:all',
15459 '#.contains(#)', list.raw, value);
15460
15461 static bool _classListContainsBeforeAddOrRemove(
15462 DomTokenList list, String value) =>
15463 // 'throws:never' is a lie, since 'contains' will throw on an illegal
15464 // token. However, we always call this function immediately prior to
15465 // add/remove/toggle with the same token. Often the result of 'contains'
15466 // is unused and the lie makes it possible for the 'contains' instruction
15467 // to be removed.
15468 JS('returns:bool;effects:none;depends:all;throws:null(1)',
15469 '#.contains(#)', list.raw, value);
15470
15471 static void _classListAdd(DomTokenList list, String value) {
15472 // list.add(value);
15473 JS('', '#.add(#)', list.raw, value);
15474 }
15475
15476 static void _classListRemove(DomTokenList list, String value) {
15477 // list.remove(value);
15478 JS('', '#.remove(#)', list.raw, value);
15479 }
15480
15481 static bool _classListToggle1(DomTokenList list, String value) {
15482 return JS('bool', '#.toggle(#)', list.raw, value);
15483 }
15484
15485 static bool _classListToggle2(
15486 DomTokenList list, String value, bool shouldAdd) {
15487 return JS('bool', '#.toggle(#, #)', list.raw, value, shouldAdd);
15488 }
15489 }
15490
15491 /**
15492 * Class representing a
15493 * [length measurement](https://developer.mozilla.org/en-US/docs/Web/CSS/length)
15494 * in CSS.
15495 */
15496 @Experimental()
15497 class Dimension {
15498 num _value;
15499 String _unit;
15500
15501 /** Set this CSS Dimension to a percentage `value`. */
15502 Dimension.percent(this._value) : _unit = '%';
15503
15504 /** Set this CSS Dimension to a pixel `value`. */
15505 Dimension.px(this._value) : _unit = 'px';
15506
15507 /** Set this CSS Dimension to a pica `value`. */
15508 Dimension.pc(this._value) : _unit = 'pc';
15509
15510 /** Set this CSS Dimension to a point `value`. */
15511 Dimension.pt(this._value) : _unit = 'pt';
15512
15513 /** Set this CSS Dimension to an inch `value`. */
15514 Dimension.inch(this._value) : _unit = 'in';
15515
15516 /** Set this CSS Dimension to a centimeter `value`. */
15517 Dimension.cm(this._value) : _unit = 'cm';
15518
15519 /** Set this CSS Dimension to a millimeter `value`. */
15520 Dimension.mm(this._value) : _unit = 'mm';
15521
15522 /**
15523 * Set this CSS Dimension to the specified number of ems.
15524 *
15525 * 1em is equal to the current font size. (So 2ems is equal to double the font
15526 * size). This is useful for producing website layouts that scale nicely with
15527 * the user's desired font size.
15528 */
15529 Dimension.em(this._value) : _unit = 'em';
15530
15531 /**
15532 * Set this CSS Dimension to the specified number of x-heights.
15533 *
15534 * One ex is equal to the the x-height of a font's baseline to its mean line,
15535 * generally the height of the letter "x" in the font, which is usually about
15536 * half the font-size.
15537 */
15538 Dimension.ex(this._value) : _unit = 'ex';
15539
15540 /**
15541 * Construct a Dimension object from the valid, simple CSS string `cssValue`
15542 * that represents a distance measurement.
15543 *
15544 * This constructor is intended as a convenience method for working with
15545 * simplistic CSS length measurements. Non-numeric values such as `auto` or
15546 * `inherit` or invalid CSS will cause this constructor to throw a
15547 * FormatError.
15548 */
15549 Dimension.css(String cssValue) {
15550 if (cssValue == '') cssValue = '0px';
15551 if (cssValue.endsWith('%')) {
15552 _unit = '%';
15553 } else {
15554 _unit = cssValue.substring(cssValue.length - 2);
15555 }
15556 if (cssValue.contains('.')) {
15557 _value = double.parse(cssValue.substring(0,
15558 cssValue.length - _unit.length));
15559 } else {
15560 _value = int.parse(cssValue.substring(0, cssValue.length - _unit.length));
15561 }
15562 }
15563
15564 /** Print out the CSS String representation of this value. */
15565 String toString() {
15566 return '${_value}${_unit}';
15567 }
15568
15569 /** Return a unitless, numerical value of this CSS value. */
15570 num get value => this._value;
15571 }
15572 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
15573 // for details. All rights reserved. Use of this source code is governed by a
15574 // BSD-style license that can be found in the LICENSE file.
15575
15576
15577 typedef EventListener(Event event);
15578 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
15579 // for details. All rights reserved. Use of this source code is governed by a
15580 // BSD-style license that can be found in the LICENSE file.
15581
15582
15583 /**
15584 * A factory to expose DOM events as Streams.
15585 */
15586 class EventStreamProvider<T extends Event> {
15587 final String _eventType;
15588
15589 const EventStreamProvider(this._eventType);
15590
15591 /**
15592 * Gets a [Stream] for this event type, on the specified target.
15593 *
15594 * This will always return a broadcast stream so multiple listeners can be
15595 * used simultaneously.
15596 *
15597 * This may be used to capture DOM events:
15598 *
15599 * Element.keyDownEvent.forTarget(element, useCapture: true).listen(...);
15600 *
15601 * // Alternate method:
15602 * Element.keyDownEvent.forTarget(element).capture(...);
15603 *
15604 * Or for listening to an event which will bubble through the DOM tree:
15605 *
15606 * MediaElement.pauseEvent.forTarget(document.body).listen(...);
15607 *
15608 * See also:
15609 *
15610 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis tener)
15611 */
15612 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) =>
15613 new _EventStream(e, _eventType, useCapture);
15614
15615 /**
15616 * Gets an [ElementEventStream] for this event type, on the specified element.
15617 *
15618 * This will always return a broadcast stream so multiple listeners can be
15619 * used simultaneously.
15620 *
15621 * This may be used to capture DOM events:
15622 *
15623 * Element.keyDownEvent.forElement(element, useCapture: true).listen(...);
15624 *
15625 * // Alternate method:
15626 * Element.keyDownEvent.forElement(element).capture(...);
15627 *
15628 * Or for listening to an event which will bubble through the DOM tree:
15629 *
15630 * MediaElement.pauseEvent.forElement(document.body).listen(...);
15631 *
15632 * See also:
15633 *
15634 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis tener)
15635 */
15636 ElementStream<T> forElement(Element e, {bool useCapture: false}) {
15637 return new _ElementEventStreamImpl(e, _eventType, useCapture);
15638 }
15639
15640 /**
15641 * Gets an [ElementEventStream] for this event type, on the list of elements.
15642 *
15643 * This will always return a broadcast stream so multiple listeners can be
15644 * used simultaneously.
15645 *
15646 * This may be used to capture DOM events:
15647 *
15648 * Element.keyDownEvent._forElementList(element, useCapture: true).listen( ...);
15649 *
15650 * See also:
15651 *
15652 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis tener)
15653 */
15654 ElementStream<T> _forElementList(ElementList e, {bool useCapture: false}) {
15655 return new _ElementListEventStreamImpl(e, _eventType, useCapture);
15656 }
15657
15658 /**
15659 * Gets the type of the event which this would listen for on the specified
15660 * event target.
15661 *
15662 * The target is necessary because some browsers may use different event names
15663 * for the same purpose and the target allows differentiating browser support.
15664 */
15665 String getEventType(EventTarget target) {
15666 return _eventType;
15667 }
15668 }
15669
15670 /** A specialized Stream available to [Element]s to enable event delegation. */
15671 abstract class ElementStream<T extends Event> implements Stream<T> {
15672 /**
15673 * Return a stream that only fires when the particular event fires for
15674 * elements matching the specified CSS selector.
15675 *
15676 * This is the Dart equivalent to jQuery's
15677 * [delegate](http://api.jquery.com/delegate/).
15678 */
15679 Stream<T> matches(String selector);
15680
15681 /**
15682 * Adds a capturing subscription to this stream.
15683 *
15684 * If the target of the event is a descendant of the element from which this
15685 * stream derives then [onData] is called before the event propagates down to
15686 * the target. This is the opposite of bubbling behavior, where the event
15687 * is first processed for the event target and then bubbles upward.
15688 *
15689 * ## Other resources
15690 *
15691 * * [Event Capture]
15692 * (http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow-capture)
15693 * from the W3C DOM Events specification.
15694 */
15695 StreamSubscription<T> capture(void onData(T event));
15696 }
15697
15698 /**
15699 * Adapter for exposing DOM events as Dart streams.
15700 */
15701 class _EventStream<T extends Event> extends Stream<T> {
15702 final EventTarget _target;
15703 final String _eventType;
15704 final bool _useCapture;
15705
15706 _EventStream(this._target, this._eventType, this._useCapture);
15707
15708 // DOM events are inherently multi-subscribers.
15709 Stream<T> asBroadcastStream({void onListen(StreamSubscription<T> subscription) ,
15710 void onCancel(StreamSubscription<T> subscription) })
15711 => this;
15712 bool get isBroadcast => true;
15713
15714 StreamSubscription<T> listen(void onData(T event),
15715 { Function onError,
15716 void onDone(),
15717 bool cancelOnError}) {
15718
15719 return new _EventStreamSubscription<T>(
15720 this._target, this._eventType, onData, this._useCapture);
15721 }
15722 }
15723
15724 /**
15725 * Adapter for exposing DOM Element events as streams, while also allowing
15726 * event delegation.
15727 */
15728 class _ElementEventStreamImpl<T extends Event> extends _EventStream<T>
15729 implements ElementStream<T> {
15730 _ElementEventStreamImpl(target, eventType, useCapture) :
15731 super(target, eventType, useCapture);
15732
15733 Stream<T> matches(String selector) => this.where(
15734 (event) => event.target.matchesWithAncestors(selector)).map((e) {
15735 e._selector = selector;
15736 return e;
15737 });
15738
15739 StreamSubscription<T> capture(void onData(T event)) =>
15740 new _EventStreamSubscription<T>(
15741 this._target, this._eventType, onData, true);
15742 }
15743
15744 /**
15745 * Adapter for exposing events on a collection of DOM Elements as streams,
15746 * while also allowing event delegation.
15747 */
15748 class _ElementListEventStreamImpl<T extends Event> extends Stream<T>
15749 implements ElementStream<T> {
15750 final Iterable<Element> _targetList;
15751 final bool _useCapture;
15752 final String _eventType;
15753
15754 _ElementListEventStreamImpl(
15755 this._targetList, this._eventType, this._useCapture);
15756
15757 Stream<T> matches(String selector) => this.where(
15758 (event) => event.target.matchesWithAncestors(selector)).map((e) {
15759 e._selector = selector;
15760 return e;
15761 });
15762
15763 // Delegate all regular Stream behavior to a wrapped Stream.
15764 StreamSubscription<T> listen(void onData(T event),
15765 { Function onError,
15766 void onDone(),
15767 bool cancelOnError}) {
15768 var pool = new _StreamPool.broadcast();
15769 for (var target in _targetList) {
15770 pool.add(new _EventStream(target, _eventType, _useCapture));
15771 }
15772 return pool.stream.listen(onData, onError: onError, onDone: onDone,
15773 cancelOnError: cancelOnError);
15774 }
15775
15776 StreamSubscription<T> capture(void onData(T event)) {
15777 var pool = new _StreamPool.broadcast();
15778 for (var target in _targetList) {
15779 pool.add(new _EventStream(target, _eventType, true));
15780 }
15781 return pool.stream.listen(onData);
15782 }
15783
15784 Stream<T> asBroadcastStream({void onListen(StreamSubscription<T> subscription) ,
15785 void onCancel(StreamSubscription<T> subscription) })
15786 => this;
15787 bool get isBroadcast => true;
15788 }
15789
15790 class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
15791 int _pauseCount = 0;
15792 EventTarget _target;
15793 final String _eventType;
15794 var _onData;
15795 final bool _useCapture;
15796
15797 _EventStreamSubscription(this._target, this._eventType, onData,
15798 this._useCapture) : _onData = _wrapZone(onData) {
15799 _tryResume();
15800 }
15801
15802 Future cancel() {
15803 if (_canceled) return null;
15804
15805 _unlisten();
15806 // Clear out the target to indicate this is complete.
15807 _target = null;
15808 _onData = null;
15809 return null;
15810 }
15811
15812 bool get _canceled => _target == null;
15813
15814 void onData(void handleData(T event)) {
15815 if (_canceled) {
15816 throw new StateError("Subscription has been canceled.");
15817 }
15818 // Remove current event listener.
15819 _unlisten();
15820
15821 _onData = _wrapZone(handleData);
15822 _tryResume();
15823 }
15824
15825 /// Has no effect.
15826 void onError(Function handleError) {}
15827
15828 /// Has no effect.
15829 void onDone(void handleDone()) {}
15830
15831 void pause([Future resumeSignal]) {
15832 if (_canceled) return;
15833 ++_pauseCount;
15834 _unlisten();
15835
15836 if (resumeSignal != null) {
15837 resumeSignal.whenComplete(resume);
15838 }
15839 }
15840
15841 bool get isPaused => _pauseCount > 0;
15842
15843 void resume() {
15844 if (_canceled || !isPaused) return;
15845 --_pauseCount;
15846 _tryResume();
15847 }
15848
15849 void _tryResume() {
15850 if (_onData != null && !isPaused) {
15851 _target.addEventListener(_eventType, _onData, _useCapture);
15852 }
15853 }
15854
15855 void _unlisten() {
15856 if (_onData != null) {
15857 _target.removeEventListener(_eventType, _onData, _useCapture);
15858 }
15859 }
15860
15861 Future asFuture([var futureValue]) {
15862 // We just need a future that will never succeed or fail.
15863 Completer completer = new Completer();
15864 return completer.future;
15865 }
15866 }
15867
15868 /**
15869 * A stream of custom events, which enables the user to "fire" (add) their own
15870 * custom events to a stream.
15871 */
15872 abstract class CustomStream<T extends Event> implements Stream<T> {
15873 /**
15874 * Add the following custom event to the stream for dispatching to interested
15875 * listeners.
15876 */
15877 void add(T event);
15878 }
15879
15880 class _CustomEventStreamImpl<T extends Event> extends Stream<T>
15881 implements CustomStream<T> {
15882 StreamController<T> _streamController;
15883 /** The type of event this stream is providing (e.g. "keydown"). */
15884 String _type;
15885
15886 _CustomEventStreamImpl(String type) {
15887 _type = type;
15888 _streamController = new StreamController.broadcast(sync: true);
15889 }
15890
15891 // Delegate all regular Stream behavior to our wrapped Stream.
15892 StreamSubscription<T> listen(void onData(T event),
15893 { Function onError,
15894 void onDone(),
15895 bool cancelOnError}) {
15896 return _streamController.stream.listen(onData, onError: onError,
15897 onDone: onDone, cancelOnError: cancelOnError);
15898 }
15899
15900 Stream<T> asBroadcastStream({void onListen(StreamSubscription<T> subscription) ,
15901 void onCancel(StreamSubscription<T> subscription) })
15902 => _streamController.stream;
15903
15904 bool get isBroadcast => true;
15905
15906 void add(T event) {
15907 if (event.type == _type) _streamController.add(event);
15908 }
15909 }
15910
15911 class _CustomKeyEventStreamImpl extends _CustomEventStreamImpl<KeyEvent>
15912 implements CustomStream<KeyEvent> {
15913 _CustomKeyEventStreamImpl(String type) : super(type);
15914
15915 void add(KeyEvent event) {
15916 if (event.type == _type) {
15917 event.currentTarget.dispatchEvent(event._parent);
15918 _streamController.add(event);
15919 }
15920 }
15921 }
15922
15923 /**
15924 * A pool of streams whose events are unified and emitted through a central
15925 * stream.
15926 */
15927 // TODO (efortuna): Remove this when Issue 12218 is addressed.
15928 class _StreamPool<T> {
15929 StreamController<T> _controller;
15930
15931 /// Subscriptions to the streams that make up the pool.
15932 var _subscriptions = new Map<Stream<T>, StreamSubscription<T>>();
15933
15934 /**
15935 * Creates a new stream pool where [stream] can be listened to more than
15936 * once.
15937 *
15938 * Any events from buffered streams in the pool will be emitted immediately,
15939 * regardless of whether [stream] has any subscribers.
15940 */
15941 _StreamPool.broadcast() {
15942 _controller = new StreamController<T>.broadcast(sync: true,
15943 onCancel: close);
15944 }
15945
15946 /**
15947 * The stream through which all events from streams in the pool are emitted.
15948 */
15949 Stream<T> get stream => _controller.stream;
15950
15951 /**
15952 * Adds [stream] as a member of this pool.
15953 *
15954 * Any events from [stream] will be emitted through [this.stream]. If
15955 * [stream] is sync, they'll be emitted synchronously; if [stream] is async,
15956 * they'll be emitted asynchronously.
15957 */
15958 void add(Stream<T> stream) {
15959 if (_subscriptions.containsKey(stream)) return;
15960 _subscriptions[stream] = stream.listen(_controller.add,
15961 onError: _controller.addError,
15962 onDone: () => remove(stream));
15963 }
15964
15965 /** Removes [stream] as a member of this pool. */
15966 void remove(Stream<T> stream) {
15967 var subscription = _subscriptions.remove(stream);
15968 if (subscription != null) subscription.cancel();
15969 }
15970
15971 /** Removes all streams from this pool and closes [stream]. */
15972 void close() {
15973 for (var subscription in _subscriptions.values) {
15974 subscription.cancel();
15975 }
15976 _subscriptions.clear();
15977 _controller.close();
15978 }
15979 }
15980
15981 /**
15982 * A factory to expose DOM events as streams, where the DOM event name has to
15983 * be determined on the fly (for example, mouse wheel events).
15984 */
15985 class _CustomEventStreamProvider<T extends Event>
15986 implements EventStreamProvider<T> {
15987
15988 final _eventTypeGetter;
15989 const _CustomEventStreamProvider(this._eventTypeGetter);
15990
15991 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) {
15992 return new _EventStream(e, _eventTypeGetter(e), useCapture);
15993 }
15994
15995 ElementStream<T> forElement(Element e, {bool useCapture: false}) {
15996 return new _ElementEventStreamImpl(e, _eventTypeGetter(e), useCapture);
15997 }
15998
15999 ElementStream<T> _forElementList(ElementList e,
16000 {bool useCapture: false}) {
16001 return new _ElementListEventStreamImpl(e, _eventTypeGetter(e), useCapture);
16002 }
16003
16004 String getEventType(EventTarget target) {
16005 return _eventTypeGetter(target);
16006 }
16007
16008 String get _eventType =>
16009 throw new UnsupportedError('Access type through getEventType method.');
16010 }
16011 // DO NOT EDIT- this file is generated from running tool/generator.sh.
16012
16013 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
16014 // for details. All rights reserved. Use of this source code is governed by a
16015 // BSD-style license that can be found in the LICENSE file.
16016
16017
16018 /**
16019 * A Dart DOM validator generated from Caja whitelists.
16020 *
16021 * This contains a whitelist of known HTML tagNames and attributes and will only
16022 * accept known good values.
16023 *
16024 * See also:
16025 *
16026 * * <https://code.google.com/p/google-caja/wiki/CajaWhitelists>
16027 */
16028 class _Html5NodeValidator implements NodeValidator {
16029
16030 static final Set<String> _allowedElements = new Set.from([
16031 'A',
16032 'ABBR',
16033 'ACRONYM',
16034 'ADDRESS',
16035 'AREA',
16036 'ARTICLE',
16037 'ASIDE',
16038 'AUDIO',
16039 'B',
16040 'BDI',
16041 'BDO',
16042 'BIG',
16043 'BLOCKQUOTE',
16044 'BR',
16045 'BUTTON',
16046 'CANVAS',
16047 'CAPTION',
16048 'CENTER',
16049 'CITE',
16050 'CODE',
16051 'COL',
16052 'COLGROUP',
16053 'COMMAND',
16054 'DATA',
16055 'DATALIST',
16056 'DD',
16057 'DEL',
16058 'DETAILS',
16059 'DFN',
16060 'DIR',
16061 'DIV',
16062 'DL',
16063 'DT',
16064 'EM',
16065 'FIELDSET',
16066 'FIGCAPTION',
16067 'FIGURE',
16068 'FONT',
16069 'FOOTER',
16070 'FORM',
16071 'H1',
16072 'H2',
16073 'H3',
16074 'H4',
16075 'H5',
16076 'H6',
16077 'HEADER',
16078 'HGROUP',
16079 'HR',
16080 'I',
16081 'IFRAME',
16082 'IMG',
16083 'INPUT',
16084 'INS',
16085 'KBD',
16086 'LABEL',
16087 'LEGEND',
16088 'LI',
16089 'MAP',
16090 'MARK',
16091 'MENU',
16092 'METER',
16093 'NAV',
16094 'NOBR',
16095 'OL',
16096 'OPTGROUP',
16097 'OPTION',
16098 'OUTPUT',
16099 'P',
16100 'PRE',
16101 'PROGRESS',
16102 'Q',
16103 'S',
16104 'SAMP',
16105 'SECTION',
16106 'SELECT',
16107 'SMALL',
16108 'SOURCE',
16109 'SPAN',
16110 'STRIKE',
16111 'STRONG',
16112 'SUB',
16113 'SUMMARY',
16114 'SUP',
16115 'TABLE',
16116 'TBODY',
16117 'TD',
16118 'TEXTAREA',
16119 'TFOOT',
16120 'TH',
16121 'THEAD',
16122 'TIME',
16123 'TR',
16124 'TRACK',
16125 'TT',
16126 'U',
16127 'UL',
16128 'VAR',
16129 'VIDEO',
16130 'WBR',
16131 ]);
16132
16133 static const _standardAttributes = const <String>[
16134 '*::class',
16135 '*::dir',
16136 '*::draggable',
16137 '*::hidden',
16138 '*::id',
16139 '*::inert',
16140 '*::itemprop',
16141 '*::itemref',
16142 '*::itemscope',
16143 '*::lang',
16144 '*::spellcheck',
16145 '*::title',
16146 '*::translate',
16147 'A::accesskey',
16148 'A::coords',
16149 'A::hreflang',
16150 'A::name',
16151 'A::shape',
16152 'A::tabindex',
16153 'A::target',
16154 'A::type',
16155 'AREA::accesskey',
16156 'AREA::alt',
16157 'AREA::coords',
16158 'AREA::nohref',
16159 'AREA::shape',
16160 'AREA::tabindex',
16161 'AREA::target',
16162 'AUDIO::controls',
16163 'AUDIO::loop',
16164 'AUDIO::mediagroup',
16165 'AUDIO::muted',
16166 'AUDIO::preload',
16167 'BDO::dir',
16168 'BODY::alink',
16169 'BODY::bgcolor',
16170 'BODY::link',
16171 'BODY::text',
16172 'BODY::vlink',
16173 'BR::clear',
16174 'BUTTON::accesskey',
16175 'BUTTON::disabled',
16176 'BUTTON::name',
16177 'BUTTON::tabindex',
16178 'BUTTON::type',
16179 'BUTTON::value',
16180 'CANVAS::height',
16181 'CANVAS::width',
16182 'CAPTION::align',
16183 'COL::align',
16184 'COL::char',
16185 'COL::charoff',
16186 'COL::span',
16187 'COL::valign',
16188 'COL::width',
16189 'COLGROUP::align',
16190 'COLGROUP::char',
16191 'COLGROUP::charoff',
16192 'COLGROUP::span',
16193 'COLGROUP::valign',
16194 'COLGROUP::width',
16195 'COMMAND::checked',
16196 'COMMAND::command',
16197 'COMMAND::disabled',
16198 'COMMAND::label',
16199 'COMMAND::radiogroup',
16200 'COMMAND::type',
16201 'DATA::value',
16202 'DEL::datetime',
16203 'DETAILS::open',
16204 'DIR::compact',
16205 'DIV::align',
16206 'DL::compact',
16207 'FIELDSET::disabled',
16208 'FONT::color',
16209 'FONT::face',
16210 'FONT::size',
16211 'FORM::accept',
16212 'FORM::autocomplete',
16213 'FORM::enctype',
16214 'FORM::method',
16215 'FORM::name',
16216 'FORM::novalidate',
16217 'FORM::target',
16218 'FRAME::name',
16219 'H1::align',
16220 'H2::align',
16221 'H3::align',
16222 'H4::align',
16223 'H5::align',
16224 'H6::align',
16225 'HR::align',
16226 'HR::noshade',
16227 'HR::size',
16228 'HR::width',
16229 'HTML::version',
16230 'IFRAME::align',
16231 'IFRAME::frameborder',
16232 'IFRAME::height',
16233 'IFRAME::marginheight',
16234 'IFRAME::marginwidth',
16235 'IFRAME::width',
16236 'IMG::align',
16237 'IMG::alt',
16238 'IMG::border',
16239 'IMG::height',
16240 'IMG::hspace',
16241 'IMG::ismap',
16242 'IMG::name',
16243 'IMG::usemap',
16244 'IMG::vspace',
16245 'IMG::width',
16246 'INPUT::accept',
16247 'INPUT::accesskey',
16248 'INPUT::align',
16249 'INPUT::alt',
16250 'INPUT::autocomplete',
16251 'INPUT::checked',
16252 'INPUT::disabled',
16253 'INPUT::inputmode',
16254 'INPUT::ismap',
16255 'INPUT::list',
16256 'INPUT::max',
16257 'INPUT::maxlength',
16258 'INPUT::min',
16259 'INPUT::multiple',
16260 'INPUT::name',
16261 'INPUT::placeholder',
16262 'INPUT::readonly',
16263 'INPUT::required',
16264 'INPUT::size',
16265 'INPUT::step',
16266 'INPUT::tabindex',
16267 'INPUT::type',
16268 'INPUT::usemap',
16269 'INPUT::value',
16270 'INS::datetime',
16271 'KEYGEN::disabled',
16272 'KEYGEN::keytype',
16273 'KEYGEN::name',
16274 'LABEL::accesskey',
16275 'LABEL::for',
16276 'LEGEND::accesskey',
16277 'LEGEND::align',
16278 'LI::type',
16279 'LI::value',
16280 'LINK::sizes',
16281 'MAP::name',
16282 'MENU::compact',
16283 'MENU::label',
16284 'MENU::type',
16285 'METER::high',
16286 'METER::low',
16287 'METER::max',
16288 'METER::min',
16289 'METER::value',
16290 'OBJECT::typemustmatch',
16291 'OL::compact',
16292 'OL::reversed',
16293 'OL::start',
16294 'OL::type',
16295 'OPTGROUP::disabled',
16296 'OPTGROUP::label',
16297 'OPTION::disabled',
16298 'OPTION::label',
16299 'OPTION::selected',
16300 'OPTION::value',
16301 'OUTPUT::for',
16302 'OUTPUT::name',
16303 'P::align',
16304 'PRE::width',
16305 'PROGRESS::max',
16306 'PROGRESS::min',
16307 'PROGRESS::value',
16308 'SELECT::autocomplete',
16309 'SELECT::disabled',
16310 'SELECT::multiple',
16311 'SELECT::name',
16312 'SELECT::required',
16313 'SELECT::size',
16314 'SELECT::tabindex',
16315 'SOURCE::type',
16316 'TABLE::align',
16317 'TABLE::bgcolor',
16318 'TABLE::border',
16319 'TABLE::cellpadding',
16320 'TABLE::cellspacing',
16321 'TABLE::frame',
16322 'TABLE::rules',
16323 'TABLE::summary',
16324 'TABLE::width',
16325 'TBODY::align',
16326 'TBODY::char',
16327 'TBODY::charoff',
16328 'TBODY::valign',
16329 'TD::abbr',
16330 'TD::align',
16331 'TD::axis',
16332 'TD::bgcolor',
16333 'TD::char',
16334 'TD::charoff',
16335 'TD::colspan',
16336 'TD::headers',
16337 'TD::height',
16338 'TD::nowrap',
16339 'TD::rowspan',
16340 'TD::scope',
16341 'TD::valign',
16342 'TD::width',
16343 'TEXTAREA::accesskey',
16344 'TEXTAREA::autocomplete',
16345 'TEXTAREA::cols',
16346 'TEXTAREA::disabled',
16347 'TEXTAREA::inputmode',
16348 'TEXTAREA::name',
16349 'TEXTAREA::placeholder',
16350 'TEXTAREA::readonly',
16351 'TEXTAREA::required',
16352 'TEXTAREA::rows',
16353 'TEXTAREA::tabindex',
16354 'TEXTAREA::wrap',
16355 'TFOOT::align',
16356 'TFOOT::char',
16357 'TFOOT::charoff',
16358 'TFOOT::valign',
16359 'TH::abbr',
16360 'TH::align',
16361 'TH::axis',
16362 'TH::bgcolor',
16363 'TH::char',
16364 'TH::charoff',
16365 'TH::colspan',
16366 'TH::headers',
16367 'TH::height',
16368 'TH::nowrap',
16369 'TH::rowspan',
16370 'TH::scope',
16371 'TH::valign',
16372 'TH::width',
16373 'THEAD::align',
16374 'THEAD::char',
16375 'THEAD::charoff',
16376 'THEAD::valign',
16377 'TR::align',
16378 'TR::bgcolor',
16379 'TR::char',
16380 'TR::charoff',
16381 'TR::valign',
16382 'TRACK::default',
16383 'TRACK::kind',
16384 'TRACK::label',
16385 'TRACK::srclang',
16386 'UL::compact',
16387 'UL::type',
16388 'VIDEO::controls',
16389 'VIDEO::height',
16390 'VIDEO::loop',
16391 'VIDEO::mediagroup',
16392 'VIDEO::muted',
16393 'VIDEO::preload',
16394 'VIDEO::width',
16395 ];
16396
16397 static const _uriAttributes = const <String>[
16398 'A::href',
16399 'AREA::href',
16400 'BLOCKQUOTE::cite',
16401 'BODY::background',
16402 'COMMAND::icon',
16403 'DEL::cite',
16404 'FORM::action',
16405 'IMG::src',
16406 'INPUT::src',
16407 'INS::cite',
16408 'Q::cite',
16409 'VIDEO::poster',
16410 ];
16411
16412 final UriPolicy uriPolicy;
16413
16414 static final Map<String, Function> _attributeValidators = {};
16415
16416 /**
16417 * All known URI attributes will be validated against the UriPolicy, if
16418 * [uriPolicy] is null then a default UriPolicy will be used.
16419 */
16420 _Html5NodeValidator({UriPolicy uriPolicy})
16421 :uriPolicy = uriPolicy != null ? uriPolicy : new UriPolicy() {
16422
16423 if (_attributeValidators.isEmpty) {
16424 for (var attr in _standardAttributes) {
16425 _attributeValidators[attr] = _standardAttributeValidator;
16426 }
16427
16428 for (var attr in _uriAttributes) {
16429 _attributeValidators[attr] = _uriAttributeValidator;
16430 }
16431 }
16432 }
16433
16434 bool allowsElement(Element element) {
16435 return _allowedElements.contains(Element._safeTagName(element));
16436 }
16437
16438 bool allowsAttribute(Element element, String attributeName, String value) {
16439 var tagName = Element._safeTagName(element);
16440 var validator = _attributeValidators['$tagName::$attributeName'];
16441 if (validator == null) {
16442 validator = _attributeValidators['*::$attributeName'];
16443 }
16444 if (validator == null) {
16445 return false;
16446 }
16447 return validator(element, attributeName, value, this);
16448 }
16449
16450 static bool _standardAttributeValidator(Element element, String attributeName,
16451 String value, _Html5NodeValidator context) {
16452 return true;
16453 }
16454
16455 static bool _uriAttributeValidator(Element element, String attributeName,
16456 String value, _Html5NodeValidator context) {
16457 return context.uriPolicy.allowsUri(value);
16458 }
16459 }
16460 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
16461 // for details. All rights reserved. Use of this source code is governed by a
16462 // BSD-style license that can be found in the LICENSE file.
16463
16464
16465 abstract class ImmutableListMixin<E> implements List<E> {
16466 // From Iterable<$E>:
16467 Iterator<E> get iterator {
16468 // Note: NodeLists are not fixed size. And most probably length shouldn't
16469 // be cached in both iterator _and_ forEach method. For now caching it
16470 // for consistency.
16471 return new FixedSizeListIterator<E>(this);
16472 }
16473
16474 // From Collection<E>:
16475 void add(E value) {
16476 throw new UnsupportedError("Cannot add to immutable List.");
16477 }
16478
16479 void addAll(Iterable<E> iterable) {
16480 throw new UnsupportedError("Cannot add to immutable List.");
16481 }
16482
16483 // From List<E>:
16484 void sort([int compare(E a, E b)]) {
16485 throw new UnsupportedError("Cannot sort immutable List.");
16486 }
16487
16488 void shuffle([Random random]) {
16489 throw new UnsupportedError("Cannot shuffle immutable List.");
16490 }
16491
16492 void insert(int index, E element) {
16493 throw new UnsupportedError("Cannot add to immutable List.");
16494 }
16495
16496 void insertAll(int index, Iterable<E> iterable) {
16497 throw new UnsupportedError("Cannot add to immutable List.");
16498 }
16499
16500 void setAll(int index, Iterable<E> iterable) {
16501 throw new UnsupportedError("Cannot modify an immutable List.");
16502 }
16503
16504 E removeAt(int pos) {
16505 throw new UnsupportedError("Cannot remove from immutable List.");
16506 }
16507
16508 E removeLast() {
16509 throw new UnsupportedError("Cannot remove from immutable List.");
16510 }
16511
16512 bool remove(Object object) {
16513 throw new UnsupportedError("Cannot remove from immutable List.");
16514 }
16515
16516 void removeWhere(bool test(E element)) {
16517 throw new UnsupportedError("Cannot remove from immutable List.");
16518 }
16519
16520 void retainWhere(bool test(E element)) {
16521 throw new UnsupportedError("Cannot remove from immutable List.");
16522 }
16523
16524 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
16525 throw new UnsupportedError("Cannot setRange on immutable List.");
16526 }
16527
16528 void removeRange(int start, int end) {
16529 throw new UnsupportedError("Cannot removeRange on immutable List.");
16530 }
16531
16532 void replaceRange(int start, int end, Iterable<E> iterable) {
16533 throw new UnsupportedError("Cannot modify an immutable List.");
16534 }
16535
16536 void fillRange(int start, int end, [E fillValue]) {
16537 throw new UnsupportedError("Cannot modify an immutable List.");
16538 }
16539 }
16540 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
16541 // for details. All rights reserved. Use of this source code is governed by a
16542 // BSD-style license that can be found in the LICENSE file.
16543
16544
16545 /**
16546 * Defines the keycode values for keys that are returned by
16547 * KeyboardEvent.keyCode.
16548 *
16549 * Important note: There is substantial divergence in how different browsers
16550 * handle keycodes and their variants in different locales/keyboard layouts. We
16551 * provide these constants to help make code processing keys more readable.
16552 */
16553 abstract class KeyCode {
16554 // These constant names were borrowed from Closure's Keycode enumeration
16555 // class.
16556 // http://closure-library.googlecode.com/svn/docs/closure_goog_events_keycodes .js.source.html
16557 static const int WIN_KEY_FF_LINUX = 0;
16558 static const int MAC_ENTER = 3;
16559 static const int BACKSPACE = 8;
16560 static const int TAB = 9;
16561 /** NUM_CENTER is also NUMLOCK for FF and Safari on Mac. */
16562 static const int NUM_CENTER = 12;
16563 static const int ENTER = 13;
16564 static const int SHIFT = 16;
16565 static const int CTRL = 17;
16566 static const int ALT = 18;
16567 static const int PAUSE = 19;
16568 static const int CAPS_LOCK = 20;
16569 static const int ESC = 27;
16570 static const int SPACE = 32;
16571 static const int PAGE_UP = 33;
16572 static const int PAGE_DOWN = 34;
16573 static const int END = 35;
16574 static const int HOME = 36;
16575 static const int LEFT = 37;
16576 static const int UP = 38;
16577 static const int RIGHT = 39;
16578 static const int DOWN = 40;
16579 static const int NUM_NORTH_EAST = 33;
16580 static const int NUM_SOUTH_EAST = 34;
16581 static const int NUM_SOUTH_WEST = 35;
16582 static const int NUM_NORTH_WEST = 36;
16583 static const int NUM_WEST = 37;
16584 static const int NUM_NORTH = 38;
16585 static const int NUM_EAST = 39;
16586 static const int NUM_SOUTH = 40;
16587 static const int PRINT_SCREEN = 44;
16588 static const int INSERT = 45;
16589 static const int NUM_INSERT = 45;
16590 static const int DELETE = 46;
16591 static const int NUM_DELETE = 46;
16592 static const int ZERO = 48;
16593 static const int ONE = 49;
16594 static const int TWO = 50;
16595 static const int THREE = 51;
16596 static const int FOUR = 52;
16597 static const int FIVE = 53;
16598 static const int SIX = 54;
16599 static const int SEVEN = 55;
16600 static const int EIGHT = 56;
16601 static const int NINE = 57;
16602 static const int FF_SEMICOLON = 59;
16603 static const int FF_EQUALS = 61;
16604 /**
16605 * CAUTION: The question mark is for US-keyboard layouts. It varies
16606 * for other locales and keyboard layouts.
16607 */
16608 static const int QUESTION_MARK = 63;
16609 static const int A = 65;
16610 static const int B = 66;
16611 static const int C = 67;
16612 static const int D = 68;
16613 static const int E = 69;
16614 static const int F = 70;
16615 static const int G = 71;
16616 static const int H = 72;
16617 static const int I = 73;
16618 static const int J = 74;
16619 static const int K = 75;
16620 static const int L = 76;
16621 static const int M = 77;
16622 static const int N = 78;
16623 static const int O = 79;
16624 static const int P = 80;
16625 static const int Q = 81;
16626 static const int R = 82;
16627 static const int S = 83;
16628 static const int T = 84;
16629 static const int U = 85;
16630 static const int V = 86;
16631 static const int W = 87;
16632 static const int X = 88;
16633 static const int Y = 89;
16634 static const int Z = 90;
16635 static const int META = 91;
16636 static const int WIN_KEY_LEFT = 91;
16637 static const int WIN_KEY_RIGHT = 92;
16638 static const int CONTEXT_MENU = 93;
16639 static const int NUM_ZERO = 96;
16640 static const int NUM_ONE = 97;
16641 static const int NUM_TWO = 98;
16642 static const int NUM_THREE = 99;
16643 static const int NUM_FOUR = 100;
16644 static const int NUM_FIVE = 101;
16645 static const int NUM_SIX = 102;
16646 static const int NUM_SEVEN = 103;
16647 static const int NUM_EIGHT = 104;
16648 static const int NUM_NINE = 105;
16649 static const int NUM_MULTIPLY = 106;
16650 static const int NUM_PLUS = 107;
16651 static const int NUM_MINUS = 109;
16652 static const int NUM_PERIOD = 110;
16653 static const int NUM_DIVISION = 111;
16654 static const int F1 = 112;
16655 static const int F2 = 113;
16656 static const int F3 = 114;
16657 static const int F4 = 115;
16658 static const int F5 = 116;
16659 static const int F6 = 117;
16660 static const int F7 = 118;
16661 static const int F8 = 119;
16662 static const int F9 = 120;
16663 static const int F10 = 121;
16664 static const int F11 = 122;
16665 static const int F12 = 123;
16666 static const int NUMLOCK = 144;
16667 static const int SCROLL_LOCK = 145;
16668
16669 // OS-specific media keys like volume controls and browser controls.
16670 static const int FIRST_MEDIA_KEY = 166;
16671 static const int LAST_MEDIA_KEY = 183;
16672
16673 /**
16674 * CAUTION: This constant requires localization for other locales and keyboard
16675 * layouts.
16676 */
16677 static const int SEMICOLON = 186;
16678 /**
16679 * CAUTION: This constant requires localization for other locales and keyboard
16680 * layouts.
16681 */
16682 static const int DASH = 189;
16683 /**
16684 * CAUTION: This constant requires localization for other locales and keyboard
16685 * layouts.
16686 */
16687 static const int EQUALS = 187;
16688 /**
16689 * CAUTION: This constant requires localization for other locales and keyboard
16690 * layouts.
16691 */
16692 static const int COMMA = 188;
16693 /**
16694 * CAUTION: This constant requires localization for other locales and keyboard
16695 * layouts.
16696 */
16697 static const int PERIOD = 190;
16698 /**
16699 * CAUTION: This constant requires localization for other locales and keyboard
16700 * layouts.
16701 */
16702 static const int SLASH = 191;
16703 /**
16704 * CAUTION: This constant requires localization for other locales and keyboard
16705 * layouts.
16706 */
16707 static const int APOSTROPHE = 192;
16708 /**
16709 * CAUTION: This constant requires localization for other locales and keyboard
16710 * layouts.
16711 */
16712 static const int TILDE = 192;
16713 /**
16714 * CAUTION: This constant requires localization for other locales and keyboard
16715 * layouts.
16716 */
16717 static const int SINGLE_QUOTE = 222;
16718 /**
16719 * CAUTION: This constant requires localization for other locales and keyboard
16720 * layouts.
16721 */
16722 static const int OPEN_SQUARE_BRACKET = 219;
16723 /**
16724 * CAUTION: This constant requires localization for other locales and keyboard
16725 * layouts.
16726 */
16727 static const int BACKSLASH = 220;
16728 /**
16729 * CAUTION: This constant requires localization for other locales and keyboard
16730 * layouts.
16731 */
16732 static const int CLOSE_SQUARE_BRACKET = 221;
16733 static const int WIN_KEY = 224;
16734 static const int MAC_FF_META = 224;
16735 static const int WIN_IME = 229;
16736
16737 /** A sentinel value if the keycode could not be determined. */
16738 static const int UNKNOWN = -1;
16739
16740 /**
16741 * Returns true if the keyCode produces a (US keyboard) character.
16742 * Note: This does not (yet) cover characters on non-US keyboards (Russian,
16743 * Hebrew, etc.).
16744 */
16745 static bool isCharacterKey(int keyCode) {
16746 if ((keyCode >= ZERO && keyCode <= NINE) ||
16747 (keyCode >= NUM_ZERO && keyCode <= NUM_MULTIPLY) ||
16748 (keyCode >= A && keyCode <= Z)) {
16749 return true;
16750 }
16751
16752 // Safari sends zero key code for non-latin characters.
16753 if (Device.isWebKit && keyCode == 0) {
16754 return true;
16755 }
16756
16757 return (keyCode == SPACE || keyCode == QUESTION_MARK || keyCode == NUM_PLUS
16758 || keyCode == NUM_MINUS || keyCode == NUM_PERIOD ||
16759 keyCode == NUM_DIVISION || keyCode == SEMICOLON ||
16760 keyCode == FF_SEMICOLON || keyCode == DASH || keyCode == EQUALS ||
16761 keyCode == FF_EQUALS || keyCode == COMMA || keyCode == PERIOD ||
16762 keyCode == SLASH || keyCode == APOSTROPHE || keyCode == SINGLE_QUOTE ||
16763 keyCode == OPEN_SQUARE_BRACKET || keyCode == BACKSLASH ||
16764 keyCode == CLOSE_SQUARE_BRACKET);
16765 }
16766
16767 /**
16768 * Experimental helper function for converting keyCodes to keyNames for the
16769 * keyIdentifier attribute still used in browsers not updated with current
16770 * spec. This is an imperfect conversion! It will need to be refined, but
16771 * hopefully it can just completely go away once all the browsers update to
16772 * follow the DOM3 spec.
16773 */
16774 static String _convertKeyCodeToKeyName(int keyCode) {
16775 switch(keyCode) {
16776 case KeyCode.ALT: return _KeyName.ALT;
16777 case KeyCode.BACKSPACE: return _KeyName.BACKSPACE;
16778 case KeyCode.CAPS_LOCK: return _KeyName.CAPS_LOCK;
16779 case KeyCode.CTRL: return _KeyName.CONTROL;
16780 case KeyCode.DELETE: return _KeyName.DEL;
16781 case KeyCode.DOWN: return _KeyName.DOWN;
16782 case KeyCode.END: return _KeyName.END;
16783 case KeyCode.ENTER: return _KeyName.ENTER;
16784 case KeyCode.ESC: return _KeyName.ESC;
16785 case KeyCode.F1: return _KeyName.F1;
16786 case KeyCode.F2: return _KeyName.F2;
16787 case KeyCode.F3: return _KeyName.F3;
16788 case KeyCode.F4: return _KeyName.F4;
16789 case KeyCode.F5: return _KeyName.F5;
16790 case KeyCode.F6: return _KeyName.F6;
16791 case KeyCode.F7: return _KeyName.F7;
16792 case KeyCode.F8: return _KeyName.F8;
16793 case KeyCode.F9: return _KeyName.F9;
16794 case KeyCode.F10: return _KeyName.F10;
16795 case KeyCode.F11: return _KeyName.F11;
16796 case KeyCode.F12: return _KeyName.F12;
16797 case KeyCode.HOME: return _KeyName.HOME;
16798 case KeyCode.INSERT: return _KeyName.INSERT;
16799 case KeyCode.LEFT: return _KeyName.LEFT;
16800 case KeyCode.META: return _KeyName.META;
16801 case KeyCode.NUMLOCK: return _KeyName.NUM_LOCK;
16802 case KeyCode.PAGE_DOWN: return _KeyName.PAGE_DOWN;
16803 case KeyCode.PAGE_UP: return _KeyName.PAGE_UP;
16804 case KeyCode.PAUSE: return _KeyName.PAUSE;
16805 case KeyCode.PRINT_SCREEN: return _KeyName.PRINT_SCREEN;
16806 case KeyCode.RIGHT: return _KeyName.RIGHT;
16807 case KeyCode.SCROLL_LOCK: return _KeyName.SCROLL;
16808 case KeyCode.SHIFT: return _KeyName.SHIFT;
16809 case KeyCode.SPACE: return _KeyName.SPACEBAR;
16810 case KeyCode.TAB: return _KeyName.TAB;
16811 case KeyCode.UP: return _KeyName.UP;
16812 case KeyCode.WIN_IME:
16813 case KeyCode.WIN_KEY:
16814 case KeyCode.WIN_KEY_LEFT:
16815 case KeyCode.WIN_KEY_RIGHT:
16816 return _KeyName.WIN;
16817 default: return _KeyName.UNIDENTIFIED;
16818 }
16819 return _KeyName.UNIDENTIFIED;
16820 }
16821 }
16822 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
16823 // for details. All rights reserved. Use of this source code is governed by a
16824 // BSD-style license that can be found in the LICENSE file.
16825
16826
16827 /**
16828 * Defines the standard key locations returned by
16829 * KeyboardEvent.getKeyLocation.
16830 */
16831 abstract class KeyLocation {
16832
16833 /**
16834 * The event key is not distinguished as the left or right version
16835 * of the key, and did not originate from the numeric keypad (or did not
16836 * originate with a virtual key corresponding to the numeric keypad).
16837 */
16838 static const int STANDARD = 0;
16839
16840 /**
16841 * The event key is in the left key location.
16842 */
16843 static const int LEFT = 1;
16844
16845 /**
16846 * The event key is in the right key location.
16847 */
16848 static const int RIGHT = 2;
16849
16850 /**
16851 * The event key originated on the numeric keypad or with a virtual key
16852 * corresponding to the numeric keypad.
16853 */
16854 static const int NUMPAD = 3;
16855
16856 /**
16857 * The event key originated on a mobile device, either on a physical
16858 * keypad or a virtual keyboard.
16859 */
16860 static const int MOBILE = 4;
16861
16862 /**
16863 * The event key originated on a game controller or a joystick on a mobile
16864 * device.
16865 */
16866 static const int JOYSTICK = 5;
16867 }
16868 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
16869 // for details. All rights reserved. Use of this source code is governed by a
16870 // BSD-style license that can be found in the LICENSE file.
16871
16872
16873 /**
16874 * Defines the standard keyboard identifier names for keys that are returned
16875 * by KeyboardEvent.getKeyboardIdentifier when the key does not have a direct
16876 * unicode mapping.
16877 */
16878 abstract class _KeyName {
16879
16880 /** The Accept (Commit, OK) key */
16881 static const String ACCEPT = "Accept";
16882
16883 /** The Add key */
16884 static const String ADD = "Add";
16885
16886 /** The Again key */
16887 static const String AGAIN = "Again";
16888
16889 /** The All Candidates key */
16890 static const String ALL_CANDIDATES = "AllCandidates";
16891
16892 /** The Alphanumeric key */
16893 static const String ALPHANUMERIC = "Alphanumeric";
16894
16895 /** The Alt (Menu) key */
16896 static const String ALT = "Alt";
16897
16898 /** The Alt-Graph key */
16899 static const String ALT_GRAPH = "AltGraph";
16900
16901 /** The Application key */
16902 static const String APPS = "Apps";
16903
16904 /** The ATTN key */
16905 static const String ATTN = "Attn";
16906
16907 /** The Browser Back key */
16908 static const String BROWSER_BACK = "BrowserBack";
16909
16910 /** The Browser Favorites key */
16911 static const String BROWSER_FAVORTIES = "BrowserFavorites";
16912
16913 /** The Browser Forward key */
16914 static const String BROWSER_FORWARD = "BrowserForward";
16915
16916 /** The Browser Home key */
16917 static const String BROWSER_NAME = "BrowserHome";
16918
16919 /** The Browser Refresh key */
16920 static const String BROWSER_REFRESH = "BrowserRefresh";
16921
16922 /** The Browser Search key */
16923 static const String BROWSER_SEARCH = "BrowserSearch";
16924
16925 /** The Browser Stop key */
16926 static const String BROWSER_STOP = "BrowserStop";
16927
16928 /** The Camera key */
16929 static const String CAMERA = "Camera";
16930
16931 /** The Caps Lock (Capital) key */
16932 static const String CAPS_LOCK = "CapsLock";
16933
16934 /** The Clear key */
16935 static const String CLEAR = "Clear";
16936
16937 /** The Code Input key */
16938 static const String CODE_INPUT = "CodeInput";
16939
16940 /** The Compose key */
16941 static const String COMPOSE = "Compose";
16942
16943 /** The Control (Ctrl) key */
16944 static const String CONTROL = "Control";
16945
16946 /** The Crsel key */
16947 static const String CRSEL = "Crsel";
16948
16949 /** The Convert key */
16950 static const String CONVERT = "Convert";
16951
16952 /** The Copy key */
16953 static const String COPY = "Copy";
16954
16955 /** The Cut key */
16956 static const String CUT = "Cut";
16957
16958 /** The Decimal key */
16959 static const String DECIMAL = "Decimal";
16960
16961 /** The Divide key */
16962 static const String DIVIDE = "Divide";
16963
16964 /** The Down Arrow key */
16965 static const String DOWN = "Down";
16966
16967 /** The diagonal Down-Left Arrow key */
16968 static const String DOWN_LEFT = "DownLeft";
16969
16970 /** The diagonal Down-Right Arrow key */
16971 static const String DOWN_RIGHT = "DownRight";
16972
16973 /** The Eject key */
16974 static const String EJECT = "Eject";
16975
16976 /** The End key */
16977 static const String END = "End";
16978
16979 /**
16980 * The Enter key. Note: This key value must also be used for the Return
16981 * (Macintosh numpad) key
16982 */
16983 static const String ENTER = "Enter";
16984
16985 /** The Erase EOF key */
16986 static const String ERASE_EOF= "EraseEof";
16987
16988 /** The Execute key */
16989 static const String EXECUTE = "Execute";
16990
16991 /** The Exsel key */
16992 static const String EXSEL = "Exsel";
16993
16994 /** The Function switch key */
16995 static const String FN = "Fn";
16996
16997 /** The F1 key */
16998 static const String F1 = "F1";
16999
17000 /** The F2 key */
17001 static const String F2 = "F2";
17002
17003 /** The F3 key */
17004 static const String F3 = "F3";
17005
17006 /** The F4 key */
17007 static const String F4 = "F4";
17008
17009 /** The F5 key */
17010 static const String F5 = "F5";
17011
17012 /** The F6 key */
17013 static const String F6 = "F6";
17014
17015 /** The F7 key */
17016 static const String F7 = "F7";
17017
17018 /** The F8 key */
17019 static const String F8 = "F8";
17020
17021 /** The F9 key */
17022 static const String F9 = "F9";
17023
17024 /** The F10 key */
17025 static const String F10 = "F10";
17026
17027 /** The F11 key */
17028 static const String F11 = "F11";
17029
17030 /** The F12 key */
17031 static const String F12 = "F12";
17032
17033 /** The F13 key */
17034 static const String F13 = "F13";
17035
17036 /** The F14 key */
17037 static const String F14 = "F14";
17038
17039 /** The F15 key */
17040 static const String F15 = "F15";
17041
17042 /** The F16 key */
17043 static const String F16 = "F16";
17044
17045 /** The F17 key */
17046 static const String F17 = "F17";
17047
17048 /** The F18 key */
17049 static const String F18 = "F18";
17050
17051 /** The F19 key */
17052 static const String F19 = "F19";
17053
17054 /** The F20 key */
17055 static const String F20 = "F20";
17056
17057 /** The F21 key */
17058 static const String F21 = "F21";
17059
17060 /** The F22 key */
17061 static const String F22 = "F22";
17062
17063 /** The F23 key */
17064 static const String F23 = "F23";
17065
17066 /** The F24 key */
17067 static const String F24 = "F24";
17068
17069 /** The Final Mode (Final) key used on some asian keyboards */
17070 static const String FINAL_MODE = "FinalMode";
17071
17072 /** The Find key */
17073 static const String FIND = "Find";
17074
17075 /** The Full-Width Characters key */
17076 static const String FULL_WIDTH = "FullWidth";
17077
17078 /** The Half-Width Characters key */
17079 static const String HALF_WIDTH = "HalfWidth";
17080
17081 /** The Hangul (Korean characters) Mode key */
17082 static const String HANGUL_MODE = "HangulMode";
17083
17084 /** The Hanja (Korean characters) Mode key */
17085 static const String HANJA_MODE = "HanjaMode";
17086
17087 /** The Help key */
17088 static const String HELP = "Help";
17089
17090 /** The Hiragana (Japanese Kana characters) key */
17091 static const String HIRAGANA = "Hiragana";
17092
17093 /** The Home key */
17094 static const String HOME = "Home";
17095
17096 /** The Insert (Ins) key */
17097 static const String INSERT = "Insert";
17098
17099 /** The Japanese-Hiragana key */
17100 static const String JAPANESE_HIRAGANA = "JapaneseHiragana";
17101
17102 /** The Japanese-Katakana key */
17103 static const String JAPANESE_KATAKANA = "JapaneseKatakana";
17104
17105 /** The Japanese-Romaji key */
17106 static const String JAPANESE_ROMAJI = "JapaneseRomaji";
17107
17108 /** The Junja Mode key */
17109 static const String JUNJA_MODE = "JunjaMode";
17110
17111 /** The Kana Mode (Kana Lock) key */
17112 static const String KANA_MODE = "KanaMode";
17113
17114 /**
17115 * The Kanji (Japanese name for ideographic characters of Chinese origin)
17116 * Mode key
17117 */
17118 static const String KANJI_MODE = "KanjiMode";
17119
17120 /** The Katakana (Japanese Kana characters) key */
17121 static const String KATAKANA = "Katakana";
17122
17123 /** The Start Application One key */
17124 static const String LAUNCH_APPLICATION_1 = "LaunchApplication1";
17125
17126 /** The Start Application Two key */
17127 static const String LAUNCH_APPLICATION_2 = "LaunchApplication2";
17128
17129 /** The Start Mail key */
17130 static const String LAUNCH_MAIL = "LaunchMail";
17131
17132 /** The Left Arrow key */
17133 static const String LEFT = "Left";
17134
17135 /** The Menu key */
17136 static const String MENU = "Menu";
17137
17138 /**
17139 * The Meta key. Note: This key value shall be also used for the Apple
17140 * Command key
17141 */
17142 static const String META = "Meta";
17143
17144 /** The Media Next Track key */
17145 static const String MEDIA_NEXT_TRACK = "MediaNextTrack";
17146
17147 /** The Media Play Pause key */
17148 static const String MEDIA_PAUSE_PLAY = "MediaPlayPause";
17149
17150 /** The Media Previous Track key */
17151 static const String MEDIA_PREVIOUS_TRACK = "MediaPreviousTrack";
17152
17153 /** The Media Stop key */
17154 static const String MEDIA_STOP = "MediaStop";
17155
17156 /** The Mode Change key */
17157 static const String MODE_CHANGE = "ModeChange";
17158
17159 /** The Next Candidate function key */
17160 static const String NEXT_CANDIDATE = "NextCandidate";
17161
17162 /** The Nonconvert (Don't Convert) key */
17163 static const String NON_CONVERT = "Nonconvert";
17164
17165 /** The Number Lock key */
17166 static const String NUM_LOCK = "NumLock";
17167
17168 /** The Page Down (Next) key */
17169 static const String PAGE_DOWN = "PageDown";
17170
17171 /** The Page Up key */
17172 static const String PAGE_UP = "PageUp";
17173
17174 /** The Paste key */
17175 static const String PASTE = "Paste";
17176
17177 /** The Pause key */
17178 static const String PAUSE = "Pause";
17179
17180 /** The Play key */
17181 static const String PLAY = "Play";
17182
17183 /**
17184 * The Power key. Note: Some devices may not expose this key to the
17185 * operating environment
17186 */
17187 static const String POWER = "Power";
17188
17189 /** The Previous Candidate function key */
17190 static const String PREVIOUS_CANDIDATE = "PreviousCandidate";
17191
17192 /** The Print Screen (PrintScrn, SnapShot) key */
17193 static const String PRINT_SCREEN = "PrintScreen";
17194
17195 /** The Process key */
17196 static const String PROCESS = "Process";
17197
17198 /** The Props key */
17199 static const String PROPS = "Props";
17200
17201 /** The Right Arrow key */
17202 static const String RIGHT = "Right";
17203
17204 /** The Roman Characters function key */
17205 static const String ROMAN_CHARACTERS = "RomanCharacters";
17206
17207 /** The Scroll Lock key */
17208 static const String SCROLL = "Scroll";
17209
17210 /** The Select key */
17211 static const String SELECT = "Select";
17212
17213 /** The Select Media key */
17214 static const String SELECT_MEDIA = "SelectMedia";
17215
17216 /** The Separator key */
17217 static const String SEPARATOR = "Separator";
17218
17219 /** The Shift key */
17220 static const String SHIFT = "Shift";
17221
17222 /** The Soft1 key */
17223 static const String SOFT_1 = "Soft1";
17224
17225 /** The Soft2 key */
17226 static const String SOFT_2 = "Soft2";
17227
17228 /** The Soft3 key */
17229 static const String SOFT_3 = "Soft3";
17230
17231 /** The Soft4 key */
17232 static const String SOFT_4 = "Soft4";
17233
17234 /** The Stop key */
17235 static const String STOP = "Stop";
17236
17237 /** The Subtract key */
17238 static const String SUBTRACT = "Subtract";
17239
17240 /** The Symbol Lock key */
17241 static const String SYMBOL_LOCK = "SymbolLock";
17242
17243 /** The Up Arrow key */
17244 static const String UP = "Up";
17245
17246 /** The diagonal Up-Left Arrow key */
17247 static const String UP_LEFT = "UpLeft";
17248
17249 /** The diagonal Up-Right Arrow key */
17250 static const String UP_RIGHT = "UpRight";
17251
17252 /** The Undo key */
17253 static const String UNDO = "Undo";
17254
17255 /** The Volume Down key */
17256 static const String VOLUME_DOWN = "VolumeDown";
17257
17258 /** The Volume Mute key */
17259 static const String VOLUMN_MUTE = "VolumeMute";
17260
17261 /** The Volume Up key */
17262 static const String VOLUMN_UP = "VolumeUp";
17263
17264 /** The Windows Logo key */
17265 static const String WIN = "Win";
17266
17267 /** The Zoom key */
17268 static const String ZOOM = "Zoom";
17269
17270 /**
17271 * The Backspace (Back) key. Note: This key value shall be also used for the
17272 * key labeled 'delete' MacOS keyboards when not modified by the 'Fn' key
17273 */
17274 static const String BACKSPACE = "Backspace";
17275
17276 /** The Horizontal Tabulation (Tab) key */
17277 static const String TAB = "Tab";
17278
17279 /** The Cancel key */
17280 static const String CANCEL = "Cancel";
17281
17282 /** The Escape (Esc) key */
17283 static const String ESC = "Esc";
17284
17285 /** The Space (Spacebar) key: */
17286 static const String SPACEBAR = "Spacebar";
17287
17288 /**
17289 * The Delete (Del) Key. Note: This key value shall be also used for the key
17290 * labeled 'delete' MacOS keyboards when modified by the 'Fn' key
17291 */
17292 static const String DEL = "Del";
17293
17294 /** The Combining Grave Accent (Greek Varia, Dead Grave) key */
17295 static const String DEAD_GRAVE = "DeadGrave";
17296
17297 /**
17298 * The Combining Acute Accent (Stress Mark, Greek Oxia, Tonos, Dead Eacute)
17299 * key
17300 */
17301 static const String DEAD_EACUTE = "DeadEacute";
17302
17303 /** The Combining Circumflex Accent (Hat, Dead Circumflex) key */
17304 static const String DEAD_CIRCUMFLEX = "DeadCircumflex";
17305
17306 /** The Combining Tilde (Dead Tilde) key */
17307 static const String DEAD_TILDE = "DeadTilde";
17308
17309 /** The Combining Macron (Long, Dead Macron) key */
17310 static const String DEAD_MACRON = "DeadMacron";
17311
17312 /** The Combining Breve (Short, Dead Breve) key */
17313 static const String DEAD_BREVE = "DeadBreve";
17314
17315 /** The Combining Dot Above (Derivative, Dead Above Dot) key */
17316 static const String DEAD_ABOVE_DOT = "DeadAboveDot";
17317
17318 /**
17319 * The Combining Diaeresis (Double Dot Abode, Umlaut, Greek Dialytika,
17320 * Double Derivative, Dead Diaeresis) key
17321 */
17322 static const String DEAD_UMLAUT = "DeadUmlaut";
17323
17324 /** The Combining Ring Above (Dead Above Ring) key */
17325 static const String DEAD_ABOVE_RING = "DeadAboveRing";
17326
17327 /** The Combining Double Acute Accent (Dead Doubleacute) key */
17328 static const String DEAD_DOUBLEACUTE = "DeadDoubleacute";
17329
17330 /** The Combining Caron (Hacek, V Above, Dead Caron) key */
17331 static const String DEAD_CARON = "DeadCaron";
17332
17333 /** The Combining Cedilla (Dead Cedilla) key */
17334 static const String DEAD_CEDILLA = "DeadCedilla";
17335
17336 /** The Combining Ogonek (Nasal Hook, Dead Ogonek) key */
17337 static const String DEAD_OGONEK = "DeadOgonek";
17338
17339 /**
17340 * The Combining Greek Ypogegrammeni (Greek Non-Spacing Iota Below, Iota
17341 * Subscript, Dead Iota) key
17342 */
17343 static const String DEAD_IOTA = "DeadIota";
17344
17345 /**
17346 * The Combining Katakana-Hiragana Voiced Sound Mark (Dead Voiced Sound) key
17347 */
17348 static const String DEAD_VOICED_SOUND = "DeadVoicedSound";
17349
17350 /**
17351 * The Combining Katakana-Hiragana Semi-Voiced Sound Mark (Dead Semivoiced
17352 * Sound) key
17353 */
17354 static const String DEC_SEMIVOICED_SOUND= "DeadSemivoicedSound";
17355
17356 /**
17357 * Key value used when an implementation is unable to identify another key
17358 * value, due to either hardware, platform, or software constraints
17359 */
17360 static const String UNIDENTIFIED = "Unidentified";
17361 }
17362 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
17363 // for details. All rights reserved. Use of this source code is governed by a
17364 // BSD-style license that can be found in the LICENSE file.
17365
17366
17367 /**
17368 * Internal class that does the actual calculations to determine keyCode and
17369 * charCode for keydown, keypress, and keyup events for all browsers.
17370 */
17371 class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> {
17372 // This code inspired by Closure's KeyHandling library.
17373 // http://closure-library.googlecode.com/svn/docs/closure_goog_events_keyhandl er.js.source.html
17374
17375 /**
17376 * The set of keys that have been pressed down without seeing their
17377 * corresponding keyup event.
17378 */
17379 final List<KeyEvent> _keyDownList = <KeyEvent>[];
17380
17381 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */
17382 final String _type;
17383
17384 /** The element we are watching for events to happen on. */
17385 final EventTarget _target;
17386
17387 // The distance to shift from upper case alphabet Roman letters to lower case.
17388 static final int _ROMAN_ALPHABET_OFFSET = "a".codeUnits[0] - "A".codeUnits[0];
17389
17390 /** Custom Stream (Controller) to produce KeyEvents for the stream. */
17391 _CustomKeyEventStreamImpl _stream;
17392
17393 static const _EVENT_TYPE = 'KeyEvent';
17394
17395 /**
17396 * An enumeration of key identifiers currently part of the W3C draft for DOM3
17397 * and their mappings to keyCodes.
17398 * http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set
17399 */
17400 static const Map<String, int> _keyIdentifier = const {
17401 'Up': KeyCode.UP,
17402 'Down': KeyCode.DOWN,
17403 'Left': KeyCode.LEFT,
17404 'Right': KeyCode.RIGHT,
17405 'Enter': KeyCode.ENTER,
17406 'F1': KeyCode.F1,
17407 'F2': KeyCode.F2,
17408 'F3': KeyCode.F3,
17409 'F4': KeyCode.F4,
17410 'F5': KeyCode.F5,
17411 'F6': KeyCode.F6,
17412 'F7': KeyCode.F7,
17413 'F8': KeyCode.F8,
17414 'F9': KeyCode.F9,
17415 'F10': KeyCode.F10,
17416 'F11': KeyCode.F11,
17417 'F12': KeyCode.F12,
17418 'U+007F': KeyCode.DELETE,
17419 'Home': KeyCode.HOME,
17420 'End': KeyCode.END,
17421 'PageUp': KeyCode.PAGE_UP,
17422 'PageDown': KeyCode.PAGE_DOWN,
17423 'Insert': KeyCode.INSERT
17424 };
17425
17426 /** Return a stream for KeyEvents for the specified target. */
17427 // Note: this actually functions like a factory constructor.
17428 CustomStream<KeyEvent> forTarget(EventTarget e, {bool useCapture: false}) {
17429 var handler = new _KeyboardEventHandler.initializeAllEventListeners(
17430 _type, e);
17431 return handler._stream;
17432 }
17433
17434 /**
17435 * General constructor, performs basic initialization for our improved
17436 * KeyboardEvent controller.
17437 */
17438 _KeyboardEventHandler(this._type):
17439 _stream = new _CustomKeyEventStreamImpl('event'), _target = null,
17440 super(_EVENT_TYPE);
17441
17442 /**
17443 * Hook up all event listeners under the covers so we can estimate keycodes
17444 * and charcodes when they are not provided.
17445 */
17446 _KeyboardEventHandler.initializeAllEventListeners(this._type, this._target) :
17447 super(_EVENT_TYPE) {
17448 throw 'Key event handling not supported in DDC';
17449 /*
17450 Element.keyDownEvent.forTarget(_target, useCapture: true).listen(
17451 processKeyDown);
17452 Element.keyPressEvent.forTarget(_target, useCapture: true).listen(
17453 processKeyPress);
17454 Element.keyUpEvent.forTarget(_target, useCapture: true).listen(
17455 processKeyUp);
17456 _stream = new _CustomKeyEventStreamImpl(_type);
17457 */
17458 }
17459
17460 /** Determine if caps lock is one of the currently depressed keys. */
17461 bool get _capsLockOn =>
17462 _keyDownList.any((var element) => element.keyCode == KeyCode.CAPS_LOCK);
17463
17464 /**
17465 * Given the previously recorded keydown key codes, see if we can determine
17466 * the keycode of this keypress [event]. (Generally browsers only provide
17467 * charCode information for keypress events, but with a little
17468 * reverse-engineering, we can also determine the keyCode.) Returns
17469 * KeyCode.UNKNOWN if the keycode could not be determined.
17470 */
17471 int _determineKeyCodeForKeypress(KeyboardEvent event) {
17472 // Note: This function is a work in progress. We'll expand this function
17473 // once we get more information about other keyboards.
17474 for (var prevEvent in _keyDownList) {
17475 if (prevEvent._shadowCharCode == event.charCode) {
17476 return prevEvent.keyCode;
17477 }
17478 if ((event.shiftKey || _capsLockOn) && event.charCode >= "A".codeUnits[0]
17479 && event.charCode <= "Z".codeUnits[0] && event.charCode +
17480 _ROMAN_ALPHABET_OFFSET == prevEvent._shadowCharCode) {
17481 return prevEvent.keyCode;
17482 }
17483 }
17484 return KeyCode.UNKNOWN;
17485 }
17486
17487 /**
17488 * Given the charater code returned from a keyDown [event], try to ascertain
17489 * and return the corresponding charCode for the character that was pressed.
17490 * This information is not shown to the user, but used to help polyfill
17491 * keypress events.
17492 */
17493 int _findCharCodeKeyDown(KeyboardEvent event) {
17494 if (event.keyLocation == 3) { // Numpad keys.
17495 switch (event.keyCode) {
17496 case KeyCode.NUM_ZERO:
17497 // Even though this function returns _charCodes_, for some cases the
17498 // KeyCode == the charCode we want, in which case we use the keycode
17499 // constant for readability.
17500 return KeyCode.ZERO;
17501 case KeyCode.NUM_ONE:
17502 return KeyCode.ONE;
17503 case KeyCode.NUM_TWO:
17504 return KeyCode.TWO;
17505 case KeyCode.NUM_THREE:
17506 return KeyCode.THREE;
17507 case KeyCode.NUM_FOUR:
17508 return KeyCode.FOUR;
17509 case KeyCode.NUM_FIVE:
17510 return KeyCode.FIVE;
17511 case KeyCode.NUM_SIX:
17512 return KeyCode.SIX;
17513 case KeyCode.NUM_SEVEN:
17514 return KeyCode.SEVEN;
17515 case KeyCode.NUM_EIGHT:
17516 return KeyCode.EIGHT;
17517 case KeyCode.NUM_NINE:
17518 return KeyCode.NINE;
17519 case KeyCode.NUM_MULTIPLY:
17520 return 42; // Char code for *
17521 case KeyCode.NUM_PLUS:
17522 return 43; // +
17523 case KeyCode.NUM_MINUS:
17524 return 45; // -
17525 case KeyCode.NUM_PERIOD:
17526 return 46; // .
17527 case KeyCode.NUM_DIVISION:
17528 return 47; // /
17529 }
17530 } else if (event.keyCode >= 65 && event.keyCode <= 90) {
17531 // Set the "char code" for key down as the lower case letter. Again, this
17532 // will not show up for the user, but will be helpful in estimating
17533 // keyCode locations and other information during the keyPress event.
17534 return event.keyCode + _ROMAN_ALPHABET_OFFSET;
17535 }
17536 switch(event.keyCode) {
17537 case KeyCode.SEMICOLON:
17538 return KeyCode.FF_SEMICOLON;
17539 case KeyCode.EQUALS:
17540 return KeyCode.FF_EQUALS;
17541 case KeyCode.COMMA:
17542 return 44; // Ascii value for ,
17543 case KeyCode.DASH:
17544 return 45; // -
17545 case KeyCode.PERIOD:
17546 return 46; // .
17547 case KeyCode.SLASH:
17548 return 47; // /
17549 case KeyCode.APOSTROPHE:
17550 return 96; // `
17551 case KeyCode.OPEN_SQUARE_BRACKET:
17552 return 91; // [
17553 case KeyCode.BACKSLASH:
17554 return 92; // \
17555 case KeyCode.CLOSE_SQUARE_BRACKET:
17556 return 93; // ]
17557 case KeyCode.SINGLE_QUOTE:
17558 return 39; // '
17559 }
17560 return event.keyCode;
17561 }
17562
17563 /**
17564 * Returns true if the key fires a keypress event in the current browser.
17565 */
17566 bool _firesKeyPressEvent(KeyEvent event) {
17567 if (!Device.isIE && !Device.isWebKit) {
17568 return true;
17569 }
17570
17571 if (Device.userAgent.contains('Mac') && event.altKey) {
17572 return KeyCode.isCharacterKey(event.keyCode);
17573 }
17574
17575 // Alt but not AltGr which is represented as Alt+Ctrl.
17576 if (event.altKey && !event.ctrlKey) {
17577 return false;
17578 }
17579
17580 // Saves Ctrl or Alt + key for IE and WebKit, which won't fire keypress.
17581 if (!event.shiftKey &&
17582 (_keyDownList.last.keyCode == KeyCode.CTRL ||
17583 _keyDownList.last.keyCode == KeyCode.ALT ||
17584 Device.userAgent.contains('Mac') &&
17585 _keyDownList.last.keyCode == KeyCode.META)) {
17586 return false;
17587 }
17588
17589 // Some keys with Ctrl/Shift do not issue keypress in WebKit.
17590 if (Device.isWebKit && event.ctrlKey && event.shiftKey && (
17591 event.keyCode == KeyCode.BACKSLASH ||
17592 event.keyCode == KeyCode.OPEN_SQUARE_BRACKET ||
17593 event.keyCode == KeyCode.CLOSE_SQUARE_BRACKET ||
17594 event.keyCode == KeyCode.TILDE ||
17595 event.keyCode == KeyCode.SEMICOLON || event.keyCode == KeyCode.DASH ||
17596 event.keyCode == KeyCode.EQUALS || event.keyCode == KeyCode.COMMA ||
17597 event.keyCode == KeyCode.PERIOD || event.keyCode == KeyCode.SLASH ||
17598 event.keyCode == KeyCode.APOSTROPHE ||
17599 event.keyCode == KeyCode.SINGLE_QUOTE)) {
17600 return false;
17601 }
17602
17603 switch (event.keyCode) {
17604 case KeyCode.ENTER:
17605 // IE9 does not fire keypress on ENTER.
17606 return !Device.isIE;
17607 case KeyCode.ESC:
17608 return !Device.isWebKit;
17609 }
17610
17611 return KeyCode.isCharacterKey(event.keyCode);
17612 }
17613
17614 /**
17615 * Normalize the keycodes to the IE KeyCodes (this is what Chrome, IE, and
17616 * Opera all use).
17617 */
17618 int _normalizeKeyCodes(KeyboardEvent event) {
17619 // Note: This may change once we get input about non-US keyboards.
17620 if (Device.isFirefox) {
17621 switch(event.keyCode) {
17622 case KeyCode.FF_EQUALS:
17623 return KeyCode.EQUALS;
17624 case KeyCode.FF_SEMICOLON:
17625 return KeyCode.SEMICOLON;
17626 case KeyCode.MAC_FF_META:
17627 return KeyCode.META;
17628 case KeyCode.WIN_KEY_FF_LINUX:
17629 return KeyCode.WIN_KEY;
17630 }
17631 }
17632 return event.keyCode;
17633 }
17634
17635 /** Handle keydown events. */
17636 void processKeyDown(KeyboardEvent e) {
17637 // Ctrl-Tab and Alt-Tab can cause the focus to be moved to another window
17638 // before we've caught a key-up event. If the last-key was one of these
17639 // we reset the state.
17640 if (_keyDownList.length > 0 &&
17641 (_keyDownList.last.keyCode == KeyCode.CTRL && !e.ctrlKey ||
17642 _keyDownList.last.keyCode == KeyCode.ALT && !e.altKey ||
17643 Device.userAgent.contains('Mac') &&
17644 _keyDownList.last.keyCode == KeyCode.META && !e.metaKey)) {
17645 _keyDownList.clear();
17646 }
17647
17648 var event = new KeyEvent.wrap(e);
17649 event._shadowKeyCode = _normalizeKeyCodes(event);
17650 // Technically a "keydown" event doesn't have a charCode. This is
17651 // calculated nonetheless to provide us with more information in giving
17652 // as much information as possible on keypress about keycode and also
17653 // charCode.
17654 event._shadowCharCode = _findCharCodeKeyDown(event);
17655 if (_keyDownList.length > 0 && event.keyCode != _keyDownList.last.keyCode &&
17656 !_firesKeyPressEvent(event)) {
17657 // Some browsers have quirks not firing keypress events where all other
17658 // browsers do. This makes them more consistent.
17659 processKeyPress(e);
17660 }
17661 _keyDownList.add(event);
17662 _stream.add(event);
17663 }
17664
17665 /** Handle keypress events. */
17666 void processKeyPress(KeyboardEvent event) {
17667 var e = new KeyEvent.wrap(event);
17668 // IE reports the character code in the keyCode field for keypress events.
17669 // There are two exceptions however, Enter and Escape.
17670 if (Device.isIE) {
17671 if (e.keyCode == KeyCode.ENTER || e.keyCode == KeyCode.ESC) {
17672 e._shadowCharCode = 0;
17673 } else {
17674 e._shadowCharCode = e.keyCode;
17675 }
17676 } else if (Device.isOpera) {
17677 // Opera reports the character code in the keyCode field.
17678 e._shadowCharCode = KeyCode.isCharacterKey(e.keyCode) ? e.keyCode : 0;
17679 }
17680 // Now we guestimate about what the keycode is that was actually
17681 // pressed, given previous keydown information.
17682 e._shadowKeyCode = _determineKeyCodeForKeypress(e);
17683
17684 // Correct the key value for certain browser-specific quirks.
17685 if (e._shadowKeyIdentifier != null &&
17686 _keyIdentifier.containsKey(e._shadowKeyIdentifier)) {
17687 // This is needed for Safari Windows because it currently doesn't give a
17688 // keyCode/which for non printable keys.
17689 e._shadowKeyCode = _keyIdentifier[e._shadowKeyIdentifier];
17690 }
17691 e._shadowAltKey = _keyDownList.any((var element) => element.altKey);
17692 _stream.add(e);
17693 }
17694
17695 /** Handle keyup events. */
17696 void processKeyUp(KeyboardEvent event) {
17697 var e = new KeyEvent.wrap(event);
17698 KeyboardEvent toRemove = null;
17699 for (var key in _keyDownList) {
17700 if (key.keyCode == e.keyCode) {
17701 toRemove = key;
17702 }
17703 }
17704 if (toRemove != null) {
17705 _keyDownList.removeWhere((element) => element == toRemove);
17706 } else if (_keyDownList.length > 0) {
17707 // This happens when we've reached some international keyboard case we
17708 // haven't accounted for or we haven't correctly eliminated all browser
17709 // inconsistencies. Filing bugs on when this is reached is welcome!
17710 _keyDownList.removeLast();
17711 }
17712 _stream.add(e);
17713 }
17714 }
17715
17716
17717 /**
17718 * Records KeyboardEvents that occur on a particular element, and provides a
17719 * stream of outgoing KeyEvents with cross-browser consistent keyCode and
17720 * charCode values despite the fact that a multitude of browsers that have
17721 * varying keyboard default behavior.
17722 *
17723 * Example usage:
17724 *
17725 * KeyboardEventStream.onKeyDown(document.body).listen(
17726 * keydownHandlerTest);
17727 *
17728 * This class is very much a work in progress, and we'd love to get information
17729 * on how we can make this class work with as many international keyboards as
17730 * possible. Bugs welcome!
17731 */
17732 class KeyboardEventStream {
17733
17734 /** Named constructor to produce a stream for onKeyPress events. */
17735 static CustomStream<KeyEvent> onKeyPress(EventTarget target) =>
17736 new _KeyboardEventHandler('keypress').forTarget(target);
17737
17738 /** Named constructor to produce a stream for onKeyUp events. */
17739 static CustomStream<KeyEvent> onKeyUp(EventTarget target) =>
17740 new _KeyboardEventHandler('keyup').forTarget(target);
17741
17742 /** Named constructor to produce a stream for onKeyDown events. */
17743 static CustomStream<KeyEvent> onKeyDown(EventTarget target) =>
17744 new _KeyboardEventHandler('keydown').forTarget(target);
17745 }
17746 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
17747 // for details. All rights reserved. Use of this source code is governed by a
17748 // BSD-style license that can be found in the LICENSE file.
17749
17750
17751
17752 /**
17753 * Class which helps construct standard node validation policies.
17754 *
17755 * By default this will not accept anything, but the 'allow*' functions can be
17756 * used to expand what types of elements or attributes are allowed.
17757 *
17758 * All allow functions are additive- elements will be accepted if they are
17759 * accepted by any specific rule.
17760 *
17761 * It is important to remember that sanitization is not just intended to prevent
17762 * cross-site scripting attacks, but also to prevent information from being
17763 * displayed in unexpected ways. For example something displaying basic
17764 * formatted text may not expect `<video>` tags to appear. In this case an
17765 * empty NodeValidatorBuilder with just [allowTextElements] might be
17766 * appropriate.
17767 */
17768 class NodeValidatorBuilder implements NodeValidator {
17769
17770 final List<NodeValidator> _validators = <NodeValidator>[];
17771
17772 NodeValidatorBuilder() {
17773 }
17774
17775 /**
17776 * Creates a new NodeValidatorBuilder which accepts common constructs.
17777 *
17778 * By default this will accept HTML5 elements and attributes with the default
17779 * [UriPolicy] and templating elements.
17780 *
17781 * Notable syntax which is filtered:
17782 *
17783 * * Only known-good HTML5 elements and attributes are allowed.
17784 * * All URLs must be same-origin, use [allowNavigation] and [allowImages] to
17785 * specify additional URI policies.
17786 * * Inline-styles are not allowed.
17787 * * Custom element tags are disallowed, use [allowCustomElement].
17788 * * Custom tags extensions are disallowed, use [allowTagExtension].
17789 * * SVG Elements are not allowed, use [allowSvg].
17790 *
17791 * For scenarios where the HTML should only contain formatted text
17792 * [allowTextElements] is more appropriate.
17793 *
17794 * Use [allowSvg] to allow SVG elements.
17795 */
17796 NodeValidatorBuilder.common() {
17797 allowHtml5();
17798 allowTemplating();
17799 }
17800
17801 /**
17802 * Allows navigation elements- Form and Anchor tags, along with common
17803 * attributes.
17804 *
17805 * The UriPolicy can be used to restrict the locations the navigation elements
17806 * are allowed to direct to. By default this will use the default [UriPolicy].
17807 */
17808 void allowNavigation([UriPolicy uriPolicy]) {
17809 if (uriPolicy == null) {
17810 uriPolicy = new UriPolicy();
17811 }
17812 add(new _SimpleNodeValidator.allowNavigation(uriPolicy));
17813 }
17814
17815 /**
17816 * Allows image elements.
17817 *
17818 * The UriPolicy can be used to restrict the locations the images may be
17819 * loaded from. By default this will use the default [UriPolicy].
17820 */
17821 void allowImages([UriPolicy uriPolicy]) {
17822 if (uriPolicy == null) {
17823 uriPolicy = new UriPolicy();
17824 }
17825 add(new _SimpleNodeValidator.allowImages(uriPolicy));
17826 }
17827
17828 /**
17829 * Allow basic text elements.
17830 *
17831 * This allows a subset of HTML5 elements, specifically just these tags and
17832 * no attributes.
17833 *
17834 * * B
17835 * * BLOCKQUOTE
17836 * * BR
17837 * * EM
17838 * * H1
17839 * * H2
17840 * * H3
17841 * * H4
17842 * * H5
17843 * * H6
17844 * * HR
17845 * * I
17846 * * LI
17847 * * OL
17848 * * P
17849 * * SPAN
17850 * * UL
17851 */
17852 void allowTextElements() {
17853 add(new _SimpleNodeValidator.allowTextElements());
17854 }
17855
17856 /**
17857 * Allow inline styles on elements.
17858 *
17859 * If [tagName] is not specified then this allows inline styles on all
17860 * elements. Otherwise tagName limits the styles to the specified elements.
17861 */
17862 void allowInlineStyles({String tagName}) {
17863 if (tagName == null) {
17864 tagName = '*';
17865 } else {
17866 tagName = tagName.toUpperCase();
17867 }
17868 add(new _SimpleNodeValidator(null, allowedAttributes: ['$tagName::style']));
17869 }
17870
17871 /**
17872 * Allow common safe HTML5 elements and attributes.
17873 *
17874 * This list is based off of the Caja whitelists at:
17875 * https://code.google.com/p/google-caja/wiki/CajaWhitelists.
17876 *
17877 * Common things which are not allowed are script elements, style attributes
17878 * and any script handlers.
17879 */
17880 void allowHtml5({UriPolicy uriPolicy}) {
17881 add(new _Html5NodeValidator(uriPolicy: uriPolicy));
17882 }
17883
17884 /**
17885 * Allow SVG elements and attributes except for known bad ones.
17886 */
17887 void allowSvg() {
17888 throw 'SVG not supported with DDC';
17889 // add(new _SvgNodeValidator());
17890 }
17891
17892 /**
17893 * Allow custom elements with the specified tag name and specified attributes.
17894 *
17895 * This will allow the elements as custom tags (such as <x-foo></x-foo>),
17896 * but will not allow tag extensions. Use [allowTagExtension] to allow
17897 * tag extensions.
17898 */
17899 void allowCustomElement(String tagName,
17900 {UriPolicy uriPolicy,
17901 Iterable<String> attributes,
17902 Iterable<String> uriAttributes}) {
17903
17904 var tagNameUpper = tagName.toUpperCase();
17905 var attrs;
17906 if (attributes != null) {
17907 attrs =
17908 attributes.map((name) => '$tagNameUpper::${name.toLowerCase()}');
17909 }
17910 var uriAttrs;
17911 if (uriAttributes != null) {
17912 uriAttrs =
17913 uriAttributes.map((name) => '$tagNameUpper::${name.toLowerCase()}');
17914 }
17915 if (uriPolicy == null) {
17916 uriPolicy = new UriPolicy();
17917 }
17918
17919 add(new _CustomElementNodeValidator(
17920 uriPolicy,
17921 [tagNameUpper],
17922 attrs,
17923 uriAttrs,
17924 false,
17925 true));
17926 }
17927
17928 /**
17929 * Allow custom tag extensions with the specified type name and specified
17930 * attributes.
17931 *
17932 * This will allow tag extensions (such as <div is="x-foo"></div>),
17933 * but will not allow custom tags. Use [allowCustomElement] to allow
17934 * custom tags.
17935 */
17936 void allowTagExtension(String tagName, String baseName,
17937 {UriPolicy uriPolicy,
17938 Iterable<String> attributes,
17939 Iterable<String> uriAttributes}) {
17940
17941 var baseNameUpper = baseName.toUpperCase();
17942 var tagNameUpper = tagName.toUpperCase();
17943 var attrs;
17944 if (attributes != null) {
17945 attrs =
17946 attributes.map((name) => '$baseNameUpper::${name.toLowerCase()}');
17947 }
17948 var uriAttrs;
17949 if (uriAttributes != null) {
17950 uriAttrs =
17951 uriAttributes.map((name) => '$baseNameUpper::${name.toLowerCase()}');
17952 }
17953 if (uriPolicy == null) {
17954 uriPolicy = new UriPolicy();
17955 }
17956
17957 add(new _CustomElementNodeValidator(
17958 uriPolicy,
17959 [tagNameUpper, baseNameUpper],
17960 attrs,
17961 uriAttrs,
17962 true,
17963 false));
17964 }
17965
17966 void allowElement(String tagName, {UriPolicy uriPolicy,
17967 Iterable<String> attributes,
17968 Iterable<String> uriAttributes}) {
17969
17970 allowCustomElement(tagName, uriPolicy: uriPolicy,
17971 attributes: attributes,
17972 uriAttributes: uriAttributes);
17973 }
17974
17975 /**
17976 * Allow templating elements (such as <template> and template-related
17977 * attributes.
17978 *
17979 * This still requires other validators to allow regular attributes to be
17980 * bound (such as [allowHtml5]).
17981 */
17982 void allowTemplating() {
17983 add(new _TemplatingNodeValidator());
17984 }
17985
17986 /**
17987 * Add an additional validator to the current list of validators.
17988 *
17989 * Elements and attributes will be accepted if they are accepted by any
17990 * validators.
17991 */
17992 void add(NodeValidator validator) {
17993 _validators.add(validator);
17994 }
17995
17996 bool allowsElement(Element element) {
17997 return _validators.any((v) => v.allowsElement(element));
17998 }
17999
18000 bool allowsAttribute(Element element, String attributeName, String value) {
18001 return _validators.any(
18002 (v) => v.allowsAttribute(element, attributeName, value));
18003 }
18004 }
18005
18006 class _SimpleNodeValidator implements NodeValidator {
18007 final Set<String> allowedElements = new Set<String>();
18008 final Set<String> allowedAttributes = new Set<String>();
18009 final Set<String> allowedUriAttributes = new Set<String>();
18010 final UriPolicy uriPolicy;
18011
18012 factory _SimpleNodeValidator.allowNavigation(UriPolicy uriPolicy) {
18013 return new _SimpleNodeValidator(uriPolicy,
18014 allowedElements: const [
18015 'A',
18016 'FORM'],
18017 allowedAttributes: const [
18018 'A::accesskey',
18019 'A::coords',
18020 'A::hreflang',
18021 'A::name',
18022 'A::shape',
18023 'A::tabindex',
18024 'A::target',
18025 'A::type',
18026 'FORM::accept',
18027 'FORM::autocomplete',
18028 'FORM::enctype',
18029 'FORM::method',
18030 'FORM::name',
18031 'FORM::novalidate',
18032 'FORM::target',
18033 ],
18034 allowedUriAttributes: const [
18035 'A::href',
18036 'FORM::action',
18037 ]);
18038 }
18039
18040 factory _SimpleNodeValidator.allowImages(UriPolicy uriPolicy) {
18041 return new _SimpleNodeValidator(uriPolicy,
18042 allowedElements: const [
18043 'IMG'
18044 ],
18045 allowedAttributes: const [
18046 'IMG::align',
18047 'IMG::alt',
18048 'IMG::border',
18049 'IMG::height',
18050 'IMG::hspace',
18051 'IMG::ismap',
18052 'IMG::name',
18053 'IMG::usemap',
18054 'IMG::vspace',
18055 'IMG::width',
18056 ],
18057 allowedUriAttributes: const [
18058 'IMG::src',
18059 ]);
18060 }
18061
18062 factory _SimpleNodeValidator.allowTextElements() {
18063 return new _SimpleNodeValidator(null,
18064 allowedElements: const [
18065 'B',
18066 'BLOCKQUOTE',
18067 'BR',
18068 'EM',
18069 'H1',
18070 'H2',
18071 'H3',
18072 'H4',
18073 'H5',
18074 'H6',
18075 'HR',
18076 'I',
18077 'LI',
18078 'OL',
18079 'P',
18080 'SPAN',
18081 'UL',
18082 ]);
18083 }
18084
18085 /**
18086 * Elements must be uppercased tag names. For example `'IMG'`.
18087 * Attributes must be uppercased tag name followed by :: followed by
18088 * lowercase attribute name. For example `'IMG:src'`.
18089 */
18090 _SimpleNodeValidator(this.uriPolicy,
18091 {Iterable<String> allowedElements, Iterable<String> allowedAttributes,
18092 Iterable<String> allowedUriAttributes}) {
18093 this.allowedElements.addAll(allowedElements ?? const []);
18094 allowedAttributes = allowedAttributes ?? const [];
18095 allowedUriAttributes = allowedUriAttributes ?? const [];
18096 var legalAttributes = allowedAttributes.where(
18097 (x) => !_Html5NodeValidator._uriAttributes.contains(x));
18098 var extraUriAttributes = allowedAttributes.where(
18099 (x) => _Html5NodeValidator._uriAttributes.contains(x));
18100 this.allowedAttributes.addAll(legalAttributes);
18101 this.allowedUriAttributes.addAll(allowedUriAttributes);
18102 this.allowedUriAttributes.addAll(extraUriAttributes);
18103 }
18104
18105 bool allowsElement(Element element) {
18106 return allowedElements.contains(Element._safeTagName(element));
18107 }
18108
18109 bool allowsAttribute(Element element, String attributeName, String value) {
18110 var tagName = Element._safeTagName(element);
18111 if (allowedUriAttributes.contains('$tagName::$attributeName')) {
18112 return uriPolicy.allowsUri(value);
18113 } else if (allowedUriAttributes.contains('*::$attributeName')) {
18114 return uriPolicy.allowsUri(value);
18115 } else if (allowedAttributes.contains('$tagName::$attributeName')) {
18116 return true;
18117 } else if (allowedAttributes.contains('*::$attributeName')) {
18118 return true;
18119 } else if (allowedAttributes.contains('$tagName::*')) {
18120 return true;
18121 } else if (allowedAttributes.contains('*::*')) {
18122 return true;
18123 }
18124 return false;
18125 }
18126 }
18127
18128 class _CustomElementNodeValidator extends _SimpleNodeValidator {
18129 final bool allowTypeExtension;
18130 final bool allowCustomTag;
18131
18132 _CustomElementNodeValidator(UriPolicy uriPolicy,
18133 Iterable<String> allowedElements,
18134 Iterable<String> allowedAttributes,
18135 Iterable<String> allowedUriAttributes,
18136 bool allowTypeExtension,
18137 bool allowCustomTag):
18138
18139 this.allowTypeExtension = allowTypeExtension == true,
18140 this.allowCustomTag = allowCustomTag == true,
18141 super(uriPolicy,
18142 allowedElements: allowedElements,
18143 allowedAttributes: allowedAttributes,
18144 allowedUriAttributes: allowedUriAttributes);
18145
18146 bool allowsElement(Element element) {
18147 if (allowTypeExtension) {
18148 var isAttr = element.attributes['is'];
18149 if (isAttr != null) {
18150 return allowedElements.contains(isAttr.toUpperCase()) &&
18151 allowedElements.contains(Element._safeTagName(element));
18152 }
18153 }
18154 return allowCustomTag && allowedElements.contains(Element._safeTagName(eleme nt));
18155 }
18156
18157 bool allowsAttribute(Element element, String attributeName, String value) {
18158 if (allowsElement(element)) {
18159 if (allowTypeExtension && attributeName == 'is' &&
18160 allowedElements.contains(value.toUpperCase())) {
18161 return true;
18162 }
18163 return super.allowsAttribute(element, attributeName, value);
18164 }
18165 return false;
18166 }
18167 }
18168
18169 class _TemplatingNodeValidator extends _SimpleNodeValidator {
18170 static const _TEMPLATE_ATTRS =
18171 const <String>['bind', 'if', 'ref', 'repeat', 'syntax'];
18172
18173 final Set<String> _templateAttrs;
18174
18175 _TemplatingNodeValidator():
18176 _templateAttrs = new Set<String>.from(_TEMPLATE_ATTRS),
18177 super(null,
18178 allowedElements: [
18179 'TEMPLATE'
18180 ],
18181 allowedAttributes: _TEMPLATE_ATTRS.map((attr) => 'TEMPLATE::$attr'));
18182
18183 bool allowsAttribute(Element element, String attributeName, String value) {
18184 if (super.allowsAttribute(element, attributeName, value)) {
18185 return true;
18186 }
18187
18188 if (attributeName == 'template' && value == "") {
18189 return true;
18190 }
18191
18192 if (element.attributes['template'] == "" ) {
18193 return _templateAttrs.contains(attributeName);
18194 }
18195 return false;
18196 }
18197 }
18198
18199 /*
18200 class _SvgNodeValidator implements NodeValidator {
18201 bool allowsElement(Element element) {
18202 if (element is svg.ScriptElement) {
18203 return false;
18204 }
18205 // Firefox 37 has issues with creating foreign elements inside a
18206 // foreignobject tag as SvgElement. We don't want foreignobject contents
18207 // anyway, so just remove the whole tree outright. And we can't rely
18208 // on IE recognizing the SvgForeignObject type, so go by tagName. Bug 23144
18209 if (element is svg.SvgElement && Element._safeTagName(element) == 'foreignOb ject') {
18210 return false;
18211 }
18212 if (element is svg.SvgElement) {
18213 return true;
18214 }
18215 return false;
18216 }
18217
18218 bool allowsAttribute(Element element, String attributeName, String value) {
18219 if (attributeName == 'is' || attributeName.startsWith('on')) {
18220 return false;
18221 }
18222 return allowsElement(element);
18223 }
18224 }
18225 */// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
18226 // for details. All rights reserved. Use of this source code is governed by a
18227 // BSD-style license that can be found in the LICENSE file.
18228
18229
18230 /**
18231 * Contains the set of standard values returned by HTMLDocument.getReadyState.
18232 */
18233 abstract class ReadyState {
18234 /**
18235 * Indicates the document is still loading and parsing.
18236 */
18237 static const String LOADING = "loading";
18238
18239 /**
18240 * Indicates the document is finished parsing but is still loading
18241 * subresources.
18242 */
18243 static const String INTERACTIVE = "interactive";
18244
18245 /**
18246 * Indicates the document and all subresources have been loaded.
18247 */
18248 static const String COMPLETE = "complete";
18249 }
18250 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
18251 // for details. All rights reserved. Use of this source code is governed by a
18252 // BSD-style license that can be found in the LICENSE file.
18253
18254
18255 /**
18256 * A list which just wraps another list, for either intercepting list calls or
18257 * retyping the list (for example, from List<A> to List<B> where B extends A).
18258 */
18259 class _WrappedList<E extends Node> extends ListBase<E>
18260 implements NodeListWrapper {
18261 final List _list;
18262
18263 _WrappedList(this._list);
18264
18265 // Iterable APIs
18266
18267 Iterator<E> get iterator => new _WrappedIterator(_list.iterator);
18268
18269 int get length => _list.length;
18270
18271 // Collection APIs
18272
18273 void add(E element) { _list.add(element); }
18274
18275 bool remove(Object element) => _list.remove(element);
18276
18277 void clear() { _list.clear(); }
18278
18279 // List APIs
18280
18281 E operator [](int index) => _list[index];
18282
18283 void operator []=(int index, E value) { _list[index] = value; }
18284
18285 set length(int newLength) { _list.length = newLength; }
18286
18287 void sort([int compare(E a, E b)]) { _list.sort(compare); }
18288
18289 int indexOf(Object element, [int start = 0]) => _list.indexOf(element, start);
18290
18291 int lastIndexOf(Object element, [int start]) => _list.lastIndexOf(element, sta rt);
18292
18293 void insert(int index, E element) => _list.insert(index, element);
18294
18295 E removeAt(int index) => _list.removeAt(index);
18296
18297 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
18298 _list.setRange(start, end, iterable, skipCount);
18299 }
18300
18301 void removeRange(int start, int end) { _list.removeRange(start, end); }
18302
18303 void replaceRange(int start, int end, Iterable<E> iterable) {
18304 _list.replaceRange(start, end, iterable);
18305 }
18306
18307 void fillRange(int start, int end, [E fillValue]) {
18308 _list.fillRange(start, end, fillValue);
18309 }
18310
18311 List<Node> get rawList => _list;
18312 }
18313
18314 /**
18315 * Iterator wrapper for _WrappedList.
18316 */
18317 class _WrappedIterator<E> implements Iterator<E> {
18318 Iterator _iterator;
18319
18320 _WrappedIterator(this._iterator);
18321
18322 bool moveNext() {
18323 return _iterator.moveNext();
18324 }
18325
18326 E get current => _iterator.current;
18327 }
18328 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
18329 // for details. All rights reserved. Use of this source code is governed by a
18330 // BSD-style license that can be found in the LICENSE file.
18331
18332
18333 class _HttpRequestUtils {
18334
18335 // Helper for factory HttpRequest.get
18336 static HttpRequest get(String url,
18337 onComplete(HttpRequest request),
18338 bool withCredentials) {
18339 final request = new HttpRequest();
18340 request.open('GET', url, async: true);
18341
18342 request.withCredentials = withCredentials;
18343
18344 request.onReadyStateChange.listen((e) {
18345 if (request.readyState == HttpRequest.DONE) {
18346 onComplete(request);
18347 }
18348 });
18349
18350 request.send();
18351
18352 return request;
18353 }
18354 }
18355 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
18356 // for details. All rights reserved. Use of this source code is governed by a
18357 // BSD-style license that can be found in the LICENSE file.
18358
18359
18360 // Iterator for arrays with fixed size.
18361 class FixedSizeListIterator<T> implements Iterator<T> {
18362 final List<T> _array;
18363 final int _length; // Cache array length for faster access.
18364 int _position;
18365 T _current;
18366
18367 FixedSizeListIterator(List<T> array)
18368 : _array = array,
18369 _position = -1,
18370 _length = array.length;
18371
18372 bool moveNext() {
18373 int nextPosition = _position + 1;
18374 if (nextPosition < _length) {
18375 _current = _array[nextPosition];
18376 _position = nextPosition;
18377 return true;
18378 }
18379 _current = null;
18380 _position = _length;
18381 return false;
18382 }
18383
18384 T get current => _current;
18385 }
18386
18387 // Iterator for arrays with variable size.
18388 class _VariableSizeListIterator<T> implements Iterator<T> {
18389 final List<T> _array;
18390 int _position;
18391 T _current;
18392
18393 _VariableSizeListIterator(List<T> array)
18394 : _array = array,
18395 _position = -1;
18396
18397 bool moveNext() {
18398 int nextPosition = _position + 1;
18399 if (nextPosition < _array.length) {
18400 _current = _array[nextPosition];
18401 _position = nextPosition;
18402 return true;
18403 }
18404 _current = null;
18405 _position = _array.length;
18406 return false;
18407 }
18408
18409 T get current => _current;
18410 }
18411 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
18412 // for details. All rights reserved. Use of this source code is governed by a
18413 // BSD-style license that can be found in the LICENSE file.
18414
18415
18416 // Conversions for Window. These check if the window is the local
18417 // window, and if it's not, wraps or unwraps it with a secure wrapper.
18418 // We need to test for EventTarget here as well as it's a base type.
18419 // We omit an unwrapper for Window as no methods take a non-local
18420 // window as a parameter.
18421
18422
18423 WindowBase _convertNativeToDart_Window(win) {
18424 if (win == null) return null;
18425 return _DOMWindowCrossFrame._createSafe(win);
18426 }
18427
18428 EventTarget _convertNativeToDart_EventTarget(e) {
18429 if (e == null) {
18430 return null;
18431 }
18432 // Assume it's a Window if it contains the postMessage property. It may be
18433 // from a different frame - without a patched prototype - so we cannot
18434 // rely on Dart type checking.
18435 if (JS('bool', r'"postMessage" in #', e)) {
18436 var window = _DOMWindowCrossFrame._createSafe(e);
18437 // If it's a native window.
18438 if (window is EventTarget) {
18439 return window;
18440 }
18441 return null;
18442 }
18443 else
18444 return e;
18445 }
18446
18447 EventTarget _convertDartToNative_EventTarget(e) {
18448 if (e is _DOMWindowCrossFrame) {
18449 return e._window;
18450 } else {
18451 return e;
18452 }
18453 }
18454
18455 _convertNativeToDart_XHR_Response(o) {
18456 if (o is Document) {
18457 return o;
18458 }
18459 return convertNativeToDart_SerializedScriptValue(o);
18460 }
18461 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
18462 // for details. All rights reserved. Use of this source code is governed by a
18463 // BSD-style license that can be found in the LICENSE file.
18464
18465
18466 // TODO(vsm): Unify with Dartium version.
18467 class _DOMWindowCrossFrame implements WindowBase {
18468 // Private window. Note, this is a window in another frame, so it
18469 // cannot be typed as "Window" as its prototype is not patched
18470 // properly. Its fields and methods can only be accessed via JavaScript.
18471 final _window;
18472
18473 // Fields.
18474 HistoryBase get history =>
18475 _HistoryCrossFrame._createSafe(JS('HistoryBase', '#.history', _window));
18476 LocationBase get location =>
18477 _LocationCrossFrame._createSafe(JS('LocationBase', '#.location', _window));
18478
18479 // TODO(vsm): Add frames to navigate subframes. See 2312.
18480
18481 bool get closed => JS('bool', '#.closed', _window);
18482
18483 WindowBase get opener => _createSafe(JS('WindowBase', '#.opener', _window));
18484
18485 WindowBase get parent => _createSafe(JS('WindowBase', '#.parent', _window));
18486
18487 WindowBase get top => _createSafe(JS('WindowBase', '#.top', _window));
18488
18489 // Methods.
18490 void close() => JS('void', '#.close()', _window);
18491
18492 void postMessage(var message, String targetOrigin, [List messagePorts = null]) {
18493 if (messagePorts == null) {
18494 JS('void', '#.postMessage(#,#)', _window,
18495 convertDartToNative_SerializedScriptValue(message), targetOrigin);
18496 } else {
18497 JS('void', '#.postMessage(#,#,#)', _window,
18498 convertDartToNative_SerializedScriptValue(message), targetOrigin,
18499 messagePorts);
18500 }
18501 }
18502
18503 // Implementation support.
18504 _DOMWindowCrossFrame(this._window);
18505
18506 static WindowBase _createSafe(w) {
18507 if (identical(w, window)) {
18508 return w;
18509 } else {
18510 // TODO(vsm): Cache or implement equality.
18511 return new _DOMWindowCrossFrame(w);
18512 }
18513 }
18514
18515 // TODO(efortuna): Remove this method. dartbug.com/16814
18516 Events get on => throw new UnsupportedError(
18517 'You can only attach EventListeners to your own window.');
18518 // TODO(efortuna): Remove this method. dartbug.com/16814
18519 void _addEventListener([String type, EventListener listener, bool useCapture])
18520 => throw new UnsupportedError(
18521 'You can only attach EventListeners to your own window.');
18522 // TODO(efortuna): Remove this method. dartbug.com/16814
18523 void addEventListener(String type, EventListener listener, [bool useCapture])
18524 => throw new UnsupportedError(
18525 'You can only attach EventListeners to your own window.');
18526 // TODO(efortuna): Remove this method. dartbug.com/16814
18527 bool dispatchEvent(Event event) => throw new UnsupportedError(
18528 'You can only attach EventListeners to your own window.');
18529 // TODO(efortuna): Remove this method. dartbug.com/16814
18530 void _removeEventListener([String type, EventListener listener,
18531 bool useCapture]) => throw new UnsupportedError(
18532 'You can only attach EventListeners to your own window.');
18533 // TODO(efortuna): Remove this method. dartbug.com/16814
18534 void removeEventListener(String type, EventListener listener,
18535 [bool useCapture]) => throw new UnsupportedError(
18536 'You can only attach EventListeners to your own window.');
18537 }
18538
18539 class _LocationCrossFrame implements LocationBase {
18540 // Private location. Note, this is a location object in another frame, so it
18541 // cannot be typed as "Location" as its prototype is not patched
18542 // properly. Its fields and methods can only be accessed via JavaScript.
18543 var _location;
18544
18545 set href(String val) => _setHref(_location, val);
18546 static void _setHref(location, val) {
18547 JS('void', '#.href = #', location, val);
18548 }
18549
18550 // Implementation support.
18551 _LocationCrossFrame(this._location);
18552
18553 static LocationBase _createSafe(location) {
18554 if (identical(location, window.location)) {
18555 return location;
18556 } else {
18557 // TODO(vsm): Cache or implement equality.
18558 return new _LocationCrossFrame(location);
18559 }
18560 }
18561 }
18562
18563 class _HistoryCrossFrame implements HistoryBase {
18564 // Private history. Note, this is a history object in another frame, so it
18565 // cannot be typed as "History" as its prototype is not patched
18566 // properly. Its fields and methods can only be accessed via JavaScript.
18567 var _history;
18568
18569 void back() => JS('void', '#.back()', _history);
18570
18571 void forward() => JS('void', '#.forward()', _history);
18572
18573 void go(int distance) => JS('void', '#.go(#)', _history, distance);
18574
18575 // Implementation support.
18576 _HistoryCrossFrame(this._history);
18577
18578 static HistoryBase _createSafe(h) {
18579 if (identical(h, window.history)) {
18580 return h;
18581 } else {
18582 // TODO(vsm): Cache or implement equality.
18583 return new _HistoryCrossFrame(h);
18584 }
18585 }
18586 }
18587 /**
18588 * A custom KeyboardEvent that attempts to eliminate cross-browser
18589 * inconsistencies, and also provide both keyCode and charCode information
18590 * for all key events (when such information can be determined).
18591 *
18592 * KeyEvent tries to provide a higher level, more polished keyboard event
18593 * information on top of the "raw" [KeyboardEvent].
18594 *
18595 * The mechanics of using KeyEvents is a little different from the underlying
18596 * [KeyboardEvent]. To use KeyEvents, you need to create a stream and then add
18597 * KeyEvents to the stream, rather than using the [EventTarget.dispatchEvent].
18598 * Here's an example usage:
18599 *
18600 * // Initialize a stream for the KeyEvents:
18601 * var stream = KeyEvent.keyPressEvent.forTarget(document.body);
18602 * // Start listening to the stream of KeyEvents.
18603 * stream.listen((keyEvent) =>
18604 * window.console.log('KeyPress event detected ${keyEvent.charCode}'));
18605 * ...
18606 * // Add a new KeyEvent of someone pressing the 'A' key to the stream so
18607 * // listeners can know a KeyEvent happened.
18608 * stream.add(new KeyEvent('keypress', keyCode: 65, charCode: 97));
18609 *
18610 * This class is very much a work in progress, and we'd love to get information
18611 * on how we can make this class work with as many international keyboards as
18612 * possible. Bugs welcome!
18613 */
18614 @Experimental()
18615 class KeyEvent extends _WrappedEvent implements KeyboardEvent {
18616 /** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */
18617 KeyboardEvent _parent;
18618
18619 /** The "fixed" value of whether the alt key is being pressed. */
18620 bool _shadowAltKey;
18621
18622 /** Caculated value of what the estimated charCode is for this event. */
18623 int _shadowCharCode;
18624
18625 /** Caculated value of what the estimated keyCode is for this event. */
18626 int _shadowKeyCode;
18627
18628 /** Caculated value of what the estimated keyCode is for this event. */
18629 int get keyCode => _shadowKeyCode;
18630
18631 /** Caculated value of what the estimated charCode is for this event. */
18632 int get charCode => this.type == 'keypress' ? _shadowCharCode : 0;
18633
18634 /** Caculated value of whether the alt key is pressed is for this event. */
18635 bool get altKey => _shadowAltKey;
18636
18637 /** Caculated value of what the estimated keyCode is for this event. */
18638 int get which => keyCode;
18639
18640 /** Accessor to the underlying keyCode value is the parent event. */
18641 int get _realKeyCode => JS('int', '#.keyCode', _parent);
18642
18643 /** Accessor to the underlying charCode value is the parent event. */
18644 int get _realCharCode => JS('int', '#.charCode', _parent);
18645
18646 /** Accessor to the underlying altKey value is the parent event. */
18647 bool get _realAltKey => JS('bool', '#.altKey', _parent);
18648
18649 /** Shadows on top of the parent's currentTarget. */
18650 EventTarget _currentTarget;
18651
18652 /**
18653 * The value we want to use for this object's dispatch. Created here so it is
18654 * only invoked once.
18655 */
18656 static final _keyboardEventDispatchRecord = _makeRecord();
18657
18658 /** Helper to statically create the dispatch record. */
18659 static _makeRecord() {
18660 var interceptor = JS_INTERCEPTOR_CONSTANT(KeyboardEvent);
18661 return makeLeafDispatchRecord(interceptor);
18662 }
18663
18664 /** Construct a KeyEvent with [parent] as the event we're emulating. */
18665 KeyEvent.wrap(KeyboardEvent parent): super(parent) {
18666 _parent = parent;
18667 _shadowAltKey = _realAltKey;
18668 _shadowCharCode = _realCharCode;
18669 _shadowKeyCode = _realKeyCode;
18670 _currentTarget = _parent.currentTarget;
18671 }
18672
18673 /** Programmatically create a new KeyEvent (and KeyboardEvent). */
18674 factory KeyEvent(String type,
18675 {Window view, bool canBubble: true, bool cancelable: true, int keyCode: 0,
18676 int charCode: 0, int keyLocation: 1, bool ctrlKey: false,
18677 bool altKey: false, bool shiftKey: false, bool metaKey: false,
18678 EventTarget currentTarget}) {
18679 if (view == null) {
18680 view = window;
18681 }
18682
18683 var eventObj;
18684 // In these two branches we create an underlying native KeyboardEvent, but
18685 // we set it with our specified values. Because we are doing custom setting
18686 // of certain values (charCode/keyCode, etc) only in this class (as opposed
18687 // to KeyboardEvent) and the way we set these custom values depends on the
18688 // type of underlying JS object, we do all the contruction for the
18689 // underlying KeyboardEvent here.
18690 if (canUseDispatchEvent) {
18691 // Currently works in everything but Internet Explorer.
18692 eventObj = new Event.eventType('Event', type,
18693 canBubble: canBubble, cancelable: cancelable);
18694
18695 JS('void', '#.keyCode = #', eventObj, keyCode);
18696 JS('void', '#.which = #', eventObj, keyCode);
18697 JS('void', '#.charCode = #', eventObj, charCode);
18698
18699 JS('void', '#.keyLocation = #', eventObj, keyLocation);
18700 JS('void', '#.ctrlKey = #', eventObj, ctrlKey);
18701 JS('void', '#.altKey = #', eventObj, altKey);
18702 JS('void', '#.shiftKey = #', eventObj, shiftKey);
18703 JS('void', '#.metaKey = #', eventObj, metaKey);
18704 } else {
18705 // Currently this works on everything but Safari. Safari throws an
18706 // "Attempting to change access mechanism for an unconfigurable property"
18707 // TypeError when trying to do the Object.defineProperty hack, so we avoid
18708 // this branch if possible.
18709 // Also, if we want this branch to work in FF, we also need to modify
18710 // _initKeyboardEvent to also take charCode and keyCode values to
18711 // initialize initKeyEvent.
18712
18713 eventObj = new Event.eventType('KeyboardEvent', type,
18714 canBubble: canBubble, cancelable: cancelable);
18715
18716 // Chromium Hack
18717 JS('void', "Object.defineProperty(#, 'keyCode', {"
18718 " get : function() { return this.keyCodeVal; } })", eventObj);
18719 JS('void', "Object.defineProperty(#, 'which', {"
18720 " get : function() { return this.keyCodeVal; } })", eventObj);
18721 JS('void', "Object.defineProperty(#, 'charCode', {"
18722 " get : function() { return this.charCodeVal; } })", eventObj);
18723
18724 var keyIdentifier = _convertToHexString(charCode, keyCode);
18725 eventObj._initKeyboardEvent(type, canBubble, cancelable, view,
18726 keyIdentifier, keyLocation, ctrlKey, altKey, shiftKey, metaKey);
18727 JS('void', '#.keyCodeVal = #', eventObj, keyCode);
18728 JS('void', '#.charCodeVal = #', eventObj, charCode);
18729 }
18730 // Tell dart2js that it smells like a KeyboardEvent!
18731 setDispatchProperty(eventObj, _keyboardEventDispatchRecord);
18732
18733 var keyEvent = new KeyEvent.wrap(eventObj);
18734 if (keyEvent._currentTarget == null) {
18735 keyEvent._currentTarget = currentTarget == null ? window : currentTarget;
18736 }
18737 return keyEvent;
18738 }
18739
18740 // Currently known to work on all browsers but IE.
18741 static bool get canUseDispatchEvent =>
18742 JS('bool',
18743 '(typeof document.body.dispatchEvent == "function")'
18744 '&& document.body.dispatchEvent.length > 0');
18745
18746 /** The currently registered target for this event. */
18747 EventTarget get currentTarget => _currentTarget;
18748
18749 // This is an experimental method to be sure.
18750 static String _convertToHexString(int charCode, int keyCode) {
18751 if (charCode != -1) {
18752 var hex = charCode.toRadixString(16); // Convert to hexadecimal.
18753 StringBuffer sb = new StringBuffer('U+');
18754 for (int i = 0; i < 4 - hex.length; i++) sb.write('0');
18755 sb.write(hex);
18756 return sb.toString();
18757 } else {
18758 return KeyCode._convertKeyCodeToKeyName(keyCode);
18759 }
18760 }
18761
18762 // TODO(efortuna): If KeyEvent is sufficiently successful that we want to make
18763 // it the default keyboard event handling, move these methods over to Element.
18764 /** Accessor to provide a stream of KeyEvents on the desired target. */
18765 static EventStreamProvider<KeyEvent> keyDownEvent =
18766 new _KeyboardEventHandler('keydown');
18767 /** Accessor to provide a stream of KeyEvents on the desired target. */
18768 static EventStreamProvider<KeyEvent> keyUpEvent =
18769 new _KeyboardEventHandler('keyup');
18770 /** Accessor to provide a stream of KeyEvents on the desired target. */
18771 static EventStreamProvider<KeyEvent> keyPressEvent =
18772 new _KeyboardEventHandler('keypress');
18773
18774 /** Accessor to the clipboardData available for this event. */
18775 DataTransfer get clipboardData => _parent.clipboardData;
18776 /** True if the ctrl key is pressed during this event. */
18777 bool get ctrlKey => _parent.ctrlKey;
18778 int get detail => _parent.detail;
18779 /**
18780 * Accessor to the part of the keyboard that the key was pressed from (one of
18781 * KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT,
18782 * KeyLocation.NUMPAD, KeyLocation.MOBILE, KeyLocation.JOYSTICK).
18783 */
18784 int get keyLocation => _parent.keyLocation;
18785 Point get layer => _parent.layer;
18786 /** True if the Meta (or Mac command) key is pressed during this event. */
18787 bool get metaKey => _parent.metaKey;
18788 Point get page => _parent.page;
18789 /** True if the shift key was pressed during this event. */
18790 bool get shiftKey => _parent.shiftKey;
18791 Window get view => _parent.view;
18792 void _initUIEvent(String type, bool canBubble, bool cancelable,
18793 Window view, int detail) {
18794 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent.");
18795 }
18796 String get _shadowKeyIdentifier => JS('String', '#.keyIdentifier', _parent);
18797
18798 int get _charCode => charCode;
18799 int get _keyCode => keyCode;
18800 String get _keyIdentifier {
18801 throw new UnsupportedError("keyIdentifier is unsupported.");
18802 }
18803 void _initKeyboardEvent(String type, bool canBubble, bool cancelable,
18804 Window view, String keyIdentifier, int keyLocation, bool ctrlKey,
18805 bool altKey, bool shiftKey, bool metaKey) {
18806 throw new UnsupportedError(
18807 "Cannot initialize a KeyboardEvent from a KeyEvent.");
18808 }
18809 int get _layerX => throw new UnsupportedError('Not applicable to KeyEvent');
18810 int get _layerY => throw new UnsupportedError('Not applicable to KeyEvent');
18811 int get _pageX => throw new UnsupportedError('Not applicable to KeyEvent');
18812 int get _pageY => throw new UnsupportedError('Not applicable to KeyEvent');
18813 @Experimental() // untriaged
18814 bool getModifierState(String keyArgument) => throw new UnimplementedError();
18815 @Experimental() // untriaged
18816 int get location => throw new UnimplementedError();
18817 @Experimental() // untriaged
18818 bool get repeat => throw new UnimplementedError();
18819 dynamic get _get_view => throw new UnimplementedError();
18820 }
18821 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
18822 // for details. All rights reserved. Use of this source code is governed by a
18823 // BSD-style license that can be found in the LICENSE file.
18824
18825
18826 class Platform {
18827 /**
18828 * Returns true if dart:typed_data types are supported on this
18829 * browser. If false, using these types will generate a runtime
18830 * error.
18831 */
18832 static final supportsTypedData = JS('bool', '!!(window.ArrayBuffer)');
18833
18834 /**
18835 * Returns true if SIMD types in dart:typed_data types are supported
18836 * on this browser. If false, using these types will generate a runtime
18837 * error.
18838 */
18839 static final supportsSimd = false;
18840 }
18841 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
18842 // for details. All rights reserved. Use of this source code is governed by a
18843 // BSD-style license that can be found in the LICENSE file.
18844
18845
18846 /**
18847 * Helper class to implement custom events which wrap DOM events.
18848 */
18849 class _WrappedEvent implements Event {
18850 final Event wrapped;
18851
18852 /** The CSS selector involved with event delegation. */
18853 String _selector;
18854
18855 _WrappedEvent(this.wrapped);
18856
18857 bool get bubbles => wrapped.bubbles;
18858
18859 bool get cancelable => wrapped.cancelable;
18860
18861 DataTransfer get clipboardData => wrapped.clipboardData;
18862
18863 EventTarget get currentTarget => wrapped.currentTarget;
18864
18865 bool get defaultPrevented => wrapped.defaultPrevented;
18866
18867 int get eventPhase => wrapped.eventPhase;
18868
18869 EventTarget get target => wrapped.target;
18870
18871 int get timeStamp => wrapped.timeStamp;
18872
18873 String get type => wrapped.type;
18874
18875 void _initEvent(String eventTypeArg, bool canBubbleArg,
18876 bool cancelableArg) {
18877 throw new UnsupportedError(
18878 'Cannot initialize this Event.');
18879 }
18880
18881 void preventDefault() {
18882 wrapped.preventDefault();
18883 }
18884
18885 void stopImmediatePropagation() {
18886 wrapped.stopImmediatePropagation();
18887 }
18888
18889 void stopPropagation() {
18890 wrapped.stopPropagation();
18891 }
18892
18893 /**
18894 * A pointer to the element whose CSS selector matched within which an event
18895 * was fired. If this Event was not associated with any Event delegation,
18896 * accessing this value will throw an [UnsupportedError].
18897 */
18898 Element get matchingTarget {
18899 if (_selector == null) {
18900 throw new UnsupportedError('Cannot call matchingTarget if this Event did'
18901 ' not arise as a result of event delegation.');
18902 }
18903 var currentTarget = this.currentTarget;
18904 var target = this.target;
18905 var matchedTarget;
18906 do {
18907 if (target.matches(_selector)) return target;
18908 target = target.parent;
18909 } while (target != null && target != currentTarget.parent);
18910 throw new StateError('No selector matched for populating matchedTarget.');
18911 }
18912
18913 /**
18914 * This event's path, taking into account shadow DOM.
18915 *
18916 * ## Other resources
18917 *
18918 * * [Shadow DOM extensions to Event]
18919 * (http://w3c.github.io/webcomponents/spec/shadow/#extensions-to-event) from
18920 * W3C.
18921 */
18922 // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#ex tensions-to-event
18923 @Experimental()
18924 List<Node> get path => wrapped.path;
18925
18926 dynamic get _get_currentTarget => wrapped._get_currentTarget;
18927
18928 dynamic get _get_target => wrapped._get_target;
18929 }
18930 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
18931 // for details. All rights reserved. Use of this source code is governed by a
18932 // BSD-style license that can be found in the LICENSE file.
18933
18934
18935 _wrapZone(callback(arg)) {
18936 // For performance reasons avoid wrapping if we are in the root zone.
18937 if (Zone.current == Zone.ROOT) return callback;
18938 if (callback == null) return null;
18939 return Zone.current.bindUnaryCallback(callback, runGuarded: true);
18940 }
18941
18942 _wrapBinaryZone(callback(arg1, arg2)) {
18943 if (Zone.current == Zone.ROOT) return callback;
18944 if (callback == null) return null;
18945 return Zone.current.bindBinaryCallback(callback, runGuarded: true);
18946 }
18947
18948 /**
18949 * Alias for [querySelector]. Note this function is deprecated because its
18950 * semantics will be changing in the future.
18951 */
18952 @deprecated
18953 @Experimental()
18954 Element query(String relativeSelectors) => document.query(relativeSelectors);
18955 /**
18956 * Alias for [querySelectorAll]. Note this function is deprecated because its
18957 * semantics will be changing in the future.
18958 */
18959 @deprecated
18960 @Experimental()
18961 ElementList<Element> queryAll(String relativeSelectors) => document.queryAll(rel ativeSelectors);
18962
18963 /**
18964 * Finds the first descendant element of this document that matches the
18965 * specified group of selectors.
18966 *
18967 * Unless your webpage contains multiple documents, the top-level
18968 * [querySelector]
18969 * method behaves the same as this method, so you should use it instead to
18970 * save typing a few characters.
18971 *
18972 * [selectors] should be a string using CSS selector syntax.
18973 *
18974 * var element1 = document.querySelector('.className');
18975 * var element2 = document.querySelector('#id');
18976 *
18977 * For details about CSS selector syntax, see the
18978 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
18979 */
18980 Element querySelector(String selectors) => document.querySelector(selectors);
18981
18982 /**
18983 * Finds all descendant elements of this document that match the specified
18984 * group of selectors.
18985 *
18986 * Unless your webpage contains multiple documents, the top-level
18987 * [querySelectorAll]
18988 * method behaves the same as this method, so you should use it instead to
18989 * save typing a few characters.
18990 *
18991 * [selectors] should be a string using CSS selector syntax.
18992 *
18993 * var items = document.querySelectorAll('.itemClassName');
18994 *
18995 * For details about CSS selector syntax, see the
18996 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/).
18997 */
18998 ElementList<Element> querySelectorAll(String selectors) => document.querySelecto rAll(selectors);
18999
19000 /// A utility for changing the Dart wrapper type for elements.
19001 abstract class ElementUpgrader {
19002 /// Upgrade the specified element to be of the Dart type this was created for.
19003 ///
19004 /// After upgrading the element passed in is invalid and the returned value
19005 /// should be used instead.
19006 Element upgrade(Element element);
19007 }
19008 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
19009 // for details. All rights reserved. Use of this source code is governed by a
19010 // BSD-style license that can be found in the LICENSE file.
19011
19012
19013
19014 /**
19015 * Interface used to validate that only accepted elements and attributes are
19016 * allowed while parsing HTML strings into DOM nodes.
19017 *
19018 * In general, customization of validation behavior should be done via the
19019 * [NodeValidatorBuilder] class to mitigate the chances of incorrectly
19020 * implementing validation rules.
19021 */
19022 abstract class NodeValidator {
19023
19024 /**
19025 * Construct a default NodeValidator which only accepts whitelisted HTML5
19026 * elements and attributes.
19027 *
19028 * If a uriPolicy is not specified then the default uriPolicy will be used.
19029 */
19030 factory NodeValidator({UriPolicy uriPolicy}) =>
19031 new _Html5NodeValidator(uriPolicy: uriPolicy);
19032
19033 factory NodeValidator.throws(NodeValidator base) =>
19034 new _ThrowsNodeValidator(base);
19035
19036 /**
19037 * Returns true if the tagName is an accepted type.
19038 */
19039 bool allowsElement(Element element);
19040
19041 /**
19042 * Returns true if the attribute is allowed.
19043 *
19044 * The attributeName parameter will always be in lowercase.
19045 *
19046 * See [allowsElement] for format of tagName.
19047 */
19048 bool allowsAttribute(Element element, String attributeName, String value);
19049 }
19050
19051 /**
19052 * Performs sanitization of a node tree after construction to ensure that it
19053 * does not contain any disallowed elements or attributes.
19054 *
19055 * In general custom implementations of this class should not be necessary and
19056 * all validation customization should be done in custom NodeValidators, but
19057 * custom implementations of this class can be created to perform more complex
19058 * tree sanitization.
19059 */
19060 abstract class NodeTreeSanitizer {
19061
19062 /**
19063 * Constructs a default tree sanitizer which will remove all elements and
19064 * attributes which are not allowed by the provided validator.
19065 */
19066 factory NodeTreeSanitizer(NodeValidator validator) =>
19067 new _ValidatingTreeSanitizer(validator);
19068
19069 /**
19070 * Called with the root of the tree which is to be sanitized.
19071 *
19072 * This method needs to walk the entire tree and either remove elements and
19073 * attributes which are not recognized as safe or throw an exception which
19074 * will mark the entire tree as unsafe.
19075 */
19076 void sanitizeTree(Node node);
19077
19078 /**
19079 * A sanitizer for trees that we trust. It does no validation and allows
19080 * any elements. It is also more efficient, since it can pass the text
19081 * directly through to the underlying APIs without creating a document
19082 * fragment to be sanitized.
19083 */
19084 static const trusted = const _TrustedHtmlTreeSanitizer();
19085 }
19086
19087 /**
19088 * A sanitizer for trees that we trust. It does no validation and allows
19089 * any elements.
19090 */
19091 class _TrustedHtmlTreeSanitizer implements NodeTreeSanitizer {
19092 const _TrustedHtmlTreeSanitizer();
19093
19094 sanitizeTree(Node node) {}
19095 }
19096
19097 /**
19098 * Defines the policy for what types of uris are allowed for particular
19099 * attribute values.
19100 *
19101 * This can be used to provide custom rules such as allowing all http:// URIs
19102 * for image attributes but only same-origin URIs for anchor tags.
19103 */
19104 abstract class UriPolicy {
19105 /**
19106 * Constructs the default UriPolicy which is to only allow Uris to the same
19107 * origin as the application was launched from.
19108 *
19109 * This will block all ftp: mailto: URIs. It will also block accessing
19110 * https://example.com if the app is running from http://example.com.
19111 */
19112 factory UriPolicy() => new _SameOriginUriPolicy();
19113
19114 /**
19115 * Checks if the uri is allowed on the specified attribute.
19116 *
19117 * The uri provided may or may not be a relative path.
19118 */
19119 bool allowsUri(String uri);
19120 }
19121
19122 /**
19123 * Allows URIs to the same origin as the current application was loaded from
19124 * (such as https://example.com:80).
19125 */
19126 class _SameOriginUriPolicy implements UriPolicy {
19127 final AnchorElement _hiddenAnchor = new AnchorElement();
19128 final Location _loc = window.location;
19129
19130 bool allowsUri(String uri) {
19131 _hiddenAnchor.href = uri;
19132 // IE leaves an empty hostname for same-origin URIs.
19133 return (_hiddenAnchor.hostname == _loc.hostname &&
19134 _hiddenAnchor.port == _loc.port &&
19135 _hiddenAnchor.protocol == _loc.protocol) ||
19136 (_hiddenAnchor.hostname == '' &&
19137 _hiddenAnchor.port == '' &&
19138 (_hiddenAnchor.protocol == ':' || _hiddenAnchor.protocol == ''));
19139 }
19140 }
19141
19142
19143 class _ThrowsNodeValidator implements NodeValidator {
19144 final NodeValidator validator;
19145
19146 _ThrowsNodeValidator(this.validator) {}
19147
19148 bool allowsElement(Element element) {
19149 if (!validator.allowsElement(element)) {
19150 throw new ArgumentError(Element._safeTagName(element));
19151 }
19152 return true;
19153 }
19154
19155 bool allowsAttribute(Element element, String attributeName, String value) {
19156 if (!validator.allowsAttribute(element, attributeName, value)) {
19157 throw new ArgumentError('${Element._safeTagName(element)}[$attributeName=" $value"]');
19158 }
19159 }
19160 }
19161
19162
19163 /**
19164 * Standard tree sanitizer which validates a node tree against the provided
19165 * validator and removes any nodes or attributes which are not allowed.
19166 */
19167 class _ValidatingTreeSanitizer implements NodeTreeSanitizer {
19168 NodeValidator validator;
19169 _ValidatingTreeSanitizer(this.validator) {}
19170
19171 void sanitizeTree(Node node) {
19172 void walk(Node node, Node parent) {
19173 sanitizeNode(node, parent);
19174
19175 var child = node.lastChild;
19176 while (child != null) {
19177 // Child may be removed during the walk.
19178 var nextChild = child.previousNode;
19179 walk(child, node);
19180 child = nextChild;
19181 }
19182 }
19183 walk(node, null);
19184 }
19185
19186 /// Aggressively try to remove node.
19187 void _removeNode(Node node, Node parent) {
19188 // If we have the parent, it's presumably already passed more sanitization
19189 // or is the fragment, so ask it to remove the child. And if that fails
19190 // try to set the outer html.
19191 if (parent == null) {
19192 node.remove();
19193 } else {
19194 parent._removeChild(node);
19195 }
19196 }
19197
19198 /// Sanitize the element, assuming we can't trust anything about it.
19199 void _sanitizeUntrustedElement(/* Element */ element, Node parent) {
19200 // If the _hasCorruptedAttributes does not successfully return false,
19201 // then we consider it corrupted and remove.
19202 // TODO(alanknight): This is a workaround because on Firefox
19203 // embed/object
19204 // tags typeof is "function", not "object". We don't recognize them, and
19205 // can't call methods. This does mean that you can't explicitly allow an
19206 // embed tag. The only thing that will let it through is a null
19207 // sanitizer that doesn't traverse the tree at all. But sanitizing while
19208 // allowing embeds seems quite unlikely. This is also the reason that we
19209 // can't declare the type of element, as an embed won't pass any type
19210 // check in dart2js.
19211 var corrupted = true;
19212 var attrs;
19213 var isAttr;
19214 try {
19215 // If getting/indexing attributes throws, count that as corrupt.
19216 attrs = element.attributes;
19217 isAttr = attrs['is'];
19218 var corruptedTest1 = Element._hasCorruptedAttributes(element);
19219
19220 // On IE, erratically, the hasCorruptedAttributes test can return false,
19221 // even though it clearly is corrupted. A separate copy of the test
19222 // inlining just the basic check seems to help.
19223 corrupted = corruptedTest1 ? true : Element._hasCorruptedAttributesAdditio nalCheck(element);
19224 } catch(e) {}
19225 var elementText = 'element unprintable';
19226 try {
19227 elementText = element.toString();
19228 } catch(e) {}
19229 try {
19230 var elementTagName = Element._safeTagName(element);
19231 _sanitizeElement(element, parent, corrupted, elementText, elementTagName,
19232 attrs, isAttr);
19233 } on ArgumentError { // Thrown by _ThrowsNodeValidator
19234 rethrow;
19235 } catch(e) { // Unexpected exception sanitizing -> remove
19236 _removeNode(element, parent);
19237 window.console.warn('Removing corrupted element $elementText');
19238 }
19239 }
19240
19241 /// Having done basic sanity checking on the element, and computed the
19242 /// important attributes we want to check, remove it if it's not valid
19243 /// or not allowed, either as a whole or particular attributes.
19244 void _sanitizeElement(Element element, Node parent, bool corrupted,
19245 String text, String tag, Map attrs, String isAttr) {
19246 if (false != corrupted) {
19247 _removeNode(element, parent);
19248 window.console.warn(
19249 'Removing element due to corrupted attributes on <$text>');
19250 return;
19251 }
19252 if (!validator.allowsElement(element)) {
19253 _removeNode(element, parent);
19254 window.console.warn(
19255 'Removing disallowed element <$tag> from $parent');
19256 return;
19257 }
19258
19259 if (isAttr != null) {
19260 if (!validator.allowsAttribute(element, 'is', isAttr)) {
19261 _removeNode(element, parent);
19262 window.console.warn('Removing disallowed type extension '
19263 '<$tag is="$isAttr">');
19264 return;
19265 }
19266 }
19267
19268 // TODO(blois): Need to be able to get all attributes, irrespective of
19269 // XMLNS.
19270 var keys = attrs.keys.toList();
19271 for (var i = attrs.length - 1; i >= 0; --i) {
19272 var name = keys[i];
19273 if (!validator.allowsAttribute(element, name.toLowerCase(),
19274 attrs[name])) {
19275 window.console.warn('Removing disallowed attribute '
19276 '<$tag $name="${attrs[name]}">');
19277 attrs.remove(name);
19278 }
19279 }
19280
19281 if (element is TemplateElement) {
19282 TemplateElement template = element;
19283 sanitizeTree(template.content);
19284 }
19285 }
19286
19287 /// Sanitize the node and its children recursively.
19288 void sanitizeNode(Node node, Node parent) {
19289 switch (node.nodeType) {
19290 case Node.ELEMENT_NODE:
19291 _sanitizeUntrustedElement(node, parent);
19292 break;
19293 case Node.COMMENT_NODE:
19294 case Node.DOCUMENT_FRAGMENT_NODE:
19295 case Node.TEXT_NODE:
19296 case Node.CDATA_SECTION_NODE:
19297 break;
19298 default:
19299 _removeNode(node, parent);
19300 }
19301 }
19302 }
19303 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
19304 // for details. All rights reserved. Use of this source code is governed by a
19305 // BSD-style license that can be found in the LICENSE file.
19306
19307 // DO NOT EDIT - unless you are editing documentation as per:
19308 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
19309 // Auto-generated dart:html library.
19310
19311
19312 import 'dart:_js_helper' show
19313 convertDartClosureToJS, Creates, JavaScriptIndexingBehavior,
19314 JSName, Native, Returns, ForceInline,
19315 findDispatchTagForInterceptorClass, setNativeSubclassDispatchRecord,
19316 makeLeafDispatchRecord;
19317 import 'dart:_interceptors' show
19318 Interceptor, JSExtendableArray, JSUInt31,
19319 findInterceptorConstructorForType,
19320 findConstructorForNativeSubclassType,
19321 getNativeInterceptor,
19322 setDispatchProperty;
19323
19324 export 'dart:math' show Rectangle, Point;
19325
19326
19327
19328 //part '../../../dom/src/dart2js_CustomElementSupport.dart';
19329
19330
19331 /**
19332 * Top-level container for a web page, which is usually a browser tab or window.
19333 *
19334 * Each web page loaded in the browser has its own [Window], which is a
19335 * container for the web page.
19336 *
19337 * If the web page has any `<iframe>` elements, then each `<iframe>` has its own
19338 * [Window] object, which is accessible only to that `<iframe>`.
19339 *
19340 * See also:
19341 *
19342 * * [Window](https://developer.mozilla.org/en-US/docs/Web/API/window) from MD N.
19343 */
19344 Window get window => wrap_jso(JS('', 'window'));
19345
19346 /**
19347 * Root node for all content in a web page.
19348 */
19349 HtmlDocument get document => wrap_jso(JS('HtmlDocument', 'document'));
19350
19351 // Workaround for tags like <cite> that lack their own Element subclass --
19352 // Dart issue 1990.
19353 @Native("HTMLElement")
19354 class HtmlElement extends Element {
19355 factory HtmlElement() { throw new UnsupportedError("Not supported"); }
19356
19357 /**
19358 * Constructor instantiated by the DOM when a custom element has been created.
19359 *
19360 * This can only be called by subclasses from their created constructor.
19361 */
19362 HtmlElement.created() : super.created();
19363 HtmlElement.internal_() : super.internal_();
19364
19365 static HtmlElement internalCreateHtmlElement() {
19366 return new HtmlElement._internalWrap();
19367 }
19368
19369 factory HtmlElement._internalWrap() {
19370 return new HtmlElement.internal_();
19371 }
19372 }
19373
19374 // EntryArray type was removed, so explicitly adding it to allow support for
19375 // older Chrome versions.
19376 // Issue #12573.
19377 @Native("EntryArray")
19378 abstract class _EntryArray implements List<Entry> {}
19379
19380 /**
19381 * Spawn a DOM isolate using the given URI in the same window.
19382 * This isolate is not concurrent. It runs on the browser thread
19383 * with full access to the DOM.
19384 * Note: this API is still evolving and may move to dart:isolate.
19385 */
19386 @Experimental()
19387 Future<Isolate> spawnDomUri(Uri uri, List<String> args, message) {
19388 // TODO(17738): Implement this.
19389 throw new UnimplementedError();
19390 }
19391
19392
19393 class DartHtmlDomObject {
19394 // FIXME(vsm): Make this final at least. Private?
19395 dynamic raw;
19396
19397 DartHtmlDomObject();
19398 DartHtmlDomObject.internal_();
19399 }
19400
19401 typedef _F1(x);
19402
19403 final _wrapper = JS('', 'Symbol("dart_wrapper")');
19404
19405 /// Dartium functions that are a NOOP in dart2js.
19406 unwrap_jso(wrapped) {
19407 if (wrapped is DartHtmlDomObject) {
19408 return wrapped.raw;
19409 }
19410 if (wrapped is _F1) {
19411 if (JS('bool', '#.hasOwnProperty(#)', wrapped, _wrapper)) {
19412 return JS('', '#[#]', wrapped, _wrapper);
19413 }
19414 var f = (e) => wrapped(wrap_jso(e));
19415 JS('', '#[#] = #', wrapped, _wrapper, f);
19416 return f;
19417 }
19418 return wrapped;
19419 }
19420
19421
19422 wrap_jso(jso) {
19423 if (jso == null || jso is bool || jso is num || jso is String) {
19424 return jso;
19425 }
19426 if (JS('bool', '#.hasOwnProperty(#)', jso, _wrapper)) {
19427 return JS('', '#[#]', jso, _wrapper);
19428 }
19429 var constructor = JS('', '#.constructor', jso)
19430 var f = null;
19431 String name;
19432 bool skip = false;
19433 while (f == null) {
19434 name = JS('String', '#.name', constructor);
19435 f = getHtmlCreateFunction(name);
19436 if (f == null) {
19437 console.error('Could not instantiate $name');
19438 skip = true;
19439 constructor = JS('', '#.__proto__', constructor);
19440 }
19441 }
19442 if (skip) {
19443 console.info('Instantiated $name instead');
19444 }
19445 var wrapped = f();
19446 wrapped.raw = jso;
19447 JS('', '#[#] = #', jso, _wrapper, wrapped);
19448 return wrapped;
19449 }
19450
19451 createCustomUpgrader(Type customElementClass, $this) => $this;
19452
19453 // FIXME: Can we make this private?
19454 final htmlBlinkMap = {
19455 '_HistoryCrossFrame': () => _HistoryCrossFrame,
19456 '_LocationCrossFrame': () => _LocationCrossFrame,
19457 '_DOMWindowCrossFrame': () => _DOMWindowCrossFrame,
19458 // FIXME: Move these to better locations.
19459 'DateTime': () => DateTime,
19460 'JsObject': () => js.JsObjectImpl,
19461 'JsFunction': () => js.JsFunctionImpl,
19462 'JsArray': () => js.JsArrayImpl,
19463 'Attr': () => _Attr,
19464 'CSSStyleDeclaration': () => CssStyleDeclaration,
19465 'CharacterData': () => CharacterData,
19466 'ChildNode': () => ChildNode,
19467 'ClientRect': () => _ClientRect,
19468 'Console': () => Console,
19469 'ConsoleBase': () => ConsoleBase,
19470 'DOMImplementation': () => DomImplementation,
19471 'DOMTokenList': () => DomTokenList,
19472 'Document': () => Document,
19473 'DocumentFragment': () => DocumentFragment,
19474 'Element': () => Element,
19475 'Event': () => Event,
19476 'EventTarget': () => EventTarget,
19477 'HTMLAnchorElement': () => AnchorElement,
19478 'HTMLBaseElement': () => BaseElement,
19479 'HTMLBodyElement': () => BodyElement,
19480 'HTMLCollection': () => HtmlCollection,
19481 'HTMLDivElement': () => DivElement,
19482 'HTMLDocument': () => HtmlDocument,
19483 'HTMLElement': () => HtmlElement,
19484 'HTMLHeadElement': () => HeadElement,
19485 'HTMLInputElement': () => InputElement,
19486 'HTMLStyleElement': () => StyleElement,
19487 'HTMLTemplateElement': () => TemplateElement,
19488 'History': () => History,
19489 'KeyboardEvent': () => KeyboardEvent,
19490 'Location': () => Location,
19491 'MouseEvent': () => MouseEvent,
19492 'NamedNodeMap': () => _NamedNodeMap,
19493 'Navigator': () => Navigator,
19494 'NavigatorCPU': () => NavigatorCpu,
19495 'Node': () => Node,
19496 'NodeList': () => NodeList,
19497 'ParentNode': () => ParentNode,
19498 'ProgressEvent': () => ProgressEvent,
19499 'Range': () => Range,
19500 'ShadowRoot': () => ShadowRoot,
19501 'Text': () => Text,
19502 'UIEvent': () => UIEvent,
19503 'URLUtils': () => UrlUtils,
19504 'Window': () => Window,
19505 'XMLHttpRequest': () => HttpRequest,
19506 'XMLHttpRequestEventTarget': () => HttpRequestEventTarget,
19507 'XMLHttpRequestProgressEvent': () => _XMLHttpRequestProgressEvent,
19508
19509 };
19510
19511 // FIXME: Can we make this private?
19512 final htmlBlinkFunctionMap = {
19513 'Attr': () => _Attr.internalCreate_Attr,
19514 'CSSStyleDeclaration': () => CssStyleDeclaration.internalCreateCssStyleDeclara tion,
19515 'CharacterData': () => CharacterData.internalCreateCharacterData,
19516 'ClientRect': () => _ClientRect.internalCreate_ClientRect,
19517 'Console': () => Console.internalCreateConsole,
19518 'ConsoleBase': () => ConsoleBase.internalCreateConsoleBase,
19519 'DOMImplementation': () => DomImplementation.internalCreateDomImplementation,
19520 'DOMTokenList': () => DomTokenList.internalCreateDomTokenList,
19521 'Document': () => Document.internalCreateDocument,
19522 'DocumentFragment': () => DocumentFragment.internalCreateDocumentFragment,
19523 'Element': () => Element.internalCreateElement,
19524 'Event': () => Event.internalCreateEvent,
19525 'EventTarget': () => EventTarget.internalCreateEventTarget,
19526 'HTMLAnchorElement': () => AnchorElement.internalCreateAnchorElement,
19527 'HTMLBaseElement': () => BaseElement.internalCreateBaseElement,
19528 'HTMLBodyElement': () => BodyElement.internalCreateBodyElement,
19529 'HTMLCollection': () => HtmlCollection.internalCreateHtmlCollection,
19530 'HTMLDivElement': () => DivElement.internalCreateDivElement,
19531 'HTMLDocument': () => HtmlDocument.internalCreateHtmlDocument,
19532 'HTMLElement': () => HtmlElement.internalCreateHtmlElement,
19533 'HTMLHeadElement': () => HeadElement.internalCreateHeadElement,
19534 'HTMLInputElement': () => InputElement.internalCreateInputElement,
19535 'HTMLStyleElement': () => StyleElement.internalCreateStyleElement,
19536 'HTMLTemplateElement': () => TemplateElement.internalCreateTemplateElement,
19537 'History': () => History.internalCreateHistory,
19538 'KeyboardEvent': () => KeyboardEvent.internalCreateKeyboardEvent,
19539 'Location': () => Location.internalCreateLocation,
19540 'MouseEvent': () => MouseEvent.internalCreateMouseEvent,
19541 'NamedNodeMap': () => _NamedNodeMap.internalCreate_NamedNodeMap,
19542 'Navigator': () => Navigator.internalCreateNavigator,
19543 'Node': () => Node.internalCreateNode,
19544 'NodeList': () => NodeList.internalCreateNodeList,
19545 'ProgressEvent': () => ProgressEvent.internalCreateProgressEvent,
19546 'Range': () => Range.internalCreateRange,
19547 'ShadowRoot': () => ShadowRoot.internalCreateShadowRoot,
19548 'Text': () => Text.internalCreateText,
19549 'UIEvent': () => UIEvent.internalCreateUIEvent,
19550 'Window': () => Window.internalCreateWindow,
19551 'XMLHttpRequest': () => HttpRequest.internalCreateHttpRequest,
19552 'XMLHttpRequestEventTarget': () => HttpRequestEventTarget.internalCreateHttpRe questEventTarget,
19553 'XMLHttpRequestProgressEvent': () => _XMLHttpRequestProgressEvent.internalCrea te_XMLHttpRequestProgressEvent,
19554
19555 };
19556
19557 // TODO(terry): We may want to move this elsewhere if html becomes
19558 // a package to avoid dartium depending on pkg:html.
19559 getHtmlCreateFunction(String key) {
19560 var result;
19561
19562 // TODO(vsm): Add Cross Frame and JS types here as well.
19563
19564 // Check the html library.
19565 result = _getHtmlFunction(key);
19566 if (result != null) {
19567 return result;
19568 }
19569 return null;
19570 }
19571
19572 Function _getHtmlFunction(String key) {
19573 if (htmlBlinkFunctionMap.containsKey(key)) {
19574 return htmlBlinkFunctionMap[key]();
19575 }
19576 return null;
19577 }
19578
OLDNEW
« no previous file with comments | « tool/input_sdk/lib/_internal/libraries.dart ('k') | tool/input_sdk/lib/html/html_common/conversions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698