OLD | NEW |
| (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:_runtime' show global_; | |
28 import 'dart:async'; | |
29 import 'dart:collection'; | |
30 import 'dart:_internal' hide Symbol; | |
31 import 'dart:html_common'; | |
32 import 'dart:isolate'; | |
33 import "dart:convert"; | |
34 import 'dart:math'; | |
35 import 'dart:_native_typed_data'; | |
36 import 'dart:typed_data'; | |
37 import 'dart:_isolate_helper' show IsolateNatives; | |
38 import 'dart:_foreign_helper' show JS, JS_INTERCEPTOR_CONSTANT, JS_CONST; | |
39 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
40 // for details. All rights reserved. Use of this source code is governed by a | |
41 // BSD-style license that can be found in the LICENSE file. | |
42 | |
43 | |
44 @DocsEditable() | |
45 @DomName('HTMLAnchorElement') | |
46 @Native("HTMLAnchorElement") | |
47 class AnchorElement extends HtmlElement implements UrlUtils { | |
48 // To suppress missing implicit constructor warnings. | |
49 factory AnchorElement._() { throw new UnsupportedError("Not supported"); } | |
50 | |
51 @DomName('HTMLAnchorElement.HTMLAnchorElement') | |
52 @DocsEditable() | |
53 factory AnchorElement({String href}) { | |
54 AnchorElement e = document.createElement("a"); | |
55 if (href != null) e.href = href; | |
56 return e; | |
57 } | |
58 | |
59 | |
60 @Deprecated("Internal Use Only") | |
61 static AnchorElement internalCreateAnchorElement() { | |
62 return new AnchorElement.internal_(); | |
63 } | |
64 | |
65 @Deprecated("Internal Use Only") | |
66 AnchorElement.internal_() : super.internal_(); | |
67 | |
68 | |
69 @DomName('HTMLAnchorElement.download') | |
70 @DocsEditable() | |
71 String get download => wrap_jso(JS("String", "#.download", this.raw)); | |
72 @DomName('HTMLAnchorElement.download') | |
73 @DocsEditable() | |
74 void set download(String val) => JS("void", "#.download = #", this.raw, unwrap
_jso(val)); | |
75 | |
76 @DomName('HTMLAnchorElement.hreflang') | |
77 @DocsEditable() | |
78 String get hreflang => wrap_jso(JS("String", "#.hreflang", this.raw)); | |
79 @DomName('HTMLAnchorElement.hreflang') | |
80 @DocsEditable() | |
81 void set hreflang(String val) => JS("void", "#.hreflang = #", this.raw, unwrap
_jso(val)); | |
82 | |
83 @DomName('HTMLAnchorElement.integrity') | |
84 @DocsEditable() | |
85 @Experimental() // untriaged | |
86 String get integrity => wrap_jso(JS("String", "#.integrity", this.raw)); | |
87 @DomName('HTMLAnchorElement.integrity') | |
88 @DocsEditable() | |
89 @Experimental() // untriaged | |
90 void set integrity(String val) => JS("void", "#.integrity = #", this.raw, unwr
ap_jso(val)); | |
91 | |
92 @DomName('HTMLAnchorElement.rel') | |
93 @DocsEditable() | |
94 String get rel => wrap_jso(JS("String", "#.rel", this.raw)); | |
95 @DomName('HTMLAnchorElement.rel') | |
96 @DocsEditable() | |
97 void set rel(String val) => JS("void", "#.rel = #", this.raw, unwrap_jso(val))
; | |
98 | |
99 @DomName('HTMLAnchorElement.target') | |
100 @DocsEditable() | |
101 String get target => wrap_jso(JS("String", "#.target", this.raw)); | |
102 @DomName('HTMLAnchorElement.target') | |
103 @DocsEditable() | |
104 void set target(String val) => JS("void", "#.target = #", this.raw, unwrap_jso
(val)); | |
105 | |
106 @DomName('HTMLAnchorElement.type') | |
107 @DocsEditable() | |
108 String get type => wrap_jso(JS("String", "#.type", this.raw)); | |
109 @DomName('HTMLAnchorElement.type') | |
110 @DocsEditable() | |
111 void set type(String val) => JS("void", "#.type = #", this.raw, unwrap_jso(val
)); | |
112 | |
113 // From URLUtils | |
114 | |
115 @DomName('HTMLAnchorElement.hash') | |
116 @DocsEditable() | |
117 String get hash => wrap_jso(JS("String", "#.hash", this.raw)); | |
118 @DomName('HTMLAnchorElement.hash') | |
119 @DocsEditable() | |
120 void set hash(String val) => JS("void", "#.hash = #", this.raw, unwrap_jso(val
)); | |
121 | |
122 @DomName('HTMLAnchorElement.host') | |
123 @DocsEditable() | |
124 String get host => wrap_jso(JS("String", "#.host", this.raw)); | |
125 @DomName('HTMLAnchorElement.host') | |
126 @DocsEditable() | |
127 void set host(String val) => JS("void", "#.host = #", this.raw, unwrap_jso(val
)); | |
128 | |
129 @DomName('HTMLAnchorElement.hostname') | |
130 @DocsEditable() | |
131 String get hostname => wrap_jso(JS("String", "#.hostname", this.raw)); | |
132 @DomName('HTMLAnchorElement.hostname') | |
133 @DocsEditable() | |
134 void set hostname(String val) => JS("void", "#.hostname = #", this.raw, unwrap
_jso(val)); | |
135 | |
136 @DomName('HTMLAnchorElement.href') | |
137 @DocsEditable() | |
138 String get href => wrap_jso(JS("String", "#.href", this.raw)); | |
139 @DomName('HTMLAnchorElement.href') | |
140 @DocsEditable() | |
141 void set href(String val) => JS("void", "#.href = #", this.raw, unwrap_jso(val
)); | |
142 | |
143 @DomName('HTMLAnchorElement.origin') | |
144 @DocsEditable() | |
145 // WebKit only | |
146 @Experimental() // non-standard | |
147 String get origin => wrap_jso(JS("String", "#.origin", this.raw)); | |
148 | |
149 @DomName('HTMLAnchorElement.password') | |
150 @DocsEditable() | |
151 @Experimental() // untriaged | |
152 String get password => wrap_jso(JS("String", "#.password", this.raw)); | |
153 @DomName('HTMLAnchorElement.password') | |
154 @DocsEditable() | |
155 @Experimental() // untriaged | |
156 void set password(String val) => JS("void", "#.password = #", this.raw, unwrap
_jso(val)); | |
157 | |
158 @DomName('HTMLAnchorElement.pathname') | |
159 @DocsEditable() | |
160 String get pathname => wrap_jso(JS("String", "#.pathname", this.raw)); | |
161 @DomName('HTMLAnchorElement.pathname') | |
162 @DocsEditable() | |
163 void set pathname(String val) => JS("void", "#.pathname = #", this.raw, unwrap
_jso(val)); | |
164 | |
165 @DomName('HTMLAnchorElement.port') | |
166 @DocsEditable() | |
167 String get port => wrap_jso(JS("String", "#.port", this.raw)); | |
168 @DomName('HTMLAnchorElement.port') | |
169 @DocsEditable() | |
170 void set port(String val) => JS("void", "#.port = #", this.raw, unwrap_jso(val
)); | |
171 | |
172 @DomName('HTMLAnchorElement.protocol') | |
173 @DocsEditable() | |
174 String get protocol => wrap_jso(JS("String", "#.protocol", this.raw)); | |
175 @DomName('HTMLAnchorElement.protocol') | |
176 @DocsEditable() | |
177 void set protocol(String val) => JS("void", "#.protocol = #", this.raw, unwrap
_jso(val)); | |
178 | |
179 @DomName('HTMLAnchorElement.search') | |
180 @DocsEditable() | |
181 String get search => wrap_jso(JS("String", "#.search", this.raw)); | |
182 @DomName('HTMLAnchorElement.search') | |
183 @DocsEditable() | |
184 void set search(String val) => JS("void", "#.search = #", this.raw, unwrap_jso
(val)); | |
185 | |
186 @DomName('HTMLAnchorElement.username') | |
187 @DocsEditable() | |
188 @Experimental() // untriaged | |
189 String get username => wrap_jso(JS("String", "#.username", this.raw)); | |
190 @DomName('HTMLAnchorElement.username') | |
191 @DocsEditable() | |
192 @Experimental() // untriaged | |
193 void set username(String val) => JS("void", "#.username = #", this.raw, unwrap
_jso(val)); | |
194 } | |
195 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
196 // for details. All rights reserved. Use of this source code is governed by a | |
197 // BSD-style license that can be found in the LICENSE file. | |
198 | |
199 | |
200 @DocsEditable() | |
201 @DomName('HTMLBaseElement') | |
202 @Native("HTMLBaseElement") | |
203 class BaseElement extends HtmlElement { | |
204 // To suppress missing implicit constructor warnings. | |
205 factory BaseElement._() { throw new UnsupportedError("Not supported"); } | |
206 | |
207 @DomName('HTMLBaseElement.HTMLBaseElement') | |
208 @DocsEditable() | |
209 factory BaseElement() => document.createElement("base"); | |
210 | |
211 | |
212 @Deprecated("Internal Use Only") | |
213 static BaseElement internalCreateBaseElement() { | |
214 return new BaseElement.internal_(); | |
215 } | |
216 | |
217 @Deprecated("Internal Use Only") | |
218 BaseElement.internal_() : super.internal_(); | |
219 | |
220 | |
221 @DomName('HTMLBaseElement.href') | |
222 @DocsEditable() | |
223 String get href => wrap_jso(JS("String", "#.href", this.raw)); | |
224 @DomName('HTMLBaseElement.href') | |
225 @DocsEditable() | |
226 void set href(String val) => JS("void", "#.href = #", this.raw, unwrap_jso(val
)); | |
227 | |
228 @DomName('HTMLBaseElement.target') | |
229 @DocsEditable() | |
230 String get target => wrap_jso(JS("String", "#.target", this.raw)); | |
231 @DomName('HTMLBaseElement.target') | |
232 @DocsEditable() | |
233 void set target(String val) => JS("void", "#.target = #", this.raw, unwrap_jso
(val)); | |
234 } | |
235 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
236 // for details. All rights reserved. Use of this source code is governed by a | |
237 // BSD-style license that can be found in the LICENSE file. | |
238 | |
239 | |
240 @DocsEditable() | |
241 @DomName('HTMLBodyElement') | |
242 @Native("HTMLBodyElement") | |
243 class BodyElement extends HtmlElement { | |
244 // To suppress missing implicit constructor warnings. | |
245 factory BodyElement._() { throw new UnsupportedError("Not supported"); } | |
246 | |
247 /** | |
248 * Static factory designed to expose `blur` events to event | |
249 * handlers that are not necessarily instances of [BodyElement]. | |
250 * | |
251 * See [EventStreamProvider] for usage information. | |
252 */ | |
253 @DomName('HTMLBodyElement.blurEvent') | |
254 @DocsEditable() | |
255 static const EventStreamProvider<Event> blurEvent = const EventStreamProvider<
Event>('blur'); | |
256 | |
257 /** | |
258 * Static factory designed to expose `error` events to event | |
259 * handlers that are not necessarily instances of [BodyElement]. | |
260 * | |
261 * See [EventStreamProvider] for usage information. | |
262 */ | |
263 @DomName('HTMLBodyElement.errorEvent') | |
264 @DocsEditable() | |
265 static const EventStreamProvider<Event> errorEvent = const EventStreamProvider
<Event>('error'); | |
266 | |
267 /** | |
268 * Static factory designed to expose `focus` events to event | |
269 * handlers that are not necessarily instances of [BodyElement]. | |
270 * | |
271 * See [EventStreamProvider] for usage information. | |
272 */ | |
273 @DomName('HTMLBodyElement.focusEvent') | |
274 @DocsEditable() | |
275 static const EventStreamProvider<Event> focusEvent = const EventStreamProvider
<Event>('focus'); | |
276 | |
277 /** | |
278 * Static factory designed to expose `load` events to event | |
279 * handlers that are not necessarily instances of [BodyElement]. | |
280 * | |
281 * See [EventStreamProvider] for usage information. | |
282 */ | |
283 @DomName('HTMLBodyElement.loadEvent') | |
284 @DocsEditable() | |
285 static const EventStreamProvider<Event> loadEvent = const EventStreamProvider<
Event>('load'); | |
286 | |
287 /** | |
288 * Static factory designed to expose `resize` events to event | |
289 * handlers that are not necessarily instances of [BodyElement]. | |
290 * | |
291 * See [EventStreamProvider] for usage information. | |
292 */ | |
293 @DomName('HTMLBodyElement.resizeEvent') | |
294 @DocsEditable() | |
295 static const EventStreamProvider<Event> resizeEvent = const EventStreamProvide
r<Event>('resize'); | |
296 | |
297 @DomName('HTMLBodyElement.scrollEvent') | |
298 @DocsEditable() | |
299 @Experimental() // untriaged | |
300 static const EventStreamProvider<Event> scrollEvent = const EventStreamProvide
r<Event>('scroll'); | |
301 | |
302 @DomName('HTMLBodyElement.HTMLBodyElement') | |
303 @DocsEditable() | |
304 factory BodyElement() => document.createElement("body"); | |
305 | |
306 | |
307 @Deprecated("Internal Use Only") | |
308 static BodyElement internalCreateBodyElement() { | |
309 return new BodyElement.internal_(); | |
310 } | |
311 | |
312 @Deprecated("Internal Use Only") | |
313 BodyElement.internal_() : super.internal_(); | |
314 | |
315 | |
316 /// Stream of `blur` events handled by this [BodyElement]. | |
317 @DomName('HTMLBodyElement.onblur') | |
318 @DocsEditable() | |
319 ElementStream<Event> get onBlur => blurEvent.forElement(this); | |
320 | |
321 /// Stream of `error` events handled by this [BodyElement]. | |
322 @DomName('HTMLBodyElement.onerror') | |
323 @DocsEditable() | |
324 ElementStream<Event> get onError => errorEvent.forElement(this); | |
325 | |
326 /// Stream of `focus` events handled by this [BodyElement]. | |
327 @DomName('HTMLBodyElement.onfocus') | |
328 @DocsEditable() | |
329 ElementStream<Event> get onFocus => focusEvent.forElement(this); | |
330 | |
331 /// Stream of `load` events handled by this [BodyElement]. | |
332 @DomName('HTMLBodyElement.onload') | |
333 @DocsEditable() | |
334 ElementStream<Event> get onLoad => loadEvent.forElement(this); | |
335 | |
336 /// Stream of `resize` events handled by this [BodyElement]. | |
337 @DomName('HTMLBodyElement.onresize') | |
338 @DocsEditable() | |
339 ElementStream<Event> get onResize => resizeEvent.forElement(this); | |
340 | |
341 @DomName('HTMLBodyElement.onscroll') | |
342 @DocsEditable() | |
343 @Experimental() // untriaged | |
344 ElementStream<Event> get onScroll => scrollEvent.forElement(this); | |
345 } | |
346 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
347 // for details. All rights reserved. Use of this source code is governed by a | |
348 // BSD-style license that can be found in the LICENSE file. | |
349 | |
350 | |
351 @DocsEditable() | |
352 @DomName('CharacterData') | |
353 @Native("CharacterData") | |
354 class CharacterData extends Node implements ChildNode { | |
355 // To suppress missing implicit constructor warnings. | |
356 factory CharacterData._() { throw new UnsupportedError("Not supported"); } | |
357 | |
358 | |
359 @Deprecated("Internal Use Only") | |
360 static CharacterData internalCreateCharacterData() { | |
361 return new CharacterData.internal_(); | |
362 } | |
363 | |
364 @Deprecated("Internal Use Only") | |
365 CharacterData.internal_() : super.internal_(); | |
366 | |
367 | |
368 @DomName('CharacterData.data') | |
369 @DocsEditable() | |
370 String get data => wrap_jso(JS("String", "#.data", this.raw)); | |
371 @DomName('CharacterData.data') | |
372 @DocsEditable() | |
373 void set data(String val) => JS("void", "#.data = #", this.raw, unwrap_jso(val
)); | |
374 | |
375 @DomName('CharacterData.length') | |
376 @DocsEditable() | |
377 int get length => wrap_jso(JS("int", "#.length", this.raw)); | |
378 | |
379 @DomName('CharacterData.appendData') | |
380 @DocsEditable() | |
381 void appendData(String data) { | |
382 _appendData_1(data); | |
383 return; | |
384 } | |
385 @JSName('appendData') | |
386 @DomName('CharacterData.appendData') | |
387 @DocsEditable() | |
388 void _appendData_1(data) => wrap_jso(JS("void ", "#.raw.appendData(#)", this,
unwrap_jso(data))); | |
389 | |
390 @DomName('CharacterData.deleteData') | |
391 @DocsEditable() | |
392 void deleteData(int offset, int length) { | |
393 _deleteData_1(offset, length); | |
394 return; | |
395 } | |
396 @JSName('deleteData') | |
397 @DomName('CharacterData.deleteData') | |
398 @DocsEditable() | |
399 void _deleteData_1(offset, length) => wrap_jso(JS("void ", "#.raw.deleteData(#
, #)", this, unwrap_jso(offset), unwrap_jso(length))); | |
400 | |
401 @DomName('CharacterData.insertData') | |
402 @DocsEditable() | |
403 void insertData(int offset, String data) { | |
404 _insertData_1(offset, data); | |
405 return; | |
406 } | |
407 @JSName('insertData') | |
408 @DomName('CharacterData.insertData') | |
409 @DocsEditable() | |
410 void _insertData_1(offset, data) => wrap_jso(JS("void ", "#.raw.insertData(#,
#)", this, unwrap_jso(offset), unwrap_jso(data))); | |
411 | |
412 @DomName('CharacterData.replaceData') | |
413 @DocsEditable() | |
414 void replaceData(int offset, int length, String data) { | |
415 _replaceData_1(offset, length, data); | |
416 return; | |
417 } | |
418 @JSName('replaceData') | |
419 @DomName('CharacterData.replaceData') | |
420 @DocsEditable() | |
421 void _replaceData_1(offset, length, data) => wrap_jso(JS("void ", "#.raw.repla
ceData(#, #, #)", this, unwrap_jso(offset), unwrap_jso(length), unwrap_jso(data)
)); | |
422 | |
423 @DomName('CharacterData.substringData') | |
424 @DocsEditable() | |
425 String substringData(int offset, int length) { | |
426 return _substringData_1(offset, length); | |
427 } | |
428 @JSName('substringData') | |
429 @DomName('CharacterData.substringData') | |
430 @DocsEditable() | |
431 String _substringData_1(offset, length) => wrap_jso(JS("String ", "#.raw.subst
ringData(#, #)", this, unwrap_jso(offset), unwrap_jso(length))); | |
432 | |
433 // From ChildNode | |
434 | |
435 @DomName('CharacterData.nextElementSibling') | |
436 @DocsEditable() | |
437 Element get nextElementSibling => wrap_jso(JS("Element", "#.nextElementSibling
", this.raw)); | |
438 | |
439 @DomName('CharacterData.previousElementSibling') | |
440 @DocsEditable() | |
441 Element get previousElementSibling => wrap_jso(JS("Element", "#.previousElemen
tSibling", this.raw)); | |
442 } | |
443 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
444 // for details. All rights reserved. Use of this source code is governed by a | |
445 // BSD-style license that can be found in the LICENSE file. | |
446 | |
447 | |
448 @DocsEditable() | |
449 @DomName('ChildNode') | |
450 @Experimental() // untriaged | |
451 abstract class ChildNode extends DartHtmlDomObject { | |
452 // To suppress missing implicit constructor warnings. | |
453 factory ChildNode._() { throw new UnsupportedError("Not supported"); } | |
454 | |
455 Element get nextElementSibling => wrap_jso(JS("Element", "#.nextElementSibling
", this.raw)); | |
456 | |
457 Element get previousElementSibling => wrap_jso(JS("Element", "#.previousElemen
tSibling", this.raw)); | |
458 | |
459 void remove() => wrap_jso(JS("void", "#.raw.remove()", this)); | |
460 } | |
461 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
462 // for details. All rights reserved. Use of this source code is governed by a | |
463 // BSD-style license that can be found in the LICENSE file. | |
464 | |
465 | |
466 @DocsEditable() | |
467 @DomName('Comment') | |
468 @Native("Comment") | |
469 class Comment extends CharacterData { | |
470 factory Comment([String data]) { | |
471 if (data != null) { | |
472 return wrap_jso(JS('Comment', '#.createComment(#)', document.raw, data)); | |
473 } | |
474 return wrap_jso(JS('Comment', '#.createComment("")', document.raw)); | |
475 } | |
476 // To suppress missing implicit constructor warnings. | |
477 factory Comment._() { throw new UnsupportedError("Not supported"); } | |
478 | |
479 | |
480 @Deprecated("Internal Use Only") | |
481 static Comment internalCreateComment() { | |
482 return new Comment.internal_(); | |
483 } | |
484 | |
485 @Deprecated("Internal Use Only") | |
486 Comment.internal_() : super.internal_(); | |
487 | |
488 } | |
489 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
490 // for details. All rights reserved. Use of this source code is governed by a | |
491 // BSD-style license that can be found in the LICENSE file. | |
492 | |
493 | |
494 @DomName('Console') | |
495 class Console extends DartHtmlDomObject { | |
496 | |
497 Console._safe(); | |
498 | |
499 static final Console _safeConsole = new Console._safe(); | |
500 | |
501 bool get _isConsoleDefined => JS('bool', 'typeof console != "undefined"'); | |
502 | |
503 @DomName('Console.assertCondition') | |
504 void assertCondition(bool condition, Object arg) => _isConsoleDefined ? | |
505 JS('void', 'console.assertCondition(#, #)', condition, arg) : null; | |
506 | |
507 @DomName('Console.clear') | |
508 void clear(Object arg) => _isConsoleDefined ? | |
509 JS('void', 'console.clear(#)', arg) : null; | |
510 | |
511 @DomName('Console.count') | |
512 void count(Object arg) => _isConsoleDefined ? | |
513 JS('void', 'console.count(#)', arg) : null; | |
514 | |
515 @DomName('Console.debug') | |
516 void debug(Object arg) => _isConsoleDefined ? | |
517 JS('void', 'console.debug(#)', arg) : null; | |
518 | |
519 @DomName('Console.dir') | |
520 void dir(Object arg) => _isConsoleDefined ? | |
521 JS('void', 'console.dir(#)', arg) : null; | |
522 | |
523 @DomName('Console.dirxml') | |
524 void dirxml(Object arg) => _isConsoleDefined ? | |
525 JS('void', 'console.dirxml(#)', arg) : null; | |
526 | |
527 @DomName('Console.error') | |
528 void error(Object arg) => _isConsoleDefined ? | |
529 JS('void', 'console.error(#)', arg) : null; | |
530 | |
531 @DomName('Console.group') | |
532 void group(Object arg) => _isConsoleDefined ? | |
533 JS('void', 'console.group(#)', arg) : null; | |
534 | |
535 @DomName('Console.groupCollapsed') | |
536 void groupCollapsed(Object arg) => _isConsoleDefined ? | |
537 JS('void', 'console.groupCollapsed(#)', arg) : null; | |
538 | |
539 @DomName('Console.groupEnd') | |
540 void groupEnd() => _isConsoleDefined ? | |
541 JS('void', 'console.groupEnd()') : null; | |
542 | |
543 @DomName('Console.info') | |
544 void info(Object arg) => _isConsoleDefined ? | |
545 JS('void', 'console.info(#)', arg) : null; | |
546 | |
547 @DomName('Console.log') | |
548 void log(Object arg) => _isConsoleDefined ? | |
549 JS('void', 'console.log(#)', arg) : null; | |
550 | |
551 @DomName('Console.markTimeline') | |
552 void markTimeline(Object arg) => _isConsoleDefined ? | |
553 JS('void', 'console.markTimeline(#)', arg) : null; | |
554 | |
555 @DomName('Console.profile') | |
556 void profile(String title) => _isConsoleDefined ? | |
557 JS('void', 'console.profile(#)', title) : null; | |
558 | |
559 @DomName('Console.profileEnd') | |
560 void profileEnd(String title) => _isConsoleDefined ? | |
561 JS('void', 'console.profileEnd(#)', title) : null; | |
562 | |
563 @DomName('Console.table') | |
564 void table(Object arg) => _isConsoleDefined ? | |
565 JS('void', 'console.table(#)', arg) : null; | |
566 | |
567 @DomName('Console.time') | |
568 void time(String title) => _isConsoleDefined ? | |
569 JS('void', 'console.time(#)', title) : null; | |
570 | |
571 @DomName('Console.timeEnd') | |
572 void timeEnd(String title) => _isConsoleDefined ? | |
573 JS('void', 'console.timeEnd(#)', title) : null; | |
574 | |
575 @DomName('Console.timeStamp') | |
576 void timeStamp(Object arg) => _isConsoleDefined ? | |
577 JS('void', 'console.timeStamp(#)', arg) : null; | |
578 | |
579 @DomName('Console.trace') | |
580 void trace(Object arg) => _isConsoleDefined ? | |
581 JS('void', 'console.trace(#)', arg) : null; | |
582 | |
583 @DomName('Console.warn') | |
584 void warn(Object arg) => _isConsoleDefined ? | |
585 JS('void', 'console.warn(#)', arg) : null; | |
586 // To suppress missing implicit constructor warnings. | |
587 factory Console._() { throw new UnsupportedError("Not supported"); } | |
588 | |
589 | |
590 @Deprecated("Internal Use Only") | |
591 static Console internalCreateConsole() { | |
592 return new Console.internal_(); | |
593 } | |
594 | |
595 @Deprecated("Internal Use Only") | |
596 Console.internal_() : super.internal_(); | |
597 | |
598 | |
599 } | |
600 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
601 // for details. All rights reserved. Use of this source code is governed by a | |
602 // BSD-style license that can be found in the LICENSE file. | |
603 | |
604 | |
605 @DocsEditable() | |
606 @DomName('ConsoleBase') | |
607 @Experimental() // untriaged | |
608 @Native("ConsoleBase") | |
609 class ConsoleBase extends DartHtmlDomObject { | |
610 // To suppress missing implicit constructor warnings. | |
611 factory ConsoleBase._() { throw new UnsupportedError("Not supported"); } | |
612 | |
613 @Deprecated("Internal Use Only") | |
614 static ConsoleBase internalCreateConsoleBase() { | |
615 return new ConsoleBase.internal_(); | |
616 } | |
617 | |
618 @Deprecated("Internal Use Only") | |
619 ConsoleBase.internal_() { } | |
620 | |
621 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
622 int get hashCode => unwrap_jso(this).hashCode; | |
623 | |
624 @DomName('ConsoleBase.timeline') | |
625 @DocsEditable() | |
626 @Experimental() // untriaged | |
627 void timeline(String title) { | |
628 _timeline_1(title); | |
629 return; | |
630 } | |
631 @JSName('timeline') | |
632 @DomName('ConsoleBase.timeline') | |
633 @DocsEditable() | |
634 @Experimental() // untriaged | |
635 void _timeline_1(title) => wrap_jso(JS("void ", "#.raw.timeline(#)", this, unw
rap_jso(title))); | |
636 | |
637 @DomName('ConsoleBase.timelineEnd') | |
638 @DocsEditable() | |
639 @Experimental() // untriaged | |
640 void timelineEnd(String title) { | |
641 _timelineEnd_1(title); | |
642 return; | |
643 } | |
644 @JSName('timelineEnd') | |
645 @DomName('ConsoleBase.timelineEnd') | |
646 @DocsEditable() | |
647 @Experimental() // untriaged | |
648 void _timelineEnd_1(title) => wrap_jso(JS("void ", "#.raw.timelineEnd(#)", thi
s, unwrap_jso(title))); | |
649 } | |
650 | |
651 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
652 // for details. All rights reserved. Use of this source code is governed by a | |
653 // BSD-style license that can be found in the LICENSE file. | |
654 | |
655 // WARNING: DO NOT EDIT THIS TEMPLATE FILE. | |
656 // The template file was generated by scripts/css_code_generator.py | |
657 | |
658 // Source of CSS properties: | |
659 // CSSPropertyNames.in | |
660 | |
661 | |
662 @DomName('CSSStyleDeclaration') | |
663 @Native("CSSStyleDeclaration,MSStyleCSSProperties,CSS2Properties") | |
664 class CssStyleDeclaration extends DartHtmlDomObject with | |
665 CssStyleDeclarationBase { | |
666 factory CssStyleDeclaration() => new CssStyleDeclaration.css(''); | |
667 | |
668 factory CssStyleDeclaration.css(String css) { | |
669 final style = new Element.tag('div').style; | |
670 style.cssText = css; | |
671 return style; | |
672 } | |
673 | |
674 String getPropertyValue(String propertyName) { | |
675 var propValue = _getPropertyValueHelper(propertyName); | |
676 return propValue != null ? propValue : ''; | |
677 } | |
678 | |
679 String _getPropertyValueHelper(String propertyName) { | |
680 if (_supportsProperty(_camelCase(propertyName))) { | |
681 return _getPropertyValue(propertyName); | |
682 } else { | |
683 return _getPropertyValue(Device.cssPrefix + propertyName); | |
684 } | |
685 } | |
686 | |
687 /** | |
688 * Returns true if the provided *CSS* property name is supported on this | |
689 * element. | |
690 * | |
691 * Please note the property name camelCase, not-hyphens. This | |
692 * method returns true if the property is accessible via an unprefixed _or_ | |
693 * prefixed property. | |
694 */ | |
695 bool supportsProperty(String propertyName) { | |
696 return _supportsProperty(propertyName) || | |
697 _supportsProperty(_camelCase(Device.cssPrefix + propertyName)); | |
698 } | |
699 | |
700 bool _supportsProperty(String propertyName) { | |
701 return JS('bool', '# in #', propertyName, this.raw); | |
702 } | |
703 | |
704 | |
705 @DomName('CSSStyleDeclaration.setProperty') | |
706 void setProperty(String propertyName, String value, [String priority]) { | |
707 return _setPropertyHelper(_browserPropertyName(propertyName), | |
708 value, priority); | |
709 } | |
710 | |
711 String _browserPropertyName(String propertyName) { | |
712 String name = _readCache(propertyName); | |
713 if (name is String) return name; | |
714 if (_supportsProperty(_camelCase(propertyName))) { | |
715 name = propertyName; | |
716 } else { | |
717 name = Device.cssPrefix + propertyName; | |
718 } | |
719 _writeCache(propertyName, name); | |
720 return name; | |
721 } | |
722 | |
723 static String _readCache(String key) => null; | |
724 static void _writeCache(String key, value) {} | |
725 | |
726 static String _camelCase(String hyphenated) { | |
727 // The "ms" prefix is always lowercased. | |
728 return hyphenated.replaceFirst(new RegExp('^-ms-'), 'ms-').replaceAllMapped( | |
729 new RegExp('-([a-z]+)', caseSensitive: false), | |
730 (match) => match[0][1].toUpperCase() + match[0].substring(2)); | |
731 } | |
732 | |
733 void _setPropertyHelper(String propertyName, String value, [String priority])
{ | |
734 if (value == null) value = ''; | |
735 if (priority == null) priority = ''; | |
736 JS('void', '#.setProperty(#, #, #)', this.raw, propertyName, value, priority
); | |
737 } | |
738 | |
739 /** | |
740 * Checks to see if CSS Transitions are supported. | |
741 */ | |
742 static bool get supportsTransitions { | |
743 return document.body.style.supportsProperty('transition'); | |
744 } | |
745 // To suppress missing implicit constructor warnings. | |
746 factory CssStyleDeclaration._() { throw new UnsupportedError("Not supported");
} | |
747 | |
748 @Deprecated("Internal Use Only") | |
749 static CssStyleDeclaration internalCreateCssStyleDeclaration() { | |
750 return new CssStyleDeclaration.internal_(); | |
751 } | |
752 | |
753 @Deprecated("Internal Use Only") | |
754 CssStyleDeclaration.internal_() { } | |
755 | |
756 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
757 int get hashCode => unwrap_jso(this).hashCode; | |
758 | |
759 @DomName('CSSStyleDeclaration.cssText') | |
760 @DocsEditable() | |
761 String get cssText => wrap_jso(JS("String", "#.cssText", this.raw)); | |
762 @DomName('CSSStyleDeclaration.cssText') | |
763 @DocsEditable() | |
764 void set cssText(String val) => JS("void", "#.cssText = #", this.raw, unwrap_j
so(val)); | |
765 | |
766 @DomName('CSSStyleDeclaration.length') | |
767 @DocsEditable() | |
768 int get length => wrap_jso(JS("int", "#.length", this.raw)); | |
769 | |
770 @DomName('CSSStyleDeclaration.__getter__') | |
771 @DocsEditable() | |
772 @Experimental() // untriaged | |
773 Object __getter__(String name) { | |
774 return __getter___1(name); | |
775 } | |
776 @JSName('__getter__') | |
777 @DomName('CSSStyleDeclaration.__getter__') | |
778 @DocsEditable() | |
779 @Experimental() // untriaged | |
780 Object __getter___1(name) => wrap_jso(JS("Object ", "#.raw.__getter__(#)", thi
s, unwrap_jso(name))); | |
781 | |
782 @DomName('CSSStyleDeclaration.__setter__') | |
783 @DocsEditable() | |
784 void __setter__(String propertyName, String propertyValue) { | |
785 __setter___1(propertyName, propertyValue); | |
786 return; | |
787 } | |
788 @JSName('__setter__') | |
789 @DomName('CSSStyleDeclaration.__setter__') | |
790 @DocsEditable() | |
791 void __setter___1(propertyName, propertyValue) => wrap_jso(JS("void ", "#.raw.
__setter__(#, #)", this, unwrap_jso(propertyName), unwrap_jso(propertyValue))); | |
792 | |
793 @DomName('CSSStyleDeclaration.getPropertyPriority') | |
794 @DocsEditable() | |
795 String getPropertyPriority(String propertyName) { | |
796 return _getPropertyPriority_1(propertyName); | |
797 } | |
798 @JSName('getPropertyPriority') | |
799 @DomName('CSSStyleDeclaration.getPropertyPriority') | |
800 @DocsEditable() | |
801 String _getPropertyPriority_1(propertyName) => wrap_jso(JS("String ", "#.raw.g
etPropertyPriority(#)", this, unwrap_jso(propertyName))); | |
802 | |
803 @DomName('CSSStyleDeclaration.getPropertyValue') | |
804 @DocsEditable() | |
805 String _getPropertyValue(String propertyName) { | |
806 return _getPropertyValue_1(propertyName); | |
807 } | |
808 @JSName('getPropertyValue') | |
809 @DomName('CSSStyleDeclaration.getPropertyValue') | |
810 @DocsEditable() | |
811 String _getPropertyValue_1(propertyName) => wrap_jso(JS("String ", "#.raw.getP
ropertyValue(#)", this, unwrap_jso(propertyName))); | |
812 | |
813 @DomName('CSSStyleDeclaration.item') | |
814 @DocsEditable() | |
815 String item(int index) { | |
816 return _item_1(index); | |
817 } | |
818 @JSName('item') | |
819 @DomName('CSSStyleDeclaration.item') | |
820 @DocsEditable() | |
821 String _item_1(index) => wrap_jso(JS("String ", "#.raw.item(#)", this, unwrap_
jso(index))); | |
822 | |
823 @DomName('CSSStyleDeclaration.removeProperty') | |
824 @DocsEditable() | |
825 String removeProperty(String propertyName) { | |
826 return _removeProperty_1(propertyName); | |
827 } | |
828 @JSName('removeProperty') | |
829 @DomName('CSSStyleDeclaration.removeProperty') | |
830 @DocsEditable() | |
831 String _removeProperty_1(propertyName) => wrap_jso(JS("String ", "#.raw.remove
Property(#)", this, unwrap_jso(propertyName))); | |
832 | |
833 } | |
834 | |
835 class _CssStyleDeclarationSet extends Object with CssStyleDeclarationBase { | |
836 final Iterable<Element> _elementIterable; | |
837 Iterable<CssStyleDeclaration> _elementCssStyleDeclarationSetIterable; | |
838 | |
839 _CssStyleDeclarationSet(this._elementIterable) { | |
840 _elementCssStyleDeclarationSetIterable = new List.from( | |
841 _elementIterable).map((e) => e.style); | |
842 } | |
843 | |
844 String getPropertyValue(String propertyName) => | |
845 _elementCssStyleDeclarationSetIterable.first.getPropertyValue( | |
846 propertyName); | |
847 | |
848 void setProperty(String propertyName, String value, [String priority]) { | |
849 _elementCssStyleDeclarationSetIterable.forEach((e) => | |
850 e.setProperty(propertyName, value, priority)); | |
851 } | |
852 | |
853 | |
854 | |
855 // Important note: CssStyleDeclarationSet does NOT implement every method | |
856 // available in CssStyleDeclaration. Some of the methods don't make so much | |
857 // sense in terms of having a resonable value to return when you're | |
858 // considering a list of Elements. You will need to manually add any of the | |
859 // items in the MEMBERS set if you want that functionality. | |
860 } | |
861 | |
862 class CssStyleDeclarationBase { | |
863 String getPropertyValue(String propertyName) => | |
864 throw new StateError('getProperty not overridden in dart:html'); | |
865 void setProperty(String propertyName, String value, [String priority]) => | |
866 throw new StateError('setProperty not overridden in dart:html'); | |
867 | |
868 /** Gets the value of "align-content" */ | |
869 String get alignContent => | |
870 getPropertyValue('align-content'); | |
871 | |
872 /** Sets the value of "align-content" */ | |
873 set alignContent(String value) { | |
874 setProperty('align-content', value, ''); | |
875 } | |
876 | |
877 /** Gets the value of "align-items" */ | |
878 String get alignItems => | |
879 getPropertyValue('align-items'); | |
880 | |
881 /** Sets the value of "align-items" */ | |
882 set alignItems(String value) { | |
883 setProperty('align-items', value, ''); | |
884 } | |
885 | |
886 /** Gets the value of "align-self" */ | |
887 String get alignSelf => | |
888 getPropertyValue('align-self'); | |
889 | |
890 /** Sets the value of "align-self" */ | |
891 set alignSelf(String value) { | |
892 setProperty('align-self', value, ''); | |
893 } | |
894 | |
895 /** Gets the value of "animation" */ | |
896 String get animation => | |
897 getPropertyValue('animation'); | |
898 | |
899 /** Sets the value of "animation" */ | |
900 set animation(String value) { | |
901 setProperty('animation', value, ''); | |
902 } | |
903 | |
904 /** Gets the value of "animation-delay" */ | |
905 String get animationDelay => | |
906 getPropertyValue('animation-delay'); | |
907 | |
908 /** Sets the value of "animation-delay" */ | |
909 set animationDelay(String value) { | |
910 setProperty('animation-delay', value, ''); | |
911 } | |
912 | |
913 /** Gets the value of "animation-direction" */ | |
914 String get animationDirection => | |
915 getPropertyValue('animation-direction'); | |
916 | |
917 /** Sets the value of "animation-direction" */ | |
918 set animationDirection(String value) { | |
919 setProperty('animation-direction', value, ''); | |
920 } | |
921 | |
922 /** Gets the value of "animation-duration" */ | |
923 String get animationDuration => | |
924 getPropertyValue('animation-duration'); | |
925 | |
926 /** Sets the value of "animation-duration" */ | |
927 set animationDuration(String value) { | |
928 setProperty('animation-duration', value, ''); | |
929 } | |
930 | |
931 /** Gets the value of "animation-fill-mode" */ | |
932 String get animationFillMode => | |
933 getPropertyValue('animation-fill-mode'); | |
934 | |
935 /** Sets the value of "animation-fill-mode" */ | |
936 set animationFillMode(String value) { | |
937 setProperty('animation-fill-mode', value, ''); | |
938 } | |
939 | |
940 /** Gets the value of "animation-iteration-count" */ | |
941 String get animationIterationCount => | |
942 getPropertyValue('animation-iteration-count'); | |
943 | |
944 /** Sets the value of "animation-iteration-count" */ | |
945 set animationIterationCount(String value) { | |
946 setProperty('animation-iteration-count', value, ''); | |
947 } | |
948 | |
949 /** Gets the value of "animation-name" */ | |
950 String get animationName => | |
951 getPropertyValue('animation-name'); | |
952 | |
953 /** Sets the value of "animation-name" */ | |
954 set animationName(String value) { | |
955 setProperty('animation-name', value, ''); | |
956 } | |
957 | |
958 /** Gets the value of "animation-play-state" */ | |
959 String get animationPlayState => | |
960 getPropertyValue('animation-play-state'); | |
961 | |
962 /** Sets the value of "animation-play-state" */ | |
963 set animationPlayState(String value) { | |
964 setProperty('animation-play-state', value, ''); | |
965 } | |
966 | |
967 /** Gets the value of "animation-timing-function" */ | |
968 String get animationTimingFunction => | |
969 getPropertyValue('animation-timing-function'); | |
970 | |
971 /** Sets the value of "animation-timing-function" */ | |
972 set animationTimingFunction(String value) { | |
973 setProperty('animation-timing-function', value, ''); | |
974 } | |
975 | |
976 /** Gets the value of "app-region" */ | |
977 String get appRegion => | |
978 getPropertyValue('app-region'); | |
979 | |
980 /** Sets the value of "app-region" */ | |
981 set appRegion(String value) { | |
982 setProperty('app-region', value, ''); | |
983 } | |
984 | |
985 /** Gets the value of "appearance" */ | |
986 String get appearance => | |
987 getPropertyValue('appearance'); | |
988 | |
989 /** Sets the value of "appearance" */ | |
990 set appearance(String value) { | |
991 setProperty('appearance', value, ''); | |
992 } | |
993 | |
994 /** Gets the value of "aspect-ratio" */ | |
995 String get aspectRatio => | |
996 getPropertyValue('aspect-ratio'); | |
997 | |
998 /** Sets the value of "aspect-ratio" */ | |
999 set aspectRatio(String value) { | |
1000 setProperty('aspect-ratio', value, ''); | |
1001 } | |
1002 | |
1003 /** Gets the value of "backface-visibility" */ | |
1004 String get backfaceVisibility => | |
1005 getPropertyValue('backface-visibility'); | |
1006 | |
1007 /** Sets the value of "backface-visibility" */ | |
1008 set backfaceVisibility(String value) { | |
1009 setProperty('backface-visibility', value, ''); | |
1010 } | |
1011 | |
1012 /** Gets the value of "background" */ | |
1013 String get background => | |
1014 getPropertyValue('background'); | |
1015 | |
1016 /** Sets the value of "background" */ | |
1017 set background(String value) { | |
1018 setProperty('background', value, ''); | |
1019 } | |
1020 | |
1021 /** Gets the value of "background-attachment" */ | |
1022 String get backgroundAttachment => | |
1023 getPropertyValue('background-attachment'); | |
1024 | |
1025 /** Sets the value of "background-attachment" */ | |
1026 set backgroundAttachment(String value) { | |
1027 setProperty('background-attachment', value, ''); | |
1028 } | |
1029 | |
1030 /** Gets the value of "background-blend-mode" */ | |
1031 String get backgroundBlendMode => | |
1032 getPropertyValue('background-blend-mode'); | |
1033 | |
1034 /** Sets the value of "background-blend-mode" */ | |
1035 set backgroundBlendMode(String value) { | |
1036 setProperty('background-blend-mode', value, ''); | |
1037 } | |
1038 | |
1039 /** Gets the value of "background-clip" */ | |
1040 String get backgroundClip => | |
1041 getPropertyValue('background-clip'); | |
1042 | |
1043 /** Sets the value of "background-clip" */ | |
1044 set backgroundClip(String value) { | |
1045 setProperty('background-clip', value, ''); | |
1046 } | |
1047 | |
1048 /** Gets the value of "background-color" */ | |
1049 String get backgroundColor => | |
1050 getPropertyValue('background-color'); | |
1051 | |
1052 /** Sets the value of "background-color" */ | |
1053 set backgroundColor(String value) { | |
1054 setProperty('background-color', value, ''); | |
1055 } | |
1056 | |
1057 /** Gets the value of "background-composite" */ | |
1058 String get backgroundComposite => | |
1059 getPropertyValue('background-composite'); | |
1060 | |
1061 /** Sets the value of "background-composite" */ | |
1062 set backgroundComposite(String value) { | |
1063 setProperty('background-composite', value, ''); | |
1064 } | |
1065 | |
1066 /** Gets the value of "background-image" */ | |
1067 String get backgroundImage => | |
1068 getPropertyValue('background-image'); | |
1069 | |
1070 /** Sets the value of "background-image" */ | |
1071 set backgroundImage(String value) { | |
1072 setProperty('background-image', value, ''); | |
1073 } | |
1074 | |
1075 /** Gets the value of "background-origin" */ | |
1076 String get backgroundOrigin => | |
1077 getPropertyValue('background-origin'); | |
1078 | |
1079 /** Sets the value of "background-origin" */ | |
1080 set backgroundOrigin(String value) { | |
1081 setProperty('background-origin', value, ''); | |
1082 } | |
1083 | |
1084 /** Gets the value of "background-position" */ | |
1085 String get backgroundPosition => | |
1086 getPropertyValue('background-position'); | |
1087 | |
1088 /** Sets the value of "background-position" */ | |
1089 set backgroundPosition(String value) { | |
1090 setProperty('background-position', value, ''); | |
1091 } | |
1092 | |
1093 /** Gets the value of "background-position-x" */ | |
1094 String get backgroundPositionX => | |
1095 getPropertyValue('background-position-x'); | |
1096 | |
1097 /** Sets the value of "background-position-x" */ | |
1098 set backgroundPositionX(String value) { | |
1099 setProperty('background-position-x', value, ''); | |
1100 } | |
1101 | |
1102 /** Gets the value of "background-position-y" */ | |
1103 String get backgroundPositionY => | |
1104 getPropertyValue('background-position-y'); | |
1105 | |
1106 /** Sets the value of "background-position-y" */ | |
1107 set backgroundPositionY(String value) { | |
1108 setProperty('background-position-y', value, ''); | |
1109 } | |
1110 | |
1111 /** Gets the value of "background-repeat" */ | |
1112 String get backgroundRepeat => | |
1113 getPropertyValue('background-repeat'); | |
1114 | |
1115 /** Sets the value of "background-repeat" */ | |
1116 set backgroundRepeat(String value) { | |
1117 setProperty('background-repeat', value, ''); | |
1118 } | |
1119 | |
1120 /** Gets the value of "background-repeat-x" */ | |
1121 String get backgroundRepeatX => | |
1122 getPropertyValue('background-repeat-x'); | |
1123 | |
1124 /** Sets the value of "background-repeat-x" */ | |
1125 set backgroundRepeatX(String value) { | |
1126 setProperty('background-repeat-x', value, ''); | |
1127 } | |
1128 | |
1129 /** Gets the value of "background-repeat-y" */ | |
1130 String get backgroundRepeatY => | |
1131 getPropertyValue('background-repeat-y'); | |
1132 | |
1133 /** Sets the value of "background-repeat-y" */ | |
1134 set backgroundRepeatY(String value) { | |
1135 setProperty('background-repeat-y', value, ''); | |
1136 } | |
1137 | |
1138 /** Gets the value of "background-size" */ | |
1139 String get backgroundSize => | |
1140 getPropertyValue('background-size'); | |
1141 | |
1142 /** Sets the value of "background-size" */ | |
1143 set backgroundSize(String value) { | |
1144 setProperty('background-size', value, ''); | |
1145 } | |
1146 | |
1147 /** Gets the value of "border" */ | |
1148 String get border => | |
1149 getPropertyValue('border'); | |
1150 | |
1151 /** Sets the value of "border" */ | |
1152 set border(String value) { | |
1153 setProperty('border', value, ''); | |
1154 } | |
1155 | |
1156 /** Gets the value of "border-after" */ | |
1157 String get borderAfter => | |
1158 getPropertyValue('border-after'); | |
1159 | |
1160 /** Sets the value of "border-after" */ | |
1161 set borderAfter(String value) { | |
1162 setProperty('border-after', value, ''); | |
1163 } | |
1164 | |
1165 /** Gets the value of "border-after-color" */ | |
1166 String get borderAfterColor => | |
1167 getPropertyValue('border-after-color'); | |
1168 | |
1169 /** Sets the value of "border-after-color" */ | |
1170 set borderAfterColor(String value) { | |
1171 setProperty('border-after-color', value, ''); | |
1172 } | |
1173 | |
1174 /** Gets the value of "border-after-style" */ | |
1175 String get borderAfterStyle => | |
1176 getPropertyValue('border-after-style'); | |
1177 | |
1178 /** Sets the value of "border-after-style" */ | |
1179 set borderAfterStyle(String value) { | |
1180 setProperty('border-after-style', value, ''); | |
1181 } | |
1182 | |
1183 /** Gets the value of "border-after-width" */ | |
1184 String get borderAfterWidth => | |
1185 getPropertyValue('border-after-width'); | |
1186 | |
1187 /** Sets the value of "border-after-width" */ | |
1188 set borderAfterWidth(String value) { | |
1189 setProperty('border-after-width', value, ''); | |
1190 } | |
1191 | |
1192 /** Gets the value of "border-before" */ | |
1193 String get borderBefore => | |
1194 getPropertyValue('border-before'); | |
1195 | |
1196 /** Sets the value of "border-before" */ | |
1197 set borderBefore(String value) { | |
1198 setProperty('border-before', value, ''); | |
1199 } | |
1200 | |
1201 /** Gets the value of "border-before-color" */ | |
1202 String get borderBeforeColor => | |
1203 getPropertyValue('border-before-color'); | |
1204 | |
1205 /** Sets the value of "border-before-color" */ | |
1206 set borderBeforeColor(String value) { | |
1207 setProperty('border-before-color', value, ''); | |
1208 } | |
1209 | |
1210 /** Gets the value of "border-before-style" */ | |
1211 String get borderBeforeStyle => | |
1212 getPropertyValue('border-before-style'); | |
1213 | |
1214 /** Sets the value of "border-before-style" */ | |
1215 set borderBeforeStyle(String value) { | |
1216 setProperty('border-before-style', value, ''); | |
1217 } | |
1218 | |
1219 /** Gets the value of "border-before-width" */ | |
1220 String get borderBeforeWidth => | |
1221 getPropertyValue('border-before-width'); | |
1222 | |
1223 /** Sets the value of "border-before-width" */ | |
1224 set borderBeforeWidth(String value) { | |
1225 setProperty('border-before-width', value, ''); | |
1226 } | |
1227 | |
1228 /** Gets the value of "border-bottom" */ | |
1229 String get borderBottom => | |
1230 getPropertyValue('border-bottom'); | |
1231 | |
1232 /** Sets the value of "border-bottom" */ | |
1233 set borderBottom(String value) { | |
1234 setProperty('border-bottom', value, ''); | |
1235 } | |
1236 | |
1237 /** Gets the value of "border-bottom-color" */ | |
1238 String get borderBottomColor => | |
1239 getPropertyValue('border-bottom-color'); | |
1240 | |
1241 /** Sets the value of "border-bottom-color" */ | |
1242 set borderBottomColor(String value) { | |
1243 setProperty('border-bottom-color', value, ''); | |
1244 } | |
1245 | |
1246 /** Gets the value of "border-bottom-left-radius" */ | |
1247 String get borderBottomLeftRadius => | |
1248 getPropertyValue('border-bottom-left-radius'); | |
1249 | |
1250 /** Sets the value of "border-bottom-left-radius" */ | |
1251 set borderBottomLeftRadius(String value) { | |
1252 setProperty('border-bottom-left-radius', value, ''); | |
1253 } | |
1254 | |
1255 /** Gets the value of "border-bottom-right-radius" */ | |
1256 String get borderBottomRightRadius => | |
1257 getPropertyValue('border-bottom-right-radius'); | |
1258 | |
1259 /** Sets the value of "border-bottom-right-radius" */ | |
1260 set borderBottomRightRadius(String value) { | |
1261 setProperty('border-bottom-right-radius', value, ''); | |
1262 } | |
1263 | |
1264 /** Gets the value of "border-bottom-style" */ | |
1265 String get borderBottomStyle => | |
1266 getPropertyValue('border-bottom-style'); | |
1267 | |
1268 /** Sets the value of "border-bottom-style" */ | |
1269 set borderBottomStyle(String value) { | |
1270 setProperty('border-bottom-style', value, ''); | |
1271 } | |
1272 | |
1273 /** Gets the value of "border-bottom-width" */ | |
1274 String get borderBottomWidth => | |
1275 getPropertyValue('border-bottom-width'); | |
1276 | |
1277 /** Sets the value of "border-bottom-width" */ | |
1278 set borderBottomWidth(String value) { | |
1279 setProperty('border-bottom-width', value, ''); | |
1280 } | |
1281 | |
1282 /** Gets the value of "border-collapse" */ | |
1283 String get borderCollapse => | |
1284 getPropertyValue('border-collapse'); | |
1285 | |
1286 /** Sets the value of "border-collapse" */ | |
1287 set borderCollapse(String value) { | |
1288 setProperty('border-collapse', value, ''); | |
1289 } | |
1290 | |
1291 /** Gets the value of "border-color" */ | |
1292 String get borderColor => | |
1293 getPropertyValue('border-color'); | |
1294 | |
1295 /** Sets the value of "border-color" */ | |
1296 set borderColor(String value) { | |
1297 setProperty('border-color', value, ''); | |
1298 } | |
1299 | |
1300 /** Gets the value of "border-end" */ | |
1301 String get borderEnd => | |
1302 getPropertyValue('border-end'); | |
1303 | |
1304 /** Sets the value of "border-end" */ | |
1305 set borderEnd(String value) { | |
1306 setProperty('border-end', value, ''); | |
1307 } | |
1308 | |
1309 /** Gets the value of "border-end-color" */ | |
1310 String get borderEndColor => | |
1311 getPropertyValue('border-end-color'); | |
1312 | |
1313 /** Sets the value of "border-end-color" */ | |
1314 set borderEndColor(String value) { | |
1315 setProperty('border-end-color', value, ''); | |
1316 } | |
1317 | |
1318 /** Gets the value of "border-end-style" */ | |
1319 String get borderEndStyle => | |
1320 getPropertyValue('border-end-style'); | |
1321 | |
1322 /** Sets the value of "border-end-style" */ | |
1323 set borderEndStyle(String value) { | |
1324 setProperty('border-end-style', value, ''); | |
1325 } | |
1326 | |
1327 /** Gets the value of "border-end-width" */ | |
1328 String get borderEndWidth => | |
1329 getPropertyValue('border-end-width'); | |
1330 | |
1331 /** Sets the value of "border-end-width" */ | |
1332 set borderEndWidth(String value) { | |
1333 setProperty('border-end-width', value, ''); | |
1334 } | |
1335 | |
1336 /** Gets the value of "border-fit" */ | |
1337 String get borderFit => | |
1338 getPropertyValue('border-fit'); | |
1339 | |
1340 /** Sets the value of "border-fit" */ | |
1341 set borderFit(String value) { | |
1342 setProperty('border-fit', value, ''); | |
1343 } | |
1344 | |
1345 /** Gets the value of "border-horizontal-spacing" */ | |
1346 String get borderHorizontalSpacing => | |
1347 getPropertyValue('border-horizontal-spacing'); | |
1348 | |
1349 /** Sets the value of "border-horizontal-spacing" */ | |
1350 set borderHorizontalSpacing(String value) { | |
1351 setProperty('border-horizontal-spacing', value, ''); | |
1352 } | |
1353 | |
1354 /** Gets the value of "border-image" */ | |
1355 String get borderImage => | |
1356 getPropertyValue('border-image'); | |
1357 | |
1358 /** Sets the value of "border-image" */ | |
1359 set borderImage(String value) { | |
1360 setProperty('border-image', value, ''); | |
1361 } | |
1362 | |
1363 /** Gets the value of "border-image-outset" */ | |
1364 String get borderImageOutset => | |
1365 getPropertyValue('border-image-outset'); | |
1366 | |
1367 /** Sets the value of "border-image-outset" */ | |
1368 set borderImageOutset(String value) { | |
1369 setProperty('border-image-outset', value, ''); | |
1370 } | |
1371 | |
1372 /** Gets the value of "border-image-repeat" */ | |
1373 String get borderImageRepeat => | |
1374 getPropertyValue('border-image-repeat'); | |
1375 | |
1376 /** Sets the value of "border-image-repeat" */ | |
1377 set borderImageRepeat(String value) { | |
1378 setProperty('border-image-repeat', value, ''); | |
1379 } | |
1380 | |
1381 /** Gets the value of "border-image-slice" */ | |
1382 String get borderImageSlice => | |
1383 getPropertyValue('border-image-slice'); | |
1384 | |
1385 /** Sets the value of "border-image-slice" */ | |
1386 set borderImageSlice(String value) { | |
1387 setProperty('border-image-slice', value, ''); | |
1388 } | |
1389 | |
1390 /** Gets the value of "border-image-source" */ | |
1391 String get borderImageSource => | |
1392 getPropertyValue('border-image-source'); | |
1393 | |
1394 /** Sets the value of "border-image-source" */ | |
1395 set borderImageSource(String value) { | |
1396 setProperty('border-image-source', value, ''); | |
1397 } | |
1398 | |
1399 /** Gets the value of "border-image-width" */ | |
1400 String get borderImageWidth => | |
1401 getPropertyValue('border-image-width'); | |
1402 | |
1403 /** Sets the value of "border-image-width" */ | |
1404 set borderImageWidth(String value) { | |
1405 setProperty('border-image-width', value, ''); | |
1406 } | |
1407 | |
1408 /** Gets the value of "border-left" */ | |
1409 String get borderLeft => | |
1410 getPropertyValue('border-left'); | |
1411 | |
1412 /** Sets the value of "border-left" */ | |
1413 set borderLeft(String value) { | |
1414 setProperty('border-left', value, ''); | |
1415 } | |
1416 | |
1417 /** Gets the value of "border-left-color" */ | |
1418 String get borderLeftColor => | |
1419 getPropertyValue('border-left-color'); | |
1420 | |
1421 /** Sets the value of "border-left-color" */ | |
1422 set borderLeftColor(String value) { | |
1423 setProperty('border-left-color', value, ''); | |
1424 } | |
1425 | |
1426 /** Gets the value of "border-left-style" */ | |
1427 String get borderLeftStyle => | |
1428 getPropertyValue('border-left-style'); | |
1429 | |
1430 /** Sets the value of "border-left-style" */ | |
1431 set borderLeftStyle(String value) { | |
1432 setProperty('border-left-style', value, ''); | |
1433 } | |
1434 | |
1435 /** Gets the value of "border-left-width" */ | |
1436 String get borderLeftWidth => | |
1437 getPropertyValue('border-left-width'); | |
1438 | |
1439 /** Sets the value of "border-left-width" */ | |
1440 set borderLeftWidth(String value) { | |
1441 setProperty('border-left-width', value, ''); | |
1442 } | |
1443 | |
1444 /** Gets the value of "border-radius" */ | |
1445 String get borderRadius => | |
1446 getPropertyValue('border-radius'); | |
1447 | |
1448 /** Sets the value of "border-radius" */ | |
1449 set borderRadius(String value) { | |
1450 setProperty('border-radius', value, ''); | |
1451 } | |
1452 | |
1453 /** Gets the value of "border-right" */ | |
1454 String get borderRight => | |
1455 getPropertyValue('border-right'); | |
1456 | |
1457 /** Sets the value of "border-right" */ | |
1458 set borderRight(String value) { | |
1459 setProperty('border-right', value, ''); | |
1460 } | |
1461 | |
1462 /** Gets the value of "border-right-color" */ | |
1463 String get borderRightColor => | |
1464 getPropertyValue('border-right-color'); | |
1465 | |
1466 /** Sets the value of "border-right-color" */ | |
1467 set borderRightColor(String value) { | |
1468 setProperty('border-right-color', value, ''); | |
1469 } | |
1470 | |
1471 /** Gets the value of "border-right-style" */ | |
1472 String get borderRightStyle => | |
1473 getPropertyValue('border-right-style'); | |
1474 | |
1475 /** Sets the value of "border-right-style" */ | |
1476 set borderRightStyle(String value) { | |
1477 setProperty('border-right-style', value, ''); | |
1478 } | |
1479 | |
1480 /** Gets the value of "border-right-width" */ | |
1481 String get borderRightWidth => | |
1482 getPropertyValue('border-right-width'); | |
1483 | |
1484 /** Sets the value of "border-right-width" */ | |
1485 set borderRightWidth(String value) { | |
1486 setProperty('border-right-width', value, ''); | |
1487 } | |
1488 | |
1489 /** Gets the value of "border-spacing" */ | |
1490 String get borderSpacing => | |
1491 getPropertyValue('border-spacing'); | |
1492 | |
1493 /** Sets the value of "border-spacing" */ | |
1494 set borderSpacing(String value) { | |
1495 setProperty('border-spacing', value, ''); | |
1496 } | |
1497 | |
1498 /** Gets the value of "border-start" */ | |
1499 String get borderStart => | |
1500 getPropertyValue('border-start'); | |
1501 | |
1502 /** Sets the value of "border-start" */ | |
1503 set borderStart(String value) { | |
1504 setProperty('border-start', value, ''); | |
1505 } | |
1506 | |
1507 /** Gets the value of "border-start-color" */ | |
1508 String get borderStartColor => | |
1509 getPropertyValue('border-start-color'); | |
1510 | |
1511 /** Sets the value of "border-start-color" */ | |
1512 set borderStartColor(String value) { | |
1513 setProperty('border-start-color', value, ''); | |
1514 } | |
1515 | |
1516 /** Gets the value of "border-start-style" */ | |
1517 String get borderStartStyle => | |
1518 getPropertyValue('border-start-style'); | |
1519 | |
1520 /** Sets the value of "border-start-style" */ | |
1521 set borderStartStyle(String value) { | |
1522 setProperty('border-start-style', value, ''); | |
1523 } | |
1524 | |
1525 /** Gets the value of "border-start-width" */ | |
1526 String get borderStartWidth => | |
1527 getPropertyValue('border-start-width'); | |
1528 | |
1529 /** Sets the value of "border-start-width" */ | |
1530 set borderStartWidth(String value) { | |
1531 setProperty('border-start-width', value, ''); | |
1532 } | |
1533 | |
1534 /** Gets the value of "border-style" */ | |
1535 String get borderStyle => | |
1536 getPropertyValue('border-style'); | |
1537 | |
1538 /** Sets the value of "border-style" */ | |
1539 set borderStyle(String value) { | |
1540 setProperty('border-style', value, ''); | |
1541 } | |
1542 | |
1543 /** Gets the value of "border-top" */ | |
1544 String get borderTop => | |
1545 getPropertyValue('border-top'); | |
1546 | |
1547 /** Sets the value of "border-top" */ | |
1548 set borderTop(String value) { | |
1549 setProperty('border-top', value, ''); | |
1550 } | |
1551 | |
1552 /** Gets the value of "border-top-color" */ | |
1553 String get borderTopColor => | |
1554 getPropertyValue('border-top-color'); | |
1555 | |
1556 /** Sets the value of "border-top-color" */ | |
1557 set borderTopColor(String value) { | |
1558 setProperty('border-top-color', value, ''); | |
1559 } | |
1560 | |
1561 /** Gets the value of "border-top-left-radius" */ | |
1562 String get borderTopLeftRadius => | |
1563 getPropertyValue('border-top-left-radius'); | |
1564 | |
1565 /** Sets the value of "border-top-left-radius" */ | |
1566 set borderTopLeftRadius(String value) { | |
1567 setProperty('border-top-left-radius', value, ''); | |
1568 } | |
1569 | |
1570 /** Gets the value of "border-top-right-radius" */ | |
1571 String get borderTopRightRadius => | |
1572 getPropertyValue('border-top-right-radius'); | |
1573 | |
1574 /** Sets the value of "border-top-right-radius" */ | |
1575 set borderTopRightRadius(String value) { | |
1576 setProperty('border-top-right-radius', value, ''); | |
1577 } | |
1578 | |
1579 /** Gets the value of "border-top-style" */ | |
1580 String get borderTopStyle => | |
1581 getPropertyValue('border-top-style'); | |
1582 | |
1583 /** Sets the value of "border-top-style" */ | |
1584 set borderTopStyle(String value) { | |
1585 setProperty('border-top-style', value, ''); | |
1586 } | |
1587 | |
1588 /** Gets the value of "border-top-width" */ | |
1589 String get borderTopWidth => | |
1590 getPropertyValue('border-top-width'); | |
1591 | |
1592 /** Sets the value of "border-top-width" */ | |
1593 set borderTopWidth(String value) { | |
1594 setProperty('border-top-width', value, ''); | |
1595 } | |
1596 | |
1597 /** Gets the value of "border-vertical-spacing" */ | |
1598 String get borderVerticalSpacing => | |
1599 getPropertyValue('border-vertical-spacing'); | |
1600 | |
1601 /** Sets the value of "border-vertical-spacing" */ | |
1602 set borderVerticalSpacing(String value) { | |
1603 setProperty('border-vertical-spacing', value, ''); | |
1604 } | |
1605 | |
1606 /** Gets the value of "border-width" */ | |
1607 String get borderWidth => | |
1608 getPropertyValue('border-width'); | |
1609 | |
1610 /** Sets the value of "border-width" */ | |
1611 set borderWidth(String value) { | |
1612 setProperty('border-width', value, ''); | |
1613 } | |
1614 | |
1615 /** Gets the value of "bottom" */ | |
1616 String get bottom => | |
1617 getPropertyValue('bottom'); | |
1618 | |
1619 /** Sets the value of "bottom" */ | |
1620 set bottom(String value) { | |
1621 setProperty('bottom', value, ''); | |
1622 } | |
1623 | |
1624 /** Gets the value of "box-align" */ | |
1625 String get boxAlign => | |
1626 getPropertyValue('box-align'); | |
1627 | |
1628 /** Sets the value of "box-align" */ | |
1629 set boxAlign(String value) { | |
1630 setProperty('box-align', value, ''); | |
1631 } | |
1632 | |
1633 /** Gets the value of "box-decoration-break" */ | |
1634 String get boxDecorationBreak => | |
1635 getPropertyValue('box-decoration-break'); | |
1636 | |
1637 /** Sets the value of "box-decoration-break" */ | |
1638 set boxDecorationBreak(String value) { | |
1639 setProperty('box-decoration-break', value, ''); | |
1640 } | |
1641 | |
1642 /** Gets the value of "box-direction" */ | |
1643 String get boxDirection => | |
1644 getPropertyValue('box-direction'); | |
1645 | |
1646 /** Sets the value of "box-direction" */ | |
1647 set boxDirection(String value) { | |
1648 setProperty('box-direction', value, ''); | |
1649 } | |
1650 | |
1651 /** Gets the value of "box-flex" */ | |
1652 String get boxFlex => | |
1653 getPropertyValue('box-flex'); | |
1654 | |
1655 /** Sets the value of "box-flex" */ | |
1656 set boxFlex(String value) { | |
1657 setProperty('box-flex', value, ''); | |
1658 } | |
1659 | |
1660 /** Gets the value of "box-flex-group" */ | |
1661 String get boxFlexGroup => | |
1662 getPropertyValue('box-flex-group'); | |
1663 | |
1664 /** Sets the value of "box-flex-group" */ | |
1665 set boxFlexGroup(String value) { | |
1666 setProperty('box-flex-group', value, ''); | |
1667 } | |
1668 | |
1669 /** Gets the value of "box-lines" */ | |
1670 String get boxLines => | |
1671 getPropertyValue('box-lines'); | |
1672 | |
1673 /** Sets the value of "box-lines" */ | |
1674 set boxLines(String value) { | |
1675 setProperty('box-lines', value, ''); | |
1676 } | |
1677 | |
1678 /** Gets the value of "box-ordinal-group" */ | |
1679 String get boxOrdinalGroup => | |
1680 getPropertyValue('box-ordinal-group'); | |
1681 | |
1682 /** Sets the value of "box-ordinal-group" */ | |
1683 set boxOrdinalGroup(String value) { | |
1684 setProperty('box-ordinal-group', value, ''); | |
1685 } | |
1686 | |
1687 /** Gets the value of "box-orient" */ | |
1688 String get boxOrient => | |
1689 getPropertyValue('box-orient'); | |
1690 | |
1691 /** Sets the value of "box-orient" */ | |
1692 set boxOrient(String value) { | |
1693 setProperty('box-orient', value, ''); | |
1694 } | |
1695 | |
1696 /** Gets the value of "box-pack" */ | |
1697 String get boxPack => | |
1698 getPropertyValue('box-pack'); | |
1699 | |
1700 /** Sets the value of "box-pack" */ | |
1701 set boxPack(String value) { | |
1702 setProperty('box-pack', value, ''); | |
1703 } | |
1704 | |
1705 /** Gets the value of "box-reflect" */ | |
1706 String get boxReflect => | |
1707 getPropertyValue('box-reflect'); | |
1708 | |
1709 /** Sets the value of "box-reflect" */ | |
1710 set boxReflect(String value) { | |
1711 setProperty('box-reflect', value, ''); | |
1712 } | |
1713 | |
1714 /** Gets the value of "box-shadow" */ | |
1715 String get boxShadow => | |
1716 getPropertyValue('box-shadow'); | |
1717 | |
1718 /** Sets the value of "box-shadow" */ | |
1719 set boxShadow(String value) { | |
1720 setProperty('box-shadow', value, ''); | |
1721 } | |
1722 | |
1723 /** Gets the value of "box-sizing" */ | |
1724 String get boxSizing => | |
1725 getPropertyValue('box-sizing'); | |
1726 | |
1727 /** Sets the value of "box-sizing" */ | |
1728 set boxSizing(String value) { | |
1729 setProperty('box-sizing', value, ''); | |
1730 } | |
1731 | |
1732 /** Gets the value of "caption-side" */ | |
1733 String get captionSide => | |
1734 getPropertyValue('caption-side'); | |
1735 | |
1736 /** Sets the value of "caption-side" */ | |
1737 set captionSide(String value) { | |
1738 setProperty('caption-side', value, ''); | |
1739 } | |
1740 | |
1741 /** Gets the value of "clear" */ | |
1742 String get clear => | |
1743 getPropertyValue('clear'); | |
1744 | |
1745 /** Sets the value of "clear" */ | |
1746 set clear(String value) { | |
1747 setProperty('clear', value, ''); | |
1748 } | |
1749 | |
1750 /** Gets the value of "clip" */ | |
1751 String get clip => | |
1752 getPropertyValue('clip'); | |
1753 | |
1754 /** Sets the value of "clip" */ | |
1755 set clip(String value) { | |
1756 setProperty('clip', value, ''); | |
1757 } | |
1758 | |
1759 /** Gets the value of "clip-path" */ | |
1760 String get clipPath => | |
1761 getPropertyValue('clip-path'); | |
1762 | |
1763 /** Sets the value of "clip-path" */ | |
1764 set clipPath(String value) { | |
1765 setProperty('clip-path', value, ''); | |
1766 } | |
1767 | |
1768 /** Gets the value of "color" */ | |
1769 String get color => | |
1770 getPropertyValue('color'); | |
1771 | |
1772 /** Sets the value of "color" */ | |
1773 set color(String value) { | |
1774 setProperty('color', value, ''); | |
1775 } | |
1776 | |
1777 /** Gets the value of "column-break-after" */ | |
1778 String get columnBreakAfter => | |
1779 getPropertyValue('column-break-after'); | |
1780 | |
1781 /** Sets the value of "column-break-after" */ | |
1782 set columnBreakAfter(String value) { | |
1783 setProperty('column-break-after', value, ''); | |
1784 } | |
1785 | |
1786 /** Gets the value of "column-break-before" */ | |
1787 String get columnBreakBefore => | |
1788 getPropertyValue('column-break-before'); | |
1789 | |
1790 /** Sets the value of "column-break-before" */ | |
1791 set columnBreakBefore(String value) { | |
1792 setProperty('column-break-before', value, ''); | |
1793 } | |
1794 | |
1795 /** Gets the value of "column-break-inside" */ | |
1796 String get columnBreakInside => | |
1797 getPropertyValue('column-break-inside'); | |
1798 | |
1799 /** Sets the value of "column-break-inside" */ | |
1800 set columnBreakInside(String value) { | |
1801 setProperty('column-break-inside', value, ''); | |
1802 } | |
1803 | |
1804 /** Gets the value of "column-count" */ | |
1805 String get columnCount => | |
1806 getPropertyValue('column-count'); | |
1807 | |
1808 /** Sets the value of "column-count" */ | |
1809 set columnCount(String value) { | |
1810 setProperty('column-count', value, ''); | |
1811 } | |
1812 | |
1813 /** Gets the value of "column-fill" */ | |
1814 String get columnFill => | |
1815 getPropertyValue('column-fill'); | |
1816 | |
1817 /** Sets the value of "column-fill" */ | |
1818 set columnFill(String value) { | |
1819 setProperty('column-fill', value, ''); | |
1820 } | |
1821 | |
1822 /** Gets the value of "column-gap" */ | |
1823 String get columnGap => | |
1824 getPropertyValue('column-gap'); | |
1825 | |
1826 /** Sets the value of "column-gap" */ | |
1827 set columnGap(String value) { | |
1828 setProperty('column-gap', value, ''); | |
1829 } | |
1830 | |
1831 /** Gets the value of "column-rule" */ | |
1832 String get columnRule => | |
1833 getPropertyValue('column-rule'); | |
1834 | |
1835 /** Sets the value of "column-rule" */ | |
1836 set columnRule(String value) { | |
1837 setProperty('column-rule', value, ''); | |
1838 } | |
1839 | |
1840 /** Gets the value of "column-rule-color" */ | |
1841 String get columnRuleColor => | |
1842 getPropertyValue('column-rule-color'); | |
1843 | |
1844 /** Sets the value of "column-rule-color" */ | |
1845 set columnRuleColor(String value) { | |
1846 setProperty('column-rule-color', value, ''); | |
1847 } | |
1848 | |
1849 /** Gets the value of "column-rule-style" */ | |
1850 String get columnRuleStyle => | |
1851 getPropertyValue('column-rule-style'); | |
1852 | |
1853 /** Sets the value of "column-rule-style" */ | |
1854 set columnRuleStyle(String value) { | |
1855 setProperty('column-rule-style', value, ''); | |
1856 } | |
1857 | |
1858 /** Gets the value of "column-rule-width" */ | |
1859 String get columnRuleWidth => | |
1860 getPropertyValue('column-rule-width'); | |
1861 | |
1862 /** Sets the value of "column-rule-width" */ | |
1863 set columnRuleWidth(String value) { | |
1864 setProperty('column-rule-width', value, ''); | |
1865 } | |
1866 | |
1867 /** Gets the value of "column-span" */ | |
1868 String get columnSpan => | |
1869 getPropertyValue('column-span'); | |
1870 | |
1871 /** Sets the value of "column-span" */ | |
1872 set columnSpan(String value) { | |
1873 setProperty('column-span', value, ''); | |
1874 } | |
1875 | |
1876 /** Gets the value of "column-width" */ | |
1877 String get columnWidth => | |
1878 getPropertyValue('column-width'); | |
1879 | |
1880 /** Sets the value of "column-width" */ | |
1881 set columnWidth(String value) { | |
1882 setProperty('column-width', value, ''); | |
1883 } | |
1884 | |
1885 /** Gets the value of "columns" */ | |
1886 String get columns => | |
1887 getPropertyValue('columns'); | |
1888 | |
1889 /** Sets the value of "columns" */ | |
1890 set columns(String value) { | |
1891 setProperty('columns', value, ''); | |
1892 } | |
1893 | |
1894 /** Gets the value of "content" */ | |
1895 String get content => | |
1896 getPropertyValue('content'); | |
1897 | |
1898 /** Sets the value of "content" */ | |
1899 set content(String value) { | |
1900 setProperty('content', value, ''); | |
1901 } | |
1902 | |
1903 /** Gets the value of "counter-increment" */ | |
1904 String get counterIncrement => | |
1905 getPropertyValue('counter-increment'); | |
1906 | |
1907 /** Sets the value of "counter-increment" */ | |
1908 set counterIncrement(String value) { | |
1909 setProperty('counter-increment', value, ''); | |
1910 } | |
1911 | |
1912 /** Gets the value of "counter-reset" */ | |
1913 String get counterReset => | |
1914 getPropertyValue('counter-reset'); | |
1915 | |
1916 /** Sets the value of "counter-reset" */ | |
1917 set counterReset(String value) { | |
1918 setProperty('counter-reset', value, ''); | |
1919 } | |
1920 | |
1921 /** Gets the value of "cursor" */ | |
1922 String get cursor => | |
1923 getPropertyValue('cursor'); | |
1924 | |
1925 /** Sets the value of "cursor" */ | |
1926 set cursor(String value) { | |
1927 setProperty('cursor', value, ''); | |
1928 } | |
1929 | |
1930 /** Gets the value of "direction" */ | |
1931 String get direction => | |
1932 getPropertyValue('direction'); | |
1933 | |
1934 /** Sets the value of "direction" */ | |
1935 set direction(String value) { | |
1936 setProperty('direction', value, ''); | |
1937 } | |
1938 | |
1939 /** Gets the value of "display" */ | |
1940 String get display => | |
1941 getPropertyValue('display'); | |
1942 | |
1943 /** Sets the value of "display" */ | |
1944 set display(String value) { | |
1945 setProperty('display', value, ''); | |
1946 } | |
1947 | |
1948 /** Gets the value of "empty-cells" */ | |
1949 String get emptyCells => | |
1950 getPropertyValue('empty-cells'); | |
1951 | |
1952 /** Sets the value of "empty-cells" */ | |
1953 set emptyCells(String value) { | |
1954 setProperty('empty-cells', value, ''); | |
1955 } | |
1956 | |
1957 /** Gets the value of "filter" */ | |
1958 String get filter => | |
1959 getPropertyValue('filter'); | |
1960 | |
1961 /** Sets the value of "filter" */ | |
1962 set filter(String value) { | |
1963 setProperty('filter', value, ''); | |
1964 } | |
1965 | |
1966 /** Gets the value of "flex" */ | |
1967 String get flex => | |
1968 getPropertyValue('flex'); | |
1969 | |
1970 /** Sets the value of "flex" */ | |
1971 set flex(String value) { | |
1972 setProperty('flex', value, ''); | |
1973 } | |
1974 | |
1975 /** Gets the value of "flex-basis" */ | |
1976 String get flexBasis => | |
1977 getPropertyValue('flex-basis'); | |
1978 | |
1979 /** Sets the value of "flex-basis" */ | |
1980 set flexBasis(String value) { | |
1981 setProperty('flex-basis', value, ''); | |
1982 } | |
1983 | |
1984 /** Gets the value of "flex-direction" */ | |
1985 String get flexDirection => | |
1986 getPropertyValue('flex-direction'); | |
1987 | |
1988 /** Sets the value of "flex-direction" */ | |
1989 set flexDirection(String value) { | |
1990 setProperty('flex-direction', value, ''); | |
1991 } | |
1992 | |
1993 /** Gets the value of "flex-flow" */ | |
1994 String get flexFlow => | |
1995 getPropertyValue('flex-flow'); | |
1996 | |
1997 /** Sets the value of "flex-flow" */ | |
1998 set flexFlow(String value) { | |
1999 setProperty('flex-flow', value, ''); | |
2000 } | |
2001 | |
2002 /** Gets the value of "flex-grow" */ | |
2003 String get flexGrow => | |
2004 getPropertyValue('flex-grow'); | |
2005 | |
2006 /** Sets the value of "flex-grow" */ | |
2007 set flexGrow(String value) { | |
2008 setProperty('flex-grow', value, ''); | |
2009 } | |
2010 | |
2011 /** Gets the value of "flex-shrink" */ | |
2012 String get flexShrink => | |
2013 getPropertyValue('flex-shrink'); | |
2014 | |
2015 /** Sets the value of "flex-shrink" */ | |
2016 set flexShrink(String value) { | |
2017 setProperty('flex-shrink', value, ''); | |
2018 } | |
2019 | |
2020 /** Gets the value of "flex-wrap" */ | |
2021 String get flexWrap => | |
2022 getPropertyValue('flex-wrap'); | |
2023 | |
2024 /** Sets the value of "flex-wrap" */ | |
2025 set flexWrap(String value) { | |
2026 setProperty('flex-wrap', value, ''); | |
2027 } | |
2028 | |
2029 /** Gets the value of "float" */ | |
2030 String get float => | |
2031 getPropertyValue('float'); | |
2032 | |
2033 /** Sets the value of "float" */ | |
2034 set float(String value) { | |
2035 setProperty('float', value, ''); | |
2036 } | |
2037 | |
2038 /** Gets the value of "font" */ | |
2039 String get font => | |
2040 getPropertyValue('font'); | |
2041 | |
2042 /** Sets the value of "font" */ | |
2043 set font(String value) { | |
2044 setProperty('font', value, ''); | |
2045 } | |
2046 | |
2047 /** Gets the value of "font-family" */ | |
2048 String get fontFamily => | |
2049 getPropertyValue('font-family'); | |
2050 | |
2051 /** Sets the value of "font-family" */ | |
2052 set fontFamily(String value) { | |
2053 setProperty('font-family', value, ''); | |
2054 } | |
2055 | |
2056 /** Gets the value of "font-feature-settings" */ | |
2057 String get fontFeatureSettings => | |
2058 getPropertyValue('font-feature-settings'); | |
2059 | |
2060 /** Sets the value of "font-feature-settings" */ | |
2061 set fontFeatureSettings(String value) { | |
2062 setProperty('font-feature-settings', value, ''); | |
2063 } | |
2064 | |
2065 /** Gets the value of "font-kerning" */ | |
2066 String get fontKerning => | |
2067 getPropertyValue('font-kerning'); | |
2068 | |
2069 /** Sets the value of "font-kerning" */ | |
2070 set fontKerning(String value) { | |
2071 setProperty('font-kerning', value, ''); | |
2072 } | |
2073 | |
2074 /** Gets the value of "font-size" */ | |
2075 String get fontSize => | |
2076 getPropertyValue('font-size'); | |
2077 | |
2078 /** Sets the value of "font-size" */ | |
2079 set fontSize(String value) { | |
2080 setProperty('font-size', value, ''); | |
2081 } | |
2082 | |
2083 /** Gets the value of "font-size-delta" */ | |
2084 String get fontSizeDelta => | |
2085 getPropertyValue('font-size-delta'); | |
2086 | |
2087 /** Sets the value of "font-size-delta" */ | |
2088 set fontSizeDelta(String value) { | |
2089 setProperty('font-size-delta', value, ''); | |
2090 } | |
2091 | |
2092 /** Gets the value of "font-smoothing" */ | |
2093 String get fontSmoothing => | |
2094 getPropertyValue('font-smoothing'); | |
2095 | |
2096 /** Sets the value of "font-smoothing" */ | |
2097 set fontSmoothing(String value) { | |
2098 setProperty('font-smoothing', value, ''); | |
2099 } | |
2100 | |
2101 /** Gets the value of "font-stretch" */ | |
2102 String get fontStretch => | |
2103 getPropertyValue('font-stretch'); | |
2104 | |
2105 /** Sets the value of "font-stretch" */ | |
2106 set fontStretch(String value) { | |
2107 setProperty('font-stretch', value, ''); | |
2108 } | |
2109 | |
2110 /** Gets the value of "font-style" */ | |
2111 String get fontStyle => | |
2112 getPropertyValue('font-style'); | |
2113 | |
2114 /** Sets the value of "font-style" */ | |
2115 set fontStyle(String value) { | |
2116 setProperty('font-style', value, ''); | |
2117 } | |
2118 | |
2119 /** Gets the value of "font-variant" */ | |
2120 String get fontVariant => | |
2121 getPropertyValue('font-variant'); | |
2122 | |
2123 /** Sets the value of "font-variant" */ | |
2124 set fontVariant(String value) { | |
2125 setProperty('font-variant', value, ''); | |
2126 } | |
2127 | |
2128 /** Gets the value of "font-variant-ligatures" */ | |
2129 String get fontVariantLigatures => | |
2130 getPropertyValue('font-variant-ligatures'); | |
2131 | |
2132 /** Sets the value of "font-variant-ligatures" */ | |
2133 set fontVariantLigatures(String value) { | |
2134 setProperty('font-variant-ligatures', value, ''); | |
2135 } | |
2136 | |
2137 /** Gets the value of "font-weight" */ | |
2138 String get fontWeight => | |
2139 getPropertyValue('font-weight'); | |
2140 | |
2141 /** Sets the value of "font-weight" */ | |
2142 set fontWeight(String value) { | |
2143 setProperty('font-weight', value, ''); | |
2144 } | |
2145 | |
2146 /** Gets the value of "grid" */ | |
2147 String get grid => | |
2148 getPropertyValue('grid'); | |
2149 | |
2150 /** Sets the value of "grid" */ | |
2151 set grid(String value) { | |
2152 setProperty('grid', value, ''); | |
2153 } | |
2154 | |
2155 /** Gets the value of "grid-area" */ | |
2156 String get gridArea => | |
2157 getPropertyValue('grid-area'); | |
2158 | |
2159 /** Sets the value of "grid-area" */ | |
2160 set gridArea(String value) { | |
2161 setProperty('grid-area', value, ''); | |
2162 } | |
2163 | |
2164 /** Gets the value of "grid-auto-columns" */ | |
2165 String get gridAutoColumns => | |
2166 getPropertyValue('grid-auto-columns'); | |
2167 | |
2168 /** Sets the value of "grid-auto-columns" */ | |
2169 set gridAutoColumns(String value) { | |
2170 setProperty('grid-auto-columns', value, ''); | |
2171 } | |
2172 | |
2173 /** Gets the value of "grid-auto-flow" */ | |
2174 String get gridAutoFlow => | |
2175 getPropertyValue('grid-auto-flow'); | |
2176 | |
2177 /** Sets the value of "grid-auto-flow" */ | |
2178 set gridAutoFlow(String value) { | |
2179 setProperty('grid-auto-flow', value, ''); | |
2180 } | |
2181 | |
2182 /** Gets the value of "grid-auto-rows" */ | |
2183 String get gridAutoRows => | |
2184 getPropertyValue('grid-auto-rows'); | |
2185 | |
2186 /** Sets the value of "grid-auto-rows" */ | |
2187 set gridAutoRows(String value) { | |
2188 setProperty('grid-auto-rows', value, ''); | |
2189 } | |
2190 | |
2191 /** Gets the value of "grid-column" */ | |
2192 String get gridColumn => | |
2193 getPropertyValue('grid-column'); | |
2194 | |
2195 /** Sets the value of "grid-column" */ | |
2196 set gridColumn(String value) { | |
2197 setProperty('grid-column', value, ''); | |
2198 } | |
2199 | |
2200 /** Gets the value of "grid-column-end" */ | |
2201 String get gridColumnEnd => | |
2202 getPropertyValue('grid-column-end'); | |
2203 | |
2204 /** Sets the value of "grid-column-end" */ | |
2205 set gridColumnEnd(String value) { | |
2206 setProperty('grid-column-end', value, ''); | |
2207 } | |
2208 | |
2209 /** Gets the value of "grid-column-start" */ | |
2210 String get gridColumnStart => | |
2211 getPropertyValue('grid-column-start'); | |
2212 | |
2213 /** Sets the value of "grid-column-start" */ | |
2214 set gridColumnStart(String value) { | |
2215 setProperty('grid-column-start', value, ''); | |
2216 } | |
2217 | |
2218 /** Gets the value of "grid-row" */ | |
2219 String get gridRow => | |
2220 getPropertyValue('grid-row'); | |
2221 | |
2222 /** Sets the value of "grid-row" */ | |
2223 set gridRow(String value) { | |
2224 setProperty('grid-row', value, ''); | |
2225 } | |
2226 | |
2227 /** Gets the value of "grid-row-end" */ | |
2228 String get gridRowEnd => | |
2229 getPropertyValue('grid-row-end'); | |
2230 | |
2231 /** Sets the value of "grid-row-end" */ | |
2232 set gridRowEnd(String value) { | |
2233 setProperty('grid-row-end', value, ''); | |
2234 } | |
2235 | |
2236 /** Gets the value of "grid-row-start" */ | |
2237 String get gridRowStart => | |
2238 getPropertyValue('grid-row-start'); | |
2239 | |
2240 /** Sets the value of "grid-row-start" */ | |
2241 set gridRowStart(String value) { | |
2242 setProperty('grid-row-start', value, ''); | |
2243 } | |
2244 | |
2245 /** Gets the value of "grid-template" */ | |
2246 String get gridTemplate => | |
2247 getPropertyValue('grid-template'); | |
2248 | |
2249 /** Sets the value of "grid-template" */ | |
2250 set gridTemplate(String value) { | |
2251 setProperty('grid-template', value, ''); | |
2252 } | |
2253 | |
2254 /** Gets the value of "grid-template-areas" */ | |
2255 String get gridTemplateAreas => | |
2256 getPropertyValue('grid-template-areas'); | |
2257 | |
2258 /** Sets the value of "grid-template-areas" */ | |
2259 set gridTemplateAreas(String value) { | |
2260 setProperty('grid-template-areas', value, ''); | |
2261 } | |
2262 | |
2263 /** Gets the value of "grid-template-columns" */ | |
2264 String get gridTemplateColumns => | |
2265 getPropertyValue('grid-template-columns'); | |
2266 | |
2267 /** Sets the value of "grid-template-columns" */ | |
2268 set gridTemplateColumns(String value) { | |
2269 setProperty('grid-template-columns', value, ''); | |
2270 } | |
2271 | |
2272 /** Gets the value of "grid-template-rows" */ | |
2273 String get gridTemplateRows => | |
2274 getPropertyValue('grid-template-rows'); | |
2275 | |
2276 /** Sets the value of "grid-template-rows" */ | |
2277 set gridTemplateRows(String value) { | |
2278 setProperty('grid-template-rows', value, ''); | |
2279 } | |
2280 | |
2281 /** Gets the value of "height" */ | |
2282 String get height => | |
2283 getPropertyValue('height'); | |
2284 | |
2285 /** Sets the value of "height" */ | |
2286 set height(String value) { | |
2287 setProperty('height', value, ''); | |
2288 } | |
2289 | |
2290 /** Gets the value of "highlight" */ | |
2291 String get highlight => | |
2292 getPropertyValue('highlight'); | |
2293 | |
2294 /** Sets the value of "highlight" */ | |
2295 set highlight(String value) { | |
2296 setProperty('highlight', value, ''); | |
2297 } | |
2298 | |
2299 /** Gets the value of "hyphenate-character" */ | |
2300 String get hyphenateCharacter => | |
2301 getPropertyValue('hyphenate-character'); | |
2302 | |
2303 /** Sets the value of "hyphenate-character" */ | |
2304 set hyphenateCharacter(String value) { | |
2305 setProperty('hyphenate-character', value, ''); | |
2306 } | |
2307 | |
2308 /** Gets the value of "image-rendering" */ | |
2309 String get imageRendering => | |
2310 getPropertyValue('image-rendering'); | |
2311 | |
2312 /** Sets the value of "image-rendering" */ | |
2313 set imageRendering(String value) { | |
2314 setProperty('image-rendering', value, ''); | |
2315 } | |
2316 | |
2317 /** Gets the value of "isolation" */ | |
2318 String get isolation => | |
2319 getPropertyValue('isolation'); | |
2320 | |
2321 /** Sets the value of "isolation" */ | |
2322 set isolation(String value) { | |
2323 setProperty('isolation', value, ''); | |
2324 } | |
2325 | |
2326 /** Gets the value of "justify-content" */ | |
2327 String get justifyContent => | |
2328 getPropertyValue('justify-content'); | |
2329 | |
2330 /** Sets the value of "justify-content" */ | |
2331 set justifyContent(String value) { | |
2332 setProperty('justify-content', value, ''); | |
2333 } | |
2334 | |
2335 /** Gets the value of "justify-self" */ | |
2336 String get justifySelf => | |
2337 getPropertyValue('justify-self'); | |
2338 | |
2339 /** Sets the value of "justify-self" */ | |
2340 set justifySelf(String value) { | |
2341 setProperty('justify-self', value, ''); | |
2342 } | |
2343 | |
2344 /** Gets the value of "left" */ | |
2345 String get left => | |
2346 getPropertyValue('left'); | |
2347 | |
2348 /** Sets the value of "left" */ | |
2349 set left(String value) { | |
2350 setProperty('left', value, ''); | |
2351 } | |
2352 | |
2353 /** Gets the value of "letter-spacing" */ | |
2354 String get letterSpacing => | |
2355 getPropertyValue('letter-spacing'); | |
2356 | |
2357 /** Sets the value of "letter-spacing" */ | |
2358 set letterSpacing(String value) { | |
2359 setProperty('letter-spacing', value, ''); | |
2360 } | |
2361 | |
2362 /** Gets the value of "line-box-contain" */ | |
2363 String get lineBoxContain => | |
2364 getPropertyValue('line-box-contain'); | |
2365 | |
2366 /** Sets the value of "line-box-contain" */ | |
2367 set lineBoxContain(String value) { | |
2368 setProperty('line-box-contain', value, ''); | |
2369 } | |
2370 | |
2371 /** Gets the value of "line-break" */ | |
2372 String get lineBreak => | |
2373 getPropertyValue('line-break'); | |
2374 | |
2375 /** Sets the value of "line-break" */ | |
2376 set lineBreak(String value) { | |
2377 setProperty('line-break', value, ''); | |
2378 } | |
2379 | |
2380 /** Gets the value of "line-clamp" */ | |
2381 String get lineClamp => | |
2382 getPropertyValue('line-clamp'); | |
2383 | |
2384 /** Sets the value of "line-clamp" */ | |
2385 set lineClamp(String value) { | |
2386 setProperty('line-clamp', value, ''); | |
2387 } | |
2388 | |
2389 /** Gets the value of "line-height" */ | |
2390 String get lineHeight => | |
2391 getPropertyValue('line-height'); | |
2392 | |
2393 /** Sets the value of "line-height" */ | |
2394 set lineHeight(String value) { | |
2395 setProperty('line-height', value, ''); | |
2396 } | |
2397 | |
2398 /** Gets the value of "list-style" */ | |
2399 String get listStyle => | |
2400 getPropertyValue('list-style'); | |
2401 | |
2402 /** Sets the value of "list-style" */ | |
2403 set listStyle(String value) { | |
2404 setProperty('list-style', value, ''); | |
2405 } | |
2406 | |
2407 /** Gets the value of "list-style-image" */ | |
2408 String get listStyleImage => | |
2409 getPropertyValue('list-style-image'); | |
2410 | |
2411 /** Sets the value of "list-style-image" */ | |
2412 set listStyleImage(String value) { | |
2413 setProperty('list-style-image', value, ''); | |
2414 } | |
2415 | |
2416 /** Gets the value of "list-style-position" */ | |
2417 String get listStylePosition => | |
2418 getPropertyValue('list-style-position'); | |
2419 | |
2420 /** Sets the value of "list-style-position" */ | |
2421 set listStylePosition(String value) { | |
2422 setProperty('list-style-position', value, ''); | |
2423 } | |
2424 | |
2425 /** Gets the value of "list-style-type" */ | |
2426 String get listStyleType => | |
2427 getPropertyValue('list-style-type'); | |
2428 | |
2429 /** Sets the value of "list-style-type" */ | |
2430 set listStyleType(String value) { | |
2431 setProperty('list-style-type', value, ''); | |
2432 } | |
2433 | |
2434 /** Gets the value of "locale" */ | |
2435 String get locale => | |
2436 getPropertyValue('locale'); | |
2437 | |
2438 /** Sets the value of "locale" */ | |
2439 set locale(String value) { | |
2440 setProperty('locale', value, ''); | |
2441 } | |
2442 | |
2443 /** Gets the value of "logical-height" */ | |
2444 String get logicalHeight => | |
2445 getPropertyValue('logical-height'); | |
2446 | |
2447 /** Sets the value of "logical-height" */ | |
2448 set logicalHeight(String value) { | |
2449 setProperty('logical-height', value, ''); | |
2450 } | |
2451 | |
2452 /** Gets the value of "logical-width" */ | |
2453 String get logicalWidth => | |
2454 getPropertyValue('logical-width'); | |
2455 | |
2456 /** Sets the value of "logical-width" */ | |
2457 set logicalWidth(String value) { | |
2458 setProperty('logical-width', value, ''); | |
2459 } | |
2460 | |
2461 /** Gets the value of "margin" */ | |
2462 String get margin => | |
2463 getPropertyValue('margin'); | |
2464 | |
2465 /** Sets the value of "margin" */ | |
2466 set margin(String value) { | |
2467 setProperty('margin', value, ''); | |
2468 } | |
2469 | |
2470 /** Gets the value of "margin-after" */ | |
2471 String get marginAfter => | |
2472 getPropertyValue('margin-after'); | |
2473 | |
2474 /** Sets the value of "margin-after" */ | |
2475 set marginAfter(String value) { | |
2476 setProperty('margin-after', value, ''); | |
2477 } | |
2478 | |
2479 /** Gets the value of "margin-after-collapse" */ | |
2480 String get marginAfterCollapse => | |
2481 getPropertyValue('margin-after-collapse'); | |
2482 | |
2483 /** Sets the value of "margin-after-collapse" */ | |
2484 set marginAfterCollapse(String value) { | |
2485 setProperty('margin-after-collapse', value, ''); | |
2486 } | |
2487 | |
2488 /** Gets the value of "margin-before" */ | |
2489 String get marginBefore => | |
2490 getPropertyValue('margin-before'); | |
2491 | |
2492 /** Sets the value of "margin-before" */ | |
2493 set marginBefore(String value) { | |
2494 setProperty('margin-before', value, ''); | |
2495 } | |
2496 | |
2497 /** Gets the value of "margin-before-collapse" */ | |
2498 String get marginBeforeCollapse => | |
2499 getPropertyValue('margin-before-collapse'); | |
2500 | |
2501 /** Sets the value of "margin-before-collapse" */ | |
2502 set marginBeforeCollapse(String value) { | |
2503 setProperty('margin-before-collapse', value, ''); | |
2504 } | |
2505 | |
2506 /** Gets the value of "margin-bottom" */ | |
2507 String get marginBottom => | |
2508 getPropertyValue('margin-bottom'); | |
2509 | |
2510 /** Sets the value of "margin-bottom" */ | |
2511 set marginBottom(String value) { | |
2512 setProperty('margin-bottom', value, ''); | |
2513 } | |
2514 | |
2515 /** Gets the value of "margin-bottom-collapse" */ | |
2516 String get marginBottomCollapse => | |
2517 getPropertyValue('margin-bottom-collapse'); | |
2518 | |
2519 /** Sets the value of "margin-bottom-collapse" */ | |
2520 set marginBottomCollapse(String value) { | |
2521 setProperty('margin-bottom-collapse', value, ''); | |
2522 } | |
2523 | |
2524 /** Gets the value of "margin-collapse" */ | |
2525 String get marginCollapse => | |
2526 getPropertyValue('margin-collapse'); | |
2527 | |
2528 /** Sets the value of "margin-collapse" */ | |
2529 set marginCollapse(String value) { | |
2530 setProperty('margin-collapse', value, ''); | |
2531 } | |
2532 | |
2533 /** Gets the value of "margin-end" */ | |
2534 String get marginEnd => | |
2535 getPropertyValue('margin-end'); | |
2536 | |
2537 /** Sets the value of "margin-end" */ | |
2538 set marginEnd(String value) { | |
2539 setProperty('margin-end', value, ''); | |
2540 } | |
2541 | |
2542 /** Gets the value of "margin-left" */ | |
2543 String get marginLeft => | |
2544 getPropertyValue('margin-left'); | |
2545 | |
2546 /** Sets the value of "margin-left" */ | |
2547 set marginLeft(String value) { | |
2548 setProperty('margin-left', value, ''); | |
2549 } | |
2550 | |
2551 /** Gets the value of "margin-right" */ | |
2552 String get marginRight => | |
2553 getPropertyValue('margin-right'); | |
2554 | |
2555 /** Sets the value of "margin-right" */ | |
2556 set marginRight(String value) { | |
2557 setProperty('margin-right', value, ''); | |
2558 } | |
2559 | |
2560 /** Gets the value of "margin-start" */ | |
2561 String get marginStart => | |
2562 getPropertyValue('margin-start'); | |
2563 | |
2564 /** Sets the value of "margin-start" */ | |
2565 set marginStart(String value) { | |
2566 setProperty('margin-start', value, ''); | |
2567 } | |
2568 | |
2569 /** Gets the value of "margin-top" */ | |
2570 String get marginTop => | |
2571 getPropertyValue('margin-top'); | |
2572 | |
2573 /** Sets the value of "margin-top" */ | |
2574 set marginTop(String value) { | |
2575 setProperty('margin-top', value, ''); | |
2576 } | |
2577 | |
2578 /** Gets the value of "margin-top-collapse" */ | |
2579 String get marginTopCollapse => | |
2580 getPropertyValue('margin-top-collapse'); | |
2581 | |
2582 /** Sets the value of "margin-top-collapse" */ | |
2583 set marginTopCollapse(String value) { | |
2584 setProperty('margin-top-collapse', value, ''); | |
2585 } | |
2586 | |
2587 /** Gets the value of "mask" */ | |
2588 String get mask => | |
2589 getPropertyValue('mask'); | |
2590 | |
2591 /** Sets the value of "mask" */ | |
2592 set mask(String value) { | |
2593 setProperty('mask', value, ''); | |
2594 } | |
2595 | |
2596 /** Gets the value of "mask-box-image" */ | |
2597 String get maskBoxImage => | |
2598 getPropertyValue('mask-box-image'); | |
2599 | |
2600 /** Sets the value of "mask-box-image" */ | |
2601 set maskBoxImage(String value) { | |
2602 setProperty('mask-box-image', value, ''); | |
2603 } | |
2604 | |
2605 /** Gets the value of "mask-box-image-outset" */ | |
2606 String get maskBoxImageOutset => | |
2607 getPropertyValue('mask-box-image-outset'); | |
2608 | |
2609 /** Sets the value of "mask-box-image-outset" */ | |
2610 set maskBoxImageOutset(String value) { | |
2611 setProperty('mask-box-image-outset', value, ''); | |
2612 } | |
2613 | |
2614 /** Gets the value of "mask-box-image-repeat" */ | |
2615 String get maskBoxImageRepeat => | |
2616 getPropertyValue('mask-box-image-repeat'); | |
2617 | |
2618 /** Sets the value of "mask-box-image-repeat" */ | |
2619 set maskBoxImageRepeat(String value) { | |
2620 setProperty('mask-box-image-repeat', value, ''); | |
2621 } | |
2622 | |
2623 /** Gets the value of "mask-box-image-slice" */ | |
2624 String get maskBoxImageSlice => | |
2625 getPropertyValue('mask-box-image-slice'); | |
2626 | |
2627 /** Sets the value of "mask-box-image-slice" */ | |
2628 set maskBoxImageSlice(String value) { | |
2629 setProperty('mask-box-image-slice', value, ''); | |
2630 } | |
2631 | |
2632 /** Gets the value of "mask-box-image-source" */ | |
2633 String get maskBoxImageSource => | |
2634 getPropertyValue('mask-box-image-source'); | |
2635 | |
2636 /** Sets the value of "mask-box-image-source" */ | |
2637 set maskBoxImageSource(String value) { | |
2638 setProperty('mask-box-image-source', value, ''); | |
2639 } | |
2640 | |
2641 /** Gets the value of "mask-box-image-width" */ | |
2642 String get maskBoxImageWidth => | |
2643 getPropertyValue('mask-box-image-width'); | |
2644 | |
2645 /** Sets the value of "mask-box-image-width" */ | |
2646 set maskBoxImageWidth(String value) { | |
2647 setProperty('mask-box-image-width', value, ''); | |
2648 } | |
2649 | |
2650 /** Gets the value of "mask-clip" */ | |
2651 String get maskClip => | |
2652 getPropertyValue('mask-clip'); | |
2653 | |
2654 /** Sets the value of "mask-clip" */ | |
2655 set maskClip(String value) { | |
2656 setProperty('mask-clip', value, ''); | |
2657 } | |
2658 | |
2659 /** Gets the value of "mask-composite" */ | |
2660 String get maskComposite => | |
2661 getPropertyValue('mask-composite'); | |
2662 | |
2663 /** Sets the value of "mask-composite" */ | |
2664 set maskComposite(String value) { | |
2665 setProperty('mask-composite', value, ''); | |
2666 } | |
2667 | |
2668 /** Gets the value of "mask-image" */ | |
2669 String get maskImage => | |
2670 getPropertyValue('mask-image'); | |
2671 | |
2672 /** Sets the value of "mask-image" */ | |
2673 set maskImage(String value) { | |
2674 setProperty('mask-image', value, ''); | |
2675 } | |
2676 | |
2677 /** Gets the value of "mask-origin" */ | |
2678 String get maskOrigin => | |
2679 getPropertyValue('mask-origin'); | |
2680 | |
2681 /** Sets the value of "mask-origin" */ | |
2682 set maskOrigin(String value) { | |
2683 setProperty('mask-origin', value, ''); | |
2684 } | |
2685 | |
2686 /** Gets the value of "mask-position" */ | |
2687 String get maskPosition => | |
2688 getPropertyValue('mask-position'); | |
2689 | |
2690 /** Sets the value of "mask-position" */ | |
2691 set maskPosition(String value) { | |
2692 setProperty('mask-position', value, ''); | |
2693 } | |
2694 | |
2695 /** Gets the value of "mask-position-x" */ | |
2696 String get maskPositionX => | |
2697 getPropertyValue('mask-position-x'); | |
2698 | |
2699 /** Sets the value of "mask-position-x" */ | |
2700 set maskPositionX(String value) { | |
2701 setProperty('mask-position-x', value, ''); | |
2702 } | |
2703 | |
2704 /** Gets the value of "mask-position-y" */ | |
2705 String get maskPositionY => | |
2706 getPropertyValue('mask-position-y'); | |
2707 | |
2708 /** Sets the value of "mask-position-y" */ | |
2709 set maskPositionY(String value) { | |
2710 setProperty('mask-position-y', value, ''); | |
2711 } | |
2712 | |
2713 /** Gets the value of "mask-repeat" */ | |
2714 String get maskRepeat => | |
2715 getPropertyValue('mask-repeat'); | |
2716 | |
2717 /** Sets the value of "mask-repeat" */ | |
2718 set maskRepeat(String value) { | |
2719 setProperty('mask-repeat', value, ''); | |
2720 } | |
2721 | |
2722 /** Gets the value of "mask-repeat-x" */ | |
2723 String get maskRepeatX => | |
2724 getPropertyValue('mask-repeat-x'); | |
2725 | |
2726 /** Sets the value of "mask-repeat-x" */ | |
2727 set maskRepeatX(String value) { | |
2728 setProperty('mask-repeat-x', value, ''); | |
2729 } | |
2730 | |
2731 /** Gets the value of "mask-repeat-y" */ | |
2732 String get maskRepeatY => | |
2733 getPropertyValue('mask-repeat-y'); | |
2734 | |
2735 /** Sets the value of "mask-repeat-y" */ | |
2736 set maskRepeatY(String value) { | |
2737 setProperty('mask-repeat-y', value, ''); | |
2738 } | |
2739 | |
2740 /** Gets the value of "mask-size" */ | |
2741 String get maskSize => | |
2742 getPropertyValue('mask-size'); | |
2743 | |
2744 /** Sets the value of "mask-size" */ | |
2745 set maskSize(String value) { | |
2746 setProperty('mask-size', value, ''); | |
2747 } | |
2748 | |
2749 /** Gets the value of "mask-source-type" */ | |
2750 String get maskSourceType => | |
2751 getPropertyValue('mask-source-type'); | |
2752 | |
2753 /** Sets the value of "mask-source-type" */ | |
2754 set maskSourceType(String value) { | |
2755 setProperty('mask-source-type', value, ''); | |
2756 } | |
2757 | |
2758 /** Gets the value of "max-height" */ | |
2759 String get maxHeight => | |
2760 getPropertyValue('max-height'); | |
2761 | |
2762 /** Sets the value of "max-height" */ | |
2763 set maxHeight(String value) { | |
2764 setProperty('max-height', value, ''); | |
2765 } | |
2766 | |
2767 /** Gets the value of "max-logical-height" */ | |
2768 String get maxLogicalHeight => | |
2769 getPropertyValue('max-logical-height'); | |
2770 | |
2771 /** Sets the value of "max-logical-height" */ | |
2772 set maxLogicalHeight(String value) { | |
2773 setProperty('max-logical-height', value, ''); | |
2774 } | |
2775 | |
2776 /** Gets the value of "max-logical-width" */ | |
2777 String get maxLogicalWidth => | |
2778 getPropertyValue('max-logical-width'); | |
2779 | |
2780 /** Sets the value of "max-logical-width" */ | |
2781 set maxLogicalWidth(String value) { | |
2782 setProperty('max-logical-width', value, ''); | |
2783 } | |
2784 | |
2785 /** Gets the value of "max-width" */ | |
2786 String get maxWidth => | |
2787 getPropertyValue('max-width'); | |
2788 | |
2789 /** Sets the value of "max-width" */ | |
2790 set maxWidth(String value) { | |
2791 setProperty('max-width', value, ''); | |
2792 } | |
2793 | |
2794 /** Gets the value of "max-zoom" */ | |
2795 String get maxZoom => | |
2796 getPropertyValue('max-zoom'); | |
2797 | |
2798 /** Sets the value of "max-zoom" */ | |
2799 set maxZoom(String value) { | |
2800 setProperty('max-zoom', value, ''); | |
2801 } | |
2802 | |
2803 /** Gets the value of "min-height" */ | |
2804 String get minHeight => | |
2805 getPropertyValue('min-height'); | |
2806 | |
2807 /** Sets the value of "min-height" */ | |
2808 set minHeight(String value) { | |
2809 setProperty('min-height', value, ''); | |
2810 } | |
2811 | |
2812 /** Gets the value of "min-logical-height" */ | |
2813 String get minLogicalHeight => | |
2814 getPropertyValue('min-logical-height'); | |
2815 | |
2816 /** Sets the value of "min-logical-height" */ | |
2817 set minLogicalHeight(String value) { | |
2818 setProperty('min-logical-height', value, ''); | |
2819 } | |
2820 | |
2821 /** Gets the value of "min-logical-width" */ | |
2822 String get minLogicalWidth => | |
2823 getPropertyValue('min-logical-width'); | |
2824 | |
2825 /** Sets the value of "min-logical-width" */ | |
2826 set minLogicalWidth(String value) { | |
2827 setProperty('min-logical-width', value, ''); | |
2828 } | |
2829 | |
2830 /** Gets the value of "min-width" */ | |
2831 String get minWidth => | |
2832 getPropertyValue('min-width'); | |
2833 | |
2834 /** Sets the value of "min-width" */ | |
2835 set minWidth(String value) { | |
2836 setProperty('min-width', value, ''); | |
2837 } | |
2838 | |
2839 /** Gets the value of "min-zoom" */ | |
2840 String get minZoom => | |
2841 getPropertyValue('min-zoom'); | |
2842 | |
2843 /** Sets the value of "min-zoom" */ | |
2844 set minZoom(String value) { | |
2845 setProperty('min-zoom', value, ''); | |
2846 } | |
2847 | |
2848 /** Gets the value of "mix-blend-mode" */ | |
2849 String get mixBlendMode => | |
2850 getPropertyValue('mix-blend-mode'); | |
2851 | |
2852 /** Sets the value of "mix-blend-mode" */ | |
2853 set mixBlendMode(String value) { | |
2854 setProperty('mix-blend-mode', value, ''); | |
2855 } | |
2856 | |
2857 /** Gets the value of "object-fit" */ | |
2858 String get objectFit => | |
2859 getPropertyValue('object-fit'); | |
2860 | |
2861 /** Sets the value of "object-fit" */ | |
2862 set objectFit(String value) { | |
2863 setProperty('object-fit', value, ''); | |
2864 } | |
2865 | |
2866 /** Gets the value of "object-position" */ | |
2867 String get objectPosition => | |
2868 getPropertyValue('object-position'); | |
2869 | |
2870 /** Sets the value of "object-position" */ | |
2871 set objectPosition(String value) { | |
2872 setProperty('object-position', value, ''); | |
2873 } | |
2874 | |
2875 /** Gets the value of "opacity" */ | |
2876 String get opacity => | |
2877 getPropertyValue('opacity'); | |
2878 | |
2879 /** Sets the value of "opacity" */ | |
2880 set opacity(String value) { | |
2881 setProperty('opacity', value, ''); | |
2882 } | |
2883 | |
2884 /** Gets the value of "order" */ | |
2885 String get order => | |
2886 getPropertyValue('order'); | |
2887 | |
2888 /** Sets the value of "order" */ | |
2889 set order(String value) { | |
2890 setProperty('order', value, ''); | |
2891 } | |
2892 | |
2893 /** Gets the value of "orientation" */ | |
2894 String get orientation => | |
2895 getPropertyValue('orientation'); | |
2896 | |
2897 /** Sets the value of "orientation" */ | |
2898 set orientation(String value) { | |
2899 setProperty('orientation', value, ''); | |
2900 } | |
2901 | |
2902 /** Gets the value of "orphans" */ | |
2903 String get orphans => | |
2904 getPropertyValue('orphans'); | |
2905 | |
2906 /** Sets the value of "orphans" */ | |
2907 set orphans(String value) { | |
2908 setProperty('orphans', value, ''); | |
2909 } | |
2910 | |
2911 /** Gets the value of "outline" */ | |
2912 String get outline => | |
2913 getPropertyValue('outline'); | |
2914 | |
2915 /** Sets the value of "outline" */ | |
2916 set outline(String value) { | |
2917 setProperty('outline', value, ''); | |
2918 } | |
2919 | |
2920 /** Gets the value of "outline-color" */ | |
2921 String get outlineColor => | |
2922 getPropertyValue('outline-color'); | |
2923 | |
2924 /** Sets the value of "outline-color" */ | |
2925 set outlineColor(String value) { | |
2926 setProperty('outline-color', value, ''); | |
2927 } | |
2928 | |
2929 /** Gets the value of "outline-offset" */ | |
2930 String get outlineOffset => | |
2931 getPropertyValue('outline-offset'); | |
2932 | |
2933 /** Sets the value of "outline-offset" */ | |
2934 set outlineOffset(String value) { | |
2935 setProperty('outline-offset', value, ''); | |
2936 } | |
2937 | |
2938 /** Gets the value of "outline-style" */ | |
2939 String get outlineStyle => | |
2940 getPropertyValue('outline-style'); | |
2941 | |
2942 /** Sets the value of "outline-style" */ | |
2943 set outlineStyle(String value) { | |
2944 setProperty('outline-style', value, ''); | |
2945 } | |
2946 | |
2947 /** Gets the value of "outline-width" */ | |
2948 String get outlineWidth => | |
2949 getPropertyValue('outline-width'); | |
2950 | |
2951 /** Sets the value of "outline-width" */ | |
2952 set outlineWidth(String value) { | |
2953 setProperty('outline-width', value, ''); | |
2954 } | |
2955 | |
2956 /** Gets the value of "overflow" */ | |
2957 String get overflow => | |
2958 getPropertyValue('overflow'); | |
2959 | |
2960 /** Sets the value of "overflow" */ | |
2961 set overflow(String value) { | |
2962 setProperty('overflow', value, ''); | |
2963 } | |
2964 | |
2965 /** Gets the value of "overflow-wrap" */ | |
2966 String get overflowWrap => | |
2967 getPropertyValue('overflow-wrap'); | |
2968 | |
2969 /** Sets the value of "overflow-wrap" */ | |
2970 set overflowWrap(String value) { | |
2971 setProperty('overflow-wrap', value, ''); | |
2972 } | |
2973 | |
2974 /** Gets the value of "overflow-x" */ | |
2975 String get overflowX => | |
2976 getPropertyValue('overflow-x'); | |
2977 | |
2978 /** Sets the value of "overflow-x" */ | |
2979 set overflowX(String value) { | |
2980 setProperty('overflow-x', value, ''); | |
2981 } | |
2982 | |
2983 /** Gets the value of "overflow-y" */ | |
2984 String get overflowY => | |
2985 getPropertyValue('overflow-y'); | |
2986 | |
2987 /** Sets the value of "overflow-y" */ | |
2988 set overflowY(String value) { | |
2989 setProperty('overflow-y', value, ''); | |
2990 } | |
2991 | |
2992 /** Gets the value of "padding" */ | |
2993 String get padding => | |
2994 getPropertyValue('padding'); | |
2995 | |
2996 /** Sets the value of "padding" */ | |
2997 set padding(String value) { | |
2998 setProperty('padding', value, ''); | |
2999 } | |
3000 | |
3001 /** Gets the value of "padding-after" */ | |
3002 String get paddingAfter => | |
3003 getPropertyValue('padding-after'); | |
3004 | |
3005 /** Sets the value of "padding-after" */ | |
3006 set paddingAfter(String value) { | |
3007 setProperty('padding-after', value, ''); | |
3008 } | |
3009 | |
3010 /** Gets the value of "padding-before" */ | |
3011 String get paddingBefore => | |
3012 getPropertyValue('padding-before'); | |
3013 | |
3014 /** Sets the value of "padding-before" */ | |
3015 set paddingBefore(String value) { | |
3016 setProperty('padding-before', value, ''); | |
3017 } | |
3018 | |
3019 /** Gets the value of "padding-bottom" */ | |
3020 String get paddingBottom => | |
3021 getPropertyValue('padding-bottom'); | |
3022 | |
3023 /** Sets the value of "padding-bottom" */ | |
3024 set paddingBottom(String value) { | |
3025 setProperty('padding-bottom', value, ''); | |
3026 } | |
3027 | |
3028 /** Gets the value of "padding-end" */ | |
3029 String get paddingEnd => | |
3030 getPropertyValue('padding-end'); | |
3031 | |
3032 /** Sets the value of "padding-end" */ | |
3033 set paddingEnd(String value) { | |
3034 setProperty('padding-end', value, ''); | |
3035 } | |
3036 | |
3037 /** Gets the value of "padding-left" */ | |
3038 String get paddingLeft => | |
3039 getPropertyValue('padding-left'); | |
3040 | |
3041 /** Sets the value of "padding-left" */ | |
3042 set paddingLeft(String value) { | |
3043 setProperty('padding-left', value, ''); | |
3044 } | |
3045 | |
3046 /** Gets the value of "padding-right" */ | |
3047 String get paddingRight => | |
3048 getPropertyValue('padding-right'); | |
3049 | |
3050 /** Sets the value of "padding-right" */ | |
3051 set paddingRight(String value) { | |
3052 setProperty('padding-right', value, ''); | |
3053 } | |
3054 | |
3055 /** Gets the value of "padding-start" */ | |
3056 String get paddingStart => | |
3057 getPropertyValue('padding-start'); | |
3058 | |
3059 /** Sets the value of "padding-start" */ | |
3060 set paddingStart(String value) { | |
3061 setProperty('padding-start', value, ''); | |
3062 } | |
3063 | |
3064 /** Gets the value of "padding-top" */ | |
3065 String get paddingTop => | |
3066 getPropertyValue('padding-top'); | |
3067 | |
3068 /** Sets the value of "padding-top" */ | |
3069 set paddingTop(String value) { | |
3070 setProperty('padding-top', value, ''); | |
3071 } | |
3072 | |
3073 /** Gets the value of "page" */ | |
3074 String get page => | |
3075 getPropertyValue('page'); | |
3076 | |
3077 /** Sets the value of "page" */ | |
3078 set page(String value) { | |
3079 setProperty('page', value, ''); | |
3080 } | |
3081 | |
3082 /** Gets the value of "page-break-after" */ | |
3083 String get pageBreakAfter => | |
3084 getPropertyValue('page-break-after'); | |
3085 | |
3086 /** Sets the value of "page-break-after" */ | |
3087 set pageBreakAfter(String value) { | |
3088 setProperty('page-break-after', value, ''); | |
3089 } | |
3090 | |
3091 /** Gets the value of "page-break-before" */ | |
3092 String get pageBreakBefore => | |
3093 getPropertyValue('page-break-before'); | |
3094 | |
3095 /** Sets the value of "page-break-before" */ | |
3096 set pageBreakBefore(String value) { | |
3097 setProperty('page-break-before', value, ''); | |
3098 } | |
3099 | |
3100 /** Gets the value of "page-break-inside" */ | |
3101 String get pageBreakInside => | |
3102 getPropertyValue('page-break-inside'); | |
3103 | |
3104 /** Sets the value of "page-break-inside" */ | |
3105 set pageBreakInside(String value) { | |
3106 setProperty('page-break-inside', value, ''); | |
3107 } | |
3108 | |
3109 /** Gets the value of "perspective" */ | |
3110 String get perspective => | |
3111 getPropertyValue('perspective'); | |
3112 | |
3113 /** Sets the value of "perspective" */ | |
3114 set perspective(String value) { | |
3115 setProperty('perspective', value, ''); | |
3116 } | |
3117 | |
3118 /** Gets the value of "perspective-origin" */ | |
3119 String get perspectiveOrigin => | |
3120 getPropertyValue('perspective-origin'); | |
3121 | |
3122 /** Sets the value of "perspective-origin" */ | |
3123 set perspectiveOrigin(String value) { | |
3124 setProperty('perspective-origin', value, ''); | |
3125 } | |
3126 | |
3127 /** Gets the value of "perspective-origin-x" */ | |
3128 String get perspectiveOriginX => | |
3129 getPropertyValue('perspective-origin-x'); | |
3130 | |
3131 /** Sets the value of "perspective-origin-x" */ | |
3132 set perspectiveOriginX(String value) { | |
3133 setProperty('perspective-origin-x', value, ''); | |
3134 } | |
3135 | |
3136 /** Gets the value of "perspective-origin-y" */ | |
3137 String get perspectiveOriginY => | |
3138 getPropertyValue('perspective-origin-y'); | |
3139 | |
3140 /** Sets the value of "perspective-origin-y" */ | |
3141 set perspectiveOriginY(String value) { | |
3142 setProperty('perspective-origin-y', value, ''); | |
3143 } | |
3144 | |
3145 /** Gets the value of "pointer-events" */ | |
3146 String get pointerEvents => | |
3147 getPropertyValue('pointer-events'); | |
3148 | |
3149 /** Sets the value of "pointer-events" */ | |
3150 set pointerEvents(String value) { | |
3151 setProperty('pointer-events', value, ''); | |
3152 } | |
3153 | |
3154 /** Gets the value of "position" */ | |
3155 String get position => | |
3156 getPropertyValue('position'); | |
3157 | |
3158 /** Sets the value of "position" */ | |
3159 set position(String value) { | |
3160 setProperty('position', value, ''); | |
3161 } | |
3162 | |
3163 /** Gets the value of "print-color-adjust" */ | |
3164 String get printColorAdjust => | |
3165 getPropertyValue('print-color-adjust'); | |
3166 | |
3167 /** Sets the value of "print-color-adjust" */ | |
3168 set printColorAdjust(String value) { | |
3169 setProperty('print-color-adjust', value, ''); | |
3170 } | |
3171 | |
3172 /** Gets the value of "quotes" */ | |
3173 String get quotes => | |
3174 getPropertyValue('quotes'); | |
3175 | |
3176 /** Sets the value of "quotes" */ | |
3177 set quotes(String value) { | |
3178 setProperty('quotes', value, ''); | |
3179 } | |
3180 | |
3181 /** Gets the value of "resize" */ | |
3182 String get resize => | |
3183 getPropertyValue('resize'); | |
3184 | |
3185 /** Sets the value of "resize" */ | |
3186 set resize(String value) { | |
3187 setProperty('resize', value, ''); | |
3188 } | |
3189 | |
3190 /** Gets the value of "right" */ | |
3191 String get right => | |
3192 getPropertyValue('right'); | |
3193 | |
3194 /** Sets the value of "right" */ | |
3195 set right(String value) { | |
3196 setProperty('right', value, ''); | |
3197 } | |
3198 | |
3199 /** Gets the value of "rtl-ordering" */ | |
3200 String get rtlOrdering => | |
3201 getPropertyValue('rtl-ordering'); | |
3202 | |
3203 /** Sets the value of "rtl-ordering" */ | |
3204 set rtlOrdering(String value) { | |
3205 setProperty('rtl-ordering', value, ''); | |
3206 } | |
3207 | |
3208 /** Gets the value of "ruby-position" */ | |
3209 String get rubyPosition => | |
3210 getPropertyValue('ruby-position'); | |
3211 | |
3212 /** Sets the value of "ruby-position" */ | |
3213 set rubyPosition(String value) { | |
3214 setProperty('ruby-position', value, ''); | |
3215 } | |
3216 | |
3217 /** Gets the value of "scroll-behavior" */ | |
3218 String get scrollBehavior => | |
3219 getPropertyValue('scroll-behavior'); | |
3220 | |
3221 /** Sets the value of "scroll-behavior" */ | |
3222 set scrollBehavior(String value) { | |
3223 setProperty('scroll-behavior', value, ''); | |
3224 } | |
3225 | |
3226 /** Gets the value of "shape-image-threshold" */ | |
3227 String get shapeImageThreshold => | |
3228 getPropertyValue('shape-image-threshold'); | |
3229 | |
3230 /** Sets the value of "shape-image-threshold" */ | |
3231 set shapeImageThreshold(String value) { | |
3232 setProperty('shape-image-threshold', value, ''); | |
3233 } | |
3234 | |
3235 /** Gets the value of "shape-margin" */ | |
3236 String get shapeMargin => | |
3237 getPropertyValue('shape-margin'); | |
3238 | |
3239 /** Sets the value of "shape-margin" */ | |
3240 set shapeMargin(String value) { | |
3241 setProperty('shape-margin', value, ''); | |
3242 } | |
3243 | |
3244 /** Gets the value of "shape-outside" */ | |
3245 String get shapeOutside => | |
3246 getPropertyValue('shape-outside'); | |
3247 | |
3248 /** Sets the value of "shape-outside" */ | |
3249 set shapeOutside(String value) { | |
3250 setProperty('shape-outside', value, ''); | |
3251 } | |
3252 | |
3253 /** Gets the value of "size" */ | |
3254 String get size => | |
3255 getPropertyValue('size'); | |
3256 | |
3257 /** Sets the value of "size" */ | |
3258 set size(String value) { | |
3259 setProperty('size', value, ''); | |
3260 } | |
3261 | |
3262 /** Gets the value of "speak" */ | |
3263 String get speak => | |
3264 getPropertyValue('speak'); | |
3265 | |
3266 /** Sets the value of "speak" */ | |
3267 set speak(String value) { | |
3268 setProperty('speak', value, ''); | |
3269 } | |
3270 | |
3271 /** Gets the value of "src" */ | |
3272 String get src => | |
3273 getPropertyValue('src'); | |
3274 | |
3275 /** Sets the value of "src" */ | |
3276 set src(String value) { | |
3277 setProperty('src', value, ''); | |
3278 } | |
3279 | |
3280 /** Gets the value of "tab-size" */ | |
3281 String get tabSize => | |
3282 getPropertyValue('tab-size'); | |
3283 | |
3284 /** Sets the value of "tab-size" */ | |
3285 set tabSize(String value) { | |
3286 setProperty('tab-size', value, ''); | |
3287 } | |
3288 | |
3289 /** Gets the value of "table-layout" */ | |
3290 String get tableLayout => | |
3291 getPropertyValue('table-layout'); | |
3292 | |
3293 /** Sets the value of "table-layout" */ | |
3294 set tableLayout(String value) { | |
3295 setProperty('table-layout', value, ''); | |
3296 } | |
3297 | |
3298 /** Gets the value of "tap-highlight-color" */ | |
3299 String get tapHighlightColor => | |
3300 getPropertyValue('tap-highlight-color'); | |
3301 | |
3302 /** Sets the value of "tap-highlight-color" */ | |
3303 set tapHighlightColor(String value) { | |
3304 setProperty('tap-highlight-color', value, ''); | |
3305 } | |
3306 | |
3307 /** Gets the value of "text-align" */ | |
3308 String get textAlign => | |
3309 getPropertyValue('text-align'); | |
3310 | |
3311 /** Sets the value of "text-align" */ | |
3312 set textAlign(String value) { | |
3313 setProperty('text-align', value, ''); | |
3314 } | |
3315 | |
3316 /** Gets the value of "text-align-last" */ | |
3317 String get textAlignLast => | |
3318 getPropertyValue('text-align-last'); | |
3319 | |
3320 /** Sets the value of "text-align-last" */ | |
3321 set textAlignLast(String value) { | |
3322 setProperty('text-align-last', value, ''); | |
3323 } | |
3324 | |
3325 /** Gets the value of "text-combine" */ | |
3326 String get textCombine => | |
3327 getPropertyValue('text-combine'); | |
3328 | |
3329 /** Sets the value of "text-combine" */ | |
3330 set textCombine(String value) { | |
3331 setProperty('text-combine', value, ''); | |
3332 } | |
3333 | |
3334 /** Gets the value of "text-decoration" */ | |
3335 String get textDecoration => | |
3336 getPropertyValue('text-decoration'); | |
3337 | |
3338 /** Sets the value of "text-decoration" */ | |
3339 set textDecoration(String value) { | |
3340 setProperty('text-decoration', value, ''); | |
3341 } | |
3342 | |
3343 /** Gets the value of "text-decoration-color" */ | |
3344 String get textDecorationColor => | |
3345 getPropertyValue('text-decoration-color'); | |
3346 | |
3347 /** Sets the value of "text-decoration-color" */ | |
3348 set textDecorationColor(String value) { | |
3349 setProperty('text-decoration-color', value, ''); | |
3350 } | |
3351 | |
3352 /** Gets the value of "text-decoration-line" */ | |
3353 String get textDecorationLine => | |
3354 getPropertyValue('text-decoration-line'); | |
3355 | |
3356 /** Sets the value of "text-decoration-line" */ | |
3357 set textDecorationLine(String value) { | |
3358 setProperty('text-decoration-line', value, ''); | |
3359 } | |
3360 | |
3361 /** Gets the value of "text-decoration-style" */ | |
3362 String get textDecorationStyle => | |
3363 getPropertyValue('text-decoration-style'); | |
3364 | |
3365 /** Sets the value of "text-decoration-style" */ | |
3366 set textDecorationStyle(String value) { | |
3367 setProperty('text-decoration-style', value, ''); | |
3368 } | |
3369 | |
3370 /** Gets the value of "text-decorations-in-effect" */ | |
3371 String get textDecorationsInEffect => | |
3372 getPropertyValue('text-decorations-in-effect'); | |
3373 | |
3374 /** Sets the value of "text-decorations-in-effect" */ | |
3375 set textDecorationsInEffect(String value) { | |
3376 setProperty('text-decorations-in-effect', value, ''); | |
3377 } | |
3378 | |
3379 /** Gets the value of "text-emphasis" */ | |
3380 String get textEmphasis => | |
3381 getPropertyValue('text-emphasis'); | |
3382 | |
3383 /** Sets the value of "text-emphasis" */ | |
3384 set textEmphasis(String value) { | |
3385 setProperty('text-emphasis', value, ''); | |
3386 } | |
3387 | |
3388 /** Gets the value of "text-emphasis-color" */ | |
3389 String get textEmphasisColor => | |
3390 getPropertyValue('text-emphasis-color'); | |
3391 | |
3392 /** Sets the value of "text-emphasis-color" */ | |
3393 set textEmphasisColor(String value) { | |
3394 setProperty('text-emphasis-color', value, ''); | |
3395 } | |
3396 | |
3397 /** Gets the value of "text-emphasis-position" */ | |
3398 String get textEmphasisPosition => | |
3399 getPropertyValue('text-emphasis-position'); | |
3400 | |
3401 /** Sets the value of "text-emphasis-position" */ | |
3402 set textEmphasisPosition(String value) { | |
3403 setProperty('text-emphasis-position', value, ''); | |
3404 } | |
3405 | |
3406 /** Gets the value of "text-emphasis-style" */ | |
3407 String get textEmphasisStyle => | |
3408 getPropertyValue('text-emphasis-style'); | |
3409 | |
3410 /** Sets the value of "text-emphasis-style" */ | |
3411 set textEmphasisStyle(String value) { | |
3412 setProperty('text-emphasis-style', value, ''); | |
3413 } | |
3414 | |
3415 /** Gets the value of "text-fill-color" */ | |
3416 String get textFillColor => | |
3417 getPropertyValue('text-fill-color'); | |
3418 | |
3419 /** Sets the value of "text-fill-color" */ | |
3420 set textFillColor(String value) { | |
3421 setProperty('text-fill-color', value, ''); | |
3422 } | |
3423 | |
3424 /** Gets the value of "text-indent" */ | |
3425 String get textIndent => | |
3426 getPropertyValue('text-indent'); | |
3427 | |
3428 /** Sets the value of "text-indent" */ | |
3429 set textIndent(String value) { | |
3430 setProperty('text-indent', value, ''); | |
3431 } | |
3432 | |
3433 /** Gets the value of "text-justify" */ | |
3434 String get textJustify => | |
3435 getPropertyValue('text-justify'); | |
3436 | |
3437 /** Sets the value of "text-justify" */ | |
3438 set textJustify(String value) { | |
3439 setProperty('text-justify', value, ''); | |
3440 } | |
3441 | |
3442 /** Gets the value of "text-line-through-color" */ | |
3443 String get textLineThroughColor => | |
3444 getPropertyValue('text-line-through-color'); | |
3445 | |
3446 /** Sets the value of "text-line-through-color" */ | |
3447 set textLineThroughColor(String value) { | |
3448 setProperty('text-line-through-color', value, ''); | |
3449 } | |
3450 | |
3451 /** Gets the value of "text-line-through-mode" */ | |
3452 String get textLineThroughMode => | |
3453 getPropertyValue('text-line-through-mode'); | |
3454 | |
3455 /** Sets the value of "text-line-through-mode" */ | |
3456 set textLineThroughMode(String value) { | |
3457 setProperty('text-line-through-mode', value, ''); | |
3458 } | |
3459 | |
3460 /** Gets the value of "text-line-through-style" */ | |
3461 String get textLineThroughStyle => | |
3462 getPropertyValue('text-line-through-style'); | |
3463 | |
3464 /** Sets the value of "text-line-through-style" */ | |
3465 set textLineThroughStyle(String value) { | |
3466 setProperty('text-line-through-style', value, ''); | |
3467 } | |
3468 | |
3469 /** Gets the value of "text-line-through-width" */ | |
3470 String get textLineThroughWidth => | |
3471 getPropertyValue('text-line-through-width'); | |
3472 | |
3473 /** Sets the value of "text-line-through-width" */ | |
3474 set textLineThroughWidth(String value) { | |
3475 setProperty('text-line-through-width', value, ''); | |
3476 } | |
3477 | |
3478 /** Gets the value of "text-orientation" */ | |
3479 String get textOrientation => | |
3480 getPropertyValue('text-orientation'); | |
3481 | |
3482 /** Sets the value of "text-orientation" */ | |
3483 set textOrientation(String value) { | |
3484 setProperty('text-orientation', value, ''); | |
3485 } | |
3486 | |
3487 /** Gets the value of "text-overflow" */ | |
3488 String get textOverflow => | |
3489 getPropertyValue('text-overflow'); | |
3490 | |
3491 /** Sets the value of "text-overflow" */ | |
3492 set textOverflow(String value) { | |
3493 setProperty('text-overflow', value, ''); | |
3494 } | |
3495 | |
3496 /** Gets the value of "text-overline-color" */ | |
3497 String get textOverlineColor => | |
3498 getPropertyValue('text-overline-color'); | |
3499 | |
3500 /** Sets the value of "text-overline-color" */ | |
3501 set textOverlineColor(String value) { | |
3502 setProperty('text-overline-color', value, ''); | |
3503 } | |
3504 | |
3505 /** Gets the value of "text-overline-mode" */ | |
3506 String get textOverlineMode => | |
3507 getPropertyValue('text-overline-mode'); | |
3508 | |
3509 /** Sets the value of "text-overline-mode" */ | |
3510 set textOverlineMode(String value) { | |
3511 setProperty('text-overline-mode', value, ''); | |
3512 } | |
3513 | |
3514 /** Gets the value of "text-overline-style" */ | |
3515 String get textOverlineStyle => | |
3516 getPropertyValue('text-overline-style'); | |
3517 | |
3518 /** Sets the value of "text-overline-style" */ | |
3519 set textOverlineStyle(String value) { | |
3520 setProperty('text-overline-style', value, ''); | |
3521 } | |
3522 | |
3523 /** Gets the value of "text-overline-width" */ | |
3524 String get textOverlineWidth => | |
3525 getPropertyValue('text-overline-width'); | |
3526 | |
3527 /** Sets the value of "text-overline-width" */ | |
3528 set textOverlineWidth(String value) { | |
3529 setProperty('text-overline-width', value, ''); | |
3530 } | |
3531 | |
3532 /** Gets the value of "text-rendering" */ | |
3533 String get textRendering => | |
3534 getPropertyValue('text-rendering'); | |
3535 | |
3536 /** Sets the value of "text-rendering" */ | |
3537 set textRendering(String value) { | |
3538 setProperty('text-rendering', value, ''); | |
3539 } | |
3540 | |
3541 /** Gets the value of "text-security" */ | |
3542 String get textSecurity => | |
3543 getPropertyValue('text-security'); | |
3544 | |
3545 /** Sets the value of "text-security" */ | |
3546 set textSecurity(String value) { | |
3547 setProperty('text-security', value, ''); | |
3548 } | |
3549 | |
3550 /** Gets the value of "text-shadow" */ | |
3551 String get textShadow => | |
3552 getPropertyValue('text-shadow'); | |
3553 | |
3554 /** Sets the value of "text-shadow" */ | |
3555 set textShadow(String value) { | |
3556 setProperty('text-shadow', value, ''); | |
3557 } | |
3558 | |
3559 /** Gets the value of "text-stroke" */ | |
3560 String get textStroke => | |
3561 getPropertyValue('text-stroke'); | |
3562 | |
3563 /** Sets the value of "text-stroke" */ | |
3564 set textStroke(String value) { | |
3565 setProperty('text-stroke', value, ''); | |
3566 } | |
3567 | |
3568 /** Gets the value of "text-stroke-color" */ | |
3569 String get textStrokeColor => | |
3570 getPropertyValue('text-stroke-color'); | |
3571 | |
3572 /** Sets the value of "text-stroke-color" */ | |
3573 set textStrokeColor(String value) { | |
3574 setProperty('text-stroke-color', value, ''); | |
3575 } | |
3576 | |
3577 /** Gets the value of "text-stroke-width" */ | |
3578 String get textStrokeWidth => | |
3579 getPropertyValue('text-stroke-width'); | |
3580 | |
3581 /** Sets the value of "text-stroke-width" */ | |
3582 set textStrokeWidth(String value) { | |
3583 setProperty('text-stroke-width', value, ''); | |
3584 } | |
3585 | |
3586 /** Gets the value of "text-transform" */ | |
3587 String get textTransform => | |
3588 getPropertyValue('text-transform'); | |
3589 | |
3590 /** Sets the value of "text-transform" */ | |
3591 set textTransform(String value) { | |
3592 setProperty('text-transform', value, ''); | |
3593 } | |
3594 | |
3595 /** Gets the value of "text-underline-color" */ | |
3596 String get textUnderlineColor => | |
3597 getPropertyValue('text-underline-color'); | |
3598 | |
3599 /** Sets the value of "text-underline-color" */ | |
3600 set textUnderlineColor(String value) { | |
3601 setProperty('text-underline-color', value, ''); | |
3602 } | |
3603 | |
3604 /** Gets the value of "text-underline-mode" */ | |
3605 String get textUnderlineMode => | |
3606 getPropertyValue('text-underline-mode'); | |
3607 | |
3608 /** Sets the value of "text-underline-mode" */ | |
3609 set textUnderlineMode(String value) { | |
3610 setProperty('text-underline-mode', value, ''); | |
3611 } | |
3612 | |
3613 /** Gets the value of "text-underline-position" */ | |
3614 String get textUnderlinePosition => | |
3615 getPropertyValue('text-underline-position'); | |
3616 | |
3617 /** Sets the value of "text-underline-position" */ | |
3618 set textUnderlinePosition(String value) { | |
3619 setProperty('text-underline-position', value, ''); | |
3620 } | |
3621 | |
3622 /** Gets the value of "text-underline-style" */ | |
3623 String get textUnderlineStyle => | |
3624 getPropertyValue('text-underline-style'); | |
3625 | |
3626 /** Sets the value of "text-underline-style" */ | |
3627 set textUnderlineStyle(String value) { | |
3628 setProperty('text-underline-style', value, ''); | |
3629 } | |
3630 | |
3631 /** Gets the value of "text-underline-width" */ | |
3632 String get textUnderlineWidth => | |
3633 getPropertyValue('text-underline-width'); | |
3634 | |
3635 /** Sets the value of "text-underline-width" */ | |
3636 set textUnderlineWidth(String value) { | |
3637 setProperty('text-underline-width', value, ''); | |
3638 } | |
3639 | |
3640 /** Gets the value of "top" */ | |
3641 String get top => | |
3642 getPropertyValue('top'); | |
3643 | |
3644 /** Sets the value of "top" */ | |
3645 set top(String value) { | |
3646 setProperty('top', value, ''); | |
3647 } | |
3648 | |
3649 /** Gets the value of "touch-action" */ | |
3650 String get touchAction => | |
3651 getPropertyValue('touch-action'); | |
3652 | |
3653 /** Sets the value of "touch-action" */ | |
3654 set touchAction(String value) { | |
3655 setProperty('touch-action', value, ''); | |
3656 } | |
3657 | |
3658 /** Gets the value of "touch-action-delay" */ | |
3659 String get touchActionDelay => | |
3660 getPropertyValue('touch-action-delay'); | |
3661 | |
3662 /** Sets the value of "touch-action-delay" */ | |
3663 set touchActionDelay(String value) { | |
3664 setProperty('touch-action-delay', value, ''); | |
3665 } | |
3666 | |
3667 /** Gets the value of "transform" */ | |
3668 String get transform => | |
3669 getPropertyValue('transform'); | |
3670 | |
3671 /** Sets the value of "transform" */ | |
3672 set transform(String value) { | |
3673 setProperty('transform', value, ''); | |
3674 } | |
3675 | |
3676 /** Gets the value of "transform-origin" */ | |
3677 String get transformOrigin => | |
3678 getPropertyValue('transform-origin'); | |
3679 | |
3680 /** Sets the value of "transform-origin" */ | |
3681 set transformOrigin(String value) { | |
3682 setProperty('transform-origin', value, ''); | |
3683 } | |
3684 | |
3685 /** Gets the value of "transform-origin-x" */ | |
3686 String get transformOriginX => | |
3687 getPropertyValue('transform-origin-x'); | |
3688 | |
3689 /** Sets the value of "transform-origin-x" */ | |
3690 set transformOriginX(String value) { | |
3691 setProperty('transform-origin-x', value, ''); | |
3692 } | |
3693 | |
3694 /** Gets the value of "transform-origin-y" */ | |
3695 String get transformOriginY => | |
3696 getPropertyValue('transform-origin-y'); | |
3697 | |
3698 /** Sets the value of "transform-origin-y" */ | |
3699 set transformOriginY(String value) { | |
3700 setProperty('transform-origin-y', value, ''); | |
3701 } | |
3702 | |
3703 /** Gets the value of "transform-origin-z" */ | |
3704 String get transformOriginZ => | |
3705 getPropertyValue('transform-origin-z'); | |
3706 | |
3707 /** Sets the value of "transform-origin-z" */ | |
3708 set transformOriginZ(String value) { | |
3709 setProperty('transform-origin-z', value, ''); | |
3710 } | |
3711 | |
3712 /** Gets the value of "transform-style" */ | |
3713 String get transformStyle => | |
3714 getPropertyValue('transform-style'); | |
3715 | |
3716 /** Sets the value of "transform-style" */ | |
3717 set transformStyle(String value) { | |
3718 setProperty('transform-style', value, ''); | |
3719 } | |
3720 | |
3721 /** Gets the value of "transition" */@SupportedBrowser(SupportedBrowser.CHROME
) | |
3722 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
3723 @SupportedBrowser(SupportedBrowser.IE, '10') | |
3724 @SupportedBrowser(SupportedBrowser.SAFARI) | |
3725 String get transition => | |
3726 getPropertyValue('transition'); | |
3727 | |
3728 /** Sets the value of "transition" */@SupportedBrowser(SupportedBrowser.CHROME
) | |
3729 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
3730 @SupportedBrowser(SupportedBrowser.IE, '10') | |
3731 @SupportedBrowser(SupportedBrowser.SAFARI) | |
3732 set transition(String value) { | |
3733 setProperty('transition', value, ''); | |
3734 } | |
3735 | |
3736 /** Gets the value of "transition-delay" */ | |
3737 String get transitionDelay => | |
3738 getPropertyValue('transition-delay'); | |
3739 | |
3740 /** Sets the value of "transition-delay" */ | |
3741 set transitionDelay(String value) { | |
3742 setProperty('transition-delay', value, ''); | |
3743 } | |
3744 | |
3745 /** Gets the value of "transition-duration" */ | |
3746 String get transitionDuration => | |
3747 getPropertyValue('transition-duration'); | |
3748 | |
3749 /** Sets the value of "transition-duration" */ | |
3750 set transitionDuration(String value) { | |
3751 setProperty('transition-duration', value, ''); | |
3752 } | |
3753 | |
3754 /** Gets the value of "transition-property" */ | |
3755 String get transitionProperty => | |
3756 getPropertyValue('transition-property'); | |
3757 | |
3758 /** Sets the value of "transition-property" */ | |
3759 set transitionProperty(String value) { | |
3760 setProperty('transition-property', value, ''); | |
3761 } | |
3762 | |
3763 /** Gets the value of "transition-timing-function" */ | |
3764 String get transitionTimingFunction => | |
3765 getPropertyValue('transition-timing-function'); | |
3766 | |
3767 /** Sets the value of "transition-timing-function" */ | |
3768 set transitionTimingFunction(String value) { | |
3769 setProperty('transition-timing-function', value, ''); | |
3770 } | |
3771 | |
3772 /** Gets the value of "unicode-bidi" */ | |
3773 String get unicodeBidi => | |
3774 getPropertyValue('unicode-bidi'); | |
3775 | |
3776 /** Sets the value of "unicode-bidi" */ | |
3777 set unicodeBidi(String value) { | |
3778 setProperty('unicode-bidi', value, ''); | |
3779 } | |
3780 | |
3781 /** Gets the value of "unicode-range" */ | |
3782 String get unicodeRange => | |
3783 getPropertyValue('unicode-range'); | |
3784 | |
3785 /** Sets the value of "unicode-range" */ | |
3786 set unicodeRange(String value) { | |
3787 setProperty('unicode-range', value, ''); | |
3788 } | |
3789 | |
3790 /** Gets the value of "user-drag" */ | |
3791 String get userDrag => | |
3792 getPropertyValue('user-drag'); | |
3793 | |
3794 /** Sets the value of "user-drag" */ | |
3795 set userDrag(String value) { | |
3796 setProperty('user-drag', value, ''); | |
3797 } | |
3798 | |
3799 /** Gets the value of "user-modify" */ | |
3800 String get userModify => | |
3801 getPropertyValue('user-modify'); | |
3802 | |
3803 /** Sets the value of "user-modify" */ | |
3804 set userModify(String value) { | |
3805 setProperty('user-modify', value, ''); | |
3806 } | |
3807 | |
3808 /** Gets the value of "user-select" */ | |
3809 String get userSelect => | |
3810 getPropertyValue('user-select'); | |
3811 | |
3812 /** Sets the value of "user-select" */ | |
3813 set userSelect(String value) { | |
3814 setProperty('user-select', value, ''); | |
3815 } | |
3816 | |
3817 /** Gets the value of "user-zoom" */ | |
3818 String get userZoom => | |
3819 getPropertyValue('user-zoom'); | |
3820 | |
3821 /** Sets the value of "user-zoom" */ | |
3822 set userZoom(String value) { | |
3823 setProperty('user-zoom', value, ''); | |
3824 } | |
3825 | |
3826 /** Gets the value of "vertical-align" */ | |
3827 String get verticalAlign => | |
3828 getPropertyValue('vertical-align'); | |
3829 | |
3830 /** Sets the value of "vertical-align" */ | |
3831 set verticalAlign(String value) { | |
3832 setProperty('vertical-align', value, ''); | |
3833 } | |
3834 | |
3835 /** Gets the value of "visibility" */ | |
3836 String get visibility => | |
3837 getPropertyValue('visibility'); | |
3838 | |
3839 /** Sets the value of "visibility" */ | |
3840 set visibility(String value) { | |
3841 setProperty('visibility', value, ''); | |
3842 } | |
3843 | |
3844 /** Gets the value of "white-space" */ | |
3845 String get whiteSpace => | |
3846 getPropertyValue('white-space'); | |
3847 | |
3848 /** Sets the value of "white-space" */ | |
3849 set whiteSpace(String value) { | |
3850 setProperty('white-space', value, ''); | |
3851 } | |
3852 | |
3853 /** Gets the value of "widows" */ | |
3854 String get widows => | |
3855 getPropertyValue('widows'); | |
3856 | |
3857 /** Sets the value of "widows" */ | |
3858 set widows(String value) { | |
3859 setProperty('widows', value, ''); | |
3860 } | |
3861 | |
3862 /** Gets the value of "width" */ | |
3863 String get width => | |
3864 getPropertyValue('width'); | |
3865 | |
3866 /** Sets the value of "width" */ | |
3867 set width(String value) { | |
3868 setProperty('width', value, ''); | |
3869 } | |
3870 | |
3871 /** Gets the value of "will-change" */ | |
3872 String get willChange => | |
3873 getPropertyValue('will-change'); | |
3874 | |
3875 /** Sets the value of "will-change" */ | |
3876 set willChange(String value) { | |
3877 setProperty('will-change', value, ''); | |
3878 } | |
3879 | |
3880 /** Gets the value of "word-break" */ | |
3881 String get wordBreak => | |
3882 getPropertyValue('word-break'); | |
3883 | |
3884 /** Sets the value of "word-break" */ | |
3885 set wordBreak(String value) { | |
3886 setProperty('word-break', value, ''); | |
3887 } | |
3888 | |
3889 /** Gets the value of "word-spacing" */ | |
3890 String get wordSpacing => | |
3891 getPropertyValue('word-spacing'); | |
3892 | |
3893 /** Sets the value of "word-spacing" */ | |
3894 set wordSpacing(String value) { | |
3895 setProperty('word-spacing', value, ''); | |
3896 } | |
3897 | |
3898 /** Gets the value of "word-wrap" */ | |
3899 String get wordWrap => | |
3900 getPropertyValue('word-wrap'); | |
3901 | |
3902 /** Sets the value of "word-wrap" */ | |
3903 set wordWrap(String value) { | |
3904 setProperty('word-wrap', value, ''); | |
3905 } | |
3906 | |
3907 /** Gets the value of "wrap-flow" */ | |
3908 String get wrapFlow => | |
3909 getPropertyValue('wrap-flow'); | |
3910 | |
3911 /** Sets the value of "wrap-flow" */ | |
3912 set wrapFlow(String value) { | |
3913 setProperty('wrap-flow', value, ''); | |
3914 } | |
3915 | |
3916 /** Gets the value of "wrap-through" */ | |
3917 String get wrapThrough => | |
3918 getPropertyValue('wrap-through'); | |
3919 | |
3920 /** Sets the value of "wrap-through" */ | |
3921 set wrapThrough(String value) { | |
3922 setProperty('wrap-through', value, ''); | |
3923 } | |
3924 | |
3925 /** Gets the value of "writing-mode" */ | |
3926 String get writingMode => | |
3927 getPropertyValue('writing-mode'); | |
3928 | |
3929 /** Sets the value of "writing-mode" */ | |
3930 set writingMode(String value) { | |
3931 setProperty('writing-mode', value, ''); | |
3932 } | |
3933 | |
3934 /** Gets the value of "z-index" */ | |
3935 String get zIndex => | |
3936 getPropertyValue('z-index'); | |
3937 | |
3938 /** Sets the value of "z-index" */ | |
3939 set zIndex(String value) { | |
3940 setProperty('z-index', value, ''); | |
3941 } | |
3942 | |
3943 /** Gets the value of "zoom" */ | |
3944 String get zoom => | |
3945 getPropertyValue('zoom'); | |
3946 | |
3947 /** Sets the value of "zoom" */ | |
3948 set zoom(String value) { | |
3949 setProperty('zoom', value, ''); | |
3950 } | |
3951 } | |
3952 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
3953 // for details. All rights reserved. Use of this source code is governed by a | |
3954 // BSD-style license that can be found in the LICENSE file. | |
3955 | |
3956 // WARNING: Do not edit - generated code. | |
3957 | |
3958 | |
3959 @DomName('CustomEvent') | |
3960 @Native("CustomEvent") | |
3961 class CustomEvent extends Event { | |
3962 var _dartDetail; | |
3963 | |
3964 factory CustomEvent(String type, | |
3965 {bool canBubble: true, bool cancelable: true, Object detail}) { | |
3966 | |
3967 final CustomEvent e = document._createEvent('CustomEvent'); | |
3968 | |
3969 e._dartDetail = detail; | |
3970 | |
3971 // Only try setting the detail if it's one of these types to avoid | |
3972 // first-chance exceptions. Can expand this list in the future as needed. | |
3973 if (detail is List || detail is Map || detail is String || detail is num) { | |
3974 try { | |
3975 e._initCustomEvent(type, canBubble, cancelable, detail); | |
3976 } catch(_) { | |
3977 e._initCustomEvent(type, canBubble, cancelable, null); | |
3978 } | |
3979 } else { | |
3980 e._initCustomEvent(type, canBubble, cancelable, null); | |
3981 } | |
3982 | |
3983 return e; | |
3984 } | |
3985 | |
3986 @DomName('CustomEvent.detail') | |
3987 get detail { | |
3988 if (_dartDetail != null) { | |
3989 return _dartDetail; | |
3990 } | |
3991 return _detail; | |
3992 } | |
3993 // To suppress missing implicit constructor warnings. | |
3994 factory CustomEvent._() { throw new UnsupportedError("Not supported"); } | |
3995 | |
3996 | |
3997 @Deprecated("Internal Use Only") | |
3998 static CustomEvent internalCreateCustomEvent() { | |
3999 return new CustomEvent.internal_(); | |
4000 } | |
4001 | |
4002 @Deprecated("Internal Use Only") | |
4003 CustomEvent.internal_() : super.internal_(); | |
4004 | |
4005 | |
4006 @DomName('CustomEvent._detail') | |
4007 @DocsEditable() | |
4008 @Experimental() // untriaged | |
4009 dynamic get _detail => convertNativeToDart_SerializedScriptValue(this._get__de
tail); | |
4010 @JSName('detail') | |
4011 @DomName('CustomEvent._detail') | |
4012 @DocsEditable() | |
4013 @Experimental() // untriaged | |
4014 @Creates('Null') | |
4015 dynamic get _get__detail => wrap_jso(JS("dynamic", "#.detail", this.raw)); | |
4016 | |
4017 @DomName('CustomEvent.initCustomEvent') | |
4018 @DocsEditable() | |
4019 void _initCustomEvent(String typeArg, bool canBubbleArg, bool cancelableArg, O
bject detailArg) { | |
4020 _initCustomEvent_1(typeArg, canBubbleArg, cancelableArg, detailArg); | |
4021 return; | |
4022 } | |
4023 @JSName('initCustomEvent') | |
4024 @DomName('CustomEvent.initCustomEvent') | |
4025 @DocsEditable() | |
4026 void _initCustomEvent_1(typeArg, canBubbleArg, cancelableArg, detailArg) => wr
ap_jso(JS("void ", "#.raw.initCustomEvent(#, #, #, #)", this, unwrap_jso(typeArg
), unwrap_jso(canBubbleArg), unwrap_jso(cancelableArg), unwrap_jso(detailArg))); | |
4027 | |
4028 } | |
4029 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
4030 // for details. All rights reserved. Use of this source code is governed by a | |
4031 // BSD-style license that can be found in the LICENSE file. | |
4032 | |
4033 | |
4034 @DocsEditable() | |
4035 /** | |
4036 * A generic container for content on an HTML page; | |
4037 * corresponds to the <div> tag. | |
4038 * | |
4039 * The [DivElement] is a generic container and does not have any semantic | |
4040 * significance. It is functionally similar to [SpanElement]. | |
4041 * | |
4042 * The [DivElement] is a block-level element, as opposed to [SpanElement], | |
4043 * which is an inline-level element. | |
4044 * | |
4045 * Example usage: | |
4046 * | |
4047 * DivElement div = new DivElement(); | |
4048 * div.text = 'Here's my new DivElem | |
4049 * document.body.elements.add(elem); | |
4050 * | |
4051 * See also: | |
4052 * | |
4053 * * [HTML <div> element](http://www.w3.org/TR/html-markup/div.html) from W3C. | |
4054 * * [Block-level element](http://www.w3.org/TR/CSS2/visuren.html#block-boxes) f
rom W3C. | |
4055 * * [Inline-level element](http://www.w3.org/TR/CSS2/visuren.html#inline-boxes)
from W3C. | |
4056 */ | |
4057 @DomName('HTMLDivElement') | |
4058 @Native("HTMLDivElement") | |
4059 class DivElement extends HtmlElement { | |
4060 // To suppress missing implicit constructor warnings. | |
4061 factory DivElement._() { throw new UnsupportedError("Not supported"); } | |
4062 | |
4063 @DomName('HTMLDivElement.HTMLDivElement') | |
4064 @DocsEditable() | |
4065 factory DivElement() => document.createElement("div"); | |
4066 | |
4067 | |
4068 @Deprecated("Internal Use Only") | |
4069 static DivElement internalCreateDivElement() { | |
4070 return new DivElement.internal_(); | |
4071 } | |
4072 | |
4073 @Deprecated("Internal Use Only") | |
4074 DivElement.internal_() : super.internal_(); | |
4075 | |
4076 } | |
4077 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
4078 // for details. All rights reserved. Use of this source code is governed by a | |
4079 // BSD-style license that can be found in the LICENSE file. | |
4080 | |
4081 | |
4082 @DocsEditable() | |
4083 /** | |
4084 * The base class for all documents. | |
4085 * | |
4086 * Each web page loaded in the browser has its own [Document] object, which is | |
4087 * typically an [HtmlDocument]. | |
4088 * | |
4089 * If you aren't comfortable with DOM concepts, see the Dart tutorial | |
4090 * [Target 2: Connect Dart & HTML](http://www.dartlang.org/docs/tutorials/connec
t-dart-html/). | |
4091 */ | |
4092 @DomName('Document') | |
4093 @Native("Document") | |
4094 class Document extends Node | |
4095 { | |
4096 | |
4097 // To suppress missing implicit constructor warnings. | |
4098 factory Document._() { throw new UnsupportedError("Not supported"); } | |
4099 | |
4100 @DomName('Document.pointerlockchangeEvent') | |
4101 @DocsEditable() | |
4102 @Experimental() // untriaged | |
4103 static const EventStreamProvider<Event> pointerLockChangeEvent = const EventSt
reamProvider<Event>('pointerlockchange'); | |
4104 | |
4105 @DomName('Document.pointerlockerrorEvent') | |
4106 @DocsEditable() | |
4107 @Experimental() // untriaged | |
4108 static const EventStreamProvider<Event> pointerLockErrorEvent = const EventStr
eamProvider<Event>('pointerlockerror'); | |
4109 | |
4110 /** | |
4111 * Static factory designed to expose `readystatechange` events to event | |
4112 * handlers that are not necessarily instances of [Document]. | |
4113 * | |
4114 * See [EventStreamProvider] for usage information. | |
4115 */ | |
4116 @DomName('Document.readystatechangeEvent') | |
4117 @DocsEditable() | |
4118 static const EventStreamProvider<Event> readyStateChangeEvent = const EventStr
eamProvider<Event>('readystatechange'); | |
4119 | |
4120 /** | |
4121 * Static factory designed to expose `selectionchange` events to event | |
4122 * handlers that are not necessarily instances of [Document]. | |
4123 * | |
4124 * See [EventStreamProvider] for usage information. | |
4125 */ | |
4126 @DomName('Document.selectionchangeEvent') | |
4127 @DocsEditable() | |
4128 static const EventStreamProvider<Event> selectionChangeEvent = const EventStre
amProvider<Event>('selectionchange'); | |
4129 | |
4130 | |
4131 @Deprecated("Internal Use Only") | |
4132 static Document internalCreateDocument() { | |
4133 return new Document.internal_(); | |
4134 } | |
4135 | |
4136 @Deprecated("Internal Use Only") | |
4137 Document.internal_() : super.internal_(); | |
4138 | |
4139 | |
4140 @DomName('Document.activeElement') | |
4141 @DocsEditable() | |
4142 @Experimental() // untriaged | |
4143 Element get activeElement => wrap_jso(JS("Element", "#.activeElement", this.ra
w)); | |
4144 | |
4145 @JSName('body') | |
4146 @DomName('Document.body') | |
4147 @DocsEditable() | |
4148 HtmlElement get _body => wrap_jso(JS("HtmlElement", "#.body", this.raw)); | |
4149 @JSName('body') | |
4150 @DomName('Document.body') | |
4151 @DocsEditable() | |
4152 void set _body(HtmlElement val) => JS("void", "#.body = #", this.raw, unwrap_j
so(val)); | |
4153 | |
4154 @DomName('Document.contentType') | |
4155 @DocsEditable() | |
4156 @Experimental() // untriaged | |
4157 String get contentType => wrap_jso(JS("String", "#.contentType", this.raw)); | |
4158 | |
4159 @DomName('Document.cookie') | |
4160 @DocsEditable() | |
4161 String get cookie => wrap_jso(JS("String", "#.cookie", this.raw)); | |
4162 @DomName('Document.cookie') | |
4163 @DocsEditable() | |
4164 void set cookie(String val) => JS("void", "#.cookie = #", this.raw, unwrap_jso
(val)); | |
4165 | |
4166 @DomName('Document.currentScript') | |
4167 @DocsEditable() | |
4168 @Experimental() // untriaged | |
4169 HtmlElement get currentScript => wrap_jso(JS("HtmlElement", "#.currentScript",
this.raw)); | |
4170 | |
4171 @DomName('Document.window') | |
4172 @DocsEditable() | |
4173 @Experimental() // untriaged | |
4174 WindowBase get window => _convertNativeToDart_Window(this._get_window); | |
4175 @JSName('defaultView') | |
4176 @DomName('Document.window') | |
4177 @DocsEditable() | |
4178 @Experimental() // untriaged | |
4179 @Creates('Window|=Object') | |
4180 @Returns('Window|=Object') | |
4181 @Creates('Window|=Object|Null') | |
4182 @Returns('Window|=Object|Null') | |
4183 dynamic get _get_window => wrap_jso(JS("dynamic", "#.defaultView", this.raw)); | |
4184 | |
4185 @DomName('Document.documentElement') | |
4186 @DocsEditable() | |
4187 Element get documentElement => wrap_jso(JS("Element", "#.documentElement", thi
s.raw)); | |
4188 | |
4189 @DomName('Document.domain') | |
4190 @DocsEditable() | |
4191 String get domain => wrap_jso(JS("String", "#.domain", this.raw)); | |
4192 | |
4193 @DomName('Document.fullscreenElement') | |
4194 @DocsEditable() | |
4195 @Experimental() // untriaged | |
4196 Element get fullscreenElement => wrap_jso(JS("Element", "#.fullscreenElement",
this.raw)); | |
4197 | |
4198 @DomName('Document.fullscreenEnabled') | |
4199 @DocsEditable() | |
4200 @Experimental() // untriaged | |
4201 bool get fullscreenEnabled => wrap_jso(JS("bool", "#.fullscreenEnabled", this.
raw)); | |
4202 | |
4203 @JSName('head') | |
4204 @DomName('Document.head') | |
4205 @DocsEditable() | |
4206 HeadElement get _head => wrap_jso(JS("HeadElement", "#.head", this.raw)); | |
4207 | |
4208 @DomName('Document.hidden') | |
4209 @DocsEditable() | |
4210 @Experimental() // untriaged | |
4211 bool get hidden => wrap_jso(JS("bool", "#.hidden", this.raw)); | |
4212 | |
4213 @DomName('Document.implementation') | |
4214 @DocsEditable() | |
4215 DomImplementation get implementation => wrap_jso(JS("DomImplementation", "#.im
plementation", this.raw)); | |
4216 | |
4217 @JSName('lastModified') | |
4218 @DomName('Document.lastModified') | |
4219 @DocsEditable() | |
4220 String get _lastModified => wrap_jso(JS("String", "#.lastModified", this.raw))
; | |
4221 | |
4222 @DomName('Document.pointerLockElement') | |
4223 @DocsEditable() | |
4224 @Experimental() // untriaged | |
4225 Element get pointerLockElement => wrap_jso(JS("Element", "#.pointerLockElement
", this.raw)); | |
4226 | |
4227 @JSName('preferredStylesheetSet') | |
4228 @DomName('Document.preferredStylesheetSet') | |
4229 @DocsEditable() | |
4230 String get _preferredStylesheetSet => wrap_jso(JS("String", "#.preferredStyles
heetSet", this.raw)); | |
4231 | |
4232 @DomName('Document.readyState') | |
4233 @DocsEditable() | |
4234 String get readyState => wrap_jso(JS("String", "#.readyState", this.raw)); | |
4235 | |
4236 @JSName('referrer') | |
4237 @DomName('Document.referrer') | |
4238 @DocsEditable() | |
4239 String get _referrer => wrap_jso(JS("String", "#.referrer", this.raw)); | |
4240 | |
4241 @DomName('Document.rootElement') | |
4242 @DocsEditable() | |
4243 @Experimental() // untriaged | |
4244 Element get rootElement => wrap_jso(JS("Element", "#.rootElement", this.raw)); | |
4245 | |
4246 @JSName('selectedStylesheetSet') | |
4247 @DomName('Document.selectedStylesheetSet') | |
4248 @DocsEditable() | |
4249 String get _selectedStylesheetSet => wrap_jso(JS("String", "#.selectedStyleshe
etSet", this.raw)); | |
4250 @JSName('selectedStylesheetSet') | |
4251 @DomName('Document.selectedStylesheetSet') | |
4252 @DocsEditable() | |
4253 void set _selectedStylesheetSet(String val) => JS("void", "#.selectedStyleshee
tSet = #", this.raw, unwrap_jso(val)); | |
4254 | |
4255 @JSName('title') | |
4256 @DomName('Document.title') | |
4257 @DocsEditable() | |
4258 String get _title => wrap_jso(JS("String", "#.title", this.raw)); | |
4259 @JSName('title') | |
4260 @DomName('Document.title') | |
4261 @DocsEditable() | |
4262 void set _title(String val) => JS("void", "#.title = #", this.raw, unwrap_jso(
val)); | |
4263 | |
4264 @DomName('Document.visibilityState') | |
4265 @DocsEditable() | |
4266 @Experimental() // untriaged | |
4267 String get visibilityState => wrap_jso(JS("String", "#.visibilityState", this.
raw)); | |
4268 | |
4269 @JSName('webkitFullscreenElement') | |
4270 @DomName('Document.webkitFullscreenElement') | |
4271 @DocsEditable() | |
4272 @SupportedBrowser(SupportedBrowser.CHROME) | |
4273 @SupportedBrowser(SupportedBrowser.SAFARI) | |
4274 @Experimental() | |
4275 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#dom-document-f
ullscreenelement | |
4276 Element get _webkitFullscreenElement => wrap_jso(JS("Element", "#.webkitFullsc
reenElement", this.raw)); | |
4277 | |
4278 @JSName('webkitFullscreenEnabled') | |
4279 @DomName('Document.webkitFullscreenEnabled') | |
4280 @DocsEditable() | |
4281 @SupportedBrowser(SupportedBrowser.CHROME) | |
4282 @SupportedBrowser(SupportedBrowser.SAFARI) | |
4283 @Experimental() | |
4284 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#dom-document-f
ullscreenenabled | |
4285 bool get _webkitFullscreenEnabled => wrap_jso(JS("bool", "#.webkitFullscreenEn
abled", this.raw)); | |
4286 | |
4287 @JSName('webkitHidden') | |
4288 @DomName('Document.webkitHidden') | |
4289 @DocsEditable() | |
4290 @SupportedBrowser(SupportedBrowser.CHROME) | |
4291 @SupportedBrowser(SupportedBrowser.SAFARI) | |
4292 @Experimental() | |
4293 // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.h
tml#document | |
4294 bool get _webkitHidden => wrap_jso(JS("bool", "#.webkitHidden", this.raw)); | |
4295 | |
4296 @JSName('webkitVisibilityState') | |
4297 @DomName('Document.webkitVisibilityState') | |
4298 @DocsEditable() | |
4299 @SupportedBrowser(SupportedBrowser.CHROME) | |
4300 @SupportedBrowser(SupportedBrowser.SAFARI) | |
4301 @Experimental() | |
4302 // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.h
tml#dom-document-visibilitystate | |
4303 String get _webkitVisibilityState => wrap_jso(JS("String", "#.webkitVisibility
State", this.raw)); | |
4304 | |
4305 @DomName('Document.adoptNode') | |
4306 @DocsEditable() | |
4307 Node adoptNode(Node node) { | |
4308 return _adoptNode_1(node); | |
4309 } | |
4310 @JSName('adoptNode') | |
4311 @DomName('Document.adoptNode') | |
4312 @DocsEditable() | |
4313 Node _adoptNode_1(Node node) => wrap_jso(JS("Node ", "#.raw.adoptNode(#)", thi
s, unwrap_jso(node))); | |
4314 | |
4315 @DomName('Document.caretRangeFromPoint') | |
4316 @DocsEditable() | |
4317 // http://www.w3.org/TR/2009/WD-cssom-view-20090804/#dom-documentview-caretran
gefrompoint | |
4318 @Experimental() | |
4319 Range _caretRangeFromPoint(int x, int y) { | |
4320 return _caretRangeFromPoint_1(x, y); | |
4321 } | |
4322 @JSName('caretRangeFromPoint') | |
4323 @DomName('Document.caretRangeFromPoint') | |
4324 @DocsEditable() | |
4325 // http://www.w3.org/TR/2009/WD-cssom-view-20090804/#dom-documentview-caretran
gefrompoint | |
4326 @Experimental() | |
4327 Range _caretRangeFromPoint_1(x, y) => wrap_jso(JS("Range ", "#.raw.caretRangeF
romPoint(#, #)", this, unwrap_jso(x), unwrap_jso(y))); | |
4328 | |
4329 @DomName('Document.createDocumentFragment') | |
4330 @DocsEditable() | |
4331 DocumentFragment createDocumentFragment() { | |
4332 return _createDocumentFragment_1(); | |
4333 } | |
4334 @JSName('createDocumentFragment') | |
4335 @DomName('Document.createDocumentFragment') | |
4336 @DocsEditable() | |
4337 DocumentFragment _createDocumentFragment_1() => wrap_jso(JS("DocumentFragment
", "#.raw.createDocumentFragment()", this)); | |
4338 | |
4339 @DomName('Document.createElement') | |
4340 @DocsEditable() | |
4341 Element _createElement(String localName_OR_tagName, [String typeExtension]) { | |
4342 if (typeExtension == null) { | |
4343 return _createElement_1(localName_OR_tagName); | |
4344 } | |
4345 if (typeExtension != null) { | |
4346 return _createElement_2(localName_OR_tagName, typeExtension); | |
4347 } | |
4348 throw new ArgumentError("Incorrect number or type of arguments"); | |
4349 } | |
4350 @JSName('createElement') | |
4351 @DomName('Document.createElement') | |
4352 @DocsEditable() | |
4353 Element _createElement_1(tagName) => wrap_jso(JS("Element ", "#.raw.createElem
ent(#)", this, unwrap_jso(tagName))); | |
4354 @JSName('createElement') | |
4355 @DomName('Document.createElement') | |
4356 @DocsEditable() | |
4357 Element _createElement_2(localName, typeExtension) => wrap_jso(JS("Element ",
"#.raw.createElement(#, #)", this, unwrap_jso(localName), unwrap_jso(typeExtensi
on))); | |
4358 | |
4359 @DomName('Document.createElementNS') | |
4360 @DocsEditable() | |
4361 Element _createElementNS(String namespaceURI, String qualifiedName, [String ty
peExtension]) { | |
4362 if (typeExtension == null) { | |
4363 return _createElementNS_1(namespaceURI, qualifiedName); | |
4364 } | |
4365 if (typeExtension != null) { | |
4366 return _createElementNS_2(namespaceURI, qualifiedName, typeExtension); | |
4367 } | |
4368 throw new ArgumentError("Incorrect number or type of arguments"); | |
4369 } | |
4370 @JSName('createElementNS') | |
4371 @DomName('Document.createElementNS') | |
4372 @DocsEditable() | |
4373 Element _createElementNS_1(namespaceURI, qualifiedName) => wrap_jso(JS("Elemen
t ", "#.raw.createElementNS(#, #)", this, unwrap_jso(namespaceURI), unwrap_jso(q
ualifiedName))); | |
4374 @JSName('createElementNS') | |
4375 @DomName('Document.createElementNS') | |
4376 @DocsEditable() | |
4377 Element _createElementNS_2(namespaceURI, qualifiedName, typeExtension) => wrap
_jso(JS("Element ", "#.raw.createElementNS(#, #, #)", this, unwrap_jso(namespace
URI), unwrap_jso(qualifiedName), unwrap_jso(typeExtension))); | |
4378 | |
4379 @DomName('Document.createEvent') | |
4380 @DocsEditable() | |
4381 Event _createEvent(String eventType) { | |
4382 return _createEvent_1(eventType); | |
4383 } | |
4384 @JSName('createEvent') | |
4385 @DomName('Document.createEvent') | |
4386 @DocsEditable() | |
4387 Event _createEvent_1(eventType) => wrap_jso(JS("Event ", "#.raw.createEvent(#)
", this, unwrap_jso(eventType))); | |
4388 | |
4389 @DomName('Document.createRange') | |
4390 @DocsEditable() | |
4391 Range createRange() { | |
4392 return _createRange_1(); | |
4393 } | |
4394 @JSName('createRange') | |
4395 @DomName('Document.createRange') | |
4396 @DocsEditable() | |
4397 Range _createRange_1() => wrap_jso(JS("Range ", "#.raw.createRange()", this)); | |
4398 | |
4399 @DomName('Document.createTextNode') | |
4400 @DocsEditable() | |
4401 Text _createTextNode(String data) { | |
4402 return _createTextNode_1(data); | |
4403 } | |
4404 @JSName('createTextNode') | |
4405 @DomName('Document.createTextNode') | |
4406 @DocsEditable() | |
4407 Text _createTextNode_1(data) => wrap_jso(JS("Text ", "#.raw.createTextNode(#)"
, this, unwrap_jso(data))); | |
4408 | |
4409 @DomName('Document.elementFromPoint') | |
4410 @DocsEditable() | |
4411 Element _elementFromPoint(int x, int y) { | |
4412 return _elementFromPoint_1(x, y); | |
4413 } | |
4414 @JSName('elementFromPoint') | |
4415 @DomName('Document.elementFromPoint') | |
4416 @DocsEditable() | |
4417 Element _elementFromPoint_1(x, y) => wrap_jso(JS("Element ", "#.raw.elementFro
mPoint(#, #)", this, unwrap_jso(x), unwrap_jso(y))); | |
4418 | |
4419 @DomName('Document.execCommand') | |
4420 @DocsEditable() | |
4421 bool execCommand(String command, bool userInterface, String value) { | |
4422 return _execCommand_1(command, userInterface, value); | |
4423 } | |
4424 @JSName('execCommand') | |
4425 @DomName('Document.execCommand') | |
4426 @DocsEditable() | |
4427 bool _execCommand_1(command, userInterface, value) => wrap_jso(JS("bool ", "#.
raw.execCommand(#, #, #)", this, unwrap_jso(command), unwrap_jso(userInterface),
unwrap_jso(value))); | |
4428 | |
4429 @DomName('Document.exitFullscreen') | |
4430 @DocsEditable() | |
4431 @Experimental() // untriaged | |
4432 void exitFullscreen() { | |
4433 _exitFullscreen_1(); | |
4434 return; | |
4435 } | |
4436 @JSName('exitFullscreen') | |
4437 @DomName('Document.exitFullscreen') | |
4438 @DocsEditable() | |
4439 @Experimental() // untriaged | |
4440 void _exitFullscreen_1() => wrap_jso(JS("void ", "#.raw.exitFullscreen()", thi
s)); | |
4441 | |
4442 @DomName('Document.exitPointerLock') | |
4443 @DocsEditable() | |
4444 @Experimental() // untriaged | |
4445 void exitPointerLock() { | |
4446 _exitPointerLock_1(); | |
4447 return; | |
4448 } | |
4449 @JSName('exitPointerLock') | |
4450 @DomName('Document.exitPointerLock') | |
4451 @DocsEditable() | |
4452 @Experimental() // untriaged | |
4453 void _exitPointerLock_1() => wrap_jso(JS("void ", "#.raw.exitPointerLock()", t
his)); | |
4454 | |
4455 @DomName('Document.getCSSCanvasContext') | |
4456 @DocsEditable() | |
4457 // https://developer.apple.com/library/safari/#documentation/AppleApplications
/Reference/SafariCSSRef/Articles/Functions.html | |
4458 @Experimental() // non-standard | |
4459 Object _getCssCanvasContext(String contextId, String name, int width, int heig
ht) { | |
4460 return _getCssCanvasContext_1(contextId, name, width, height); | |
4461 } | |
4462 @JSName('getCSSCanvasContext') | |
4463 @DomName('Document.getCSSCanvasContext') | |
4464 @DocsEditable() | |
4465 // https://developer.apple.com/library/safari/#documentation/AppleApplications
/Reference/SafariCSSRef/Articles/Functions.html | |
4466 @Experimental() // non-standard | |
4467 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))); | |
4468 | |
4469 @DomName('Document.getElementById') | |
4470 @DocsEditable() | |
4471 Element getElementById(String elementId) { | |
4472 return _getElementById_1(elementId); | |
4473 } | |
4474 @JSName('getElementById') | |
4475 @DomName('Document.getElementById') | |
4476 @DocsEditable() | |
4477 Element _getElementById_1(elementId) => wrap_jso(JS("Element ", "#.raw.getElem
entById(#)", this, unwrap_jso(elementId))); | |
4478 | |
4479 @DomName('Document.getElementsByClassName') | |
4480 @DocsEditable() | |
4481 @Creates('NodeList|HtmlCollection') | |
4482 @Returns('NodeList|HtmlCollection') | |
4483 HtmlCollection getElementsByClassName(String classNames) { | |
4484 return _getElementsByClassName_1(classNames); | |
4485 } | |
4486 @JSName('getElementsByClassName') | |
4487 @DomName('Document.getElementsByClassName') | |
4488 @DocsEditable() | |
4489 @Creates('NodeList|HtmlCollection') | |
4490 @Returns('NodeList|HtmlCollection') | |
4491 HtmlCollection _getElementsByClassName_1(classNames) => wrap_jso(JS("HtmlColle
ction ", "#.raw.getElementsByClassName(#)", this, unwrap_jso(classNames))); | |
4492 | |
4493 @DomName('Document.getElementsByName') | |
4494 @DocsEditable() | |
4495 @Creates('NodeList|HtmlCollection') | |
4496 @Returns('NodeList|HtmlCollection') | |
4497 NodeList getElementsByName(String elementName) { | |
4498 return _getElementsByName_1(elementName); | |
4499 } | |
4500 @JSName('getElementsByName') | |
4501 @DomName('Document.getElementsByName') | |
4502 @DocsEditable() | |
4503 @Creates('NodeList|HtmlCollection') | |
4504 @Returns('NodeList|HtmlCollection') | |
4505 NodeList _getElementsByName_1(elementName) => wrap_jso(JS("NodeList ", "#.raw.
getElementsByName(#)", this, unwrap_jso(elementName))); | |
4506 | |
4507 @DomName('Document.getElementsByTagName') | |
4508 @DocsEditable() | |
4509 @Creates('NodeList|HtmlCollection') | |
4510 @Returns('NodeList|HtmlCollection') | |
4511 HtmlCollection getElementsByTagName(String localName) { | |
4512 return _getElementsByTagName_1(localName); | |
4513 } | |
4514 @JSName('getElementsByTagName') | |
4515 @DomName('Document.getElementsByTagName') | |
4516 @DocsEditable() | |
4517 @Creates('NodeList|HtmlCollection') | |
4518 @Returns('NodeList|HtmlCollection') | |
4519 HtmlCollection _getElementsByTagName_1(localName) => wrap_jso(JS("HtmlCollecti
on ", "#.raw.getElementsByTagName(#)", this, unwrap_jso(localName))); | |
4520 | |
4521 @DomName('Document.importNode') | |
4522 @DocsEditable() | |
4523 Node importNode(Node node, [bool deep]) { | |
4524 if (deep != null) { | |
4525 return _importNode_1(node, deep); | |
4526 } | |
4527 return _importNode_2(node); | |
4528 } | |
4529 @JSName('importNode') | |
4530 @DomName('Document.importNode') | |
4531 @DocsEditable() | |
4532 Node _importNode_1(Node node, deep) => wrap_jso(JS("Node ", "#.raw.importNode(
#, #)", this, unwrap_jso(node), unwrap_jso(deep))); | |
4533 @JSName('importNode') | |
4534 @DomName('Document.importNode') | |
4535 @DocsEditable() | |
4536 Node _importNode_2(Node node) => wrap_jso(JS("Node ", "#.raw.importNode(#)", t
his, unwrap_jso(node))); | |
4537 | |
4538 @DomName('Document.queryCommandEnabled') | |
4539 @DocsEditable() | |
4540 bool queryCommandEnabled(String command) { | |
4541 return _queryCommandEnabled_1(command); | |
4542 } | |
4543 @JSName('queryCommandEnabled') | |
4544 @DomName('Document.queryCommandEnabled') | |
4545 @DocsEditable() | |
4546 bool _queryCommandEnabled_1(command) => wrap_jso(JS("bool ", "#.raw.queryComma
ndEnabled(#)", this, unwrap_jso(command))); | |
4547 | |
4548 @DomName('Document.queryCommandIndeterm') | |
4549 @DocsEditable() | |
4550 bool queryCommandIndeterm(String command) { | |
4551 return _queryCommandIndeterm_1(command); | |
4552 } | |
4553 @JSName('queryCommandIndeterm') | |
4554 @DomName('Document.queryCommandIndeterm') | |
4555 @DocsEditable() | |
4556 bool _queryCommandIndeterm_1(command) => wrap_jso(JS("bool ", "#.raw.queryComm
andIndeterm(#)", this, unwrap_jso(command))); | |
4557 | |
4558 @DomName('Document.queryCommandState') | |
4559 @DocsEditable() | |
4560 bool queryCommandState(String command) { | |
4561 return _queryCommandState_1(command); | |
4562 } | |
4563 @JSName('queryCommandState') | |
4564 @DomName('Document.queryCommandState') | |
4565 @DocsEditable() | |
4566 bool _queryCommandState_1(command) => wrap_jso(JS("bool ", "#.raw.queryCommand
State(#)", this, unwrap_jso(command))); | |
4567 | |
4568 @DomName('Document.queryCommandSupported') | |
4569 @DocsEditable() | |
4570 bool queryCommandSupported(String command) { | |
4571 return _queryCommandSupported_1(command); | |
4572 } | |
4573 @JSName('queryCommandSupported') | |
4574 @DomName('Document.queryCommandSupported') | |
4575 @DocsEditable() | |
4576 bool _queryCommandSupported_1(command) => wrap_jso(JS("bool ", "#.raw.queryCom
mandSupported(#)", this, unwrap_jso(command))); | |
4577 | |
4578 @DomName('Document.queryCommandValue') | |
4579 @DocsEditable() | |
4580 String queryCommandValue(String command) { | |
4581 return _queryCommandValue_1(command); | |
4582 } | |
4583 @JSName('queryCommandValue') | |
4584 @DomName('Document.queryCommandValue') | |
4585 @DocsEditable() | |
4586 String _queryCommandValue_1(command) => wrap_jso(JS("String ", "#.raw.queryCom
mandValue(#)", this, unwrap_jso(command))); | |
4587 | |
4588 @DomName('Document.transformDocumentToTreeView') | |
4589 @DocsEditable() | |
4590 @Experimental() // untriaged | |
4591 void transformDocumentToTreeView(String noStyleMessage) { | |
4592 _transformDocumentToTreeView_1(noStyleMessage); | |
4593 return; | |
4594 } | |
4595 @JSName('transformDocumentToTreeView') | |
4596 @DomName('Document.transformDocumentToTreeView') | |
4597 @DocsEditable() | |
4598 @Experimental() // untriaged | |
4599 void _transformDocumentToTreeView_1(noStyleMessage) => wrap_jso(JS("void ", "#
.raw.transformDocumentToTreeView(#)", this, unwrap_jso(noStyleMessage))); | |
4600 | |
4601 @DomName('Document.webkitExitFullscreen') | |
4602 @DocsEditable() | |
4603 @SupportedBrowser(SupportedBrowser.CHROME) | |
4604 @SupportedBrowser(SupportedBrowser.SAFARI) | |
4605 @Experimental() | |
4606 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#dom-document-e
xitfullscreen | |
4607 void _webkitExitFullscreen() { | |
4608 _webkitExitFullscreen_1(); | |
4609 return; | |
4610 } | |
4611 @JSName('webkitExitFullscreen') | |
4612 @DomName('Document.webkitExitFullscreen') | |
4613 @DocsEditable() | |
4614 @SupportedBrowser(SupportedBrowser.CHROME) | |
4615 @SupportedBrowser(SupportedBrowser.SAFARI) | |
4616 @Experimental() | |
4617 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#dom-document-e
xitfullscreen | |
4618 void _webkitExitFullscreen_1() => wrap_jso(JS("void ", "#.raw.webkitExitFullsc
reen()", this)); | |
4619 | |
4620 // From ParentNode | |
4621 | |
4622 @JSName('childElementCount') | |
4623 @DomName('Document.childElementCount') | |
4624 @DocsEditable() | |
4625 int get _childElementCount => wrap_jso(JS("int", "#.childElementCount", this.r
aw)); | |
4626 | |
4627 @JSName('children') | |
4628 @DomName('Document.children') | |
4629 @DocsEditable() | |
4630 @Returns('HtmlCollection') | |
4631 @Creates('HtmlCollection') | |
4632 List<Node> get _children => wrap_jso(JS("List<Node>", "#.children", this.raw))
; | |
4633 | |
4634 @JSName('firstElementChild') | |
4635 @DomName('Document.firstElementChild') | |
4636 @DocsEditable() | |
4637 Element get _firstElementChild => wrap_jso(JS("Element", "#.firstElementChild"
, this.raw)); | |
4638 | |
4639 @JSName('lastElementChild') | |
4640 @DomName('Document.lastElementChild') | |
4641 @DocsEditable() | |
4642 Element get _lastElementChild => wrap_jso(JS("Element", "#.lastElementChild",
this.raw)); | |
4643 | |
4644 /** | |
4645 * Finds the first descendant element of this document that matches the | |
4646 * specified group of selectors. | |
4647 * | |
4648 * Unless your webpage contains multiple documents, the top-level | |
4649 * [querySelector] | |
4650 * method behaves the same as this method, so you should use it instead to | |
4651 * save typing a few characters. | |
4652 * | |
4653 * [selectors] should be a string using CSS selector syntax. | |
4654 * | |
4655 * var element1 = document.querySelector('.className'); | |
4656 * var element2 = document.querySelector('#id'); | |
4657 * | |
4658 * For details about CSS selector syntax, see the | |
4659 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
4660 */ | |
4661 @DomName('Document.querySelector') | |
4662 @DocsEditable() | |
4663 Element querySelector(String selectors) { | |
4664 return _querySelector_1(selectors); | |
4665 } | |
4666 @JSName('querySelector') | |
4667 /** | |
4668 * Finds the first descendant element of this document that matches the | |
4669 * specified group of selectors. | |
4670 * | |
4671 * Unless your webpage contains multiple documents, the top-level | |
4672 * [querySelector] | |
4673 * method behaves the same as this method, so you should use it instead to | |
4674 * save typing a few characters. | |
4675 * | |
4676 * [selectors] should be a string using CSS selector syntax. | |
4677 * | |
4678 * var element1 = document.querySelector('.className'); | |
4679 * var element2 = document.querySelector('#id'); | |
4680 * | |
4681 * For details about CSS selector syntax, see the | |
4682 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
4683 */ | |
4684 @DomName('Document.querySelector') | |
4685 @DocsEditable() | |
4686 Element _querySelector_1(selectors) => wrap_jso(JS("Element ", "#.raw.querySel
ector(#)", this, unwrap_jso(selectors))); | |
4687 | |
4688 @DomName('Document.querySelectorAll') | |
4689 @DocsEditable() | |
4690 @Returns('NodeList') | |
4691 @Creates('NodeList') | |
4692 NodeList _querySelectorAll(String selectors) { | |
4693 return _querySelectorAll_1(selectors); | |
4694 } | |
4695 @JSName('querySelectorAll') | |
4696 @DomName('Document.querySelectorAll') | |
4697 @DocsEditable() | |
4698 @Returns('NodeList') | |
4699 @Creates('NodeList') | |
4700 NodeList _querySelectorAll_1(selectors) => wrap_jso(JS("NodeList ", "#.raw.que
rySelectorAll(#)", this, unwrap_jso(selectors))); | |
4701 | |
4702 /// Stream of `beforecopy` events handled by this [Document]. | |
4703 @DomName('Document.onbeforecopy') | |
4704 @DocsEditable() | |
4705 Stream<Event> get onBeforeCopy => Element.beforeCopyEvent.forTarget(this); | |
4706 | |
4707 /// Stream of `beforecut` events handled by this [Document]. | |
4708 @DomName('Document.onbeforecut') | |
4709 @DocsEditable() | |
4710 Stream<Event> get onBeforeCut => Element.beforeCutEvent.forTarget(this); | |
4711 | |
4712 /// Stream of `beforepaste` events handled by this [Document]. | |
4713 @DomName('Document.onbeforepaste') | |
4714 @DocsEditable() | |
4715 Stream<Event> get onBeforePaste => Element.beforePasteEvent.forTarget(this); | |
4716 | |
4717 /// Stream of `copy` events handled by this [Document]. | |
4718 @DomName('Document.oncopy') | |
4719 @DocsEditable() | |
4720 Stream<Event> get onCopy => Element.copyEvent.forTarget(this); | |
4721 | |
4722 /// Stream of `cut` events handled by this [Document]. | |
4723 @DomName('Document.oncut') | |
4724 @DocsEditable() | |
4725 Stream<Event> get onCut => Element.cutEvent.forTarget(this); | |
4726 | |
4727 /// Stream of `paste` events handled by this [Document]. | |
4728 @DomName('Document.onpaste') | |
4729 @DocsEditable() | |
4730 Stream<Event> get onPaste => Element.pasteEvent.forTarget(this); | |
4731 | |
4732 @DomName('Document.onpointerlockchange') | |
4733 @DocsEditable() | |
4734 @Experimental() // untriaged | |
4735 Stream<Event> get onPointerLockChange => pointerLockChangeEvent.forTarget(this
); | |
4736 | |
4737 @DomName('Document.onpointerlockerror') | |
4738 @DocsEditable() | |
4739 @Experimental() // untriaged | |
4740 Stream<Event> get onPointerLockError => pointerLockErrorEvent.forTarget(this); | |
4741 | |
4742 /// Stream of `readystatechange` events handled by this [Document]. | |
4743 @DomName('Document.onreadystatechange') | |
4744 @DocsEditable() | |
4745 Stream<Event> get onReadyStateChange => readyStateChangeEvent.forTarget(this); | |
4746 | |
4747 /// Stream of `search` events handled by this [Document]. | |
4748 @DomName('Document.onsearch') | |
4749 @DocsEditable() | |
4750 // http://www.w3.org/TR/html-markup/input.search.html | |
4751 @Experimental() | |
4752 Stream<Event> get onSearch => Element.searchEvent.forTarget(this); | |
4753 | |
4754 /// Stream of `selectionchange` events handled by this [Document]. | |
4755 @DomName('Document.onselectionchange') | |
4756 @DocsEditable() | |
4757 Stream<Event> get onSelectionChange => selectionChangeEvent.forTarget(this); | |
4758 | |
4759 /// Stream of `selectstart` events handled by this [Document]. | |
4760 @DomName('Document.onselectstart') | |
4761 @DocsEditable() | |
4762 Stream<Event> get onSelectStart => Element.selectStartEvent.forTarget(this); | |
4763 | |
4764 /// Stream of `fullscreenchange` events handled by this [Document]. | |
4765 @DomName('Document.onwebkitfullscreenchange') | |
4766 @DocsEditable() | |
4767 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html | |
4768 @Experimental() | |
4769 Stream<Event> get onFullscreenChange => Element.fullscreenChangeEvent.forTarge
t(this); | |
4770 | |
4771 /// Stream of `fullscreenerror` events handled by this [Document]. | |
4772 @DomName('Document.onwebkitfullscreenerror') | |
4773 @DocsEditable() | |
4774 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html | |
4775 @Experimental() | |
4776 Stream<Event> get onFullscreenError => Element.fullscreenErrorEvent.forTarget(
this); | |
4777 | |
4778 /** | |
4779 * Finds all descendant elements of this document that match the specified | |
4780 * group of selectors. | |
4781 * | |
4782 * Unless your webpage contains multiple documents, the top-level | |
4783 * [querySelectorAll] | |
4784 * method behaves the same as this method, so you should use it instead to | |
4785 * save typing a few characters. | |
4786 * | |
4787 * [selectors] should be a string using CSS selector syntax. | |
4788 * | |
4789 * var items = document.querySelectorAll('.itemClassName'); | |
4790 * | |
4791 * For details about CSS selector syntax, see the | |
4792 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
4793 */ | |
4794 ElementList<Element> querySelectorAll(String selectors) { | |
4795 return new _FrozenElementList._wrap(_querySelectorAll(selectors)); | |
4796 } | |
4797 | |
4798 /** | |
4799 * Alias for [querySelector]. Note this function is deprecated because its | |
4800 * semantics will be changing in the future. | |
4801 */ | |
4802 @deprecated | |
4803 @Experimental() | |
4804 @DomName('Document.querySelector') | |
4805 Element query(String relativeSelectors) => querySelector(relativeSelectors); | |
4806 | |
4807 /** | |
4808 * Alias for [querySelectorAll]. Note this function is deprecated because its | |
4809 * semantics will be changing in the future. | |
4810 */ | |
4811 @deprecated | |
4812 @Experimental() | |
4813 @DomName('Document.querySelectorAll') | |
4814 ElementList<Element> queryAll(String relativeSelectors) => | |
4815 querySelectorAll(relativeSelectors); | |
4816 | |
4817 /// Checks if [registerElement] is supported on the current platform. | |
4818 bool get supportsRegisterElement { | |
4819 return true; | |
4820 } | |
4821 | |
4822 /// *Deprecated*: use [supportsRegisterElement] instead. | |
4823 @deprecated | |
4824 bool get supportsRegister => supportsRegisterElement; | |
4825 | |
4826 @DomName('Document.createElement') | |
4827 Element createElement(String tagName, [String typeExtension]) { | |
4828 return _createElement(tagName, typeExtension); | |
4829 } | |
4830 | |
4831 @DomName('Document.createElementNS') | |
4832 @DocsEditable() | |
4833 Element createElementNS(String namespaceURI, String qualifiedName, [String typ
eExtension]) { | |
4834 return _createElementNS(namespaceURI, qualifiedName, typeExtension); | |
4835 } | |
4836 | |
4837 } | |
4838 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
4839 // for details. All rights reserved. Use of this source code is governed by a | |
4840 // BSD-style license that can be found in the LICENSE file. | |
4841 | |
4842 | |
4843 @DomName('DocumentFragment') | |
4844 @Native("DocumentFragment") | |
4845 class DocumentFragment extends Node implements ParentNode { | |
4846 factory DocumentFragment() => document.createDocumentFragment(); | |
4847 | |
4848 factory DocumentFragment.html(String html, | |
4849 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | |
4850 | |
4851 return document.body.createFragment(html, | |
4852 validator: validator, treeSanitizer: treeSanitizer); | |
4853 } | |
4854 | |
4855 factory DocumentFragment.svg(String svgContent, | |
4856 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | |
4857 throw 'SVG not supported in DDC'; | |
4858 } | |
4859 | |
4860 HtmlCollection get _children => throw new UnimplementedError( | |
4861 'Use _docChildren instead'); | |
4862 | |
4863 List<Element> _docChildren; | |
4864 | |
4865 List<Element> get children { | |
4866 if (_docChildren == null) { | |
4867 _docChildren = new FilteredElementList(this); | |
4868 } | |
4869 return _docChildren; | |
4870 } | |
4871 | |
4872 set children(List<Element> value) { | |
4873 // Copy list first since we don't want liveness during iteration. | |
4874 List copy = new List.from(value); | |
4875 var children = this.children; | |
4876 children.clear(); | |
4877 children.addAll(copy); | |
4878 } | |
4879 | |
4880 /** | |
4881 * Finds all descendant elements of this document fragment that match the | |
4882 * specified group of selectors. | |
4883 * | |
4884 * [selectors] should be a string using CSS selector syntax. | |
4885 * | |
4886 * var items = document.querySelectorAll('.itemClassName'); | |
4887 * | |
4888 * For details about CSS selector syntax, see the | |
4889 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
4890 */ | |
4891 ElementList<Element> querySelectorAll(String selectors) => | |
4892 new _FrozenElementList._wrap(_querySelectorAll(selectors)); | |
4893 | |
4894 String get innerHtml { | |
4895 final e = new Element.tag("div"); | |
4896 e.append(this.clone(true)); | |
4897 return e.innerHtml; | |
4898 } | |
4899 | |
4900 set innerHtml(String value) { | |
4901 this.setInnerHtml(value); | |
4902 } | |
4903 | |
4904 void setInnerHtml(String html, | |
4905 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | |
4906 | |
4907 this.nodes.clear(); | |
4908 append(document.body.createFragment( | |
4909 html, validator: validator, treeSanitizer: treeSanitizer)); | |
4910 } | |
4911 | |
4912 /** | |
4913 * Adds the specified text as a text node after the last child of this | |
4914 * document fragment. | |
4915 */ | |
4916 void appendText(String text) { | |
4917 this.append(new Text(text)); | |
4918 } | |
4919 | |
4920 | |
4921 /** | |
4922 * Parses the specified text as HTML and adds the resulting node after the | |
4923 * last child of this document fragment. | |
4924 */ | |
4925 void appendHtml(String text, {NodeValidator validator, | |
4926 NodeTreeSanitizer, treeSanitizer}) { | |
4927 this.append(new DocumentFragment.html(text, validator: validator, | |
4928 treeSanitizer: treeSanitizer)); | |
4929 } | |
4930 | |
4931 /** | |
4932 * Alias for [querySelector]. Note this function is deprecated because its | |
4933 * semantics will be changing in the future. | |
4934 */ | |
4935 @deprecated | |
4936 @Experimental() | |
4937 @DomName('DocumentFragment.querySelector') | |
4938 Element query(String relativeSelectors) { | |
4939 return querySelector(relativeSelectors); | |
4940 } | |
4941 | |
4942 /** | |
4943 * Alias for [querySelectorAll]. Note this function is deprecated because its | |
4944 * semantics will be changing in the future. | |
4945 */ | |
4946 @deprecated | |
4947 @Experimental() | |
4948 @DomName('DocumentFragment.querySelectorAll') | |
4949 ElementList<Element> queryAll(String relativeSelectors) { | |
4950 return querySelectorAll(relativeSelectors); | |
4951 } | |
4952 // To suppress missing implicit constructor warnings. | |
4953 factory DocumentFragment._() { throw new UnsupportedError("Not supported"); } | |
4954 | |
4955 | |
4956 @Deprecated("Internal Use Only") | |
4957 static DocumentFragment internalCreateDocumentFragment() { | |
4958 return new DocumentFragment.internal_(); | |
4959 } | |
4960 | |
4961 @Deprecated("Internal Use Only") | |
4962 DocumentFragment.internal_() : super.internal_(); | |
4963 | |
4964 | |
4965 @DomName('DocumentFragment.getElementById') | |
4966 @DocsEditable() | |
4967 @Experimental() // untriaged | |
4968 Element getElementById(String elementId) { | |
4969 return _getElementById_1(elementId); | |
4970 } | |
4971 @JSName('getElementById') | |
4972 @DomName('DocumentFragment.getElementById') | |
4973 @DocsEditable() | |
4974 @Experimental() // untriaged | |
4975 Element _getElementById_1(elementId) => wrap_jso(JS("Element ", "#.raw.getElem
entById(#)", this, unwrap_jso(elementId))); | |
4976 | |
4977 // From ParentNode | |
4978 | |
4979 @JSName('childElementCount') | |
4980 @DomName('DocumentFragment.childElementCount') | |
4981 @DocsEditable() | |
4982 int get _childElementCount => wrap_jso(JS("int", "#.childElementCount", this.r
aw)); | |
4983 | |
4984 @JSName('firstElementChild') | |
4985 @DomName('DocumentFragment.firstElementChild') | |
4986 @DocsEditable() | |
4987 Element get _firstElementChild => wrap_jso(JS("Element", "#.firstElementChild"
, this.raw)); | |
4988 | |
4989 @JSName('lastElementChild') | |
4990 @DomName('DocumentFragment.lastElementChild') | |
4991 @DocsEditable() | |
4992 Element get _lastElementChild => wrap_jso(JS("Element", "#.lastElementChild",
this.raw)); | |
4993 | |
4994 /** | |
4995 * Finds the first descendant element of this document fragment that matches | |
4996 * the specified group of selectors. | |
4997 * | |
4998 * [selectors] should be a string using CSS selector syntax. | |
4999 * | |
5000 * var element1 = fragment.querySelector('.className'); | |
5001 * var element2 = fragment.querySelector('#id'); | |
5002 * | |
5003 * For details about CSS selector syntax, see the | |
5004 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
5005 */ | |
5006 @DomName('DocumentFragment.querySelector') | |
5007 @DocsEditable() | |
5008 Element querySelector(String selectors) { | |
5009 return _querySelector_1(selectors); | |
5010 } | |
5011 @JSName('querySelector') | |
5012 /** | |
5013 * Finds the first descendant element of this document fragment that matches | |
5014 * the specified group of selectors. | |
5015 * | |
5016 * [selectors] should be a string using CSS selector syntax. | |
5017 * | |
5018 * var element1 = fragment.querySelector('.className'); | |
5019 * var element2 = fragment.querySelector('#id'); | |
5020 * | |
5021 * For details about CSS selector syntax, see the | |
5022 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
5023 */ | |
5024 @DomName('DocumentFragment.querySelector') | |
5025 @DocsEditable() | |
5026 Element _querySelector_1(selectors) => wrap_jso(JS("Element ", "#.raw.querySel
ector(#)", this, unwrap_jso(selectors))); | |
5027 | |
5028 @DomName('DocumentFragment.querySelectorAll') | |
5029 @DocsEditable() | |
5030 @Returns('NodeList') | |
5031 @Creates('NodeList') | |
5032 NodeList _querySelectorAll(String selectors) { | |
5033 return _querySelectorAll_1(selectors); | |
5034 } | |
5035 @JSName('querySelectorAll') | |
5036 @DomName('DocumentFragment.querySelectorAll') | |
5037 @DocsEditable() | |
5038 @Returns('NodeList') | |
5039 @Creates('NodeList') | |
5040 NodeList _querySelectorAll_1(selectors) => wrap_jso(JS("NodeList ", "#.raw.que
rySelectorAll(#)", this, unwrap_jso(selectors))); | |
5041 | |
5042 } | |
5043 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
5044 // for details. All rights reserved. Use of this source code is governed by a | |
5045 // BSD-style license that can be found in the LICENSE file. | |
5046 | |
5047 | |
5048 @DocsEditable() | |
5049 @DomName('DOMImplementation') | |
5050 @Native("DOMImplementation") | |
5051 class DomImplementation extends DartHtmlDomObject { | |
5052 // To suppress missing implicit constructor warnings. | |
5053 factory DomImplementation._() { throw new UnsupportedError("Not supported"); } | |
5054 | |
5055 @Deprecated("Internal Use Only") | |
5056 static DomImplementation internalCreateDomImplementation() { | |
5057 return new DomImplementation.internal_(); | |
5058 } | |
5059 | |
5060 @Deprecated("Internal Use Only") | |
5061 DomImplementation.internal_() { } | |
5062 | |
5063 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
5064 int get hashCode => unwrap_jso(this).hashCode; | |
5065 | |
5066 @DomName('DOMImplementation.createDocument') | |
5067 @DocsEditable() | |
5068 Document createDocument(String namespaceURI, String qualifiedName, Node doctyp
e) { | |
5069 return _createDocument_1(namespaceURI, qualifiedName, doctype); | |
5070 } | |
5071 @JSName('createDocument') | |
5072 @DomName('DOMImplementation.createDocument') | |
5073 @DocsEditable() | |
5074 Document _createDocument_1(namespaceURI, qualifiedName, Node doctype) => wrap_
jso(JS("Document ", "#.raw.createDocument(#, #, #)", this, unwrap_jso(namespaceU
RI), unwrap_jso(qualifiedName), unwrap_jso(doctype))); | |
5075 | |
5076 @DomName('DOMImplementation.createDocumentType') | |
5077 @DocsEditable() | |
5078 Node createDocumentType(String qualifiedName, String publicId, String systemId
) { | |
5079 return _createDocumentType_1(qualifiedName, publicId, systemId); | |
5080 } | |
5081 @JSName('createDocumentType') | |
5082 @DomName('DOMImplementation.createDocumentType') | |
5083 @DocsEditable() | |
5084 Node _createDocumentType_1(qualifiedName, publicId, systemId) => wrap_jso(JS("
Node ", "#.raw.createDocumentType(#, #, #)", this, unwrap_jso(qualifiedName), un
wrap_jso(publicId), unwrap_jso(systemId))); | |
5085 | |
5086 @DomName('DOMImplementation.createHTMLDocument') | |
5087 @DocsEditable() | |
5088 HtmlDocument createHtmlDocument(String title) { | |
5089 return _createHtmlDocument_1(title); | |
5090 } | |
5091 @JSName('createHTMLDocument') | |
5092 @DomName('DOMImplementation.createHTMLDocument') | |
5093 @DocsEditable() | |
5094 HtmlDocument _createHtmlDocument_1(title) => wrap_jso(JS("HtmlDocument ", "#.r
aw.createHTMLDocument(#)", this, unwrap_jso(title))); | |
5095 | |
5096 @DomName('DOMImplementation.hasFeature') | |
5097 @DocsEditable() | |
5098 bool hasFeature(String feature, String version) { | |
5099 return _hasFeature_1(feature, version); | |
5100 } | |
5101 @JSName('hasFeature') | |
5102 @DomName('DOMImplementation.hasFeature') | |
5103 @DocsEditable() | |
5104 bool _hasFeature_1(feature, version) => wrap_jso(JS("bool ", "#.raw.hasFeature
(#, #)", this, unwrap_jso(feature), unwrap_jso(version))); | |
5105 } | |
5106 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
5107 // for details. All rights reserved. Use of this source code is governed by a | |
5108 // BSD-style license that can be found in the LICENSE file. | |
5109 | |
5110 | |
5111 @DocsEditable() | |
5112 @DomName('DOMTokenList') | |
5113 @Native("DOMTokenList") | |
5114 class DomTokenList extends DartHtmlDomObject { | |
5115 // To suppress missing implicit constructor warnings. | |
5116 factory DomTokenList._() { throw new UnsupportedError("Not supported"); } | |
5117 | |
5118 @Deprecated("Internal Use Only") | |
5119 static DomTokenList internalCreateDomTokenList() { | |
5120 return new DomTokenList.internal_(); | |
5121 } | |
5122 | |
5123 @Deprecated("Internal Use Only") | |
5124 DomTokenList.internal_() { } | |
5125 | |
5126 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
5127 int get hashCode => unwrap_jso(this).hashCode; | |
5128 | |
5129 @DomName('DOMTokenList.length') | |
5130 @DocsEditable() | |
5131 int get length => wrap_jso(JS("int", "#.length", this.raw)); | |
5132 | |
5133 @DomName('DOMTokenList.add') | |
5134 @DocsEditable() | |
5135 @Experimental() // untriaged | |
5136 void add(String tokens) { | |
5137 _add_1(tokens); | |
5138 return; | |
5139 } | |
5140 @JSName('add') | |
5141 @DomName('DOMTokenList.add') | |
5142 @DocsEditable() | |
5143 @Experimental() // untriaged | |
5144 void _add_1(tokens) => wrap_jso(JS("void ", "#.raw.add(#)", this, unwrap_jso(t
okens))); | |
5145 | |
5146 @DomName('DOMTokenList.contains') | |
5147 @DocsEditable() | |
5148 bool contains(String token) { | |
5149 return _contains_1(token); | |
5150 } | |
5151 @JSName('contains') | |
5152 @DomName('DOMTokenList.contains') | |
5153 @DocsEditable() | |
5154 bool _contains_1(token) => wrap_jso(JS("bool ", "#.raw.contains(#)", this, unw
rap_jso(token))); | |
5155 | |
5156 @DomName('DOMTokenList.item') | |
5157 @DocsEditable() | |
5158 String item(int index) { | |
5159 return _item_1(index); | |
5160 } | |
5161 @JSName('item') | |
5162 @DomName('DOMTokenList.item') | |
5163 @DocsEditable() | |
5164 String _item_1(index) => wrap_jso(JS("String ", "#.raw.item(#)", this, unwrap_
jso(index))); | |
5165 | |
5166 @DomName('DOMTokenList.remove') | |
5167 @DocsEditable() | |
5168 @Experimental() // untriaged | |
5169 void remove(String tokens) { | |
5170 _remove_1(tokens); | |
5171 return; | |
5172 } | |
5173 @JSName('remove') | |
5174 @DomName('DOMTokenList.remove') | |
5175 @DocsEditable() | |
5176 @Experimental() // untriaged | |
5177 void _remove_1(tokens) => wrap_jso(JS("void ", "#.raw.remove(#)", this, unwrap
_jso(tokens))); | |
5178 | |
5179 @DomName('DOMTokenList.toggle') | |
5180 @DocsEditable() | |
5181 bool toggle(String token, [bool force]) { | |
5182 if (force != null) { | |
5183 return _toggle_1(token, force); | |
5184 } | |
5185 return _toggle_2(token); | |
5186 } | |
5187 @JSName('toggle') | |
5188 @DomName('DOMTokenList.toggle') | |
5189 @DocsEditable() | |
5190 bool _toggle_1(token, force) => wrap_jso(JS("bool ", "#.raw.toggle(#, #)", thi
s, unwrap_jso(token), unwrap_jso(force))); | |
5191 @JSName('toggle') | |
5192 @DomName('DOMTokenList.toggle') | |
5193 @DocsEditable() | |
5194 bool _toggle_2(token) => wrap_jso(JS("bool ", "#.raw.toggle(#)", this, unwrap_
jso(token))); | |
5195 } | |
5196 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
5197 // for details. All rights reserved. Use of this source code is governed by a | |
5198 // BSD-style license that can be found in the LICENSE file. | |
5199 | |
5200 | |
5201 class _ChildrenElementList extends ListBase<Element> | |
5202 implements NodeListWrapper { | |
5203 // Raw Element. | |
5204 final Element _element; | |
5205 final HtmlCollection _childElements; | |
5206 | |
5207 _ChildrenElementList._wrap(Element element) | |
5208 : _childElements = element._children, | |
5209 _element = element; | |
5210 | |
5211 bool contains(Object element) => _childElements.contains(element); | |
5212 | |
5213 | |
5214 bool get isEmpty { | |
5215 return _element._firstElementChild == null; | |
5216 } | |
5217 | |
5218 int get length { | |
5219 return _childElements.length; | |
5220 } | |
5221 | |
5222 Element operator [](int index) { | |
5223 return _childElements[index]; | |
5224 } | |
5225 | |
5226 void operator []=(int index, Element value) { | |
5227 _element._replaceChild(value, _childElements[index]); | |
5228 } | |
5229 | |
5230 set length(int newLength) { | |
5231 // TODO(jacobr): remove children when length is reduced. | |
5232 throw new UnsupportedError('Cannot resize element lists'); | |
5233 } | |
5234 | |
5235 Element add(Element value) { | |
5236 _element.append(value); | |
5237 return value; | |
5238 } | |
5239 | |
5240 Iterator<Element> get iterator => toList().iterator; | |
5241 | |
5242 void addAll(Iterable<Element> iterable) { | |
5243 if (iterable is _ChildNodeListLazy) { | |
5244 iterable = new List.from(iterable); | |
5245 } | |
5246 | |
5247 for (Element element in iterable) { | |
5248 _element.append(element); | |
5249 } | |
5250 } | |
5251 | |
5252 void sort([int compare(Element a, Element b)]) { | |
5253 throw new UnsupportedError('Cannot sort element lists'); | |
5254 } | |
5255 | |
5256 void shuffle([Random random]) { | |
5257 throw new UnsupportedError('Cannot shuffle element lists'); | |
5258 } | |
5259 | |
5260 void removeWhere(bool test(Element element)) { | |
5261 _filter(test, false); | |
5262 } | |
5263 | |
5264 void retainWhere(bool test(Element element)) { | |
5265 _filter(test, true); | |
5266 } | |
5267 | |
5268 void _filter(bool test(var element), bool retainMatching) { | |
5269 var removed; | |
5270 if (retainMatching) { | |
5271 removed = _element.children.where((e) => !test(e)); | |
5272 } else { | |
5273 removed = _element.children.where(test); | |
5274 } | |
5275 for (var e in removed) e.remove(); | |
5276 } | |
5277 | |
5278 void setRange(int start, int end, Iterable<Element> iterable, | |
5279 [int skipCount = 0]) { | |
5280 throw new UnimplementedError(); | |
5281 } | |
5282 | |
5283 void replaceRange(int start, int end, Iterable<Element> iterable) { | |
5284 throw new UnimplementedError(); | |
5285 } | |
5286 | |
5287 void fillRange(int start, int end, [Element fillValue]) { | |
5288 throw new UnimplementedError(); | |
5289 } | |
5290 | |
5291 bool remove(Object object) { | |
5292 if (object is Element) { | |
5293 Element element = object; | |
5294 // We aren't preserving identity of nodes in JSINTEROP mode | |
5295 if (element.parentNode == _element) { | |
5296 _element._removeChild(element); | |
5297 return true; | |
5298 } | |
5299 } | |
5300 return false; | |
5301 } | |
5302 | |
5303 void insert(int index, Element element) { | |
5304 if (index < 0 || index > length) { | |
5305 throw new RangeError.range(index, 0, length); | |
5306 } | |
5307 if (index == length) { | |
5308 _element.append(element); | |
5309 } else { | |
5310 _element.insertBefore(element, this[index]); | |
5311 } | |
5312 } | |
5313 | |
5314 void setAll(int index, Iterable<Element> iterable) { | |
5315 throw new UnimplementedError(); | |
5316 } | |
5317 | |
5318 void clear() { | |
5319 _element._clearChildren(); | |
5320 } | |
5321 | |
5322 Element removeAt(int index) { | |
5323 final result = this[index]; | |
5324 if (result != null) { | |
5325 _element._removeChild(result); | |
5326 } | |
5327 return result; | |
5328 } | |
5329 | |
5330 Element removeLast() { | |
5331 final result = this.last; | |
5332 if (result != null) { | |
5333 _element._removeChild(result); | |
5334 } | |
5335 return result; | |
5336 } | |
5337 | |
5338 Element get first { | |
5339 Element result = _element._firstElementChild; | |
5340 if (result == null) throw new StateError("No elements"); | |
5341 return result; | |
5342 } | |
5343 | |
5344 | |
5345 Element get last { | |
5346 Element result = _element._lastElementChild; | |
5347 if (result == null) throw new StateError("No elements"); | |
5348 return result; | |
5349 } | |
5350 | |
5351 Element get single { | |
5352 if (length > 1) throw new StateError("More than one element"); | |
5353 return first; | |
5354 } | |
5355 | |
5356 List<Node> get rawList => _childElements; | |
5357 } | |
5358 | |
5359 /** | |
5360 * An immutable list containing HTML elements. This list contains some | |
5361 * additional methods when compared to regular lists for ease of CSS | |
5362 * manipulation on a group of elements. | |
5363 */ | |
5364 abstract class ElementList<T extends Element> extends ListBase<T> { | |
5365 /** | |
5366 * The union of all CSS classes applied to the elements in this list. | |
5367 * | |
5368 * This set makes it easy to add, remove or toggle (add if not present, remove | |
5369 * if present) the classes applied to a collection of elements. | |
5370 * | |
5371 * htmlList.classes.add('selected'); | |
5372 * htmlList.classes.toggle('isOnline'); | |
5373 * htmlList.classes.remove('selected'); | |
5374 */ | |
5375 CssClassSet get classes; | |
5376 | |
5377 /** Replace the classes with `value` for every element in this list. */ | |
5378 set classes(Iterable<String> value); | |
5379 | |
5380 /** | |
5381 * Access the union of all [CssStyleDeclaration]s that are associated with an | |
5382 * [ElementList]. | |
5383 * | |
5384 * Grouping the style objects all together provides easy editing of specific | |
5385 * properties of a collection of elements. Setting a specific property value | |
5386 * will set that property in all [Element]s in the [ElementList]. Getting a | |
5387 * specific property value will return the value of the property of the first | |
5388 * element in the [ElementList]. | |
5389 */ | |
5390 CssStyleDeclarationBase get style; | |
5391 | |
5392 /** | |
5393 * Access dimensions and position of the Elements in this list. | |
5394 * | |
5395 * Setting the height or width properties will set the height or width | |
5396 * property for all elements in the list. This returns a rectangle with the | |
5397 * dimenions actually available for content | |
5398 * in this element, in pixels, regardless of this element's box-sizing | |
5399 * property. Getting the height or width returns the height or width of the | |
5400 * first Element in this list. | |
5401 * | |
5402 * Unlike [getBoundingClientRect], the dimensions of this rectangle | |
5403 * will return the same numerical height if the element is hidden or not. | |
5404 */ | |
5405 @Experimental() | |
5406 CssRect get contentEdge; | |
5407 | |
5408 /** | |
5409 * Access dimensions and position of the first Element's content + padding box | |
5410 * in this list. | |
5411 * | |
5412 * This returns a rectangle with the dimenions actually available for content | |
5413 * in this element, in pixels, regardless of this element's box-sizing | |
5414 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle | |
5415 * will return the same numerical height if the element is hidden or not. This | |
5416 * can be used to retrieve jQuery's `innerHeight` value for an element. This | |
5417 * is also a rectangle equalling the dimensions of clientHeight and | |
5418 * clientWidth. | |
5419 */ | |
5420 @Experimental() | |
5421 CssRect get paddingEdge; | |
5422 | |
5423 /** | |
5424 * Access dimensions and position of the first Element's content + padding + | |
5425 * border box in this list. | |
5426 * | |
5427 * This returns a rectangle with the dimenions actually available for content | |
5428 * in this element, in pixels, regardless of this element's box-sizing | |
5429 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle | |
5430 * will return the same numerical height if the element is hidden or not. This | |
5431 * can be used to retrieve jQuery's `outerHeight` value for an element. | |
5432 */ | |
5433 @Experimental() | |
5434 CssRect get borderEdge; | |
5435 | |
5436 /** | |
5437 * Access dimensions and position of the first Element's content + padding + | |
5438 * border + margin box in this list. | |
5439 * | |
5440 * This returns a rectangle with the dimenions actually available for content | |
5441 * in this element, in pixels, regardless of this element's box-sizing | |
5442 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle | |
5443 * will return the same numerical height if the element is hidden or not. This | |
5444 * can be used to retrieve jQuery's `outerHeight` value for an element. | |
5445 */ | |
5446 @Experimental() | |
5447 CssRect get marginEdge; | |
5448 | |
5449 /// Stream of `beforecopy` events handled by this [Element]. | |
5450 @DomName('Element.onbeforecopy') | |
5451 @DocsEditable() | |
5452 ElementStream<Event> get onBeforeCopy; | |
5453 | |
5454 /// Stream of `beforecut` events handled by this [Element]. | |
5455 @DomName('Element.onbeforecut') | |
5456 @DocsEditable() | |
5457 ElementStream<Event> get onBeforeCut; | |
5458 | |
5459 /// Stream of `beforepaste` events handled by this [Element]. | |
5460 @DomName('Element.onbeforepaste') | |
5461 @DocsEditable() | |
5462 ElementStream<Event> get onBeforePaste; | |
5463 | |
5464 /// Stream of `copy` events handled by this [Element]. | |
5465 @DomName('Element.oncopy') | |
5466 @DocsEditable() | |
5467 ElementStream<Event> get onCopy; | |
5468 | |
5469 /// Stream of `cut` events handled by this [Element]. | |
5470 @DomName('Element.oncut') | |
5471 @DocsEditable() | |
5472 ElementStream<Event> get onCut; | |
5473 | |
5474 /// Stream of `paste` events handled by this [Element]. | |
5475 @DomName('Element.onpaste') | |
5476 @DocsEditable() | |
5477 ElementStream<Event> get onPaste; | |
5478 | |
5479 /// Stream of `search` events handled by this [Element]. | |
5480 @DomName('Element.onsearch') | |
5481 @DocsEditable() | |
5482 // http://www.w3.org/TR/html-markup/input.search.html | |
5483 @Experimental() | |
5484 ElementStream<Event> get onSearch; | |
5485 | |
5486 /// Stream of `selectstart` events handled by this [Element]. | |
5487 @DomName('Element.onselectstart') | |
5488 @DocsEditable() | |
5489 @Experimental() // nonstandard | |
5490 ElementStream<Event> get onSelectStart; | |
5491 | |
5492 /// Stream of `fullscreenchange` events handled by this [Element]. | |
5493 @DomName('Element.onwebkitfullscreenchange') | |
5494 @DocsEditable() | |
5495 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html | |
5496 @Experimental() | |
5497 ElementStream<Event> get onFullscreenChange; | |
5498 | |
5499 /// Stream of `fullscreenerror` events handled by this [Element]. | |
5500 @DomName('Element.onwebkitfullscreenerror') | |
5501 @DocsEditable() | |
5502 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html | |
5503 @Experimental() | |
5504 ElementStream<Event> get onFullscreenError; | |
5505 | |
5506 } | |
5507 | |
5508 // Wrapper over an immutable NodeList to make it implement ElementList. | |
5509 // | |
5510 // Clients are {`Document`, `DocumentFragment`}.`querySelectorAll` which are | |
5511 // declared to return `ElementList`. This provides all the static analysis | |
5512 // benefit so there is no need for this class have a constrained type parameter. | |
5513 // | |
5514 class _FrozenElementList extends ListBase<Element> | |
5515 implements ElementList<Element>, NodeListWrapper { | |
5516 final List<Node> _nodeList; | |
5517 | |
5518 var dartClass_instance; | |
5519 | |
5520 _FrozenElementList._wrap(this._nodeList) { | |
5521 this.dartClass_instance = this._nodeList; | |
5522 } | |
5523 | |
5524 int get length => _nodeList.length; | |
5525 | |
5526 Element operator [](int index) => _nodeList[index]; | |
5527 | |
5528 void operator []=(int index, Element value) { | |
5529 throw new UnsupportedError('Cannot modify list'); | |
5530 } | |
5531 | |
5532 set length(int newLength) { | |
5533 throw new UnsupportedError('Cannot modify list'); | |
5534 } | |
5535 | |
5536 void sort([Comparator<Element> compare]) { | |
5537 throw new UnsupportedError('Cannot sort list'); | |
5538 } | |
5539 | |
5540 void shuffle([Random random]) { | |
5541 throw new UnsupportedError('Cannot shuffle list'); | |
5542 } | |
5543 | |
5544 Element get first => _nodeList.first; | |
5545 | |
5546 Element get last => _nodeList.last; | |
5547 | |
5548 Element get single => _nodeList.single; | |
5549 | |
5550 CssClassSet get classes => new _MultiElementCssClassSet(this); | |
5551 | |
5552 CssStyleDeclarationBase get style => | |
5553 new _CssStyleDeclarationSet(this); | |
5554 | |
5555 set classes(Iterable<String> value) { | |
5556 // TODO(sra): This might be faster for Sets: | |
5557 // | |
5558 // new _MultiElementCssClassSet(this).writeClasses(value) | |
5559 // | |
5560 // as the code below converts the Iterable[value] to a string multiple | |
5561 // times. Maybe compute the string and set className here. | |
5562 _nodeList.forEach((e) => e.classes = value); | |
5563 } | |
5564 | |
5565 CssRect get contentEdge => new _ContentCssListRect(this); | |
5566 | |
5567 CssRect get paddingEdge => this.first.paddingEdge; | |
5568 | |
5569 CssRect get borderEdge => this.first.borderEdge; | |
5570 | |
5571 CssRect get marginEdge => this.first.marginEdge; | |
5572 | |
5573 List<Node> get rawList => _nodeList; | |
5574 | |
5575 | |
5576 /// Stream of `beforecopy` events handled by this [Element]. | |
5577 @DomName('Element.onbeforecopy') | |
5578 @DocsEditable() | |
5579 ElementStream<Event> get onBeforeCopy => Element.beforeCopyEvent._forElementLi
st(this); | |
5580 | |
5581 /// Stream of `beforecut` events handled by this [Element]. | |
5582 @DomName('Element.onbeforecut') | |
5583 @DocsEditable() | |
5584 ElementStream<Event> get onBeforeCut => Element.beforeCutEvent._forElementList
(this); | |
5585 | |
5586 /// Stream of `beforepaste` events handled by this [Element]. | |
5587 @DomName('Element.onbeforepaste') | |
5588 @DocsEditable() | |
5589 ElementStream<Event> get onBeforePaste => Element.beforePasteEvent._forElement
List(this); | |
5590 | |
5591 /// Stream of `copy` events handled by this [Element]. | |
5592 @DomName('Element.oncopy') | |
5593 @DocsEditable() | |
5594 ElementStream<Event> get onCopy => Element.copyEvent._forElementList(this); | |
5595 | |
5596 /// Stream of `cut` events handled by this [Element]. | |
5597 @DomName('Element.oncut') | |
5598 @DocsEditable() | |
5599 ElementStream<Event> get onCut => Element.cutEvent._forElementList(this); | |
5600 | |
5601 /// Stream of `paste` events handled by this [Element]. | |
5602 @DomName('Element.onpaste') | |
5603 @DocsEditable() | |
5604 ElementStream<Event> get onPaste => Element.pasteEvent._forElementList(this); | |
5605 | |
5606 /// Stream of `search` events handled by this [Element]. | |
5607 @DomName('Element.onsearch') | |
5608 @DocsEditable() | |
5609 // http://www.w3.org/TR/html-markup/input.search.html | |
5610 @Experimental() | |
5611 ElementStream<Event> get onSearch => Element.searchEvent._forElementList(this)
; | |
5612 | |
5613 /// Stream of `selectstart` events handled by this [Element]. | |
5614 @DomName('Element.onselectstart') | |
5615 @DocsEditable() | |
5616 @Experimental() // nonstandard | |
5617 ElementStream<Event> get onSelectStart => Element.selectStartEvent._forElement
List(this); | |
5618 | |
5619 /// Stream of `fullscreenchange` events handled by this [Element]. | |
5620 @DomName('Element.onwebkitfullscreenchange') | |
5621 @DocsEditable() | |
5622 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html | |
5623 @Experimental() | |
5624 ElementStream<Event> get onFullscreenChange => Element.fullscreenChangeEvent._
forElementList(this); | |
5625 | |
5626 /// Stream of `fullscreenerror` events handled by this [Element]. | |
5627 @DomName('Element.onwebkitfullscreenerror') | |
5628 @DocsEditable() | |
5629 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html | |
5630 @Experimental() | |
5631 ElementStream<Event> get onFullscreenError => Element.fullscreenErrorEvent._fo
rElementList(this); | |
5632 | |
5633 } | |
5634 | |
5635 @DocsEditable() | |
5636 /** | |
5637 * An abstract class, which all HTML elements extend. | |
5638 */ | |
5639 @DomName('Element') | |
5640 @Native("Element") | |
5641 class Element extends Node implements ParentNode, ChildNode { | |
5642 | |
5643 /** | |
5644 * Creates an HTML element from a valid fragment of HTML. | |
5645 * | |
5646 * var element = new Element.html('<div class="foo">content</div>'); | |
5647 * | |
5648 * The HTML fragment should contain only one single root element, any | |
5649 * leading or trailing text nodes will be removed. | |
5650 * | |
5651 * The HTML fragment is parsed as if it occurred within the context of a | |
5652 * `<body>` tag, this means that special elements such as `<caption>` which | |
5653 * must be parsed within the scope of a `<table>` element will be dropped. Use | |
5654 * [createFragment] to parse contextual HTML fragments. | |
5655 * | |
5656 * Unless a validator is provided this will perform the default validation | |
5657 * and remove all scriptable elements and attributes. | |
5658 * | |
5659 * See also: | |
5660 * | |
5661 * * [NodeValidator] | |
5662 * | |
5663 */ | |
5664 factory Element.html(String html, | |
5665 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | |
5666 var fragment = document.body.createFragment(html, validator: validator, | |
5667 treeSanitizer: treeSanitizer); | |
5668 | |
5669 return fragment.nodes.where((e) => e is Element).single; | |
5670 } | |
5671 | |
5672 /** | |
5673 * Custom element creation constructor. | |
5674 * | |
5675 * This constructor is used by the DOM when a custom element has been | |
5676 * created. It can only be invoked by subclasses of Element from | |
5677 * that classes created constructor. | |
5678 * | |
5679 * class CustomElement extends Element { | |
5680 * factory CustomElement() => new Element.tag('x-custom'); | |
5681 * | |
5682 * CustomElement.created() : super.created() { | |
5683 * // Perform any element initialization. | |
5684 * } | |
5685 * } | |
5686 * document.registerElement('x-custom', CustomElement); | |
5687 */ | |
5688 Element.created() : super._created(); | |
5689 | |
5690 /** | |
5691 * Creates the HTML element specified by the tag name. | |
5692 * | |
5693 * This is similar to [Document.createElement]. | |
5694 * [tag] should be a valid HTML tag name. If [tag] is an unknown tag then | |
5695 * this will create an [UnknownElement]. | |
5696 * | |
5697 * var divElement = new Element.tag('div'); | |
5698 * print(divElement is DivElement); // 'true' | |
5699 * var myElement = new Element.tag('unknownTag'); | |
5700 * print(myElement is UnknownElement); // 'true' | |
5701 * | |
5702 * For standard elements it is more preferable to use the type constructors: | |
5703 * var element = new DivElement(); | |
5704 * | |
5705 * See also: | |
5706 * | |
5707 * * [isTagSupported] | |
5708 */ | |
5709 factory Element.tag(String tag, [String typeExtention]) => | |
5710 _ElementFactoryProvider.createElement_tag(tag, typeExtention); | |
5711 | |
5712 /// Creates a new `<a>` element. | |
5713 /// | |
5714 /// This is identical to calling `new Element.tag('a')`. | |
5715 factory Element.a() => new Element.tag('a'); | |
5716 | |
5717 /// Creates a new `<article>` element. | |
5718 /// | |
5719 /// This is identical to calling `new Element.tag('article')`. | |
5720 factory Element.article() => new Element.tag('article'); | |
5721 | |
5722 /// Creates a new `<aside>` element. | |
5723 /// | |
5724 /// This is identical to calling `new Element.tag('aside')`. | |
5725 factory Element.aside() => new Element.tag('aside'); | |
5726 | |
5727 /// Creates a new `<audio>` element. | |
5728 /// | |
5729 /// This is identical to calling `new Element.tag('audio')`. | |
5730 factory Element.audio() => new Element.tag('audio'); | |
5731 | |
5732 /// Creates a new `<br>` element. | |
5733 /// | |
5734 /// This is identical to calling `new Element.tag('br')`. | |
5735 factory Element.br() => new Element.tag('br'); | |
5736 | |
5737 /// Creates a new `<canvas>` element. | |
5738 /// | |
5739 /// This is identical to calling `new Element.tag('canvas')`. | |
5740 factory Element.canvas() => new Element.tag('canvas'); | |
5741 | |
5742 /// Creates a new `<div>` element. | |
5743 /// | |
5744 /// This is identical to calling `new Element.tag('div')`. | |
5745 factory Element.div() => new Element.tag('div'); | |
5746 | |
5747 /// Creates a new `<footer>` element. | |
5748 /// | |
5749 /// This is identical to calling `new Element.tag('footer')`. | |
5750 factory Element.footer() => new Element.tag('footer'); | |
5751 | |
5752 /// Creates a new `<header>` element. | |
5753 /// | |
5754 /// This is identical to calling `new Element.tag('header')`. | |
5755 factory Element.header() => new Element.tag('header'); | |
5756 | |
5757 /// Creates a new `<hr>` element. | |
5758 /// | |
5759 /// This is identical to calling `new Element.tag('hr')`. | |
5760 factory Element.hr() => new Element.tag('hr'); | |
5761 | |
5762 /// Creates a new `<iframe>` element. | |
5763 /// | |
5764 /// This is identical to calling `new Element.tag('iframe')`. | |
5765 factory Element.iframe() => new Element.tag('iframe'); | |
5766 | |
5767 /// Creates a new `<img>` element. | |
5768 /// | |
5769 /// This is identical to calling `new Element.tag('img')`. | |
5770 factory Element.img() => new Element.tag('img'); | |
5771 | |
5772 /// Creates a new `<li>` element. | |
5773 /// | |
5774 /// This is identical to calling `new Element.tag('li')`. | |
5775 factory Element.li() => new Element.tag('li'); | |
5776 | |
5777 /// Creates a new `<nav>` element. | |
5778 /// | |
5779 /// This is identical to calling `new Element.tag('nav')`. | |
5780 factory Element.nav() => new Element.tag('nav'); | |
5781 | |
5782 /// Creates a new `<ol>` element. | |
5783 /// | |
5784 /// This is identical to calling `new Element.tag('ol')`. | |
5785 factory Element.ol() => new Element.tag('ol'); | |
5786 | |
5787 /// Creates a new `<option>` element. | |
5788 /// | |
5789 /// This is identical to calling `new Element.tag('option')`. | |
5790 factory Element.option() => new Element.tag('option'); | |
5791 | |
5792 /// Creates a new `<p>` element. | |
5793 /// | |
5794 /// This is identical to calling `new Element.tag('p')`. | |
5795 factory Element.p() => new Element.tag('p'); | |
5796 | |
5797 /// Creates a new `<pre>` element. | |
5798 /// | |
5799 /// This is identical to calling `new Element.tag('pre')`. | |
5800 factory Element.pre() => new Element.tag('pre'); | |
5801 | |
5802 /// Creates a new `<section>` element. | |
5803 /// | |
5804 /// This is identical to calling `new Element.tag('section')`. | |
5805 factory Element.section() => new Element.tag('section'); | |
5806 | |
5807 /// Creates a new `<select>` element. | |
5808 /// | |
5809 /// This is identical to calling `new Element.tag('select')`. | |
5810 factory Element.select() => new Element.tag('select'); | |
5811 | |
5812 /// Creates a new `<span>` element. | |
5813 /// | |
5814 /// This is identical to calling `new Element.tag('span')`. | |
5815 factory Element.span() => new Element.tag('span'); | |
5816 | |
5817 /// Creates a new `<svg>` element. | |
5818 /// | |
5819 /// This is identical to calling `new Element.tag('svg')`. | |
5820 factory Element.svg() => new Element.tag('svg'); | |
5821 | |
5822 /// Creates a new `<table>` element. | |
5823 /// | |
5824 /// This is identical to calling `new Element.tag('table')`. | |
5825 factory Element.table() => new Element.tag('table'); | |
5826 | |
5827 /// Creates a new `<td>` element. | |
5828 /// | |
5829 /// This is identical to calling `new Element.tag('td')`. | |
5830 factory Element.td() => new Element.tag('td'); | |
5831 | |
5832 /// Creates a new `<textarea>` element. | |
5833 /// | |
5834 /// This is identical to calling `new Element.tag('textarea')`. | |
5835 factory Element.textarea() => new Element.tag('textarea'); | |
5836 | |
5837 /// Creates a new `<th>` element. | |
5838 /// | |
5839 /// This is identical to calling `new Element.tag('th')`. | |
5840 factory Element.th() => new Element.tag('th'); | |
5841 | |
5842 /// Creates a new `<tr>` element. | |
5843 /// | |
5844 /// This is identical to calling `new Element.tag('tr')`. | |
5845 factory Element.tr() => new Element.tag('tr'); | |
5846 | |
5847 /// Creates a new `<ul>` element. | |
5848 /// | |
5849 /// This is identical to calling `new Element.tag('ul')`. | |
5850 factory Element.ul() => new Element.tag('ul'); | |
5851 | |
5852 /// Creates a new `<video>` element. | |
5853 /// | |
5854 /// This is identical to calling `new Element.tag('video')`. | |
5855 factory Element.video() => new Element.tag('video'); | |
5856 | |
5857 /** | |
5858 * All attributes on this element. | |
5859 * | |
5860 * Any modifications to the attribute map will automatically be applied to | |
5861 * this element. | |
5862 * | |
5863 * This only includes attributes which are not in a namespace | |
5864 * (such as 'xlink:href'), additional attributes can be accessed via | |
5865 * [getNamespacedAttributes]. | |
5866 */ | |
5867 Map<String, String> get attributes => new _ElementAttributeMap(this); | |
5868 | |
5869 set attributes(Map<String, String> value) { | |
5870 Map<String, String> attributes = this.attributes; | |
5871 attributes.clear(); | |
5872 for (String key in value.keys) { | |
5873 attributes[key] = value[key]; | |
5874 } | |
5875 } | |
5876 | |
5877 /** | |
5878 * List of the direct children of this element. | |
5879 * | |
5880 * This collection can be used to add and remove elements from the document. | |
5881 * | |
5882 * var item = new DivElement(); | |
5883 * item.text = 'Something'; | |
5884 * document.body.children.add(item) // Item is now displayed on the page. | |
5885 * for (var element in document.body.children) { | |
5886 * element.style.background = 'red'; // Turns every child of body red. | |
5887 * } | |
5888 */ | |
5889 List<Element> get children => new _ChildrenElementList._wrap(this); | |
5890 | |
5891 set children(List<Element> value) { | |
5892 // Copy list first since we don't want liveness during iteration. | |
5893 List copy = new List.from(value); | |
5894 var children = this.children; | |
5895 children.clear(); | |
5896 children.addAll(copy); | |
5897 } | |
5898 | |
5899 /** | |
5900 * Finds all descendent elements of this element that match the specified | |
5901 * group of selectors. | |
5902 * | |
5903 * [selectors] should be a string using CSS selector syntax. | |
5904 * | |
5905 * var items = element.querySelectorAll('.itemClassName'); | |
5906 * | |
5907 * For details about CSS selector syntax, see the | |
5908 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
5909 */ | |
5910 @DomName('Element.querySelectorAll') | |
5911 ElementList<Element> querySelectorAll(String selectors) => | |
5912 new _FrozenElementList._wrap(_querySelectorAll(selectors)); | |
5913 | |
5914 /** | |
5915 * Alias for [querySelector]. Note this function is deprecated because its | |
5916 * semantics will be changing in the future. | |
5917 */ | |
5918 @deprecated | |
5919 @DomName('Element.querySelector') | |
5920 @Experimental() | |
5921 Element query(String relativeSelectors) => querySelector(relativeSelectors); | |
5922 | |
5923 /** | |
5924 * Alias for [querySelectorAll]. Note this function is deprecated because its | |
5925 * semantics will be changing in the future. | |
5926 */ | |
5927 @deprecated | |
5928 @DomName('Element.querySelectorAll') | |
5929 @Experimental() | |
5930 ElementList<Element> queryAll(String relativeSelectors) => | |
5931 querySelectorAll(relativeSelectors); | |
5932 | |
5933 /** | |
5934 * The set of CSS classes applied to this element. | |
5935 * | |
5936 * This set makes it easy to add, remove or toggle the classes applied to | |
5937 * this element. | |
5938 * | |
5939 * element.classes.add('selected'); | |
5940 * element.classes.toggle('isOnline'); | |
5941 * element.classes.remove('selected'); | |
5942 */ | |
5943 CssClassSet get classes => new _ElementCssClassSet(this); | |
5944 | |
5945 set classes(Iterable<String> value) { | |
5946 // TODO(sra): Do this without reading the classes in clear() and addAll(), | |
5947 // or writing the classes in clear(). | |
5948 CssClassSet classSet = classes; | |
5949 classSet.clear(); | |
5950 classSet.addAll(value); | |
5951 } | |
5952 | |
5953 /** | |
5954 * Allows access to all custom data attributes (data-*) set on this element. | |
5955 * | |
5956 * The keys for the map must follow these rules: | |
5957 * | |
5958 * * The name must not begin with 'xml'. | |
5959 * * The name cannot contain a semi-colon (';'). | |
5960 * * The name cannot contain any capital letters. | |
5961 * | |
5962 * Any keys from markup will be converted to camel-cased keys in the map. | |
5963 * | |
5964 * For example, HTML specified as: | |
5965 * | |
5966 * <div data-my-random-value='value'></div> | |
5967 * | |
5968 * Would be accessed in Dart as: | |
5969 * | |
5970 * var value = element.dataset['myRandomValue']; | |
5971 * | |
5972 * See also: | |
5973 * | |
5974 * * [Custom data attributes](http://www.w3.org/TR/html5/global-attributes.htm
l#custom-data-attribute) | |
5975 */ | |
5976 Map<String, String> get dataset => | |
5977 new _DataAttributeMap(attributes); | |
5978 | |
5979 set dataset(Map<String, String> value) { | |
5980 final data = this.dataset; | |
5981 data.clear(); | |
5982 for (String key in value.keys) { | |
5983 data[key] = value[key]; | |
5984 } | |
5985 } | |
5986 | |
5987 /** | |
5988 * Gets a map for manipulating the attributes of a particular namespace. | |
5989 * | |
5990 * This is primarily useful for SVG attributes such as xref:link. | |
5991 */ | |
5992 Map<String, String> getNamespacedAttributes(String namespace) { | |
5993 return new _NamespacedAttributeMap(this, namespace); | |
5994 } | |
5995 | |
5996 /** | |
5997 * The set of all CSS values applied to this element, including inherited | |
5998 * and default values. | |
5999 * | |
6000 * The computedStyle contains values that are inherited from other | |
6001 * sources, such as parent elements or stylesheets. This differs from the | |
6002 * [style] property, which contains only the values specified directly on this | |
6003 * element. | |
6004 * | |
6005 * PseudoElement can be values such as `::after`, `::before`, `::marker`, | |
6006 * `::line-marker`. | |
6007 * | |
6008 * See also: | |
6009 * | |
6010 * * [CSS Inheritance and Cascade](http://docs.webplatform.org/wiki/tutorials/
inheritance_and_cascade) | |
6011 * * [Pseudo-elements](http://docs.webplatform.org/wiki/css/selectors/pseudo-e
lements) | |
6012 */ | |
6013 CssStyleDeclaration getComputedStyle([String pseudoElement]) { | |
6014 if (pseudoElement == null) { | |
6015 pseudoElement = ''; | |
6016 } | |
6017 // TODO(jacobr): last param should be null, see b/5045788 | |
6018 return window._getComputedStyle(this, pseudoElement); | |
6019 } | |
6020 | |
6021 /** | |
6022 * Gets the position of this element relative to the client area of the page. | |
6023 */ | |
6024 Rectangle get client => new Rectangle(clientLeft, clientTop, clientWidth, | |
6025 clientHeight); | |
6026 | |
6027 /** | |
6028 * Gets the offset of this element relative to its offsetParent. | |
6029 */ | |
6030 Rectangle get offset => new Rectangle(offsetLeft, offsetTop, offsetWidth, | |
6031 offsetHeight); | |
6032 | |
6033 /** | |
6034 * Adds the specified text after the last child of this element. | |
6035 */ | |
6036 void appendText(String text) { | |
6037 this.append(new Text(text)); | |
6038 } | |
6039 | |
6040 /** | |
6041 * Parses the specified text as HTML and adds the resulting node after the | |
6042 * last child of this element. | |
6043 */ | |
6044 void appendHtml(String text, {NodeValidator validator, | |
6045 NodeTreeSanitizer treeSanitizer}) { | |
6046 this.insertAdjacentHtml('beforeend', text, validator: validator, | |
6047 treeSanitizer: treeSanitizer); | |
6048 } | |
6049 | |
6050 /** | |
6051 * Checks to see if the tag name is supported by the current platform. | |
6052 * | |
6053 * The tag should be a valid HTML tag name. | |
6054 */ | |
6055 static bool isTagSupported(String tag) { | |
6056 var e = _ElementFactoryProvider.createElement_tag(tag, null); | |
6057 return e is Element && !(JS('bool', '#.constructor.name == "HTMLUnknownEleme
nt"', e)); | |
6058 } | |
6059 | |
6060 /** | |
6061 * Called by the DOM when this element has been inserted into the live | |
6062 * document. | |
6063 * | |
6064 * More information can be found in the | |
6065 * [Custom Elements](http://w3c.github.io/webcomponents/spec/custom/#dfn-attac
hed-callback) | |
6066 * draft specification. | |
6067 */ | |
6068 @Experimental() | |
6069 void attached() { | |
6070 // For the deprecation period, call the old callback. | |
6071 enteredView(); | |
6072 } | |
6073 | |
6074 /** | |
6075 * Called by the DOM when this element has been removed from the live | |
6076 * document. | |
6077 * | |
6078 * More information can be found in the | |
6079 * [Custom Elements](http://w3c.github.io/webcomponents/spec/custom/#dfn-detac
hed-callback) | |
6080 * draft specification. | |
6081 */ | |
6082 @Experimental() | |
6083 void detached() { | |
6084 // For the deprecation period, call the old callback. | |
6085 leftView(); | |
6086 } | |
6087 | |
6088 /** *Deprecated*: override [attached] instead. */ | |
6089 @Experimental() | |
6090 @deprecated | |
6091 void enteredView() {} | |
6092 | |
6093 /** *Deprecated*: override [detached] instead. */ | |
6094 @Experimental() | |
6095 @deprecated | |
6096 void leftView() {} | |
6097 | |
6098 | |
6099 /** | |
6100 * Called by the DOM whenever an attribute on this has been changed. | |
6101 */ | |
6102 void attributeChanged(String name, String oldValue, String newValue) {} | |
6103 | |
6104 // Hooks to support custom WebComponents. | |
6105 | |
6106 Element _xtag; | |
6107 | |
6108 /** | |
6109 * Experimental support for [web components][wc]. This field stores a | |
6110 * reference to the component implementation. It was inspired by Mozilla's | |
6111 * [x-tags][] project. Please note: in the future it may be possible to | |
6112 * `extend Element` from your class, in which case this field will be | |
6113 * deprecated. | |
6114 * | |
6115 * If xtag has not been set, it will simply return `this` [Element]. | |
6116 * | |
6117 * [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html | |
6118 * [x-tags]: http://x-tags.org/ | |
6119 */ | |
6120 // Note: return type is `dynamic` for convenience to suppress warnings when | |
6121 // members of the component are used. The actual type is a subtype of Element. | |
6122 get xtag => _xtag != null ? _xtag : this; | |
6123 | |
6124 set xtag(Element value) { | |
6125 _xtag = value; | |
6126 } | |
6127 | |
6128 @DomName('Element.localName') | |
6129 @DocsEditable() | |
6130 String get localName => _localName; | |
6131 | |
6132 /** | |
6133 * A URI that identifies the XML namespace of this element. | |
6134 * | |
6135 * `null` if no namespace URI is specified. | |
6136 * | |
6137 * ## Other resources | |
6138 * | |
6139 * * [Node.namespaceURI] | |
6140 * (http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-NodeNSname) from W3C. | |
6141 */ | |
6142 @DomName('Element.namespaceUri') | |
6143 String get namespaceUri => _namespaceUri; | |
6144 | |
6145 /** | |
6146 * The string representation of this element. | |
6147 * | |
6148 * This is equivalent to reading the [localName] property. | |
6149 */ | |
6150 String toString() => localName; | |
6151 | |
6152 /** | |
6153 * Scrolls this element into view. | |
6154 * | |
6155 * Only one of of the alignment options may be specified at a time. | |
6156 * | |
6157 * If no options are specified then this will attempt to scroll the minimum | |
6158 * amount needed to bring the element into view. | |
6159 * | |
6160 * Note that alignCenter is currently only supported on WebKit platforms. If | |
6161 * alignCenter is specified but not supported then this will fall back to | |
6162 * alignTop. | |
6163 * | |
6164 * See also: | |
6165 * | |
6166 * * [scrollIntoView](http://docs.webplatform.org/wiki/dom/methods/scrollIntoV
iew) | |
6167 * * [scrollIntoViewIfNeeded](http://docs.webplatform.org/wiki/dom/methods/scr
ollIntoViewIfNeeded) | |
6168 */ | |
6169 void scrollIntoView([ScrollAlignment alignment]) { | |
6170 var hasScrollIntoViewIfNeeded = true; | |
6171 if (alignment == ScrollAlignment.TOP) { | |
6172 this._scrollIntoView(true); | |
6173 } else if (alignment == ScrollAlignment.BOTTOM) { | |
6174 this._scrollIntoView(false); | |
6175 } else if (hasScrollIntoViewIfNeeded) { | |
6176 if (alignment == ScrollAlignment.CENTER) { | |
6177 this._scrollIntoViewIfNeeded(true); | |
6178 } else { | |
6179 this._scrollIntoViewIfNeeded(); | |
6180 } | |
6181 } else { | |
6182 this._scrollIntoView(); | |
6183 } | |
6184 } | |
6185 | |
6186 | |
6187 /** | |
6188 * Parses text as an HTML fragment and inserts it into the DOM at the | |
6189 * specified location. | |
6190 * | |
6191 * The [where] parameter indicates where to insert the HTML fragment: | |
6192 * | |
6193 * * 'beforeBegin': Immediately before this element. | |
6194 * * 'afterBegin': As the first child of this element. | |
6195 * * 'beforeEnd': As the last child of this element. | |
6196 * * 'afterEnd': Immediately after this element. | |
6197 * | |
6198 * var html = '<div class="something">content</div>'; | |
6199 * // Inserts as the first child | |
6200 * document.body.insertAdjacentHtml('afterBegin', html); | |
6201 * var createdElement = document.body.children[0]; | |
6202 * print(createdElement.classes[0]); // Prints 'something' | |
6203 * | |
6204 * See also: | |
6205 * | |
6206 * * [insertAdjacentText] | |
6207 * * [insertAdjacentElement] | |
6208 */ | |
6209 void insertAdjacentHtml(String where, String html, {NodeValidator validator, | |
6210 NodeTreeSanitizer treeSanitizer}) { | |
6211 if (treeSanitizer is _TrustedHtmlTreeSanitizer) { | |
6212 _insertAdjacentHtml(where, html); | |
6213 } else { | |
6214 _insertAdjacentNode(where, createFragment(html, | |
6215 validator: validator, treeSanitizer: treeSanitizer)); | |
6216 } | |
6217 } | |
6218 | |
6219 @JSName('insertAdjacentHTML') | |
6220 void _insertAdjacentHtml(String where, String text) => JS('void', '#.insertAdj
acentHTML(#,#)', this.raw, where, text); | |
6221 | |
6222 | |
6223 void _insertAdjacentNode(String where, Node node) { | |
6224 switch (where.toLowerCase()) { | |
6225 case 'beforebegin': | |
6226 this.parentNode.insertBefore(node, this); | |
6227 break; | |
6228 case 'afterbegin': | |
6229 var first = this.nodes.length > 0 ? this.nodes[0] : null; | |
6230 this.insertBefore(node, first); | |
6231 break; | |
6232 case 'beforeend': | |
6233 this.append(node); | |
6234 break; | |
6235 case 'afterend': | |
6236 this.parentNode.insertBefore(node, this.nextNode); | |
6237 break; | |
6238 default: | |
6239 throw new ArgumentError("Invalid position ${where}"); | |
6240 } | |
6241 } | |
6242 | |
6243 bool matches(String selectors) => JS('bool', '#.matches(#)', this.raw, selecto
rs); | |
6244 | |
6245 /** Checks if this element or any of its parents match the CSS selectors. */ | |
6246 @Experimental() | |
6247 bool matchesWithAncestors(String selectors) { | |
6248 var elem = this; | |
6249 do { | |
6250 if (elem.matches(selectors)) return true; | |
6251 elem = elem.parent; | |
6252 } while(elem != null); | |
6253 return false; | |
6254 } | |
6255 | |
6256 | |
6257 /** | |
6258 * Access this element's content position. | |
6259 * | |
6260 * This returns a rectangle with the dimenions actually available for content | |
6261 * in this element, in pixels, regardless of this element's box-sizing | |
6262 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle | |
6263 * will return the same numerical height if the element is hidden or not. | |
6264 * | |
6265 * _Important_ _note_: use of this method _will_ perform CSS calculations that | |
6266 * can trigger a browser reflow. Therefore, use of this property _during_ an | |
6267 * animation frame is discouraged. See also: | |
6268 * [Browser Reflow](https://developers.google.com/speed/articles/reflow) | |
6269 */ | |
6270 @Experimental() | |
6271 CssRect get contentEdge => new _ContentCssRect(this); | |
6272 | |
6273 /** | |
6274 * Access the dimensions and position of this element's content + padding box. | |
6275 * | |
6276 * This returns a rectangle with the dimenions actually available for content | |
6277 * in this element, in pixels, regardless of this element's box-sizing | |
6278 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle | |
6279 * will return the same numerical height if the element is hidden or not. This | |
6280 * can be used to retrieve jQuery's | |
6281 * [innerHeight](http://api.jquery.com/innerHeight/) value for an element. | |
6282 * This is also a rectangle equalling the dimensions of clientHeight and | |
6283 * clientWidth. | |
6284 * | |
6285 * _Important_ _note_: use of this method _will_ perform CSS calculations that | |
6286 * can trigger a browser reflow. Therefore, use of this property _during_ an | |
6287 * animation frame is discouraged. See also: | |
6288 * [Browser Reflow](https://developers.google.com/speed/articles/reflow) | |
6289 */ | |
6290 @Experimental() | |
6291 CssRect get paddingEdge => new _PaddingCssRect(this); | |
6292 | |
6293 /** | |
6294 * Access the dimensions and position of this element's content + padding + | |
6295 * border box. | |
6296 * | |
6297 * This returns a rectangle with the dimenions actually available for content | |
6298 * in this element, in pixels, regardless of this element's box-sizing | |
6299 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle | |
6300 * will return the same numerical height if the element is hidden or not. This | |
6301 * can be used to retrieve jQuery's | |
6302 * [outerHeight](http://api.jquery.com/outerHeight/) value for an element. | |
6303 * | |
6304 * _Important_ _note_: use of this method _will_ perform CSS calculations that | |
6305 * can trigger a browser reflow. Therefore, use of this property _during_ an | |
6306 * animation frame is discouraged. See also: | |
6307 * [Browser Reflow](https://developers.google.com/speed/articles/reflow) | |
6308 */ | |
6309 @Experimental() | |
6310 CssRect get borderEdge => new _BorderCssRect(this); | |
6311 | |
6312 /** | |
6313 * Access the dimensions and position of this element's content + padding + | |
6314 * border + margin box. | |
6315 * | |
6316 * This returns a rectangle with the dimenions actually available for content | |
6317 * in this element, in pixels, regardless of this element's box-sizing | |
6318 * property. Unlike [getBoundingClientRect], the dimensions of this rectangle | |
6319 * will return the same numerical height if the element is hidden or not. This | |
6320 * can be used to retrieve jQuery's | |
6321 * [outerHeight](http://api.jquery.com/outerHeight/) value for an element. | |
6322 * | |
6323 * _Important_ _note_: use of this method will perform CSS calculations that | |
6324 * can trigger a browser reflow. Therefore, use of this property _during_ an | |
6325 * animation frame is discouraged. See also: | |
6326 * [Browser Reflow](https://developers.google.com/speed/articles/reflow) | |
6327 */ | |
6328 @Experimental() | |
6329 CssRect get marginEdge => new _MarginCssRect(this); | |
6330 | |
6331 /** | |
6332 * Provides the coordinates of the element relative to the top of the | |
6333 * document. | |
6334 * | |
6335 * This method is the Dart equivalent to jQuery's | |
6336 * [offset](http://api.jquery.com/offset/) method. | |
6337 */ | |
6338 @Experimental() | |
6339 Point get documentOffset => offsetTo(document.documentElement); | |
6340 | |
6341 /** | |
6342 * Provides the offset of this element's [borderEdge] relative to the | |
6343 * specified [parent]. | |
6344 * | |
6345 * This is the Dart equivalent of jQuery's | |
6346 * [position](http://api.jquery.com/position/) method. Unlike jQuery's | |
6347 * position, however, [parent] can be any parent element of `this`, | |
6348 * rather than only `this`'s immediate [offsetParent]. If the specified | |
6349 * element is _not_ an offset parent or transitive offset parent to this | |
6350 * element, an [ArgumentError] is thrown. | |
6351 */ | |
6352 @Experimental() | |
6353 Point offsetTo(Element parent) { | |
6354 return Element._offsetToHelper(this, parent); | |
6355 } | |
6356 | |
6357 static Point _offsetToHelper(Element current, Element parent) { | |
6358 // We're hopping from _offsetParent_ to offsetParent (not just parent), so | |
6359 // offsetParent, "tops out" at BODY. But people could conceivably pass in | |
6360 // the document.documentElement and I want it to return an absolute offset, | |
6361 // so we have the special case checking for HTML. | |
6362 bool sameAsParent = current == parent; | |
6363 bool foundAsParent = sameAsParent || parent.tagName == 'HTML'; | |
6364 if (current == null || sameAsParent) { | |
6365 if (foundAsParent) return new Point(0, 0); | |
6366 throw new ArgumentError("Specified element is not a transitive offset " | |
6367 "parent of this element."); | |
6368 } | |
6369 Element parentOffset = current.offsetParent; | |
6370 Point p = Element._offsetToHelper(parentOffset, parent); | |
6371 return new Point(p.x + current.offsetLeft, p.y + current.offsetTop); | |
6372 } | |
6373 | |
6374 static HtmlDocument _parseDocument; | |
6375 static Range _parseRange; | |
6376 static NodeValidatorBuilder _defaultValidator; | |
6377 static _ValidatingTreeSanitizer _defaultSanitizer; | |
6378 | |
6379 /** | |
6380 * Create a DocumentFragment from the HTML fragment and ensure that it follows | |
6381 * the sanitization rules specified by the validator or treeSanitizer. | |
6382 * | |
6383 * If the default validation behavior is too restrictive then a new | |
6384 * NodeValidator should be created, either extending or wrapping a default | |
6385 * validator and overriding the validation APIs. | |
6386 * | |
6387 * The treeSanitizer is used to walk the generated node tree and sanitize it. | |
6388 * A custom treeSanitizer can also be provided to perform special validation | |
6389 * rules but since the API is more complex to implement this is discouraged. | |
6390 * | |
6391 * The returned tree is guaranteed to only contain nodes and attributes which | |
6392 * are allowed by the provided validator. | |
6393 * | |
6394 * See also: | |
6395 * | |
6396 * * [NodeValidator] | |
6397 * * [NodeTreeSanitizer] | |
6398 */ | |
6399 DocumentFragment createFragment(String html, | |
6400 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | |
6401 if (treeSanitizer == null) { | |
6402 if (validator == null) { | |
6403 if (_defaultValidator == null) { | |
6404 _defaultValidator = new NodeValidatorBuilder.common(); | |
6405 } | |
6406 validator = _defaultValidator; | |
6407 } | |
6408 if (_defaultSanitizer == null) { | |
6409 _defaultSanitizer = new _ValidatingTreeSanitizer(validator); | |
6410 } else { | |
6411 _defaultSanitizer.validator = validator; | |
6412 } | |
6413 treeSanitizer = _defaultSanitizer; | |
6414 } else if (validator != null) { | |
6415 throw new ArgumentError( | |
6416 'validator can only be passed if treeSanitizer is null'); | |
6417 } | |
6418 | |
6419 if (_parseDocument == null) { | |
6420 _parseDocument = document.implementation.createHtmlDocument(''); | |
6421 _parseRange = _parseDocument.createRange(); | |
6422 | |
6423 // Workaround for Safari bug. Was also previously Chrome bug 229142 | |
6424 // - URIs are not resolved in new doc. | |
6425 BaseElement base = _parseDocument.createElement('base'); | |
6426 base.href = document.baseUri; | |
6427 _parseDocument.head.append(base); | |
6428 } | |
6429 var contextElement; | |
6430 if (this is BodyElement) { | |
6431 contextElement = _parseDocument.body; | |
6432 } else { | |
6433 contextElement = _parseDocument.createElement(tagName); | |
6434 _parseDocument.body.append(contextElement); | |
6435 } | |
6436 var fragment; | |
6437 if (Range.supportsCreateContextualFragment && | |
6438 _canBeUsedToCreateContextualFragment) { | |
6439 _parseRange.selectNodeContents(contextElement); | |
6440 fragment = _parseRange.createContextualFragment(html); | |
6441 } else { | |
6442 contextElement._innerHtml = html; | |
6443 | |
6444 fragment = _parseDocument.createDocumentFragment(); | |
6445 while (contextElement.firstChild != null) { | |
6446 fragment.append(contextElement.firstChild); | |
6447 } | |
6448 } | |
6449 if (contextElement != _parseDocument.body) { | |
6450 contextElement.remove(); | |
6451 } | |
6452 | |
6453 treeSanitizer.sanitizeTree(fragment); | |
6454 // Copy the fragment over to the main document (fix for 14184) | |
6455 document.adoptNode(fragment); | |
6456 | |
6457 return fragment; | |
6458 } | |
6459 | |
6460 /** Test if createContextualFragment is supported for this element type */ | |
6461 bool get _canBeUsedToCreateContextualFragment => | |
6462 !_cannotBeUsedToCreateContextualFragment; | |
6463 | |
6464 /** Test if createContextualFragment is NOT supported for this element type */ | |
6465 bool get _cannotBeUsedToCreateContextualFragment => | |
6466 _tagsForWhichCreateContextualFragmentIsNotSupported.contains(tagName); | |
6467 | |
6468 /** | |
6469 * A hard-coded list of the tag names for which createContextualFragment | |
6470 * isn't supported. | |
6471 */ | |
6472 static const _tagsForWhichCreateContextualFragmentIsNotSupported = | |
6473 const ['HEAD', 'AREA', | |
6474 'BASE', 'BASEFONT', 'BR', 'COL', 'COLGROUP', 'EMBED', 'FRAME', 'FRAMESET', | |
6475 'HR', 'IMAGE', 'IMG', 'INPUT', 'ISINDEX', 'LINK', 'META', 'PARAM', | |
6476 'SOURCE', 'STYLE', 'TITLE', 'WBR']; | |
6477 | |
6478 /** | |
6479 * Parses the HTML fragment and sets it as the contents of this element. | |
6480 * | |
6481 * This uses the default sanitization behavior to sanitize the HTML fragment, | |
6482 * use [setInnerHtml] to override the default behavior. | |
6483 */ | |
6484 set innerHtml(String html) { | |
6485 this.setInnerHtml(html); | |
6486 } | |
6487 | |
6488 /** | |
6489 * Parses the HTML fragment and sets it as the contents of this element. | |
6490 * This ensures that the generated content follows the sanitization rules | |
6491 * specified by the validator or treeSanitizer. | |
6492 * | |
6493 * If the default validation behavior is too restrictive then a new | |
6494 * NodeValidator should be created, either extending or wrapping a default | |
6495 * validator and overriding the validation APIs. | |
6496 * | |
6497 * The treeSanitizer is used to walk the generated node tree and sanitize it. | |
6498 * A custom treeSanitizer can also be provided to perform special validation | |
6499 * rules but since the API is more complex to implement this is discouraged. | |
6500 * | |
6501 * The resulting tree is guaranteed to only contain nodes and attributes which | |
6502 * are allowed by the provided validator. | |
6503 * | |
6504 * See also: | |
6505 * | |
6506 * * [NodeValidator] | |
6507 * * [NodeTreeSanitizer] | |
6508 */ | |
6509 void setInnerHtml(String html, | |
6510 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | |
6511 text = null; | |
6512 if (treeSanitizer is _TrustedHtmlTreeSanitizer) { | |
6513 _innerHtml = html; | |
6514 } else { | |
6515 append(createFragment( | |
6516 html, validator: validator, treeSanitizer: treeSanitizer)); | |
6517 } | |
6518 } | |
6519 String get innerHtml => _innerHtml; | |
6520 | |
6521 /** | |
6522 * This is an ease-of-use accessor for event streams which should only be | |
6523 * used when an explicit accessor is not available. | |
6524 */ | |
6525 ElementEvents get on => new ElementEvents(this); | |
6526 | |
6527 /** | |
6528 * Verify if any of the attributes that we use in the sanitizer look unexpecte
d, | |
6529 * possibly indicating DOM clobbering attacks. | |
6530 * | |
6531 * Those attributes are: attributes, lastChild, children, previousNode and tag
Name. | |
6532 */ | |
6533 static bool _hasCorruptedAttributes(Element element) { | |
6534 return JS('bool', r''' | |
6535 (function(element) { | |
6536 if (!(element.attributes instanceof NamedNodeMap)) { | |
6537 return true; | |
6538 } | |
6539 var childNodes = element.childNodes; | |
6540 if (element.lastChild && | |
6541 element.lastChild !== childNodes[childNodes.length -1]) { | |
6542 return true; | |
6543 } | |
6544 if (element.children) { // On Safari, children can apparently be null. | |
6545 if (!((element.children instanceof HTMLCollection) || | |
6546 (element.children instanceof NodeList))) { | |
6547 return true; | |
6548 } | |
6549 } | |
6550 var length = 0; | |
6551 if (element.children) { | |
6552 length = element.children.length; | |
6553 } | |
6554 for (var i = 0; i < length; i++) { | |
6555 var child = element.children[i]; | |
6556 // On IE it seems like we sometimes don't see the clobbered attribute
, | |
6557 // perhaps as a result of an over-optimization. Also use another rout
e | |
6558 // to check of attributes, children, or lastChild are clobbered. It m
ay | |
6559 // seem silly to check children as we rely on children to do this ite
ration, | |
6560 // but it seems possible that the access to children might see the re
al thing, | |
6561 // allowing us to check for clobbering that may show up in other acce
sses. | |
6562 if (child["id"] == 'attributes' || child["name"] == 'attributes' || | |
6563 child["id"] == 'lastChild' || child["name"] == 'lastChild' || | |
6564 child["id"] == 'children' || child["name"] == 'children') { | |
6565 return true; | |
6566 } | |
6567 } | |
6568 return false; | |
6569 })(#)''', | |
6570 element.raw | |
6571 ); | |
6572 } | |
6573 | |
6574 /// A secondary check for corruption, needed on IE | |
6575 static bool _hasCorruptedAttributesAdditionalCheck(Element element) { | |
6576 return JS('bool', r'!(#.attributes instanceof NamedNodeMap)', | |
6577 element.raw | |
6578 ); | |
6579 } | |
6580 | |
6581 static String _safeTagName(element) { | |
6582 String result = 'element tag unavailable'; | |
6583 try { | |
6584 if (element.tagName is String) { | |
6585 result = element.tagName; | |
6586 } | |
6587 } catch (e) {} | |
6588 return result; | |
6589 } | |
6590 | |
6591 @DomName('Element.offsetHeight') | |
6592 @DocsEditable() | |
6593 int get offsetHeight => JS('num', '#.offsetHeight', this.raw).round(); | |
6594 | |
6595 @DomName('Element.offsetLeft') | |
6596 @DocsEditable() | |
6597 int get offsetLeft => JS('num', '#.offsetLeft', this.raw).round(); | |
6598 | |
6599 @DomName('Element.offsetTop') | |
6600 @DocsEditable() | |
6601 int get offsetTop => JS('num', '#.offsetTop', this.raw).round(); | |
6602 | |
6603 @DomName('Element.offsetWidth') | |
6604 @DocsEditable() | |
6605 int get offsetWidth => JS('num', '#.offsetWidth', this.raw).round(); | |
6606 | |
6607 @DomName('Element.clientHeight') | |
6608 @DocsEditable() | |
6609 int get clientHeight => JS('num', '#.clientHeight', this.raw).round(); | |
6610 | |
6611 @DomName('Element.clientLeft') | |
6612 @DocsEditable() | |
6613 int get clientLeft => JS('num', '#.clientLeft', this.raw).round(); | |
6614 | |
6615 @DomName('Element.clientTop') | |
6616 @DocsEditable() | |
6617 int get clientTop => JS('num', '#.clientTop', this.raw).round(); | |
6618 | |
6619 @DomName('Element.clientWidth') | |
6620 @DocsEditable() | |
6621 int get clientWidth => JS('num', '#.clientWidth', this.raw).round(); | |
6622 | |
6623 @DomName('Element.scrollHeight') | |
6624 @DocsEditable() | |
6625 int get scrollHeight => JS('num', '#.scrollHeight', this.raw).round(); | |
6626 | |
6627 @DomName('Element.scrollLeft') | |
6628 @DocsEditable() | |
6629 int get scrollLeft => JS('num', '#.scrollLeft', this.raw).round(); | |
6630 | |
6631 @DomName('Element.scrollLeft') | |
6632 @DocsEditable() | |
6633 set scrollLeft(int value) { | |
6634 JS("void", "#.scrollLeft = #", this.raw, value.round()); | |
6635 } | |
6636 | |
6637 @DomName('Element.scrollTop') | |
6638 @DocsEditable() | |
6639 int get scrollTop => JS('num', '#.scrollTop', this.raw).round(); | |
6640 | |
6641 @DomName('Element.scrollTop') | |
6642 @DocsEditable() | |
6643 set scrollTop(int value) { | |
6644 JS("void", "#.scrollTop = #", this.raw, value.round()); | |
6645 } | |
6646 | |
6647 @DomName('Element.scrollWidth') | |
6648 @DocsEditable() | |
6649 int get scrollWidth => JS('num', '#.scrollWidth', this.raw).round(); | |
6650 | |
6651 // To suppress missing implicit constructor warnings. | |
6652 factory Element._() { throw new UnsupportedError("Not supported"); } | |
6653 | |
6654 /** | |
6655 * Static factory designed to expose `beforecopy` events to event | |
6656 * handlers that are not necessarily instances of [Element]. | |
6657 * | |
6658 * See [EventStreamProvider] for usage information. | |
6659 */ | |
6660 @DomName('Element.beforecopyEvent') | |
6661 @DocsEditable() | |
6662 static const EventStreamProvider<Event> beforeCopyEvent = const EventStreamPro
vider<Event>('beforecopy'); | |
6663 | |
6664 /** | |
6665 * Static factory designed to expose `beforecut` events to event | |
6666 * handlers that are not necessarily instances of [Element]. | |
6667 * | |
6668 * See [EventStreamProvider] for usage information. | |
6669 */ | |
6670 @DomName('Element.beforecutEvent') | |
6671 @DocsEditable() | |
6672 static const EventStreamProvider<Event> beforeCutEvent = const EventStreamProv
ider<Event>('beforecut'); | |
6673 | |
6674 /** | |
6675 * Static factory designed to expose `beforepaste` events to event | |
6676 * handlers that are not necessarily instances of [Element]. | |
6677 * | |
6678 * See [EventStreamProvider] for usage information. | |
6679 */ | |
6680 @DomName('Element.beforepasteEvent') | |
6681 @DocsEditable() | |
6682 static const EventStreamProvider<Event> beforePasteEvent = const EventStreamPr
ovider<Event>('beforepaste'); | |
6683 | |
6684 /** | |
6685 * Static factory designed to expose `copy` events to event | |
6686 * handlers that are not necessarily instances of [Element]. | |
6687 * | |
6688 * See [EventStreamProvider] for usage information. | |
6689 */ | |
6690 @DomName('Element.copyEvent') | |
6691 @DocsEditable() | |
6692 static const EventStreamProvider<Event> copyEvent = const EventStreamProvider<
Event>('copy'); | |
6693 | |
6694 /** | |
6695 * Static factory designed to expose `cut` events to event | |
6696 * handlers that are not necessarily instances of [Element]. | |
6697 * | |
6698 * See [EventStreamProvider] for usage information. | |
6699 */ | |
6700 @DomName('Element.cutEvent') | |
6701 @DocsEditable() | |
6702 static const EventStreamProvider<Event> cutEvent = const EventStreamProvider<E
vent>('cut'); | |
6703 | |
6704 /** | |
6705 * Static factory designed to expose `paste` events to event | |
6706 * handlers that are not necessarily instances of [Element]. | |
6707 * | |
6708 * See [EventStreamProvider] for usage information. | |
6709 */ | |
6710 @DomName('Element.pasteEvent') | |
6711 @DocsEditable() | |
6712 static const EventStreamProvider<Event> pasteEvent = const EventStreamProvider
<Event>('paste'); | |
6713 | |
6714 /** | |
6715 * Static factory designed to expose `search` events to event | |
6716 * handlers that are not necessarily instances of [Element]. | |
6717 * | |
6718 * See [EventStreamProvider] for usage information. | |
6719 */ | |
6720 @DomName('Element.searchEvent') | |
6721 @DocsEditable() | |
6722 // http://www.w3.org/TR/html-markup/input.search.html | |
6723 @Experimental() | |
6724 static const EventStreamProvider<Event> searchEvent = const EventStreamProvide
r<Event>('search'); | |
6725 | |
6726 /** | |
6727 * Static factory designed to expose `selectstart` events to event | |
6728 * handlers that are not necessarily instances of [Element]. | |
6729 * | |
6730 * See [EventStreamProvider] for usage information. | |
6731 */ | |
6732 @DomName('Element.selectstartEvent') | |
6733 @DocsEditable() | |
6734 @Experimental() // nonstandard | |
6735 static const EventStreamProvider<Event> selectStartEvent = const EventStreamPr
ovider<Event>('selectstart'); | |
6736 | |
6737 /** | |
6738 * Static factory designed to expose `fullscreenchange` events to event | |
6739 * handlers that are not necessarily instances of [Element]. | |
6740 * | |
6741 * See [EventStreamProvider] for usage information. | |
6742 */ | |
6743 @DomName('Element.webkitfullscreenchangeEvent') | |
6744 @DocsEditable() | |
6745 @SupportedBrowser(SupportedBrowser.CHROME) | |
6746 @SupportedBrowser(SupportedBrowser.SAFARI) | |
6747 @Experimental() | |
6748 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html | |
6749 static const EventStreamProvider<Event> fullscreenChangeEvent = const EventStr
eamProvider<Event>('webkitfullscreenchange'); | |
6750 | |
6751 /** | |
6752 * Static factory designed to expose `fullscreenerror` events to event | |
6753 * handlers that are not necessarily instances of [Element]. | |
6754 * | |
6755 * See [EventStreamProvider] for usage information. | |
6756 */ | |
6757 @DomName('Element.webkitfullscreenerrorEvent') | |
6758 @DocsEditable() | |
6759 @SupportedBrowser(SupportedBrowser.CHROME) | |
6760 @SupportedBrowser(SupportedBrowser.SAFARI) | |
6761 @Experimental() | |
6762 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html | |
6763 static const EventStreamProvider<Event> fullscreenErrorEvent = const EventStre
amProvider<Event>('webkitfullscreenerror'); | |
6764 | |
6765 | |
6766 @Deprecated("Internal Use Only") | |
6767 static Element internalCreateElement() { | |
6768 return new Element.internal_(); | |
6769 } | |
6770 | |
6771 @Deprecated("Internal Use Only") | |
6772 Element.internal_() : super.internal_(); | |
6773 | |
6774 | |
6775 @DomName('Element.contentEditable') | |
6776 @DocsEditable() | |
6777 String get contentEditable => wrap_jso(JS("String", "#.contentEditable", this.
raw)); | |
6778 @DomName('Element.contentEditable') | |
6779 @DocsEditable() | |
6780 void set contentEditable(String val) => JS("void", "#.contentEditable = #", th
is.raw, unwrap_jso(val)); | |
6781 | |
6782 @DomName('Element.contextMenu') | |
6783 @DocsEditable() | |
6784 @Experimental() // untriaged | |
6785 HtmlElement get contextMenu => wrap_jso(JS("HtmlElement", "#.contextMenu", thi
s.raw)); | |
6786 @DomName('Element.contextMenu') | |
6787 @DocsEditable() | |
6788 @Experimental() // untriaged | |
6789 void set contextMenu(HtmlElement val) => JS("void", "#.contextMenu = #", this.
raw, unwrap_jso(val)); | |
6790 | |
6791 @DomName('Element.dir') | |
6792 @DocsEditable() | |
6793 String get dir => wrap_jso(JS("String", "#.dir", this.raw)); | |
6794 @DomName('Element.dir') | |
6795 @DocsEditable() | |
6796 void set dir(String val) => JS("void", "#.dir = #", this.raw, unwrap_jso(val))
; | |
6797 | |
6798 /** | |
6799 * Indicates whether the element can be dragged and dropped. | |
6800 * | |
6801 * ## Other resources | |
6802 * | |
6803 * * [Drag and drop sample] | |
6804 * (https://github.com/dart-lang/dart-samples/tree/master/web/html5/dnd/basics
) | |
6805 * based on [the tutorial](http://www.html5rocks.com/en/tutorials/dnd/basics/) | |
6806 * from HTML5Rocks. | |
6807 * * [Drag and drop specification] | |
6808 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dnd) | |
6809 * from WHATWG. | |
6810 */ | |
6811 @DomName('Element.draggable') | |
6812 @DocsEditable() | |
6813 bool get draggable => wrap_jso(JS("bool", "#.draggable", this.raw)); | |
6814 /** | |
6815 * Indicates whether the element can be dragged and dropped. | |
6816 * | |
6817 * ## Other resources | |
6818 * | |
6819 * * [Drag and drop sample] | |
6820 * (https://github.com/dart-lang/dart-samples/tree/master/web/html5/dnd/basics
) | |
6821 * based on [the tutorial](http://www.html5rocks.com/en/tutorials/dnd/basics/) | |
6822 * from HTML5Rocks. | |
6823 * * [Drag and drop specification] | |
6824 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dnd) | |
6825 * from WHATWG. | |
6826 */ | |
6827 @DomName('Element.draggable') | |
6828 @DocsEditable() | |
6829 void set draggable(bool val) => JS("void", "#.draggable = #", this.raw, unwrap
_jso(val)); | |
6830 | |
6831 /** | |
6832 * Indicates whether the element is not relevant to the page's current state. | |
6833 * | |
6834 * ## Other resources | |
6835 * | |
6836 * * [Hidden attribute specification] | |
6837 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#t
he-hidden-attribute) | |
6838 * from WHATWG. | |
6839 */ | |
6840 @DomName('Element.hidden') | |
6841 @DocsEditable() | |
6842 bool get hidden => wrap_jso(JS("bool", "#.hidden", this.raw)); | |
6843 /** | |
6844 * Indicates whether the element is not relevant to the page's current state. | |
6845 * | |
6846 * ## Other resources | |
6847 * | |
6848 * * [Hidden attribute specification] | |
6849 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#t
he-hidden-attribute) | |
6850 * from WHATWG. | |
6851 */ | |
6852 @DomName('Element.hidden') | |
6853 @DocsEditable() | |
6854 void set hidden(bool val) => JS("void", "#.hidden = #", this.raw, unwrap_jso(v
al)); | |
6855 | |
6856 @DomName('Element.isContentEditable') | |
6857 @DocsEditable() | |
6858 bool get isContentEditable => wrap_jso(JS("bool", "#.isContentEditable", this.
raw)); | |
6859 | |
6860 @DomName('Element.lang') | |
6861 @DocsEditable() | |
6862 String get lang => wrap_jso(JS("String", "#.lang", this.raw)); | |
6863 @DomName('Element.lang') | |
6864 @DocsEditable() | |
6865 void set lang(String val) => JS("void", "#.lang = #", this.raw, unwrap_jso(val
)); | |
6866 | |
6867 @DomName('Element.spellcheck') | |
6868 @DocsEditable() | |
6869 // http://blog.whatwg.org/the-road-to-html-5-spellchecking | |
6870 @Experimental() // nonstandard | |
6871 bool get spellcheck => wrap_jso(JS("bool", "#.spellcheck", this.raw)); | |
6872 @DomName('Element.spellcheck') | |
6873 @DocsEditable() | |
6874 // http://blog.whatwg.org/the-road-to-html-5-spellchecking | |
6875 @Experimental() // nonstandard | |
6876 void set spellcheck(bool val) => JS("void", "#.spellcheck = #", this.raw, unwr
ap_jso(val)); | |
6877 | |
6878 @DomName('Element.tabIndex') | |
6879 @DocsEditable() | |
6880 int get tabIndex => wrap_jso(JS("int", "#.tabIndex", this.raw)); | |
6881 @DomName('Element.tabIndex') | |
6882 @DocsEditable() | |
6883 void set tabIndex(int val) => JS("void", "#.tabIndex = #", this.raw, unwrap_js
o(val)); | |
6884 | |
6885 @DomName('Element.title') | |
6886 @DocsEditable() | |
6887 String get title => wrap_jso(JS("String", "#.title", this.raw)); | |
6888 @DomName('Element.title') | |
6889 @DocsEditable() | |
6890 void set title(String val) => JS("void", "#.title = #", this.raw, unwrap_jso(v
al)); | |
6891 | |
6892 /** | |
6893 * Specifies whether this element's text content changes when the page is | |
6894 * localized. | |
6895 * | |
6896 * ## Other resources | |
6897 * | |
6898 * * [The translate attribute] | |
6899 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#
the-translate-attribute) | |
6900 * from WHATWG. | |
6901 */ | |
6902 @DomName('Element.translate') | |
6903 @DocsEditable() | |
6904 // http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#t
he-translate-attribute | |
6905 @Experimental() | |
6906 bool get translate => wrap_jso(JS("bool", "#.translate", this.raw)); | |
6907 /** | |
6908 * Specifies whether this element's text content changes when the page is | |
6909 * localized. | |
6910 * | |
6911 * ## Other resources | |
6912 * | |
6913 * * [The translate attribute] | |
6914 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#
the-translate-attribute) | |
6915 * from WHATWG. | |
6916 */ | |
6917 @DomName('Element.translate') | |
6918 @DocsEditable() | |
6919 // http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#t
he-translate-attribute | |
6920 @Experimental() | |
6921 void set translate(bool val) => JS("void", "#.translate = #", this.raw, unwrap
_jso(val)); | |
6922 | |
6923 @JSName('webkitdropzone') | |
6924 /** | |
6925 * A set of space-separated keywords that specify what kind of data this | |
6926 * Element accepts on drop and what to do with that data. | |
6927 * | |
6928 * ## Other resources | |
6929 * | |
6930 * * [Drag and drop sample] | |
6931 * (https://github.com/dart-lang/dart-samples/tree/master/web/html5/dnd/basics
) | |
6932 * based on [the tutorial](http://www.html5rocks.com/en/tutorials/dnd/basics/) | |
6933 * from HTML5Rocks. | |
6934 * * [Drag and drop specification] | |
6935 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dnd) | |
6936 * from WHATWG. | |
6937 */ | |
6938 @DomName('Element.webkitdropzone') | |
6939 @DocsEditable() | |
6940 @SupportedBrowser(SupportedBrowser.CHROME) | |
6941 @SupportedBrowser(SupportedBrowser.SAFARI) | |
6942 @Experimental() | |
6943 // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#the-dr
opzone-attribute | |
6944 String get dropzone => wrap_jso(JS("String", "#.webkitdropzone", this.raw)); | |
6945 @JSName('webkitdropzone') | |
6946 /** | |
6947 * A set of space-separated keywords that specify what kind of data this | |
6948 * Element accepts on drop and what to do with that data. | |
6949 * | |
6950 * ## Other resources | |
6951 * | |
6952 * * [Drag and drop sample] | |
6953 * (https://github.com/dart-lang/dart-samples/tree/master/web/html5/dnd/basics
) | |
6954 * based on [the tutorial](http://www.html5rocks.com/en/tutorials/dnd/basics/) | |
6955 * from HTML5Rocks. | |
6956 * * [Drag and drop specification] | |
6957 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dnd) | |
6958 * from WHATWG. | |
6959 */ | |
6960 @DomName('Element.webkitdropzone') | |
6961 @DocsEditable() | |
6962 @SupportedBrowser(SupportedBrowser.CHROME) | |
6963 @SupportedBrowser(SupportedBrowser.SAFARI) | |
6964 @Experimental() | |
6965 // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#the-dr
opzone-attribute | |
6966 void set dropzone(String val) => JS("void", "#.webkitdropzone = #", this.raw,
unwrap_jso(val)); | |
6967 | |
6968 @DomName('Element.click') | |
6969 @DocsEditable() | |
6970 void click() { | |
6971 _click_1(); | |
6972 return; | |
6973 } | |
6974 @JSName('click') | |
6975 @DomName('Element.click') | |
6976 @DocsEditable() | |
6977 void _click_1() => wrap_jso(JS("void ", "#.raw.click()", this)); | |
6978 | |
6979 @JSName('attributes') | |
6980 @DomName('Element.attributes') | |
6981 @DocsEditable() | |
6982 _NamedNodeMap get _attributes => wrap_jso(JS("_NamedNodeMap", "#.attributes",
this.raw)); | |
6983 | |
6984 @DomName('Element.className') | |
6985 @DocsEditable() | |
6986 String get className => wrap_jso(JS("String", "#.className", this.raw)); | |
6987 @DomName('Element.className') | |
6988 @DocsEditable() | |
6989 void set className(String val) => JS("void", "#.className = #", this.raw, unwr
ap_jso(val)); | |
6990 | |
6991 @JSName('clientHeight') | |
6992 @DomName('Element.clientHeight') | |
6993 @DocsEditable() | |
6994 int get _clientHeight => wrap_jso(JS("int", "#.clientHeight", this.raw)); | |
6995 | |
6996 @JSName('clientLeft') | |
6997 @DomName('Element.clientLeft') | |
6998 @DocsEditable() | |
6999 int get _clientLeft => wrap_jso(JS("int", "#.clientLeft", this.raw)); | |
7000 | |
7001 @JSName('clientTop') | |
7002 @DomName('Element.clientTop') | |
7003 @DocsEditable() | |
7004 int get _clientTop => wrap_jso(JS("int", "#.clientTop", this.raw)); | |
7005 | |
7006 @JSName('clientWidth') | |
7007 @DomName('Element.clientWidth') | |
7008 @DocsEditable() | |
7009 int get _clientWidth => wrap_jso(JS("int", "#.clientWidth", this.raw)); | |
7010 | |
7011 @DomName('Element.id') | |
7012 @DocsEditable() | |
7013 String get id => wrap_jso(JS("String", "#.id", this.raw)); | |
7014 @DomName('Element.id') | |
7015 @DocsEditable() | |
7016 void set id(String val) => JS("void", "#.id = #", this.raw, unwrap_jso(val)); | |
7017 | |
7018 @JSName('innerHTML') | |
7019 @DomName('Element.innerHTML') | |
7020 @DocsEditable() | |
7021 String get _innerHtml => wrap_jso(JS("String", "#.innerHTML", this.raw)); | |
7022 @JSName('innerHTML') | |
7023 @DomName('Element.innerHTML') | |
7024 @DocsEditable() | |
7025 void set _innerHtml(String val) => JS("void", "#.innerHTML = #", this.raw, unw
rap_jso(val)); | |
7026 | |
7027 // Use implementation from Node. | |
7028 // final String _localName; | |
7029 | |
7030 // Use implementation from Node. | |
7031 // final String _namespaceUri; | |
7032 | |
7033 @JSName('offsetHeight') | |
7034 @DomName('Element.offsetHeight') | |
7035 @DocsEditable() | |
7036 int get _offsetHeight => wrap_jso(JS("int", "#.offsetHeight", this.raw)); | |
7037 | |
7038 @JSName('offsetLeft') | |
7039 @DomName('Element.offsetLeft') | |
7040 @DocsEditable() | |
7041 int get _offsetLeft => wrap_jso(JS("int", "#.offsetLeft", this.raw)); | |
7042 | |
7043 @DomName('Element.offsetParent') | |
7044 @DocsEditable() | |
7045 Element get offsetParent => wrap_jso(JS("Element", "#.offsetParent", this.raw)
); | |
7046 | |
7047 @JSName('offsetTop') | |
7048 @DomName('Element.offsetTop') | |
7049 @DocsEditable() | |
7050 int get _offsetTop => wrap_jso(JS("int", "#.offsetTop", this.raw)); | |
7051 | |
7052 @JSName('offsetWidth') | |
7053 @DomName('Element.offsetWidth') | |
7054 @DocsEditable() | |
7055 int get _offsetWidth => wrap_jso(JS("int", "#.offsetWidth", this.raw)); | |
7056 | |
7057 @JSName('outerHTML') | |
7058 @DomName('Element.outerHTML') | |
7059 @DocsEditable() | |
7060 String get outerHtml => wrap_jso(JS("String", "#.outerHTML", this.raw)); | |
7061 | |
7062 @JSName('scrollHeight') | |
7063 @DomName('Element.scrollHeight') | |
7064 @DocsEditable() | |
7065 int get _scrollHeight => wrap_jso(JS("int", "#.scrollHeight", this.raw)); | |
7066 | |
7067 @JSName('scrollLeft') | |
7068 @DomName('Element.scrollLeft') | |
7069 @DocsEditable() | |
7070 num get _scrollLeft => wrap_jso(JS("num", "#.scrollLeft", this.raw)); | |
7071 @JSName('scrollLeft') | |
7072 @DomName('Element.scrollLeft') | |
7073 @DocsEditable() | |
7074 void set _scrollLeft(num val) => JS("void", "#.scrollLeft = #", this.raw, unwr
ap_jso(val)); | |
7075 | |
7076 @JSName('scrollTop') | |
7077 @DomName('Element.scrollTop') | |
7078 @DocsEditable() | |
7079 num get _scrollTop => wrap_jso(JS("num", "#.scrollTop", this.raw)); | |
7080 @JSName('scrollTop') | |
7081 @DomName('Element.scrollTop') | |
7082 @DocsEditable() | |
7083 void set _scrollTop(num val) => JS("void", "#.scrollTop = #", this.raw, unwrap
_jso(val)); | |
7084 | |
7085 @JSName('scrollWidth') | |
7086 @DomName('Element.scrollWidth') | |
7087 @DocsEditable() | |
7088 int get _scrollWidth => wrap_jso(JS("int", "#.scrollWidth", this.raw)); | |
7089 | |
7090 @DomName('Element.style') | |
7091 @DocsEditable() | |
7092 CssStyleDeclaration get style => wrap_jso(JS("CssStyleDeclaration", "#.style",
this.raw)); | |
7093 | |
7094 @DomName('Element.tagName') | |
7095 @DocsEditable() | |
7096 String get tagName => wrap_jso(JS("String", "#.tagName", this.raw)); | |
7097 | |
7098 @DomName('Element.blur') | |
7099 @DocsEditable() | |
7100 void blur() { | |
7101 _blur_1(); | |
7102 return; | |
7103 } | |
7104 @JSName('blur') | |
7105 @DomName('Element.blur') | |
7106 @DocsEditable() | |
7107 void _blur_1() => wrap_jso(JS("void ", "#.raw.blur()", this)); | |
7108 | |
7109 @DomName('Element.focus') | |
7110 @DocsEditable() | |
7111 void focus() { | |
7112 _focus_1(); | |
7113 return; | |
7114 } | |
7115 @JSName('focus') | |
7116 @DomName('Element.focus') | |
7117 @DocsEditable() | |
7118 void _focus_1() => wrap_jso(JS("void ", "#.raw.focus()", this)); | |
7119 | |
7120 @DomName('Element.getAttribute') | |
7121 @DocsEditable() | |
7122 @Experimental() // untriaged | |
7123 String getAttribute(String name) { | |
7124 return _getAttribute_1(name); | |
7125 } | |
7126 @JSName('getAttribute') | |
7127 @DomName('Element.getAttribute') | |
7128 @DocsEditable() | |
7129 @Experimental() // untriaged | |
7130 String _getAttribute_1(name) => wrap_jso(JS("String ", "#.raw.getAttribute(#)"
, this, unwrap_jso(name))); | |
7131 | |
7132 @DomName('Element.getAttributeNS') | |
7133 @DocsEditable() | |
7134 @Experimental() // untriaged | |
7135 String getAttributeNS(String namespaceURI, String localName) { | |
7136 return _getAttributeNS_1(namespaceURI, localName); | |
7137 } | |
7138 @JSName('getAttributeNS') | |
7139 @DomName('Element.getAttributeNS') | |
7140 @DocsEditable() | |
7141 @Experimental() // untriaged | |
7142 String _getAttributeNS_1(namespaceURI, localName) => wrap_jso(JS("String ", "#
.raw.getAttributeNS(#, #)", this, unwrap_jso(namespaceURI), unwrap_jso(localName
))); | |
7143 | |
7144 /** | |
7145 * Returns the smallest bounding rectangle that encompasses this element's | |
7146 * padding, scrollbar, and border. | |
7147 * | |
7148 * ## Other resources | |
7149 * | |
7150 * * [Element.getBoundingClientRect] | |
7151 * (https://developer.mozilla.org/en-US/docs/Web/API/Element.getBoundingClient
Rect) | |
7152 * from MDN. | |
7153 * * [The getBoundingClientRect() method] | |
7154 * (http://www.w3.org/TR/cssom-view/#the-getclientrects-and-getboundingclientr
ect-methods) | |
7155 * from W3C. | |
7156 */ | |
7157 @DomName('Element.getBoundingClientRect') | |
7158 @DocsEditable() | |
7159 Rectangle getBoundingClientRect() { | |
7160 return _getBoundingClientRect_1(); | |
7161 } | |
7162 @JSName('getBoundingClientRect') | |
7163 /** | |
7164 * Returns the smallest bounding rectangle that encompasses this element's | |
7165 * padding, scrollbar, and border. | |
7166 * | |
7167 * ## Other resources | |
7168 * | |
7169 * * [Element.getBoundingClientRect] | |
7170 * (https://developer.mozilla.org/en-US/docs/Web/API/Element.getBoundingClient
Rect) | |
7171 * from MDN. | |
7172 * * [The getBoundingClientRect() method] | |
7173 * (http://www.w3.org/TR/cssom-view/#the-getclientrects-and-getboundingclientr
ect-methods) | |
7174 * from W3C. | |
7175 */ | |
7176 @DomName('Element.getBoundingClientRect') | |
7177 @DocsEditable() | |
7178 Rectangle _getBoundingClientRect_1() => wrap_jso(JS("Rectangle ", "#.raw.getBo
undingClientRect()", this)); | |
7179 | |
7180 /** | |
7181 * Returns a list of shadow DOM insertion points to which this element is | |
7182 * distributed. | |
7183 * | |
7184 * ## Other resources | |
7185 * | |
7186 * * [Shadow DOM specification] | |
7187 * (https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html) | |
7188 * from W3C. | |
7189 */ | |
7190 @DomName('Element.getDestinationInsertionPoints') | |
7191 @DocsEditable() | |
7192 @Experimental() // untriaged | |
7193 @Returns('NodeList') | |
7194 @Creates('NodeList') | |
7195 NodeList getDestinationInsertionPoints() { | |
7196 return _getDestinationInsertionPoints_1(); | |
7197 } | |
7198 @JSName('getDestinationInsertionPoints') | |
7199 /** | |
7200 * Returns a list of shadow DOM insertion points to which this element is | |
7201 * distributed. | |
7202 * | |
7203 * ## Other resources | |
7204 * | |
7205 * * [Shadow DOM specification] | |
7206 * (https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html) | |
7207 * from W3C. | |
7208 */ | |
7209 @DomName('Element.getDestinationInsertionPoints') | |
7210 @DocsEditable() | |
7211 @Experimental() // untriaged | |
7212 @Returns('NodeList') | |
7213 @Creates('NodeList') | |
7214 NodeList _getDestinationInsertionPoints_1() => wrap_jso(JS("NodeList ", "#.raw
.getDestinationInsertionPoints()", this)); | |
7215 | |
7216 /** | |
7217 * Returns a list of nodes with the given class name inside this element. | |
7218 * | |
7219 * ## Other resources | |
7220 * | |
7221 * * [getElementsByClassName] | |
7222 * (https://developer.mozilla.org/en-US/docs/Web/API/document.getElementsByCla
ssName) | |
7223 * from MDN. | |
7224 * * [DOM specification] | |
7225 * (http://www.w3.org/TR/domcore/) from W3C. | |
7226 */ | |
7227 @DomName('Element.getElementsByClassName') | |
7228 @DocsEditable() | |
7229 @Creates('NodeList|HtmlCollection') | |
7230 @Returns('NodeList|HtmlCollection') | |
7231 HtmlCollection getElementsByClassName(String classNames) { | |
7232 return _getElementsByClassName_1(classNames); | |
7233 } | |
7234 @JSName('getElementsByClassName') | |
7235 /** | |
7236 * Returns a list of nodes with the given class name inside this element. | |
7237 * | |
7238 * ## Other resources | |
7239 * | |
7240 * * [getElementsByClassName] | |
7241 * (https://developer.mozilla.org/en-US/docs/Web/API/document.getElementsByCla
ssName) | |
7242 * from MDN. | |
7243 * * [DOM specification] | |
7244 * (http://www.w3.org/TR/domcore/) from W3C. | |
7245 */ | |
7246 @DomName('Element.getElementsByClassName') | |
7247 @DocsEditable() | |
7248 @Creates('NodeList|HtmlCollection') | |
7249 @Returns('NodeList|HtmlCollection') | |
7250 HtmlCollection _getElementsByClassName_1(classNames) => wrap_jso(JS("HtmlColle
ction ", "#.raw.getElementsByClassName(#)", this, unwrap_jso(classNames))); | |
7251 | |
7252 @DomName('Element.getElementsByTagName') | |
7253 @DocsEditable() | |
7254 @Creates('NodeList|HtmlCollection') | |
7255 @Returns('NodeList|HtmlCollection') | |
7256 HtmlCollection _getElementsByTagName(String name) { | |
7257 return _getElementsByTagName_1(name); | |
7258 } | |
7259 @JSName('getElementsByTagName') | |
7260 @DomName('Element.getElementsByTagName') | |
7261 @DocsEditable() | |
7262 @Creates('NodeList|HtmlCollection') | |
7263 @Returns('NodeList|HtmlCollection') | |
7264 HtmlCollection _getElementsByTagName_1(name) => wrap_jso(JS("HtmlCollection ",
"#.raw.getElementsByTagName(#)", this, unwrap_jso(name))); | |
7265 | |
7266 @DomName('Element.hasAttribute') | |
7267 @DocsEditable() | |
7268 bool _hasAttribute(String name) { | |
7269 return _hasAttribute_1(name); | |
7270 } | |
7271 @JSName('hasAttribute') | |
7272 @DomName('Element.hasAttribute') | |
7273 @DocsEditable() | |
7274 bool _hasAttribute_1(name) => wrap_jso(JS("bool ", "#.raw.hasAttribute(#)", th
is, unwrap_jso(name))); | |
7275 | |
7276 @DomName('Element.hasAttributeNS') | |
7277 @DocsEditable() | |
7278 bool _hasAttributeNS(String namespaceURI, String localName) { | |
7279 return _hasAttributeNS_1(namespaceURI, localName); | |
7280 } | |
7281 @JSName('hasAttributeNS') | |
7282 @DomName('Element.hasAttributeNS') | |
7283 @DocsEditable() | |
7284 bool _hasAttributeNS_1(namespaceURI, localName) => wrap_jso(JS("bool ", "#.raw
.hasAttributeNS(#, #)", this, unwrap_jso(namespaceURI), unwrap_jso(localName))); | |
7285 | |
7286 @DomName('Element.removeAttribute') | |
7287 @DocsEditable() | |
7288 void _removeAttribute(String name) { | |
7289 _removeAttribute_1(name); | |
7290 return; | |
7291 } | |
7292 @JSName('removeAttribute') | |
7293 @DomName('Element.removeAttribute') | |
7294 @DocsEditable() | |
7295 void _removeAttribute_1(name) => wrap_jso(JS("void ", "#.raw.removeAttribute(#
)", this, unwrap_jso(name))); | |
7296 | |
7297 @DomName('Element.removeAttributeNS') | |
7298 @DocsEditable() | |
7299 void _removeAttributeNS(String namespaceURI, String localName) { | |
7300 _removeAttributeNS_1(namespaceURI, localName); | |
7301 return; | |
7302 } | |
7303 @JSName('removeAttributeNS') | |
7304 @DomName('Element.removeAttributeNS') | |
7305 @DocsEditable() | |
7306 void _removeAttributeNS_1(namespaceURI, localName) => wrap_jso(JS("void ", "#.
raw.removeAttributeNS(#, #)", this, unwrap_jso(namespaceURI), unwrap_jso(localNa
me))); | |
7307 | |
7308 @DomName('Element.requestFullscreen') | |
7309 @DocsEditable() | |
7310 @Experimental() // untriaged | |
7311 void requestFullscreen() { | |
7312 _requestFullscreen_1(); | |
7313 return; | |
7314 } | |
7315 @JSName('requestFullscreen') | |
7316 @DomName('Element.requestFullscreen') | |
7317 @DocsEditable() | |
7318 @Experimental() // untriaged | |
7319 void _requestFullscreen_1() => wrap_jso(JS("void ", "#.raw.requestFullscreen()
", this)); | |
7320 | |
7321 @DomName('Element.requestPointerLock') | |
7322 @DocsEditable() | |
7323 @Experimental() // untriaged | |
7324 void requestPointerLock() { | |
7325 _requestPointerLock_1(); | |
7326 return; | |
7327 } | |
7328 @JSName('requestPointerLock') | |
7329 @DomName('Element.requestPointerLock') | |
7330 @DocsEditable() | |
7331 @Experimental() // untriaged | |
7332 void _requestPointerLock_1() => wrap_jso(JS("void ", "#.raw.requestPointerLock
()", this)); | |
7333 | |
7334 @DomName('Element.scrollIntoView') | |
7335 @DocsEditable() | |
7336 void _scrollIntoView([bool alignWithTop]) { | |
7337 if (alignWithTop != null) { | |
7338 _scrollIntoView_1(alignWithTop); | |
7339 return; | |
7340 } | |
7341 _scrollIntoView_2(); | |
7342 return; | |
7343 } | |
7344 @JSName('scrollIntoView') | |
7345 @DomName('Element.scrollIntoView') | |
7346 @DocsEditable() | |
7347 void _scrollIntoView_1(alignWithTop) => wrap_jso(JS("void ", "#.raw.scrollInto
View(#)", this, unwrap_jso(alignWithTop))); | |
7348 @JSName('scrollIntoView') | |
7349 @DomName('Element.scrollIntoView') | |
7350 @DocsEditable() | |
7351 void _scrollIntoView_2() => wrap_jso(JS("void ", "#.raw.scrollIntoView()", thi
s)); | |
7352 | |
7353 @DomName('Element.scrollIntoViewIfNeeded') | |
7354 @DocsEditable() | |
7355 // http://docs.webplatform.org/wiki/dom/methods/scrollIntoViewIfNeeded | |
7356 @Experimental() // non-standard | |
7357 void _scrollIntoViewIfNeeded([bool centerIfNeeded]) { | |
7358 if (centerIfNeeded != null) { | |
7359 _scrollIntoViewIfNeeded_1(centerIfNeeded); | |
7360 return; | |
7361 } | |
7362 _scrollIntoViewIfNeeded_2(); | |
7363 return; | |
7364 } | |
7365 @JSName('scrollIntoViewIfNeeded') | |
7366 @DomName('Element.scrollIntoViewIfNeeded') | |
7367 @DocsEditable() | |
7368 // http://docs.webplatform.org/wiki/dom/methods/scrollIntoViewIfNeeded | |
7369 @Experimental() // non-standard | |
7370 void _scrollIntoViewIfNeeded_1(centerIfNeeded) => wrap_jso(JS("void ", "#.raw.
scrollIntoViewIfNeeded(#)", this, unwrap_jso(centerIfNeeded))); | |
7371 @JSName('scrollIntoViewIfNeeded') | |
7372 @DomName('Element.scrollIntoViewIfNeeded') | |
7373 @DocsEditable() | |
7374 // http://docs.webplatform.org/wiki/dom/methods/scrollIntoViewIfNeeded | |
7375 @Experimental() // non-standard | |
7376 void _scrollIntoViewIfNeeded_2() => wrap_jso(JS("void ", "#.raw.scrollIntoView
IfNeeded()", this)); | |
7377 | |
7378 @DomName('Element.setAttribute') | |
7379 @DocsEditable() | |
7380 void setAttribute(String name, String value) { | |
7381 _setAttribute_1(name, value); | |
7382 return; | |
7383 } | |
7384 @JSName('setAttribute') | |
7385 @DomName('Element.setAttribute') | |
7386 @DocsEditable() | |
7387 void _setAttribute_1(name, value) => wrap_jso(JS("void ", "#.raw.setAttribute(
#, #)", this, unwrap_jso(name), unwrap_jso(value))); | |
7388 | |
7389 @DomName('Element.setAttributeNS') | |
7390 @DocsEditable() | |
7391 void setAttributeNS(String namespaceURI, String qualifiedName, String value) { | |
7392 _setAttributeNS_1(namespaceURI, qualifiedName, value); | |
7393 return; | |
7394 } | |
7395 @JSName('setAttributeNS') | |
7396 @DomName('Element.setAttributeNS') | |
7397 @DocsEditable() | |
7398 void _setAttributeNS_1(namespaceURI, qualifiedName, value) => wrap_jso(JS("voi
d ", "#.raw.setAttributeNS(#, #, #)", this, unwrap_jso(namespaceURI), unwrap_jso
(qualifiedName), unwrap_jso(value))); | |
7399 | |
7400 // From ChildNode | |
7401 | |
7402 @DomName('Element.nextElementSibling') | |
7403 @DocsEditable() | |
7404 Element get nextElementSibling => wrap_jso(JS("Element", "#.nextElementSibling
", this.raw)); | |
7405 | |
7406 @DomName('Element.previousElementSibling') | |
7407 @DocsEditable() | |
7408 Element get previousElementSibling => wrap_jso(JS("Element", "#.previousElemen
tSibling", this.raw)); | |
7409 | |
7410 // From ParentNode | |
7411 | |
7412 @JSName('childElementCount') | |
7413 @DomName('Element.childElementCount') | |
7414 @DocsEditable() | |
7415 int get _childElementCount => wrap_jso(JS("int", "#.childElementCount", this.r
aw)); | |
7416 | |
7417 @JSName('children') | |
7418 @DomName('Element.children') | |
7419 @DocsEditable() | |
7420 @Returns('HtmlCollection') | |
7421 @Creates('HtmlCollection') | |
7422 List<Node> get _children => wrap_jso(JS("List<Node>", "#.children", this.raw))
; | |
7423 | |
7424 @JSName('firstElementChild') | |
7425 @DomName('Element.firstElementChild') | |
7426 @DocsEditable() | |
7427 Element get _firstElementChild => wrap_jso(JS("Element", "#.firstElementChild"
, this.raw)); | |
7428 | |
7429 @JSName('lastElementChild') | |
7430 @DomName('Element.lastElementChild') | |
7431 @DocsEditable() | |
7432 Element get _lastElementChild => wrap_jso(JS("Element", "#.lastElementChild",
this.raw)); | |
7433 | |
7434 /** | |
7435 * Finds the first descendant element of this element that matches the | |
7436 * specified group of selectors. | |
7437 * | |
7438 * [selectors] should be a string using CSS selector syntax. | |
7439 * | |
7440 * // Gets the first descendant with the class 'classname' | |
7441 * var element = element.querySelector('.className'); | |
7442 * // Gets the element with id 'id' | |
7443 * var element = element.querySelector('#id'); | |
7444 * // Gets the first descendant [ImageElement] | |
7445 * var img = element.querySelector('img'); | |
7446 * | |
7447 * For details about CSS selector syntax, see the | |
7448 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
7449 */ | |
7450 @DomName('Element.querySelector') | |
7451 @DocsEditable() | |
7452 Element querySelector(String selectors) { | |
7453 return _querySelector_1(selectors); | |
7454 } | |
7455 @JSName('querySelector') | |
7456 /** | |
7457 * Finds the first descendant element of this element that matches the | |
7458 * specified group of selectors. | |
7459 * | |
7460 * [selectors] should be a string using CSS selector syntax. | |
7461 * | |
7462 * // Gets the first descendant with the class 'classname' | |
7463 * var element = element.querySelector('.className'); | |
7464 * // Gets the element with id 'id' | |
7465 * var element = element.querySelector('#id'); | |
7466 * // Gets the first descendant [ImageElement] | |
7467 * var img = element.querySelector('img'); | |
7468 * | |
7469 * For details about CSS selector syntax, see the | |
7470 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
7471 */ | |
7472 @DomName('Element.querySelector') | |
7473 @DocsEditable() | |
7474 Element _querySelector_1(selectors) => wrap_jso(JS("Element ", "#.raw.querySel
ector(#)", this, unwrap_jso(selectors))); | |
7475 | |
7476 @DomName('Element.querySelectorAll') | |
7477 @DocsEditable() | |
7478 @Returns('NodeList') | |
7479 @Creates('NodeList') | |
7480 NodeList _querySelectorAll(String selectors) { | |
7481 return _querySelectorAll_1(selectors); | |
7482 } | |
7483 @JSName('querySelectorAll') | |
7484 @DomName('Element.querySelectorAll') | |
7485 @DocsEditable() | |
7486 @Returns('NodeList') | |
7487 @Creates('NodeList') | |
7488 NodeList _querySelectorAll_1(selectors) => wrap_jso(JS("NodeList ", "#.raw.que
rySelectorAll(#)", this, unwrap_jso(selectors))); | |
7489 | |
7490 /// Stream of `beforecopy` events handled by this [Element]. | |
7491 @DomName('Element.onbeforecopy') | |
7492 @DocsEditable() | |
7493 ElementStream<Event> get onBeforeCopy => beforeCopyEvent.forElement(this); | |
7494 | |
7495 /// Stream of `beforecut` events handled by this [Element]. | |
7496 @DomName('Element.onbeforecut') | |
7497 @DocsEditable() | |
7498 ElementStream<Event> get onBeforeCut => beforeCutEvent.forElement(this); | |
7499 | |
7500 /// Stream of `beforepaste` events handled by this [Element]. | |
7501 @DomName('Element.onbeforepaste') | |
7502 @DocsEditable() | |
7503 ElementStream<Event> get onBeforePaste => beforePasteEvent.forElement(this); | |
7504 | |
7505 /// Stream of `copy` events handled by this [Element]. | |
7506 @DomName('Element.oncopy') | |
7507 @DocsEditable() | |
7508 ElementStream<Event> get onCopy => copyEvent.forElement(this); | |
7509 | |
7510 /// Stream of `cut` events handled by this [Element]. | |
7511 @DomName('Element.oncut') | |
7512 @DocsEditable() | |
7513 ElementStream<Event> get onCut => cutEvent.forElement(this); | |
7514 | |
7515 /// Stream of `paste` events handled by this [Element]. | |
7516 @DomName('Element.onpaste') | |
7517 @DocsEditable() | |
7518 ElementStream<Event> get onPaste => pasteEvent.forElement(this); | |
7519 | |
7520 /// Stream of `search` events handled by this [Element]. | |
7521 @DomName('Element.onsearch') | |
7522 @DocsEditable() | |
7523 // http://www.w3.org/TR/html-markup/input.search.html | |
7524 @Experimental() | |
7525 ElementStream<Event> get onSearch => searchEvent.forElement(this); | |
7526 | |
7527 /// Stream of `selectstart` events handled by this [Element]. | |
7528 @DomName('Element.onselectstart') | |
7529 @DocsEditable() | |
7530 @Experimental() // nonstandard | |
7531 ElementStream<Event> get onSelectStart => selectStartEvent.forElement(this); | |
7532 | |
7533 /// Stream of `fullscreenchange` events handled by this [Element]. | |
7534 @DomName('Element.onwebkitfullscreenchange') | |
7535 @DocsEditable() | |
7536 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html | |
7537 @Experimental() | |
7538 ElementStream<Event> get onFullscreenChange => fullscreenChangeEvent.forElemen
t(this); | |
7539 | |
7540 /// Stream of `fullscreenerror` events handled by this [Element]. | |
7541 @DomName('Element.onwebkitfullscreenerror') | |
7542 @DocsEditable() | |
7543 // https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html | |
7544 @Experimental() | |
7545 ElementStream<Event> get onFullscreenError => fullscreenErrorEvent.forElement(
this); | |
7546 | |
7547 } | |
7548 | |
7549 | |
7550 class _ElementFactoryProvider { | |
7551 | |
7552 @DomName('Document.createElement') | |
7553 static Element createElement_tag(String tag, String typeExtension) => | |
7554 document.createElement(tag, typeExtension); | |
7555 } | |
7556 | |
7557 | |
7558 /** | |
7559 * Options for Element.scrollIntoView. | |
7560 */ | |
7561 class ScrollAlignment { | |
7562 final _value; | |
7563 const ScrollAlignment._internal(this._value); | |
7564 toString() => 'ScrollAlignment.$_value'; | |
7565 | |
7566 /// Attempt to align the element to the top of the scrollable area. | |
7567 static const TOP = const ScrollAlignment._internal('TOP'); | |
7568 /// Attempt to center the element in the scrollable area. | |
7569 static const CENTER = const ScrollAlignment._internal('CENTER'); | |
7570 /// Attempt to align the element to the bottom of the scrollable area. | |
7571 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); | |
7572 } | |
7573 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
7574 // for details. All rights reserved. Use of this source code is governed by a | |
7575 // BSD-style license that can be found in the LICENSE file. | |
7576 | |
7577 // WARNING: Do not edit - generated code. | |
7578 | |
7579 | |
7580 @DomName('Event') | |
7581 @Native("Event,InputEvent,ClipboardEvent") | |
7582 class Event extends DartHtmlDomObject { | |
7583 // In JS, canBubble and cancelable are technically required parameters to | |
7584 // init*Event. In practice, though, if they aren't provided they simply | |
7585 // default to false (since that's Boolean(undefined)). | |
7586 // | |
7587 // Contrary to JS, we default canBubble and cancelable to true, since that's | |
7588 // what people want most of the time anyway. | |
7589 factory Event(String type, | |
7590 {bool canBubble: true, bool cancelable: true}) { | |
7591 return new Event.eventType('Event', type, canBubble: canBubble, | |
7592 cancelable: cancelable); | |
7593 } | |
7594 | |
7595 /** | |
7596 * Creates a new Event object of the specified type. | |
7597 * | |
7598 * This is analogous to document.createEvent. | |
7599 * Normally events should be created via their constructors, if available. | |
7600 * | |
7601 * var e = new Event.type('MouseEvent', 'mousedown', true, true); | |
7602 */ | |
7603 factory Event.eventType(String type, String name, {bool canBubble: true, | |
7604 bool cancelable: true}) { | |
7605 final Event e = document._createEvent(type); | |
7606 e._initEvent(name, canBubble, cancelable); | |
7607 return e; | |
7608 } | |
7609 | |
7610 /** The CSS selector involved with event delegation. */ | |
7611 String _selector; | |
7612 | |
7613 /** | |
7614 * A pointer to the element whose CSS selector matched within which an event | |
7615 * was fired. If this Event was not associated with any Event delegation, | |
7616 * accessing this value will throw an [UnsupportedError]. | |
7617 */ | |
7618 Element get matchingTarget { | |
7619 if (_selector == null) { | |
7620 throw new UnsupportedError('Cannot call matchingTarget if this Event did' | |
7621 ' not arise as a result of event delegation.'); | |
7622 } | |
7623 Element currentTarget = this.currentTarget; | |
7624 Element target = this.target; | |
7625 var matchedTarget; | |
7626 do { | |
7627 if (target.matches(_selector)) return target; | |
7628 target = target.parent; | |
7629 } while (target != null && target != currentTarget.parent); | |
7630 throw new StateError('No selector matched for populating matchedTarget.'); | |
7631 } | |
7632 // To suppress missing implicit constructor warnings. | |
7633 factory Event._() { throw new UnsupportedError("Not supported"); } | |
7634 | |
7635 @Deprecated("Internal Use Only") | |
7636 static Event internalCreateEvent() { | |
7637 return new Event.internal_(); | |
7638 } | |
7639 | |
7640 @Deprecated("Internal Use Only") | |
7641 Event.internal_() { } | |
7642 | |
7643 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
7644 int get hashCode => unwrap_jso(this).hashCode; | |
7645 | |
7646 /** | |
7647 * This event is being handled by the event target. | |
7648 * | |
7649 * ## Other resources | |
7650 * | |
7651 * * [Target phase] (http://www.w3.org/TR/DOM-Level-3-Events/#target-phase) | |
7652 * from W3C. | |
7653 */ | |
7654 @DomName('Event.AT_TARGET') | |
7655 @DocsEditable() | |
7656 static const int AT_TARGET = 2; | |
7657 | |
7658 /** | |
7659 * This event is bubbling up through the target's ancestors. | |
7660 * | |
7661 * ## Other resources | |
7662 * | |
7663 * * [Bubble phase] (http://www.w3.org/TR/DOM-Level-3-Events/#bubble-phase) | |
7664 * from W3C. | |
7665 */ | |
7666 @DomName('Event.BUBBLING_PHASE') | |
7667 @DocsEditable() | |
7668 static const int BUBBLING_PHASE = 3; | |
7669 | |
7670 /** | |
7671 * This event is propagating through the target's ancestors, starting from the | |
7672 * document. | |
7673 * | |
7674 * ## Other resources | |
7675 * | |
7676 * * [Bubble phase] (http://www.w3.org/TR/DOM-Level-3-Events/#bubble-phase) | |
7677 * from W3C. | |
7678 */ | |
7679 @DomName('Event.CAPTURING_PHASE') | |
7680 @DocsEditable() | |
7681 static const int CAPTURING_PHASE = 1; | |
7682 | |
7683 @DomName('Event.bubbles') | |
7684 @DocsEditable() | |
7685 bool get bubbles => wrap_jso(JS("bool", "#.bubbles", this.raw)); | |
7686 | |
7687 @DomName('Event.cancelable') | |
7688 @DocsEditable() | |
7689 bool get cancelable => wrap_jso(JS("bool", "#.cancelable", this.raw)); | |
7690 | |
7691 @DomName('Event.currentTarget') | |
7692 @DocsEditable() | |
7693 EventTarget get currentTarget => _convertNativeToDart_EventTarget(this._get_cu
rrentTarget); | |
7694 @JSName('currentTarget') | |
7695 @DomName('Event.currentTarget') | |
7696 @DocsEditable() | |
7697 @Creates('Null') | |
7698 @Returns('EventTarget|=Object') | |
7699 dynamic get _get_currentTarget => wrap_jso(JS("dynamic", "#.currentTarget", th
is.raw)); | |
7700 | |
7701 @DomName('Event.defaultPrevented') | |
7702 @DocsEditable() | |
7703 bool get defaultPrevented => wrap_jso(JS("bool", "#.defaultPrevented", this.ra
w)); | |
7704 | |
7705 @DomName('Event.eventPhase') | |
7706 @DocsEditable() | |
7707 int get eventPhase => wrap_jso(JS("int", "#.eventPhase", this.raw)); | |
7708 | |
7709 /** | |
7710 * This event's path, taking into account shadow DOM. | |
7711 * | |
7712 * ## Other resources | |
7713 * | |
7714 * * [Shadow DOM extensions to Event] | |
7715 * (http://w3c.github.io/webcomponents/spec/shadow/#extensions-to-event) from | |
7716 * W3C. | |
7717 */ | |
7718 @DomName('Event.path') | |
7719 @DocsEditable() | |
7720 // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#ex
tensions-to-event | |
7721 @Experimental() | |
7722 @Returns('NodeList') | |
7723 @Creates('NodeList') | |
7724 List<Node> get path => wrap_jso(JS("List<Node>", "#.path", this.raw)); | |
7725 | |
7726 @DomName('Event.target') | |
7727 @DocsEditable() | |
7728 EventTarget get target => _convertNativeToDart_EventTarget(this._get_target); | |
7729 @JSName('target') | |
7730 @DomName('Event.target') | |
7731 @DocsEditable() | |
7732 @Creates('Node') | |
7733 @Returns('EventTarget|=Object') | |
7734 dynamic get _get_target => wrap_jso(JS("dynamic", "#.target", this.raw)); | |
7735 | |
7736 @DomName('Event.timeStamp') | |
7737 @DocsEditable() | |
7738 int get timeStamp => wrap_jso(JS("int", "#.timeStamp", this.raw)); | |
7739 | |
7740 @DomName('Event.type') | |
7741 @DocsEditable() | |
7742 String get type => wrap_jso(JS("String", "#.type", this.raw)); | |
7743 | |
7744 @DomName('Event.initEvent') | |
7745 @DocsEditable() | |
7746 void _initEvent(String eventTypeArg, bool canBubbleArg, bool cancelableArg) { | |
7747 _initEvent_1(eventTypeArg, canBubbleArg, cancelableArg); | |
7748 return; | |
7749 } | |
7750 @JSName('initEvent') | |
7751 @DomName('Event.initEvent') | |
7752 @DocsEditable() | |
7753 void _initEvent_1(eventTypeArg, canBubbleArg, cancelableArg) => wrap_jso(JS("v
oid ", "#.raw.initEvent(#, #, #)", this, unwrap_jso(eventTypeArg), unwrap_jso(ca
nBubbleArg), unwrap_jso(cancelableArg))); | |
7754 | |
7755 @DomName('Event.preventDefault') | |
7756 @DocsEditable() | |
7757 void preventDefault() { | |
7758 _preventDefault_1(); | |
7759 return; | |
7760 } | |
7761 @JSName('preventDefault') | |
7762 @DomName('Event.preventDefault') | |
7763 @DocsEditable() | |
7764 void _preventDefault_1() => wrap_jso(JS("void ", "#.raw.preventDefault()", thi
s)); | |
7765 | |
7766 @DomName('Event.stopImmediatePropagation') | |
7767 @DocsEditable() | |
7768 void stopImmediatePropagation() { | |
7769 _stopImmediatePropagation_1(); | |
7770 return; | |
7771 } | |
7772 @JSName('stopImmediatePropagation') | |
7773 @DomName('Event.stopImmediatePropagation') | |
7774 @DocsEditable() | |
7775 void _stopImmediatePropagation_1() => wrap_jso(JS("void ", "#.raw.stopImmediat
ePropagation()", this)); | |
7776 | |
7777 @DomName('Event.stopPropagation') | |
7778 @DocsEditable() | |
7779 void stopPropagation() { | |
7780 _stopPropagation_1(); | |
7781 return; | |
7782 } | |
7783 @JSName('stopPropagation') | |
7784 @DomName('Event.stopPropagation') | |
7785 @DocsEditable() | |
7786 void _stopPropagation_1() => wrap_jso(JS("void ", "#.raw.stopPropagation()", t
his)); | |
7787 | |
7788 } | |
7789 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
7790 // for details. All rights reserved. Use of this source code is governed by a | |
7791 // BSD-style license that can be found in the LICENSE file. | |
7792 | |
7793 | |
7794 /** | |
7795 * Base class that supports listening for and dispatching browser events. | |
7796 * | |
7797 * Normally events are accessed via the Stream getter: | |
7798 * | |
7799 * element.onMouseOver.listen((e) => print('Mouse over!')); | |
7800 * | |
7801 * To access bubbling events which are declared on one element, but may bubble | |
7802 * up to another element type (common for MediaElement events): | |
7803 * | |
7804 * MediaElement.pauseEvent.forTarget(document.body).listen(...); | |
7805 * | |
7806 * To useCapture on events: | |
7807 * | |
7808 * Element.keyDownEvent.forTarget(element, useCapture: true).listen(...); | |
7809 * | |
7810 * Custom events can be declared as: | |
7811 * | |
7812 * class DataGenerator { | |
7813 * static EventStreamProvider<Event> dataEvent = | |
7814 * new EventStreamProvider('data'); | |
7815 * } | |
7816 * | |
7817 * Then listeners should access the event with: | |
7818 * | |
7819 * DataGenerator.dataEvent.forTarget(element).listen(...); | |
7820 * | |
7821 * Custom events can also be accessed as: | |
7822 * | |
7823 * element.on['some_event'].listen(...); | |
7824 * | |
7825 * This approach is generally discouraged as it loses the event typing and | |
7826 * some DOM events may have multiple platform-dependent event names under the | |
7827 * covers. By using the standard Stream getters you will get the platform | |
7828 * specific event name automatically. | |
7829 */ | |
7830 class Events { | |
7831 /* Raw event target. */ | |
7832 final EventTarget _ptr; | |
7833 | |
7834 Events(this._ptr); | |
7835 | |
7836 Stream operator [](String type) { | |
7837 return new _EventStream(_ptr, type, false); | |
7838 } | |
7839 } | |
7840 | |
7841 class ElementEvents extends Events { | |
7842 /* Raw event target. */ | |
7843 static final webkitEvents = { | |
7844 'animationend' : 'webkitAnimationEnd', | |
7845 'animationiteration' : 'webkitAnimationIteration', | |
7846 'animationstart' : 'webkitAnimationStart', | |
7847 'fullscreenchange' : 'webkitfullscreenchange', | |
7848 'fullscreenerror' : 'webkitfullscreenerror', | |
7849 'keyadded' : 'webkitkeyadded', | |
7850 'keyerror' : 'webkitkeyerror', | |
7851 'keymessage' : 'webkitkeymessage', | |
7852 'needkey' : 'webkitneedkey', | |
7853 'pointerlockchange' : 'webkitpointerlockchange', | |
7854 'pointerlockerror' : 'webkitpointerlockerror', | |
7855 'resourcetimingbufferfull' : 'webkitresourcetimingbufferfull', | |
7856 'transitionend': 'webkitTransitionEnd', | |
7857 'speechchange' : 'webkitSpeechChange' | |
7858 }; | |
7859 | |
7860 ElementEvents(Element ptr) : super(ptr); | |
7861 | |
7862 Stream operator [](String type) { | |
7863 if (webkitEvents.keys.contains(type.toLowerCase())) { | |
7864 if (Device.isWebKit) { | |
7865 return new _ElementEventStreamImpl( | |
7866 _ptr, webkitEvents[type.toLowerCase()], false); | |
7867 } | |
7868 } | |
7869 return new _ElementEventStreamImpl(_ptr, type, false); | |
7870 } | |
7871 } | |
7872 | |
7873 /** | |
7874 * Base class for all browser objects that support events. | |
7875 * | |
7876 * Use the [on] property to add, and remove events | |
7877 * for compile-time type checks and a more concise API. | |
7878 */ | |
7879 @DomName('EventTarget') | |
7880 @Native("EventTarget") | |
7881 class EventTarget extends DartHtmlDomObject { | |
7882 | |
7883 // Custom element created callback. | |
7884 EventTarget._created(); | |
7885 | |
7886 /** | |
7887 * This is an ease-of-use accessor for event streams which should only be | |
7888 * used when an explicit accessor is not available. | |
7889 */ | |
7890 Events get on => new Events(this); | |
7891 | |
7892 void addEventListener(String type, EventListener listener, [bool useCapture])
{ | |
7893 // TODO(leafp): This check is avoid a bug in our dispatch code when | |
7894 // listener is null. The browser treats this call as a no-op in this | |
7895 // case, so it's fine to short-circuit it, but we should not have to. | |
7896 if (listener != null) { | |
7897 _addEventListener(type, listener, useCapture); | |
7898 } | |
7899 } | |
7900 | |
7901 void removeEventListener(String type, EventListener listener, [bool useCapture
]) { | |
7902 // TODO(leafp): This check is avoid a bug in our dispatch code when | |
7903 // listener is null. The browser treats this call as a no-op in this | |
7904 // case, so it's fine to short-circuit it, but we should not have to. | |
7905 if (listener != null) { | |
7906 _removeEventListener(type, listener, useCapture); | |
7907 } | |
7908 } | |
7909 | |
7910 // To suppress missing implicit constructor warnings. | |
7911 factory EventTarget._() { throw new UnsupportedError("Not supported"); } | |
7912 | |
7913 @Deprecated("Internal Use Only") | |
7914 static EventTarget internalCreateEventTarget() { | |
7915 return new EventTarget.internal_(); | |
7916 } | |
7917 | |
7918 @Deprecated("Internal Use Only") | |
7919 EventTarget.internal_() { } | |
7920 | |
7921 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
7922 int get hashCode => unwrap_jso(this).hashCode; | |
7923 | |
7924 @DomName('EventTarget.addEventListener') | |
7925 @DocsEditable() | |
7926 void _addEventListener([String type, EventListener listener, bool useCapture])
{ | |
7927 if (useCapture != null) { | |
7928 _addEventListener_1(type, listener, useCapture); | |
7929 return; | |
7930 } | |
7931 if (listener != null) { | |
7932 _addEventListener_2(type, listener); | |
7933 return; | |
7934 } | |
7935 if (type != null) { | |
7936 _addEventListener_3(type); | |
7937 return; | |
7938 } | |
7939 _addEventListener_4(); | |
7940 return; | |
7941 } | |
7942 @JSName('addEventListener') | |
7943 @DomName('EventTarget.addEventListener') | |
7944 @DocsEditable() | |
7945 void _addEventListener_1(type, EventListener listener, useCapture) => wrap_jso
(JS("void ", "#.raw.addEventListener(#, #, #)", this, unwrap_jso(type), unwrap_j
so(listener), unwrap_jso(useCapture))); | |
7946 @JSName('addEventListener') | |
7947 @DomName('EventTarget.addEventListener') | |
7948 @DocsEditable() | |
7949 void _addEventListener_2(type, EventListener listener) => wrap_jso(JS("void ",
"#.raw.addEventListener(#, #)", this, unwrap_jso(type), unwrap_jso(listener))); | |
7950 @JSName('addEventListener') | |
7951 @DomName('EventTarget.addEventListener') | |
7952 @DocsEditable() | |
7953 void _addEventListener_3(type) => wrap_jso(JS("void ", "#.raw.addEventListener
(#)", this, unwrap_jso(type))); | |
7954 @JSName('addEventListener') | |
7955 @DomName('EventTarget.addEventListener') | |
7956 @DocsEditable() | |
7957 void _addEventListener_4() => wrap_jso(JS("void ", "#.raw.addEventListener()",
this)); | |
7958 | |
7959 @DomName('EventTarget.dispatchEvent') | |
7960 @DocsEditable() | |
7961 bool dispatchEvent(Event event) { | |
7962 return _dispatchEvent_1(event); | |
7963 } | |
7964 @JSName('dispatchEvent') | |
7965 @DomName('EventTarget.dispatchEvent') | |
7966 @DocsEditable() | |
7967 bool _dispatchEvent_1(Event event) => wrap_jso(JS("bool ", "#.raw.dispatchEven
t(#)", this, unwrap_jso(event))); | |
7968 | |
7969 @DomName('EventTarget.removeEventListener') | |
7970 @DocsEditable() | |
7971 void _removeEventListener([String type, EventListener listener, bool useCaptur
e]) { | |
7972 if (useCapture != null) { | |
7973 _removeEventListener_1(type, listener, useCapture); | |
7974 return; | |
7975 } | |
7976 if (listener != null) { | |
7977 _removeEventListener_2(type, listener); | |
7978 return; | |
7979 } | |
7980 if (type != null) { | |
7981 _removeEventListener_3(type); | |
7982 return; | |
7983 } | |
7984 _removeEventListener_4(); | |
7985 return; | |
7986 } | |
7987 @JSName('removeEventListener') | |
7988 @DomName('EventTarget.removeEventListener') | |
7989 @DocsEditable() | |
7990 void _removeEventListener_1(type, EventListener listener, useCapture) => wrap_
jso(JS("void ", "#.raw.removeEventListener(#, #, #)", this, unwrap_jso(type), un
wrap_jso(listener), unwrap_jso(useCapture))); | |
7991 @JSName('removeEventListener') | |
7992 @DomName('EventTarget.removeEventListener') | |
7993 @DocsEditable() | |
7994 void _removeEventListener_2(type, EventListener listener) => wrap_jso(JS("void
", "#.raw.removeEventListener(#, #)", this, unwrap_jso(type), unwrap_jso(listen
er))); | |
7995 @JSName('removeEventListener') | |
7996 @DomName('EventTarget.removeEventListener') | |
7997 @DocsEditable() | |
7998 void _removeEventListener_3(type) => wrap_jso(JS("void ", "#.raw.removeEventLi
stener(#)", this, unwrap_jso(type))); | |
7999 @JSName('removeEventListener') | |
8000 @DomName('EventTarget.removeEventListener') | |
8001 @DocsEditable() | |
8002 void _removeEventListener_4() => wrap_jso(JS("void ", "#.raw.removeEventListen
er()", this)); | |
8003 | |
8004 } | |
8005 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
8006 // for details. All rights reserved. Use of this source code is governed by a | |
8007 // BSD-style license that can be found in the LICENSE file. | |
8008 | |
8009 | |
8010 @DocsEditable() | |
8011 @DomName('HTMLHeadElement') | |
8012 @Native("HTMLHeadElement") | |
8013 class HeadElement extends HtmlElement { | |
8014 // To suppress missing implicit constructor warnings. | |
8015 factory HeadElement._() { throw new UnsupportedError("Not supported"); } | |
8016 | |
8017 @DomName('HTMLHeadElement.HTMLHeadElement') | |
8018 @DocsEditable() | |
8019 factory HeadElement() => document.createElement("head"); | |
8020 | |
8021 | |
8022 @Deprecated("Internal Use Only") | |
8023 static HeadElement internalCreateHeadElement() { | |
8024 return new HeadElement.internal_(); | |
8025 } | |
8026 | |
8027 @Deprecated("Internal Use Only") | |
8028 HeadElement.internal_() : super.internal_(); | |
8029 | |
8030 } | |
8031 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
8032 // for details. All rights reserved. Use of this source code is governed by a | |
8033 // BSD-style license that can be found in the LICENSE file. | |
8034 | |
8035 | |
8036 @DomName('History') | |
8037 @Native("History") | |
8038 class History extends DartHtmlDomObject implements HistoryBase { | |
8039 | |
8040 /** | |
8041 * Checks if the State APIs are supported on the current platform. | |
8042 * | |
8043 * See also: | |
8044 * | |
8045 * * [pushState] | |
8046 * * [replaceState] | |
8047 * * [state] | |
8048 */ | |
8049 static bool get supportsState => true; | |
8050 // To suppress missing implicit constructor warnings. | |
8051 factory History._() { throw new UnsupportedError("Not supported"); } | |
8052 | |
8053 @Deprecated("Internal Use Only") | |
8054 static History internalCreateHistory() { | |
8055 return new History.internal_(); | |
8056 } | |
8057 | |
8058 @Deprecated("Internal Use Only") | |
8059 History.internal_() { } | |
8060 | |
8061 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
8062 int get hashCode => unwrap_jso(this).hashCode; | |
8063 | |
8064 @DomName('History.length') | |
8065 @DocsEditable() | |
8066 int get length => wrap_jso(JS("int", "#.length", this.raw)); | |
8067 | |
8068 @DomName('History.state') | |
8069 @DocsEditable() | |
8070 dynamic get state => convertNativeToDart_SerializedScriptValue(this._get_state
); | |
8071 @JSName('state') | |
8072 @DomName('History.state') | |
8073 @DocsEditable() | |
8074 @annotation_Creates_SerializedScriptValue | |
8075 @annotation_Returns_SerializedScriptValue | |
8076 dynamic get _get_state => wrap_jso(JS("dynamic", "#.state", this.raw)); | |
8077 | |
8078 @DomName('History.back') | |
8079 @DocsEditable() | |
8080 void back() { | |
8081 _back_1(); | |
8082 return; | |
8083 } | |
8084 @JSName('back') | |
8085 @DomName('History.back') | |
8086 @DocsEditable() | |
8087 void _back_1() => wrap_jso(JS("void ", "#.raw.back()", this)); | |
8088 | |
8089 @DomName('History.forward') | |
8090 @DocsEditable() | |
8091 void forward() { | |
8092 _forward_1(); | |
8093 return; | |
8094 } | |
8095 @JSName('forward') | |
8096 @DomName('History.forward') | |
8097 @DocsEditable() | |
8098 void _forward_1() => wrap_jso(JS("void ", "#.raw.forward()", this)); | |
8099 | |
8100 @DomName('History.go') | |
8101 @DocsEditable() | |
8102 void go(int distance) { | |
8103 _go_1(distance); | |
8104 return; | |
8105 } | |
8106 @JSName('go') | |
8107 @DomName('History.go') | |
8108 @DocsEditable() | |
8109 void _go_1(distance) => wrap_jso(JS("void ", "#.raw.go(#)", this, unwrap_jso(d
istance))); | |
8110 | |
8111 @DomName('History.pushState') | |
8112 @DocsEditable() | |
8113 @SupportedBrowser(SupportedBrowser.CHROME) | |
8114 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
8115 @SupportedBrowser(SupportedBrowser.IE, '10') | |
8116 @SupportedBrowser(SupportedBrowser.SAFARI) | |
8117 void pushState(/*any*/ data, String title, [String url]) { | |
8118 if (url != null) { | |
8119 var data_1 = convertDartToNative_SerializedScriptValue(data); | |
8120 _pushState_1(data_1, title, url); | |
8121 return; | |
8122 } | |
8123 var data_1 = convertDartToNative_SerializedScriptValue(data); | |
8124 _pushState_2(data_1, title); | |
8125 return; | |
8126 } | |
8127 @JSName('pushState') | |
8128 @DomName('History.pushState') | |
8129 @DocsEditable() | |
8130 @SupportedBrowser(SupportedBrowser.CHROME) | |
8131 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
8132 @SupportedBrowser(SupportedBrowser.IE, '10') | |
8133 @SupportedBrowser(SupportedBrowser.SAFARI) | |
8134 void _pushState_1(data, title, url) => wrap_jso(JS("void ", "#.raw.pushState(#
, #, #)", this, unwrap_jso(data), unwrap_jso(title), unwrap_jso(url))); | |
8135 @JSName('pushState') | |
8136 @DomName('History.pushState') | |
8137 @DocsEditable() | |
8138 @SupportedBrowser(SupportedBrowser.CHROME) | |
8139 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
8140 @SupportedBrowser(SupportedBrowser.IE, '10') | |
8141 @SupportedBrowser(SupportedBrowser.SAFARI) | |
8142 void _pushState_2(data, title) => wrap_jso(JS("void ", "#.raw.pushState(#, #)"
, this, unwrap_jso(data), unwrap_jso(title))); | |
8143 | |
8144 @DomName('History.replaceState') | |
8145 @DocsEditable() | |
8146 @SupportedBrowser(SupportedBrowser.CHROME) | |
8147 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
8148 @SupportedBrowser(SupportedBrowser.IE, '10') | |
8149 @SupportedBrowser(SupportedBrowser.SAFARI) | |
8150 void replaceState(/*any*/ data, String title, [String url]) { | |
8151 if (url != null) { | |
8152 var data_1 = convertDartToNative_SerializedScriptValue(data); | |
8153 _replaceState_1(data_1, title, url); | |
8154 return; | |
8155 } | |
8156 var data_1 = convertDartToNative_SerializedScriptValue(data); | |
8157 _replaceState_2(data_1, title); | |
8158 return; | |
8159 } | |
8160 @JSName('replaceState') | |
8161 @DomName('History.replaceState') | |
8162 @DocsEditable() | |
8163 @SupportedBrowser(SupportedBrowser.CHROME) | |
8164 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
8165 @SupportedBrowser(SupportedBrowser.IE, '10') | |
8166 @SupportedBrowser(SupportedBrowser.SAFARI) | |
8167 void _replaceState_1(data, title, url) => wrap_jso(JS("void ", "#.raw.replaceS
tate(#, #, #)", this, unwrap_jso(data), unwrap_jso(title), unwrap_jso(url))); | |
8168 @JSName('replaceState') | |
8169 @DomName('History.replaceState') | |
8170 @DocsEditable() | |
8171 @SupportedBrowser(SupportedBrowser.CHROME) | |
8172 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
8173 @SupportedBrowser(SupportedBrowser.IE, '10') | |
8174 @SupportedBrowser(SupportedBrowser.SAFARI) | |
8175 void _replaceState_2(data, title) => wrap_jso(JS("void ", "#.raw.replaceState(
#, #)", this, unwrap_jso(data), unwrap_jso(title))); | |
8176 } | |
8177 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
8178 // for details. All rights reserved. Use of this source code is governed by a | |
8179 // BSD-style license that can be found in the LICENSE file. | |
8180 | |
8181 | |
8182 @DocsEditable() | |
8183 @DomName('HTMLCollection') | |
8184 @Native("HTMLCollection") | |
8185 class HtmlCollection extends DartHtmlDomObject with ListMixin<Node>, ImmutableLi
stMixin<Node> implements JavaScriptIndexingBehavior, List<Node> { | |
8186 // To suppress missing implicit constructor warnings. | |
8187 factory HtmlCollection._() { throw new UnsupportedError("Not supported"); } | |
8188 | |
8189 @Deprecated("Internal Use Only") | |
8190 static HtmlCollection internalCreateHtmlCollection() { | |
8191 return new HtmlCollection.internal_(); | |
8192 } | |
8193 | |
8194 @Deprecated("Internal Use Only") | |
8195 HtmlCollection.internal_() { } | |
8196 | |
8197 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
8198 int get hashCode => unwrap_jso(this).hashCode; | |
8199 | |
8200 @DomName('HTMLCollection.length') | |
8201 @DocsEditable() | |
8202 int get length => wrap_jso(JS("int", "#.length", this.raw)); | |
8203 | |
8204 Node operator[](int index) { | |
8205 if (JS("bool", "# >>> 0 !== # || # >= #", index, | |
8206 index, index, length)) | |
8207 throw new RangeError.index(index, this); | |
8208 return wrap_jso(JS("Node", "#[#]", this.raw, index)); | |
8209 } | |
8210 void operator[]=(int index, Node value) { | |
8211 throw new UnsupportedError("Cannot assign element of immutable List."); | |
8212 } | |
8213 // -- start List<Node> mixins. | |
8214 // Node is the element type. | |
8215 | |
8216 | |
8217 set length(int value) { | |
8218 throw new UnsupportedError("Cannot resize immutable List."); | |
8219 } | |
8220 | |
8221 Node get first { | |
8222 if (this.length > 0) { | |
8223 return wrap_jso(JS('Node', '#[0]', this.raw)); | |
8224 } | |
8225 throw new StateError("No elements"); | |
8226 } | |
8227 | |
8228 Node get last { | |
8229 int len = this.length; | |
8230 if (len > 0) { | |
8231 return wrap_jso(JS('Node', '#[#]', this.raw, len - 1)); | |
8232 } | |
8233 throw new StateError("No elements"); | |
8234 } | |
8235 | |
8236 Node get single { | |
8237 int len = this.length; | |
8238 if (len == 1) { | |
8239 return wrap_jso(JS('Node', '#[0]', this.raw)); | |
8240 } | |
8241 if (len == 0) throw new StateError("No elements"); | |
8242 throw new StateError("More than one element"); | |
8243 } | |
8244 | |
8245 Node elementAt(int index) => this[index]; | |
8246 // -- end List<Node> mixins. | |
8247 | |
8248 @DomName('HTMLCollection.item') | |
8249 @DocsEditable() | |
8250 Element item(int index) { | |
8251 return _item_1(index); | |
8252 } | |
8253 @JSName('item') | |
8254 @DomName('HTMLCollection.item') | |
8255 @DocsEditable() | |
8256 Element _item_1(index) => wrap_jso(JS("Element ", "#.raw.item(#)", this, unwra
p_jso(index))); | |
8257 | |
8258 @DomName('HTMLCollection.namedItem') | |
8259 @DocsEditable() | |
8260 Element namedItem(String name) { | |
8261 return _namedItem_1(name); | |
8262 } | |
8263 @JSName('namedItem') | |
8264 @DomName('HTMLCollection.namedItem') | |
8265 @DocsEditable() | |
8266 Element _namedItem_1(name) => wrap_jso(JS("Element ", "#.raw.namedItem(#)", th
is, unwrap_jso(name))); | |
8267 } | |
8268 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
8269 // for details. All rights reserved. Use of this source code is governed by a | |
8270 // BSD-style license that can be found in the LICENSE file. | |
8271 | |
8272 // WARNING: Do not edit - generated code. | |
8273 | |
8274 | |
8275 @DomName('HTMLDocument') | |
8276 @Native("HTMLDocument") | |
8277 class HtmlDocument extends Document { | |
8278 // To suppress missing implicit constructor warnings. | |
8279 factory HtmlDocument._() { throw new UnsupportedError("Not supported"); } | |
8280 | |
8281 | |
8282 @Deprecated("Internal Use Only") | |
8283 static HtmlDocument internalCreateHtmlDocument() { | |
8284 return new HtmlDocument.internal_(); | |
8285 } | |
8286 | |
8287 @Deprecated("Internal Use Only") | |
8288 HtmlDocument.internal_() : super.internal_(); | |
8289 | |
8290 | |
8291 | |
8292 @DomName('Document.body') | |
8293 BodyElement get body => _body; | |
8294 | |
8295 @DomName('Document.body') | |
8296 set body(BodyElement value) { | |
8297 _body = value; | |
8298 } | |
8299 | |
8300 @DomName('Document.caretRangeFromPoint') | |
8301 Range caretRangeFromPoint(int x, int y) { | |
8302 return _caretRangeFromPoint(x, y); | |
8303 } | |
8304 | |
8305 @DomName('Document.elementFromPoint') | |
8306 Element elementFromPoint(int x, int y) { | |
8307 return _elementFromPoint(x, y); | |
8308 } | |
8309 | |
8310 /** | |
8311 * Checks if the getCssCanvasContext API is supported on the current platform. | |
8312 * | |
8313 * See also: | |
8314 * | |
8315 * * [getCssCanvasContext] | |
8316 */ | |
8317 static bool get supportsCssCanvasContext => | |
8318 JS('bool', '!!(document.getCSSCanvasContext)'); | |
8319 | |
8320 | |
8321 @DomName('Document.head') | |
8322 HeadElement get head => _head; | |
8323 | |
8324 @DomName('Document.lastModified') | |
8325 String get lastModified => _lastModified; | |
8326 | |
8327 @DomName('Document.preferredStylesheetSet') | |
8328 String get preferredStylesheetSet => _preferredStylesheetSet; | |
8329 | |
8330 @DomName('Document.referrer') | |
8331 String get referrer => _referrer; | |
8332 | |
8333 @DomName('Document.selectedStylesheetSet') | |
8334 String get selectedStylesheetSet => _selectedStylesheetSet; | |
8335 set selectedStylesheetSet(String value) { | |
8336 _selectedStylesheetSet = value; | |
8337 } | |
8338 | |
8339 | |
8340 @DomName('Document.title') | |
8341 String get title => _title; | |
8342 | |
8343 @DomName('Document.title') | |
8344 set title(String value) { | |
8345 _title = value; | |
8346 } | |
8347 | |
8348 /** | |
8349 * Returns page to standard layout. | |
8350 * | |
8351 * Has no effect if the page is not in fullscreen mode. | |
8352 * | |
8353 * ## Other resources | |
8354 * | |
8355 * * [Using the fullscreen API] | |
8356 * (http://docs.webplatform.org/wiki/tutorials/using_the_full-screen_api) from | |
8357 * WebPlatform.org. | |
8358 * * [Fullscreen specification] | |
8359 * (http://www.w3.org/TR/fullscreen/) from W3C. | |
8360 */ | |
8361 @DomName('Document.webkitExitFullscreen') | |
8362 @SupportedBrowser(SupportedBrowser.CHROME) | |
8363 @SupportedBrowser(SupportedBrowser.SAFARI) | |
8364 @Experimental() | |
8365 void exitFullscreen() { | |
8366 _webkitExitFullscreen(); | |
8367 } | |
8368 | |
8369 /** | |
8370 * Returns the element, if any, that is currently displayed in fullscreen. | |
8371 * | |
8372 * Returns null if there is currently no fullscreen element. You can use | |
8373 * this to determine if the page is in fullscreen mode. | |
8374 * | |
8375 * myVideo = new VideoElement(); | |
8376 * if (document.fullscreenElement == null) { | |
8377 * myVideo.requestFullscreen(); | |
8378 * print(document.fullscreenElement == myVideo); // true | |
8379 * } | |
8380 * | |
8381 * ## Other resources | |
8382 * | |
8383 * * [Using the fullscreen API] | |
8384 * (http://docs.webplatform.org/wiki/tutorials/using_the_full-screen_api) from | |
8385 * WebPlatform.org. | |
8386 * * [Fullscreen specification] | |
8387 * (http://www.w3.org/TR/fullscreen/) from W3C. | |
8388 */ | |
8389 @DomName('Document.webkitFullscreenElement') | |
8390 @SupportedBrowser(SupportedBrowser.CHROME) | |
8391 @SupportedBrowser(SupportedBrowser.SAFARI) | |
8392 @Experimental() | |
8393 Element get fullscreenElement => _webkitFullscreenElement; | |
8394 | |
8395 /** | |
8396 * Returns true if this document can display elements in fullscreen mode. | |
8397 * | |
8398 * ## Other resources | |
8399 * | |
8400 * * [Using the fullscreen API] | |
8401 * (http://docs.webplatform.org/wiki/tutorials/using_the_full-screen_api) from | |
8402 * WebPlatform.org. | |
8403 * * [Fullscreen specification] | |
8404 * (http://www.w3.org/TR/fullscreen/) from W3C. | |
8405 */ | |
8406 @DomName('Document.webkitFullscreenEnabled') | |
8407 @SupportedBrowser(SupportedBrowser.CHROME) | |
8408 @SupportedBrowser(SupportedBrowser.SAFARI) | |
8409 @Experimental() | |
8410 bool get fullscreenEnabled => _webkitFullscreenEnabled; | |
8411 | |
8412 @DomName('Document.webkitHidden') | |
8413 @SupportedBrowser(SupportedBrowser.CHROME) | |
8414 @SupportedBrowser(SupportedBrowser.SAFARI) | |
8415 @Experimental() | |
8416 bool get hidden => _webkitHidden; | |
8417 | |
8418 @DomName('Document.visibilityState') | |
8419 @SupportedBrowser(SupportedBrowser.CHROME) | |
8420 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
8421 @SupportedBrowser(SupportedBrowser.IE, '10') | |
8422 @Experimental() | |
8423 String get visibilityState => _webkitVisibilityState; | |
8424 | |
8425 @Experimental() | |
8426 /** | |
8427 * Register a custom subclass of Element to be instantiatable by the DOM. | |
8428 * | |
8429 * This is necessary to allow the construction of any custom elements. | |
8430 * | |
8431 * The class being registered must either subclass HtmlElement or SvgElement. | |
8432 * If they subclass these directly then they can be used as: | |
8433 * | |
8434 * class FooElement extends HtmlElement{ | |
8435 * void created() { | |
8436 * print('FooElement created!'); | |
8437 * } | |
8438 * } | |
8439 * | |
8440 * main() { | |
8441 * document.registerElement('x-foo', FooElement); | |
8442 * var myFoo = new Element.tag('x-foo'); | |
8443 * // prints 'FooElement created!' to the console. | |
8444 * } | |
8445 * | |
8446 * The custom element can also be instantiated via HTML using the syntax | |
8447 * `<x-foo></x-foo>` | |
8448 * | |
8449 * Other elements can be subclassed as well: | |
8450 * | |
8451 * class BarElement extends InputElement{ | |
8452 * void created() { | |
8453 * print('BarElement created!'); | |
8454 * } | |
8455 * } | |
8456 * | |
8457 * main() { | |
8458 * document.registerElement('x-bar', BarElement); | |
8459 * var myBar = new Element.tag('input', 'x-bar'); | |
8460 * // prints 'BarElement created!' to the console. | |
8461 * } | |
8462 * | |
8463 * This custom element can also be instantiated via HTML using the syntax | |
8464 * `<input is="x-bar"></input>` | |
8465 * | |
8466 */ | |
8467 void registerElement(String tag, Type customElementClass, | |
8468 {String extendsTag}) { | |
8469 _registerCustomElement(JS('', 'window'), this, tag, customElementClass, | |
8470 extendsTag); | |
8471 } | |
8472 | |
8473 /** *Deprecated*: use [registerElement] instead. */ | |
8474 @deprecated | |
8475 @Experimental() | |
8476 void register(String tag, Type customElementClass, {String extendsTag}) { | |
8477 return registerElement(tag, customElementClass, extendsTag: extendsTag); | |
8478 } | |
8479 | |
8480 /** | |
8481 * Static factory designed to expose `visibilitychange` events to event | |
8482 * handlers that are not necessarily instances of [Document]. | |
8483 * | |
8484 * See [EventStreamProvider] for usage information. | |
8485 */ | |
8486 @DomName('Document.visibilityChange') | |
8487 @SupportedBrowser(SupportedBrowser.CHROME) | |
8488 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
8489 @SupportedBrowser(SupportedBrowser.IE, '10') | |
8490 @Experimental() | |
8491 static const EventStreamProvider<Event> visibilityChangeEvent = | |
8492 const _CustomEventStreamProvider<Event>( | |
8493 _determineVisibilityChangeEventType); | |
8494 | |
8495 static String _determineVisibilityChangeEventType(EventTarget e) { | |
8496 return 'webkitvisibilitychange'; | |
8497 } | |
8498 | |
8499 @SupportedBrowser(SupportedBrowser.CHROME) | |
8500 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
8501 @SupportedBrowser(SupportedBrowser.IE, '10') | |
8502 @Experimental() | |
8503 Stream<Event> get onVisibilityChange => | |
8504 visibilityChangeEvent.forTarget(this); | |
8505 | |
8506 /// Creates an element upgrader which can be used to change the Dart wrapper | |
8507 /// type for elements. | |
8508 /// | |
8509 /// The type specified must be a subclass of HtmlElement, when an element is | |
8510 /// upgraded then the created constructor will be invoked on that element. | |
8511 /// | |
8512 /// If the type is not a direct subclass of HtmlElement then the extendsTag | |
8513 /// parameter must be provided. | |
8514 @Experimental() | |
8515 ElementUpgrader createElementUpgrader(Type type, {String extendsTag}) { | |
8516 throw 'ElementUpgrader not yet supported on DDC'; | |
8517 } | |
8518 } | |
8519 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
8520 // for details. All rights reserved. Use of this source code is governed by a | |
8521 // BSD-style license that can be found in the LICENSE file. | |
8522 | |
8523 | |
8524 @DocsEditable() | |
8525 @DomName('HTMLHtmlElement') | |
8526 @Native("HTMLHtmlElement") | |
8527 class HtmlHtmlElement extends HtmlElement { | |
8528 // To suppress missing implicit constructor warnings. | |
8529 factory HtmlHtmlElement._() { throw new UnsupportedError("Not supported"); } | |
8530 | |
8531 @DomName('HTMLHtmlElement.HTMLHtmlElement') | |
8532 @DocsEditable() | |
8533 factory HtmlHtmlElement() => document.createElement("html"); | |
8534 | |
8535 | |
8536 @Deprecated("Internal Use Only") | |
8537 static HtmlHtmlElement internalCreateHtmlHtmlElement() { | |
8538 return new HtmlHtmlElement.internal_(); | |
8539 } | |
8540 | |
8541 @Deprecated("Internal Use Only") | |
8542 HtmlHtmlElement.internal_() : super.internal_(); | |
8543 | |
8544 } | |
8545 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
8546 // for details. All rights reserved. Use of this source code is governed by a | |
8547 // BSD-style license that can be found in the LICENSE file. | |
8548 | |
8549 | |
8550 /** | |
8551 * A client-side XHR request for getting data from a URL, | |
8552 * formally known as XMLHttpRequest. | |
8553 * | |
8554 * HttpRequest can be used to obtain data from HTTP and FTP protocols, | |
8555 * and is useful for AJAX-style page updates. | |
8556 * | |
8557 * The simplest way to get the contents of a text file, such as a | |
8558 * JSON-formatted file, is with [getString]. | |
8559 * For example, the following code gets the contents of a JSON file | |
8560 * and prints its length: | |
8561 * | |
8562 * var path = 'myData.json'; | |
8563 * HttpRequest.getString(path) | |
8564 * .then((String fileContents) { | |
8565 * print(fileContents.length); | |
8566 * }) | |
8567 * .catchError((Error error) { | |
8568 * print(error.toString()); | |
8569 * }); | |
8570 * | |
8571 * ## Fetching data from other servers | |
8572 * | |
8573 * For security reasons, browsers impose restrictions on requests | |
8574 * made by embedded apps. | |
8575 * With the default behavior of this class, | |
8576 * the code making the request must be served from the same origin | |
8577 * (domain name, port, and application layer protocol) | |
8578 * as the requested resource. | |
8579 * In the example above, the myData.json file must be co-located with the | |
8580 * app that uses it. | |
8581 * You might be able to | |
8582 * [get around this restriction](http://www.dartlang.org/articles/json-web-serv
ice/#a-note-on-cors-and-httprequest) | |
8583 * by using CORS headers or JSONP. | |
8584 * | |
8585 * ## Other resources | |
8586 * | |
8587 * * [Fetch Data Dynamically](https://www.dartlang.org/docs/tutorials/fetchdata
/), | |
8588 * a tutorial from _A Game of Darts_, | |
8589 * shows two different ways to use HttpRequest to get a JSON file. | |
8590 * * [Get Input from a Form](https://www.dartlang.org/docs/tutorials/forms/), | |
8591 * another tutorial from _A Game of Darts_, | |
8592 * shows using HttpRequest with a custom server. | |
8593 * * [Dart article on using HttpRequests](http://www.dartlang.org/articles/json
-web-service/#getting-data) | |
8594 * * [JS XMLHttpRequest](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRe
quest) | |
8595 * * [Using XMLHttpRequest](https://developer.mozilla.org/en-US/docs/DOM/XMLHtt
pRequest/Using_XMLHttpRequest) | |
8596 */ | |
8597 @DomName('XMLHttpRequest') | |
8598 @Native("XMLHttpRequest") | |
8599 class HttpRequest extends HttpRequestEventTarget { | |
8600 | |
8601 /** | |
8602 * Creates a GET request for the specified [url]. | |
8603 * | |
8604 * The server response must be a `text/` mime type for this request to | |
8605 * succeed. | |
8606 * | |
8607 * This is similar to [request] but specialized for HTTP GET requests which | |
8608 * return text content. | |
8609 * | |
8610 * To add query parameters, append them to the [url] following a `?`, | |
8611 * joining each key to its value with `=` and separating key-value pairs with | |
8612 * `&`. | |
8613 * | |
8614 * var name = Uri.encodeQueryComponent('John'); | |
8615 * var id = Uri.encodeQueryComponent('42'); | |
8616 * HttpRequest.getString('users.json?name=$name&id=$id') | |
8617 * .then((HttpRequest resp) { | |
8618 * // Do something with the response. | |
8619 * }); | |
8620 * | |
8621 * See also: | |
8622 * | |
8623 * * [request] | |
8624 */ | |
8625 static Future<String> getString(String url, | |
8626 {bool withCredentials, void onProgress(ProgressEvent e)}) { | |
8627 return request(url, withCredentials: withCredentials, | |
8628 onProgress: onProgress).then((HttpRequest xhr) => xhr.responseText); | |
8629 } | |
8630 | |
8631 /** | |
8632 * Makes a server POST request with the specified data encoded as form data. | |
8633 * | |
8634 * This is roughly the POST equivalent of getString. This method is similar | |
8635 * to sending a FormData object with broader browser support but limited to | |
8636 * String values. | |
8637 * | |
8638 * If [data] is supplied, the key/value pairs are URI encoded with | |
8639 * [Uri.encodeQueryComponent] and converted into an HTTP query string. | |
8640 * | |
8641 * Unless otherwise specified, this method appends the following header: | |
8642 * | |
8643 * Content-Type: application/x-www-form-urlencoded; charset=UTF-8 | |
8644 * | |
8645 * Here's an example of using this method: | |
8646 * | |
8647 * var data = { 'firstName' : 'John', 'lastName' : 'Doe' }; | |
8648 * HttpRequest.postFormData('/send', data).then((HttpRequest resp) { | |
8649 * // Do something with the response. | |
8650 * }); | |
8651 * | |
8652 * See also: | |
8653 * | |
8654 * * [request] | |
8655 */ | |
8656 static Future<HttpRequest> postFormData(String url, Map<String, String> data, | |
8657 {bool withCredentials, String responseType, | |
8658 Map<String, String> requestHeaders, | |
8659 void onProgress(ProgressEvent e)}) { | |
8660 | |
8661 var parts = []; | |
8662 data.forEach((key, value) { | |
8663 parts.add('${Uri.encodeQueryComponent(key)}=' | |
8664 '${Uri.encodeQueryComponent(value)}'); | |
8665 }); | |
8666 var formData = parts.join('&'); | |
8667 | |
8668 if (requestHeaders == null) { | |
8669 requestHeaders = <String, String>{}; | |
8670 } | |
8671 requestHeaders.putIfAbsent('Content-Type', | |
8672 () => 'application/x-www-form-urlencoded; charset=UTF-8'); | |
8673 | |
8674 return request(url, method: 'POST', withCredentials: withCredentials, | |
8675 responseType: responseType, | |
8676 requestHeaders: requestHeaders, sendData: formData, | |
8677 onProgress: onProgress); | |
8678 } | |
8679 | |
8680 /** | |
8681 * Creates and sends a URL request for the specified [url]. | |
8682 * | |
8683 * By default `request` will perform an HTTP GET request, but a different | |
8684 * method (`POST`, `PUT`, `DELETE`, etc) can be used by specifying the | |
8685 * [method] parameter. (See also [HttpRequest.postFormData] for `POST` | |
8686 * requests only. | |
8687 * | |
8688 * The Future is completed when the response is available. | |
8689 * | |
8690 * If specified, `sendData` will send data in the form of a [ByteBuffer], | |
8691 * [Blob], [Document], [String], or [FormData] along with the HttpRequest. | |
8692 * | |
8693 * If specified, [responseType] sets the desired response format for the | |
8694 * request. By default it is [String], but can also be 'arraybuffer', 'blob', | |
8695 * 'document', 'json', or 'text'. See also [HttpRequest.responseType] | |
8696 * for more information. | |
8697 * | |
8698 * The [withCredentials] parameter specified that credentials such as a cookie | |
8699 * (already) set in the header or | |
8700 * [authorization headers](http://tools.ietf.org/html/rfc1945#section-10.2) | |
8701 * should be specified for the request. Details to keep in mind when using | |
8702 * credentials: | |
8703 * | |
8704 * * Using credentials is only useful for cross-origin requests. | |
8705 * * The `Access-Control-Allow-Origin` header of `url` cannot contain a wildca
rd (*). | |
8706 * * The `Access-Control-Allow-Credentials` header of `url` must be set to tru
e. | |
8707 * * 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]. | |
8708 * | |
8709 * The following is equivalent to the [getString] sample above: | |
8710 * | |
8711 * var name = Uri.encodeQueryComponent('John'); | |
8712 * var id = Uri.encodeQueryComponent('42'); | |
8713 * HttpRequest.request('users.json?name=$name&id=$id') | |
8714 * .then((HttpRequest resp) { | |
8715 * // Do something with the response. | |
8716 * }); | |
8717 * | |
8718 * Here's an example of submitting an entire form with [FormData]. | |
8719 * | |
8720 * var myForm = querySelector('form#myForm'); | |
8721 * var data = new FormData(myForm); | |
8722 * HttpRequest.request('/submit', method: 'POST', sendData: data) | |
8723 * .then((HttpRequest resp) { | |
8724 * // Do something with the response. | |
8725 * }); | |
8726 * | |
8727 * Note that requests for file:// URIs are only supported by Chrome extensions | |
8728 * with appropriate permissions in their manifest. Requests to file:// URIs | |
8729 * will also never fail- the Future will always complete successfully, even | |
8730 * when the file cannot be found. | |
8731 * | |
8732 * See also: [authorization headers](http://en.wikipedia.org/wiki/Basic_access
_authentication). | |
8733 */ | |
8734 static Future<HttpRequest> request(String url, | |
8735 {String method, bool withCredentials, String responseType, | |
8736 String mimeType, Map<String, String> requestHeaders, sendData, | |
8737 void onProgress(ProgressEvent e)}) { | |
8738 var completer = new Completer<HttpRequest>(); | |
8739 | |
8740 var xhr = new HttpRequest(); | |
8741 if (method == null) { | |
8742 method = 'GET'; | |
8743 } | |
8744 xhr.open(method, url, async: true); | |
8745 | |
8746 if (withCredentials != null) { | |
8747 xhr.withCredentials = withCredentials; | |
8748 } | |
8749 | |
8750 if (responseType != null) { | |
8751 xhr.responseType = responseType; | |
8752 } | |
8753 | |
8754 if (mimeType != null) { | |
8755 xhr.overrideMimeType(mimeType); | |
8756 } | |
8757 | |
8758 if (requestHeaders != null) { | |
8759 requestHeaders.forEach((header, value) { | |
8760 xhr.setRequestHeader(header, value); | |
8761 }); | |
8762 } | |
8763 | |
8764 if (onProgress != null) { | |
8765 xhr.onProgress.listen(onProgress); | |
8766 } | |
8767 | |
8768 xhr.onLoad.listen((e) { | |
8769 var accepted = xhr.status >= 200 && xhr.status < 300; | |
8770 var fileUri = xhr.status == 0; // file:// URIs have status of 0. | |
8771 var notModified = xhr.status == 304; | |
8772 // Redirect status is specified up to 307, but others have been used in | |
8773 // practice. Notably Google Drive uses 308 Resume Incomplete for | |
8774 // resumable uploads, and it's also been used as a redirect. The | |
8775 // redirect case will be handled by the browser before it gets to us, | |
8776 // so if we see it we should pass it through to the user. | |
8777 var unknownRedirect = xhr.status > 307 && xhr.status < 400; | |
8778 | |
8779 if (accepted || fileUri || notModified || unknownRedirect) { | |
8780 completer.complete(xhr); | |
8781 } else { | |
8782 completer.completeError(e); | |
8783 } | |
8784 }); | |
8785 | |
8786 xhr.onError.listen(completer.completeError); | |
8787 | |
8788 if (sendData != null) { | |
8789 xhr.send(sendData); | |
8790 } else { | |
8791 xhr.send(); | |
8792 } | |
8793 | |
8794 return completer.future; | |
8795 } | |
8796 | |
8797 /** | |
8798 * Checks to see if the Progress event is supported on the current platform. | |
8799 */ | |
8800 static bool get supportsProgressEvent { | |
8801 return true; | |
8802 } | |
8803 | |
8804 /** | |
8805 * Checks to see if the current platform supports making cross origin | |
8806 * requests. | |
8807 * | |
8808 * Note that even if cross origin requests are supported, they still may fail | |
8809 * if the destination server does not support CORS requests. | |
8810 */ | |
8811 static bool get supportsCrossOrigin { | |
8812 return true; | |
8813 } | |
8814 | |
8815 /** | |
8816 * Checks to see if the LoadEnd event is supported on the current platform. | |
8817 */ | |
8818 static bool get supportsLoadEndEvent { | |
8819 return true; | |
8820 } | |
8821 | |
8822 /** | |
8823 * Checks to see if the overrideMimeType method is supported on the current | |
8824 * platform. | |
8825 */ | |
8826 static bool get supportsOverrideMimeType { | |
8827 return true; | |
8828 } | |
8829 | |
8830 /** | |
8831 * Makes a cross-origin request to the specified URL. | |
8832 * | |
8833 * This API provides a subset of [request] which works on IE9. If IE9 | |
8834 * cross-origin support is not required then [request] should be used instead. | |
8835 */ | |
8836 @Experimental() | |
8837 static Future<String> requestCrossOrigin(String url, | |
8838 {String method, String sendData}) { | |
8839 if (supportsCrossOrigin) { | |
8840 return request(url, method: method, sendData: sendData).then((xhr) { | |
8841 return xhr.responseText; | |
8842 }); | |
8843 } | |
8844 } | |
8845 | |
8846 /** | |
8847 * Returns all response headers as a key-value map. | |
8848 * | |
8849 * Multiple values for the same header key can be combined into one, | |
8850 * separated by a comma and a space. | |
8851 * | |
8852 * See: http://www.w3.org/TR/XMLHttpRequest/#the-getresponseheader()-method | |
8853 */ | |
8854 Map<String, String> get responseHeaders { | |
8855 // from Closure's goog.net.Xhrio.getResponseHeaders. | |
8856 var headers = <String, String>{}; | |
8857 var headersString = this.getAllResponseHeaders(); | |
8858 if (headersString == null) { | |
8859 return headers; | |
8860 } | |
8861 var headersList = headersString.split('\r\n'); | |
8862 for (var header in headersList) { | |
8863 if (header.isEmpty) { | |
8864 continue; | |
8865 } | |
8866 | |
8867 var splitIdx = header.indexOf(': '); | |
8868 if (splitIdx == -1) { | |
8869 continue; | |
8870 } | |
8871 var key = header.substring(0, splitIdx).toLowerCase(); | |
8872 var value = header.substring(splitIdx + 2); | |
8873 if (headers.containsKey(key)) { | |
8874 headers[key] = '${headers[key]}, $value'; | |
8875 } else { | |
8876 headers[key] = value; | |
8877 } | |
8878 } | |
8879 return headers; | |
8880 } | |
8881 | |
8882 /** | |
8883 * Specify the desired `url`, and `method` to use in making the request. | |
8884 * | |
8885 * By default the request is done asyncronously, with no user or password | |
8886 * authentication information. If `async` is false, the request will be send | |
8887 * synchronously. | |
8888 * | |
8889 * Calling `open` again on a currently active request is equivalent to | |
8890 * calling `abort`. | |
8891 * | |
8892 * Note: Most simple HTTP requests can be accomplished using the [getString], | |
8893 * [request], [requestCrossOrigin], or [postFormData] methods. Use of this | |
8894 * `open` method is intended only for more complext HTTP requests where | |
8895 * finer-grained control is needed. | |
8896 */ | |
8897 @DomName('XMLHttpRequest.open') | |
8898 @DocsEditable() | |
8899 void open(String method, String url, {bool async, String user, String password
}) { | |
8900 if (async == null && user == null && password == null) { | |
8901 JS('void', '#.open(#, #)', this.raw, method, url); | |
8902 } else { | |
8903 JS('void', '#.open(#, #, #, #, #)', this.raw, method, url, async, user, p
assword); | |
8904 } | |
8905 } | |
8906 | |
8907 String get responseType => JS('String', '#.responseType', this.raw); | |
8908 void set responseType(String value) { JS('void', '#.responseType = #', this.ra
w, value); } | |
8909 | |
8910 // To suppress missing implicit constructor warnings. | |
8911 factory HttpRequest._() { throw new UnsupportedError("Not supported"); } | |
8912 | |
8913 /** | |
8914 * Static factory designed to expose `readystatechange` events to event | |
8915 * handlers that are not necessarily instances of [HttpRequest]. | |
8916 * | |
8917 * See [EventStreamProvider] for usage information. | |
8918 */ | |
8919 @DomName('XMLHttpRequest.readystatechangeEvent') | |
8920 @DocsEditable() | |
8921 static const EventStreamProvider<ProgressEvent> readyStateChangeEvent = const
EventStreamProvider<ProgressEvent>('readystatechange'); | |
8922 | |
8923 /** | |
8924 * General constructor for any type of request (GET, POST, etc). | |
8925 * | |
8926 * This call is used in conjunction with [open]: | |
8927 * | |
8928 * var request = new HttpRequest(); | |
8929 * request.open('GET', 'http://dartlang.org'); | |
8930 * request.onLoad.listen((event) => print( | |
8931 * 'Request complete ${event.target.reponseText}')); | |
8932 * request.send(); | |
8933 * | |
8934 * is the (more verbose) equivalent of | |
8935 * | |
8936 * HttpRequest.getString('http://dartlang.org').then( | |
8937 * (result) => print('Request complete: $result')); | |
8938 */ | |
8939 @DomName('XMLHttpRequest.XMLHttpRequest') | |
8940 @DocsEditable() | |
8941 factory HttpRequest() { | |
8942 return HttpRequest._create_1(); | |
8943 } | |
8944 static HttpRequest _create_1() => wrap_jso(JS('HttpRequest', 'new XMLHttpReque
st()')); | |
8945 | |
8946 | |
8947 @Deprecated("Internal Use Only") | |
8948 static HttpRequest internalCreateHttpRequest() { | |
8949 return new HttpRequest.internal_(); | |
8950 } | |
8951 | |
8952 @Deprecated("Internal Use Only") | |
8953 HttpRequest.internal_() : super.internal_(); | |
8954 | |
8955 | |
8956 @DomName('XMLHttpRequest.DONE') | |
8957 @DocsEditable() | |
8958 static const int DONE = 4; | |
8959 | |
8960 @DomName('XMLHttpRequest.HEADERS_RECEIVED') | |
8961 @DocsEditable() | |
8962 static const int HEADERS_RECEIVED = 2; | |
8963 | |
8964 @DomName('XMLHttpRequest.LOADING') | |
8965 @DocsEditable() | |
8966 static const int LOADING = 3; | |
8967 | |
8968 @DomName('XMLHttpRequest.OPENED') | |
8969 @DocsEditable() | |
8970 static const int OPENED = 1; | |
8971 | |
8972 @DomName('XMLHttpRequest.UNSENT') | |
8973 @DocsEditable() | |
8974 static const int UNSENT = 0; | |
8975 | |
8976 /** | |
8977 * Indicator of the current state of the request: | |
8978 * | |
8979 * <table> | |
8980 * <tr> | |
8981 * <td>Value</td> | |
8982 * <td>State</td> | |
8983 * <td>Meaning</td> | |
8984 * </tr> | |
8985 * <tr> | |
8986 * <td>0</td> | |
8987 * <td>unsent</td> | |
8988 * <td><code>open()</code> has not yet been called</td> | |
8989 * </tr> | |
8990 * <tr> | |
8991 * <td>1</td> | |
8992 * <td>opened</td> | |
8993 * <td><code>send()</code> has not yet been called</td> | |
8994 * </tr> | |
8995 * <tr> | |
8996 * <td>2</td> | |
8997 * <td>headers received</td> | |
8998 * <td><code>sent()</code> has been called; response headers and <code>sta
tus</code> are available</td> | |
8999 * </tr> | |
9000 * <tr> | |
9001 * <td>3</td> <td>loading</td> <td><code>responseText</code> holds some da
ta</td> | |
9002 * </tr> | |
9003 * <tr> | |
9004 * <td>4</td> <td>done</td> <td>request is complete</td> | |
9005 * </tr> | |
9006 * </table> | |
9007 */ | |
9008 @DomName('XMLHttpRequest.readyState') | |
9009 @DocsEditable() | |
9010 int get readyState => wrap_jso(JS("int", "#.readyState", this.raw)); | |
9011 | |
9012 /** | |
9013 * The data received as a reponse from the request. | |
9014 * | |
9015 * The data could be in the | |
9016 * form of a [String], [ByteBuffer], [Document], [Blob], or json (also a | |
9017 * [String]). `null` indicates request failure. | |
9018 */ | |
9019 @DomName('XMLHttpRequest.response') | |
9020 @DocsEditable() | |
9021 @SupportedBrowser(SupportedBrowser.CHROME) | |
9022 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
9023 @SupportedBrowser(SupportedBrowser.IE, '10') | |
9024 @SupportedBrowser(SupportedBrowser.SAFARI) | |
9025 dynamic get response => _convertNativeToDart_XHR_Response(this._get_response); | |
9026 @JSName('response') | |
9027 /** | |
9028 * The data received as a reponse from the request. | |
9029 * | |
9030 * The data could be in the | |
9031 * form of a [String], [ByteBuffer], [Document], [Blob], or json (also a | |
9032 * [String]). `null` indicates request failure. | |
9033 */ | |
9034 @DomName('XMLHttpRequest.response') | |
9035 @DocsEditable() | |
9036 @SupportedBrowser(SupportedBrowser.CHROME) | |
9037 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
9038 @SupportedBrowser(SupportedBrowser.IE, '10') | |
9039 @SupportedBrowser(SupportedBrowser.SAFARI) | |
9040 @Creates('NativeByteBuffer|Blob|Document|=Object|JSExtendableArray|String|num'
) | |
9041 dynamic get _get_response => wrap_jso(JS("dynamic", "#.response", this.raw)); | |
9042 | |
9043 /** | |
9044 * The response in String form or empty String on failure. | |
9045 */ | |
9046 @DomName('XMLHttpRequest.responseText') | |
9047 @DocsEditable() | |
9048 String get responseText => wrap_jso(JS("String", "#.responseText", this.raw)); | |
9049 | |
9050 @JSName('responseURL') | |
9051 @DomName('XMLHttpRequest.responseURL') | |
9052 @DocsEditable() | |
9053 @Experimental() // untriaged | |
9054 String get responseUrl => wrap_jso(JS("String", "#.responseURL", this.raw)); | |
9055 | |
9056 @JSName('responseXML') | |
9057 /** | |
9058 * The request response, or null on failure. | |
9059 * | |
9060 * The response is processed as | |
9061 * `text/xml` stream, unless responseType = 'document' and the request is | |
9062 * synchronous. | |
9063 */ | |
9064 @DomName('XMLHttpRequest.responseXML') | |
9065 @DocsEditable() | |
9066 Document get responseXml => wrap_jso(JS("Document", "#.responseXML", this.raw)
); | |
9067 | |
9068 /** | |
9069 * The http result code from the request (200, 404, etc). | |
9070 * See also: [Http Status Codes](http://en.wikipedia.org/wiki/List_of_HTTP_sta
tus_codes) | |
9071 */ | |
9072 @DomName('XMLHttpRequest.status') | |
9073 @DocsEditable() | |
9074 int get status => wrap_jso(JS("int", "#.status", this.raw)); | |
9075 | |
9076 /** | |
9077 * The request response string (such as \"200 OK\"). | |
9078 * See also: [Http Status Codes](http://en.wikipedia.org/wiki/List_of_HTTP_sta
tus_codes) | |
9079 */ | |
9080 @DomName('XMLHttpRequest.statusText') | |
9081 @DocsEditable() | |
9082 String get statusText => wrap_jso(JS("String", "#.statusText", this.raw)); | |
9083 | |
9084 /** | |
9085 * Length of time before a request is automatically terminated. | |
9086 * | |
9087 * When the time has passed, a [TimeoutEvent] is dispatched. | |
9088 * | |
9089 * If [timeout] is set to 0, then the request will not time out. | |
9090 * | |
9091 * ## Other resources | |
9092 * | |
9093 * * [XMLHttpRequest.timeout] | |
9094 * (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#timeout) | |
9095 * from MDN. | |
9096 * * [The timeout attribute] | |
9097 * (http://www.w3.org/TR/XMLHttpRequest/#the-timeout-attribute) | |
9098 * from W3C. | |
9099 */ | |
9100 @DomName('XMLHttpRequest.timeout') | |
9101 @DocsEditable() | |
9102 @Experimental() // untriaged | |
9103 int get timeout => wrap_jso(JS("int", "#.timeout", this.raw)); | |
9104 /** | |
9105 * Length of time before a request is automatically terminated. | |
9106 * | |
9107 * When the time has passed, a [TimeoutEvent] is dispatched. | |
9108 * | |
9109 * If [timeout] is set to 0, then the request will not time out. | |
9110 * | |
9111 * ## Other resources | |
9112 * | |
9113 * * [XMLHttpRequest.timeout] | |
9114 * (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#timeout) | |
9115 * from MDN. | |
9116 * * [The timeout attribute] | |
9117 * (http://www.w3.org/TR/XMLHttpRequest/#the-timeout-attribute) | |
9118 * from W3C. | |
9119 */ | |
9120 @DomName('XMLHttpRequest.timeout') | |
9121 @DocsEditable() | |
9122 @Experimental() // untriaged | |
9123 void set timeout(int val) => JS("void", "#.timeout = #", this.raw, unwrap_jso(
val)); | |
9124 | |
9125 /** | |
9126 * [EventTarget] that can hold listeners to track the progress of the request. | |
9127 * The events fired will be members of [HttpRequestUploadEvents]. | |
9128 */ | |
9129 @DomName('XMLHttpRequest.upload') | |
9130 @DocsEditable() | |
9131 @Unstable() | |
9132 HttpRequestEventTarget get upload => wrap_jso(JS("HttpRequestEventTarget", "#.
upload", this.raw)); | |
9133 | |
9134 /** | |
9135 * True if cross-site requests should use credentials such as cookies | |
9136 * or authorization headers; false otherwise. | |
9137 * | |
9138 * This value is ignored for same-site requests. | |
9139 */ | |
9140 @DomName('XMLHttpRequest.withCredentials') | |
9141 @DocsEditable() | |
9142 bool get withCredentials => wrap_jso(JS("bool", "#.withCredentials", this.raw)
); | |
9143 /** | |
9144 * True if cross-site requests should use credentials such as cookies | |
9145 * or authorization headers; false otherwise. | |
9146 * | |
9147 * This value is ignored for same-site requests. | |
9148 */ | |
9149 @DomName('XMLHttpRequest.withCredentials') | |
9150 @DocsEditable() | |
9151 void set withCredentials(bool val) => JS("void", "#.withCredentials = #", this
.raw, unwrap_jso(val)); | |
9152 | |
9153 /** | |
9154 * Stop the current request. | |
9155 * | |
9156 * The request can only be stopped if readyState is `HEADERS_RECIEVED` or | |
9157 * `LOADING`. If this method is not in the process of being sent, the method | |
9158 * has no effect. | |
9159 */ | |
9160 @DomName('XMLHttpRequest.abort') | |
9161 @DocsEditable() | |
9162 void abort() { | |
9163 _abort_1(); | |
9164 return; | |
9165 } | |
9166 @JSName('abort') | |
9167 /** | |
9168 * Stop the current request. | |
9169 * | |
9170 * The request can only be stopped if readyState is `HEADERS_RECIEVED` or | |
9171 * `LOADING`. If this method is not in the process of being sent, the method | |
9172 * has no effect. | |
9173 */ | |
9174 @DomName('XMLHttpRequest.abort') | |
9175 @DocsEditable() | |
9176 void _abort_1() => wrap_jso(JS("void ", "#.raw.abort()", this)); | |
9177 | |
9178 /** | |
9179 * Retrieve all the response headers from a request. | |
9180 * | |
9181 * `null` if no headers have been received. For multipart requests, | |
9182 * `getAllResponseHeaders` will return the response headers for the current | |
9183 * part of the request. | |
9184 * | |
9185 * See also [HTTP response headers](http://en.wikipedia.org/wiki/List_of_HTTP_
header_fields#Responses) | |
9186 * for a list of common response headers. | |
9187 */ | |
9188 @DomName('XMLHttpRequest.getAllResponseHeaders') | |
9189 @DocsEditable() | |
9190 @Unstable() | |
9191 String getAllResponseHeaders() { | |
9192 return _getAllResponseHeaders_1(); | |
9193 } | |
9194 @JSName('getAllResponseHeaders') | |
9195 /** | |
9196 * Retrieve all the response headers from a request. | |
9197 * | |
9198 * `null` if no headers have been received. For multipart requests, | |
9199 * `getAllResponseHeaders` will return the response headers for the current | |
9200 * part of the request. | |
9201 * | |
9202 * See also [HTTP response headers](http://en.wikipedia.org/wiki/List_of_HTTP_
header_fields#Responses) | |
9203 * for a list of common response headers. | |
9204 */ | |
9205 @DomName('XMLHttpRequest.getAllResponseHeaders') | |
9206 @DocsEditable() | |
9207 @Unstable() | |
9208 String _getAllResponseHeaders_1() => wrap_jso(JS("String ", "#.raw.getAllRespo
nseHeaders()", this)); | |
9209 | |
9210 /** | |
9211 * Return the response header named `header`, or null if not found. | |
9212 * | |
9213 * See also [HTTP response headers](http://en.wikipedia.org/wiki/List_of_HTTP_
header_fields#Responses) | |
9214 * for a list of common response headers. | |
9215 */ | |
9216 @DomName('XMLHttpRequest.getResponseHeader') | |
9217 @DocsEditable() | |
9218 @Unstable() | |
9219 String getResponseHeader(String header) { | |
9220 return _getResponseHeader_1(header); | |
9221 } | |
9222 @JSName('getResponseHeader') | |
9223 /** | |
9224 * Return the response header named `header`, or null if not found. | |
9225 * | |
9226 * See also [HTTP response headers](http://en.wikipedia.org/wiki/List_of_HTTP_
header_fields#Responses) | |
9227 * for a list of common response headers. | |
9228 */ | |
9229 @DomName('XMLHttpRequest.getResponseHeader') | |
9230 @DocsEditable() | |
9231 @Unstable() | |
9232 String _getResponseHeader_1(header) => wrap_jso(JS("String ", "#.raw.getRespon
seHeader(#)", this, unwrap_jso(header))); | |
9233 | |
9234 /** | |
9235 * Specify a particular MIME type (such as `text/xml`) desired for the | |
9236 * response. | |
9237 * | |
9238 * This value must be set before the request has been sent. See also the list | |
9239 * of [common MIME types](http://en.wikipedia.org/wiki/Internet_media_type#Lis
t_of_common_media_types) | |
9240 */ | |
9241 @DomName('XMLHttpRequest.overrideMimeType') | |
9242 @DocsEditable() | |
9243 @SupportedBrowser(SupportedBrowser.CHROME) | |
9244 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
9245 @SupportedBrowser(SupportedBrowser.SAFARI) | |
9246 void overrideMimeType(String override) { | |
9247 _overrideMimeType_1(override); | |
9248 return; | |
9249 } | |
9250 @JSName('overrideMimeType') | |
9251 /** | |
9252 * Specify a particular MIME type (such as `text/xml`) desired for the | |
9253 * response. | |
9254 * | |
9255 * This value must be set before the request has been sent. See also the list | |
9256 * of [common MIME types](http://en.wikipedia.org/wiki/Internet_media_type#Lis
t_of_common_media_types) | |
9257 */ | |
9258 @DomName('XMLHttpRequest.overrideMimeType') | |
9259 @DocsEditable() | |
9260 @SupportedBrowser(SupportedBrowser.CHROME) | |
9261 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
9262 @SupportedBrowser(SupportedBrowser.SAFARI) | |
9263 void _overrideMimeType_1(override) => wrap_jso(JS("void ", "#.raw.overrideMime
Type(#)", this, unwrap_jso(override))); | |
9264 | |
9265 /** | |
9266 * Send the request with any given `data`. | |
9267 * | |
9268 * Note: Most simple HTTP requests can be accomplished using the [getString], | |
9269 * [request], [requestCrossOrigin], or [postFormData] methods. Use of this | |
9270 * `send` method is intended only for more complext HTTP requests where | |
9271 * finer-grained control is needed. | |
9272 * | |
9273 * ## Other resources | |
9274 * | |
9275 * * [XMLHttpRequest.send] | |
9276 * (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#send%28%29) | |
9277 * from MDN. | |
9278 */ | |
9279 @DomName('XMLHttpRequest.send') | |
9280 @DocsEditable() | |
9281 void send([data]) { | |
9282 if (data == null) { | |
9283 _send_1(); | |
9284 return; | |
9285 } | |
9286 if ((data is Document || data == null)) { | |
9287 _send_2(data); | |
9288 return; | |
9289 } | |
9290 if ((data is String || data == null)) { | |
9291 _send_3(data); | |
9292 return; | |
9293 } | |
9294 throw new ArgumentError("Incorrect number or type of arguments"); | |
9295 } | |
9296 @JSName('send') | |
9297 /** | |
9298 * Send the request with any given `data`. | |
9299 * | |
9300 * Note: Most simple HTTP requests can be accomplished using the [getString], | |
9301 * [request], [requestCrossOrigin], or [postFormData] methods. Use of this | |
9302 * `send` method is intended only for more complext HTTP requests where | |
9303 * finer-grained control is needed. | |
9304 * | |
9305 * ## Other resources | |
9306 * | |
9307 * * [XMLHttpRequest.send] | |
9308 * (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#send%28%29) | |
9309 * from MDN. | |
9310 */ | |
9311 @DomName('XMLHttpRequest.send') | |
9312 @DocsEditable() | |
9313 void _send_1() => wrap_jso(JS("void ", "#.raw.send()", this)); | |
9314 @JSName('send') | |
9315 /** | |
9316 * Send the request with any given `data`. | |
9317 * | |
9318 * Note: Most simple HTTP requests can be accomplished using the [getString], | |
9319 * [request], [requestCrossOrigin], or [postFormData] methods. Use of this | |
9320 * `send` method is intended only for more complext HTTP requests where | |
9321 * finer-grained control is needed. | |
9322 * | |
9323 * ## Other resources | |
9324 * | |
9325 * * [XMLHttpRequest.send] | |
9326 * (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#send%28%29) | |
9327 * from MDN. | |
9328 */ | |
9329 @DomName('XMLHttpRequest.send') | |
9330 @DocsEditable() | |
9331 void _send_2(Document data) => wrap_jso(JS("void ", "#.raw.send(#)", this, unw
rap_jso(data))); | |
9332 @JSName('send') | |
9333 /** | |
9334 * Send the request with any given `data`. | |
9335 * | |
9336 * Note: Most simple HTTP requests can be accomplished using the [getString], | |
9337 * [request], [requestCrossOrigin], or [postFormData] methods. Use of this | |
9338 * `send` method is intended only for more complext HTTP requests where | |
9339 * finer-grained control is needed. | |
9340 * | |
9341 * ## Other resources | |
9342 * | |
9343 * * [XMLHttpRequest.send] | |
9344 * (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#send%28%29) | |
9345 * from MDN. | |
9346 */ | |
9347 @DomName('XMLHttpRequest.send') | |
9348 @DocsEditable() | |
9349 void _send_3(String data) => wrap_jso(JS("void ", "#.raw.send(#)", this, unwra
p_jso(data))); | |
9350 | |
9351 /** | |
9352 * Sets the value of an HTTP requst header. | |
9353 * | |
9354 * This method should be called after the request is opened, but before | |
9355 * the request is sent. | |
9356 * | |
9357 * Multiple calls with the same header will combine all their values into a | |
9358 * single header. | |
9359 * | |
9360 * ## Other resources | |
9361 * | |
9362 * * [XMLHttpRequest.setRequestHeader] | |
9363 * (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#send%28%29) | |
9364 * from MDN. | |
9365 * * [The setRequestHeader() method] | |
9366 * (http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader()-method) from | |
9367 * W3C. | |
9368 */ | |
9369 @DomName('XMLHttpRequest.setRequestHeader') | |
9370 @DocsEditable() | |
9371 void setRequestHeader(String header, String value) { | |
9372 _setRequestHeader_1(header, value); | |
9373 return; | |
9374 } | |
9375 @JSName('setRequestHeader') | |
9376 /** | |
9377 * Sets the value of an HTTP requst header. | |
9378 * | |
9379 * This method should be called after the request is opened, but before | |
9380 * the request is sent. | |
9381 * | |
9382 * Multiple calls with the same header will combine all their values into a | |
9383 * single header. | |
9384 * | |
9385 * ## Other resources | |
9386 * | |
9387 * * [XMLHttpRequest.setRequestHeader] | |
9388 * (https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#send%28%29) | |
9389 * from MDN. | |
9390 * * [The setRequestHeader() method] | |
9391 * (http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader()-method) from | |
9392 * W3C. | |
9393 */ | |
9394 @DomName('XMLHttpRequest.setRequestHeader') | |
9395 @DocsEditable() | |
9396 void _setRequestHeader_1(header, value) => wrap_jso(JS("void ", "#.raw.setRequ
estHeader(#, #)", this, unwrap_jso(header), unwrap_jso(value))); | |
9397 | |
9398 /// Stream of `readystatechange` events handled by this [HttpRequest]. | |
9399 /** | |
9400 * Event listeners to be notified every time the [HttpRequest] | |
9401 * object's `readyState` changes values. | |
9402 */ | |
9403 @DomName('XMLHttpRequest.onreadystatechange') | |
9404 @DocsEditable() | |
9405 Stream<ProgressEvent> get onReadyStateChange => readyStateChangeEvent.forTarge
t(this); | |
9406 | |
9407 } | |
9408 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
9409 // for details. All rights reserved. Use of this source code is governed by a | |
9410 // BSD-style license that can be found in the LICENSE file. | |
9411 | |
9412 | |
9413 @DocsEditable() | |
9414 @DomName('XMLHttpRequestEventTarget') | |
9415 @Experimental() // untriaged | |
9416 @Native("XMLHttpRequestEventTarget") | |
9417 class HttpRequestEventTarget extends EventTarget { | |
9418 // To suppress missing implicit constructor warnings. | |
9419 factory HttpRequestEventTarget._() { throw new UnsupportedError("Not supported
"); } | |
9420 | |
9421 /** | |
9422 * Static factory designed to expose `abort` events to event | |
9423 * handlers that are not necessarily instances of [HttpRequestEventTarget]. | |
9424 * | |
9425 * See [EventStreamProvider] for usage information. | |
9426 */ | |
9427 @DomName('XMLHttpRequestEventTarget.abortEvent') | |
9428 @DocsEditable() | |
9429 @Experimental() // untriaged | |
9430 static const EventStreamProvider<ProgressEvent> abortEvent = const EventStream
Provider<ProgressEvent>('abort'); | |
9431 | |
9432 /** | |
9433 * Static factory designed to expose `error` events to event | |
9434 * handlers that are not necessarily instances of [HttpRequestEventTarget]. | |
9435 * | |
9436 * See [EventStreamProvider] for usage information. | |
9437 */ | |
9438 @DomName('XMLHttpRequestEventTarget.errorEvent') | |
9439 @DocsEditable() | |
9440 @Experimental() // untriaged | |
9441 static const EventStreamProvider<ProgressEvent> errorEvent = const EventStream
Provider<ProgressEvent>('error'); | |
9442 | |
9443 /** | |
9444 * Static factory designed to expose `load` events to event | |
9445 * handlers that are not necessarily instances of [HttpRequestEventTarget]. | |
9446 * | |
9447 * See [EventStreamProvider] for usage information. | |
9448 */ | |
9449 @DomName('XMLHttpRequestEventTarget.loadEvent') | |
9450 @DocsEditable() | |
9451 @Experimental() // untriaged | |
9452 static const EventStreamProvider<ProgressEvent> loadEvent = const EventStreamP
rovider<ProgressEvent>('load'); | |
9453 | |
9454 /** | |
9455 * Static factory designed to expose `loadend` events to event | |
9456 * handlers that are not necessarily instances of [HttpRequestEventTarget]. | |
9457 * | |
9458 * See [EventStreamProvider] for usage information. | |
9459 */ | |
9460 @DomName('XMLHttpRequestEventTarget.loadendEvent') | |
9461 @DocsEditable() | |
9462 @Experimental() // untriaged | |
9463 static const EventStreamProvider<ProgressEvent> loadEndEvent = const EventStre
amProvider<ProgressEvent>('loadend'); | |
9464 | |
9465 /** | |
9466 * Static factory designed to expose `loadstart` events to event | |
9467 * handlers that are not necessarily instances of [HttpRequestEventTarget]. | |
9468 * | |
9469 * See [EventStreamProvider] for usage information. | |
9470 */ | |
9471 @DomName('XMLHttpRequestEventTarget.loadstartEvent') | |
9472 @DocsEditable() | |
9473 @Experimental() // untriaged | |
9474 static const EventStreamProvider<ProgressEvent> loadStartEvent = const EventSt
reamProvider<ProgressEvent>('loadstart'); | |
9475 | |
9476 /** | |
9477 * Static factory designed to expose `progress` events to event | |
9478 * handlers that are not necessarily instances of [HttpRequestEventTarget]. | |
9479 * | |
9480 * See [EventStreamProvider] for usage information. | |
9481 */ | |
9482 @DomName('XMLHttpRequestEventTarget.progressEvent') | |
9483 @DocsEditable() | |
9484 @Experimental() // untriaged | |
9485 static const EventStreamProvider<ProgressEvent> progressEvent = const EventStr
eamProvider<ProgressEvent>('progress'); | |
9486 | |
9487 /** | |
9488 * Static factory designed to expose `timeout` events to event | |
9489 * handlers that are not necessarily instances of [HttpRequestEventTarget]. | |
9490 * | |
9491 * See [EventStreamProvider] for usage information. | |
9492 */ | |
9493 @DomName('XMLHttpRequestEventTarget.timeoutEvent') | |
9494 @DocsEditable() | |
9495 @Experimental() // untriaged | |
9496 static const EventStreamProvider<ProgressEvent> timeoutEvent = const EventStre
amProvider<ProgressEvent>('timeout'); | |
9497 | |
9498 | |
9499 @Deprecated("Internal Use Only") | |
9500 static HttpRequestEventTarget internalCreateHttpRequestEventTarget() { | |
9501 return new HttpRequestEventTarget.internal_(); | |
9502 } | |
9503 | |
9504 @Deprecated("Internal Use Only") | |
9505 HttpRequestEventTarget.internal_() : super.internal_(); | |
9506 | |
9507 | |
9508 /// Stream of `abort` events handled by this [HttpRequestEventTarget]. | |
9509 @DomName('XMLHttpRequestEventTarget.onabort') | |
9510 @DocsEditable() | |
9511 @Experimental() // untriaged | |
9512 Stream<ProgressEvent> get onAbort => abortEvent.forTarget(this); | |
9513 | |
9514 /// Stream of `error` events handled by this [HttpRequestEventTarget]. | |
9515 @DomName('XMLHttpRequestEventTarget.onerror') | |
9516 @DocsEditable() | |
9517 @Experimental() // untriaged | |
9518 Stream<ProgressEvent> get onError => errorEvent.forTarget(this); | |
9519 | |
9520 /// Stream of `load` events handled by this [HttpRequestEventTarget]. | |
9521 @DomName('XMLHttpRequestEventTarget.onload') | |
9522 @DocsEditable() | |
9523 @Experimental() // untriaged | |
9524 Stream<ProgressEvent> get onLoad => loadEvent.forTarget(this); | |
9525 | |
9526 /// Stream of `loadend` events handled by this [HttpRequestEventTarget]. | |
9527 @DomName('XMLHttpRequestEventTarget.onloadend') | |
9528 @DocsEditable() | |
9529 @SupportedBrowser(SupportedBrowser.CHROME) | |
9530 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
9531 @SupportedBrowser(SupportedBrowser.IE, '10') | |
9532 @SupportedBrowser(SupportedBrowser.SAFARI) | |
9533 @Experimental() // untriaged | |
9534 Stream<ProgressEvent> get onLoadEnd => loadEndEvent.forTarget(this); | |
9535 | |
9536 /// Stream of `loadstart` events handled by this [HttpRequestEventTarget]. | |
9537 @DomName('XMLHttpRequestEventTarget.onloadstart') | |
9538 @DocsEditable() | |
9539 @Experimental() // untriaged | |
9540 Stream<ProgressEvent> get onLoadStart => loadStartEvent.forTarget(this); | |
9541 | |
9542 /// Stream of `progress` events handled by this [HttpRequestEventTarget]. | |
9543 @DomName('XMLHttpRequestEventTarget.onprogress') | |
9544 @DocsEditable() | |
9545 @SupportedBrowser(SupportedBrowser.CHROME) | |
9546 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
9547 @SupportedBrowser(SupportedBrowser.IE, '10') | |
9548 @SupportedBrowser(SupportedBrowser.SAFARI) | |
9549 @Experimental() // untriaged | |
9550 Stream<ProgressEvent> get onProgress => progressEvent.forTarget(this); | |
9551 | |
9552 /// Stream of `timeout` events handled by this [HttpRequestEventTarget]. | |
9553 @DomName('XMLHttpRequestEventTarget.ontimeout') | |
9554 @DocsEditable() | |
9555 @Experimental() // untriaged | |
9556 Stream<ProgressEvent> get onTimeout => timeoutEvent.forTarget(this); | |
9557 } | |
9558 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
9559 // for details. All rights reserved. Use of this source code is governed by a | |
9560 // BSD-style license that can be found in the LICENSE file. | |
9561 | |
9562 | |
9563 @DomName('HTMLInputElement') | |
9564 @Native("HTMLInputElement") | |
9565 class InputElement extends HtmlElement implements | |
9566 HiddenInputElement, | |
9567 SearchInputElement, | |
9568 TextInputElement, | |
9569 UrlInputElement, | |
9570 TelephoneInputElement, | |
9571 EmailInputElement, | |
9572 PasswordInputElement, | |
9573 DateInputElement, | |
9574 MonthInputElement, | |
9575 WeekInputElement, | |
9576 TimeInputElement, | |
9577 LocalDateTimeInputElement, | |
9578 NumberInputElement, | |
9579 RangeInputElement, | |
9580 CheckboxInputElement, | |
9581 RadioButtonInputElement, | |
9582 FileUploadInputElement, | |
9583 SubmitButtonInputElement, | |
9584 ImageButtonInputElement, | |
9585 ResetButtonInputElement, | |
9586 ButtonInputElement { | |
9587 | |
9588 factory InputElement({String type}) { | |
9589 InputElement e = document.createElement("input"); | |
9590 if (type != null) { | |
9591 try { | |
9592 // IE throws an exception for unknown types. | |
9593 e.type = type; | |
9594 } catch(_) {} | |
9595 } | |
9596 return e; | |
9597 } | |
9598 | |
9599 // To suppress missing implicit constructor warnings. | |
9600 factory InputElement._() { throw new UnsupportedError("Not supported"); } | |
9601 | |
9602 | |
9603 @Deprecated("Internal Use Only") | |
9604 static InputElement internalCreateInputElement() { | |
9605 return new InputElement.internal_(); | |
9606 } | |
9607 | |
9608 @Deprecated("Internal Use Only") | |
9609 InputElement.internal_() : super.internal_(); | |
9610 | |
9611 | |
9612 @DomName('HTMLInputElement.accept') | |
9613 @DocsEditable() | |
9614 String get accept => wrap_jso(JS("String", "#.accept", this.raw)); | |
9615 @DomName('HTMLInputElement.accept') | |
9616 @DocsEditable() | |
9617 void set accept(String val) => JS("void", "#.accept = #", this.raw, unwrap_jso
(val)); | |
9618 | |
9619 @DomName('HTMLInputElement.alt') | |
9620 @DocsEditable() | |
9621 String get alt => wrap_jso(JS("String", "#.alt", this.raw)); | |
9622 @DomName('HTMLInputElement.alt') | |
9623 @DocsEditable() | |
9624 void set alt(String val) => JS("void", "#.alt = #", this.raw, unwrap_jso(val))
; | |
9625 | |
9626 @DomName('HTMLInputElement.autocomplete') | |
9627 @DocsEditable() | |
9628 String get autocomplete => wrap_jso(JS("String", "#.autocomplete", this.raw)); | |
9629 @DomName('HTMLInputElement.autocomplete') | |
9630 @DocsEditable() | |
9631 void set autocomplete(String val) => JS("void", "#.autocomplete = #", this.raw
, unwrap_jso(val)); | |
9632 | |
9633 @DomName('HTMLInputElement.autofocus') | |
9634 @DocsEditable() | |
9635 bool get autofocus => wrap_jso(JS("bool", "#.autofocus", this.raw)); | |
9636 @DomName('HTMLInputElement.autofocus') | |
9637 @DocsEditable() | |
9638 void set autofocus(bool val) => JS("void", "#.autofocus = #", this.raw, unwrap
_jso(val)); | |
9639 | |
9640 @DomName('HTMLInputElement.capture') | |
9641 @DocsEditable() | |
9642 @Experimental() // untriaged | |
9643 bool get capture => wrap_jso(JS("bool", "#.capture", this.raw)); | |
9644 @DomName('HTMLInputElement.capture') | |
9645 @DocsEditable() | |
9646 @Experimental() // untriaged | |
9647 void set capture(bool val) => JS("void", "#.capture = #", this.raw, unwrap_jso
(val)); | |
9648 | |
9649 @DomName('HTMLInputElement.checked') | |
9650 @DocsEditable() | |
9651 bool get checked => wrap_jso(JS("bool", "#.checked", this.raw)); | |
9652 @DomName('HTMLInputElement.checked') | |
9653 @DocsEditable() | |
9654 void set checked(bool val) => JS("void", "#.checked = #", this.raw, unwrap_jso
(val)); | |
9655 | |
9656 @DomName('HTMLInputElement.defaultChecked') | |
9657 @DocsEditable() | |
9658 bool get defaultChecked => wrap_jso(JS("bool", "#.defaultChecked", this.raw)); | |
9659 @DomName('HTMLInputElement.defaultChecked') | |
9660 @DocsEditable() | |
9661 void set defaultChecked(bool val) => JS("void", "#.defaultChecked = #", this.r
aw, unwrap_jso(val)); | |
9662 | |
9663 @DomName('HTMLInputElement.defaultValue') | |
9664 @DocsEditable() | |
9665 String get defaultValue => wrap_jso(JS("String", "#.defaultValue", this.raw)); | |
9666 @DomName('HTMLInputElement.defaultValue') | |
9667 @DocsEditable() | |
9668 void set defaultValue(String val) => JS("void", "#.defaultValue = #", this.raw
, unwrap_jso(val)); | |
9669 | |
9670 @DomName('HTMLInputElement.dirName') | |
9671 @DocsEditable() | |
9672 String get dirName => wrap_jso(JS("String", "#.dirName", this.raw)); | |
9673 @DomName('HTMLInputElement.dirName') | |
9674 @DocsEditable() | |
9675 void set dirName(String val) => JS("void", "#.dirName = #", this.raw, unwrap_j
so(val)); | |
9676 | |
9677 @DomName('HTMLInputElement.disabled') | |
9678 @DocsEditable() | |
9679 bool get disabled => wrap_jso(JS("bool", "#.disabled", this.raw)); | |
9680 @DomName('HTMLInputElement.disabled') | |
9681 @DocsEditable() | |
9682 void set disabled(bool val) => JS("void", "#.disabled = #", this.raw, unwrap_j
so(val)); | |
9683 | |
9684 @DomName('HTMLInputElement.form') | |
9685 @DocsEditable() | |
9686 HtmlElement get form => wrap_jso(JS("HtmlElement", "#.form", this.raw)); | |
9687 | |
9688 @DomName('HTMLInputElement.formAction') | |
9689 @DocsEditable() | |
9690 String get formAction => wrap_jso(JS("String", "#.formAction", this.raw)); | |
9691 @DomName('HTMLInputElement.formAction') | |
9692 @DocsEditable() | |
9693 void set formAction(String val) => JS("void", "#.formAction = #", this.raw, un
wrap_jso(val)); | |
9694 | |
9695 @DomName('HTMLInputElement.formEnctype') | |
9696 @DocsEditable() | |
9697 String get formEnctype => wrap_jso(JS("String", "#.formEnctype", this.raw)); | |
9698 @DomName('HTMLInputElement.formEnctype') | |
9699 @DocsEditable() | |
9700 void set formEnctype(String val) => JS("void", "#.formEnctype = #", this.raw,
unwrap_jso(val)); | |
9701 | |
9702 @DomName('HTMLInputElement.formMethod') | |
9703 @DocsEditable() | |
9704 String get formMethod => wrap_jso(JS("String", "#.formMethod", this.raw)); | |
9705 @DomName('HTMLInputElement.formMethod') | |
9706 @DocsEditable() | |
9707 void set formMethod(String val) => JS("void", "#.formMethod = #", this.raw, un
wrap_jso(val)); | |
9708 | |
9709 @DomName('HTMLInputElement.formNoValidate') | |
9710 @DocsEditable() | |
9711 bool get formNoValidate => wrap_jso(JS("bool", "#.formNoValidate", this.raw)); | |
9712 @DomName('HTMLInputElement.formNoValidate') | |
9713 @DocsEditable() | |
9714 void set formNoValidate(bool val) => JS("void", "#.formNoValidate = #", this.r
aw, unwrap_jso(val)); | |
9715 | |
9716 @DomName('HTMLInputElement.formTarget') | |
9717 @DocsEditable() | |
9718 String get formTarget => wrap_jso(JS("String", "#.formTarget", this.raw)); | |
9719 @DomName('HTMLInputElement.formTarget') | |
9720 @DocsEditable() | |
9721 void set formTarget(String val) => JS("void", "#.formTarget = #", this.raw, un
wrap_jso(val)); | |
9722 | |
9723 @DomName('HTMLInputElement.height') | |
9724 @DocsEditable() | |
9725 int get height => wrap_jso(JS("int", "#.height", this.raw)); | |
9726 @DomName('HTMLInputElement.height') | |
9727 @DocsEditable() | |
9728 void set height(int val) => JS("void", "#.height = #", this.raw, unwrap_jso(va
l)); | |
9729 | |
9730 @DomName('HTMLInputElement.incremental') | |
9731 @DocsEditable() | |
9732 // http://www.w3.org/TR/html-markup/input.search.html | |
9733 @Experimental() | |
9734 bool get incremental => wrap_jso(JS("bool", "#.incremental", this.raw)); | |
9735 @DomName('HTMLInputElement.incremental') | |
9736 @DocsEditable() | |
9737 // http://www.w3.org/TR/html-markup/input.search.html | |
9738 @Experimental() | |
9739 void set incremental(bool val) => JS("void", "#.incremental = #", this.raw, un
wrap_jso(val)); | |
9740 | |
9741 @DomName('HTMLInputElement.indeterminate') | |
9742 @DocsEditable() | |
9743 bool get indeterminate => wrap_jso(JS("bool", "#.indeterminate", this.raw)); | |
9744 @DomName('HTMLInputElement.indeterminate') | |
9745 @DocsEditable() | |
9746 void set indeterminate(bool val) => JS("void", "#.indeterminate = #", this.raw
, unwrap_jso(val)); | |
9747 | |
9748 @DomName('HTMLInputElement.inputMode') | |
9749 @DocsEditable() | |
9750 @Experimental() // untriaged | |
9751 String get inputMode => wrap_jso(JS("String", "#.inputMode", this.raw)); | |
9752 @DomName('HTMLInputElement.inputMode') | |
9753 @DocsEditable() | |
9754 @Experimental() // untriaged | |
9755 void set inputMode(String val) => JS("void", "#.inputMode = #", this.raw, unwr
ap_jso(val)); | |
9756 | |
9757 @DomName('HTMLInputElement.labels') | |
9758 @DocsEditable() | |
9759 @Returns('NodeList') | |
9760 @Creates('NodeList') | |
9761 List<Node> get labels => wrap_jso(JS("List<Node>", "#.labels", this.raw)); | |
9762 | |
9763 @DomName('HTMLInputElement.list') | |
9764 @DocsEditable() | |
9765 HtmlElement get list => wrap_jso(JS("HtmlElement", "#.list", this.raw)); | |
9766 | |
9767 @DomName('HTMLInputElement.max') | |
9768 @DocsEditable() | |
9769 String get max => wrap_jso(JS("String", "#.max", this.raw)); | |
9770 @DomName('HTMLInputElement.max') | |
9771 @DocsEditable() | |
9772 void set max(String val) => JS("void", "#.max = #", this.raw, unwrap_jso(val))
; | |
9773 | |
9774 @DomName('HTMLInputElement.maxLength') | |
9775 @DocsEditable() | |
9776 int get maxLength => wrap_jso(JS("int", "#.maxLength", this.raw)); | |
9777 @DomName('HTMLInputElement.maxLength') | |
9778 @DocsEditable() | |
9779 void set maxLength(int val) => JS("void", "#.maxLength = #", this.raw, unwrap_
jso(val)); | |
9780 | |
9781 @DomName('HTMLInputElement.min') | |
9782 @DocsEditable() | |
9783 String get min => wrap_jso(JS("String", "#.min", this.raw)); | |
9784 @DomName('HTMLInputElement.min') | |
9785 @DocsEditable() | |
9786 void set min(String val) => JS("void", "#.min = #", this.raw, unwrap_jso(val))
; | |
9787 | |
9788 @DomName('HTMLInputElement.multiple') | |
9789 @DocsEditable() | |
9790 bool get multiple => wrap_jso(JS("bool", "#.multiple", this.raw)); | |
9791 @DomName('HTMLInputElement.multiple') | |
9792 @DocsEditable() | |
9793 void set multiple(bool val) => JS("void", "#.multiple = #", this.raw, unwrap_j
so(val)); | |
9794 | |
9795 @DomName('HTMLInputElement.name') | |
9796 @DocsEditable() | |
9797 String get name => wrap_jso(JS("String", "#.name", this.raw)); | |
9798 @DomName('HTMLInputElement.name') | |
9799 @DocsEditable() | |
9800 void set name(String val) => JS("void", "#.name = #", this.raw, unwrap_jso(val
)); | |
9801 | |
9802 @DomName('HTMLInputElement.pattern') | |
9803 @DocsEditable() | |
9804 String get pattern => wrap_jso(JS("String", "#.pattern", this.raw)); | |
9805 @DomName('HTMLInputElement.pattern') | |
9806 @DocsEditable() | |
9807 void set pattern(String val) => JS("void", "#.pattern = #", this.raw, unwrap_j
so(val)); | |
9808 | |
9809 @DomName('HTMLInputElement.placeholder') | |
9810 @DocsEditable() | |
9811 String get placeholder => wrap_jso(JS("String", "#.placeholder", this.raw)); | |
9812 @DomName('HTMLInputElement.placeholder') | |
9813 @DocsEditable() | |
9814 void set placeholder(String val) => JS("void", "#.placeholder = #", this.raw,
unwrap_jso(val)); | |
9815 | |
9816 @DomName('HTMLInputElement.readOnly') | |
9817 @DocsEditable() | |
9818 bool get readOnly => wrap_jso(JS("bool", "#.readOnly", this.raw)); | |
9819 @DomName('HTMLInputElement.readOnly') | |
9820 @DocsEditable() | |
9821 void set readOnly(bool val) => JS("void", "#.readOnly = #", this.raw, unwrap_j
so(val)); | |
9822 | |
9823 @DomName('HTMLInputElement.required') | |
9824 @DocsEditable() | |
9825 bool get required => wrap_jso(JS("bool", "#.required", this.raw)); | |
9826 @DomName('HTMLInputElement.required') | |
9827 @DocsEditable() | |
9828 void set required(bool val) => JS("void", "#.required = #", this.raw, unwrap_j
so(val)); | |
9829 | |
9830 @DomName('HTMLInputElement.selectionDirection') | |
9831 @DocsEditable() | |
9832 String get selectionDirection => wrap_jso(JS("String", "#.selectionDirection",
this.raw)); | |
9833 @DomName('HTMLInputElement.selectionDirection') | |
9834 @DocsEditable() | |
9835 void set selectionDirection(String val) => JS("void", "#.selectionDirection =
#", this.raw, unwrap_jso(val)); | |
9836 | |
9837 @DomName('HTMLInputElement.selectionEnd') | |
9838 @DocsEditable() | |
9839 int get selectionEnd => wrap_jso(JS("int", "#.selectionEnd", this.raw)); | |
9840 @DomName('HTMLInputElement.selectionEnd') | |
9841 @DocsEditable() | |
9842 void set selectionEnd(int val) => JS("void", "#.selectionEnd = #", this.raw, u
nwrap_jso(val)); | |
9843 | |
9844 @DomName('HTMLInputElement.selectionStart') | |
9845 @DocsEditable() | |
9846 int get selectionStart => wrap_jso(JS("int", "#.selectionStart", this.raw)); | |
9847 @DomName('HTMLInputElement.selectionStart') | |
9848 @DocsEditable() | |
9849 void set selectionStart(int val) => JS("void", "#.selectionStart = #", this.ra
w, unwrap_jso(val)); | |
9850 | |
9851 @DomName('HTMLInputElement.size') | |
9852 @DocsEditable() | |
9853 int get size => wrap_jso(JS("int", "#.size", this.raw)); | |
9854 @DomName('HTMLInputElement.size') | |
9855 @DocsEditable() | |
9856 void set size(int val) => JS("void", "#.size = #", this.raw, unwrap_jso(val)); | |
9857 | |
9858 @DomName('HTMLInputElement.src') | |
9859 @DocsEditable() | |
9860 String get src => wrap_jso(JS("String", "#.src", this.raw)); | |
9861 @DomName('HTMLInputElement.src') | |
9862 @DocsEditable() | |
9863 void set src(String val) => JS("void", "#.src = #", this.raw, unwrap_jso(val))
; | |
9864 | |
9865 @DomName('HTMLInputElement.step') | |
9866 @DocsEditable() | |
9867 String get step => wrap_jso(JS("String", "#.step", this.raw)); | |
9868 @DomName('HTMLInputElement.step') | |
9869 @DocsEditable() | |
9870 void set step(String val) => JS("void", "#.step = #", this.raw, unwrap_jso(val
)); | |
9871 | |
9872 @DomName('HTMLInputElement.type') | |
9873 @DocsEditable() | |
9874 String get type => wrap_jso(JS("String", "#.type", this.raw)); | |
9875 @DomName('HTMLInputElement.type') | |
9876 @DocsEditable() | |
9877 void set type(String val) => JS("void", "#.type = #", this.raw, unwrap_jso(val
)); | |
9878 | |
9879 @DomName('HTMLInputElement.validationMessage') | |
9880 @DocsEditable() | |
9881 String get validationMessage => wrap_jso(JS("String", "#.validationMessage", t
his.raw)); | |
9882 | |
9883 @DomName('HTMLInputElement.value') | |
9884 @DocsEditable() | |
9885 String get value => wrap_jso(JS("String", "#.value", this.raw)); | |
9886 @DomName('HTMLInputElement.value') | |
9887 @DocsEditable() | |
9888 void set value(String val) => JS("void", "#.value = #", this.raw, unwrap_jso(v
al)); | |
9889 | |
9890 @DomName('HTMLInputElement.valueAsDate') | |
9891 @DocsEditable() | |
9892 DateTime get valueAsDate => convertNativeToDart_DateTime(this._get_valueAsDate
); | |
9893 @JSName('valueAsDate') | |
9894 @DomName('HTMLInputElement.valueAsDate') | |
9895 @DocsEditable() | |
9896 @Creates('Null') | |
9897 dynamic get _get_valueAsDate => wrap_jso(JS("dynamic", "#.valueAsDate", this.r
aw)); | |
9898 | |
9899 set valueAsDate(DateTime value) { | |
9900 this._set_valueAsDate = convertDartToNative_DateTime(value); | |
9901 } | |
9902 set _set_valueAsDate(/*dynamic*/ value) { | |
9903 JS("void", "#.raw.valueAsDate = #", this, unwrap_jso(value)); | |
9904 } | |
9905 | |
9906 @DomName('HTMLInputElement.valueAsNumber') | |
9907 @DocsEditable() | |
9908 num get valueAsNumber => wrap_jso(JS("num", "#.valueAsNumber", this.raw)); | |
9909 @DomName('HTMLInputElement.valueAsNumber') | |
9910 @DocsEditable() | |
9911 void set valueAsNumber(num val) => JS("void", "#.valueAsNumber = #", this.raw,
unwrap_jso(val)); | |
9912 | |
9913 @JSName('webkitdirectory') | |
9914 @DomName('HTMLInputElement.webkitdirectory') | |
9915 @DocsEditable() | |
9916 @SupportedBrowser(SupportedBrowser.CHROME) | |
9917 @SupportedBrowser(SupportedBrowser.SAFARI) | |
9918 @Experimental() | |
9919 // https://plus.sandbox.google.com/+AddyOsmani/posts/Dk5UhZ6zfF3 | |
9920 bool get directory => wrap_jso(JS("bool", "#.webkitdirectory", this.raw)); | |
9921 @JSName('webkitdirectory') | |
9922 @DomName('HTMLInputElement.webkitdirectory') | |
9923 @DocsEditable() | |
9924 @SupportedBrowser(SupportedBrowser.CHROME) | |
9925 @SupportedBrowser(SupportedBrowser.SAFARI) | |
9926 @Experimental() | |
9927 // https://plus.sandbox.google.com/+AddyOsmani/posts/Dk5UhZ6zfF3 | |
9928 void set directory(bool val) => JS("void", "#.webkitdirectory = #", this.raw,
unwrap_jso(val)); | |
9929 | |
9930 @DomName('HTMLInputElement.width') | |
9931 @DocsEditable() | |
9932 int get width => wrap_jso(JS("int", "#.width", this.raw)); | |
9933 @DomName('HTMLInputElement.width') | |
9934 @DocsEditable() | |
9935 void set width(int val) => JS("void", "#.width = #", this.raw, unwrap_jso(val)
); | |
9936 | |
9937 @DomName('HTMLInputElement.willValidate') | |
9938 @DocsEditable() | |
9939 bool get willValidate => wrap_jso(JS("bool", "#.willValidate", this.raw)); | |
9940 | |
9941 @DomName('HTMLInputElement.checkValidity') | |
9942 @DocsEditable() | |
9943 bool checkValidity() { | |
9944 return _checkValidity_1(); | |
9945 } | |
9946 @JSName('checkValidity') | |
9947 @DomName('HTMLInputElement.checkValidity') | |
9948 @DocsEditable() | |
9949 bool _checkValidity_1() => wrap_jso(JS("bool ", "#.raw.checkValidity()", this)
); | |
9950 | |
9951 @DomName('HTMLInputElement.select') | |
9952 @DocsEditable() | |
9953 void select() { | |
9954 _select_1(); | |
9955 return; | |
9956 } | |
9957 @JSName('select') | |
9958 @DomName('HTMLInputElement.select') | |
9959 @DocsEditable() | |
9960 void _select_1() => wrap_jso(JS("void ", "#.raw.select()", this)); | |
9961 | |
9962 @DomName('HTMLInputElement.setCustomValidity') | |
9963 @DocsEditable() | |
9964 void setCustomValidity(String error) { | |
9965 _setCustomValidity_1(error); | |
9966 return; | |
9967 } | |
9968 @JSName('setCustomValidity') | |
9969 @DomName('HTMLInputElement.setCustomValidity') | |
9970 @DocsEditable() | |
9971 void _setCustomValidity_1(error) => wrap_jso(JS("void ", "#.raw.setCustomValid
ity(#)", this, unwrap_jso(error))); | |
9972 | |
9973 @DomName('HTMLInputElement.setRangeText') | |
9974 @DocsEditable() | |
9975 // http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-
controls-and-forms.html#dom-textarea/input-setrangetext | |
9976 @Experimental() // experimental | |
9977 void setRangeText(String replacement, {int start, int end, String selectionMod
e}) { | |
9978 if (start == null && end == null && selectionMode == null) { | |
9979 _setRangeText_1(replacement); | |
9980 return; | |
9981 } | |
9982 if (end != null && start != null && selectionMode == null) { | |
9983 _setRangeText_2(replacement, start, end); | |
9984 return; | |
9985 } | |
9986 if (selectionMode != null && end != null && start != null) { | |
9987 _setRangeText_3(replacement, start, end, selectionMode); | |
9988 return; | |
9989 } | |
9990 throw new ArgumentError("Incorrect number or type of arguments"); | |
9991 } | |
9992 @JSName('setRangeText') | |
9993 @DomName('HTMLInputElement.setRangeText') | |
9994 @DocsEditable() | |
9995 // http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-
controls-and-forms.html#dom-textarea/input-setrangetext | |
9996 @Experimental() // experimental | |
9997 void _setRangeText_1(replacement) => wrap_jso(JS("void ", "#.raw.setRangeText(
#)", this, unwrap_jso(replacement))); | |
9998 @JSName('setRangeText') | |
9999 @DomName('HTMLInputElement.setRangeText') | |
10000 @DocsEditable() | |
10001 // http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-
controls-and-forms.html#dom-textarea/input-setrangetext | |
10002 @Experimental() // experimental | |
10003 void _setRangeText_2(replacement, start, end) => wrap_jso(JS("void ", "#.raw.s
etRangeText(#, #, #)", this, unwrap_jso(replacement), unwrap_jso(start), unwrap_
jso(end))); | |
10004 @JSName('setRangeText') | |
10005 @DomName('HTMLInputElement.setRangeText') | |
10006 @DocsEditable() | |
10007 // http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-
controls-and-forms.html#dom-textarea/input-setrangetext | |
10008 @Experimental() // experimental | |
10009 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))); | |
10010 | |
10011 @DomName('HTMLInputElement.setSelectionRange') | |
10012 @DocsEditable() | |
10013 void setSelectionRange(int start, int end, [String direction]) { | |
10014 if (direction != null) { | |
10015 _setSelectionRange_1(start, end, direction); | |
10016 return; | |
10017 } | |
10018 _setSelectionRange_2(start, end); | |
10019 return; | |
10020 } | |
10021 @JSName('setSelectionRange') | |
10022 @DomName('HTMLInputElement.setSelectionRange') | |
10023 @DocsEditable() | |
10024 void _setSelectionRange_1(start, end, direction) => wrap_jso(JS("void ", "#.ra
w.setSelectionRange(#, #, #)", this, unwrap_jso(start), unwrap_jso(end), unwrap_
jso(direction))); | |
10025 @JSName('setSelectionRange') | |
10026 @DomName('HTMLInputElement.setSelectionRange') | |
10027 @DocsEditable() | |
10028 void _setSelectionRange_2(start, end) => wrap_jso(JS("void ", "#.raw.setSelect
ionRange(#, #)", this, unwrap_jso(start), unwrap_jso(end))); | |
10029 | |
10030 @DomName('HTMLInputElement.stepDown') | |
10031 @DocsEditable() | |
10032 void stepDown([int n]) { | |
10033 if (n != null) { | |
10034 _stepDown_1(n); | |
10035 return; | |
10036 } | |
10037 _stepDown_2(); | |
10038 return; | |
10039 } | |
10040 @JSName('stepDown') | |
10041 @DomName('HTMLInputElement.stepDown') | |
10042 @DocsEditable() | |
10043 void _stepDown_1(n) => wrap_jso(JS("void ", "#.raw.stepDown(#)", this, unwrap_
jso(n))); | |
10044 @JSName('stepDown') | |
10045 @DomName('HTMLInputElement.stepDown') | |
10046 @DocsEditable() | |
10047 void _stepDown_2() => wrap_jso(JS("void ", "#.raw.stepDown()", this)); | |
10048 | |
10049 @DomName('HTMLInputElement.stepUp') | |
10050 @DocsEditable() | |
10051 void stepUp([int n]) { | |
10052 if (n != null) { | |
10053 _stepUp_1(n); | |
10054 return; | |
10055 } | |
10056 _stepUp_2(); | |
10057 return; | |
10058 } | |
10059 @JSName('stepUp') | |
10060 @DomName('HTMLInputElement.stepUp') | |
10061 @DocsEditable() | |
10062 void _stepUp_1(n) => wrap_jso(JS("void ", "#.raw.stepUp(#)", this, unwrap_jso(
n))); | |
10063 @JSName('stepUp') | |
10064 @DomName('HTMLInputElement.stepUp') | |
10065 @DocsEditable() | |
10066 void _stepUp_2() => wrap_jso(JS("void ", "#.raw.stepUp()", this)); | |
10067 | |
10068 } | |
10069 | |
10070 | |
10071 // Interfaces representing the InputElement APIs which are supported | |
10072 // for the various types of InputElement. From: | |
10073 // http://www.w3.org/html/wg/drafts/html/master/forms.html#the-input-element. | |
10074 | |
10075 /** | |
10076 * Exposes the functionality common between all InputElement types. | |
10077 */ | |
10078 abstract class InputElementBase implements Element { | |
10079 @DomName('HTMLInputElement.autofocus') | |
10080 bool autofocus; | |
10081 | |
10082 @DomName('HTMLInputElement.disabled') | |
10083 bool disabled; | |
10084 | |
10085 @DomName('HTMLInputElement.incremental') | |
10086 bool incremental; | |
10087 | |
10088 @DomName('HTMLInputElement.indeterminate') | |
10089 bool indeterminate; | |
10090 | |
10091 @DomName('HTMLInputElement.labels') | |
10092 List<Node> get labels; | |
10093 | |
10094 @DomName('HTMLInputElement.name') | |
10095 String name; | |
10096 | |
10097 @DomName('HTMLInputElement.validationMessage') | |
10098 String get validationMessage; | |
10099 | |
10100 | |
10101 @DomName('HTMLInputElement.value') | |
10102 String value; | |
10103 | |
10104 @DomName('HTMLInputElement.willValidate') | |
10105 bool get willValidate; | |
10106 | |
10107 @DomName('HTMLInputElement.checkValidity') | |
10108 bool checkValidity(); | |
10109 | |
10110 @DomName('HTMLInputElement.setCustomValidity') | |
10111 void setCustomValidity(String error); | |
10112 } | |
10113 | |
10114 /** | |
10115 * Hidden input which is not intended to be seen or edited by the user. | |
10116 */ | |
10117 abstract class HiddenInputElement implements InputElementBase { | |
10118 factory HiddenInputElement() => new InputElement(type: 'hidden'); | |
10119 } | |
10120 | |
10121 | |
10122 /** | |
10123 * Base interface for all inputs which involve text editing. | |
10124 */ | |
10125 abstract class TextInputElementBase implements InputElementBase { | |
10126 @DomName('HTMLInputElement.autocomplete') | |
10127 String autocomplete; | |
10128 | |
10129 @DomName('HTMLInputElement.maxLength') | |
10130 int maxLength; | |
10131 | |
10132 @DomName('HTMLInputElement.pattern') | |
10133 String pattern; | |
10134 | |
10135 @DomName('HTMLInputElement.placeholder') | |
10136 String placeholder; | |
10137 | |
10138 @DomName('HTMLInputElement.readOnly') | |
10139 bool readOnly; | |
10140 | |
10141 @DomName('HTMLInputElement.required') | |
10142 bool required; | |
10143 | |
10144 @DomName('HTMLInputElement.size') | |
10145 int size; | |
10146 | |
10147 @DomName('HTMLInputElement.select') | |
10148 void select(); | |
10149 | |
10150 @DomName('HTMLInputElement.selectionDirection') | |
10151 String selectionDirection; | |
10152 | |
10153 @DomName('HTMLInputElement.selectionEnd') | |
10154 int selectionEnd; | |
10155 | |
10156 @DomName('HTMLInputElement.selectionStart') | |
10157 int selectionStart; | |
10158 | |
10159 @DomName('HTMLInputElement.setSelectionRange') | |
10160 void setSelectionRange(int start, int end, [String direction]); | |
10161 } | |
10162 | |
10163 /** | |
10164 * Similar to [TextInputElement], but on platforms where search is styled | |
10165 * differently this will get the search style. | |
10166 * | |
10167 * Use [supported] to check if this is supported on the current platform. | |
10168 */ | |
10169 @SupportedBrowser(SupportedBrowser.CHROME) | |
10170 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
10171 @SupportedBrowser(SupportedBrowser.IE, '10') | |
10172 @SupportedBrowser(SupportedBrowser.SAFARI) | |
10173 abstract class SearchInputElement implements TextInputElementBase { | |
10174 factory SearchInputElement() => new InputElement(type: 'search'); | |
10175 | |
10176 @DomName('HTMLInputElement.dirName') | |
10177 String dirName; | |
10178 | |
10179 @DomName('HTMLInputElement.list') | |
10180 Element get list; | |
10181 | |
10182 /// Returns true if this input type is supported on the current platform. | |
10183 static bool get supported { | |
10184 return (new InputElement(type: 'search')).type == 'search'; | |
10185 } | |
10186 } | |
10187 | |
10188 /** | |
10189 * A basic text input editor control. | |
10190 */ | |
10191 abstract class TextInputElement implements TextInputElementBase { | |
10192 factory TextInputElement() => new InputElement(type: 'text'); | |
10193 | |
10194 @DomName('HTMLInputElement.dirName') | |
10195 String dirName; | |
10196 | |
10197 @DomName('HTMLInputElement.list') | |
10198 Element get list; | |
10199 } | |
10200 | |
10201 /** | |
10202 * A control for editing an absolute URL. | |
10203 * | |
10204 * Use [supported] to check if this is supported on the current platform. | |
10205 */ | |
10206 @SupportedBrowser(SupportedBrowser.CHROME) | |
10207 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
10208 @SupportedBrowser(SupportedBrowser.IE, '10') | |
10209 @SupportedBrowser(SupportedBrowser.SAFARI) | |
10210 abstract class UrlInputElement implements TextInputElementBase { | |
10211 factory UrlInputElement() => new InputElement(type: 'url'); | |
10212 | |
10213 @DomName('HTMLInputElement.list') | |
10214 Element get list; | |
10215 | |
10216 /// Returns true if this input type is supported on the current platform. | |
10217 static bool get supported { | |
10218 return (new InputElement(type: 'url')).type == 'url'; | |
10219 } | |
10220 } | |
10221 | |
10222 /** | |
10223 * Represents a control for editing a telephone number. | |
10224 * | |
10225 * This provides a single line of text with minimal formatting help since | |
10226 * there is a wide variety of telephone numbers. | |
10227 * | |
10228 * Use [supported] to check if this is supported on the current platform. | |
10229 */ | |
10230 @SupportedBrowser(SupportedBrowser.CHROME) | |
10231 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
10232 @SupportedBrowser(SupportedBrowser.IE, '10') | |
10233 @SupportedBrowser(SupportedBrowser.SAFARI) | |
10234 abstract class TelephoneInputElement implements TextInputElementBase { | |
10235 factory TelephoneInputElement() => new InputElement(type: 'tel'); | |
10236 | |
10237 @DomName('HTMLInputElement.list') | |
10238 Element get list; | |
10239 | |
10240 /// Returns true if this input type is supported on the current platform. | |
10241 static bool get supported { | |
10242 return (new InputElement(type: 'tel')).type == 'tel'; | |
10243 } | |
10244 } | |
10245 | |
10246 /** | |
10247 * An e-mail address or list of e-mail addresses. | |
10248 * | |
10249 * Use [supported] to check if this is supported on the current platform. | |
10250 */ | |
10251 @SupportedBrowser(SupportedBrowser.CHROME) | |
10252 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
10253 @SupportedBrowser(SupportedBrowser.IE, '10') | |
10254 @SupportedBrowser(SupportedBrowser.SAFARI) | |
10255 abstract class EmailInputElement implements TextInputElementBase { | |
10256 factory EmailInputElement() => new InputElement(type: 'email'); | |
10257 | |
10258 @DomName('HTMLInputElement.autocomplete') | |
10259 String autocomplete; | |
10260 | |
10261 @DomName('HTMLInputElement.autofocus') | |
10262 bool autofocus; | |
10263 | |
10264 @DomName('HTMLInputElement.list') | |
10265 Element get list; | |
10266 | |
10267 @DomName('HTMLInputElement.maxLength') | |
10268 int maxLength; | |
10269 | |
10270 @DomName('HTMLInputElement.multiple') | |
10271 bool multiple; | |
10272 | |
10273 @DomName('HTMLInputElement.pattern') | |
10274 String pattern; | |
10275 | |
10276 @DomName('HTMLInputElement.placeholder') | |
10277 String placeholder; | |
10278 | |
10279 @DomName('HTMLInputElement.readOnly') | |
10280 bool readOnly; | |
10281 | |
10282 @DomName('HTMLInputElement.required') | |
10283 bool required; | |
10284 | |
10285 @DomName('HTMLInputElement.size') | |
10286 int size; | |
10287 | |
10288 /// Returns true if this input type is supported on the current platform. | |
10289 static bool get supported { | |
10290 return (new InputElement(type: 'email')).type == 'email'; | |
10291 } | |
10292 } | |
10293 | |
10294 /** | |
10295 * Text with no line breaks (sensitive information). | |
10296 */ | |
10297 abstract class PasswordInputElement implements TextInputElementBase { | |
10298 factory PasswordInputElement() => new InputElement(type: 'password'); | |
10299 } | |
10300 | |
10301 /** | |
10302 * Base interface for all input element types which involve ranges. | |
10303 */ | |
10304 abstract class RangeInputElementBase implements InputElementBase { | |
10305 | |
10306 @DomName('HTMLInputElement.list') | |
10307 Element get list; | |
10308 | |
10309 @DomName('HTMLInputElement.max') | |
10310 String max; | |
10311 | |
10312 @DomName('HTMLInputElement.min') | |
10313 String min; | |
10314 | |
10315 @DomName('HTMLInputElement.step') | |
10316 String step; | |
10317 | |
10318 @DomName('HTMLInputElement.valueAsNumber') | |
10319 num valueAsNumber; | |
10320 | |
10321 @DomName('HTMLInputElement.stepDown') | |
10322 void stepDown([int n]); | |
10323 | |
10324 @DomName('HTMLInputElement.stepUp') | |
10325 void stepUp([int n]); | |
10326 } | |
10327 | |
10328 /** | |
10329 * A date (year, month, day) with no time zone. | |
10330 * | |
10331 * Use [supported] to check if this is supported on the current platform. | |
10332 */ | |
10333 @SupportedBrowser(SupportedBrowser.CHROME, '25') | |
10334 @Experimental() | |
10335 abstract class DateInputElement implements RangeInputElementBase { | |
10336 factory DateInputElement() => new InputElement(type: 'date'); | |
10337 | |
10338 @DomName('HTMLInputElement.valueAsDate') | |
10339 DateTime valueAsDate; | |
10340 | |
10341 @DomName('HTMLInputElement.readOnly') | |
10342 bool readOnly; | |
10343 | |
10344 @DomName('HTMLInputElement.required') | |
10345 bool required; | |
10346 | |
10347 /// Returns true if this input type is supported on the current platform. | |
10348 static bool get supported { | |
10349 return (new InputElement(type: 'date')).type == 'date'; | |
10350 } | |
10351 } | |
10352 | |
10353 /** | |
10354 * A date consisting of a year and a month with no time zone. | |
10355 * | |
10356 * Use [supported] to check if this is supported on the current platform. | |
10357 */ | |
10358 @SupportedBrowser(SupportedBrowser.CHROME, '25') | |
10359 @Experimental() | |
10360 abstract class MonthInputElement implements RangeInputElementBase { | |
10361 factory MonthInputElement() => new InputElement(type: 'month'); | |
10362 | |
10363 @DomName('HTMLInputElement.valueAsDate') | |
10364 DateTime valueAsDate; | |
10365 | |
10366 @DomName('HTMLInputElement.readOnly') | |
10367 bool readOnly; | |
10368 | |
10369 @DomName('HTMLInputElement.required') | |
10370 bool required; | |
10371 | |
10372 /// Returns true if this input type is supported on the current platform. | |
10373 static bool get supported { | |
10374 return (new InputElement(type: 'month')).type == 'month'; | |
10375 } | |
10376 } | |
10377 | |
10378 /** | |
10379 * A date consisting of a week-year number and a week number with no time zone. | |
10380 * | |
10381 * Use [supported] to check if this is supported on the current platform. | |
10382 */ | |
10383 @SupportedBrowser(SupportedBrowser.CHROME, '25') | |
10384 @Experimental() | |
10385 abstract class WeekInputElement implements RangeInputElementBase { | |
10386 factory WeekInputElement() => new InputElement(type: 'week'); | |
10387 | |
10388 @DomName('HTMLInputElement.valueAsDate') | |
10389 DateTime valueAsDate; | |
10390 | |
10391 @DomName('HTMLInputElement.readOnly') | |
10392 bool readOnly; | |
10393 | |
10394 @DomName('HTMLInputElement.required') | |
10395 bool required; | |
10396 | |
10397 /// Returns true if this input type is supported on the current platform. | |
10398 static bool get supported { | |
10399 return (new InputElement(type: 'week')).type == 'week'; | |
10400 } | |
10401 } | |
10402 | |
10403 /** | |
10404 * A time (hour, minute, seconds, fractional seconds) with no time zone. | |
10405 * | |
10406 * Use [supported] to check if this is supported on the current platform. | |
10407 */ | |
10408 @SupportedBrowser(SupportedBrowser.CHROME) | |
10409 @Experimental() | |
10410 abstract class TimeInputElement implements RangeInputElementBase { | |
10411 factory TimeInputElement() => new InputElement(type: 'time'); | |
10412 | |
10413 @DomName('HTMLInputElement.valueAsDate') | |
10414 DateTime valueAsDate; | |
10415 | |
10416 @DomName('HTMLInputElement.readOnly') | |
10417 bool readOnly; | |
10418 | |
10419 @DomName('HTMLInputElement.required') | |
10420 bool required; | |
10421 | |
10422 /// Returns true if this input type is supported on the current platform. | |
10423 static bool get supported { | |
10424 return (new InputElement(type: 'time')).type == 'time'; | |
10425 } | |
10426 } | |
10427 | |
10428 /** | |
10429 * A date and time (year, month, day, hour, minute, second, fraction of a | |
10430 * second) with no time zone. | |
10431 * | |
10432 * Use [supported] to check if this is supported on the current platform. | |
10433 */ | |
10434 @SupportedBrowser(SupportedBrowser.CHROME, '25') | |
10435 @Experimental() | |
10436 abstract class LocalDateTimeInputElement implements RangeInputElementBase { | |
10437 factory LocalDateTimeInputElement() => | |
10438 new InputElement(type: 'datetime-local'); | |
10439 | |
10440 @DomName('HTMLInputElement.readOnly') | |
10441 bool readOnly; | |
10442 | |
10443 @DomName('HTMLInputElement.required') | |
10444 bool required; | |
10445 | |
10446 /// Returns true if this input type is supported on the current platform. | |
10447 static bool get supported { | |
10448 return (new InputElement(type: 'datetime-local')).type == 'datetime-local'; | |
10449 } | |
10450 } | |
10451 | |
10452 /** | |
10453 * A numeric editor control. | |
10454 */ | |
10455 @SupportedBrowser(SupportedBrowser.CHROME) | |
10456 @SupportedBrowser(SupportedBrowser.IE) | |
10457 @SupportedBrowser(SupportedBrowser.SAFARI) | |
10458 @Experimental() | |
10459 abstract class NumberInputElement implements RangeInputElementBase { | |
10460 factory NumberInputElement() => new InputElement(type: 'number'); | |
10461 | |
10462 @DomName('HTMLInputElement.placeholder') | |
10463 String placeholder; | |
10464 | |
10465 @DomName('HTMLInputElement.readOnly') | |
10466 bool readOnly; | |
10467 | |
10468 @DomName('HTMLInputElement.required') | |
10469 bool required; | |
10470 | |
10471 /// Returns true if this input type is supported on the current platform. | |
10472 static bool get supported { | |
10473 return (new InputElement(type: 'number')).type == 'number'; | |
10474 } | |
10475 } | |
10476 | |
10477 /** | |
10478 * Similar to [NumberInputElement] but the browser may provide more optimal | |
10479 * styling (such as a slider control). | |
10480 * | |
10481 * Use [supported] to check if this is supported on the current platform. | |
10482 */ | |
10483 @SupportedBrowser(SupportedBrowser.CHROME) | |
10484 @SupportedBrowser(SupportedBrowser.IE, '10') | |
10485 @Experimental() | |
10486 abstract class RangeInputElement implements RangeInputElementBase { | |
10487 factory RangeInputElement() => new InputElement(type: 'range'); | |
10488 | |
10489 /// Returns true if this input type is supported on the current platform. | |
10490 static bool get supported { | |
10491 return (new InputElement(type: 'range')).type == 'range'; | |
10492 } | |
10493 } | |
10494 | |
10495 /** | |
10496 * A boolean editor control. | |
10497 * | |
10498 * Note that if [indeterminate] is set then this control is in a third | |
10499 * indeterminate state. | |
10500 */ | |
10501 abstract class CheckboxInputElement implements InputElementBase { | |
10502 factory CheckboxInputElement() => new InputElement(type: 'checkbox'); | |
10503 | |
10504 @DomName('HTMLInputElement.checked') | |
10505 bool checked; | |
10506 | |
10507 @DomName('HTMLInputElement.required') | |
10508 bool required; | |
10509 } | |
10510 | |
10511 | |
10512 /** | |
10513 * A control that when used with other [ReadioButtonInputElement] controls | |
10514 * forms a radio button group in which only one control can be checked at a | |
10515 * time. | |
10516 * | |
10517 * Radio buttons are considered to be in the same radio button group if: | |
10518 * | |
10519 * * They are all of type 'radio'. | |
10520 * * They all have either the same [FormElement] owner, or no owner. | |
10521 * * Their name attributes contain the same name. | |
10522 */ | |
10523 abstract class RadioButtonInputElement implements InputElementBase { | |
10524 factory RadioButtonInputElement() => new InputElement(type: 'radio'); | |
10525 | |
10526 @DomName('HTMLInputElement.checked') | |
10527 bool checked; | |
10528 | |
10529 @DomName('HTMLInputElement.required') | |
10530 bool required; | |
10531 } | |
10532 | |
10533 /** | |
10534 * A control for picking files from the user's computer. | |
10535 */ | |
10536 abstract class FileUploadInputElement implements InputElementBase { | |
10537 factory FileUploadInputElement() => new InputElement(type: 'file'); | |
10538 | |
10539 @DomName('HTMLInputElement.accept') | |
10540 String accept; | |
10541 | |
10542 @DomName('HTMLInputElement.multiple') | |
10543 bool multiple; | |
10544 | |
10545 @DomName('HTMLInputElement.required') | |
10546 bool required; | |
10547 | |
10548 } | |
10549 | |
10550 /** | |
10551 * A button, which when clicked, submits the form. | |
10552 */ | |
10553 abstract class SubmitButtonInputElement implements InputElementBase { | |
10554 factory SubmitButtonInputElement() => new InputElement(type: 'submit'); | |
10555 | |
10556 @DomName('HTMLInputElement.formAction') | |
10557 String formAction; | |
10558 | |
10559 @DomName('HTMLInputElement.formEnctype') | |
10560 String formEnctype; | |
10561 | |
10562 @DomName('HTMLInputElement.formMethod') | |
10563 String formMethod; | |
10564 | |
10565 @DomName('HTMLInputElement.formNoValidate') | |
10566 bool formNoValidate; | |
10567 | |
10568 @DomName('HTMLInputElement.formTarget') | |
10569 String formTarget; | |
10570 } | |
10571 | |
10572 /** | |
10573 * Either an image which the user can select a coordinate to or a form | |
10574 * submit button. | |
10575 */ | |
10576 abstract class ImageButtonInputElement implements InputElementBase { | |
10577 factory ImageButtonInputElement() => new InputElement(type: 'image'); | |
10578 | |
10579 @DomName('HTMLInputElement.alt') | |
10580 String alt; | |
10581 | |
10582 @DomName('HTMLInputElement.formAction') | |
10583 String formAction; | |
10584 | |
10585 @DomName('HTMLInputElement.formEnctype') | |
10586 String formEnctype; | |
10587 | |
10588 @DomName('HTMLInputElement.formMethod') | |
10589 String formMethod; | |
10590 | |
10591 @DomName('HTMLInputElement.formNoValidate') | |
10592 bool formNoValidate; | |
10593 | |
10594 @DomName('HTMLInputElement.formTarget') | |
10595 String formTarget; | |
10596 | |
10597 @DomName('HTMLInputElement.height') | |
10598 int height; | |
10599 | |
10600 @DomName('HTMLInputElement.src') | |
10601 String src; | |
10602 | |
10603 @DomName('HTMLInputElement.width') | |
10604 int width; | |
10605 } | |
10606 | |
10607 /** | |
10608 * A button, which when clicked, resets the form. | |
10609 */ | |
10610 abstract class ResetButtonInputElement implements InputElementBase { | |
10611 factory ResetButtonInputElement() => new InputElement(type: 'reset'); | |
10612 } | |
10613 | |
10614 /** | |
10615 * A button, with no default behavior. | |
10616 */ | |
10617 abstract class ButtonInputElement implements InputElementBase { | |
10618 factory ButtonInputElement() => new InputElement(type: 'button'); | |
10619 } | |
10620 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
10621 // for details. All rights reserved. Use of this source code is governed by a | |
10622 // BSD-style license that can be found in the LICENSE file. | |
10623 | |
10624 | |
10625 /** | |
10626 * An event that describes user interaction with the keyboard. | |
10627 * | |
10628 * The [type] of the event identifies what kind of interaction occurred. | |
10629 * | |
10630 * See also: | |
10631 * | |
10632 * * [KeyboardEvent](https://developer.mozilla.org/en/DOM/KeyboardEvent) at MDN. | |
10633 */ | |
10634 @DomName('KeyboardEvent') | |
10635 @Native("KeyboardEvent") | |
10636 class KeyboardEvent extends UIEvent { | |
10637 | |
10638 /** | |
10639 * Programmatically create a KeyboardEvent. | |
10640 * | |
10641 * Due to browser differences, keyCode, charCode, or keyIdentifier values | |
10642 * cannot be specified in this base level constructor. This constructor | |
10643 * enables the user to programmatically create and dispatch a [KeyboardEvent], | |
10644 * but it will not contain any particular key content. For programmatically | |
10645 * creating keyboard events with specific key value contents, see the custom | |
10646 * Event [KeyEvent]. | |
10647 */ | |
10648 factory KeyboardEvent(String type, | |
10649 {Window view, bool canBubble: true, bool cancelable: true, | |
10650 int keyLocation: 1, bool ctrlKey: false, | |
10651 bool altKey: false, bool shiftKey: false, bool metaKey: false}) { | |
10652 if (view == null) { | |
10653 view = window; | |
10654 } | |
10655 KeyboardEvent e = document._createEvent("KeyboardEvent"); | |
10656 e._initKeyboardEvent(type, canBubble, cancelable, view, "", | |
10657 keyLocation, ctrlKey, altKey, shiftKey, metaKey); | |
10658 return e; | |
10659 } | |
10660 | |
10661 @DomName('KeyboardEvent.initKeyboardEvent') | |
10662 void _initKeyboardEvent(String type, bool canBubble, bool cancelable, | |
10663 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, | |
10664 bool altKey, bool shiftKey, bool metaKey) { | |
10665 if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this.raw)) { | |
10666 // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has | |
10667 // a slightly different signature, and allows you to specify keyCode and | |
10668 // charCode as the last two arguments, but we just set them as the default | |
10669 // since they can't be specified in other browsers. | |
10670 JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this.raw, | |
10671 type, canBubble, cancelable, unwrap_jso(view), | |
10672 ctrlKey, altKey, shiftKey, metaKey); | |
10673 } else { | |
10674 // initKeyboardEvent is for all other browsers. | |
10675 JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #)', this.raw, | |
10676 type, canBubble, cancelable, unwrap_jso(view), keyIdentifier, keyLocat
ion, | |
10677 ctrlKey, altKey, shiftKey, metaKey); | |
10678 } | |
10679 } | |
10680 | |
10681 @DomName('KeyboardEvent.keyCode') | |
10682 int get keyCode => _keyCode; | |
10683 | |
10684 @DomName('KeyboardEvent.charCode') | |
10685 int get charCode => _charCode; | |
10686 // To suppress missing implicit constructor warnings. | |
10687 factory KeyboardEvent._() { throw new UnsupportedError("Not supported"); } | |
10688 | |
10689 | |
10690 @Deprecated("Internal Use Only") | |
10691 static KeyboardEvent internalCreateKeyboardEvent() { | |
10692 return new KeyboardEvent.internal_(); | |
10693 } | |
10694 | |
10695 @Deprecated("Internal Use Only") | |
10696 KeyboardEvent.internal_() : super.internal_(); | |
10697 | |
10698 | |
10699 @DomName('KeyboardEvent.DOM_KEY_LOCATION_LEFT') | |
10700 @DocsEditable() | |
10701 @Experimental() // untriaged | |
10702 static const int DOM_KEY_LOCATION_LEFT = 0x01; | |
10703 | |
10704 @DomName('KeyboardEvent.DOM_KEY_LOCATION_NUMPAD') | |
10705 @DocsEditable() | |
10706 @Experimental() // untriaged | |
10707 static const int DOM_KEY_LOCATION_NUMPAD = 0x03; | |
10708 | |
10709 @DomName('KeyboardEvent.DOM_KEY_LOCATION_RIGHT') | |
10710 @DocsEditable() | |
10711 @Experimental() // untriaged | |
10712 static const int DOM_KEY_LOCATION_RIGHT = 0x02; | |
10713 | |
10714 @DomName('KeyboardEvent.DOM_KEY_LOCATION_STANDARD') | |
10715 @DocsEditable() | |
10716 @Experimental() // untriaged | |
10717 static const int DOM_KEY_LOCATION_STANDARD = 0x00; | |
10718 | |
10719 @DomName('KeyboardEvent.altKey') | |
10720 @DocsEditable() | |
10721 bool get altKey => wrap_jso(JS("bool", "#.altKey", this.raw)); | |
10722 | |
10723 @DomName('KeyboardEvent.ctrlKey') | |
10724 @DocsEditable() | |
10725 bool get ctrlKey => wrap_jso(JS("bool", "#.ctrlKey", this.raw)); | |
10726 | |
10727 @JSName('keyIdentifier') | |
10728 @DomName('KeyboardEvent.keyIdentifier') | |
10729 @DocsEditable() | |
10730 @Experimental() // nonstandard | |
10731 String get _keyIdentifier => wrap_jso(JS("String", "#.keyIdentifier", this.raw
)); | |
10732 | |
10733 @DomName('KeyboardEvent.keyLocation') | |
10734 @DocsEditable() | |
10735 @Experimental() // nonstandard | |
10736 int get keyLocation => wrap_jso(JS("int", "#.keyLocation", this.raw)); | |
10737 | |
10738 @DomName('KeyboardEvent.location') | |
10739 @DocsEditable() | |
10740 @Experimental() // untriaged | |
10741 int get location => wrap_jso(JS("int", "#.location", this.raw)); | |
10742 | |
10743 @DomName('KeyboardEvent.metaKey') | |
10744 @DocsEditable() | |
10745 bool get metaKey => wrap_jso(JS("bool", "#.metaKey", this.raw)); | |
10746 | |
10747 @DomName('KeyboardEvent.repeat') | |
10748 @DocsEditable() | |
10749 @Experimental() // untriaged | |
10750 bool get repeat => wrap_jso(JS("bool", "#.repeat", this.raw)); | |
10751 | |
10752 @DomName('KeyboardEvent.shiftKey') | |
10753 @DocsEditable() | |
10754 bool get shiftKey => wrap_jso(JS("bool", "#.shiftKey", this.raw)); | |
10755 | |
10756 @DomName('KeyboardEvent.getModifierState') | |
10757 @DocsEditable() | |
10758 @Experimental() // untriaged | |
10759 bool getModifierState(String keyArgument) { | |
10760 return _getModifierState_1(keyArgument); | |
10761 } | |
10762 @JSName('getModifierState') | |
10763 @DomName('KeyboardEvent.getModifierState') | |
10764 @DocsEditable() | |
10765 @Experimental() // untriaged | |
10766 bool _getModifierState_1(keyArgument) => wrap_jso(JS("bool ", "#.raw.getModifi
erState(#)", this, unwrap_jso(keyArgument))); | |
10767 | |
10768 } | |
10769 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
10770 // for details. All rights reserved. Use of this source code is governed by a | |
10771 // BSD-style license that can be found in the LICENSE file. | |
10772 | |
10773 | |
10774 @DocsEditable() | |
10775 @DomName('Location') | |
10776 @Native("Location") | |
10777 class Location extends DartHtmlDomObject implements LocationBase { | |
10778 // To suppress missing implicit constructor warnings. | |
10779 factory Location._() { throw new UnsupportedError("Not supported"); } | |
10780 | |
10781 @Deprecated("Internal Use Only") | |
10782 static Location internalCreateLocation() { | |
10783 return new Location.internal_(); | |
10784 } | |
10785 | |
10786 @Deprecated("Internal Use Only") | |
10787 Location.internal_() { } | |
10788 | |
10789 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
10790 int get hashCode => unwrap_jso(this).hashCode; | |
10791 | |
10792 @DomName('Location.hash') | |
10793 @DocsEditable() | |
10794 String get hash => wrap_jso(JS("String", "#.hash", this.raw)); | |
10795 @DomName('Location.hash') | |
10796 @DocsEditable() | |
10797 void set hash(String val) => JS("void", "#.hash = #", this.raw, unwrap_jso(val
)); | |
10798 | |
10799 @DomName('Location.host') | |
10800 @DocsEditable() | |
10801 String get host => wrap_jso(JS("String", "#.host", this.raw)); | |
10802 @DomName('Location.host') | |
10803 @DocsEditable() | |
10804 void set host(String val) => JS("void", "#.host = #", this.raw, unwrap_jso(val
)); | |
10805 | |
10806 @DomName('Location.hostname') | |
10807 @DocsEditable() | |
10808 String get hostname => wrap_jso(JS("String", "#.hostname", this.raw)); | |
10809 @DomName('Location.hostname') | |
10810 @DocsEditable() | |
10811 void set hostname(String val) => JS("void", "#.hostname = #", this.raw, unwrap
_jso(val)); | |
10812 | |
10813 @DomName('Location.href') | |
10814 @DocsEditable() | |
10815 String get href => wrap_jso(JS("String", "#.href", this.raw)); | |
10816 @DomName('Location.href') | |
10817 @DocsEditable() | |
10818 void set href(String val) => JS("void", "#.href = #", this.raw, unwrap_jso(val
)); | |
10819 | |
10820 @DomName('Location.pathname') | |
10821 @DocsEditable() | |
10822 String get pathname => wrap_jso(JS("String", "#.pathname", this.raw)); | |
10823 @DomName('Location.pathname') | |
10824 @DocsEditable() | |
10825 void set pathname(String val) => JS("void", "#.pathname = #", this.raw, unwrap
_jso(val)); | |
10826 | |
10827 @DomName('Location.port') | |
10828 @DocsEditable() | |
10829 String get port => wrap_jso(JS("String", "#.port", this.raw)); | |
10830 @DomName('Location.port') | |
10831 @DocsEditable() | |
10832 void set port(String val) => JS("void", "#.port = #", this.raw, unwrap_jso(val
)); | |
10833 | |
10834 @DomName('Location.protocol') | |
10835 @DocsEditable() | |
10836 String get protocol => wrap_jso(JS("String", "#.protocol", this.raw)); | |
10837 @DomName('Location.protocol') | |
10838 @DocsEditable() | |
10839 void set protocol(String val) => JS("void", "#.protocol = #", this.raw, unwrap
_jso(val)); | |
10840 | |
10841 @DomName('Location.search') | |
10842 @DocsEditable() | |
10843 String get search => wrap_jso(JS("String", "#.search", this.raw)); | |
10844 @DomName('Location.search') | |
10845 @DocsEditable() | |
10846 void set search(String val) => JS("void", "#.search = #", this.raw, unwrap_jso
(val)); | |
10847 | |
10848 @DomName('Location.assign') | |
10849 @DocsEditable() | |
10850 void assign([String url]) { | |
10851 if (url != null) { | |
10852 _assign_1(url); | |
10853 return; | |
10854 } | |
10855 _assign_2(); | |
10856 return; | |
10857 } | |
10858 @JSName('assign') | |
10859 @DomName('Location.assign') | |
10860 @DocsEditable() | |
10861 void _assign_1(url) => wrap_jso(JS("void ", "#.raw.assign(#)", this, unwrap_js
o(url))); | |
10862 @JSName('assign') | |
10863 @DomName('Location.assign') | |
10864 @DocsEditable() | |
10865 void _assign_2() => wrap_jso(JS("void ", "#.raw.assign()", this)); | |
10866 | |
10867 @DomName('Location.reload') | |
10868 @DocsEditable() | |
10869 void reload() { | |
10870 _reload_1(); | |
10871 return; | |
10872 } | |
10873 @JSName('reload') | |
10874 @DomName('Location.reload') | |
10875 @DocsEditable() | |
10876 void _reload_1() => wrap_jso(JS("void ", "#.raw.reload()", this)); | |
10877 | |
10878 @DomName('Location.replace') | |
10879 @DocsEditable() | |
10880 void replace(String url) { | |
10881 _replace_1(url); | |
10882 return; | |
10883 } | |
10884 @JSName('replace') | |
10885 @DomName('Location.replace') | |
10886 @DocsEditable() | |
10887 void _replace_1(url) => wrap_jso(JS("void ", "#.raw.replace(#)", this, unwrap_
jso(url))); | |
10888 | |
10889 | |
10890 | |
10891 } | |
10892 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
10893 // for details. All rights reserved. Use of this source code is governed by a | |
10894 // BSD-style license that can be found in the LICENSE file. | |
10895 | |
10896 | |
10897 @DocsEditable() | |
10898 @DomName('MouseEvent') | |
10899 @Native("MouseEvent,DragEvent,PointerEvent,MSPointerEvent") | |
10900 class MouseEvent extends UIEvent { | |
10901 // To suppress missing implicit constructor warnings. | |
10902 factory MouseEvent._() { throw new UnsupportedError("Not supported"); } | |
10903 | |
10904 | |
10905 @Deprecated("Internal Use Only") | |
10906 static MouseEvent internalCreateMouseEvent() { | |
10907 return new MouseEvent.internal_(); | |
10908 } | |
10909 | |
10910 @Deprecated("Internal Use Only") | |
10911 MouseEvent.internal_() : super.internal_(); | |
10912 | |
10913 | |
10914 @DomName('MouseEvent.altKey') | |
10915 @DocsEditable() | |
10916 bool get altKey => wrap_jso(JS("bool", "#.altKey", this.raw)); | |
10917 | |
10918 @DomName('MouseEvent.button') | |
10919 @DocsEditable() | |
10920 int get button => wrap_jso(JS("int", "#.button", this.raw)); | |
10921 | |
10922 @JSName('clientX') | |
10923 @DomName('MouseEvent.clientX') | |
10924 @DocsEditable() | |
10925 int get _clientX => wrap_jso(JS("int", "#.clientX", this.raw)); | |
10926 | |
10927 @JSName('clientY') | |
10928 @DomName('MouseEvent.clientY') | |
10929 @DocsEditable() | |
10930 int get _clientY => wrap_jso(JS("int", "#.clientY", this.raw)); | |
10931 | |
10932 @DomName('MouseEvent.ctrlKey') | |
10933 @DocsEditable() | |
10934 bool get ctrlKey => wrap_jso(JS("bool", "#.ctrlKey", this.raw)); | |
10935 | |
10936 /** | |
10937 * The nonstandard way to access the element that the mouse comes | |
10938 * from in the case of a `mouseover` event. | |
10939 * | |
10940 * This member is deprecated and not cross-browser compatible; use | |
10941 * relatedTarget to get the same information in the standard way. | |
10942 */ | |
10943 @DomName('MouseEvent.fromElement') | |
10944 @DocsEditable() | |
10945 @deprecated | |
10946 Node get fromElement => wrap_jso(JS("Node", "#.fromElement", this.raw)); | |
10947 | |
10948 @DomName('MouseEvent.metaKey') | |
10949 @DocsEditable() | |
10950 bool get metaKey => wrap_jso(JS("bool", "#.metaKey", this.raw)); | |
10951 | |
10952 @JSName('movementX') | |
10953 @DomName('MouseEvent.movementX') | |
10954 @DocsEditable() | |
10955 @Experimental() // untriaged | |
10956 int get _movementX => wrap_jso(JS("int", "#.movementX", this.raw)); | |
10957 | |
10958 @JSName('movementY') | |
10959 @DomName('MouseEvent.movementY') | |
10960 @DocsEditable() | |
10961 @Experimental() // untriaged | |
10962 int get _movementY => wrap_jso(JS("int", "#.movementY", this.raw)); | |
10963 | |
10964 @DomName('MouseEvent.region') | |
10965 @DocsEditable() | |
10966 @Experimental() // untriaged | |
10967 String get region => wrap_jso(JS("String", "#.region", this.raw)); | |
10968 | |
10969 @DomName('MouseEvent.relatedTarget') | |
10970 @DocsEditable() | |
10971 EventTarget get relatedTarget => _convertNativeToDart_EventTarget(this._get_re
latedTarget); | |
10972 @JSName('relatedTarget') | |
10973 @DomName('MouseEvent.relatedTarget') | |
10974 @DocsEditable() | |
10975 @Creates('Node') | |
10976 @Returns('EventTarget|=Object') | |
10977 dynamic get _get_relatedTarget => wrap_jso(JS("dynamic", "#.relatedTarget", th
is.raw)); | |
10978 | |
10979 @JSName('screenX') | |
10980 @DomName('MouseEvent.screenX') | |
10981 @DocsEditable() | |
10982 int get _screenX => wrap_jso(JS("int", "#.screenX", this.raw)); | |
10983 | |
10984 @JSName('screenY') | |
10985 @DomName('MouseEvent.screenY') | |
10986 @DocsEditable() | |
10987 int get _screenY => wrap_jso(JS("int", "#.screenY", this.raw)); | |
10988 | |
10989 @DomName('MouseEvent.shiftKey') | |
10990 @DocsEditable() | |
10991 bool get shiftKey => wrap_jso(JS("bool", "#.shiftKey", this.raw)); | |
10992 | |
10993 /** | |
10994 * The nonstandard way to access the element that the mouse goes | |
10995 * to in the case of a `mouseout` event. | |
10996 * | |
10997 * This member is deprecated and not cross-browser compatible; use | |
10998 * relatedTarget to get the same information in the standard way. | |
10999 */ | |
11000 @DomName('MouseEvent.toElement') | |
11001 @DocsEditable() | |
11002 @deprecated | |
11003 Node get toElement => wrap_jso(JS("Node", "#.toElement", this.raw)); | |
11004 | |
11005 @JSName('webkitMovementX') | |
11006 @DomName('MouseEvent.webkitMovementX') | |
11007 @DocsEditable() | |
11008 @SupportedBrowser(SupportedBrowser.CHROME) | |
11009 @SupportedBrowser(SupportedBrowser.SAFARI) | |
11010 @Experimental() | |
11011 int get _webkitMovementX => wrap_jso(JS("int", "#.webkitMovementX", this.raw))
; | |
11012 | |
11013 @JSName('webkitMovementY') | |
11014 @DomName('MouseEvent.webkitMovementY') | |
11015 @DocsEditable() | |
11016 @SupportedBrowser(SupportedBrowser.CHROME) | |
11017 @SupportedBrowser(SupportedBrowser.SAFARI) | |
11018 @Experimental() | |
11019 int get _webkitMovementY => wrap_jso(JS("int", "#.webkitMovementY", this.raw))
; | |
11020 | |
11021 @DomName('MouseEvent.initMouseEvent') | |
11022 @DocsEditable() | |
11023 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)
{ | |
11024 var relatedTarget_1 = _convertDartToNative_EventTarget(relatedTarget); | |
11025 _initMouseEvent_1(type, canBubble, cancelable, view, detail, screenX, screen
Y, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget_1
); | |
11026 return; | |
11027 } | |
11028 @JSName('initMouseEvent') | |
11029 @DomName('MouseEvent.initMouseEvent') | |
11030 @DocsEditable() | |
11031 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))); | |
11032 } | |
11033 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
11034 // for details. All rights reserved. Use of this source code is governed by a | |
11035 // BSD-style license that can be found in the LICENSE file. | |
11036 | |
11037 | |
11038 @DomName('Navigator') | |
11039 @Native("Navigator") | |
11040 class Navigator extends DartHtmlDomObject implements NavigatorCpu { | |
11041 | |
11042 | |
11043 @DomName('Navigator.language') | |
11044 String get language => JS('String', '#.language || #.userLanguage', this.raw, | |
11045 this.raw); | |
11046 | |
11047 | |
11048 // To suppress missing implicit constructor warnings. | |
11049 factory Navigator._() { throw new UnsupportedError("Not supported"); } | |
11050 | |
11051 @Deprecated("Internal Use Only") | |
11052 static Navigator internalCreateNavigator() { | |
11053 return new Navigator.internal_(); | |
11054 } | |
11055 | |
11056 @Deprecated("Internal Use Only") | |
11057 Navigator.internal_() { } | |
11058 | |
11059 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
11060 int get hashCode => unwrap_jso(this).hashCode; | |
11061 | |
11062 @DomName('Navigator.cookieEnabled') | |
11063 @DocsEditable() | |
11064 @Unstable() | |
11065 bool get cookieEnabled => wrap_jso(JS("bool", "#.cookieEnabled", this.raw)); | |
11066 | |
11067 @DomName('Navigator.doNotTrack') | |
11068 @DocsEditable() | |
11069 // http://www.w3.org/2011/tracking-protection/drafts/tracking-dnt.html#js-dom | |
11070 @Experimental() // experimental | |
11071 String get doNotTrack => wrap_jso(JS("String", "#.doNotTrack", this.raw)); | |
11072 | |
11073 @DomName('Navigator.maxTouchPoints') | |
11074 @DocsEditable() | |
11075 @Experimental() // untriaged | |
11076 int get maxTouchPoints => wrap_jso(JS("int", "#.maxTouchPoints", this.raw)); | |
11077 | |
11078 @DomName('Navigator.productSub') | |
11079 @DocsEditable() | |
11080 @Unstable() | |
11081 String get productSub => wrap_jso(JS("String", "#.productSub", this.raw)); | |
11082 | |
11083 @DomName('Navigator.vendor') | |
11084 @DocsEditable() | |
11085 @Unstable() | |
11086 String get vendor => wrap_jso(JS("String", "#.vendor", this.raw)); | |
11087 | |
11088 @DomName('Navigator.vendorSub') | |
11089 @DocsEditable() | |
11090 @Unstable() | |
11091 String get vendorSub => wrap_jso(JS("String", "#.vendorSub", this.raw)); | |
11092 | |
11093 @DomName('Navigator.getBattery') | |
11094 @DocsEditable() | |
11095 @Experimental() // untriaged | |
11096 Future getBattery() { | |
11097 return _getBattery_1(); | |
11098 } | |
11099 @JSName('getBattery') | |
11100 @DomName('Navigator.getBattery') | |
11101 @DocsEditable() | |
11102 @Experimental() // untriaged | |
11103 Future _getBattery_1() => wrap_jso(JS("Future ", "#.raw.getBattery()", this)); | |
11104 | |
11105 @DomName('Navigator.getStorageUpdates') | |
11106 @DocsEditable() | |
11107 // http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#nav
igatorstorageutils | |
11108 @Experimental() | |
11109 void getStorageUpdates() { | |
11110 _getStorageUpdates_1(); | |
11111 return; | |
11112 } | |
11113 @JSName('getStorageUpdates') | |
11114 @DomName('Navigator.getStorageUpdates') | |
11115 @DocsEditable() | |
11116 // http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#nav
igatorstorageutils | |
11117 @Experimental() | |
11118 void _getStorageUpdates_1() => wrap_jso(JS("void ", "#.raw.getStorageUpdates()
", this)); | |
11119 | |
11120 @DomName('Navigator.registerProtocolHandler') | |
11121 @DocsEditable() | |
11122 @Unstable() | |
11123 void registerProtocolHandler(String scheme, String url, String title) { | |
11124 _registerProtocolHandler_1(scheme, url, title); | |
11125 return; | |
11126 } | |
11127 @JSName('registerProtocolHandler') | |
11128 @DomName('Navigator.registerProtocolHandler') | |
11129 @DocsEditable() | |
11130 @Unstable() | |
11131 void _registerProtocolHandler_1(scheme, url, title) => wrap_jso(JS("void ", "#
.raw.registerProtocolHandler(#, #, #)", this, unwrap_jso(scheme), unwrap_jso(url
), unwrap_jso(title))); | |
11132 | |
11133 @DomName('Navigator.sendBeacon') | |
11134 @DocsEditable() | |
11135 @Experimental() // untriaged | |
11136 bool sendBeacon(String url, String data) { | |
11137 return _sendBeacon_1(url, data); | |
11138 } | |
11139 @JSName('sendBeacon') | |
11140 @DomName('Navigator.sendBeacon') | |
11141 @DocsEditable() | |
11142 @Experimental() // untriaged | |
11143 bool _sendBeacon_1(url, data) => wrap_jso(JS("bool ", "#.raw.sendBeacon(#, #)"
, this, unwrap_jso(url), unwrap_jso(data))); | |
11144 | |
11145 // From NavigatorCPU | |
11146 | |
11147 @DomName('Navigator.hardwareConcurrency') | |
11148 @DocsEditable() | |
11149 @Experimental() // untriaged | |
11150 int get hardwareConcurrency => wrap_jso(JS("int", "#.hardwareConcurrency", thi
s.raw)); | |
11151 | |
11152 } | |
11153 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
11154 // for details. All rights reserved. Use of this source code is governed by a | |
11155 // BSD-style license that can be found in the LICENSE file. | |
11156 | |
11157 | |
11158 @DocsEditable() | |
11159 @DomName('NavigatorCPU') | |
11160 @Experimental() // untriaged | |
11161 abstract class NavigatorCpu extends DartHtmlDomObject { | |
11162 // To suppress missing implicit constructor warnings. | |
11163 factory NavigatorCpu._() { throw new UnsupportedError("Not supported"); } | |
11164 | |
11165 int get hardwareConcurrency => wrap_jso(JS("int", "#.hardwareConcurrency", thi
s.raw)); | |
11166 } | |
11167 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
11168 // for details. All rights reserved. Use of this source code is governed by a | |
11169 // BSD-style license that can be found in the LICENSE file. | |
11170 | |
11171 | |
11172 /** | |
11173 * Lazy implementation of the child nodes of an element that does not request | |
11174 * the actual child nodes of an element until strictly necessary greatly | |
11175 * improving performance for the typical cases where it is not required. | |
11176 */ | |
11177 class _ChildNodeListLazy extends ListBase<Node> implements NodeListWrapper { | |
11178 final Node _this; | |
11179 | |
11180 _ChildNodeListLazy(this._this); | |
11181 | |
11182 | |
11183 Node get first { | |
11184 Node result = _this.firstChild; | |
11185 if (result == null) throw new StateError("No elements"); | |
11186 return result; | |
11187 } | |
11188 Node get last { | |
11189 Node result = _this.lastChild; | |
11190 if (result == null) throw new StateError("No elements"); | |
11191 return result; | |
11192 } | |
11193 Node get single { | |
11194 int l = this.length; | |
11195 if (l == 0) throw new StateError("No elements"); | |
11196 if (l > 1) throw new StateError("More than one element"); | |
11197 return _this.firstChild; | |
11198 } | |
11199 | |
11200 void add(Node value) { | |
11201 _this.append(value); | |
11202 } | |
11203 | |
11204 void addAll(Iterable<Node> iterable) { | |
11205 if (iterable is _ChildNodeListLazy) { | |
11206 _ChildNodeListLazy otherList = iterable; | |
11207 if (!identical(otherList._this, _this)) { | |
11208 // Optimized route for copying between nodes. | |
11209 for (var i = 0, len = otherList.length; i < len; ++i) { | |
11210 _this.append(otherList._this.firstChild); | |
11211 } | |
11212 } | |
11213 return; | |
11214 } | |
11215 for (Node node in iterable) { | |
11216 _this.append(node); | |
11217 } | |
11218 } | |
11219 | |
11220 void insert(int index, Node node) { | |
11221 if (index < 0 || index > length) { | |
11222 throw new RangeError.range(index, 0, length); | |
11223 } | |
11224 if (index == length) { | |
11225 _this.append(node); | |
11226 } else { | |
11227 _this.insertBefore(node, this[index]); | |
11228 } | |
11229 } | |
11230 | |
11231 void insertAll(int index, Iterable<Node> iterable) { | |
11232 if (index == length) { | |
11233 addAll(iterable); | |
11234 } else { | |
11235 var item = this[index]; | |
11236 _this.insertAllBefore(iterable, item); | |
11237 } | |
11238 } | |
11239 | |
11240 void setAll(int index, Iterable<Node> iterable) { | |
11241 throw new UnsupportedError("Cannot setAll on Node list"); | |
11242 } | |
11243 | |
11244 Node removeLast() { | |
11245 final result = last; | |
11246 if (result != null) { | |
11247 _this._removeChild(result); | |
11248 } | |
11249 return result; | |
11250 } | |
11251 | |
11252 Node removeAt(int index) { | |
11253 var result = this[index]; | |
11254 if (result != null) { | |
11255 _this._removeChild(result); | |
11256 } | |
11257 return result; | |
11258 } | |
11259 | |
11260 bool remove(Object object) { | |
11261 if (object is! Node) return false; | |
11262 Node node = object; | |
11263 // We aren't preserving identity of nodes in JSINTEROP mode | |
11264 if (_this != node.parentNode) return false; | |
11265 _this._removeChild(node); | |
11266 return true; | |
11267 } | |
11268 | |
11269 void _filter(bool test(Node node), bool removeMatching) { | |
11270 // This implementation of removeWhere/retainWhere is more efficient | |
11271 // than the default in ListBase. Child nodes can be removed in constant | |
11272 // time. | |
11273 Node child = _this.firstChild; | |
11274 while (child != null) { | |
11275 Node nextChild = child.nextNode; | |
11276 if (test(child) == removeMatching) { | |
11277 _this._removeChild(child); | |
11278 } | |
11279 child = nextChild; | |
11280 } | |
11281 } | |
11282 | |
11283 void removeWhere(bool test(Node node)) { | |
11284 _filter(test, true); | |
11285 } | |
11286 | |
11287 void retainWhere(bool test(Node node)) { | |
11288 _filter(test, false); | |
11289 } | |
11290 | |
11291 void clear() { | |
11292 _this._clearChildren(); | |
11293 } | |
11294 | |
11295 void operator []=(int index, Node value) { | |
11296 _this._replaceChild(value, this[index]); | |
11297 } | |
11298 | |
11299 Iterator<Node> get iterator => _this.childNodes.iterator; | |
11300 | |
11301 // From List<Node>: | |
11302 | |
11303 // TODO(jacobr): this could be implemented for child node lists. | |
11304 // The exception we throw here is misleading. | |
11305 void sort([Comparator<Node> compare]) { | |
11306 throw new UnsupportedError("Cannot sort Node list"); | |
11307 } | |
11308 | |
11309 void shuffle([Random random]) { | |
11310 throw new UnsupportedError("Cannot shuffle Node list"); | |
11311 } | |
11312 | |
11313 // FIXME: implement these. | |
11314 void setRange(int start, int end, Iterable<Node> iterable, | |
11315 [int skipCount = 0]) { | |
11316 throw new UnsupportedError("Cannot setRange on Node list"); | |
11317 } | |
11318 | |
11319 void fillRange(int start, int end, [Node fill]) { | |
11320 throw new UnsupportedError("Cannot fillRange on Node list"); | |
11321 } | |
11322 // -- end List<Node> mixins. | |
11323 | |
11324 // TODO(jacobr): benchmark whether this is more efficient or whether caching | |
11325 // a local copy of childNodes is more efficient. | |
11326 int get length => _this.childNodes.length; | |
11327 | |
11328 set length(int value) { | |
11329 throw new UnsupportedError( | |
11330 "Cannot set length on immutable List."); | |
11331 } | |
11332 | |
11333 Node operator[](int index) => _this.childNodes[index]; | |
11334 | |
11335 List<Node> get rawList => _this.childNodes; | |
11336 } | |
11337 | |
11338 | |
11339 @DomName('Node') | |
11340 @Native("Node") | |
11341 class Node extends EventTarget { | |
11342 | |
11343 // Custom element created callback. | |
11344 Node._created() : super._created(); | |
11345 | |
11346 /** | |
11347 * A modifiable list of this node's children. | |
11348 */ | |
11349 List<Node> get nodes { | |
11350 return new _ChildNodeListLazy(this); | |
11351 } | |
11352 | |
11353 set nodes(Iterable<Node> value) { | |
11354 // Copy list first since we don't want liveness during iteration. | |
11355 // TODO(jacobr): there is a better way to do this. | |
11356 List copy = new List.from(value); | |
11357 text = ''; | |
11358 for (Node node in copy) { | |
11359 append(node); | |
11360 } | |
11361 } | |
11362 | |
11363 /** | |
11364 * Removes this node from the DOM. | |
11365 */ | |
11366 @DomName('Node.removeChild') | |
11367 void remove() { | |
11368 // TODO(jacobr): should we throw an exception if parent is already null? | |
11369 // TODO(vsm): Use the native remove when available. | |
11370 if (this.parentNode != null) { | |
11371 final Node parent = this.parentNode; | |
11372 parentNode._removeChild(this); | |
11373 } | |
11374 } | |
11375 | |
11376 /** | |
11377 * Replaces this node with another node. | |
11378 */ | |
11379 @DomName('Node.replaceChild') | |
11380 Node replaceWith(Node otherNode) { | |
11381 try { | |
11382 final Node parent = this.parentNode; | |
11383 parent._replaceChild(otherNode, this); | |
11384 } catch (e) { | |
11385 | |
11386 }; | |
11387 return this; | |
11388 } | |
11389 | |
11390 /** | |
11391 * Inserts all of the nodes into this node directly before refChild. | |
11392 * | |
11393 * See also: | |
11394 * | |
11395 * * [insertBefore] | |
11396 */ | |
11397 Node insertAllBefore(Iterable<Node> newNodes, Node refChild) { | |
11398 if (newNodes is _ChildNodeListLazy) { | |
11399 _ChildNodeListLazy otherList = newNodes; | |
11400 if (identical(otherList._this, this)) { | |
11401 throw new ArgumentError(newNodes); | |
11402 } | |
11403 | |
11404 // Optimized route for copying between nodes. | |
11405 for (var i = 0, len = otherList.length; i < len; ++i) { | |
11406 this.insertBefore(otherList._this.firstChild, refChild); | |
11407 } | |
11408 } else { | |
11409 for (var node in newNodes) { | |
11410 this.insertBefore(node, refChild); | |
11411 } | |
11412 } | |
11413 } | |
11414 | |
11415 void _clearChildren() { | |
11416 while (firstChild != null) { | |
11417 _removeChild(firstChild); | |
11418 } | |
11419 } | |
11420 | |
11421 /** | |
11422 * Print out a String representation of this Node. | |
11423 */ | |
11424 String toString() { | |
11425 String value = nodeValue; // Fetch DOM Node property once. | |
11426 return value == null ? super.toString() : value; | |
11427 } | |
11428 | |
11429 /** | |
11430 * A list of this node's children. | |
11431 * | |
11432 * ## Other resources | |
11433 * | |
11434 * * [Node.childNodes] | |
11435 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.childNodes) | |
11436 * from MDN. | |
11437 */ | |
11438 @DomName('Node.childNodes') | |
11439 @DocsEditable() | |
11440 List<Node> get childNodes => wrap_jso(JS('List', '#.childNodes', this.raw)); | |
11441 // To suppress missing implicit constructor warnings. | |
11442 factory Node._() { throw new UnsupportedError("Not supported"); } | |
11443 | |
11444 | |
11445 @Deprecated("Internal Use Only") | |
11446 static Node internalCreateNode() { | |
11447 return new Node.internal_(); | |
11448 } | |
11449 | |
11450 @Deprecated("Internal Use Only") | |
11451 Node.internal_() : super.internal_(); | |
11452 | |
11453 | |
11454 @DomName('Node.ATTRIBUTE_NODE') | |
11455 @DocsEditable() | |
11456 static const int ATTRIBUTE_NODE = 2; | |
11457 | |
11458 @DomName('Node.CDATA_SECTION_NODE') | |
11459 @DocsEditable() | |
11460 static const int CDATA_SECTION_NODE = 4; | |
11461 | |
11462 @DomName('Node.COMMENT_NODE') | |
11463 @DocsEditable() | |
11464 static const int COMMENT_NODE = 8; | |
11465 | |
11466 @DomName('Node.DOCUMENT_FRAGMENT_NODE') | |
11467 @DocsEditable() | |
11468 static const int DOCUMENT_FRAGMENT_NODE = 11; | |
11469 | |
11470 @DomName('Node.DOCUMENT_NODE') | |
11471 @DocsEditable() | |
11472 static const int DOCUMENT_NODE = 9; | |
11473 | |
11474 @DomName('Node.DOCUMENT_TYPE_NODE') | |
11475 @DocsEditable() | |
11476 static const int DOCUMENT_TYPE_NODE = 10; | |
11477 | |
11478 @DomName('Node.ELEMENT_NODE') | |
11479 @DocsEditable() | |
11480 static const int ELEMENT_NODE = 1; | |
11481 | |
11482 @DomName('Node.ENTITY_NODE') | |
11483 @DocsEditable() | |
11484 static const int ENTITY_NODE = 6; | |
11485 | |
11486 @DomName('Node.ENTITY_REFERENCE_NODE') | |
11487 @DocsEditable() | |
11488 static const int ENTITY_REFERENCE_NODE = 5; | |
11489 | |
11490 @DomName('Node.NOTATION_NODE') | |
11491 @DocsEditable() | |
11492 static const int NOTATION_NODE = 12; | |
11493 | |
11494 @DomName('Node.PROCESSING_INSTRUCTION_NODE') | |
11495 @DocsEditable() | |
11496 static const int PROCESSING_INSTRUCTION_NODE = 7; | |
11497 | |
11498 @DomName('Node.TEXT_NODE') | |
11499 @DocsEditable() | |
11500 static const int TEXT_NODE = 3; | |
11501 | |
11502 @JSName('baseURI') | |
11503 @DomName('Node.baseURI') | |
11504 @DocsEditable() | |
11505 String get baseUri => wrap_jso(JS("String", "#.baseURI", this.raw)); | |
11506 | |
11507 /** | |
11508 * The first child of this node. | |
11509 * | |
11510 * ## Other resources | |
11511 * | |
11512 * * [Node.firstChild] | |
11513 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.firstChild) | |
11514 * from MDN. | |
11515 */ | |
11516 @DomName('Node.firstChild') | |
11517 @DocsEditable() | |
11518 Node get firstChild => wrap_jso(JS("Node", "#.firstChild", this.raw)); | |
11519 | |
11520 /** | |
11521 * The last child of this node. | |
11522 * | |
11523 * ## Other resources | |
11524 * | |
11525 * * [Node.lastChild] | |
11526 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.lastChild) | |
11527 * from MDN. | |
11528 */ | |
11529 @DomName('Node.lastChild') | |
11530 @DocsEditable() | |
11531 Node get lastChild => wrap_jso(JS("Node", "#.lastChild", this.raw)); | |
11532 | |
11533 @JSName('localName') | |
11534 @DomName('Node.localName') | |
11535 @DocsEditable() | |
11536 String get _localName => wrap_jso(JS("String", "#.localName", this.raw)); | |
11537 | |
11538 @JSName('namespaceURI') | |
11539 @DomName('Node.namespaceURI') | |
11540 @DocsEditable() | |
11541 String get _namespaceUri => wrap_jso(JS("String", "#.namespaceURI", this.raw))
; | |
11542 | |
11543 @JSName('nextSibling') | |
11544 /** | |
11545 * The next sibling node. | |
11546 * | |
11547 * ## Other resources | |
11548 * | |
11549 * * [Node.nextSibling] | |
11550 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.nextSibling) | |
11551 * from MDN. | |
11552 */ | |
11553 @DomName('Node.nextSibling') | |
11554 @DocsEditable() | |
11555 Node get nextNode => wrap_jso(JS("Node", "#.nextSibling", this.raw)); | |
11556 | |
11557 /** | |
11558 * The name of this node. | |
11559 * | |
11560 * This varies by this node's [nodeType]. | |
11561 * | |
11562 * ## Other resources | |
11563 * | |
11564 * * [Node.nodeName] | |
11565 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.nodeName) | |
11566 * from MDN. This page contains a table of [nodeName] values for each | |
11567 * [nodeType]. | |
11568 */ | |
11569 @DomName('Node.nodeName') | |
11570 @DocsEditable() | |
11571 String get nodeName => wrap_jso(JS("String", "#.nodeName", this.raw)); | |
11572 | |
11573 /** | |
11574 * The type of node. | |
11575 * | |
11576 * This value is one of: | |
11577 * | |
11578 * * [ATTRIBUTE_NODE] if this node is an attribute. | |
11579 * * [CDATA_SECTION_NODE] if this node is a [CDataSection]. | |
11580 * * [COMMENT_NODE] if this node is a [Comment]. | |
11581 * * [DOCUMENT_FRAGMENT_NODE] if this node is a [DocumentFragment]. | |
11582 * * [DOCUMENT_NODE] if this node is a [Document]. | |
11583 * * [DOCUMENT_TYPE_NODE] if this node is a [DocumentType] node. | |
11584 * * [ELEMENT_NODE] if this node is an [Element]. | |
11585 * * [ENTITY_NODE] if this node is an entity. | |
11586 * * [ENTITY_REFERENCE_NODE] if this node is an entity reference. | |
11587 * * [NOTATION_NODE] if this node is a notation. | |
11588 * * [PROCESSING_INSTRUCTION_NODE] if this node is a [ProcessingInstruction]. | |
11589 * * [TEXT_NODE] if this node is a [Text] node. | |
11590 * | |
11591 * ## Other resources | |
11592 * | |
11593 * * [Node.nodeType] | |
11594 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.nodeType) from MDN. | |
11595 */ | |
11596 @DomName('Node.nodeType') | |
11597 @DocsEditable() | |
11598 int get nodeType => wrap_jso(JS("int", "#.nodeType", this.raw)); | |
11599 | |
11600 /** | |
11601 * The value of this node. | |
11602 * | |
11603 * This varies by this type's [nodeType]. | |
11604 * | |
11605 * ## Other resources | |
11606 * | |
11607 * * [Node.nodeValue] | |
11608 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.nodeValue) | |
11609 * from MDN. This page contains a table of [nodeValue] values for each | |
11610 * [nodeType]. | |
11611 */ | |
11612 @DomName('Node.nodeValue') | |
11613 @DocsEditable() | |
11614 String get nodeValue => wrap_jso(JS("String", "#.nodeValue", this.raw)); | |
11615 | |
11616 /** | |
11617 * The document this node belongs to. | |
11618 * | |
11619 * Returns null if this node does not belong to any document. | |
11620 * | |
11621 * ## Other resources | |
11622 * | |
11623 * * [Node.ownerDocument] | |
11624 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.ownerDocument) from | |
11625 * MDN. | |
11626 */ | |
11627 @DomName('Node.ownerDocument') | |
11628 @DocsEditable() | |
11629 Document get ownerDocument => wrap_jso(JS("Document", "#.ownerDocument", this.
raw)); | |
11630 | |
11631 @JSName('parentElement') | |
11632 /** | |
11633 * The parent element of this node. | |
11634 * | |
11635 * Returns null if this node either does not have a parent or its parent is | |
11636 * not an element. | |
11637 * | |
11638 * ## Other resources | |
11639 * | |
11640 * * [Node.parentElement] | |
11641 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.parentElement) from | |
11642 * W3C. | |
11643 */ | |
11644 @DomName('Node.parentElement') | |
11645 @DocsEditable() | |
11646 Element get parent => wrap_jso(JS("Element", "#.parentElement", this.raw)); | |
11647 | |
11648 /** | |
11649 * The parent node of this node. | |
11650 * | |
11651 * ## Other resources | |
11652 * | |
11653 * * [Node.parentNode] | |
11654 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.parentNode) from | |
11655 * MDN. | |
11656 */ | |
11657 @DomName('Node.parentNode') | |
11658 @DocsEditable() | |
11659 Node get parentNode => wrap_jso(JS("Node", "#.parentNode", this.raw)); | |
11660 | |
11661 @JSName('previousSibling') | |
11662 /** | |
11663 * The previous sibling node. | |
11664 * | |
11665 * ## Other resources | |
11666 * | |
11667 * * [Node.previousSibling] | |
11668 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.previousSibling) | |
11669 * from MDN. | |
11670 */ | |
11671 @DomName('Node.previousSibling') | |
11672 @DocsEditable() | |
11673 Node get previousNode => wrap_jso(JS("Node", "#.previousSibling", this.raw)); | |
11674 | |
11675 @JSName('textContent') | |
11676 /** | |
11677 * All text within this node and its decendents. | |
11678 * | |
11679 * ## Other resources | |
11680 * | |
11681 * * [Node.textContent] | |
11682 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.textContent) from | |
11683 * MDN. | |
11684 */ | |
11685 @DomName('Node.textContent') | |
11686 @DocsEditable() | |
11687 String get text => wrap_jso(JS("String", "#.textContent", this.raw)); | |
11688 @JSName('textContent') | |
11689 /** | |
11690 * All text within this node and its decendents. | |
11691 * | |
11692 * ## Other resources | |
11693 * | |
11694 * * [Node.textContent] | |
11695 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.textContent) from | |
11696 * MDN. | |
11697 */ | |
11698 @DomName('Node.textContent') | |
11699 @DocsEditable() | |
11700 void set text(String val) => JS("void", "#.textContent = #", this.raw, unwrap_
jso(val)); | |
11701 | |
11702 /** | |
11703 * Adds a node to the end of the child [nodes] list of this node. | |
11704 * | |
11705 * If the node already exists in this document, it will be removed from its | |
11706 * current parent node, then added to this node. | |
11707 * | |
11708 * This method is more efficient than `nodes.add`, and is the preferred | |
11709 * way of appending a child node. | |
11710 */ | |
11711 @DomName('Node.appendChild') | |
11712 @DocsEditable() | |
11713 Node append(Node newChild) { | |
11714 return _append_1(newChild); | |
11715 } | |
11716 @JSName('appendChild') | |
11717 /** | |
11718 * Adds a node to the end of the child [nodes] list of this node. | |
11719 * | |
11720 * If the node already exists in this document, it will be removed from its | |
11721 * current parent node, then added to this node. | |
11722 * | |
11723 * This method is more efficient than `nodes.add`, and is the preferred | |
11724 * way of appending a child node. | |
11725 */ | |
11726 @DomName('Node.appendChild') | |
11727 @DocsEditable() | |
11728 Node _append_1(Node newChild) => wrap_jso(JS("Node ", "#.raw.appendChild(#)",
this, unwrap_jso(newChild))); | |
11729 | |
11730 /** | |
11731 * Returns a copy of this node. | |
11732 * | |
11733 * If [deep] is `true`, then all of this node's children and decendents are | |
11734 * copied as well. If [deep] is `false`, then only this node is copied. | |
11735 * | |
11736 * ## Other resources | |
11737 * | |
11738 * * [Node.cloneNode] | |
11739 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.cloneNode) from | |
11740 * MDN. | |
11741 */ | |
11742 @DomName('Node.cloneNode') | |
11743 @DocsEditable() | |
11744 Node clone(bool deep) { | |
11745 return _clone_1(deep); | |
11746 } | |
11747 @JSName('cloneNode') | |
11748 /** | |
11749 * Returns a copy of this node. | |
11750 * | |
11751 * If [deep] is `true`, then all of this node's children and decendents are | |
11752 * copied as well. If [deep] is `false`, then only this node is copied. | |
11753 * | |
11754 * ## Other resources | |
11755 * | |
11756 * * [Node.cloneNode] | |
11757 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.cloneNode) from | |
11758 * MDN. | |
11759 */ | |
11760 @DomName('Node.cloneNode') | |
11761 @DocsEditable() | |
11762 Node _clone_1(deep) => wrap_jso(JS("Node ", "#.raw.cloneNode(#)", this, unwrap
_jso(deep))); | |
11763 | |
11764 /** | |
11765 * Returns true if this node contains the specified node. | |
11766 * | |
11767 * ## Other resources | |
11768 * | |
11769 * * [Node.contains] | |
11770 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.contains) from MDN. | |
11771 */ | |
11772 @DomName('Node.contains') | |
11773 @DocsEditable() | |
11774 bool contains(Node other) { | |
11775 return _contains_1(other); | |
11776 } | |
11777 @JSName('contains') | |
11778 /** | |
11779 * Returns true if this node contains the specified node. | |
11780 * | |
11781 * ## Other resources | |
11782 * | |
11783 * * [Node.contains] | |
11784 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.contains) from MDN. | |
11785 */ | |
11786 @DomName('Node.contains') | |
11787 @DocsEditable() | |
11788 bool _contains_1(Node other) => wrap_jso(JS("bool ", "#.raw.contains(#)", this
, unwrap_jso(other))); | |
11789 | |
11790 /** | |
11791 * Returns true if this node has any children. | |
11792 * | |
11793 * ## Other resources | |
11794 * | |
11795 * * [Node.hasChildNodes] | |
11796 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.hasChildNodes) from | |
11797 * MDN. | |
11798 */ | |
11799 @DomName('Node.hasChildNodes') | |
11800 @DocsEditable() | |
11801 bool hasChildNodes() { | |
11802 return _hasChildNodes_1(); | |
11803 } | |
11804 @JSName('hasChildNodes') | |
11805 /** | |
11806 * Returns true if this node has any children. | |
11807 * | |
11808 * ## Other resources | |
11809 * | |
11810 * * [Node.hasChildNodes] | |
11811 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.hasChildNodes) from | |
11812 * MDN. | |
11813 */ | |
11814 @DomName('Node.hasChildNodes') | |
11815 @DocsEditable() | |
11816 bool _hasChildNodes_1() => wrap_jso(JS("bool ", "#.raw.hasChildNodes()", this)
); | |
11817 | |
11818 /** | |
11819 * Inserts all of the nodes into this node directly before refChild. | |
11820 * | |
11821 * ## Other resources | |
11822 * | |
11823 * * [Node.insertBefore] | |
11824 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.insertBefore) from | |
11825 * MDN. | |
11826 */ | |
11827 @DomName('Node.insertBefore') | |
11828 @DocsEditable() | |
11829 Node insertBefore(Node newChild, Node refChild) { | |
11830 return _insertBefore_1(newChild, refChild); | |
11831 } | |
11832 @JSName('insertBefore') | |
11833 /** | |
11834 * Inserts all of the nodes into this node directly before refChild. | |
11835 * | |
11836 * ## Other resources | |
11837 * | |
11838 * * [Node.insertBefore] | |
11839 * (https://developer.mozilla.org/en-US/docs/Web/API/Node.insertBefore) from | |
11840 * MDN. | |
11841 */ | |
11842 @DomName('Node.insertBefore') | |
11843 @DocsEditable() | |
11844 Node _insertBefore_1(Node newChild, Node refChild) => wrap_jso(JS("Node ", "#.
raw.insertBefore(#, #)", this, unwrap_jso(newChild), unwrap_jso(refChild))); | |
11845 | |
11846 @DomName('Node.removeChild') | |
11847 @DocsEditable() | |
11848 Node _removeChild(Node oldChild) { | |
11849 return _removeChild_1(oldChild); | |
11850 } | |
11851 @JSName('removeChild') | |
11852 @DomName('Node.removeChild') | |
11853 @DocsEditable() | |
11854 Node _removeChild_1(Node oldChild) => wrap_jso(JS("Node ", "#.raw.removeChild(
#)", this, unwrap_jso(oldChild))); | |
11855 | |
11856 @DomName('Node.replaceChild') | |
11857 @DocsEditable() | |
11858 Node _replaceChild(Node newChild, Node oldChild) { | |
11859 return _replaceChild_1(newChild, oldChild); | |
11860 } | |
11861 @JSName('replaceChild') | |
11862 @DomName('Node.replaceChild') | |
11863 @DocsEditable() | |
11864 Node _replaceChild_1(Node newChild, Node oldChild) => wrap_jso(JS("Node ", "#.
raw.replaceChild(#, #)", this, unwrap_jso(newChild), unwrap_jso(oldChild))); | |
11865 | |
11866 } | |
11867 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
11868 // for details. All rights reserved. Use of this source code is governed by a | |
11869 // BSD-style license that can be found in the LICENSE file. | |
11870 | |
11871 | |
11872 @DocsEditable() | |
11873 @DomName('NodeList') | |
11874 @Native("NodeList,RadioNodeList") | |
11875 class NodeList extends DartHtmlDomObject with ListMixin<Node>, ImmutableListMixi
n<Node> implements JavaScriptIndexingBehavior, List<Node> { | |
11876 // To suppress missing implicit constructor warnings. | |
11877 factory NodeList._() { throw new UnsupportedError("Not supported"); } | |
11878 | |
11879 @Deprecated("Internal Use Only") | |
11880 static NodeList internalCreateNodeList() { | |
11881 return new NodeList.internal_(); | |
11882 } | |
11883 | |
11884 @Deprecated("Internal Use Only") | |
11885 NodeList.internal_() { } | |
11886 | |
11887 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
11888 int get hashCode => unwrap_jso(this).hashCode; | |
11889 | |
11890 @DomName('NodeList.length') | |
11891 @DocsEditable() | |
11892 int get length => wrap_jso(JS("int", "#.length", this.raw)); | |
11893 | |
11894 Node operator[](int index) { | |
11895 if (JS("bool", "# >>> 0 !== # || # >= #", index, | |
11896 index, index, length)) | |
11897 throw new RangeError.index(index, this); | |
11898 return wrap_jso(JS("Node", "#[#]", this.raw, index)); | |
11899 } | |
11900 void operator[]=(int index, Node value) { | |
11901 throw new UnsupportedError("Cannot assign element of immutable List."); | |
11902 } | |
11903 // -- start List<Node> mixins. | |
11904 // Node is the element type. | |
11905 | |
11906 | |
11907 set length(int value) { | |
11908 throw new UnsupportedError("Cannot resize immutable List."); | |
11909 } | |
11910 | |
11911 Node get first { | |
11912 if (this.length > 0) { | |
11913 return wrap_jso(JS('Node', '#[0]', this.raw)); | |
11914 } | |
11915 throw new StateError("No elements"); | |
11916 } | |
11917 | |
11918 Node get last { | |
11919 int len = this.length; | |
11920 if (len > 0) { | |
11921 return wrap_jso(JS('Node', '#[#]', this.raw, len - 1)); | |
11922 } | |
11923 throw new StateError("No elements"); | |
11924 } | |
11925 | |
11926 Node get single { | |
11927 int len = this.length; | |
11928 if (len == 1) { | |
11929 return wrap_jso(JS('Node', '#[0]', this.raw)); | |
11930 } | |
11931 if (len == 0) throw new StateError("No elements"); | |
11932 throw new StateError("More than one element"); | |
11933 } | |
11934 | |
11935 Node elementAt(int index) => this[index]; | |
11936 // -- end List<Node> mixins. | |
11937 | |
11938 @DomName('NodeList.item') | |
11939 @DocsEditable() | |
11940 Node _item(int index) { | |
11941 return _item_1(index); | |
11942 } | |
11943 @JSName('item') | |
11944 @DomName('NodeList.item') | |
11945 @DocsEditable() | |
11946 Node _item_1(index) => wrap_jso(JS("Node ", "#.raw.item(#)", this, unwrap_jso(
index))); | |
11947 } | |
11948 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
11949 // for details. All rights reserved. Use of this source code is governed by a | |
11950 // BSD-style license that can be found in the LICENSE file. | |
11951 | |
11952 | |
11953 @DocsEditable() | |
11954 @DomName('ParentNode') | |
11955 @Experimental() // untriaged | |
11956 abstract class ParentNode extends DartHtmlDomObject { | |
11957 // To suppress missing implicit constructor warnings. | |
11958 factory ParentNode._() { throw new UnsupportedError("Not supported"); } | |
11959 | |
11960 int get _childElementCount => wrap_jso(JS("int", "#.childElementCount", this.r
aw)); | |
11961 | |
11962 List<Node> get _children => wrap_jso(JS("List<Node>", "#.children", this.raw))
; | |
11963 | |
11964 Element get _firstElementChild => wrap_jso(JS("Element", "#.firstElementChild"
, this.raw)); | |
11965 | |
11966 Element get _lastElementChild => wrap_jso(JS("Element", "#.lastElementChild",
this.raw)); | |
11967 | |
11968 Element querySelector(String selectors) => wrap_jso(JS("Element", "#.raw.query
Selector(#)", this, unwrap_jso(selectors))); | |
11969 | |
11970 List<Node> _querySelectorAll(String selectors) => wrap_jso(JS("List<Node>", "#
.raw.querySelectorAll(#)", this, unwrap_jso(selectors))); | |
11971 } | |
11972 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
11973 // for details. All rights reserved. Use of this source code is governed by a | |
11974 // BSD-style license that can be found in the LICENSE file. | |
11975 | |
11976 | |
11977 @DocsEditable() | |
11978 @DomName('ProgressEvent') | |
11979 @Native("ProgressEvent") | |
11980 class ProgressEvent extends Event { | |
11981 // To suppress missing implicit constructor warnings. | |
11982 factory ProgressEvent._() { throw new UnsupportedError("Not supported"); } | |
11983 | |
11984 | |
11985 @Deprecated("Internal Use Only") | |
11986 static ProgressEvent internalCreateProgressEvent() { | |
11987 return new ProgressEvent.internal_(); | |
11988 } | |
11989 | |
11990 @Deprecated("Internal Use Only") | |
11991 ProgressEvent.internal_() : super.internal_(); | |
11992 | |
11993 | |
11994 @DomName('ProgressEvent.lengthComputable') | |
11995 @DocsEditable() | |
11996 bool get lengthComputable => wrap_jso(JS("bool", "#.lengthComputable", this.ra
w)); | |
11997 | |
11998 @DomName('ProgressEvent.loaded') | |
11999 @DocsEditable() | |
12000 int get loaded => wrap_jso(JS("int", "#.loaded", this.raw)); | |
12001 | |
12002 @DomName('ProgressEvent.total') | |
12003 @DocsEditable() | |
12004 int get total => wrap_jso(JS("int", "#.total", this.raw)); | |
12005 } | |
12006 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
12007 // for details. All rights reserved. Use of this source code is governed by a | |
12008 // BSD-style license that can be found in the LICENSE file. | |
12009 | |
12010 // WARNING: Do not edit - generated code. | |
12011 | |
12012 | |
12013 @DomName('Range') | |
12014 @Unstable() | |
12015 @Native("Range") | |
12016 class Range extends DartHtmlDomObject { | |
12017 factory Range() => document.createRange(); | |
12018 | |
12019 factory Range.fromPoint(Point point) => | |
12020 document._caretRangeFromPoint(point.x, point.y); | |
12021 // To suppress missing implicit constructor warnings. | |
12022 factory Range._() { throw new UnsupportedError("Not supported"); } | |
12023 | |
12024 @Deprecated("Internal Use Only") | |
12025 static Range internalCreateRange() { | |
12026 return new Range.internal_(); | |
12027 } | |
12028 | |
12029 @Deprecated("Internal Use Only") | |
12030 Range.internal_() { } | |
12031 | |
12032 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
12033 int get hashCode => unwrap_jso(this).hashCode; | |
12034 | |
12035 @DomName('Range.END_TO_END') | |
12036 @DocsEditable() | |
12037 static const int END_TO_END = 2; | |
12038 | |
12039 @DomName('Range.END_TO_START') | |
12040 @DocsEditable() | |
12041 static const int END_TO_START = 3; | |
12042 | |
12043 @DomName('Range.NODE_AFTER') | |
12044 @DocsEditable() | |
12045 @Experimental() // nonstandard | |
12046 static const int NODE_AFTER = 1; | |
12047 | |
12048 @DomName('Range.NODE_BEFORE') | |
12049 @DocsEditable() | |
12050 @Experimental() // nonstandard | |
12051 static const int NODE_BEFORE = 0; | |
12052 | |
12053 @DomName('Range.NODE_BEFORE_AND_AFTER') | |
12054 @DocsEditable() | |
12055 @Experimental() // nonstandard | |
12056 static const int NODE_BEFORE_AND_AFTER = 2; | |
12057 | |
12058 @DomName('Range.NODE_INSIDE') | |
12059 @DocsEditable() | |
12060 @Experimental() // nonstandard | |
12061 static const int NODE_INSIDE = 3; | |
12062 | |
12063 @DomName('Range.START_TO_END') | |
12064 @DocsEditable() | |
12065 static const int START_TO_END = 1; | |
12066 | |
12067 @DomName('Range.START_TO_START') | |
12068 @DocsEditable() | |
12069 static const int START_TO_START = 0; | |
12070 | |
12071 @DomName('Range.collapsed') | |
12072 @DocsEditable() | |
12073 bool get collapsed => wrap_jso(JS("bool", "#.collapsed", this.raw)); | |
12074 | |
12075 @DomName('Range.commonAncestorContainer') | |
12076 @DocsEditable() | |
12077 Node get commonAncestorContainer => wrap_jso(JS("Node", "#.commonAncestorConta
iner", this.raw)); | |
12078 | |
12079 @DomName('Range.endContainer') | |
12080 @DocsEditable() | |
12081 Node get endContainer => wrap_jso(JS("Node", "#.endContainer", this.raw)); | |
12082 | |
12083 @DomName('Range.endOffset') | |
12084 @DocsEditable() | |
12085 int get endOffset => wrap_jso(JS("int", "#.endOffset", this.raw)); | |
12086 | |
12087 @DomName('Range.startContainer') | |
12088 @DocsEditable() | |
12089 Node get startContainer => wrap_jso(JS("Node", "#.startContainer", this.raw)); | |
12090 | |
12091 @DomName('Range.startOffset') | |
12092 @DocsEditable() | |
12093 int get startOffset => wrap_jso(JS("int", "#.startOffset", this.raw)); | |
12094 | |
12095 @DomName('Range.cloneContents') | |
12096 @DocsEditable() | |
12097 DocumentFragment cloneContents() { | |
12098 return _cloneContents_1(); | |
12099 } | |
12100 @JSName('cloneContents') | |
12101 @DomName('Range.cloneContents') | |
12102 @DocsEditable() | |
12103 DocumentFragment _cloneContents_1() => wrap_jso(JS("DocumentFragment ", "#.raw
.cloneContents()", this)); | |
12104 | |
12105 @DomName('Range.cloneRange') | |
12106 @DocsEditable() | |
12107 Range cloneRange() { | |
12108 return _cloneRange_1(); | |
12109 } | |
12110 @JSName('cloneRange') | |
12111 @DomName('Range.cloneRange') | |
12112 @DocsEditable() | |
12113 Range _cloneRange_1() => wrap_jso(JS("Range ", "#.raw.cloneRange()", this)); | |
12114 | |
12115 @DomName('Range.collapse') | |
12116 @DocsEditable() | |
12117 void collapse([bool toStart]) { | |
12118 if (toStart != null) { | |
12119 _collapse_1(toStart); | |
12120 return; | |
12121 } | |
12122 _collapse_2(); | |
12123 return; | |
12124 } | |
12125 @JSName('collapse') | |
12126 @DomName('Range.collapse') | |
12127 @DocsEditable() | |
12128 void _collapse_1(toStart) => wrap_jso(JS("void ", "#.raw.collapse(#)", this, u
nwrap_jso(toStart))); | |
12129 @JSName('collapse') | |
12130 @DomName('Range.collapse') | |
12131 @DocsEditable() | |
12132 void _collapse_2() => wrap_jso(JS("void ", "#.raw.collapse()", this)); | |
12133 | |
12134 @DomName('Range.compareBoundaryPoints') | |
12135 @DocsEditable() | |
12136 @Experimental() // untriaged | |
12137 int compareBoundaryPoints(int how, Range sourceRange) { | |
12138 return _compareBoundaryPoints_1(how, sourceRange); | |
12139 } | |
12140 @JSName('compareBoundaryPoints') | |
12141 @DomName('Range.compareBoundaryPoints') | |
12142 @DocsEditable() | |
12143 @Experimental() // untriaged | |
12144 int _compareBoundaryPoints_1(how, Range sourceRange) => wrap_jso(JS("int ", "#
.raw.compareBoundaryPoints(#, #)", this, unwrap_jso(how), unwrap_jso(sourceRange
))); | |
12145 | |
12146 @DomName('Range.comparePoint') | |
12147 @DocsEditable() | |
12148 int comparePoint(Node refNode, int offset) { | |
12149 return _comparePoint_1(refNode, offset); | |
12150 } | |
12151 @JSName('comparePoint') | |
12152 @DomName('Range.comparePoint') | |
12153 @DocsEditable() | |
12154 int _comparePoint_1(Node refNode, offset) => wrap_jso(JS("int ", "#.raw.compar
ePoint(#, #)", this, unwrap_jso(refNode), unwrap_jso(offset))); | |
12155 | |
12156 @DomName('Range.createContextualFragment') | |
12157 @DocsEditable() | |
12158 DocumentFragment createContextualFragment(String html) { | |
12159 return _createContextualFragment_1(html); | |
12160 } | |
12161 @JSName('createContextualFragment') | |
12162 @DomName('Range.createContextualFragment') | |
12163 @DocsEditable() | |
12164 DocumentFragment _createContextualFragment_1(html) => wrap_jso(JS("DocumentFra
gment ", "#.raw.createContextualFragment(#)", this, unwrap_jso(html))); | |
12165 | |
12166 @DomName('Range.deleteContents') | |
12167 @DocsEditable() | |
12168 void deleteContents() { | |
12169 _deleteContents_1(); | |
12170 return; | |
12171 } | |
12172 @JSName('deleteContents') | |
12173 @DomName('Range.deleteContents') | |
12174 @DocsEditable() | |
12175 void _deleteContents_1() => wrap_jso(JS("void ", "#.raw.deleteContents()", thi
s)); | |
12176 | |
12177 @DomName('Range.detach') | |
12178 @DocsEditable() | |
12179 void detach() { | |
12180 _detach_1(); | |
12181 return; | |
12182 } | |
12183 @JSName('detach') | |
12184 @DomName('Range.detach') | |
12185 @DocsEditable() | |
12186 void _detach_1() => wrap_jso(JS("void ", "#.raw.detach()", this)); | |
12187 | |
12188 @DomName('Range.expand') | |
12189 @DocsEditable() | |
12190 @Experimental() // non-standard | |
12191 void expand(String unit) { | |
12192 _expand_1(unit); | |
12193 return; | |
12194 } | |
12195 @JSName('expand') | |
12196 @DomName('Range.expand') | |
12197 @DocsEditable() | |
12198 @Experimental() // non-standard | |
12199 void _expand_1(unit) => wrap_jso(JS("void ", "#.raw.expand(#)", this, unwrap_j
so(unit))); | |
12200 | |
12201 @DomName('Range.extractContents') | |
12202 @DocsEditable() | |
12203 DocumentFragment extractContents() { | |
12204 return _extractContents_1(); | |
12205 } | |
12206 @JSName('extractContents') | |
12207 @DomName('Range.extractContents') | |
12208 @DocsEditable() | |
12209 DocumentFragment _extractContents_1() => wrap_jso(JS("DocumentFragment ", "#.r
aw.extractContents()", this)); | |
12210 | |
12211 @DomName('Range.getBoundingClientRect') | |
12212 @DocsEditable() | |
12213 Rectangle getBoundingClientRect() { | |
12214 return _getBoundingClientRect_1(); | |
12215 } | |
12216 @JSName('getBoundingClientRect') | |
12217 @DomName('Range.getBoundingClientRect') | |
12218 @DocsEditable() | |
12219 Rectangle _getBoundingClientRect_1() => wrap_jso(JS("Rectangle ", "#.raw.getBo
undingClientRect()", this)); | |
12220 | |
12221 @DomName('Range.insertNode') | |
12222 @DocsEditable() | |
12223 void insertNode(Node newNode) { | |
12224 _insertNode_1(newNode); | |
12225 return; | |
12226 } | |
12227 @JSName('insertNode') | |
12228 @DomName('Range.insertNode') | |
12229 @DocsEditable() | |
12230 void _insertNode_1(Node newNode) => wrap_jso(JS("void ", "#.raw.insertNode(#)"
, this, unwrap_jso(newNode))); | |
12231 | |
12232 @DomName('Range.isPointInRange') | |
12233 @DocsEditable() | |
12234 bool isPointInRange(Node refNode, int offset) { | |
12235 return _isPointInRange_1(refNode, offset); | |
12236 } | |
12237 @JSName('isPointInRange') | |
12238 @DomName('Range.isPointInRange') | |
12239 @DocsEditable() | |
12240 bool _isPointInRange_1(Node refNode, offset) => wrap_jso(JS("bool ", "#.raw.is
PointInRange(#, #)", this, unwrap_jso(refNode), unwrap_jso(offset))); | |
12241 | |
12242 @DomName('Range.selectNode') | |
12243 @DocsEditable() | |
12244 void selectNode(Node refNode) { | |
12245 _selectNode_1(refNode); | |
12246 return; | |
12247 } | |
12248 @JSName('selectNode') | |
12249 @DomName('Range.selectNode') | |
12250 @DocsEditable() | |
12251 void _selectNode_1(Node refNode) => wrap_jso(JS("void ", "#.raw.selectNode(#)"
, this, unwrap_jso(refNode))); | |
12252 | |
12253 @DomName('Range.selectNodeContents') | |
12254 @DocsEditable() | |
12255 void selectNodeContents(Node refNode) { | |
12256 _selectNodeContents_1(refNode); | |
12257 return; | |
12258 } | |
12259 @JSName('selectNodeContents') | |
12260 @DomName('Range.selectNodeContents') | |
12261 @DocsEditable() | |
12262 void _selectNodeContents_1(Node refNode) => wrap_jso(JS("void ", "#.raw.select
NodeContents(#)", this, unwrap_jso(refNode))); | |
12263 | |
12264 @DomName('Range.setEnd') | |
12265 @DocsEditable() | |
12266 void setEnd(Node refNode, int offset) { | |
12267 _setEnd_1(refNode, offset); | |
12268 return; | |
12269 } | |
12270 @JSName('setEnd') | |
12271 @DomName('Range.setEnd') | |
12272 @DocsEditable() | |
12273 void _setEnd_1(Node refNode, offset) => wrap_jso(JS("void ", "#.raw.setEnd(#,
#)", this, unwrap_jso(refNode), unwrap_jso(offset))); | |
12274 | |
12275 @DomName('Range.setEndAfter') | |
12276 @DocsEditable() | |
12277 void setEndAfter(Node refNode) { | |
12278 _setEndAfter_1(refNode); | |
12279 return; | |
12280 } | |
12281 @JSName('setEndAfter') | |
12282 @DomName('Range.setEndAfter') | |
12283 @DocsEditable() | |
12284 void _setEndAfter_1(Node refNode) => wrap_jso(JS("void ", "#.raw.setEndAfter(#
)", this, unwrap_jso(refNode))); | |
12285 | |
12286 @DomName('Range.setEndBefore') | |
12287 @DocsEditable() | |
12288 void setEndBefore(Node refNode) { | |
12289 _setEndBefore_1(refNode); | |
12290 return; | |
12291 } | |
12292 @JSName('setEndBefore') | |
12293 @DomName('Range.setEndBefore') | |
12294 @DocsEditable() | |
12295 void _setEndBefore_1(Node refNode) => wrap_jso(JS("void ", "#.raw.setEndBefore
(#)", this, unwrap_jso(refNode))); | |
12296 | |
12297 @DomName('Range.setStart') | |
12298 @DocsEditable() | |
12299 void setStart(Node refNode, int offset) { | |
12300 _setStart_1(refNode, offset); | |
12301 return; | |
12302 } | |
12303 @JSName('setStart') | |
12304 @DomName('Range.setStart') | |
12305 @DocsEditable() | |
12306 void _setStart_1(Node refNode, offset) => wrap_jso(JS("void ", "#.raw.setStart
(#, #)", this, unwrap_jso(refNode), unwrap_jso(offset))); | |
12307 | |
12308 @DomName('Range.setStartAfter') | |
12309 @DocsEditable() | |
12310 void setStartAfter(Node refNode) { | |
12311 _setStartAfter_1(refNode); | |
12312 return; | |
12313 } | |
12314 @JSName('setStartAfter') | |
12315 @DomName('Range.setStartAfter') | |
12316 @DocsEditable() | |
12317 void _setStartAfter_1(Node refNode) => wrap_jso(JS("void ", "#.raw.setStartAft
er(#)", this, unwrap_jso(refNode))); | |
12318 | |
12319 @DomName('Range.setStartBefore') | |
12320 @DocsEditable() | |
12321 void setStartBefore(Node refNode) { | |
12322 _setStartBefore_1(refNode); | |
12323 return; | |
12324 } | |
12325 @JSName('setStartBefore') | |
12326 @DomName('Range.setStartBefore') | |
12327 @DocsEditable() | |
12328 void _setStartBefore_1(Node refNode) => wrap_jso(JS("void ", "#.raw.setStartBe
fore(#)", this, unwrap_jso(refNode))); | |
12329 | |
12330 @DomName('Range.surroundContents') | |
12331 @DocsEditable() | |
12332 void surroundContents(Node newParent) { | |
12333 _surroundContents_1(newParent); | |
12334 return; | |
12335 } | |
12336 @JSName('surroundContents') | |
12337 @DomName('Range.surroundContents') | |
12338 @DocsEditable() | |
12339 void _surroundContents_1(Node newParent) => wrap_jso(JS("void ", "#.raw.surrou
ndContents(#)", this, unwrap_jso(newParent))); | |
12340 | |
12341 | |
12342 /** | |
12343 * Checks if createContextualFragment is supported. | |
12344 * | |
12345 * See also: | |
12346 * | |
12347 * * [createContextualFragment] | |
12348 */ | |
12349 static bool get supportsCreateContextualFragment => true; | |
12350 } | |
12351 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
12352 // for details. All rights reserved. Use of this source code is governed by a | |
12353 // BSD-style license that can be found in the LICENSE file. | |
12354 | |
12355 // WARNING: Do not edit - generated code. | |
12356 | |
12357 | |
12358 @DomName('RequestAnimationFrameCallback') | |
12359 typedef void RequestAnimationFrameCallback(num highResTime); | |
12360 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
12361 // for details. All rights reserved. Use of this source code is governed by a | |
12362 // BSD-style license that can be found in the LICENSE file. | |
12363 | |
12364 | |
12365 @DocsEditable() | |
12366 @DomName('Screen') | |
12367 @Native("Screen") | |
12368 class Screen extends DartHtmlDomObject { | |
12369 | |
12370 @DomName('Screen.availHeight') | |
12371 @DomName('Screen.availLeft') | |
12372 @DomName('Screen.availTop') | |
12373 @DomName('Screen.availWidth') | |
12374 Rectangle get available => new Rectangle(_availLeft, _availTop, _availWidth, | |
12375 _availHeight); | |
12376 // To suppress missing implicit constructor warnings. | |
12377 factory Screen._() { throw new UnsupportedError("Not supported"); } | |
12378 | |
12379 @Deprecated("Internal Use Only") | |
12380 static Screen internalCreateScreen() { | |
12381 return new Screen.internal_(); | |
12382 } | |
12383 | |
12384 @Deprecated("Internal Use Only") | |
12385 Screen.internal_() { } | |
12386 | |
12387 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
12388 int get hashCode => unwrap_jso(this).hashCode; | |
12389 | |
12390 @JSName('availHeight') | |
12391 @DomName('Screen.availHeight') | |
12392 @DocsEditable() | |
12393 int get _availHeight => wrap_jso(JS("int", "#.availHeight", this.raw)); | |
12394 | |
12395 @JSName('availLeft') | |
12396 @DomName('Screen.availLeft') | |
12397 @DocsEditable() | |
12398 @Experimental() // nonstandard | |
12399 int get _availLeft => wrap_jso(JS("int", "#.availLeft", this.raw)); | |
12400 | |
12401 @JSName('availTop') | |
12402 @DomName('Screen.availTop') | |
12403 @DocsEditable() | |
12404 @Experimental() // nonstandard | |
12405 int get _availTop => wrap_jso(JS("int", "#.availTop", this.raw)); | |
12406 | |
12407 @JSName('availWidth') | |
12408 @DomName('Screen.availWidth') | |
12409 @DocsEditable() | |
12410 int get _availWidth => wrap_jso(JS("int", "#.availWidth", this.raw)); | |
12411 | |
12412 @DomName('Screen.colorDepth') | |
12413 @DocsEditable() | |
12414 int get colorDepth => wrap_jso(JS("int", "#.colorDepth", this.raw)); | |
12415 | |
12416 @DomName('Screen.height') | |
12417 @DocsEditable() | |
12418 int get height => wrap_jso(JS("int", "#.height", this.raw)); | |
12419 | |
12420 @DomName('Screen.pixelDepth') | |
12421 @DocsEditable() | |
12422 int get pixelDepth => wrap_jso(JS("int", "#.pixelDepth", this.raw)); | |
12423 | |
12424 @DomName('Screen.width') | |
12425 @DocsEditable() | |
12426 int get width => wrap_jso(JS("int", "#.width", this.raw)); | |
12427 } | |
12428 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
12429 // for details. All rights reserved. Use of this source code is governed by a | |
12430 // BSD-style license that can be found in the LICENSE file. | |
12431 | |
12432 // WARNING: Do not edit - generated code. | |
12433 | |
12434 | |
12435 @DomName('ShadowRoot') | |
12436 @SupportedBrowser(SupportedBrowser.CHROME, '26') | |
12437 @Experimental() | |
12438 // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#api-
shadow-root | |
12439 @Native("ShadowRoot") | |
12440 class ShadowRoot extends DocumentFragment { | |
12441 // To suppress missing implicit constructor warnings. | |
12442 factory ShadowRoot._() { throw new UnsupportedError("Not supported"); } | |
12443 | |
12444 | |
12445 @Deprecated("Internal Use Only") | |
12446 static ShadowRoot internalCreateShadowRoot() { | |
12447 return new ShadowRoot.internal_(); | |
12448 } | |
12449 | |
12450 @Deprecated("Internal Use Only") | |
12451 ShadowRoot.internal_() : super.internal_(); | |
12452 | |
12453 | |
12454 @DomName('ShadowRoot.activeElement') | |
12455 @DocsEditable() | |
12456 Element get activeElement => wrap_jso(JS("Element", "#.activeElement", this.ra
w)); | |
12457 | |
12458 @DomName('ShadowRoot.host') | |
12459 @DocsEditable() | |
12460 @Experimental() // untriaged | |
12461 Element get host => wrap_jso(JS("Element", "#.host", this.raw)); | |
12462 | |
12463 @JSName('innerHTML') | |
12464 @DomName('ShadowRoot.innerHTML') | |
12465 @DocsEditable() | |
12466 String get innerHtml => wrap_jso(JS("String", "#.innerHTML", this.raw)); | |
12467 @JSName('innerHTML') | |
12468 @DomName('ShadowRoot.innerHTML') | |
12469 @DocsEditable() | |
12470 void set innerHtml(String val) => JS("void", "#.innerHTML = #", this.raw, unwr
ap_jso(val)); | |
12471 | |
12472 @DomName('ShadowRoot.olderShadowRoot') | |
12473 @DocsEditable() | |
12474 @Experimental() // untriaged | |
12475 ShadowRoot get olderShadowRoot => wrap_jso(JS("ShadowRoot", "#.olderShadowRoot
", this.raw)); | |
12476 | |
12477 @DomName('ShadowRoot.cloneNode') | |
12478 @DocsEditable() | |
12479 Node clone(bool deep) { | |
12480 return _clone_1(deep); | |
12481 } | |
12482 @JSName('cloneNode') | |
12483 @DomName('ShadowRoot.cloneNode') | |
12484 @DocsEditable() | |
12485 Node _clone_1(deep) => wrap_jso(JS("Node ", "#.raw.cloneNode(#)", this, unwrap
_jso(deep))); | |
12486 | |
12487 @DomName('ShadowRoot.elementFromPoint') | |
12488 @DocsEditable() | |
12489 Element elementFromPoint(int x, int y) { | |
12490 return _elementFromPoint_1(x, y); | |
12491 } | |
12492 @JSName('elementFromPoint') | |
12493 @DomName('ShadowRoot.elementFromPoint') | |
12494 @DocsEditable() | |
12495 Element _elementFromPoint_1(x, y) => wrap_jso(JS("Element ", "#.raw.elementFro
mPoint(#, #)", this, unwrap_jso(x), unwrap_jso(y))); | |
12496 | |
12497 @DomName('ShadowRoot.getElementsByClassName') | |
12498 @DocsEditable() | |
12499 @Creates('NodeList|HtmlCollection') | |
12500 @Returns('NodeList|HtmlCollection') | |
12501 HtmlCollection getElementsByClassName(String className) { | |
12502 return _getElementsByClassName_1(className); | |
12503 } | |
12504 @JSName('getElementsByClassName') | |
12505 @DomName('ShadowRoot.getElementsByClassName') | |
12506 @DocsEditable() | |
12507 @Creates('NodeList|HtmlCollection') | |
12508 @Returns('NodeList|HtmlCollection') | |
12509 HtmlCollection _getElementsByClassName_1(className) => wrap_jso(JS("HtmlCollec
tion ", "#.raw.getElementsByClassName(#)", this, unwrap_jso(className))); | |
12510 | |
12511 @DomName('ShadowRoot.getElementsByTagName') | |
12512 @DocsEditable() | |
12513 @Creates('NodeList|HtmlCollection') | |
12514 @Returns('NodeList|HtmlCollection') | |
12515 HtmlCollection getElementsByTagName(String tagName) { | |
12516 return _getElementsByTagName_1(tagName); | |
12517 } | |
12518 @JSName('getElementsByTagName') | |
12519 @DomName('ShadowRoot.getElementsByTagName') | |
12520 @DocsEditable() | |
12521 @Creates('NodeList|HtmlCollection') | |
12522 @Returns('NodeList|HtmlCollection') | |
12523 HtmlCollection _getElementsByTagName_1(tagName) => wrap_jso(JS("HtmlCollection
", "#.raw.getElementsByTagName(#)", this, unwrap_jso(tagName))); | |
12524 | |
12525 static final bool supported = true; | |
12526 | |
12527 static bool _shadowRootDeprecationReported = false; | |
12528 static void _shadowRootDeprecationReport() { | |
12529 if (!_shadowRootDeprecationReported) { | |
12530 window.console.warn(''' | |
12531 ShadowRoot.resetStyleInheritance and ShadowRoot.applyAuthorStyles now deprecated
in dart:html. | |
12532 Please remove them from your code. | |
12533 '''); | |
12534 _shadowRootDeprecationReported = true; | |
12535 } | |
12536 } | |
12537 | |
12538 @deprecated | |
12539 bool get resetStyleInheritance { | |
12540 _shadowRootDeprecationReport(); | |
12541 // Default value from when it was specified. | |
12542 return false; | |
12543 } | |
12544 | |
12545 @deprecated | |
12546 set resetStyleInheritance(bool value) { | |
12547 _shadowRootDeprecationReport(); | |
12548 } | |
12549 | |
12550 @deprecated | |
12551 bool get applyAuthorStyles { | |
12552 _shadowRootDeprecationReport(); | |
12553 // Default value from when it was specified. | |
12554 return false; | |
12555 } | |
12556 | |
12557 @deprecated | |
12558 set applyAuthorStyles(bool value) { | |
12559 _shadowRootDeprecationReport(); | |
12560 } | |
12561 } | |
12562 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
12563 // for details. All rights reserved. Use of this source code is governed by a | |
12564 // BSD-style license that can be found in the LICENSE file. | |
12565 | |
12566 | |
12567 @DocsEditable() | |
12568 @DomName('HTMLStyleElement') | |
12569 @Native("HTMLStyleElement") | |
12570 class StyleElement extends HtmlElement { | |
12571 // To suppress missing implicit constructor warnings. | |
12572 factory StyleElement._() { throw new UnsupportedError("Not supported"); } | |
12573 | |
12574 @DomName('HTMLStyleElement.HTMLStyleElement') | |
12575 @DocsEditable() | |
12576 factory StyleElement() => document.createElement("style"); | |
12577 | |
12578 | |
12579 @Deprecated("Internal Use Only") | |
12580 static StyleElement internalCreateStyleElement() { | |
12581 return new StyleElement.internal_(); | |
12582 } | |
12583 | |
12584 @Deprecated("Internal Use Only") | |
12585 StyleElement.internal_() : super.internal_(); | |
12586 | |
12587 | |
12588 @DomName('HTMLStyleElement.disabled') | |
12589 @DocsEditable() | |
12590 bool get disabled => wrap_jso(JS("bool", "#.disabled", this.raw)); | |
12591 @DomName('HTMLStyleElement.disabled') | |
12592 @DocsEditable() | |
12593 void set disabled(bool val) => JS("void", "#.disabled = #", this.raw, unwrap_j
so(val)); | |
12594 | |
12595 @DomName('HTMLStyleElement.media') | |
12596 @DocsEditable() | |
12597 String get media => wrap_jso(JS("String", "#.media", this.raw)); | |
12598 @DomName('HTMLStyleElement.media') | |
12599 @DocsEditable() | |
12600 void set media(String val) => JS("void", "#.media = #", this.raw, unwrap_jso(v
al)); | |
12601 | |
12602 @DomName('HTMLStyleElement.type') | |
12603 @DocsEditable() | |
12604 String get type => wrap_jso(JS("String", "#.type", this.raw)); | |
12605 @DomName('HTMLStyleElement.type') | |
12606 @DocsEditable() | |
12607 void set type(String val) => JS("void", "#.type = #", this.raw, unwrap_jso(val
)); | |
12608 } | |
12609 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
12610 // for details. All rights reserved. Use of this source code is governed by a | |
12611 // BSD-style license that can be found in the LICENSE file. | |
12612 | |
12613 // WARNING: Do not edit - generated code. | |
12614 | |
12615 | |
12616 @Experimental() | |
12617 @DomName('HTMLTemplateElement') | |
12618 @SupportedBrowser(SupportedBrowser.CHROME) | |
12619 @Experimental() | |
12620 // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#t
emplate-element | |
12621 @Native("HTMLTemplateElement") | |
12622 class TemplateElement extends HtmlElement { | |
12623 // To suppress missing implicit constructor warnings. | |
12624 factory TemplateElement._() { throw new UnsupportedError("Not supported"); } | |
12625 | |
12626 @DomName('HTMLTemplateElement.HTMLTemplateElement') | |
12627 @DocsEditable() | |
12628 factory TemplateElement() => document.createElement("template"); | |
12629 | |
12630 | |
12631 @Deprecated("Internal Use Only") | |
12632 static TemplateElement internalCreateTemplateElement() { | |
12633 return new TemplateElement.internal_(); | |
12634 } | |
12635 | |
12636 @Deprecated("Internal Use Only") | |
12637 TemplateElement.internal_() : super.internal_(); | |
12638 | |
12639 | |
12640 /// Checks if this type is supported on the current platform. | |
12641 static bool get supported => Element.isTagSupported('template'); | |
12642 | |
12643 @DomName('HTMLTemplateElement.content') | |
12644 @DocsEditable() | |
12645 DocumentFragment get content => wrap_jso(JS("DocumentFragment", "#.content", t
his.raw)); | |
12646 | |
12647 | |
12648 /** | |
12649 * An override to place the contents into content rather than as child nodes. | |
12650 * | |
12651 * See also: | |
12652 * | |
12653 * * <https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.h
tml#innerhtml-on-templates> | |
12654 */ | |
12655 void setInnerHtml(String html, | |
12656 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | |
12657 text = null; | |
12658 var fragment = createFragment( | |
12659 html, validator: validator, treeSanitizer: treeSanitizer); | |
12660 | |
12661 content.append(fragment); | |
12662 } | |
12663 } | |
12664 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
12665 // for details. All rights reserved. Use of this source code is governed by a | |
12666 // BSD-style license that can be found in the LICENSE file. | |
12667 | |
12668 // WARNING: Do not edit - generated code. | |
12669 | |
12670 | |
12671 @DomName('Text') | |
12672 @Native("Text") | |
12673 class Text extends CharacterData { | |
12674 factory Text(String data) => document._createTextNode(data); | |
12675 // To suppress missing implicit constructor warnings. | |
12676 factory Text._() { throw new UnsupportedError("Not supported"); } | |
12677 | |
12678 | |
12679 @Deprecated("Internal Use Only") | |
12680 static Text internalCreateText() { | |
12681 return new Text.internal_(); | |
12682 } | |
12683 | |
12684 @Deprecated("Internal Use Only") | |
12685 Text.internal_() : super.internal_(); | |
12686 | |
12687 | |
12688 @DomName('Text.wholeText') | |
12689 @DocsEditable() | |
12690 String get wholeText => wrap_jso(JS("String", "#.wholeText", this.raw)); | |
12691 | |
12692 @DomName('Text.getDestinationInsertionPoints') | |
12693 @DocsEditable() | |
12694 @Experimental() // untriaged | |
12695 @Returns('NodeList') | |
12696 @Creates('NodeList') | |
12697 NodeList getDestinationInsertionPoints() { | |
12698 return _getDestinationInsertionPoints_1(); | |
12699 } | |
12700 @JSName('getDestinationInsertionPoints') | |
12701 @DomName('Text.getDestinationInsertionPoints') | |
12702 @DocsEditable() | |
12703 @Experimental() // untriaged | |
12704 @Returns('NodeList') | |
12705 @Creates('NodeList') | |
12706 NodeList _getDestinationInsertionPoints_1() => wrap_jso(JS("NodeList ", "#.raw
.getDestinationInsertionPoints()", this)); | |
12707 | |
12708 @DomName('Text.splitText') | |
12709 @DocsEditable() | |
12710 Text splitText(int offset) { | |
12711 return _splitText_1(offset); | |
12712 } | |
12713 @JSName('splitText') | |
12714 @DomName('Text.splitText') | |
12715 @DocsEditable() | |
12716 Text _splitText_1(offset) => wrap_jso(JS("Text ", "#.raw.splitText(#)", this,
unwrap_jso(offset))); | |
12717 | |
12718 } | |
12719 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
12720 // for details. All rights reserved. Use of this source code is governed by a | |
12721 // BSD-style license that can be found in the LICENSE file. | |
12722 | |
12723 // WARNING: Do not edit - generated code. | |
12724 | |
12725 | |
12726 @DomName('UIEvent') | |
12727 @Native("UIEvent") | |
12728 class UIEvent extends Event { | |
12729 // In JS, canBubble and cancelable are technically required parameters to | |
12730 // init*Event. In practice, though, if they aren't provided they simply | |
12731 // default to false (since that's Boolean(undefined)). | |
12732 // | |
12733 // Contrary to JS, we default canBubble and cancelable to true, since that's | |
12734 // what people want most of the time anyway. | |
12735 factory UIEvent(String type, | |
12736 {Window view, int detail: 0, bool canBubble: true, | |
12737 bool cancelable: true}) { | |
12738 if (view == null) { | |
12739 view = window; | |
12740 } | |
12741 UIEvent e = document._createEvent("UIEvent"); | |
12742 e._initUIEvent(type, canBubble, cancelable, view, detail); | |
12743 return e; | |
12744 } | |
12745 // To suppress missing implicit constructor warnings. | |
12746 factory UIEvent._() { throw new UnsupportedError("Not supported"); } | |
12747 | |
12748 | |
12749 @Deprecated("Internal Use Only") | |
12750 static UIEvent internalCreateUIEvent() { | |
12751 return new UIEvent.internal_(); | |
12752 } | |
12753 | |
12754 @Deprecated("Internal Use Only") | |
12755 UIEvent.internal_() : super.internal_(); | |
12756 | |
12757 | |
12758 @JSName('charCode') | |
12759 @DomName('UIEvent.charCode') | |
12760 @DocsEditable() | |
12761 @Unstable() | |
12762 int get _charCode => wrap_jso(JS("int", "#.charCode", this.raw)); | |
12763 | |
12764 @DomName('UIEvent.detail') | |
12765 @DocsEditable() | |
12766 int get detail => wrap_jso(JS("int", "#.detail", this.raw)); | |
12767 | |
12768 @JSName('keyCode') | |
12769 @DomName('UIEvent.keyCode') | |
12770 @DocsEditable() | |
12771 @Unstable() | |
12772 int get _keyCode => wrap_jso(JS("int", "#.keyCode", this.raw)); | |
12773 | |
12774 @JSName('layerX') | |
12775 @DomName('UIEvent.layerX') | |
12776 @DocsEditable() | |
12777 // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#even
ts-mouseevents | |
12778 @Experimental() // nonstandard | |
12779 int get _layerX => wrap_jso(JS("int", "#.layerX", this.raw)); | |
12780 | |
12781 @JSName('layerY') | |
12782 @DomName('UIEvent.layerY') | |
12783 @DocsEditable() | |
12784 // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#even
ts-mouseevents | |
12785 @Experimental() // nonstandard | |
12786 int get _layerY => wrap_jso(JS("int", "#.layerY", this.raw)); | |
12787 | |
12788 @JSName('pageX') | |
12789 @DomName('UIEvent.pageX') | |
12790 @DocsEditable() | |
12791 // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#even
ts-mouseevents | |
12792 @Experimental() // nonstandard | |
12793 int get _pageX => wrap_jso(JS("int", "#.pageX", this.raw)); | |
12794 | |
12795 @JSName('pageY') | |
12796 @DomName('UIEvent.pageY') | |
12797 @DocsEditable() | |
12798 // http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#even
ts-mouseevents | |
12799 @Experimental() // nonstandard | |
12800 int get _pageY => wrap_jso(JS("int", "#.pageY", this.raw)); | |
12801 | |
12802 @DomName('UIEvent.view') | |
12803 @DocsEditable() | |
12804 WindowBase get view => _convertNativeToDart_Window(this._get_view); | |
12805 @JSName('view') | |
12806 @DomName('UIEvent.view') | |
12807 @DocsEditable() | |
12808 @Creates('Window|=Object') | |
12809 @Returns('Window|=Object') | |
12810 dynamic get _get_view => wrap_jso(JS("dynamic", "#.view", this.raw)); | |
12811 | |
12812 @DomName('UIEvent.which') | |
12813 @DocsEditable() | |
12814 @Unstable() | |
12815 int get which => wrap_jso(JS("int", "#.which", this.raw)); | |
12816 | |
12817 @DomName('UIEvent.initUIEvent') | |
12818 @DocsEditable() | |
12819 void _initUIEvent(String type, bool canBubble, bool cancelable, Window view, i
nt detail) { | |
12820 _initUIEvent_1(type, canBubble, cancelable, view, detail); | |
12821 return; | |
12822 } | |
12823 @JSName('initUIEvent') | |
12824 @DomName('UIEvent.initUIEvent') | |
12825 @DocsEditable() | |
12826 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))
); | |
12827 | |
12828 | |
12829 @DomName('UIEvent.layerX') | |
12830 @DomName('UIEvent.layerY') | |
12831 Point get layer => new Point(_layerX, _layerY); | |
12832 | |
12833 @DomName('UIEvent.pageX') | |
12834 @DomName('UIEvent.pageY') | |
12835 Point get page => new Point(_pageX, _pageY); | |
12836 } | |
12837 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
12838 // for details. All rights reserved. Use of this source code is governed by a | |
12839 // BSD-style license that can be found in the LICENSE file. | |
12840 | |
12841 | |
12842 @DocsEditable() | |
12843 @DomName('URLUtils') | |
12844 @Experimental() // untriaged | |
12845 abstract class UrlUtils extends DartHtmlDomObject { | |
12846 // To suppress missing implicit constructor warnings. | |
12847 factory UrlUtils._() { throw new UnsupportedError("Not supported"); } | |
12848 | |
12849 String get hash => wrap_jso(JS("String", "#.hash", this.raw)); | |
12850 void set hash(String val) => JS("void", "#.hash = #", this.raw, unwrap_jso(val
)); | |
12851 | |
12852 String get host => wrap_jso(JS("String", "#.host", this.raw)); | |
12853 void set host(String val) => JS("void", "#.host = #", this.raw, unwrap_jso(val
)); | |
12854 | |
12855 String get hostname => wrap_jso(JS("String", "#.hostname", this.raw)); | |
12856 void set hostname(String val) => JS("void", "#.hostname = #", this.raw, unwrap
_jso(val)); | |
12857 | |
12858 String get href => wrap_jso(JS("String", "#.href", this.raw)); | |
12859 void set href(String val) => JS("void", "#.href = #", this.raw, unwrap_jso(val
)); | |
12860 | |
12861 String get origin => wrap_jso(JS("String", "#.origin", this.raw)); | |
12862 | |
12863 String get password => wrap_jso(JS("String", "#.password", this.raw)); | |
12864 void set password(String val) => JS("void", "#.password = #", this.raw, unwrap
_jso(val)); | |
12865 | |
12866 String get pathname => wrap_jso(JS("String", "#.pathname", this.raw)); | |
12867 void set pathname(String val) => JS("void", "#.pathname = #", this.raw, unwrap
_jso(val)); | |
12868 | |
12869 String get port => wrap_jso(JS("String", "#.port", this.raw)); | |
12870 void set port(String val) => JS("void", "#.port = #", this.raw, unwrap_jso(val
)); | |
12871 | |
12872 String get protocol => wrap_jso(JS("String", "#.protocol", this.raw)); | |
12873 void set protocol(String val) => JS("void", "#.protocol = #", this.raw, unwrap
_jso(val)); | |
12874 | |
12875 String get search => wrap_jso(JS("String", "#.search", this.raw)); | |
12876 void set search(String val) => JS("void", "#.search = #", this.raw, unwrap_jso
(val)); | |
12877 | |
12878 String get username => wrap_jso(JS("String", "#.username", this.raw)); | |
12879 void set username(String val) => JS("void", "#.username = #", this.raw, unwrap
_jso(val)); | |
12880 | |
12881 String toString() => wrap_jso(JS("String", "#.raw.toString()", this)); | |
12882 } | |
12883 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
12884 // for details. All rights reserved. Use of this source code is governed by a | |
12885 // BSD-style license that can be found in the LICENSE file. | |
12886 | |
12887 | |
12888 @DocsEditable() | |
12889 /** | |
12890 * Top-level container for the current browser tab or window. | |
12891 * | |
12892 * In a web browser, each window has a [Window] object, but within the context | |
12893 * of a script, this object represents only the current window. | |
12894 * Each other window, tab, and iframe has its own [Window] object. | |
12895 * | |
12896 * Each window contains a [Document] object, which contains all of the window's | |
12897 * content. | |
12898 * | |
12899 * Use the top-level `window` object to access the current window. | |
12900 * For example: | |
12901 * | |
12902 * // Draw a scene when the window repaints. | |
12903 * drawScene(num delta) {...} | |
12904 * window.animationFrame.then(drawScene);. | |
12905 * | |
12906 * // Write to the console. | |
12907 * window.console.log('Jinkies!'); | |
12908 * window.console.error('Jeepers!'); | |
12909 * | |
12910 * **Note:** This class represents only the current window, while [WindowBase] | |
12911 * is a representation of any window, including other tabs, windows, and frames. | |
12912 * | |
12913 * ## See also | |
12914 * | |
12915 * * [WindowBase] | |
12916 * | |
12917 * ## Other resources | |
12918 * | |
12919 * * [DOM Window](https://developer.mozilla.org/en-US/docs/DOM/window) from MDN. | |
12920 * * [Window](http://www.w3.org/TR/Window/) from the W3C. | |
12921 */ | |
12922 @DomName('Window') | |
12923 @Native("Window") | |
12924 class Window extends EventTarget implements WindowBase { | |
12925 | |
12926 /** | |
12927 * Returns a Future that completes just before the window is about to | |
12928 * repaint so the user can draw an animation frame. | |
12929 * | |
12930 * If you need to later cancel this animation, use [requestAnimationFrame] | |
12931 * instead. | |
12932 * | |
12933 * The [Future] completes to a timestamp that represents a floating | |
12934 * point value of the number of milliseconds that have elapsed since the page | |
12935 * started to load (which is also the timestamp at this call to | |
12936 * animationFrame). | |
12937 * | |
12938 * Note: The code that runs when the future completes should call | |
12939 * [animationFrame] again for the animation to continue. | |
12940 */ | |
12941 Future<num> get animationFrame { | |
12942 var completer = new Completer<num>.sync(); | |
12943 requestAnimationFrame((time) { | |
12944 completer.complete(time); | |
12945 }); | |
12946 return completer.future; | |
12947 } | |
12948 | |
12949 /** | |
12950 * The newest document in this window. | |
12951 * | |
12952 * ## Other resources | |
12953 * | |
12954 * * [Loading web pages] | |
12955 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html) | |
12956 * from WHATWG. | |
12957 */ | |
12958 Document get document => wrap_jso(JS('Document', '#.document', this.raw)); | |
12959 | |
12960 WindowBase _open2(url, name) => wrap_jso(JS('Window', '#.open(#,#)', this.raw,
url, name)); | |
12961 | |
12962 WindowBase _open3(url, name, options) => | |
12963 wrap_jso(JS('Window', '#.open(#,#,#)', this.raw, url, name, options)); | |
12964 | |
12965 /** | |
12966 * Opens a new window. | |
12967 * | |
12968 * ## Other resources | |
12969 * | |
12970 * * [Window.open] | |
12971 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.open) from MDN. | |
12972 * * [Window open] | |
12973 * (http://docs.webplatform.org/wiki/dom/methods/open) from WebPlatform.org. | |
12974 */ | |
12975 WindowBase open(String url, String name, [String options]) { | |
12976 if (options == null) { | |
12977 return _DOMWindowCrossFrame._createSafe(_open2(url, name)); | |
12978 } else { | |
12979 return _DOMWindowCrossFrame._createSafe(_open3(url, name, options)); | |
12980 } | |
12981 } | |
12982 | |
12983 // API level getter and setter for Location. | |
12984 // TODO: The cross domain safe wrapper can be inserted here. | |
12985 /** | |
12986 * The current location of this window. | |
12987 * | |
12988 * Location currentLocation = window.location; | |
12989 * print(currentLocation.href); // 'http://www.example.com:80/' | |
12990 */ | |
12991 Location get location => _location; | |
12992 | |
12993 // TODO: consider forcing users to do: window.location.assign('string'). | |
12994 /** | |
12995 * Sets the window's location, which causes the browser to navigate to the new | |
12996 * location. [value] may be a Location object or a String. | |
12997 */ | |
12998 set location(value) { | |
12999 _location = value; | |
13000 } | |
13001 | |
13002 // Native getter and setter to access raw Location object. | |
13003 dynamic get _location => wrap_jso(JS('Location|Null', '#.location', this.raw))
; | |
13004 set _location(value) { | |
13005 JS('void', '#.location = #', this.raw, unwrap_jso(value)); | |
13006 } | |
13007 | |
13008 /** | |
13009 * Called to draw an animation frame and then request the window to repaint | |
13010 * after [callback] has finished (creating the animation). | |
13011 * | |
13012 * Use this method only if you need to later call [cancelAnimationFrame]. If | |
13013 * not, the preferred Dart idiom is to set animation frames by calling | |
13014 * [animationFrame], which returns a Future. | |
13015 * | |
13016 * Returns a non-zero valued integer to represent the request id for this | |
13017 * request. This value only needs to be saved if you intend to call | |
13018 * [cancelAnimationFrame] so you can specify the particular animation to | |
13019 * cancel. | |
13020 * | |
13021 * Note: The supplied [callback] needs to call [requestAnimationFrame] again | |
13022 * for the animation to continue. | |
13023 */ | |
13024 @DomName('Window.requestAnimationFrame') | |
13025 int requestAnimationFrame(RequestAnimationFrameCallback callback) { | |
13026 _ensureRequestAnimationFrame(); | |
13027 return _requestAnimationFrame(_wrapZone(callback)); | |
13028 } | |
13029 | |
13030 /** | |
13031 * Cancels an animation frame request. | |
13032 * | |
13033 * ## Other resources | |
13034 * | |
13035 * * [Window.cancelAnimationFrame] | |
13036 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.cancelAnimationFra
me) from MDN. | |
13037 */ | |
13038 void cancelAnimationFrame(int id) { | |
13039 _ensureRequestAnimationFrame(); | |
13040 _cancelAnimationFrame(id); | |
13041 } | |
13042 | |
13043 @JSName('requestAnimationFrame') | |
13044 int _requestAnimationFrame(RequestAnimationFrameCallback callback) | |
13045 => JS('int', '#.requestAnimationFrame', this.raw); | |
13046 | |
13047 @JSName('cancelAnimationFrame') | |
13048 void _cancelAnimationFrame(int id) | |
13049 { JS('void', '#.cancelAnimationFrame(#)', this.raw, id); } | |
13050 | |
13051 _ensureRequestAnimationFrame() { | |
13052 if (JS('bool', | |
13053 '!!(#.requestAnimationFrame && #.cancelAnimationFrame)', this.raw, th
is.raw)) | |
13054 return; | |
13055 | |
13056 JS('void', | |
13057 r""" | |
13058 (function($this) { | |
13059 var vendors = ['ms', 'moz', 'webkit', 'o']; | |
13060 for (var i = 0; i < vendors.length && !$this.requestAnimationFrame; ++i) { | |
13061 $this.requestAnimationFrame = $this[vendors[i] + 'RequestAnimationFrame']; | |
13062 $this.cancelAnimationFrame = | |
13063 $this[vendors[i]+'CancelAnimationFrame'] || | |
13064 $this[vendors[i]+'CancelRequestAnimationFrame']; | |
13065 } | |
13066 if ($this.requestAnimationFrame && $this.cancelAnimationFrame) return; | |
13067 $this.requestAnimationFrame = function(callback) { | |
13068 return window.setTimeout(function() { | |
13069 callback(Date.now()); | |
13070 }, 16 /* 16ms ~= 60fps */); | |
13071 }; | |
13072 $this.cancelAnimationFrame = function(id) { clearTimeout(id); } | |
13073 })(#)""", | |
13074 this.raw); | |
13075 } | |
13076 | |
13077 /// The debugging console for this window. | |
13078 @DomName('Window.console') | |
13079 Console get console => Console._safeConsole; | |
13080 | |
13081 // To suppress missing implicit constructor warnings. | |
13082 factory Window._() { throw new UnsupportedError("Not supported"); } | |
13083 | |
13084 /** | |
13085 * Static factory designed to expose `contentloaded` events to event | |
13086 * handlers that are not necessarily instances of [Window]. | |
13087 * | |
13088 * See [EventStreamProvider] for usage information. | |
13089 */ | |
13090 @DomName('Window.DOMContentLoadedEvent') | |
13091 @DocsEditable() | |
13092 static const EventStreamProvider<Event> contentLoadedEvent = const EventStream
Provider<Event>('DOMContentLoaded'); | |
13093 | |
13094 | |
13095 @Deprecated("Internal Use Only") | |
13096 static Window internalCreateWindow() { | |
13097 return new Window.internal_(); | |
13098 } | |
13099 | |
13100 @Deprecated("Internal Use Only") | |
13101 Window.internal_() : super.internal_(); | |
13102 | |
13103 | |
13104 /** | |
13105 * Indicates that file system data cannot be cleared unless given user | |
13106 * permission. | |
13107 * | |
13108 * ## Other resources | |
13109 * | |
13110 * * [Exploring the FileSystem APIs] | |
13111 * (http://www.html5rocks.com/en/tutorials/file/filesystem/) from HTML5Rocks. | |
13112 * * [File API] | |
13113 * (http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem) from W3C. | |
13114 */ | |
13115 @DomName('Window.PERSISTENT') | |
13116 @DocsEditable() | |
13117 // http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem | |
13118 @Experimental() | |
13119 static const int PERSISTENT = 1; | |
13120 | |
13121 /** | |
13122 * Indicates that file system data can be cleared at any time. | |
13123 * | |
13124 * ## Other resources | |
13125 * | |
13126 * * [Exploring the FileSystem APIs] | |
13127 * (http://www.html5rocks.com/en/tutorials/file/filesystem/) from HTML5Rocks. | |
13128 * * [File API] | |
13129 * (http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem) from W3C. | |
13130 */ | |
13131 @DomName('Window.TEMPORARY') | |
13132 @DocsEditable() | |
13133 // http://www.w3.org/TR/file-system-api/#idl-def-LocalFileSystem | |
13134 @Experimental() | |
13135 static const int TEMPORARY = 0; | |
13136 | |
13137 @DomName('Window.closed') | |
13138 @DocsEditable() | |
13139 bool get closed => wrap_jso(JS("bool", "#.closed", this.raw)); | |
13140 | |
13141 /// *Deprecated*. | |
13142 @DomName('Window.defaultStatus') | |
13143 @DocsEditable() | |
13144 @Experimental() // non-standard | |
13145 String get defaultStatus => wrap_jso(JS("String", "#.defaultStatus", this.raw)
); | |
13146 /// *Deprecated*. | |
13147 @DomName('Window.defaultStatus') | |
13148 @DocsEditable() | |
13149 @Experimental() // non-standard | |
13150 void set defaultStatus(String val) => JS("void", "#.defaultStatus = #", this.r
aw, unwrap_jso(val)); | |
13151 | |
13152 /// *Deprecated*. | |
13153 @DomName('Window.defaultstatus') | |
13154 @DocsEditable() | |
13155 @Experimental() // non-standard | |
13156 String get defaultstatus => wrap_jso(JS("String", "#.defaultstatus", this.raw)
); | |
13157 /// *Deprecated*. | |
13158 @DomName('Window.defaultstatus') | |
13159 @DocsEditable() | |
13160 @Experimental() // non-standard | |
13161 void set defaultstatus(String val) => JS("void", "#.defaultstatus = #", this.r
aw, unwrap_jso(val)); | |
13162 | |
13163 /** | |
13164 * The ratio between physical pixels and logical CSS pixels. | |
13165 * | |
13166 * ## Other resources | |
13167 * | |
13168 * * [devicePixelRatio] | |
13169 * (http://www.quirksmode.org/blog/archives/2012/06/devicepixelrati.html) from | |
13170 * quirksmode. | |
13171 * * [More about devicePixelRatio] | |
13172 * (http://www.quirksmode.org/blog/archives/2012/07/more_about_devi.html) from | |
13173 * quirksmode. | |
13174 */ | |
13175 @DomName('Window.devicePixelRatio') | |
13176 @DocsEditable() | |
13177 // http://www.quirksmode.org/blog/archives/2012/06/devicepixelrati.html | |
13178 @Experimental() // non-standard | |
13179 double get devicePixelRatio => wrap_jso(JS("double", "#.devicePixelRatio", thi
s.raw)); | |
13180 | |
13181 /** | |
13182 * The current session history for this window's newest document. | |
13183 * | |
13184 * ## Other resources | |
13185 * | |
13186 * * [Loading web pages] | |
13187 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html) | |
13188 * from WHATWG. | |
13189 */ | |
13190 @DomName('Window.history') | |
13191 @DocsEditable() | |
13192 History get history => wrap_jso(JS("History", "#.history", this.raw)); | |
13193 | |
13194 /** | |
13195 * The height of the viewport including scrollbars. | |
13196 * | |
13197 * ## Other resources | |
13198 * | |
13199 * * [innerHeight] | |
13200 * (http://docs.webplatform.org/wiki/css/cssom/properties/innerHeight) from | |
13201 * WebPlatform.org. | |
13202 */ | |
13203 @DomName('Window.innerHeight') | |
13204 @DocsEditable() | |
13205 int get innerHeight => wrap_jso(JS("int", "#.innerHeight", this.raw)); | |
13206 | |
13207 /** | |
13208 * The width of the viewport including scrollbars. | |
13209 * | |
13210 * ## Other resources | |
13211 * | |
13212 * * [innerWidth] | |
13213 * (http://docs.webplatform.org/wiki/css/cssom/properties/innerWidth) from | |
13214 * WebPlatform.org. | |
13215 */ | |
13216 @DomName('Window.innerWidth') | |
13217 @DocsEditable() | |
13218 int get innerWidth => wrap_jso(JS("int", "#.innerWidth", this.raw)); | |
13219 | |
13220 /** | |
13221 * The name of this window. | |
13222 * | |
13223 * ## Other resources | |
13224 * | |
13225 * * [Window name] | |
13226 * (http://docs.webplatform.org/wiki/html/attributes/name_(window)) from | |
13227 * WebPlatform.org. | |
13228 */ | |
13229 @DomName('Window.name') | |
13230 @DocsEditable() | |
13231 String get name => wrap_jso(JS("String", "#.name", this.raw)); | |
13232 /** | |
13233 * The name of this window. | |
13234 * | |
13235 * ## Other resources | |
13236 * | |
13237 * * [Window name] | |
13238 * (http://docs.webplatform.org/wiki/html/attributes/name_(window)) from | |
13239 * WebPlatform.org. | |
13240 */ | |
13241 @DomName('Window.name') | |
13242 @DocsEditable() | |
13243 void set name(String val) => JS("void", "#.name = #", this.raw, unwrap_jso(val
)); | |
13244 | |
13245 /** | |
13246 * The user agent accessing this window. | |
13247 * | |
13248 * ## Other resources | |
13249 * | |
13250 * * [The navigator object] | |
13251 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#th
e-navigator-object) | |
13252 * from WHATWG. | |
13253 */ | |
13254 @DomName('Window.navigator') | |
13255 @DocsEditable() | |
13256 Navigator get navigator => wrap_jso(JS("Navigator", "#.navigator", this.raw)); | |
13257 | |
13258 /** | |
13259 * Whether objects are drawn offscreen before being displayed. | |
13260 * | |
13261 * ## Other resources | |
13262 * | |
13263 * * [offscreenBuffering] | |
13264 * (http://docs.webplatform.org/wiki/dom/properties/offscreenBuffering) from | |
13265 * WebPlatform.org. | |
13266 */ | |
13267 @DomName('Window.offscreenBuffering') | |
13268 @DocsEditable() | |
13269 @Experimental() // non-standard | |
13270 bool get offscreenBuffering => wrap_jso(JS("bool", "#.offscreenBuffering", thi
s.raw)); | |
13271 | |
13272 @DomName('Window.opener') | |
13273 @DocsEditable() | |
13274 WindowBase get opener => _convertNativeToDart_Window(this._get_opener); | |
13275 @JSName('opener') | |
13276 @DomName('Window.opener') | |
13277 @DocsEditable() | |
13278 @Creates('Window|=Object') | |
13279 @Returns('Window|=Object') | |
13280 dynamic get _get_opener => wrap_jso(JS("dynamic", "#.opener", this.raw)); | |
13281 | |
13282 set opener(Window value) { | |
13283 JS("void", "#.raw.opener = #", this, unwrap_jso(value)); | |
13284 } | |
13285 | |
13286 @DomName('Window.orientation') | |
13287 @DocsEditable() | |
13288 @Experimental() // untriaged | |
13289 int get orientation => wrap_jso(JS("int", "#.orientation", this.raw)); | |
13290 | |
13291 /** | |
13292 * The height of this window including all user interface elements. | |
13293 * | |
13294 * ## Other resources | |
13295 * | |
13296 * * [outerHeight] | |
13297 * (http://docs.webplatform.org/wiki/css/cssom/properties/outerHeight) from | |
13298 * WebPlatform.org. | |
13299 */ | |
13300 @DomName('Window.outerHeight') | |
13301 @DocsEditable() | |
13302 int get outerHeight => wrap_jso(JS("int", "#.outerHeight", this.raw)); | |
13303 | |
13304 /** | |
13305 * The width of the window including all user interface elements. | |
13306 * | |
13307 * ## Other resources | |
13308 * | |
13309 * * [outerWidth] | |
13310 * (http://docs.webplatform.org/wiki/css/cssom/properties/outerWidth) from | |
13311 * WebPlatform.org. | |
13312 */ | |
13313 @DomName('Window.outerWidth') | |
13314 @DocsEditable() | |
13315 int get outerWidth => wrap_jso(JS("int", "#.outerWidth", this.raw)); | |
13316 | |
13317 @JSName('pageXOffset') | |
13318 /** | |
13319 * The distance this window has been scrolled horizontally. | |
13320 * | |
13321 * This attribute is an alias for [scrollX]. | |
13322 * | |
13323 * ## Other resources | |
13324 * | |
13325 * * [The Screen interface specification] | |
13326 * (http://www.w3.org/TR/cssom-view/#screen) from W3C. | |
13327 * * [scrollX and pageXOffset] | |
13328 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollX) from MDN. | |
13329 */ | |
13330 @DomName('Window.pageXOffset') | |
13331 @DocsEditable() | |
13332 double get _pageXOffset => wrap_jso(JS("double", "#.pageXOffset", this.raw)); | |
13333 | |
13334 @JSName('pageYOffset') | |
13335 /** | |
13336 * The distance this window has been scrolled vertically. | |
13337 * | |
13338 * This attribute is an alias for [scrollY]. | |
13339 * | |
13340 * ## Other resources | |
13341 * | |
13342 * * [The Screen interface specification] | |
13343 * (http://www.w3.org/TR/cssom-view/#screen) from W3C. | |
13344 * * [scrollY and pageYOffset] | |
13345 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY) from MDN. | |
13346 */ | |
13347 @DomName('Window.pageYOffset') | |
13348 @DocsEditable() | |
13349 double get _pageYOffset => wrap_jso(JS("double", "#.pageYOffset", this.raw)); | |
13350 | |
13351 @DomName('Window.parent') | |
13352 @DocsEditable() | |
13353 WindowBase get parent => _convertNativeToDart_Window(this._get_parent); | |
13354 @JSName('parent') | |
13355 @DomName('Window.parent') | |
13356 @DocsEditable() | |
13357 @Creates('Window|=Object') | |
13358 @Returns('Window|=Object') | |
13359 dynamic get _get_parent => wrap_jso(JS("dynamic", "#.parent", this.raw)); | |
13360 | |
13361 /** | |
13362 * Information about the screen displaying this window. | |
13363 * | |
13364 * ## Other resources | |
13365 * | |
13366 * * [The Screen interface specification] | |
13367 * (http://www.w3.org/TR/cssom-view/#screen) from W3C. | |
13368 */ | |
13369 @DomName('Window.screen') | |
13370 @DocsEditable() | |
13371 Screen get screen => wrap_jso(JS("Screen", "#.screen", this.raw)); | |
13372 | |
13373 /** | |
13374 * The distance from the left side of the screen to the left side of this | |
13375 * window. | |
13376 * | |
13377 * ## Other resources | |
13378 * | |
13379 * * [The Screen interface specification] | |
13380 * (http://www.w3.org/TR/cssom-view/#screen) from W3C. | |
13381 */ | |
13382 @DomName('Window.screenLeft') | |
13383 @DocsEditable() | |
13384 int get screenLeft => wrap_jso(JS("int", "#.screenLeft", this.raw)); | |
13385 | |
13386 /** | |
13387 * The distance from the top of the screen to the top of this window. | |
13388 * | |
13389 * ## Other resources | |
13390 * | |
13391 * * [The Screen interface specification] | |
13392 * (http://www.w3.org/TR/cssom-view/#screen) from W3C. | |
13393 */ | |
13394 @DomName('Window.screenTop') | |
13395 @DocsEditable() | |
13396 int get screenTop => wrap_jso(JS("int", "#.screenTop", this.raw)); | |
13397 | |
13398 /** | |
13399 * The distance from the left side of the screen to the mouse pointer. | |
13400 * | |
13401 * ## Other resources | |
13402 * | |
13403 * * [The Screen interface specification] | |
13404 * (http://www.w3.org/TR/cssom-view/#screen) from W3C. | |
13405 */ | |
13406 @DomName('Window.screenX') | |
13407 @DocsEditable() | |
13408 int get screenX => wrap_jso(JS("int", "#.screenX", this.raw)); | |
13409 | |
13410 /** | |
13411 * The distance from the top of the screen to the mouse pointer. | |
13412 * | |
13413 * ## Other resources | |
13414 * | |
13415 * * [The Screen interface specification] | |
13416 * (http://www.w3.org/TR/cssom-view/#screen) from W3C. | |
13417 */ | |
13418 @DomName('Window.screenY') | |
13419 @DocsEditable() | |
13420 int get screenY => wrap_jso(JS("int", "#.screenY", this.raw)); | |
13421 | |
13422 /** | |
13423 * The current window. | |
13424 * | |
13425 * ## Other resources | |
13426 * | |
13427 * * [Window.self] | |
13428 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.self) from MDN. | |
13429 */ | |
13430 @DomName('Window.self') | |
13431 @DocsEditable() | |
13432 WindowBase get self => _convertNativeToDart_Window(this._get_self); | |
13433 @JSName('self') | |
13434 /** | |
13435 * The current window. | |
13436 * | |
13437 * ## Other resources | |
13438 * | |
13439 * * [Window.self] | |
13440 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.self) from MDN. | |
13441 */ | |
13442 @DomName('Window.self') | |
13443 @DocsEditable() | |
13444 @Creates('Window|=Object') | |
13445 @Returns('Window|=Object') | |
13446 dynamic get _get_self => wrap_jso(JS("dynamic", "#.self", this.raw)); | |
13447 | |
13448 /// *Deprecated*. | |
13449 @DomName('Window.status') | |
13450 @DocsEditable() | |
13451 String get status => wrap_jso(JS("String", "#.status", this.raw)); | |
13452 /// *Deprecated*. | |
13453 @DomName('Window.status') | |
13454 @DocsEditable() | |
13455 void set status(String val) => JS("void", "#.status = #", this.raw, unwrap_jso
(val)); | |
13456 | |
13457 @DomName('Window.top') | |
13458 @DocsEditable() | |
13459 WindowBase get top => _convertNativeToDart_Window(this._get_top); | |
13460 @JSName('top') | |
13461 @DomName('Window.top') | |
13462 @DocsEditable() | |
13463 @Creates('Window|=Object') | |
13464 @Returns('Window|=Object') | |
13465 dynamic get _get_top => wrap_jso(JS("dynamic", "#.top", this.raw)); | |
13466 | |
13467 /** | |
13468 * The current window. | |
13469 * | |
13470 * ## Other resources | |
13471 * | |
13472 * * [Window.window] | |
13473 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.window) from MDN. | |
13474 */ | |
13475 @DomName('Window.window') | |
13476 @DocsEditable() | |
13477 WindowBase get window => _convertNativeToDart_Window(this._get_window); | |
13478 @JSName('window') | |
13479 /** | |
13480 * The current window. | |
13481 * | |
13482 * ## Other resources | |
13483 * | |
13484 * * [Window.window] | |
13485 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.window) from MDN. | |
13486 */ | |
13487 @DomName('Window.window') | |
13488 @DocsEditable() | |
13489 @Creates('Window|=Object') | |
13490 @Returns('Window|=Object') | |
13491 dynamic get _get_window => wrap_jso(JS("dynamic", "#.window", this.raw)); | |
13492 | |
13493 @DomName('Window.__getter__') | |
13494 @DocsEditable() | |
13495 @Creates('Window|=Object') | |
13496 @Returns('Window|=Object') | |
13497 WindowBase __getter__(index_OR_name) { | |
13498 if ((index_OR_name is int)) { | |
13499 return _convertNativeToDart_Window(__getter___1(index_OR_name)); | |
13500 } | |
13501 if ((index_OR_name is String)) { | |
13502 return _convertNativeToDart_Window(__getter___2(index_OR_name)); | |
13503 } | |
13504 throw new ArgumentError("Incorrect number or type of arguments"); | |
13505 } | |
13506 @JSName('__getter__') | |
13507 @DomName('Window.__getter__') | |
13508 @DocsEditable() | |
13509 @Creates('Window|=Object') | |
13510 @Returns('Window|=Object') | |
13511 __getter___1(int index) => wrap_jso(JS("", "#.raw.__getter__(#)", this, unwrap
_jso(index))); | |
13512 @JSName('__getter__') | |
13513 @DomName('Window.__getter__') | |
13514 @DocsEditable() | |
13515 @Creates('Window|=Object') | |
13516 @Returns('Window|=Object') | |
13517 __getter___2(String name) => wrap_jso(JS("", "#.raw.__getter__(#)", this, unwr
ap_jso(name))); | |
13518 | |
13519 /** | |
13520 * Displays a modal alert to the user. | |
13521 * | |
13522 * ## Other resources | |
13523 * | |
13524 * * [User prompts] | |
13525 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#us
er-prompts) | |
13526 * from WHATWG. | |
13527 */ | |
13528 @DomName('Window.alert') | |
13529 @DocsEditable() | |
13530 void alert([String message]) { | |
13531 if (message != null) { | |
13532 _alert_1(message); | |
13533 return; | |
13534 } | |
13535 _alert_2(); | |
13536 return; | |
13537 } | |
13538 @JSName('alert') | |
13539 /** | |
13540 * Displays a modal alert to the user. | |
13541 * | |
13542 * ## Other resources | |
13543 * | |
13544 * * [User prompts] | |
13545 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#us
er-prompts) | |
13546 * from WHATWG. | |
13547 */ | |
13548 @DomName('Window.alert') | |
13549 @DocsEditable() | |
13550 void _alert_1(message) => wrap_jso(JS("void ", "#.raw.alert(#)", this, unwrap_
jso(message))); | |
13551 @JSName('alert') | |
13552 /** | |
13553 * Displays a modal alert to the user. | |
13554 * | |
13555 * ## Other resources | |
13556 * | |
13557 * * [User prompts] | |
13558 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#us
er-prompts) | |
13559 * from WHATWG. | |
13560 */ | |
13561 @DomName('Window.alert') | |
13562 @DocsEditable() | |
13563 void _alert_2() => wrap_jso(JS("void ", "#.raw.alert()", this)); | |
13564 | |
13565 @DomName('Window.close') | |
13566 @DocsEditable() | |
13567 void close() { | |
13568 _close_1(); | |
13569 return; | |
13570 } | |
13571 @JSName('close') | |
13572 @DomName('Window.close') | |
13573 @DocsEditable() | |
13574 void _close_1() => wrap_jso(JS("void ", "#.raw.close()", this)); | |
13575 | |
13576 /** | |
13577 * Displays a modal OK/Cancel prompt to the user. | |
13578 * | |
13579 * ## Other resources | |
13580 * | |
13581 * * [User prompts] | |
13582 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#us
er-prompts) | |
13583 * from WHATWG. | |
13584 */ | |
13585 @DomName('Window.confirm') | |
13586 @DocsEditable() | |
13587 bool confirm([String message]) { | |
13588 if (message != null) { | |
13589 return _confirm_1(message); | |
13590 } | |
13591 return _confirm_2(); | |
13592 } | |
13593 @JSName('confirm') | |
13594 /** | |
13595 * Displays a modal OK/Cancel prompt to the user. | |
13596 * | |
13597 * ## Other resources | |
13598 * | |
13599 * * [User prompts] | |
13600 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#us
er-prompts) | |
13601 * from WHATWG. | |
13602 */ | |
13603 @DomName('Window.confirm') | |
13604 @DocsEditable() | |
13605 bool _confirm_1(message) => wrap_jso(JS("bool ", "#.raw.confirm(#)", this, unw
rap_jso(message))); | |
13606 @JSName('confirm') | |
13607 /** | |
13608 * Displays a modal OK/Cancel prompt to the user. | |
13609 * | |
13610 * ## Other resources | |
13611 * | |
13612 * * [User prompts] | |
13613 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#us
er-prompts) | |
13614 * from WHATWG. | |
13615 */ | |
13616 @DomName('Window.confirm') | |
13617 @DocsEditable() | |
13618 bool _confirm_2() => wrap_jso(JS("bool ", "#.raw.confirm()", this)); | |
13619 | |
13620 /** | |
13621 * Finds text in this window. | |
13622 * | |
13623 * ## Other resources | |
13624 * | |
13625 * * [Window.find] | |
13626 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.find) from MDN. | |
13627 */ | |
13628 @DomName('Window.find') | |
13629 @DocsEditable() | |
13630 @Experimental() // non-standard | |
13631 bool find(String string, bool caseSensitive, bool backwards, bool wrap, bool w
holeWord, bool searchInFrames, bool showDialog) { | |
13632 return _find_1(string, caseSensitive, backwards, wrap, wholeWord, searchInFr
ames, showDialog); | |
13633 } | |
13634 @JSName('find') | |
13635 /** | |
13636 * Finds text in this window. | |
13637 * | |
13638 * ## Other resources | |
13639 * | |
13640 * * [Window.find] | |
13641 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.find) from MDN. | |
13642 */ | |
13643 @DomName('Window.find') | |
13644 @DocsEditable() | |
13645 @Experimental() // non-standard | |
13646 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)
)); | |
13647 | |
13648 @DomName('Window.getComputedStyle') | |
13649 @DocsEditable() | |
13650 CssStyleDeclaration _getComputedStyle(Element element, String pseudoElement) { | |
13651 return _getComputedStyle_1(element, pseudoElement); | |
13652 } | |
13653 @JSName('getComputedStyle') | |
13654 @DomName('Window.getComputedStyle') | |
13655 @DocsEditable() | |
13656 CssStyleDeclaration _getComputedStyle_1(Element element, pseudoElement) => wra
p_jso(JS("CssStyleDeclaration ", "#.raw.getComputedStyle(#, #)", this, unwrap_js
o(element), unwrap_jso(pseudoElement))); | |
13657 | |
13658 /** | |
13659 * Moves this window. | |
13660 * | |
13661 * x and y can be negative. | |
13662 * | |
13663 * ## Other resources | |
13664 * | |
13665 * * [Window.moveBy] | |
13666 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.moveBy) from MDN. | |
13667 * * [Window.moveBy] | |
13668 * (http://dev.w3.org/csswg/cssom-view/#dom-window-moveby) from W3C. | |
13669 */ | |
13670 @DomName('Window.moveBy') | |
13671 @DocsEditable() | |
13672 void moveBy(num x, num y) { | |
13673 _moveBy_1(x, y); | |
13674 return; | |
13675 } | |
13676 @JSName('moveBy') | |
13677 /** | |
13678 * Moves this window. | |
13679 * | |
13680 * x and y can be negative. | |
13681 * | |
13682 * ## Other resources | |
13683 * | |
13684 * * [Window.moveBy] | |
13685 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.moveBy) from MDN. | |
13686 * * [Window.moveBy] | |
13687 * (http://dev.w3.org/csswg/cssom-view/#dom-window-moveby) from W3C. | |
13688 */ | |
13689 @DomName('Window.moveBy') | |
13690 @DocsEditable() | |
13691 void _moveBy_1(x, y) => wrap_jso(JS("void ", "#.raw.moveBy(#, #)", this, unwra
p_jso(x), unwrap_jso(y))); | |
13692 | |
13693 @DomName('Window.moveTo') | |
13694 @DocsEditable() | |
13695 void _moveTo(num x, num y) { | |
13696 _moveTo_1(x, y); | |
13697 return; | |
13698 } | |
13699 @JSName('moveTo') | |
13700 @DomName('Window.moveTo') | |
13701 @DocsEditable() | |
13702 void _moveTo_1(x, y) => wrap_jso(JS("void ", "#.raw.moveTo(#, #)", this, unwra
p_jso(x), unwrap_jso(y))); | |
13703 | |
13704 /** | |
13705 * Opens the print dialog for this window. | |
13706 * | |
13707 * ## Other resources | |
13708 * | |
13709 * * [Window.print] | |
13710 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.print) from MDN. | |
13711 */ | |
13712 @DomName('Window.print') | |
13713 @DocsEditable() | |
13714 void print() { | |
13715 _print_1(); | |
13716 return; | |
13717 } | |
13718 @JSName('print') | |
13719 /** | |
13720 * Opens the print dialog for this window. | |
13721 * | |
13722 * ## Other resources | |
13723 * | |
13724 * * [Window.print] | |
13725 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.print) from MDN. | |
13726 */ | |
13727 @DomName('Window.print') | |
13728 @DocsEditable() | |
13729 void _print_1() => wrap_jso(JS("void ", "#.raw.print()", this)); | |
13730 | |
13731 /** | |
13732 * Resizes this window by an offset. | |
13733 * | |
13734 * ## Other resources | |
13735 * | |
13736 * * [Window resizeBy] (http://docs.webplatform.org/wiki/dom/methods/resizeBy) | |
13737 * from WebPlatform.org. | |
13738 */ | |
13739 @DomName('Window.resizeBy') | |
13740 @DocsEditable() | |
13741 void resizeBy(num x, num y) { | |
13742 _resizeBy_1(x, y); | |
13743 return; | |
13744 } | |
13745 @JSName('resizeBy') | |
13746 /** | |
13747 * Resizes this window by an offset. | |
13748 * | |
13749 * ## Other resources | |
13750 * | |
13751 * * [Window resizeBy] (http://docs.webplatform.org/wiki/dom/methods/resizeBy) | |
13752 * from WebPlatform.org. | |
13753 */ | |
13754 @DomName('Window.resizeBy') | |
13755 @DocsEditable() | |
13756 void _resizeBy_1(x, y) => wrap_jso(JS("void ", "#.raw.resizeBy(#, #)", this, u
nwrap_jso(x), unwrap_jso(y))); | |
13757 | |
13758 /** | |
13759 * Resizes this window to a specific width and height. | |
13760 * | |
13761 * ## Other resources | |
13762 * | |
13763 * * [Window resizeTo] (http://docs.webplatform.org/wiki/dom/methods/resizeTo) | |
13764 * from WebPlatform.org. | |
13765 */ | |
13766 @DomName('Window.resizeTo') | |
13767 @DocsEditable() | |
13768 void resizeTo(num width, num height) { | |
13769 _resizeTo_1(width, height); | |
13770 return; | |
13771 } | |
13772 @JSName('resizeTo') | |
13773 /** | |
13774 * Resizes this window to a specific width and height. | |
13775 * | |
13776 * ## Other resources | |
13777 * | |
13778 * * [Window resizeTo] (http://docs.webplatform.org/wiki/dom/methods/resizeTo) | |
13779 * from WebPlatform.org. | |
13780 */ | |
13781 @DomName('Window.resizeTo') | |
13782 @DocsEditable() | |
13783 void _resizeTo_1(width, height) => wrap_jso(JS("void ", "#.raw.resizeTo(#, #)"
, this, unwrap_jso(width), unwrap_jso(height))); | |
13784 | |
13785 /** | |
13786 * Scrolls the page horizontally and vertically to a specific point. | |
13787 * | |
13788 * This method is identical to [scrollTo]. | |
13789 * | |
13790 * ## Other resources | |
13791 * | |
13792 * * [Window scroll] (http://docs.webplatform.org/wiki/dom/methods/scroll) | |
13793 * from WebPlatform.org. | |
13794 */ | |
13795 @DomName('Window.scroll') | |
13796 @DocsEditable() | |
13797 void scroll(x, y, [Map scrollOptions]) { | |
13798 if ((y is num) && (x is num) && scrollOptions == null) { | |
13799 _scroll_1(x, y); | |
13800 return; | |
13801 } | |
13802 if (scrollOptions != null && (y is num) && (x is num)) { | |
13803 var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions); | |
13804 _scroll_2(x, y, scrollOptions_1); | |
13805 return; | |
13806 } | |
13807 if ((y is int) && (x is int) && scrollOptions == null) { | |
13808 _scroll_3(x, y); | |
13809 return; | |
13810 } | |
13811 if (scrollOptions != null && (y is int) && (x is int)) { | |
13812 var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions); | |
13813 _scroll_4(x, y, scrollOptions_1); | |
13814 return; | |
13815 } | |
13816 throw new ArgumentError("Incorrect number or type of arguments"); | |
13817 } | |
13818 @JSName('scroll') | |
13819 /** | |
13820 * Scrolls the page horizontally and vertically to a specific point. | |
13821 * | |
13822 * This method is identical to [scrollTo]. | |
13823 * | |
13824 * ## Other resources | |
13825 * | |
13826 * * [Window scroll] (http://docs.webplatform.org/wiki/dom/methods/scroll) | |
13827 * from WebPlatform.org. | |
13828 */ | |
13829 @DomName('Window.scroll') | |
13830 @DocsEditable() | |
13831 void _scroll_1(num x, num y) => wrap_jso(JS("void ", "#.raw.scroll(#, #)", thi
s, unwrap_jso(x), unwrap_jso(y))); | |
13832 @JSName('scroll') | |
13833 /** | |
13834 * Scrolls the page horizontally and vertically to a specific point. | |
13835 * | |
13836 * This method is identical to [scrollTo]. | |
13837 * | |
13838 * ## Other resources | |
13839 * | |
13840 * * [Window scroll] (http://docs.webplatform.org/wiki/dom/methods/scroll) | |
13841 * from WebPlatform.org. | |
13842 */ | |
13843 @DomName('Window.scroll') | |
13844 @DocsEditable() | |
13845 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))); | |
13846 @JSName('scroll') | |
13847 /** | |
13848 * Scrolls the page horizontally and vertically to a specific point. | |
13849 * | |
13850 * This method is identical to [scrollTo]. | |
13851 * | |
13852 * ## Other resources | |
13853 * | |
13854 * * [Window scroll] (http://docs.webplatform.org/wiki/dom/methods/scroll) | |
13855 * from WebPlatform.org. | |
13856 */ | |
13857 @DomName('Window.scroll') | |
13858 @DocsEditable() | |
13859 void _scroll_3(int x, int y) => wrap_jso(JS("void ", "#.raw.scroll(#, #)", thi
s, unwrap_jso(x), unwrap_jso(y))); | |
13860 @JSName('scroll') | |
13861 /** | |
13862 * Scrolls the page horizontally and vertically to a specific point. | |
13863 * | |
13864 * This method is identical to [scrollTo]. | |
13865 * | |
13866 * ## Other resources | |
13867 * | |
13868 * * [Window scroll] (http://docs.webplatform.org/wiki/dom/methods/scroll) | |
13869 * from WebPlatform.org. | |
13870 */ | |
13871 @DomName('Window.scroll') | |
13872 @DocsEditable() | |
13873 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))); | |
13874 | |
13875 /** | |
13876 * Scrolls the page horizontally and vertically by an offset. | |
13877 * | |
13878 * ## Other resources | |
13879 * | |
13880 * * [Window scrollBy] (http://docs.webplatform.org/wiki/dom/methods/scrollBy) | |
13881 * from WebPlatform.org. | |
13882 */ | |
13883 @DomName('Window.scrollBy') | |
13884 @DocsEditable() | |
13885 void scrollBy(x, y, [Map scrollOptions]) { | |
13886 if ((y is num) && (x is num) && scrollOptions == null) { | |
13887 _scrollBy_1(x, y); | |
13888 return; | |
13889 } | |
13890 if (scrollOptions != null && (y is num) && (x is num)) { | |
13891 var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions); | |
13892 _scrollBy_2(x, y, scrollOptions_1); | |
13893 return; | |
13894 } | |
13895 if ((y is int) && (x is int) && scrollOptions == null) { | |
13896 _scrollBy_3(x, y); | |
13897 return; | |
13898 } | |
13899 if (scrollOptions != null && (y is int) && (x is int)) { | |
13900 var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions); | |
13901 _scrollBy_4(x, y, scrollOptions_1); | |
13902 return; | |
13903 } | |
13904 throw new ArgumentError("Incorrect number or type of arguments"); | |
13905 } | |
13906 @JSName('scrollBy') | |
13907 /** | |
13908 * Scrolls the page horizontally and vertically by an offset. | |
13909 * | |
13910 * ## Other resources | |
13911 * | |
13912 * * [Window scrollBy] (http://docs.webplatform.org/wiki/dom/methods/scrollBy) | |
13913 * from WebPlatform.org. | |
13914 */ | |
13915 @DomName('Window.scrollBy') | |
13916 @DocsEditable() | |
13917 void _scrollBy_1(num x, num y) => wrap_jso(JS("void ", "#.raw.scrollBy(#, #)",
this, unwrap_jso(x), unwrap_jso(y))); | |
13918 @JSName('scrollBy') | |
13919 /** | |
13920 * Scrolls the page horizontally and vertically by an offset. | |
13921 * | |
13922 * ## Other resources | |
13923 * | |
13924 * * [Window scrollBy] (http://docs.webplatform.org/wiki/dom/methods/scrollBy) | |
13925 * from WebPlatform.org. | |
13926 */ | |
13927 @DomName('Window.scrollBy') | |
13928 @DocsEditable() | |
13929 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)
)); | |
13930 @JSName('scrollBy') | |
13931 /** | |
13932 * Scrolls the page horizontally and vertically by an offset. | |
13933 * | |
13934 * ## Other resources | |
13935 * | |
13936 * * [Window scrollBy] (http://docs.webplatform.org/wiki/dom/methods/scrollBy) | |
13937 * from WebPlatform.org. | |
13938 */ | |
13939 @DomName('Window.scrollBy') | |
13940 @DocsEditable() | |
13941 void _scrollBy_3(int x, int y) => wrap_jso(JS("void ", "#.raw.scrollBy(#, #)",
this, unwrap_jso(x), unwrap_jso(y))); | |
13942 @JSName('scrollBy') | |
13943 /** | |
13944 * Scrolls the page horizontally and vertically by an offset. | |
13945 * | |
13946 * ## Other resources | |
13947 * | |
13948 * * [Window scrollBy] (http://docs.webplatform.org/wiki/dom/methods/scrollBy) | |
13949 * from WebPlatform.org. | |
13950 */ | |
13951 @DomName('Window.scrollBy') | |
13952 @DocsEditable() | |
13953 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)
)); | |
13954 | |
13955 /** | |
13956 * Scrolls the page horizontally and vertically to a specific point. | |
13957 * | |
13958 * This method is identical to [scroll]. | |
13959 * | |
13960 * ## Other resources | |
13961 * | |
13962 * * [Window scrollTo] (http://docs.webplatform.org/wiki/dom/methods/scrollTo) | |
13963 * from WebPlatform.org. | |
13964 */ | |
13965 @DomName('Window.scrollTo') | |
13966 @DocsEditable() | |
13967 void scrollTo(x, y, [Map scrollOptions]) { | |
13968 if ((y is num) && (x is num) && scrollOptions == null) { | |
13969 _scrollTo_1(x, y); | |
13970 return; | |
13971 } | |
13972 if (scrollOptions != null && (y is num) && (x is num)) { | |
13973 var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions); | |
13974 _scrollTo_2(x, y, scrollOptions_1); | |
13975 return; | |
13976 } | |
13977 if ((y is int) && (x is int) && scrollOptions == null) { | |
13978 _scrollTo_3(x, y); | |
13979 return; | |
13980 } | |
13981 if (scrollOptions != null && (y is int) && (x is int)) { | |
13982 var scrollOptions_1 = convertDartToNative_Dictionary(scrollOptions); | |
13983 _scrollTo_4(x, y, scrollOptions_1); | |
13984 return; | |
13985 } | |
13986 throw new ArgumentError("Incorrect number or type of arguments"); | |
13987 } | |
13988 @JSName('scrollTo') | |
13989 /** | |
13990 * Scrolls the page horizontally and vertically to a specific point. | |
13991 * | |
13992 * This method is identical to [scroll]. | |
13993 * | |
13994 * ## Other resources | |
13995 * | |
13996 * * [Window scrollTo] (http://docs.webplatform.org/wiki/dom/methods/scrollTo) | |
13997 * from WebPlatform.org. | |
13998 */ | |
13999 @DomName('Window.scrollTo') | |
14000 @DocsEditable() | |
14001 void _scrollTo_1(num x, num y) => wrap_jso(JS("void ", "#.raw.scrollTo(#, #)",
this, unwrap_jso(x), unwrap_jso(y))); | |
14002 @JSName('scrollTo') | |
14003 /** | |
14004 * Scrolls the page horizontally and vertically to a specific point. | |
14005 * | |
14006 * This method is identical to [scroll]. | |
14007 * | |
14008 * ## Other resources | |
14009 * | |
14010 * * [Window scrollTo] (http://docs.webplatform.org/wiki/dom/methods/scrollTo) | |
14011 * from WebPlatform.org. | |
14012 */ | |
14013 @DomName('Window.scrollTo') | |
14014 @DocsEditable() | |
14015 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)
)); | |
14016 @JSName('scrollTo') | |
14017 /** | |
14018 * Scrolls the page horizontally and vertically to a specific point. | |
14019 * | |
14020 * This method is identical to [scroll]. | |
14021 * | |
14022 * ## Other resources | |
14023 * | |
14024 * * [Window scrollTo] (http://docs.webplatform.org/wiki/dom/methods/scrollTo) | |
14025 * from WebPlatform.org. | |
14026 */ | |
14027 @DomName('Window.scrollTo') | |
14028 @DocsEditable() | |
14029 void _scrollTo_3(int x, int y) => wrap_jso(JS("void ", "#.raw.scrollTo(#, #)",
this, unwrap_jso(x), unwrap_jso(y))); | |
14030 @JSName('scrollTo') | |
14031 /** | |
14032 * Scrolls the page horizontally and vertically to a specific point. | |
14033 * | |
14034 * This method is identical to [scroll]. | |
14035 * | |
14036 * ## Other resources | |
14037 * | |
14038 * * [Window scrollTo] (http://docs.webplatform.org/wiki/dom/methods/scrollTo) | |
14039 * from WebPlatform.org. | |
14040 */ | |
14041 @DomName('Window.scrollTo') | |
14042 @DocsEditable() | |
14043 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)
)); | |
14044 | |
14045 /** | |
14046 * Opens a new page as a modal dialog. | |
14047 * | |
14048 * ## Other resources | |
14049 * | |
14050 * * [Dialogs implemented using separate documents] | |
14051 * (http://www.w3.org/html/wg/drafts/html/master/webappapis.html#dialogs-imple
mented-using-separate-documents) | |
14052 * from W3C. | |
14053 */ | |
14054 @DomName('Window.showModalDialog') | |
14055 @DocsEditable() | |
14056 @Creates('Null') | |
14057 Object showModalDialog(String url, [Object dialogArgs, String featureArgs]) { | |
14058 if (featureArgs != null) { | |
14059 return _showModalDialog_1(url, dialogArgs, featureArgs); | |
14060 } | |
14061 if (dialogArgs != null) { | |
14062 return _showModalDialog_2(url, dialogArgs); | |
14063 } | |
14064 return _showModalDialog_3(url); | |
14065 } | |
14066 @JSName('showModalDialog') | |
14067 /** | |
14068 * Opens a new page as a modal dialog. | |
14069 * | |
14070 * ## Other resources | |
14071 * | |
14072 * * [Dialogs implemented using separate documents] | |
14073 * (http://www.w3.org/html/wg/drafts/html/master/webappapis.html#dialogs-imple
mented-using-separate-documents) | |
14074 * from W3C. | |
14075 */ | |
14076 @DomName('Window.showModalDialog') | |
14077 @DocsEditable() | |
14078 @Creates('Null') | |
14079 Object _showModalDialog_1(url, dialogArgs, featureArgs) => wrap_jso(JS("Object
", "#.raw.showModalDialog(#, #, #)", this, unwrap_jso(url), unwrap_jso(dialogAr
gs), unwrap_jso(featureArgs))); | |
14080 @JSName('showModalDialog') | |
14081 /** | |
14082 * Opens a new page as a modal dialog. | |
14083 * | |
14084 * ## Other resources | |
14085 * | |
14086 * * [Dialogs implemented using separate documents] | |
14087 * (http://www.w3.org/html/wg/drafts/html/master/webappapis.html#dialogs-imple
mented-using-separate-documents) | |
14088 * from W3C. | |
14089 */ | |
14090 @DomName('Window.showModalDialog') | |
14091 @DocsEditable() | |
14092 @Creates('Null') | |
14093 Object _showModalDialog_2(url, dialogArgs) => wrap_jso(JS("Object ", "#.raw.sh
owModalDialog(#, #)", this, unwrap_jso(url), unwrap_jso(dialogArgs))); | |
14094 @JSName('showModalDialog') | |
14095 /** | |
14096 * Opens a new page as a modal dialog. | |
14097 * | |
14098 * ## Other resources | |
14099 * | |
14100 * * [Dialogs implemented using separate documents] | |
14101 * (http://www.w3.org/html/wg/drafts/html/master/webappapis.html#dialogs-imple
mented-using-separate-documents) | |
14102 * from W3C. | |
14103 */ | |
14104 @DomName('Window.showModalDialog') | |
14105 @DocsEditable() | |
14106 @Creates('Null') | |
14107 Object _showModalDialog_3(url) => wrap_jso(JS("Object ", "#.raw.showModalDialo
g(#)", this, unwrap_jso(url))); | |
14108 | |
14109 /** | |
14110 * Stops the window from loading. | |
14111 * | |
14112 * ## Other resources | |
14113 * | |
14114 * * [The Window object] | |
14115 * (http://www.w3.org/html/wg/drafts/html/master/browsers.html#the-window-obje
ct) | |
14116 * from W3C. | |
14117 */ | |
14118 @DomName('Window.stop') | |
14119 @DocsEditable() | |
14120 void stop() { | |
14121 _stop_1(); | |
14122 return; | |
14123 } | |
14124 @JSName('stop') | |
14125 /** | |
14126 * Stops the window from loading. | |
14127 * | |
14128 * ## Other resources | |
14129 * | |
14130 * * [The Window object] | |
14131 * (http://www.w3.org/html/wg/drafts/html/master/browsers.html#the-window-obje
ct) | |
14132 * from W3C. | |
14133 */ | |
14134 @DomName('Window.stop') | |
14135 @DocsEditable() | |
14136 void _stop_1() => wrap_jso(JS("void ", "#.raw.stop()", this)); | |
14137 | |
14138 /// Stream of `contentloaded` events handled by this [Window]. | |
14139 @DomName('Window.onDOMContentLoaded') | |
14140 @DocsEditable() | |
14141 Stream<Event> get onContentLoaded => contentLoadedEvent.forTarget(this); | |
14142 | |
14143 /// Stream of `search` events handled by this [Window]. | |
14144 @DomName('Window.onsearch') | |
14145 @DocsEditable() | |
14146 // http://www.w3.org/TR/html-markup/input.search.html | |
14147 @Experimental() | |
14148 Stream<Event> get onSearch => Element.searchEvent.forTarget(this); | |
14149 | |
14150 | |
14151 | |
14152 /** | |
14153 * Moves this window to a specific position. | |
14154 * | |
14155 * x and y can be negative. | |
14156 * | |
14157 * ## Other resources | |
14158 * | |
14159 * * [Window.moveTo] | |
14160 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.moveTo) from MDN. | |
14161 * * [Window.moveTo] | |
14162 * (http://dev.w3.org/csswg/cssom-view/#dom-window-moveto) from W3C. | |
14163 */ | |
14164 void moveTo(Point p) { | |
14165 _moveTo(p.x, p.y); | |
14166 } | |
14167 | |
14168 @DomName('Window.pageXOffset') | |
14169 @DocsEditable() | |
14170 int get pageXOffset => JS('num', '#.pageXOffset', this.raw).round(); | |
14171 | |
14172 @DomName('Window.pageYOffset') | |
14173 @DocsEditable() | |
14174 int get pageYOffset => JS('num', '#.pageYOffset', this.raw).round(); | |
14175 | |
14176 /** | |
14177 * The distance this window has been scrolled horizontally. | |
14178 * | |
14179 * ## Other resources | |
14180 * | |
14181 * * [The Screen interface specification] | |
14182 * (http://www.w3.org/TR/cssom-view/#screen) from W3C. | |
14183 * * [scrollX] | |
14184 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollX) from MDN. | |
14185 */ | |
14186 @DomName('Window.scrollX') | |
14187 @DocsEditable() | |
14188 int get scrollX => JS('bool', '("scrollX" in #)', this.raw) ? | |
14189 JS('num', '#.scrollX', this.raw).round() : | |
14190 document.documentElement.scrollLeft; | |
14191 | |
14192 /** | |
14193 * The distance this window has been scrolled vertically. | |
14194 * | |
14195 * ## Other resources | |
14196 * | |
14197 * * [The Screen interface specification] | |
14198 * (http://www.w3.org/TR/cssom-view/#screen) from W3C. | |
14199 * * [scrollY] | |
14200 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY) from MDN. | |
14201 */ | |
14202 @DomName('Window.scrollY') | |
14203 @DocsEditable() | |
14204 int get scrollY => JS('bool', '("scrollY" in #)', this.raw) ? | |
14205 JS('num', '#.scrollY', this.raw).round() : | |
14206 document.documentElement.scrollTop; | |
14207 | |
14208 void postMessage(var message, String targetOrigin, [List messagePorts]) { | |
14209 if (messagePorts != null) { | |
14210 throw 'postMessage unsupported'; | |
14211 } | |
14212 JS('void', '#.postMessage(#, #)', this.raw, message, targetOrigin); | |
14213 } | |
14214 } | |
14215 | |
14216 | |
14217 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
14218 // for details. All rights reserved. Use of this source code is governed by a | |
14219 // BSD-style license that can be found in the LICENSE file. | |
14220 | |
14221 | |
14222 @DocsEditable() | |
14223 @DomName('Attr') | |
14224 @Native("Attr") | |
14225 class _Attr extends Node { | |
14226 // To suppress missing implicit constructor warnings. | |
14227 factory _Attr._() { throw new UnsupportedError("Not supported"); } | |
14228 | |
14229 | |
14230 @Deprecated("Internal Use Only") | |
14231 static _Attr internalCreate_Attr() { | |
14232 return new _Attr.internal_(); | |
14233 } | |
14234 | |
14235 @Deprecated("Internal Use Only") | |
14236 _Attr.internal_() : super.internal_(); | |
14237 | |
14238 | |
14239 // Use implementation from Node. | |
14240 // final String _localName; | |
14241 | |
14242 @DomName('Attr.name') | |
14243 @DocsEditable() | |
14244 String get name => wrap_jso(JS("String", "#.name", this.raw)); | |
14245 | |
14246 // Use implementation from Node. | |
14247 // final String _namespaceUri; | |
14248 | |
14249 // Use implementation from Node. | |
14250 // final String nodeValue; | |
14251 | |
14252 // Shadowing definition. | |
14253 String get text => wrap_jso(JS("String", "#.raw.textContent", this)); | |
14254 | |
14255 set text(String value) { | |
14256 JS("void", "#.raw.textContent = #", this, unwrap_jso(value)); | |
14257 } | |
14258 | |
14259 @DomName('Attr.value') | |
14260 @DocsEditable() | |
14261 String get value => wrap_jso(JS("String", "#.value", this.raw)); | |
14262 @DomName('Attr.value') | |
14263 @DocsEditable() | |
14264 void set value(String val) => JS("void", "#.value = #", this.raw, unwrap_jso(v
al)); | |
14265 } | |
14266 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
14267 // for details. All rights reserved. Use of this source code is governed by a | |
14268 // BSD-style license that can be found in the LICENSE file. | |
14269 | |
14270 | |
14271 @DocsEditable() | |
14272 @DomName('ClientRect') | |
14273 @Native("ClientRect") | |
14274 class _ClientRect extends DartHtmlDomObject implements Rectangle { | |
14275 | |
14276 // NOTE! All code below should be common with RectangleBase. | |
14277 String toString() { | |
14278 return 'Rectangle ($left, $top) $width x $height'; | |
14279 } | |
14280 | |
14281 bool operator ==(other) { | |
14282 if (other is !Rectangle) return false; | |
14283 return left == other.left && top == other.top && width == other.width && | |
14284 height == other.height; | |
14285 } | |
14286 | |
14287 int get hashCode => _JenkinsSmiHash.hash4(left.hashCode, top.hashCode, | |
14288 width.hashCode, height.hashCode); | |
14289 | |
14290 /** | |
14291 * Computes the intersection of `this` and [other]. | |
14292 * | |
14293 * The intersection of two axis-aligned rectangles, if any, is always another | |
14294 * axis-aligned rectangle. | |
14295 * | |
14296 * Returns the intersection of this and `other`, or null if they don't | |
14297 * intersect. | |
14298 */ | |
14299 Rectangle intersection(Rectangle other) { | |
14300 var x0 = max(left, other.left); | |
14301 var x1 = min(left + width, other.left + other.width); | |
14302 | |
14303 if (x0 <= x1) { | |
14304 var y0 = max(top, other.top); | |
14305 var y1 = min(top + height, other.top + other.height); | |
14306 | |
14307 if (y0 <= y1) { | |
14308 return new Rectangle(x0, y0, x1 - x0, y1 - y0); | |
14309 } | |
14310 } | |
14311 return null; | |
14312 } | |
14313 | |
14314 | |
14315 /** | |
14316 * Returns true if `this` intersects [other]. | |
14317 */ | |
14318 bool intersects(Rectangle<num> other) { | |
14319 return (left <= other.left + other.width && | |
14320 other.left <= left + width && | |
14321 top <= other.top + other.height && | |
14322 other.top <= top + height); | |
14323 } | |
14324 | |
14325 /** | |
14326 * Returns a new rectangle which completely contains `this` and [other]. | |
14327 */ | |
14328 Rectangle boundingBox(Rectangle other) { | |
14329 var right = max(this.left + this.width, other.left + other.width); | |
14330 var bottom = max(this.top + this.height, other.top + other.height); | |
14331 | |
14332 var left = min(this.left, other.left); | |
14333 var top = min(this.top, other.top); | |
14334 | |
14335 return new Rectangle(left, top, right - left, bottom - top); | |
14336 } | |
14337 | |
14338 /** | |
14339 * Tests whether `this` entirely contains [another]. | |
14340 */ | |
14341 bool containsRectangle(Rectangle<num> another) { | |
14342 return left <= another.left && | |
14343 left + width >= another.left + another.width && | |
14344 top <= another.top && | |
14345 top + height >= another.top + another.height; | |
14346 } | |
14347 | |
14348 /** | |
14349 * Tests whether [another] is inside or along the edges of `this`. | |
14350 */ | |
14351 bool containsPoint(Point<num> another) { | |
14352 return another.x >= left && | |
14353 another.x <= left + width && | |
14354 another.y >= top && | |
14355 another.y <= top + height; | |
14356 } | |
14357 | |
14358 Point get topLeft => new Point(this.left, this.top); | |
14359 Point get topRight => new Point(this.left + this.width, this.top); | |
14360 Point get bottomRight => new Point(this.left + this.width, | |
14361 this.top + this.height); | |
14362 Point get bottomLeft => new Point(this.left, | |
14363 this.top + this.height); | |
14364 | |
14365 // To suppress missing implicit constructor warnings. | |
14366 factory _ClientRect._() { throw new UnsupportedError("Not supported"); } | |
14367 | |
14368 @Deprecated("Internal Use Only") | |
14369 static _ClientRect internalCreate_ClientRect() { | |
14370 return new _ClientRect.internal_(); | |
14371 } | |
14372 | |
14373 @Deprecated("Internal Use Only") | |
14374 _ClientRect.internal_() { } | |
14375 | |
14376 | |
14377 @DomName('ClientRect.bottom') | |
14378 @DocsEditable() | |
14379 double get bottom => wrap_jso(JS("double", "#.bottom", this.raw)); | |
14380 | |
14381 @DomName('ClientRect.height') | |
14382 @DocsEditable() | |
14383 double get height => wrap_jso(JS("double", "#.height", this.raw)); | |
14384 | |
14385 @DomName('ClientRect.left') | |
14386 @DocsEditable() | |
14387 double get left => wrap_jso(JS("double", "#.left", this.raw)); | |
14388 | |
14389 @DomName('ClientRect.right') | |
14390 @DocsEditable() | |
14391 double get right => wrap_jso(JS("double", "#.right", this.raw)); | |
14392 | |
14393 @DomName('ClientRect.top') | |
14394 @DocsEditable() | |
14395 double get top => wrap_jso(JS("double", "#.top", this.raw)); | |
14396 | |
14397 @DomName('ClientRect.width') | |
14398 @DocsEditable() | |
14399 double get width => wrap_jso(JS("double", "#.width", this.raw)); | |
14400 } | |
14401 | |
14402 /** | |
14403 * This is the [Jenkins hash function][1] but using masking to keep | |
14404 * values in SMI range. | |
14405 * | |
14406 * [1]: http://en.wikipedia.org/wiki/Jenkins_hash_function | |
14407 * | |
14408 * Use: | |
14409 * Hash each value with the hash of the previous value, then get the final | |
14410 * hash by calling finish. | |
14411 * | |
14412 * var hash = 0; | |
14413 * for (var value in values) { | |
14414 * hash = JenkinsSmiHash.combine(hash, value.hashCode); | |
14415 * } | |
14416 * hash = JenkinsSmiHash.finish(hash); | |
14417 */ | |
14418 class _JenkinsSmiHash { | |
14419 // TODO(11617): This class should be optimized and standardized elsewhere. | |
14420 | |
14421 static int combine(int hash, int value) { | |
14422 hash = 0x1fffffff & (hash + value); | |
14423 hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); | |
14424 return hash ^ (hash >> 6); | |
14425 } | |
14426 | |
14427 static int finish(int hash) { | |
14428 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); | |
14429 hash = hash ^ (hash >> 11); | |
14430 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); | |
14431 } | |
14432 | |
14433 static int hash2(a, b) => finish(combine(combine(0, a), b)); | |
14434 | |
14435 static int hash4(a, b, c, d) => | |
14436 finish(combine(combine(combine(combine(0, a), b), c), d)); | |
14437 } | |
14438 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
14439 // for details. All rights reserved. Use of this source code is governed by a | |
14440 // BSD-style license that can be found in the LICENSE file. | |
14441 | |
14442 | |
14443 @DocsEditable() | |
14444 @DomName('NamedNodeMap') | |
14445 // http://dom.spec.whatwg.org/#namednodemap | |
14446 @deprecated // deprecated | |
14447 @Native("NamedNodeMap,MozNamedAttrMap") | |
14448 class _NamedNodeMap extends DartHtmlDomObject with ListMixin<Node>, ImmutableLis
tMixin<Node> implements JavaScriptIndexingBehavior, List<Node> { | |
14449 // To suppress missing implicit constructor warnings. | |
14450 factory _NamedNodeMap._() { throw new UnsupportedError("Not supported"); } | |
14451 | |
14452 @Deprecated("Internal Use Only") | |
14453 static _NamedNodeMap internalCreate_NamedNodeMap() { | |
14454 return new _NamedNodeMap.internal_(); | |
14455 } | |
14456 | |
14457 @Deprecated("Internal Use Only") | |
14458 _NamedNodeMap.internal_() { } | |
14459 | |
14460 bool operator ==(other) => unwrap_jso(other) == unwrap_jso(this) || identical(
this, other); | |
14461 int get hashCode => unwrap_jso(this).hashCode; | |
14462 | |
14463 @DomName('NamedNodeMap.length') | |
14464 @DocsEditable() | |
14465 int get length => wrap_jso(JS("int", "#.length", this.raw)); | |
14466 | |
14467 Node operator[](int index) { | |
14468 if (JS("bool", "# >>> 0 !== # || # >= #", index, | |
14469 index, index, length)) | |
14470 throw new RangeError.index(index, this); | |
14471 return wrap_jso(JS("Node", "#[#]", this.raw, index)); | |
14472 } | |
14473 void operator[]=(int index, Node value) { | |
14474 throw new UnsupportedError("Cannot assign element of immutable List."); | |
14475 } | |
14476 // -- start List<Node> mixins. | |
14477 // Node is the element type. | |
14478 | |
14479 | |
14480 set length(int value) { | |
14481 throw new UnsupportedError("Cannot resize immutable List."); | |
14482 } | |
14483 | |
14484 Node get first { | |
14485 if (this.length > 0) { | |
14486 return wrap_jso(JS('Node', '#[0]', this.raw)); | |
14487 } | |
14488 throw new StateError("No elements"); | |
14489 } | |
14490 | |
14491 Node get last { | |
14492 int len = this.length; | |
14493 if (len > 0) { | |
14494 return wrap_jso(JS('Node', '#[#]', this.raw, len - 1)); | |
14495 } | |
14496 throw new StateError("No elements"); | |
14497 } | |
14498 | |
14499 Node get single { | |
14500 int len = this.length; | |
14501 if (len == 1) { | |
14502 return wrap_jso(JS('Node', '#[0]', this.raw)); | |
14503 } | |
14504 if (len == 0) throw new StateError("No elements"); | |
14505 throw new StateError("More than one element"); | |
14506 } | |
14507 | |
14508 Node elementAt(int index) => this[index]; | |
14509 // -- end List<Node> mixins. | |
14510 | |
14511 @DomName('NamedNodeMap.__getter__') | |
14512 @DocsEditable() | |
14513 Node __getter__(String name) { | |
14514 return __getter___1(name); | |
14515 } | |
14516 @JSName('__getter__') | |
14517 @DomName('NamedNodeMap.__getter__') | |
14518 @DocsEditable() | |
14519 Node __getter___1(name) => wrap_jso(JS("Node ", "#.raw.__getter__(#)", this, u
nwrap_jso(name))); | |
14520 | |
14521 @DomName('NamedNodeMap.getNamedItem') | |
14522 @DocsEditable() | |
14523 Node getNamedItem(String name) { | |
14524 return _getNamedItem_1(name); | |
14525 } | |
14526 @JSName('getNamedItem') | |
14527 @DomName('NamedNodeMap.getNamedItem') | |
14528 @DocsEditable() | |
14529 Node _getNamedItem_1(name) => wrap_jso(JS("Node ", "#.raw.getNamedItem(#)", th
is, unwrap_jso(name))); | |
14530 | |
14531 @DomName('NamedNodeMap.getNamedItemNS') | |
14532 @DocsEditable() | |
14533 Node getNamedItemNS(String namespaceURI, String localName) { | |
14534 return _getNamedItemNS_1(namespaceURI, localName); | |
14535 } | |
14536 @JSName('getNamedItemNS') | |
14537 @DomName('NamedNodeMap.getNamedItemNS') | |
14538 @DocsEditable() | |
14539 Node _getNamedItemNS_1(namespaceURI, localName) => wrap_jso(JS("Node ", "#.raw
.getNamedItemNS(#, #)", this, unwrap_jso(namespaceURI), unwrap_jso(localName))); | |
14540 | |
14541 @DomName('NamedNodeMap.item') | |
14542 @DocsEditable() | |
14543 Node item(int index) { | |
14544 return _item_1(index); | |
14545 } | |
14546 @JSName('item') | |
14547 @DomName('NamedNodeMap.item') | |
14548 @DocsEditable() | |
14549 Node _item_1(index) => wrap_jso(JS("Node ", "#.raw.item(#)", this, unwrap_jso(
index))); | |
14550 | |
14551 @DomName('NamedNodeMap.removeNamedItem') | |
14552 @DocsEditable() | |
14553 Node removeNamedItem(String name) { | |
14554 return _removeNamedItem_1(name); | |
14555 } | |
14556 @JSName('removeNamedItem') | |
14557 @DomName('NamedNodeMap.removeNamedItem') | |
14558 @DocsEditable() | |
14559 Node _removeNamedItem_1(name) => wrap_jso(JS("Node ", "#.raw.removeNamedItem(#
)", this, unwrap_jso(name))); | |
14560 | |
14561 @DomName('NamedNodeMap.removeNamedItemNS') | |
14562 @DocsEditable() | |
14563 Node removeNamedItemNS(String namespaceURI, String localName) { | |
14564 return _removeNamedItemNS_1(namespaceURI, localName); | |
14565 } | |
14566 @JSName('removeNamedItemNS') | |
14567 @DomName('NamedNodeMap.removeNamedItemNS') | |
14568 @DocsEditable() | |
14569 Node _removeNamedItemNS_1(namespaceURI, localName) => wrap_jso(JS("Node ", "#.
raw.removeNamedItemNS(#, #)", this, unwrap_jso(namespaceURI), unwrap_jso(localNa
me))); | |
14570 | |
14571 @DomName('NamedNodeMap.setNamedItem') | |
14572 @DocsEditable() | |
14573 Node setNamedItem(Node node) { | |
14574 return _setNamedItem_1(node); | |
14575 } | |
14576 @JSName('setNamedItem') | |
14577 @DomName('NamedNodeMap.setNamedItem') | |
14578 @DocsEditable() | |
14579 Node _setNamedItem_1(Node node) => wrap_jso(JS("Node ", "#.raw.setNamedItem(#)
", this, unwrap_jso(node))); | |
14580 | |
14581 @DomName('NamedNodeMap.setNamedItemNS') | |
14582 @DocsEditable() | |
14583 Node setNamedItemNS(Node node) { | |
14584 return _setNamedItemNS_1(node); | |
14585 } | |
14586 @JSName('setNamedItemNS') | |
14587 @DomName('NamedNodeMap.setNamedItemNS') | |
14588 @DocsEditable() | |
14589 Node _setNamedItemNS_1(Node node) => wrap_jso(JS("Node ", "#.raw.setNamedItemN
S(#)", this, unwrap_jso(node))); | |
14590 } | |
14591 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
14592 // for details. All rights reserved. Use of this source code is governed by a | |
14593 // BSD-style license that can be found in the LICENSE file. | |
14594 | |
14595 | |
14596 @DocsEditable() | |
14597 @DomName('XMLHttpRequestProgressEvent') | |
14598 @Experimental() // nonstandard | |
14599 @Native("XMLHttpRequestProgressEvent") | |
14600 class _XMLHttpRequestProgressEvent extends ProgressEvent { | |
14601 // To suppress missing implicit constructor warnings. | |
14602 factory _XMLHttpRequestProgressEvent._() { throw new UnsupportedError("Not sup
ported"); } | |
14603 | |
14604 | |
14605 @Deprecated("Internal Use Only") | |
14606 static _XMLHttpRequestProgressEvent internalCreate_XMLHttpRequestProgressEvent
() { | |
14607 return new _XMLHttpRequestProgressEvent.internal_(); | |
14608 } | |
14609 | |
14610 @Deprecated("Internal Use Only") | |
14611 _XMLHttpRequestProgressEvent.internal_() : super.internal_(); | |
14612 | |
14613 } | |
14614 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
14615 // for details. All rights reserved. Use of this source code is governed by a | |
14616 // BSD-style license that can be found in the LICENSE file. | |
14617 | |
14618 | |
14619 abstract class _AttributeMap implements Map<String, String> { | |
14620 final Element _element; | |
14621 | |
14622 _AttributeMap(this._element); | |
14623 | |
14624 void addAll(Map<String, String> other) { | |
14625 other.forEach((k, v) { this[k] = v; }); | |
14626 } | |
14627 | |
14628 bool containsValue(Object value) { | |
14629 for (var v in this.values) { | |
14630 if (value == v) { | |
14631 return true; | |
14632 } | |
14633 } | |
14634 return false; | |
14635 } | |
14636 | |
14637 String putIfAbsent(String key, String ifAbsent()) { | |
14638 if (!containsKey(key)) { | |
14639 this[key] = ifAbsent(); | |
14640 } | |
14641 return this[key]; | |
14642 } | |
14643 | |
14644 void clear() { | |
14645 for (var key in keys) { | |
14646 remove(key); | |
14647 } | |
14648 } | |
14649 | |
14650 void forEach(void f(String key, String value)) { | |
14651 for (var key in keys) { | |
14652 var value = this[key]; | |
14653 f(key, value); | |
14654 } | |
14655 } | |
14656 | |
14657 Iterable<String> get keys { | |
14658 // TODO: generate a lazy collection instead. | |
14659 var attributes = _element._attributes; | |
14660 var keys = new List<String>(); | |
14661 for (int i = 0, len = attributes.length; i < len; i++) { | |
14662 if (_matches(attributes[i])) { | |
14663 keys.add(attributes[i].name); | |
14664 } | |
14665 } | |
14666 return keys; | |
14667 } | |
14668 | |
14669 Iterable<String> get values { | |
14670 // TODO: generate a lazy collection instead. | |
14671 var attributes = _element._attributes; | |
14672 var values = new List<String>(); | |
14673 for (int i = 0, len = attributes.length; i < len; i++) { | |
14674 if (_matches(attributes[i])) { | |
14675 values.add(attributes[i].value); | |
14676 } | |
14677 } | |
14678 return values; | |
14679 } | |
14680 | |
14681 /** | |
14682 * Returns true if there is no {key, value} pair in the map. | |
14683 */ | |
14684 bool get isEmpty { | |
14685 return length == 0; | |
14686 } | |
14687 | |
14688 /** | |
14689 * Returns true if there is at least one {key, value} pair in the map. | |
14690 */ | |
14691 bool get isNotEmpty => !isEmpty; | |
14692 | |
14693 /** | |
14694 * Checks to see if the node should be included in this map. | |
14695 */ | |
14696 bool _matches(Node node); | |
14697 } | |
14698 | |
14699 /** | |
14700 * Wrapper to expose [Element.attributes] as a typed map. | |
14701 */ | |
14702 class _ElementAttributeMap extends _AttributeMap { | |
14703 | |
14704 _ElementAttributeMap(Element element): super(element); | |
14705 | |
14706 bool containsKey(Object key) { | |
14707 return _element._hasAttribute(key); | |
14708 } | |
14709 | |
14710 String operator [](Object key) { | |
14711 return _element.getAttribute(key); | |
14712 } | |
14713 | |
14714 void operator []=(String key, String value) { | |
14715 _element.setAttribute(key, value); | |
14716 } | |
14717 | |
14718 String remove(Object key) { | |
14719 String value = _element.getAttribute(key); | |
14720 _element._removeAttribute(key); | |
14721 return value; | |
14722 } | |
14723 | |
14724 /** | |
14725 * The number of {key, value} pairs in the map. | |
14726 */ | |
14727 int get length { | |
14728 return keys.length; | |
14729 } | |
14730 | |
14731 bool _matches(Node node) => node._namespaceUri == null; | |
14732 } | |
14733 | |
14734 /** | |
14735 * Wrapper to expose namespaced attributes as a typed map. | |
14736 */ | |
14737 class _NamespacedAttributeMap extends _AttributeMap { | |
14738 | |
14739 final String _namespace; | |
14740 | |
14741 _NamespacedAttributeMap(Element element, this._namespace): super(element); | |
14742 | |
14743 bool containsKey(Object key) { | |
14744 return _element._hasAttributeNS(_namespace, key); | |
14745 } | |
14746 | |
14747 String operator [](Object key) { | |
14748 return _element.getAttributeNS(_namespace, key); | |
14749 } | |
14750 | |
14751 void operator []=(String key, String value) { | |
14752 _element.setAttributeNS(_namespace, key, value); | |
14753 } | |
14754 | |
14755 String remove(Object key) { | |
14756 String value = this[key]; | |
14757 _element._removeAttributeNS(_namespace, key); | |
14758 return value; | |
14759 } | |
14760 | |
14761 /** | |
14762 * The number of {key, value} pairs in the map. | |
14763 */ | |
14764 int get length { | |
14765 return keys.length; | |
14766 } | |
14767 | |
14768 bool _matches(Node node) => node._namespaceUri == _namespace; | |
14769 } | |
14770 | |
14771 | |
14772 /** | |
14773 * Provides a Map abstraction on top of data-* attributes, similar to the | |
14774 * dataSet in the old DOM. | |
14775 */ | |
14776 class _DataAttributeMap implements Map<String, String> { | |
14777 | |
14778 final Map<String, String> _attributes; | |
14779 | |
14780 _DataAttributeMap(this._attributes); | |
14781 | |
14782 // interface Map | |
14783 | |
14784 void addAll(Map<String, String> other) { | |
14785 other.forEach((k, v) { this[k] = v; }); | |
14786 } | |
14787 | |
14788 // TODO: Use lazy iterator when it is available on Map. | |
14789 bool containsValue(Object value) => values.any((v) => v == value); | |
14790 | |
14791 bool containsKey(Object key) => _attributes.containsKey(_attr(key)); | |
14792 | |
14793 String operator [](Object key) => _attributes[_attr(key)]; | |
14794 | |
14795 void operator []=(String key, String value) { | |
14796 _attributes[_attr(key)] = value; | |
14797 } | |
14798 | |
14799 String putIfAbsent(String key, String ifAbsent()) => | |
14800 _attributes.putIfAbsent(_attr(key), ifAbsent); | |
14801 | |
14802 String remove(Object key) => _attributes.remove(_attr(key)); | |
14803 | |
14804 void clear() { | |
14805 // Needs to operate on a snapshot since we are mutating the collection. | |
14806 for (String key in keys) { | |
14807 remove(key); | |
14808 } | |
14809 } | |
14810 | |
14811 void forEach(void f(String key, String value)) { | |
14812 _attributes.forEach((String key, String value) { | |
14813 if (_matches(key)) { | |
14814 f(_strip(key), value); | |
14815 } | |
14816 }); | |
14817 } | |
14818 | |
14819 Iterable<String> get keys { | |
14820 final keys = new List<String>(); | |
14821 _attributes.forEach((String key, String value) { | |
14822 if (_matches(key)) { | |
14823 keys.add(_strip(key)); | |
14824 } | |
14825 }); | |
14826 return keys; | |
14827 } | |
14828 | |
14829 Iterable<String> get values { | |
14830 final values = new List<String>(); | |
14831 _attributes.forEach((String key, String value) { | |
14832 if (_matches(key)) { | |
14833 values.add(value); | |
14834 } | |
14835 }); | |
14836 return values; | |
14837 } | |
14838 | |
14839 int get length => keys.length; | |
14840 | |
14841 // TODO: Use lazy iterator when it is available on Map. | |
14842 bool get isEmpty => length == 0; | |
14843 | |
14844 bool get isNotEmpty => !isEmpty; | |
14845 | |
14846 // Helpers. | |
14847 String _attr(String key) => 'data-${_toHyphenedName(key)}'; | |
14848 bool _matches(String key) => key.startsWith('data-'); | |
14849 String _strip(String key) => _toCamelCase(key.substring(5)); | |
14850 | |
14851 /** | |
14852 * Converts a string name with hyphens into an identifier, by removing hyphens | |
14853 * and capitalizing the following letter. Optionally [startUppercase] to | |
14854 * captialize the first letter. | |
14855 */ | |
14856 String _toCamelCase(String hyphenedName, {bool startUppercase: false}) { | |
14857 var segments = hyphenedName.split('-'); | |
14858 int start = startUppercase ? 0 : 1; | |
14859 for (int i = start; i < segments.length; i++) { | |
14860 var segment = segments[i]; | |
14861 if (segment.length > 0) { | |
14862 // Character between 'a'..'z' mapped to 'A'..'Z' | |
14863 segments[i] = '${segment[0].toUpperCase()}${segment.substring(1)}'; | |
14864 } | |
14865 } | |
14866 return segments.join(''); | |
14867 } | |
14868 | |
14869 /** Reverse of [toCamelCase]. */ | |
14870 String _toHyphenedName(String word) { | |
14871 var sb = new StringBuffer(); | |
14872 for (int i = 0; i < word.length; i++) { | |
14873 var lower = word[i].toLowerCase(); | |
14874 if (word[i] != lower && i > 0) sb.write('-'); | |
14875 sb.write(lower); | |
14876 } | |
14877 return sb.toString(); | |
14878 } | |
14879 } | |
14880 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
14881 // for details. All rights reserved. Use of this source code is governed by a | |
14882 // BSD-style license that can be found in the LICENSE file. | |
14883 | |
14884 | |
14885 /** | |
14886 * An object that can be drawn to a 2D canvas rendering context. | |
14887 * | |
14888 * The image drawn to the canvas depends on the type of this object: | |
14889 * | |
14890 * * If this object is an [ImageElement], then this element's image is | |
14891 * drawn to the canvas. If this element is an animated image, then this | |
14892 * element's poster frame is drawn. If this element has no poster frame, then | |
14893 * the first frame of animation is drawn. | |
14894 * | |
14895 * * If this object is a [VideoElement], then the frame at this element's curren
t | |
14896 * playback position is drawn to the canvas. | |
14897 * | |
14898 * * If this object is a [CanvasElement], then this element's bitmap is drawn to | |
14899 * the canvas. | |
14900 * | |
14901 * **Note:** Currently all versions of Internet Explorer do not support | |
14902 * drawing a video element to a canvas. You may also encounter problems drawing | |
14903 * a video to a canvas in Firefox if the source of the video is a data URL. | |
14904 * | |
14905 * ## See also | |
14906 * | |
14907 * * [CanvasRenderingContext2D.drawImage] | |
14908 * * [CanvasRenderingContext2D.drawImageToRect] | |
14909 * * [CanvasRenderingContext2D.drawImageScaled] | |
14910 * * [CanvasRenderingContext2D.drawImageScaledFromSource] | |
14911 * | |
14912 * ## Other resources | |
14913 * | |
14914 * * [Image sources for 2D rendering contexts] | |
14915 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-eleme
nt.html#image-sources-for-2d-rendering-contexts) | |
14916 * from WHATWG. | |
14917 * * [Drawing images] | |
14918 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-eleme
nt.html#dom-context-2d-drawimage) | |
14919 * from WHATWG. | |
14920 */ | |
14921 abstract class CanvasImageSource {} | |
14922 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
14923 // for details. All rights reserved. Use of this source code is governed by a | |
14924 // BSD-style license that can be found in the LICENSE file. | |
14925 | |
14926 | |
14927 /** | |
14928 * Top-level container for a browser tab or window. | |
14929 * | |
14930 * In a web browser, a [WindowBase] object represents any browser window. This | |
14931 * object contains the window's state and its relation to other | |
14932 * windows, such as which window opened this window. | |
14933 * | |
14934 * **Note:** This class represents any window, while [Window] is | |
14935 * used to access the properties and content of the current window or tab. | |
14936 * | |
14937 * ## See also | |
14938 * | |
14939 * * [Window] | |
14940 * | |
14941 * ## Other resources | |
14942 * | |
14943 * * [DOM Window](https://developer.mozilla.org/en-US/docs/DOM/window) from MDN. | |
14944 * * [Window](http://www.w3.org/TR/Window/) from the W3C. | |
14945 */ | |
14946 abstract class WindowBase implements EventTarget { | |
14947 // Fields. | |
14948 | |
14949 /** | |
14950 * The current location of this window. | |
14951 * | |
14952 * Location currentLocation = window.location; | |
14953 * print(currentLocation.href); // 'http://www.example.com:80/' | |
14954 */ | |
14955 LocationBase get location; | |
14956 | |
14957 /** | |
14958 * The current session history for this window. | |
14959 * | |
14960 * ## Other resources | |
14961 * | |
14962 * * [Session history and navigation specification] | |
14963 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html) | |
14964 * from WHATWG. | |
14965 */ | |
14966 HistoryBase get history; | |
14967 | |
14968 /** | |
14969 * Indicates whether this window has been closed. | |
14970 * | |
14971 * print(window.closed); // 'false' | |
14972 * window.close(); | |
14973 * print(window.closed); // 'true' | |
14974 */ | |
14975 bool get closed; | |
14976 | |
14977 /** | |
14978 * A reference to the window that opened this one. | |
14979 * | |
14980 * Window thisWindow = window; | |
14981 * WindowBase otherWindow = thisWindow.open('http://www.example.com/', 'fo
o'); | |
14982 * print(otherWindow.opener == thisWindow); // 'true' | |
14983 */ | |
14984 WindowBase get opener; | |
14985 | |
14986 /** | |
14987 * A reference to the parent of this window. | |
14988 * | |
14989 * If this [WindowBase] has no parent, [parent] will return a reference to | |
14990 * the [WindowBase] itself. | |
14991 * | |
14992 * IFrameElement myIFrame = new IFrameElement(); | |
14993 * window.document.body.elements.add(myIFrame); | |
14994 * print(myIframe.contentWindow.parent == window) // 'true' | |
14995 * | |
14996 * print(window.parent == window) // 'true' | |
14997 */ | |
14998 WindowBase get parent; | |
14999 | |
15000 /** | |
15001 * A reference to the topmost window in the window hierarchy. | |
15002 * | |
15003 * If this [WindowBase] is the topmost [WindowBase], [top] will return a | |
15004 * reference to the [WindowBase] itself. | |
15005 * | |
15006 * // Add an IFrame to the current window. | |
15007 * IFrameElement myIFrame = new IFrameElement(); | |
15008 * window.document.body.elements.add(myIFrame); | |
15009 * | |
15010 * // Add an IFrame inside of the other IFrame. | |
15011 * IFrameElement innerIFrame = new IFrameElement(); | |
15012 * myIFrame.elements.add(innerIFrame); | |
15013 * | |
15014 * print(myIframe.contentWindow.top == window) // 'true' | |
15015 * print(innerIFrame.contentWindow.top == window) // 'true' | |
15016 * | |
15017 * print(window.top == window) // 'true' | |
15018 */ | |
15019 WindowBase get top; | |
15020 | |
15021 // Methods. | |
15022 /** | |
15023 * Closes the window. | |
15024 * | |
15025 * This method should only succeed if the [WindowBase] object is | |
15026 * **script-closeable** and the window calling [close] is allowed to navigate | |
15027 * the window. | |
15028 * | |
15029 * A window is script-closeable if it is either a window | |
15030 * that was opened by another window, or if it is a window with only one | |
15031 * document in its history. | |
15032 * | |
15033 * A window might not be allowed to navigate, and therefore close, another | |
15034 * window due to browser security features. | |
15035 * | |
15036 * var other = window.open('http://www.example.com', 'foo'); | |
15037 * // Closes other window, as it is script-closeable. | |
15038 * other.close(); | |
15039 * print(other.closed()); // 'true' | |
15040 * | |
15041 * window.location('http://www.mysite.com', 'foo'); | |
15042 * // Does not close this window, as the history has changed. | |
15043 * window.close(); | |
15044 * print(window.closed()); // 'false' | |
15045 * | |
15046 * See also: | |
15047 * | |
15048 * * [Window close discussion](http://www.w3.org/TR/html5/browsers.html#dom-wi
ndow-close) from the W3C | |
15049 */ | |
15050 void close(); | |
15051 | |
15052 /** | |
15053 * Sends a cross-origin message. | |
15054 * | |
15055 * ## Other resources | |
15056 * | |
15057 * * [window.postMessage] | |
15058 * (https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage) from | |
15059 * MDN. | |
15060 * * [Cross-document messaging] | |
15061 * (http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.
html) | |
15062 * from WHATWG. | |
15063 */ | |
15064 void postMessage(var message, String targetOrigin, [List messagePorts]); | |
15065 } | |
15066 | |
15067 abstract class LocationBase { | |
15068 void set href(String val); | |
15069 } | |
15070 | |
15071 abstract class HistoryBase { | |
15072 void back(); | |
15073 void forward(); | |
15074 void go(int distance); | |
15075 } | |
15076 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
15077 // for details. All rights reserved. Use of this source code is governed by a | |
15078 // BSD-style license that can be found in the LICENSE file. | |
15079 | |
15080 | |
15081 /** A Set that stores the CSS class names for an element. */ | |
15082 abstract class CssClassSet implements Set<String> { | |
15083 | |
15084 /** | |
15085 * Adds the class [value] to the element if it is not on it, removes it if it | |
15086 * is. | |
15087 * | |
15088 * If [shouldAdd] is true, then we always add that [value] to the element. If | |
15089 * [shouldAdd] is false then we always remove [value] from the element. | |
15090 * | |
15091 * If this corresponds to one element, returns `true` if [value] is present | |
15092 * after the operation, and returns `false` if [value] is absent after the | |
15093 * operation. | |
15094 * | |
15095 * If this corresponds to many elements, `null` is always returned. | |
15096 * | |
15097 * [value] must be a valid 'token' representing a single class, i.e. a | |
15098 * non-empty string containing no whitespace. To toggle multiple classes, use | |
15099 * [toggleAll]. | |
15100 */ | |
15101 bool toggle(String value, [bool shouldAdd]); | |
15102 | |
15103 /** | |
15104 * Returns [:true:] if classes cannot be added or removed from this | |
15105 * [:CssClassSet:]. | |
15106 */ | |
15107 bool get frozen; | |
15108 | |
15109 /** | |
15110 * Determine if this element contains the class [value]. | |
15111 * | |
15112 * This is the Dart equivalent of jQuery's | |
15113 * [hasClass](http://api.jquery.com/hasClass/). | |
15114 * | |
15115 * [value] must be a valid 'token' representing a single class, i.e. a | |
15116 * non-empty string containing no whitespace. | |
15117 */ | |
15118 bool contains(Object value); | |
15119 | |
15120 /** | |
15121 * Add the class [value] to element. | |
15122 * | |
15123 * [add] and [addAll] are the Dart equivalent of jQuery's | |
15124 * [addClass](http://api.jquery.com/addClass/). | |
15125 * | |
15126 * If this CssClassSet corresponds to one element. Returns true if [value] was | |
15127 * added to the set, otherwise false. | |
15128 * | |
15129 * If this corresponds to many elements, `null` is always returned. | |
15130 * | |
15131 * [value] must be a valid 'token' representing a single class, i.e. a | |
15132 * non-empty string containing no whitespace. To add multiple classes use | |
15133 * [addAll]. | |
15134 */ | |
15135 bool add(String value); | |
15136 | |
15137 /** | |
15138 * Remove the class [value] from element, and return true on successful | |
15139 * removal. | |
15140 * | |
15141 * [remove] and [removeAll] are the Dart equivalent of jQuery's | |
15142 * [removeClass](http://api.jquery.com/removeClass/). | |
15143 * | |
15144 * [value] must be a valid 'token' representing a single class, i.e. a | |
15145 * non-empty string containing no whitespace. To remove multiple classes, use | |
15146 * [removeAll]. | |
15147 */ | |
15148 bool remove(Object value); | |
15149 | |
15150 /** | |
15151 * Add all classes specified in [iterable] to element. | |
15152 * | |
15153 * [add] and [addAll] are the Dart equivalent of jQuery's | |
15154 * [addClass](http://api.jquery.com/addClass/). | |
15155 * | |
15156 * Each element of [iterable] must be a valid 'token' representing a single | |
15157 * class, i.e. a non-empty string containing no whitespace. | |
15158 */ | |
15159 void addAll(Iterable<String> iterable); | |
15160 | |
15161 /** | |
15162 * Remove all classes specified in [iterable] from element. | |
15163 * | |
15164 * [remove] and [removeAll] are the Dart equivalent of jQuery's | |
15165 * [removeClass](http://api.jquery.com/removeClass/). | |
15166 * | |
15167 * Each element of [iterable] must be a valid 'token' representing a single | |
15168 * class, i.e. a non-empty string containing no whitespace. | |
15169 */ | |
15170 void removeAll(Iterable<Object> iterable); | |
15171 | |
15172 /** | |
15173 * Toggles all classes specified in [iterable] on element. | |
15174 * | |
15175 * Iterate through [iterable]'s items, and add it if it is not on it, or | |
15176 * remove it if it is. This is the Dart equivalent of jQuery's | |
15177 * [toggleClass](http://api.jquery.com/toggleClass/). | |
15178 * If [shouldAdd] is true, then we always add all the classes in [iterable] | |
15179 * element. If [shouldAdd] is false then we always remove all the classes in | |
15180 * [iterable] from the element. | |
15181 * | |
15182 * Each element of [iterable] must be a valid 'token' representing a single | |
15183 * class, i.e. a non-empty string containing no whitespace. | |
15184 */ | |
15185 void toggleAll(Iterable<String> iterable, [bool shouldAdd]); | |
15186 } | |
15187 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
15188 // for details. All rights reserved. Use of this source code is governed by a | |
15189 // BSD-style license that can be found in the LICENSE file. | |
15190 | |
15191 | |
15192 /** | |
15193 * A rectangle representing all the content of the element in the | |
15194 * [box model](http://www.w3.org/TR/CSS2/box.html). | |
15195 */ | |
15196 class _ContentCssRect extends CssRect { | |
15197 | |
15198 _ContentCssRect(element) : super(element); | |
15199 | |
15200 num get height => _element.offsetHeight + | |
15201 _addOrSubtractToBoxModel(_HEIGHT, _CONTENT); | |
15202 | |
15203 num get width => _element.offsetWidth + | |
15204 _addOrSubtractToBoxModel(_WIDTH, _CONTENT); | |
15205 | |
15206 /** | |
15207 * Set the height to `newHeight`. | |
15208 * | |
15209 * newHeight can be either a [num] representing the height in pixels or a | |
15210 * [Dimension] object. Values of newHeight that are less than zero are | |
15211 * converted to effectively setting the height to 0. This is equivalent to the | |
15212 * `height` function in jQuery and the calculated `height` CSS value, | |
15213 * converted to a num in pixels. | |
15214 */ | |
15215 set height(Object newHeight) { | |
15216 if (newHeight is Dimension) { | |
15217 var result = (newHeight.value < 0) ? new Dimension.px(0) : newHeight; | |
15218 _element.style.height = result.toString(); | |
15219 } else { | |
15220 var result = ((newHeight as int) < 0) ? 0 : newHeight; | |
15221 _element.style.height = '${result}px'; | |
15222 } | |
15223 } | |
15224 | |
15225 /** | |
15226 * Set the current computed width in pixels of this element. | |
15227 * | |
15228 * newWidth can be either a [num] representing the width in pixels or a | |
15229 * [Dimension] object. This is equivalent to the `width` function in jQuery | |
15230 * and the calculated | |
15231 * `width` CSS value, converted to a dimensionless num in pixels. | |
15232 */ | |
15233 set width(Object newWidth) { | |
15234 if (newWidth is Dimension) { | |
15235 var result = (newWidth.value < 0) ? new Dimension.px(0) : newWidth; | |
15236 _element.style.width = result.toString(); | |
15237 } else { | |
15238 var result = ((newWidth as int) < 0) ? 0 : newWidth; | |
15239 _element.style.width = '${result}px'; | |
15240 } | |
15241 } | |
15242 | |
15243 num get left => _element.getBoundingClientRect().left - | |
15244 _addOrSubtractToBoxModel(['left'], _CONTENT); | |
15245 num get top => _element.getBoundingClientRect().top - | |
15246 _addOrSubtractToBoxModel(['top'], _CONTENT); | |
15247 } | |
15248 | |
15249 /** | |
15250 * A list of element content rectangles in the | |
15251 * [box model](http://www.w3.org/TR/CSS2/box.html). | |
15252 */ | |
15253 class _ContentCssListRect extends _ContentCssRect { | |
15254 List<Element> _elementList; | |
15255 | |
15256 _ContentCssListRect(elementList) : super(elementList.first) { | |
15257 _elementList = elementList; | |
15258 } | |
15259 | |
15260 /** | |
15261 * Set the height to `newHeight`. | |
15262 * | |
15263 * Values of newHeight that are less than zero are converted to effectively | |
15264 * setting the height to 0. This is equivalent to the `height` | |
15265 * function in jQuery and the calculated `height` CSS value, converted to a | |
15266 * num in pixels. | |
15267 */ | |
15268 set height(newHeight) { | |
15269 _elementList.forEach((e) => e.contentEdge.height = newHeight); | |
15270 } | |
15271 | |
15272 /** | |
15273 * Set the current computed width in pixels of this element. | |
15274 * | |
15275 * This is equivalent to the `width` function in jQuery and the calculated | |
15276 * `width` CSS value, converted to a dimensionless num in pixels. | |
15277 */ | |
15278 set width(newWidth) { | |
15279 _elementList.forEach((e) => e.contentEdge.width = newWidth); | |
15280 } | |
15281 } | |
15282 | |
15283 /** | |
15284 * A rectangle representing the dimensions of the space occupied by the | |
15285 * element's content + padding in the | |
15286 * [box model](http://www.w3.org/TR/CSS2/box.html). | |
15287 */ | |
15288 class _PaddingCssRect extends CssRect { | |
15289 _PaddingCssRect(element) : super(element); | |
15290 num get height => _element.offsetHeight + | |
15291 _addOrSubtractToBoxModel(_HEIGHT, _PADDING); | |
15292 num get width => _element.offsetWidth + | |
15293 _addOrSubtractToBoxModel(_WIDTH, _PADDING); | |
15294 | |
15295 num get left => _element.getBoundingClientRect().left - | |
15296 _addOrSubtractToBoxModel(['left'], _PADDING); | |
15297 num get top => _element.getBoundingClientRect().top - | |
15298 _addOrSubtractToBoxModel(['top'], _PADDING); | |
15299 } | |
15300 | |
15301 /** | |
15302 * A rectangle representing the dimensions of the space occupied by the | |
15303 * element's content + padding + border in the | |
15304 * [box model](http://www.w3.org/TR/CSS2/box.html). | |
15305 */ | |
15306 class _BorderCssRect extends CssRect { | |
15307 _BorderCssRect(element) : super(element); | |
15308 num get height => _element.offsetHeight; | |
15309 num get width => _element.offsetWidth; | |
15310 | |
15311 num get left => _element.getBoundingClientRect().left; | |
15312 num get top => _element.getBoundingClientRect().top; | |
15313 } | |
15314 | |
15315 /** | |
15316 * A rectangle representing the dimensions of the space occupied by the | |
15317 * element's content + padding + border + margin in the | |
15318 * [box model](http://www.w3.org/TR/CSS2/box.html). | |
15319 */ | |
15320 class _MarginCssRect extends CssRect { | |
15321 _MarginCssRect(element) : super(element); | |
15322 num get height => _element.offsetHeight + | |
15323 _addOrSubtractToBoxModel(_HEIGHT, _MARGIN); | |
15324 num get width => | |
15325 _element.offsetWidth + _addOrSubtractToBoxModel(_WIDTH, _MARGIN); | |
15326 | |
15327 num get left => _element.getBoundingClientRect().left - | |
15328 _addOrSubtractToBoxModel(['left'], _MARGIN); | |
15329 num get top => _element.getBoundingClientRect().top - | |
15330 _addOrSubtractToBoxModel(['top'], _MARGIN); | |
15331 } | |
15332 | |
15333 /** | |
15334 * A class for representing CSS dimensions. | |
15335 * | |
15336 * In contrast to the more general purpose [Rectangle] class, this class's | |
15337 * values are mutable, so one can change the height of an element | |
15338 * programmatically. | |
15339 * | |
15340 * _Important_ _note_: use of these methods will perform CSS calculations that | |
15341 * can trigger a browser reflow. Therefore, use of these properties _during_ an | |
15342 * animation frame is discouraged. See also: | |
15343 * [Browser Reflow](https://developers.google.com/speed/articles/reflow) | |
15344 */ | |
15345 abstract class CssRect extends MutableRectangle<num> { | |
15346 Element _element; | |
15347 | |
15348 CssRect(this._element) : super(0, 0, 0, 0); | |
15349 | |
15350 num get left; | |
15351 | |
15352 num get top; | |
15353 | |
15354 /** | |
15355 * The height of this rectangle. | |
15356 * | |
15357 * This is equivalent to the `height` function in jQuery and the calculated | |
15358 * `height` CSS value, converted to a dimensionless num in pixels. Unlike | |
15359 * [getBoundingClientRect], `height` will return the same numerical width if | |
15360 * the element is hidden or not. | |
15361 */ | |
15362 num get height; | |
15363 | |
15364 /** | |
15365 * The width of this rectangle. | |
15366 * | |
15367 * This is equivalent to the `width` function in jQuery and the calculated | |
15368 * `width` CSS value, converted to a dimensionless num in pixels. Unlike | |
15369 * [getBoundingClientRect], `width` will return the same numerical width if | |
15370 * the element is hidden or not. | |
15371 */ | |
15372 num get width; | |
15373 | |
15374 /** | |
15375 * Set the height to `newHeight`. | |
15376 * | |
15377 * newHeight can be either a [num] representing the height in pixels or a | |
15378 * [Dimension] object. Values of newHeight that are less than zero are | |
15379 * converted to effectively setting the height to 0. This is equivalent to the | |
15380 * `height` function in jQuery and the calculated `height` CSS value, | |
15381 * converted to a num in pixels. | |
15382 * | |
15383 * Note that only the content height can actually be set via this method. | |
15384 */ | |
15385 set height(newHeight) { | |
15386 throw new UnsupportedError("Can only set height for content rect."); | |
15387 } | |
15388 | |
15389 /** | |
15390 * Set the current computed width in pixels of this element. | |
15391 * | |
15392 * newWidth can be either a [num] representing the width in pixels or a | |
15393 * [Dimension] object. This is equivalent to the `width` function in jQuery | |
15394 * and the calculated | |
15395 * `width` CSS value, converted to a dimensionless num in pixels. | |
15396 * | |
15397 * Note that only the content width can be set via this method. | |
15398 */ | |
15399 set width(newWidth) { | |
15400 throw new UnsupportedError("Can only set width for content rect."); | |
15401 } | |
15402 | |
15403 /** | |
15404 * Return a value that is used to modify the initial height or width | |
15405 * measurement of an element. Depending on the value (ideally an enum) passed | |
15406 * to augmentingMeasurement, we may need to add or subtract margin, padding, | |
15407 * or border values, depending on the measurement we're trying to obtain. | |
15408 */ | |
15409 num _addOrSubtractToBoxModel(List<String> dimensions, | |
15410 String augmentingMeasurement) { | |
15411 // getComputedStyle always returns pixel values (hence, computed), so we're | |
15412 // always dealing with pixels in this method. | |
15413 var styles = _element.getComputedStyle(); | |
15414 | |
15415 var val = 0; | |
15416 | |
15417 for (String measurement in dimensions) { | |
15418 // The border-box and default box model both exclude margin in the regular | |
15419 // height/width calculation, so add it if we want it for this measurement. | |
15420 if (augmentingMeasurement == _MARGIN) { | |
15421 val += new Dimension.css(styles.getPropertyValue( | |
15422 '$augmentingMeasurement-$measurement')).value; | |
15423 } | |
15424 | |
15425 // The border-box includes padding and border, so remove it if we want | |
15426 // just the content itself. | |
15427 if (augmentingMeasurement == _CONTENT) { | |
15428 val -= new Dimension.css( | |
15429 styles.getPropertyValue('${_PADDING}-$measurement')).value; | |
15430 } | |
15431 | |
15432 // At this point, we don't wan't to augment with border or margin, | |
15433 // so remove border. | |
15434 if (augmentingMeasurement != _MARGIN) { | |
15435 val -= new Dimension.css(styles.getPropertyValue( | |
15436 'border-${measurement}-width')).value; | |
15437 } | |
15438 } | |
15439 return val; | |
15440 } | |
15441 } | |
15442 | |
15443 final _HEIGHT = ['top', 'bottom']; | |
15444 final _WIDTH = ['right', 'left']; | |
15445 final _CONTENT = 'content'; | |
15446 final _PADDING = 'padding'; | |
15447 final _MARGIN = 'margin'; | |
15448 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
15449 // for details. All rights reserved. Use of this source code is governed by a | |
15450 // BSD-style license that can be found in the LICENSE file. | |
15451 | |
15452 | |
15453 /** | |
15454 * A set (union) of the CSS classes that are present in a set of elements. | |
15455 * Implemented separately from _ElementCssClassSet for performance. | |
15456 */ | |
15457 class _MultiElementCssClassSet extends CssClassSetImpl { | |
15458 final Iterable<Element> _elementIterable; | |
15459 | |
15460 // TODO(sra): Perhaps we should store the DomTokenList instead. | |
15461 final List<CssClassSetImpl> _sets; | |
15462 | |
15463 factory _MultiElementCssClassSet(Iterable<Element> elements) { | |
15464 return new _MultiElementCssClassSet._(elements, | |
15465 elements.map((Element e) => e.classes).toList()); | |
15466 } | |
15467 | |
15468 _MultiElementCssClassSet._(this._elementIterable, this._sets); | |
15469 | |
15470 Set<String> readClasses() { | |
15471 var s = new LinkedHashSet<String>(); | |
15472 _sets.forEach((CssClassSetImpl e) => s.addAll(e.readClasses())); | |
15473 return s; | |
15474 } | |
15475 | |
15476 void writeClasses(Set<String> s) { | |
15477 var classes = s.join(' '); | |
15478 for (Element e in _elementIterable) { | |
15479 e.className = classes; | |
15480 } | |
15481 } | |
15482 | |
15483 /** | |
15484 * Helper method used to modify the set of css classes on this element. | |
15485 * | |
15486 * f - callback with: | |
15487 * s - a Set of all the css class name currently on this element. | |
15488 * | |
15489 * After f returns, the modified set is written to the | |
15490 * className property of this element. | |
15491 */ | |
15492 modify( f(Set<String> s)) { | |
15493 _sets.forEach((CssClassSetImpl e) => e.modify(f)); | |
15494 } | |
15495 | |
15496 /** | |
15497 * Adds the class [value] to the element if it is not on it, removes it if it | |
15498 * is. | |
15499 * | |
15500 * TODO(sra): It seems wrong to collect a 'changed' flag like this when the | |
15501 * underlying toggle returns an 'is set' flag. | |
15502 */ | |
15503 bool toggle(String value, [bool shouldAdd]) => | |
15504 _sets.fold(false, | |
15505 (bool changed, CssClassSetImpl e) => | |
15506 e.toggle(value, shouldAdd) || changed); | |
15507 | |
15508 /** | |
15509 * Remove the class [value] from element, and return true on successful | |
15510 * removal. | |
15511 * | |
15512 * This is the Dart equivalent of jQuery's | |
15513 * [removeClass](http://api.jquery.com/removeClass/). | |
15514 */ | |
15515 bool remove(Object value) => _sets.fold(false, | |
15516 (bool changed, CssClassSetImpl e) => e.remove(value) || changed); | |
15517 } | |
15518 | |
15519 class _ElementCssClassSet extends CssClassSetImpl { | |
15520 final Element _element; | |
15521 | |
15522 _ElementCssClassSet(this._element); | |
15523 | |
15524 Set<String> readClasses() { | |
15525 var s = new LinkedHashSet<String>(); | |
15526 var classname = _element.className; | |
15527 | |
15528 for (String name in classname.split(' ')) { | |
15529 String trimmed = name.trim(); | |
15530 if (!trimmed.isEmpty) { | |
15531 s.add(trimmed); | |
15532 } | |
15533 } | |
15534 return s; | |
15535 } | |
15536 | |
15537 void writeClasses(Set<String> s) { | |
15538 _element.className = s.join(' '); | |
15539 } | |
15540 | |
15541 int get length => _classListLength(_classListOf(_element)); | |
15542 bool get isEmpty => length == 0; | |
15543 bool get isNotEmpty => length != 0; | |
15544 | |
15545 void clear() { | |
15546 _element.className = ''; | |
15547 } | |
15548 | |
15549 bool contains(Object value) { | |
15550 return _contains(_element, value); | |
15551 } | |
15552 | |
15553 bool add(String value) { | |
15554 return _add(_element, value); | |
15555 } | |
15556 | |
15557 bool remove(Object value) { | |
15558 return value is String && _remove(_element, value); | |
15559 } | |
15560 | |
15561 bool toggle(String value, [bool shouldAdd]) { | |
15562 return _toggle(_element, value, shouldAdd); | |
15563 } | |
15564 | |
15565 void addAll(Iterable<String> iterable) { | |
15566 _addAll(_element, iterable); | |
15567 } | |
15568 | |
15569 void removeAll(Iterable<Object> iterable) { | |
15570 _removeAll(_element, iterable); | |
15571 } | |
15572 | |
15573 void retainAll(Iterable<Object> iterable) { | |
15574 _removeWhere(_element, iterable.toSet().contains, false); | |
15575 } | |
15576 | |
15577 void removeWhere(bool test(String name)) { | |
15578 _removeWhere(_element, test, true); | |
15579 } | |
15580 | |
15581 void retainWhere(bool test(String name)) { | |
15582 _removeWhere(_element, test, false); | |
15583 } | |
15584 | |
15585 static bool _contains(Element _element, Object value) { | |
15586 return value is String && _classListContains(_classListOf(_element), value); | |
15587 } | |
15588 | |
15589 static bool _add(Element _element, String value) { | |
15590 DomTokenList list = _classListOf(_element); | |
15591 // Compute returned result independently of action upon the set. | |
15592 bool added = !_classListContainsBeforeAddOrRemove(list, value); | |
15593 _classListAdd(list, value); | |
15594 return added; | |
15595 } | |
15596 | |
15597 static bool _remove(Element _element, String value) { | |
15598 DomTokenList list = _classListOf(_element); | |
15599 bool removed = _classListContainsBeforeAddOrRemove(list, value); | |
15600 _classListRemove(list, value); | |
15601 return removed; | |
15602 } | |
15603 | |
15604 static bool _toggle(Element _element, String value, bool shouldAdd) { | |
15605 // There is no value that can be passed as the second argument of | |
15606 // DomTokenList.toggle that behaves the same as passing one argument. | |
15607 // `null` is seen as false, meaning 'remove'. | |
15608 return shouldAdd == null | |
15609 ? _toggleDefault(_element, value) | |
15610 : _toggleOnOff(_element, value, shouldAdd); | |
15611 } | |
15612 | |
15613 static bool _toggleDefault(Element _element, String value) { | |
15614 DomTokenList list = _classListOf(_element); | |
15615 return _classListToggle1(list, value); | |
15616 } | |
15617 | |
15618 static bool _toggleOnOff(Element _element, String value, bool shouldAdd) { | |
15619 DomTokenList list = _classListOf(_element); | |
15620 // IE's toggle does not take a second parameter. We would prefer: | |
15621 // | |
15622 // return _classListToggle2(list, value, shouldAdd); | |
15623 // | |
15624 if (shouldAdd) { | |
15625 _classListAdd(list, value); | |
15626 return true; | |
15627 } else { | |
15628 _classListRemove(list, value); | |
15629 return false; | |
15630 } | |
15631 } | |
15632 | |
15633 static void _addAll(Element _element, Iterable<String> iterable) { | |
15634 DomTokenList list = _classListOf(_element); | |
15635 for (String value in iterable) { | |
15636 _classListAdd(list, value); | |
15637 } | |
15638 } | |
15639 | |
15640 static void _removeAll(Element _element, Iterable<String> iterable) { | |
15641 DomTokenList list = _classListOf(_element); | |
15642 for (var value in iterable) { | |
15643 _classListRemove(list, value); | |
15644 } | |
15645 } | |
15646 | |
15647 static void _removeWhere( | |
15648 Element _element, bool test(String name), bool doRemove) { | |
15649 DomTokenList list = _classListOf(_element); | |
15650 int i = 0; | |
15651 while (i < _classListLength(list)) { | |
15652 String item = list.item(i); | |
15653 if (doRemove == test(item)) { | |
15654 _classListRemove(list, item); | |
15655 } else { | |
15656 ++i; | |
15657 } | |
15658 } | |
15659 } | |
15660 | |
15661 // A collection of static methods for DomTokenList. These methods are a | |
15662 // work-around for the lack of annotations to express the full behaviour of | |
15663 // the DomTokenList methods. | |
15664 | |
15665 static DomTokenList _classListOf(Element e) => | |
15666 wrap_jso(JS('returns:DomTokenList;creates:DomTokenList;effects:none;depends:
all;', | |
15667 '#.classList', e.raw)); | |
15668 | |
15669 static int _classListLength(DomTokenList list) => | |
15670 JS('returns:JSUInt31;effects:none;depends:all;', '#.length', list.raw); | |
15671 | |
15672 static bool _classListContains(DomTokenList list, String value) => | |
15673 JS('returns:bool;effects:none;depends:all', | |
15674 '#.contains(#)', list.raw, value); | |
15675 | |
15676 static bool _classListContainsBeforeAddOrRemove( | |
15677 DomTokenList list, String value) => | |
15678 // 'throws:never' is a lie, since 'contains' will throw on an illegal | |
15679 // token. However, we always call this function immediately prior to | |
15680 // add/remove/toggle with the same token. Often the result of 'contains' | |
15681 // is unused and the lie makes it possible for the 'contains' instruction | |
15682 // to be removed. | |
15683 JS('returns:bool;effects:none;depends:all;throws:null(1)', | |
15684 '#.contains(#)', list.raw, value); | |
15685 | |
15686 static void _classListAdd(DomTokenList list, String value) { | |
15687 // list.add(value); | |
15688 JS('', '#.add(#)', list.raw, value); | |
15689 } | |
15690 | |
15691 static void _classListRemove(DomTokenList list, String value) { | |
15692 // list.remove(value); | |
15693 JS('', '#.remove(#)', list.raw, value); | |
15694 } | |
15695 | |
15696 static bool _classListToggle1(DomTokenList list, String value) { | |
15697 return JS('bool', '#.toggle(#)', list.raw, value); | |
15698 } | |
15699 | |
15700 static bool _classListToggle2( | |
15701 DomTokenList list, String value, bool shouldAdd) { | |
15702 return JS('bool', '#.toggle(#, #)', list.raw, value, shouldAdd); | |
15703 } | |
15704 } | |
15705 | |
15706 /** | |
15707 * Class representing a | |
15708 * [length measurement](https://developer.mozilla.org/en-US/docs/Web/CSS/length) | |
15709 * in CSS. | |
15710 */ | |
15711 @Experimental() | |
15712 class Dimension { | |
15713 num _value; | |
15714 String _unit; | |
15715 | |
15716 /** Set this CSS Dimension to a percentage `value`. */ | |
15717 Dimension.percent(this._value) : _unit = '%'; | |
15718 | |
15719 /** Set this CSS Dimension to a pixel `value`. */ | |
15720 Dimension.px(this._value) : _unit = 'px'; | |
15721 | |
15722 /** Set this CSS Dimension to a pica `value`. */ | |
15723 Dimension.pc(this._value) : _unit = 'pc'; | |
15724 | |
15725 /** Set this CSS Dimension to a point `value`. */ | |
15726 Dimension.pt(this._value) : _unit = 'pt'; | |
15727 | |
15728 /** Set this CSS Dimension to an inch `value`. */ | |
15729 Dimension.inch(this._value) : _unit = 'in'; | |
15730 | |
15731 /** Set this CSS Dimension to a centimeter `value`. */ | |
15732 Dimension.cm(this._value) : _unit = 'cm'; | |
15733 | |
15734 /** Set this CSS Dimension to a millimeter `value`. */ | |
15735 Dimension.mm(this._value) : _unit = 'mm'; | |
15736 | |
15737 /** | |
15738 * Set this CSS Dimension to the specified number of ems. | |
15739 * | |
15740 * 1em is equal to the current font size. (So 2ems is equal to double the font | |
15741 * size). This is useful for producing website layouts that scale nicely with | |
15742 * the user's desired font size. | |
15743 */ | |
15744 Dimension.em(this._value) : _unit = 'em'; | |
15745 | |
15746 /** | |
15747 * Set this CSS Dimension to the specified number of x-heights. | |
15748 * | |
15749 * One ex is equal to the the x-height of a font's baseline to its mean line, | |
15750 * generally the height of the letter "x" in the font, which is usually about | |
15751 * half the font-size. | |
15752 */ | |
15753 Dimension.ex(this._value) : _unit = 'ex'; | |
15754 | |
15755 /** | |
15756 * Construct a Dimension object from the valid, simple CSS string `cssValue` | |
15757 * that represents a distance measurement. | |
15758 * | |
15759 * This constructor is intended as a convenience method for working with | |
15760 * simplistic CSS length measurements. Non-numeric values such as `auto` or | |
15761 * `inherit` or invalid CSS will cause this constructor to throw a | |
15762 * FormatError. | |
15763 */ | |
15764 Dimension.css(String cssValue) { | |
15765 if (cssValue == '') cssValue = '0px'; | |
15766 if (cssValue.endsWith('%')) { | |
15767 _unit = '%'; | |
15768 } else { | |
15769 _unit = cssValue.substring(cssValue.length - 2); | |
15770 } | |
15771 if (cssValue.contains('.')) { | |
15772 _value = double.parse(cssValue.substring(0, | |
15773 cssValue.length - _unit.length)); | |
15774 } else { | |
15775 _value = int.parse(cssValue.substring(0, cssValue.length - _unit.length)); | |
15776 } | |
15777 } | |
15778 | |
15779 /** Print out the CSS String representation of this value. */ | |
15780 String toString() { | |
15781 return '${_value}${_unit}'; | |
15782 } | |
15783 | |
15784 /** Return a unitless, numerical value of this CSS value. */ | |
15785 num get value => this._value; | |
15786 } | |
15787 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
15788 // for details. All rights reserved. Use of this source code is governed by a | |
15789 // BSD-style license that can be found in the LICENSE file. | |
15790 | |
15791 | |
15792 typedef EventListener(Event event); | |
15793 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
15794 // for details. All rights reserved. Use of this source code is governed by a | |
15795 // BSD-style license that can be found in the LICENSE file. | |
15796 | |
15797 | |
15798 /** | |
15799 * A factory to expose DOM events as Streams. | |
15800 */ | |
15801 class EventStreamProvider<T extends Event> { | |
15802 final String _eventType; | |
15803 | |
15804 const EventStreamProvider(this._eventType); | |
15805 | |
15806 /** | |
15807 * Gets a [Stream] for this event type, on the specified target. | |
15808 * | |
15809 * This will always return a broadcast stream so multiple listeners can be | |
15810 * used simultaneously. | |
15811 * | |
15812 * This may be used to capture DOM events: | |
15813 * | |
15814 * Element.keyDownEvent.forTarget(element, useCapture: true).listen(...); | |
15815 * | |
15816 * // Alternate method: | |
15817 * Element.keyDownEvent.forTarget(element).capture(...); | |
15818 * | |
15819 * Or for listening to an event which will bubble through the DOM tree: | |
15820 * | |
15821 * MediaElement.pauseEvent.forTarget(document.body).listen(...); | |
15822 * | |
15823 * See also: | |
15824 * | |
15825 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis
tener) | |
15826 */ | |
15827 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) => | |
15828 new _EventStream(e, _eventType, useCapture); | |
15829 | |
15830 /** | |
15831 * Gets an [ElementEventStream] for this event type, on the specified element. | |
15832 * | |
15833 * This will always return a broadcast stream so multiple listeners can be | |
15834 * used simultaneously. | |
15835 * | |
15836 * This may be used to capture DOM events: | |
15837 * | |
15838 * Element.keyDownEvent.forElement(element, useCapture: true).listen(...); | |
15839 * | |
15840 * // Alternate method: | |
15841 * Element.keyDownEvent.forElement(element).capture(...); | |
15842 * | |
15843 * Or for listening to an event which will bubble through the DOM tree: | |
15844 * | |
15845 * MediaElement.pauseEvent.forElement(document.body).listen(...); | |
15846 * | |
15847 * See also: | |
15848 * | |
15849 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis
tener) | |
15850 */ | |
15851 ElementStream<T> forElement(Element e, {bool useCapture: false}) { | |
15852 return new _ElementEventStreamImpl(e, _eventType, useCapture); | |
15853 } | |
15854 | |
15855 /** | |
15856 * Gets an [ElementEventStream] for this event type, on the list of elements. | |
15857 * | |
15858 * This will always return a broadcast stream so multiple listeners can be | |
15859 * used simultaneously. | |
15860 * | |
15861 * This may be used to capture DOM events: | |
15862 * | |
15863 * Element.keyDownEvent._forElementList(element, useCapture: true).listen(
...); | |
15864 * | |
15865 * See also: | |
15866 * | |
15867 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis
tener) | |
15868 */ | |
15869 ElementStream<T> _forElementList(ElementList e, {bool useCapture: false}) { | |
15870 return new _ElementListEventStreamImpl(e, _eventType, useCapture); | |
15871 } | |
15872 | |
15873 /** | |
15874 * Gets the type of the event which this would listen for on the specified | |
15875 * event target. | |
15876 * | |
15877 * The target is necessary because some browsers may use different event names | |
15878 * for the same purpose and the target allows differentiating browser support. | |
15879 */ | |
15880 String getEventType(EventTarget target) { | |
15881 return _eventType; | |
15882 } | |
15883 } | |
15884 | |
15885 /** A specialized Stream available to [Element]s to enable event delegation. */ | |
15886 abstract class ElementStream<T extends Event> implements Stream<T> { | |
15887 /** | |
15888 * Return a stream that only fires when the particular event fires for | |
15889 * elements matching the specified CSS selector. | |
15890 * | |
15891 * This is the Dart equivalent to jQuery's | |
15892 * [delegate](http://api.jquery.com/delegate/). | |
15893 */ | |
15894 Stream<T> matches(String selector); | |
15895 | |
15896 /** | |
15897 * Adds a capturing subscription to this stream. | |
15898 * | |
15899 * If the target of the event is a descendant of the element from which this | |
15900 * stream derives then [onData] is called before the event propagates down to | |
15901 * the target. This is the opposite of bubbling behavior, where the event | |
15902 * is first processed for the event target and then bubbles upward. | |
15903 * | |
15904 * ## Other resources | |
15905 * | |
15906 * * [Event Capture] | |
15907 * (http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow-capture) | |
15908 * from the W3C DOM Events specification. | |
15909 */ | |
15910 StreamSubscription<T> capture(void onData(T event)); | |
15911 } | |
15912 | |
15913 /** | |
15914 * Adapter for exposing DOM events as Dart streams. | |
15915 */ | |
15916 class _EventStream<T extends Event> extends Stream<T> { | |
15917 final EventTarget _target; | |
15918 final String _eventType; | |
15919 final bool _useCapture; | |
15920 | |
15921 _EventStream(this._target, this._eventType, this._useCapture); | |
15922 | |
15923 // DOM events are inherently multi-subscribers. | |
15924 Stream<T> asBroadcastStream({void onListen(StreamSubscription<T> subscription)
, | |
15925 void onCancel(StreamSubscription<T> subscription)
}) | |
15926 => this; | |
15927 bool get isBroadcast => true; | |
15928 | |
15929 StreamSubscription<T> listen(void onData(T event), | |
15930 { Function onError, | |
15931 void onDone(), | |
15932 bool cancelOnError}) { | |
15933 | |
15934 return new _EventStreamSubscription<T>( | |
15935 this._target, this._eventType, onData, this._useCapture); | |
15936 } | |
15937 } | |
15938 | |
15939 /** | |
15940 * Adapter for exposing DOM Element events as streams, while also allowing | |
15941 * event delegation. | |
15942 */ | |
15943 class _ElementEventStreamImpl<T extends Event> extends _EventStream<T> | |
15944 implements ElementStream<T> { | |
15945 _ElementEventStreamImpl(target, eventType, useCapture) : | |
15946 super(target, eventType, useCapture); | |
15947 | |
15948 Stream<T> matches(String selector) => this.where( | |
15949 (event) => event.target.matchesWithAncestors(selector)).map((e) { | |
15950 e._selector = selector; | |
15951 return e; | |
15952 }); | |
15953 | |
15954 StreamSubscription<T> capture(void onData(T event)) => | |
15955 new _EventStreamSubscription<T>( | |
15956 this._target, this._eventType, onData, true); | |
15957 } | |
15958 | |
15959 /** | |
15960 * Adapter for exposing events on a collection of DOM Elements as streams, | |
15961 * while also allowing event delegation. | |
15962 */ | |
15963 class _ElementListEventStreamImpl<T extends Event> extends Stream<T> | |
15964 implements ElementStream<T> { | |
15965 final Iterable<Element> _targetList; | |
15966 final bool _useCapture; | |
15967 final String _eventType; | |
15968 | |
15969 _ElementListEventStreamImpl( | |
15970 this._targetList, this._eventType, this._useCapture); | |
15971 | |
15972 Stream<T> matches(String selector) => this.where( | |
15973 (event) => event.target.matchesWithAncestors(selector)).map((e) { | |
15974 e._selector = selector; | |
15975 return e; | |
15976 }); | |
15977 | |
15978 // Delegate all regular Stream behavior to a wrapped Stream. | |
15979 StreamSubscription<T> listen(void onData(T event), | |
15980 { Function onError, | |
15981 void onDone(), | |
15982 bool cancelOnError}) { | |
15983 var pool = new _StreamPool.broadcast(); | |
15984 for (var target in _targetList) { | |
15985 pool.add(new _EventStream(target, _eventType, _useCapture)); | |
15986 } | |
15987 return pool.stream.listen(onData, onError: onError, onDone: onDone, | |
15988 cancelOnError: cancelOnError); | |
15989 } | |
15990 | |
15991 StreamSubscription<T> capture(void onData(T event)) { | |
15992 var pool = new _StreamPool.broadcast(); | |
15993 for (var target in _targetList) { | |
15994 pool.add(new _EventStream(target, _eventType, true)); | |
15995 } | |
15996 return pool.stream.listen(onData); | |
15997 } | |
15998 | |
15999 Stream<T> asBroadcastStream({void onListen(StreamSubscription<T> subscription)
, | |
16000 void onCancel(StreamSubscription<T> subscription)
}) | |
16001 => this; | |
16002 bool get isBroadcast => true; | |
16003 } | |
16004 | |
16005 class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> { | |
16006 int _pauseCount = 0; | |
16007 EventTarget _target; | |
16008 final String _eventType; | |
16009 var _onData; | |
16010 final bool _useCapture; | |
16011 | |
16012 _EventStreamSubscription(this._target, this._eventType, onData, | |
16013 this._useCapture) : _onData = _wrapZone(onData) { | |
16014 _tryResume(); | |
16015 } | |
16016 | |
16017 Future cancel() { | |
16018 if (_canceled) return null; | |
16019 | |
16020 _unlisten(); | |
16021 // Clear out the target to indicate this is complete. | |
16022 _target = null; | |
16023 _onData = null; | |
16024 return null; | |
16025 } | |
16026 | |
16027 bool get _canceled => _target == null; | |
16028 | |
16029 void onData(void handleData(T event)) { | |
16030 if (_canceled) { | |
16031 throw new StateError("Subscription has been canceled."); | |
16032 } | |
16033 // Remove current event listener. | |
16034 _unlisten(); | |
16035 | |
16036 _onData = _wrapZone(handleData); | |
16037 _tryResume(); | |
16038 } | |
16039 | |
16040 /// Has no effect. | |
16041 void onError(Function handleError) {} | |
16042 | |
16043 /// Has no effect. | |
16044 void onDone(void handleDone()) {} | |
16045 | |
16046 void pause([Future resumeSignal]) { | |
16047 if (_canceled) return; | |
16048 ++_pauseCount; | |
16049 _unlisten(); | |
16050 | |
16051 if (resumeSignal != null) { | |
16052 resumeSignal.whenComplete(resume); | |
16053 } | |
16054 } | |
16055 | |
16056 bool get isPaused => _pauseCount > 0; | |
16057 | |
16058 void resume() { | |
16059 if (_canceled || !isPaused) return; | |
16060 --_pauseCount; | |
16061 _tryResume(); | |
16062 } | |
16063 | |
16064 void _tryResume() { | |
16065 if (_onData != null && !isPaused) { | |
16066 _target.addEventListener(_eventType, _onData, _useCapture); | |
16067 } | |
16068 } | |
16069 | |
16070 void _unlisten() { | |
16071 if (_onData != null) { | |
16072 _target.removeEventListener(_eventType, _onData, _useCapture); | |
16073 } | |
16074 } | |
16075 | |
16076 Future asFuture([var futureValue]) { | |
16077 // We just need a future that will never succeed or fail. | |
16078 Completer completer = new Completer(); | |
16079 return completer.future; | |
16080 } | |
16081 } | |
16082 | |
16083 /** | |
16084 * A stream of custom events, which enables the user to "fire" (add) their own | |
16085 * custom events to a stream. | |
16086 */ | |
16087 abstract class CustomStream<T extends Event> implements Stream<T> { | |
16088 /** | |
16089 * Add the following custom event to the stream for dispatching to interested | |
16090 * listeners. | |
16091 */ | |
16092 void add(T event); | |
16093 } | |
16094 | |
16095 class _CustomEventStreamImpl<T extends Event> extends Stream<T> | |
16096 implements CustomStream<T> { | |
16097 StreamController<T> _streamController; | |
16098 /** The type of event this stream is providing (e.g. "keydown"). */ | |
16099 String _type; | |
16100 | |
16101 _CustomEventStreamImpl(String type) { | |
16102 _type = type; | |
16103 _streamController = new StreamController.broadcast(sync: true); | |
16104 } | |
16105 | |
16106 // Delegate all regular Stream behavior to our wrapped Stream. | |
16107 StreamSubscription<T> listen(void onData(T event), | |
16108 { Function onError, | |
16109 void onDone(), | |
16110 bool cancelOnError}) { | |
16111 return _streamController.stream.listen(onData, onError: onError, | |
16112 onDone: onDone, cancelOnError: cancelOnError); | |
16113 } | |
16114 | |
16115 Stream<T> asBroadcastStream({void onListen(StreamSubscription<T> subscription)
, | |
16116 void onCancel(StreamSubscription<T> subscription)
}) | |
16117 => _streamController.stream; | |
16118 | |
16119 bool get isBroadcast => true; | |
16120 | |
16121 void add(T event) { | |
16122 if (event.type == _type) _streamController.add(event); | |
16123 } | |
16124 } | |
16125 | |
16126 class _CustomKeyEventStreamImpl extends _CustomEventStreamImpl<KeyEvent> | |
16127 implements CustomStream<KeyEvent> { | |
16128 _CustomKeyEventStreamImpl(String type) : super(type); | |
16129 | |
16130 void add(KeyEvent event) { | |
16131 if (event.type == _type) { | |
16132 event.currentTarget.dispatchEvent(event._parent); | |
16133 _streamController.add(event); | |
16134 } | |
16135 } | |
16136 } | |
16137 | |
16138 /** | |
16139 * A pool of streams whose events are unified and emitted through a central | |
16140 * stream. | |
16141 */ | |
16142 // TODO (efortuna): Remove this when Issue 12218 is addressed. | |
16143 class _StreamPool<T> { | |
16144 StreamController<T> _controller; | |
16145 | |
16146 /// Subscriptions to the streams that make up the pool. | |
16147 var _subscriptions = new Map<Stream<T>, StreamSubscription<T>>(); | |
16148 | |
16149 /** | |
16150 * Creates a new stream pool where [stream] can be listened to more than | |
16151 * once. | |
16152 * | |
16153 * Any events from buffered streams in the pool will be emitted immediately, | |
16154 * regardless of whether [stream] has any subscribers. | |
16155 */ | |
16156 _StreamPool.broadcast() { | |
16157 _controller = new StreamController<T>.broadcast(sync: true, | |
16158 onCancel: close); | |
16159 } | |
16160 | |
16161 /** | |
16162 * The stream through which all events from streams in the pool are emitted. | |
16163 */ | |
16164 Stream<T> get stream => _controller.stream; | |
16165 | |
16166 /** | |
16167 * Adds [stream] as a member of this pool. | |
16168 * | |
16169 * Any events from [stream] will be emitted through [this.stream]. If | |
16170 * [stream] is sync, they'll be emitted synchronously; if [stream] is async, | |
16171 * they'll be emitted asynchronously. | |
16172 */ | |
16173 void add(Stream<T> stream) { | |
16174 if (_subscriptions.containsKey(stream)) return; | |
16175 _subscriptions[stream] = stream.listen(_controller.add, | |
16176 onError: _controller.addError, | |
16177 onDone: () => remove(stream)); | |
16178 } | |
16179 | |
16180 /** Removes [stream] as a member of this pool. */ | |
16181 void remove(Stream<T> stream) { | |
16182 var subscription = _subscriptions.remove(stream); | |
16183 if (subscription != null) subscription.cancel(); | |
16184 } | |
16185 | |
16186 /** Removes all streams from this pool and closes [stream]. */ | |
16187 void close() { | |
16188 for (var subscription in _subscriptions.values) { | |
16189 subscription.cancel(); | |
16190 } | |
16191 _subscriptions.clear(); | |
16192 _controller.close(); | |
16193 } | |
16194 } | |
16195 | |
16196 /** | |
16197 * A factory to expose DOM events as streams, where the DOM event name has to | |
16198 * be determined on the fly (for example, mouse wheel events). | |
16199 */ | |
16200 class _CustomEventStreamProvider<T extends Event> | |
16201 implements EventStreamProvider<T> { | |
16202 | |
16203 final _eventTypeGetter; | |
16204 const _CustomEventStreamProvider(this._eventTypeGetter); | |
16205 | |
16206 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) { | |
16207 return new _EventStream(e, _eventTypeGetter(e), useCapture); | |
16208 } | |
16209 | |
16210 ElementStream<T> forElement(Element e, {bool useCapture: false}) { | |
16211 return new _ElementEventStreamImpl(e, _eventTypeGetter(e), useCapture); | |
16212 } | |
16213 | |
16214 ElementStream<T> _forElementList(ElementList e, | |
16215 {bool useCapture: false}) { | |
16216 return new _ElementListEventStreamImpl(e, _eventTypeGetter(e), useCapture); | |
16217 } | |
16218 | |
16219 String getEventType(EventTarget target) { | |
16220 return _eventTypeGetter(target); | |
16221 } | |
16222 | |
16223 String get _eventType => | |
16224 throw new UnsupportedError('Access type through getEventType method.'); | |
16225 } | |
16226 // DO NOT EDIT- this file is generated from running tool/generator.sh. | |
16227 | |
16228 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
16229 // for details. All rights reserved. Use of this source code is governed by a | |
16230 // BSD-style license that can be found in the LICENSE file. | |
16231 | |
16232 | |
16233 /** | |
16234 * A Dart DOM validator generated from Caja whitelists. | |
16235 * | |
16236 * This contains a whitelist of known HTML tagNames and attributes and will only | |
16237 * accept known good values. | |
16238 * | |
16239 * See also: | |
16240 * | |
16241 * * <https://code.google.com/p/google-caja/wiki/CajaWhitelists> | |
16242 */ | |
16243 class _Html5NodeValidator implements NodeValidator { | |
16244 | |
16245 static final Set<String> _allowedElements = new Set.from([ | |
16246 'A', | |
16247 'ABBR', | |
16248 'ACRONYM', | |
16249 'ADDRESS', | |
16250 'AREA', | |
16251 'ARTICLE', | |
16252 'ASIDE', | |
16253 'AUDIO', | |
16254 'B', | |
16255 'BDI', | |
16256 'BDO', | |
16257 'BIG', | |
16258 'BLOCKQUOTE', | |
16259 'BR', | |
16260 'BUTTON', | |
16261 'CANVAS', | |
16262 'CAPTION', | |
16263 'CENTER', | |
16264 'CITE', | |
16265 'CODE', | |
16266 'COL', | |
16267 'COLGROUP', | |
16268 'COMMAND', | |
16269 'DATA', | |
16270 'DATALIST', | |
16271 'DD', | |
16272 'DEL', | |
16273 'DETAILS', | |
16274 'DFN', | |
16275 'DIR', | |
16276 'DIV', | |
16277 'DL', | |
16278 'DT', | |
16279 'EM', | |
16280 'FIELDSET', | |
16281 'FIGCAPTION', | |
16282 'FIGURE', | |
16283 'FONT', | |
16284 'FOOTER', | |
16285 'FORM', | |
16286 'H1', | |
16287 'H2', | |
16288 'H3', | |
16289 'H4', | |
16290 'H5', | |
16291 'H6', | |
16292 'HEADER', | |
16293 'HGROUP', | |
16294 'HR', | |
16295 'I', | |
16296 'IFRAME', | |
16297 'IMG', | |
16298 'INPUT', | |
16299 'INS', | |
16300 'KBD', | |
16301 'LABEL', | |
16302 'LEGEND', | |
16303 'LI', | |
16304 'MAP', | |
16305 'MARK', | |
16306 'MENU', | |
16307 'METER', | |
16308 'NAV', | |
16309 'NOBR', | |
16310 'OL', | |
16311 'OPTGROUP', | |
16312 'OPTION', | |
16313 'OUTPUT', | |
16314 'P', | |
16315 'PRE', | |
16316 'PROGRESS', | |
16317 'Q', | |
16318 'S', | |
16319 'SAMP', | |
16320 'SECTION', | |
16321 'SELECT', | |
16322 'SMALL', | |
16323 'SOURCE', | |
16324 'SPAN', | |
16325 'STRIKE', | |
16326 'STRONG', | |
16327 'SUB', | |
16328 'SUMMARY', | |
16329 'SUP', | |
16330 'TABLE', | |
16331 'TBODY', | |
16332 'TD', | |
16333 'TEXTAREA', | |
16334 'TFOOT', | |
16335 'TH', | |
16336 'THEAD', | |
16337 'TIME', | |
16338 'TR', | |
16339 'TRACK', | |
16340 'TT', | |
16341 'U', | |
16342 'UL', | |
16343 'VAR', | |
16344 'VIDEO', | |
16345 'WBR', | |
16346 ]); | |
16347 | |
16348 static const _standardAttributes = const <String>[ | |
16349 '*::class', | |
16350 '*::dir', | |
16351 '*::draggable', | |
16352 '*::hidden', | |
16353 '*::id', | |
16354 '*::inert', | |
16355 '*::itemprop', | |
16356 '*::itemref', | |
16357 '*::itemscope', | |
16358 '*::lang', | |
16359 '*::spellcheck', | |
16360 '*::title', | |
16361 '*::translate', | |
16362 'A::accesskey', | |
16363 'A::coords', | |
16364 'A::hreflang', | |
16365 'A::name', | |
16366 'A::shape', | |
16367 'A::tabindex', | |
16368 'A::target', | |
16369 'A::type', | |
16370 'AREA::accesskey', | |
16371 'AREA::alt', | |
16372 'AREA::coords', | |
16373 'AREA::nohref', | |
16374 'AREA::shape', | |
16375 'AREA::tabindex', | |
16376 'AREA::target', | |
16377 'AUDIO::controls', | |
16378 'AUDIO::loop', | |
16379 'AUDIO::mediagroup', | |
16380 'AUDIO::muted', | |
16381 'AUDIO::preload', | |
16382 'BDO::dir', | |
16383 'BODY::alink', | |
16384 'BODY::bgcolor', | |
16385 'BODY::link', | |
16386 'BODY::text', | |
16387 'BODY::vlink', | |
16388 'BR::clear', | |
16389 'BUTTON::accesskey', | |
16390 'BUTTON::disabled', | |
16391 'BUTTON::name', | |
16392 'BUTTON::tabindex', | |
16393 'BUTTON::type', | |
16394 'BUTTON::value', | |
16395 'CANVAS::height', | |
16396 'CANVAS::width', | |
16397 'CAPTION::align', | |
16398 'COL::align', | |
16399 'COL::char', | |
16400 'COL::charoff', | |
16401 'COL::span', | |
16402 'COL::valign', | |
16403 'COL::width', | |
16404 'COLGROUP::align', | |
16405 'COLGROUP::char', | |
16406 'COLGROUP::charoff', | |
16407 'COLGROUP::span', | |
16408 'COLGROUP::valign', | |
16409 'COLGROUP::width', | |
16410 'COMMAND::checked', | |
16411 'COMMAND::command', | |
16412 'COMMAND::disabled', | |
16413 'COMMAND::label', | |
16414 'COMMAND::radiogroup', | |
16415 'COMMAND::type', | |
16416 'DATA::value', | |
16417 'DEL::datetime', | |
16418 'DETAILS::open', | |
16419 'DIR::compact', | |
16420 'DIV::align', | |
16421 'DL::compact', | |
16422 'FIELDSET::disabled', | |
16423 'FONT::color', | |
16424 'FONT::face', | |
16425 'FONT::size', | |
16426 'FORM::accept', | |
16427 'FORM::autocomplete', | |
16428 'FORM::enctype', | |
16429 'FORM::method', | |
16430 'FORM::name', | |
16431 'FORM::novalidate', | |
16432 'FORM::target', | |
16433 'FRAME::name', | |
16434 'H1::align', | |
16435 'H2::align', | |
16436 'H3::align', | |
16437 'H4::align', | |
16438 'H5::align', | |
16439 'H6::align', | |
16440 'HR::align', | |
16441 'HR::noshade', | |
16442 'HR::size', | |
16443 'HR::width', | |
16444 'HTML::version', | |
16445 'IFRAME::align', | |
16446 'IFRAME::frameborder', | |
16447 'IFRAME::height', | |
16448 'IFRAME::marginheight', | |
16449 'IFRAME::marginwidth', | |
16450 'IFRAME::width', | |
16451 'IMG::align', | |
16452 'IMG::alt', | |
16453 'IMG::border', | |
16454 'IMG::height', | |
16455 'IMG::hspace', | |
16456 'IMG::ismap', | |
16457 'IMG::name', | |
16458 'IMG::usemap', | |
16459 'IMG::vspace', | |
16460 'IMG::width', | |
16461 'INPUT::accept', | |
16462 'INPUT::accesskey', | |
16463 'INPUT::align', | |
16464 'INPUT::alt', | |
16465 'INPUT::autocomplete', | |
16466 'INPUT::checked', | |
16467 'INPUT::disabled', | |
16468 'INPUT::inputmode', | |
16469 'INPUT::ismap', | |
16470 'INPUT::list', | |
16471 'INPUT::max', | |
16472 'INPUT::maxlength', | |
16473 'INPUT::min', | |
16474 'INPUT::multiple', | |
16475 'INPUT::name', | |
16476 'INPUT::placeholder', | |
16477 'INPUT::readonly', | |
16478 'INPUT::required', | |
16479 'INPUT::size', | |
16480 'INPUT::step', | |
16481 'INPUT::tabindex', | |
16482 'INPUT::type', | |
16483 'INPUT::usemap', | |
16484 'INPUT::value', | |
16485 'INS::datetime', | |
16486 'KEYGEN::disabled', | |
16487 'KEYGEN::keytype', | |
16488 'KEYGEN::name', | |
16489 'LABEL::accesskey', | |
16490 'LABEL::for', | |
16491 'LEGEND::accesskey', | |
16492 'LEGEND::align', | |
16493 'LI::type', | |
16494 'LI::value', | |
16495 'LINK::sizes', | |
16496 'MAP::name', | |
16497 'MENU::compact', | |
16498 'MENU::label', | |
16499 'MENU::type', | |
16500 'METER::high', | |
16501 'METER::low', | |
16502 'METER::max', | |
16503 'METER::min', | |
16504 'METER::value', | |
16505 'OBJECT::typemustmatch', | |
16506 'OL::compact', | |
16507 'OL::reversed', | |
16508 'OL::start', | |
16509 'OL::type', | |
16510 'OPTGROUP::disabled', | |
16511 'OPTGROUP::label', | |
16512 'OPTION::disabled', | |
16513 'OPTION::label', | |
16514 'OPTION::selected', | |
16515 'OPTION::value', | |
16516 'OUTPUT::for', | |
16517 'OUTPUT::name', | |
16518 'P::align', | |
16519 'PRE::width', | |
16520 'PROGRESS::max', | |
16521 'PROGRESS::min', | |
16522 'PROGRESS::value', | |
16523 'SELECT::autocomplete', | |
16524 'SELECT::disabled', | |
16525 'SELECT::multiple', | |
16526 'SELECT::name', | |
16527 'SELECT::required', | |
16528 'SELECT::size', | |
16529 'SELECT::tabindex', | |
16530 'SOURCE::type', | |
16531 'TABLE::align', | |
16532 'TABLE::bgcolor', | |
16533 'TABLE::border', | |
16534 'TABLE::cellpadding', | |
16535 'TABLE::cellspacing', | |
16536 'TABLE::frame', | |
16537 'TABLE::rules', | |
16538 'TABLE::summary', | |
16539 'TABLE::width', | |
16540 'TBODY::align', | |
16541 'TBODY::char', | |
16542 'TBODY::charoff', | |
16543 'TBODY::valign', | |
16544 'TD::abbr', | |
16545 'TD::align', | |
16546 'TD::axis', | |
16547 'TD::bgcolor', | |
16548 'TD::char', | |
16549 'TD::charoff', | |
16550 'TD::colspan', | |
16551 'TD::headers', | |
16552 'TD::height', | |
16553 'TD::nowrap', | |
16554 'TD::rowspan', | |
16555 'TD::scope', | |
16556 'TD::valign', | |
16557 'TD::width', | |
16558 'TEXTAREA::accesskey', | |
16559 'TEXTAREA::autocomplete', | |
16560 'TEXTAREA::cols', | |
16561 'TEXTAREA::disabled', | |
16562 'TEXTAREA::inputmode', | |
16563 'TEXTAREA::name', | |
16564 'TEXTAREA::placeholder', | |
16565 'TEXTAREA::readonly', | |
16566 'TEXTAREA::required', | |
16567 'TEXTAREA::rows', | |
16568 'TEXTAREA::tabindex', | |
16569 'TEXTAREA::wrap', | |
16570 'TFOOT::align', | |
16571 'TFOOT::char', | |
16572 'TFOOT::charoff', | |
16573 'TFOOT::valign', | |
16574 'TH::abbr', | |
16575 'TH::align', | |
16576 'TH::axis', | |
16577 'TH::bgcolor', | |
16578 'TH::char', | |
16579 'TH::charoff', | |
16580 'TH::colspan', | |
16581 'TH::headers', | |
16582 'TH::height', | |
16583 'TH::nowrap', | |
16584 'TH::rowspan', | |
16585 'TH::scope', | |
16586 'TH::valign', | |
16587 'TH::width', | |
16588 'THEAD::align', | |
16589 'THEAD::char', | |
16590 'THEAD::charoff', | |
16591 'THEAD::valign', | |
16592 'TR::align', | |
16593 'TR::bgcolor', | |
16594 'TR::char', | |
16595 'TR::charoff', | |
16596 'TR::valign', | |
16597 'TRACK::default', | |
16598 'TRACK::kind', | |
16599 'TRACK::label', | |
16600 'TRACK::srclang', | |
16601 'UL::compact', | |
16602 'UL::type', | |
16603 'VIDEO::controls', | |
16604 'VIDEO::height', | |
16605 'VIDEO::loop', | |
16606 'VIDEO::mediagroup', | |
16607 'VIDEO::muted', | |
16608 'VIDEO::preload', | |
16609 'VIDEO::width', | |
16610 ]; | |
16611 | |
16612 static const _uriAttributes = const <String>[ | |
16613 'A::href', | |
16614 'AREA::href', | |
16615 'BLOCKQUOTE::cite', | |
16616 'BODY::background', | |
16617 'COMMAND::icon', | |
16618 'DEL::cite', | |
16619 'FORM::action', | |
16620 'IMG::src', | |
16621 'INPUT::src', | |
16622 'INS::cite', | |
16623 'Q::cite', | |
16624 'VIDEO::poster', | |
16625 ]; | |
16626 | |
16627 final UriPolicy uriPolicy; | |
16628 | |
16629 static final Map<String, Function> _attributeValidators = {}; | |
16630 | |
16631 /** | |
16632 * All known URI attributes will be validated against the UriPolicy, if | |
16633 * [uriPolicy] is null then a default UriPolicy will be used. | |
16634 */ | |
16635 _Html5NodeValidator({UriPolicy uriPolicy}) | |
16636 :uriPolicy = uriPolicy != null ? uriPolicy : new UriPolicy() { | |
16637 | |
16638 if (_attributeValidators.isEmpty) { | |
16639 for (var attr in _standardAttributes) { | |
16640 _attributeValidators[attr] = _standardAttributeValidator; | |
16641 } | |
16642 | |
16643 for (var attr in _uriAttributes) { | |
16644 _attributeValidators[attr] = _uriAttributeValidator; | |
16645 } | |
16646 } | |
16647 } | |
16648 | |
16649 bool allowsElement(Element element) { | |
16650 return _allowedElements.contains(Element._safeTagName(element)); | |
16651 } | |
16652 | |
16653 bool allowsAttribute(Element element, String attributeName, String value) { | |
16654 var tagName = Element._safeTagName(element); | |
16655 var validator = _attributeValidators['$tagName::$attributeName']; | |
16656 if (validator == null) { | |
16657 validator = _attributeValidators['*::$attributeName']; | |
16658 } | |
16659 if (validator == null) { | |
16660 return false; | |
16661 } | |
16662 return validator(element, attributeName, value, this); | |
16663 } | |
16664 | |
16665 static bool _standardAttributeValidator(Element element, String attributeName, | |
16666 String value, _Html5NodeValidator context) { | |
16667 return true; | |
16668 } | |
16669 | |
16670 static bool _uriAttributeValidator(Element element, String attributeName, | |
16671 String value, _Html5NodeValidator context) { | |
16672 return context.uriPolicy.allowsUri(value); | |
16673 } | |
16674 } | |
16675 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
16676 // for details. All rights reserved. Use of this source code is governed by a | |
16677 // BSD-style license that can be found in the LICENSE file. | |
16678 | |
16679 | |
16680 abstract class ImmutableListMixin<E> implements List<E> { | |
16681 // From Iterable<$E>: | |
16682 Iterator<E> get iterator { | |
16683 // Note: NodeLists are not fixed size. And most probably length shouldn't | |
16684 // be cached in both iterator _and_ forEach method. For now caching it | |
16685 // for consistency. | |
16686 return new FixedSizeListIterator<E>(this); | |
16687 } | |
16688 | |
16689 // From Collection<E>: | |
16690 void add(E value) { | |
16691 throw new UnsupportedError("Cannot add to immutable List."); | |
16692 } | |
16693 | |
16694 void addAll(Iterable<E> iterable) { | |
16695 throw new UnsupportedError("Cannot add to immutable List."); | |
16696 } | |
16697 | |
16698 // From List<E>: | |
16699 void sort([int compare(E a, E b)]) { | |
16700 throw new UnsupportedError("Cannot sort immutable List."); | |
16701 } | |
16702 | |
16703 void shuffle([Random random]) { | |
16704 throw new UnsupportedError("Cannot shuffle immutable List."); | |
16705 } | |
16706 | |
16707 void insert(int index, E element) { | |
16708 throw new UnsupportedError("Cannot add to immutable List."); | |
16709 } | |
16710 | |
16711 void insertAll(int index, Iterable<E> iterable) { | |
16712 throw new UnsupportedError("Cannot add to immutable List."); | |
16713 } | |
16714 | |
16715 void setAll(int index, Iterable<E> iterable) { | |
16716 throw new UnsupportedError("Cannot modify an immutable List."); | |
16717 } | |
16718 | |
16719 E removeAt(int pos) { | |
16720 throw new UnsupportedError("Cannot remove from immutable List."); | |
16721 } | |
16722 | |
16723 E removeLast() { | |
16724 throw new UnsupportedError("Cannot remove from immutable List."); | |
16725 } | |
16726 | |
16727 bool remove(Object object) { | |
16728 throw new UnsupportedError("Cannot remove from immutable List."); | |
16729 } | |
16730 | |
16731 void removeWhere(bool test(E element)) { | |
16732 throw new UnsupportedError("Cannot remove from immutable List."); | |
16733 } | |
16734 | |
16735 void retainWhere(bool test(E element)) { | |
16736 throw new UnsupportedError("Cannot remove from immutable List."); | |
16737 } | |
16738 | |
16739 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { | |
16740 throw new UnsupportedError("Cannot setRange on immutable List."); | |
16741 } | |
16742 | |
16743 void removeRange(int start, int end) { | |
16744 throw new UnsupportedError("Cannot removeRange on immutable List."); | |
16745 } | |
16746 | |
16747 void replaceRange(int start, int end, Iterable<E> iterable) { | |
16748 throw new UnsupportedError("Cannot modify an immutable List."); | |
16749 } | |
16750 | |
16751 void fillRange(int start, int end, [E fillValue]) { | |
16752 throw new UnsupportedError("Cannot modify an immutable List."); | |
16753 } | |
16754 } | |
16755 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
16756 // for details. All rights reserved. Use of this source code is governed by a | |
16757 // BSD-style license that can be found in the LICENSE file. | |
16758 | |
16759 | |
16760 /** | |
16761 * Defines the keycode values for keys that are returned by | |
16762 * KeyboardEvent.keyCode. | |
16763 * | |
16764 * Important note: There is substantial divergence in how different browsers | |
16765 * handle keycodes and their variants in different locales/keyboard layouts. We | |
16766 * provide these constants to help make code processing keys more readable. | |
16767 */ | |
16768 abstract class KeyCode { | |
16769 // These constant names were borrowed from Closure's Keycode enumeration | |
16770 // class. | |
16771 // http://closure-library.googlecode.com/svn/docs/closure_goog_events_keycodes
.js.source.html | |
16772 static const int WIN_KEY_FF_LINUX = 0; | |
16773 static const int MAC_ENTER = 3; | |
16774 static const int BACKSPACE = 8; | |
16775 static const int TAB = 9; | |
16776 /** NUM_CENTER is also NUMLOCK for FF and Safari on Mac. */ | |
16777 static const int NUM_CENTER = 12; | |
16778 static const int ENTER = 13; | |
16779 static const int SHIFT = 16; | |
16780 static const int CTRL = 17; | |
16781 static const int ALT = 18; | |
16782 static const int PAUSE = 19; | |
16783 static const int CAPS_LOCK = 20; | |
16784 static const int ESC = 27; | |
16785 static const int SPACE = 32; | |
16786 static const int PAGE_UP = 33; | |
16787 static const int PAGE_DOWN = 34; | |
16788 static const int END = 35; | |
16789 static const int HOME = 36; | |
16790 static const int LEFT = 37; | |
16791 static const int UP = 38; | |
16792 static const int RIGHT = 39; | |
16793 static const int DOWN = 40; | |
16794 static const int NUM_NORTH_EAST = 33; | |
16795 static const int NUM_SOUTH_EAST = 34; | |
16796 static const int NUM_SOUTH_WEST = 35; | |
16797 static const int NUM_NORTH_WEST = 36; | |
16798 static const int NUM_WEST = 37; | |
16799 static const int NUM_NORTH = 38; | |
16800 static const int NUM_EAST = 39; | |
16801 static const int NUM_SOUTH = 40; | |
16802 static const int PRINT_SCREEN = 44; | |
16803 static const int INSERT = 45; | |
16804 static const int NUM_INSERT = 45; | |
16805 static const int DELETE = 46; | |
16806 static const int NUM_DELETE = 46; | |
16807 static const int ZERO = 48; | |
16808 static const int ONE = 49; | |
16809 static const int TWO = 50; | |
16810 static const int THREE = 51; | |
16811 static const int FOUR = 52; | |
16812 static const int FIVE = 53; | |
16813 static const int SIX = 54; | |
16814 static const int SEVEN = 55; | |
16815 static const int EIGHT = 56; | |
16816 static const int NINE = 57; | |
16817 static const int FF_SEMICOLON = 59; | |
16818 static const int FF_EQUALS = 61; | |
16819 /** | |
16820 * CAUTION: The question mark is for US-keyboard layouts. It varies | |
16821 * for other locales and keyboard layouts. | |
16822 */ | |
16823 static const int QUESTION_MARK = 63; | |
16824 static const int A = 65; | |
16825 static const int B = 66; | |
16826 static const int C = 67; | |
16827 static const int D = 68; | |
16828 static const int E = 69; | |
16829 static const int F = 70; | |
16830 static const int G = 71; | |
16831 static const int H = 72; | |
16832 static const int I = 73; | |
16833 static const int J = 74; | |
16834 static const int K = 75; | |
16835 static const int L = 76; | |
16836 static const int M = 77; | |
16837 static const int N = 78; | |
16838 static const int O = 79; | |
16839 static const int P = 80; | |
16840 static const int Q = 81; | |
16841 static const int R = 82; | |
16842 static const int S = 83; | |
16843 static const int T = 84; | |
16844 static const int U = 85; | |
16845 static const int V = 86; | |
16846 static const int W = 87; | |
16847 static const int X = 88; | |
16848 static const int Y = 89; | |
16849 static const int Z = 90; | |
16850 static const int META = 91; | |
16851 static const int WIN_KEY_LEFT = 91; | |
16852 static const int WIN_KEY_RIGHT = 92; | |
16853 static const int CONTEXT_MENU = 93; | |
16854 static const int NUM_ZERO = 96; | |
16855 static const int NUM_ONE = 97; | |
16856 static const int NUM_TWO = 98; | |
16857 static const int NUM_THREE = 99; | |
16858 static const int NUM_FOUR = 100; | |
16859 static const int NUM_FIVE = 101; | |
16860 static const int NUM_SIX = 102; | |
16861 static const int NUM_SEVEN = 103; | |
16862 static const int NUM_EIGHT = 104; | |
16863 static const int NUM_NINE = 105; | |
16864 static const int NUM_MULTIPLY = 106; | |
16865 static const int NUM_PLUS = 107; | |
16866 static const int NUM_MINUS = 109; | |
16867 static const int NUM_PERIOD = 110; | |
16868 static const int NUM_DIVISION = 111; | |
16869 static const int F1 = 112; | |
16870 static const int F2 = 113; | |
16871 static const int F3 = 114; | |
16872 static const int F4 = 115; | |
16873 static const int F5 = 116; | |
16874 static const int F6 = 117; | |
16875 static const int F7 = 118; | |
16876 static const int F8 = 119; | |
16877 static const int F9 = 120; | |
16878 static const int F10 = 121; | |
16879 static const int F11 = 122; | |
16880 static const int F12 = 123; | |
16881 static const int NUMLOCK = 144; | |
16882 static const int SCROLL_LOCK = 145; | |
16883 | |
16884 // OS-specific media keys like volume controls and browser controls. | |
16885 static const int FIRST_MEDIA_KEY = 166; | |
16886 static const int LAST_MEDIA_KEY = 183; | |
16887 | |
16888 /** | |
16889 * CAUTION: This constant requires localization for other locales and keyboard | |
16890 * layouts. | |
16891 */ | |
16892 static const int SEMICOLON = 186; | |
16893 /** | |
16894 * CAUTION: This constant requires localization for other locales and keyboard | |
16895 * layouts. | |
16896 */ | |
16897 static const int DASH = 189; | |
16898 /** | |
16899 * CAUTION: This constant requires localization for other locales and keyboard | |
16900 * layouts. | |
16901 */ | |
16902 static const int EQUALS = 187; | |
16903 /** | |
16904 * CAUTION: This constant requires localization for other locales and keyboard | |
16905 * layouts. | |
16906 */ | |
16907 static const int COMMA = 188; | |
16908 /** | |
16909 * CAUTION: This constant requires localization for other locales and keyboard | |
16910 * layouts. | |
16911 */ | |
16912 static const int PERIOD = 190; | |
16913 /** | |
16914 * CAUTION: This constant requires localization for other locales and keyboard | |
16915 * layouts. | |
16916 */ | |
16917 static const int SLASH = 191; | |
16918 /** | |
16919 * CAUTION: This constant requires localization for other locales and keyboard | |
16920 * layouts. | |
16921 */ | |
16922 static const int APOSTROPHE = 192; | |
16923 /** | |
16924 * CAUTION: This constant requires localization for other locales and keyboard | |
16925 * layouts. | |
16926 */ | |
16927 static const int TILDE = 192; | |
16928 /** | |
16929 * CAUTION: This constant requires localization for other locales and keyboard | |
16930 * layouts. | |
16931 */ | |
16932 static const int SINGLE_QUOTE = 222; | |
16933 /** | |
16934 * CAUTION: This constant requires localization for other locales and keyboard | |
16935 * layouts. | |
16936 */ | |
16937 static const int OPEN_SQUARE_BRACKET = 219; | |
16938 /** | |
16939 * CAUTION: This constant requires localization for other locales and keyboard | |
16940 * layouts. | |
16941 */ | |
16942 static const int BACKSLASH = 220; | |
16943 /** | |
16944 * CAUTION: This constant requires localization for other locales and keyboard | |
16945 * layouts. | |
16946 */ | |
16947 static const int CLOSE_SQUARE_BRACKET = 221; | |
16948 static const int WIN_KEY = 224; | |
16949 static const int MAC_FF_META = 224; | |
16950 static const int WIN_IME = 229; | |
16951 | |
16952 /** A sentinel value if the keycode could not be determined. */ | |
16953 static const int UNKNOWN = -1; | |
16954 | |
16955 /** | |
16956 * Returns true if the keyCode produces a (US keyboard) character. | |
16957 * Note: This does not (yet) cover characters on non-US keyboards (Russian, | |
16958 * Hebrew, etc.). | |
16959 */ | |
16960 static bool isCharacterKey(int keyCode) { | |
16961 if ((keyCode >= ZERO && keyCode <= NINE) || | |
16962 (keyCode >= NUM_ZERO && keyCode <= NUM_MULTIPLY) || | |
16963 (keyCode >= A && keyCode <= Z)) { | |
16964 return true; | |
16965 } | |
16966 | |
16967 // Safari sends zero key code for non-latin characters. | |
16968 if (Device.isWebKit && keyCode == 0) { | |
16969 return true; | |
16970 } | |
16971 | |
16972 return (keyCode == SPACE || keyCode == QUESTION_MARK || keyCode == NUM_PLUS | |
16973 || keyCode == NUM_MINUS || keyCode == NUM_PERIOD || | |
16974 keyCode == NUM_DIVISION || keyCode == SEMICOLON || | |
16975 keyCode == FF_SEMICOLON || keyCode == DASH || keyCode == EQUALS || | |
16976 keyCode == FF_EQUALS || keyCode == COMMA || keyCode == PERIOD || | |
16977 keyCode == SLASH || keyCode == APOSTROPHE || keyCode == SINGLE_QUOTE || | |
16978 keyCode == OPEN_SQUARE_BRACKET || keyCode == BACKSLASH || | |
16979 keyCode == CLOSE_SQUARE_BRACKET); | |
16980 } | |
16981 | |
16982 /** | |
16983 * Experimental helper function for converting keyCodes to keyNames for the | |
16984 * keyIdentifier attribute still used in browsers not updated with current | |
16985 * spec. This is an imperfect conversion! It will need to be refined, but | |
16986 * hopefully it can just completely go away once all the browsers update to | |
16987 * follow the DOM3 spec. | |
16988 */ | |
16989 static String _convertKeyCodeToKeyName(int keyCode) { | |
16990 switch(keyCode) { | |
16991 case KeyCode.ALT: return _KeyName.ALT; | |
16992 case KeyCode.BACKSPACE: return _KeyName.BACKSPACE; | |
16993 case KeyCode.CAPS_LOCK: return _KeyName.CAPS_LOCK; | |
16994 case KeyCode.CTRL: return _KeyName.CONTROL; | |
16995 case KeyCode.DELETE: return _KeyName.DEL; | |
16996 case KeyCode.DOWN: return _KeyName.DOWN; | |
16997 case KeyCode.END: return _KeyName.END; | |
16998 case KeyCode.ENTER: return _KeyName.ENTER; | |
16999 case KeyCode.ESC: return _KeyName.ESC; | |
17000 case KeyCode.F1: return _KeyName.F1; | |
17001 case KeyCode.F2: return _KeyName.F2; | |
17002 case KeyCode.F3: return _KeyName.F3; | |
17003 case KeyCode.F4: return _KeyName.F4; | |
17004 case KeyCode.F5: return _KeyName.F5; | |
17005 case KeyCode.F6: return _KeyName.F6; | |
17006 case KeyCode.F7: return _KeyName.F7; | |
17007 case KeyCode.F8: return _KeyName.F8; | |
17008 case KeyCode.F9: return _KeyName.F9; | |
17009 case KeyCode.F10: return _KeyName.F10; | |
17010 case KeyCode.F11: return _KeyName.F11; | |
17011 case KeyCode.F12: return _KeyName.F12; | |
17012 case KeyCode.HOME: return _KeyName.HOME; | |
17013 case KeyCode.INSERT: return _KeyName.INSERT; | |
17014 case KeyCode.LEFT: return _KeyName.LEFT; | |
17015 case KeyCode.META: return _KeyName.META; | |
17016 case KeyCode.NUMLOCK: return _KeyName.NUM_LOCK; | |
17017 case KeyCode.PAGE_DOWN: return _KeyName.PAGE_DOWN; | |
17018 case KeyCode.PAGE_UP: return _KeyName.PAGE_UP; | |
17019 case KeyCode.PAUSE: return _KeyName.PAUSE; | |
17020 case KeyCode.PRINT_SCREEN: return _KeyName.PRINT_SCREEN; | |
17021 case KeyCode.RIGHT: return _KeyName.RIGHT; | |
17022 case KeyCode.SCROLL_LOCK: return _KeyName.SCROLL; | |
17023 case KeyCode.SHIFT: return _KeyName.SHIFT; | |
17024 case KeyCode.SPACE: return _KeyName.SPACEBAR; | |
17025 case KeyCode.TAB: return _KeyName.TAB; | |
17026 case KeyCode.UP: return _KeyName.UP; | |
17027 case KeyCode.WIN_IME: | |
17028 case KeyCode.WIN_KEY: | |
17029 case KeyCode.WIN_KEY_LEFT: | |
17030 case KeyCode.WIN_KEY_RIGHT: | |
17031 return _KeyName.WIN; | |
17032 default: return _KeyName.UNIDENTIFIED; | |
17033 } | |
17034 return _KeyName.UNIDENTIFIED; | |
17035 } | |
17036 } | |
17037 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
17038 // for details. All rights reserved. Use of this source code is governed by a | |
17039 // BSD-style license that can be found in the LICENSE file. | |
17040 | |
17041 | |
17042 /** | |
17043 * Defines the standard key locations returned by | |
17044 * KeyboardEvent.getKeyLocation. | |
17045 */ | |
17046 abstract class KeyLocation { | |
17047 | |
17048 /** | |
17049 * The event key is not distinguished as the left or right version | |
17050 * of the key, and did not originate from the numeric keypad (or did not | |
17051 * originate with a virtual key corresponding to the numeric keypad). | |
17052 */ | |
17053 static const int STANDARD = 0; | |
17054 | |
17055 /** | |
17056 * The event key is in the left key location. | |
17057 */ | |
17058 static const int LEFT = 1; | |
17059 | |
17060 /** | |
17061 * The event key is in the right key location. | |
17062 */ | |
17063 static const int RIGHT = 2; | |
17064 | |
17065 /** | |
17066 * The event key originated on the numeric keypad or with a virtual key | |
17067 * corresponding to the numeric keypad. | |
17068 */ | |
17069 static const int NUMPAD = 3; | |
17070 | |
17071 /** | |
17072 * The event key originated on a mobile device, either on a physical | |
17073 * keypad or a virtual keyboard. | |
17074 */ | |
17075 static const int MOBILE = 4; | |
17076 | |
17077 /** | |
17078 * The event key originated on a game controller or a joystick on a mobile | |
17079 * device. | |
17080 */ | |
17081 static const int JOYSTICK = 5; | |
17082 } | |
17083 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
17084 // for details. All rights reserved. Use of this source code is governed by a | |
17085 // BSD-style license that can be found in the LICENSE file. | |
17086 | |
17087 | |
17088 /** | |
17089 * Defines the standard keyboard identifier names for keys that are returned | |
17090 * by KeyboardEvent.getKeyboardIdentifier when the key does not have a direct | |
17091 * unicode mapping. | |
17092 */ | |
17093 abstract class _KeyName { | |
17094 | |
17095 /** The Accept (Commit, OK) key */ | |
17096 static const String ACCEPT = "Accept"; | |
17097 | |
17098 /** The Add key */ | |
17099 static const String ADD = "Add"; | |
17100 | |
17101 /** The Again key */ | |
17102 static const String AGAIN = "Again"; | |
17103 | |
17104 /** The All Candidates key */ | |
17105 static const String ALL_CANDIDATES = "AllCandidates"; | |
17106 | |
17107 /** The Alphanumeric key */ | |
17108 static const String ALPHANUMERIC = "Alphanumeric"; | |
17109 | |
17110 /** The Alt (Menu) key */ | |
17111 static const String ALT = "Alt"; | |
17112 | |
17113 /** The Alt-Graph key */ | |
17114 static const String ALT_GRAPH = "AltGraph"; | |
17115 | |
17116 /** The Application key */ | |
17117 static const String APPS = "Apps"; | |
17118 | |
17119 /** The ATTN key */ | |
17120 static const String ATTN = "Attn"; | |
17121 | |
17122 /** The Browser Back key */ | |
17123 static const String BROWSER_BACK = "BrowserBack"; | |
17124 | |
17125 /** The Browser Favorites key */ | |
17126 static const String BROWSER_FAVORTIES = "BrowserFavorites"; | |
17127 | |
17128 /** The Browser Forward key */ | |
17129 static const String BROWSER_FORWARD = "BrowserForward"; | |
17130 | |
17131 /** The Browser Home key */ | |
17132 static const String BROWSER_NAME = "BrowserHome"; | |
17133 | |
17134 /** The Browser Refresh key */ | |
17135 static const String BROWSER_REFRESH = "BrowserRefresh"; | |
17136 | |
17137 /** The Browser Search key */ | |
17138 static const String BROWSER_SEARCH = "BrowserSearch"; | |
17139 | |
17140 /** The Browser Stop key */ | |
17141 static const String BROWSER_STOP = "BrowserStop"; | |
17142 | |
17143 /** The Camera key */ | |
17144 static const String CAMERA = "Camera"; | |
17145 | |
17146 /** The Caps Lock (Capital) key */ | |
17147 static const String CAPS_LOCK = "CapsLock"; | |
17148 | |
17149 /** The Clear key */ | |
17150 static const String CLEAR = "Clear"; | |
17151 | |
17152 /** The Code Input key */ | |
17153 static const String CODE_INPUT = "CodeInput"; | |
17154 | |
17155 /** The Compose key */ | |
17156 static const String COMPOSE = "Compose"; | |
17157 | |
17158 /** The Control (Ctrl) key */ | |
17159 static const String CONTROL = "Control"; | |
17160 | |
17161 /** The Crsel key */ | |
17162 static const String CRSEL = "Crsel"; | |
17163 | |
17164 /** The Convert key */ | |
17165 static const String CONVERT = "Convert"; | |
17166 | |
17167 /** The Copy key */ | |
17168 static const String COPY = "Copy"; | |
17169 | |
17170 /** The Cut key */ | |
17171 static const String CUT = "Cut"; | |
17172 | |
17173 /** The Decimal key */ | |
17174 static const String DECIMAL = "Decimal"; | |
17175 | |
17176 /** The Divide key */ | |
17177 static const String DIVIDE = "Divide"; | |
17178 | |
17179 /** The Down Arrow key */ | |
17180 static const String DOWN = "Down"; | |
17181 | |
17182 /** The diagonal Down-Left Arrow key */ | |
17183 static const String DOWN_LEFT = "DownLeft"; | |
17184 | |
17185 /** The diagonal Down-Right Arrow key */ | |
17186 static const String DOWN_RIGHT = "DownRight"; | |
17187 | |
17188 /** The Eject key */ | |
17189 static const String EJECT = "Eject"; | |
17190 | |
17191 /** The End key */ | |
17192 static const String END = "End"; | |
17193 | |
17194 /** | |
17195 * The Enter key. Note: This key value must also be used for the Return | |
17196 * (Macintosh numpad) key | |
17197 */ | |
17198 static const String ENTER = "Enter"; | |
17199 | |
17200 /** The Erase EOF key */ | |
17201 static const String ERASE_EOF= "EraseEof"; | |
17202 | |
17203 /** The Execute key */ | |
17204 static const String EXECUTE = "Execute"; | |
17205 | |
17206 /** The Exsel key */ | |
17207 static const String EXSEL = "Exsel"; | |
17208 | |
17209 /** The Function switch key */ | |
17210 static const String FN = "Fn"; | |
17211 | |
17212 /** The F1 key */ | |
17213 static const String F1 = "F1"; | |
17214 | |
17215 /** The F2 key */ | |
17216 static const String F2 = "F2"; | |
17217 | |
17218 /** The F3 key */ | |
17219 static const String F3 = "F3"; | |
17220 | |
17221 /** The F4 key */ | |
17222 static const String F4 = "F4"; | |
17223 | |
17224 /** The F5 key */ | |
17225 static const String F5 = "F5"; | |
17226 | |
17227 /** The F6 key */ | |
17228 static const String F6 = "F6"; | |
17229 | |
17230 /** The F7 key */ | |
17231 static const String F7 = "F7"; | |
17232 | |
17233 /** The F8 key */ | |
17234 static const String F8 = "F8"; | |
17235 | |
17236 /** The F9 key */ | |
17237 static const String F9 = "F9"; | |
17238 | |
17239 /** The F10 key */ | |
17240 static const String F10 = "F10"; | |
17241 | |
17242 /** The F11 key */ | |
17243 static const String F11 = "F11"; | |
17244 | |
17245 /** The F12 key */ | |
17246 static const String F12 = "F12"; | |
17247 | |
17248 /** The F13 key */ | |
17249 static const String F13 = "F13"; | |
17250 | |
17251 /** The F14 key */ | |
17252 static const String F14 = "F14"; | |
17253 | |
17254 /** The F15 key */ | |
17255 static const String F15 = "F15"; | |
17256 | |
17257 /** The F16 key */ | |
17258 static const String F16 = "F16"; | |
17259 | |
17260 /** The F17 key */ | |
17261 static const String F17 = "F17"; | |
17262 | |
17263 /** The F18 key */ | |
17264 static const String F18 = "F18"; | |
17265 | |
17266 /** The F19 key */ | |
17267 static const String F19 = "F19"; | |
17268 | |
17269 /** The F20 key */ | |
17270 static const String F20 = "F20"; | |
17271 | |
17272 /** The F21 key */ | |
17273 static const String F21 = "F21"; | |
17274 | |
17275 /** The F22 key */ | |
17276 static const String F22 = "F22"; | |
17277 | |
17278 /** The F23 key */ | |
17279 static const String F23 = "F23"; | |
17280 | |
17281 /** The F24 key */ | |
17282 static const String F24 = "F24"; | |
17283 | |
17284 /** The Final Mode (Final) key used on some asian keyboards */ | |
17285 static const String FINAL_MODE = "FinalMode"; | |
17286 | |
17287 /** The Find key */ | |
17288 static const String FIND = "Find"; | |
17289 | |
17290 /** The Full-Width Characters key */ | |
17291 static const String FULL_WIDTH = "FullWidth"; | |
17292 | |
17293 /** The Half-Width Characters key */ | |
17294 static const String HALF_WIDTH = "HalfWidth"; | |
17295 | |
17296 /** The Hangul (Korean characters) Mode key */ | |
17297 static const String HANGUL_MODE = "HangulMode"; | |
17298 | |
17299 /** The Hanja (Korean characters) Mode key */ | |
17300 static const String HANJA_MODE = "HanjaMode"; | |
17301 | |
17302 /** The Help key */ | |
17303 static const String HELP = "Help"; | |
17304 | |
17305 /** The Hiragana (Japanese Kana characters) key */ | |
17306 static const String HIRAGANA = "Hiragana"; | |
17307 | |
17308 /** The Home key */ | |
17309 static const String HOME = "Home"; | |
17310 | |
17311 /** The Insert (Ins) key */ | |
17312 static const String INSERT = "Insert"; | |
17313 | |
17314 /** The Japanese-Hiragana key */ | |
17315 static const String JAPANESE_HIRAGANA = "JapaneseHiragana"; | |
17316 | |
17317 /** The Japanese-Katakana key */ | |
17318 static const String JAPANESE_KATAKANA = "JapaneseKatakana"; | |
17319 | |
17320 /** The Japanese-Romaji key */ | |
17321 static const String JAPANESE_ROMAJI = "JapaneseRomaji"; | |
17322 | |
17323 /** The Junja Mode key */ | |
17324 static const String JUNJA_MODE = "JunjaMode"; | |
17325 | |
17326 /** The Kana Mode (Kana Lock) key */ | |
17327 static const String KANA_MODE = "KanaMode"; | |
17328 | |
17329 /** | |
17330 * The Kanji (Japanese name for ideographic characters of Chinese origin) | |
17331 * Mode key | |
17332 */ | |
17333 static const String KANJI_MODE = "KanjiMode"; | |
17334 | |
17335 /** The Katakana (Japanese Kana characters) key */ | |
17336 static const String KATAKANA = "Katakana"; | |
17337 | |
17338 /** The Start Application One key */ | |
17339 static const String LAUNCH_APPLICATION_1 = "LaunchApplication1"; | |
17340 | |
17341 /** The Start Application Two key */ | |
17342 static const String LAUNCH_APPLICATION_2 = "LaunchApplication2"; | |
17343 | |
17344 /** The Start Mail key */ | |
17345 static const String LAUNCH_MAIL = "LaunchMail"; | |
17346 | |
17347 /** The Left Arrow key */ | |
17348 static const String LEFT = "Left"; | |
17349 | |
17350 /** The Menu key */ | |
17351 static const String MENU = "Menu"; | |
17352 | |
17353 /** | |
17354 * The Meta key. Note: This key value shall be also used for the Apple | |
17355 * Command key | |
17356 */ | |
17357 static const String META = "Meta"; | |
17358 | |
17359 /** The Media Next Track key */ | |
17360 static const String MEDIA_NEXT_TRACK = "MediaNextTrack"; | |
17361 | |
17362 /** The Media Play Pause key */ | |
17363 static const String MEDIA_PAUSE_PLAY = "MediaPlayPause"; | |
17364 | |
17365 /** The Media Previous Track key */ | |
17366 static const String MEDIA_PREVIOUS_TRACK = "MediaPreviousTrack"; | |
17367 | |
17368 /** The Media Stop key */ | |
17369 static const String MEDIA_STOP = "MediaStop"; | |
17370 | |
17371 /** The Mode Change key */ | |
17372 static const String MODE_CHANGE = "ModeChange"; | |
17373 | |
17374 /** The Next Candidate function key */ | |
17375 static const String NEXT_CANDIDATE = "NextCandidate"; | |
17376 | |
17377 /** The Nonconvert (Don't Convert) key */ | |
17378 static const String NON_CONVERT = "Nonconvert"; | |
17379 | |
17380 /** The Number Lock key */ | |
17381 static const String NUM_LOCK = "NumLock"; | |
17382 | |
17383 /** The Page Down (Next) key */ | |
17384 static const String PAGE_DOWN = "PageDown"; | |
17385 | |
17386 /** The Page Up key */ | |
17387 static const String PAGE_UP = "PageUp"; | |
17388 | |
17389 /** The Paste key */ | |
17390 static const String PASTE = "Paste"; | |
17391 | |
17392 /** The Pause key */ | |
17393 static const String PAUSE = "Pause"; | |
17394 | |
17395 /** The Play key */ | |
17396 static const String PLAY = "Play"; | |
17397 | |
17398 /** | |
17399 * The Power key. Note: Some devices may not expose this key to the | |
17400 * operating environment | |
17401 */ | |
17402 static const String POWER = "Power"; | |
17403 | |
17404 /** The Previous Candidate function key */ | |
17405 static const String PREVIOUS_CANDIDATE = "PreviousCandidate"; | |
17406 | |
17407 /** The Print Screen (PrintScrn, SnapShot) key */ | |
17408 static const String PRINT_SCREEN = "PrintScreen"; | |
17409 | |
17410 /** The Process key */ | |
17411 static const String PROCESS = "Process"; | |
17412 | |
17413 /** The Props key */ | |
17414 static const String PROPS = "Props"; | |
17415 | |
17416 /** The Right Arrow key */ | |
17417 static const String RIGHT = "Right"; | |
17418 | |
17419 /** The Roman Characters function key */ | |
17420 static const String ROMAN_CHARACTERS = "RomanCharacters"; | |
17421 | |
17422 /** The Scroll Lock key */ | |
17423 static const String SCROLL = "Scroll"; | |
17424 | |
17425 /** The Select key */ | |
17426 static const String SELECT = "Select"; | |
17427 | |
17428 /** The Select Media key */ | |
17429 static const String SELECT_MEDIA = "SelectMedia"; | |
17430 | |
17431 /** The Separator key */ | |
17432 static const String SEPARATOR = "Separator"; | |
17433 | |
17434 /** The Shift key */ | |
17435 static const String SHIFT = "Shift"; | |
17436 | |
17437 /** The Soft1 key */ | |
17438 static const String SOFT_1 = "Soft1"; | |
17439 | |
17440 /** The Soft2 key */ | |
17441 static const String SOFT_2 = "Soft2"; | |
17442 | |
17443 /** The Soft3 key */ | |
17444 static const String SOFT_3 = "Soft3"; | |
17445 | |
17446 /** The Soft4 key */ | |
17447 static const String SOFT_4 = "Soft4"; | |
17448 | |
17449 /** The Stop key */ | |
17450 static const String STOP = "Stop"; | |
17451 | |
17452 /** The Subtract key */ | |
17453 static const String SUBTRACT = "Subtract"; | |
17454 | |
17455 /** The Symbol Lock key */ | |
17456 static const String SYMBOL_LOCK = "SymbolLock"; | |
17457 | |
17458 /** The Up Arrow key */ | |
17459 static const String UP = "Up"; | |
17460 | |
17461 /** The diagonal Up-Left Arrow key */ | |
17462 static const String UP_LEFT = "UpLeft"; | |
17463 | |
17464 /** The diagonal Up-Right Arrow key */ | |
17465 static const String UP_RIGHT = "UpRight"; | |
17466 | |
17467 /** The Undo key */ | |
17468 static const String UNDO = "Undo"; | |
17469 | |
17470 /** The Volume Down key */ | |
17471 static const String VOLUME_DOWN = "VolumeDown"; | |
17472 | |
17473 /** The Volume Mute key */ | |
17474 static const String VOLUMN_MUTE = "VolumeMute"; | |
17475 | |
17476 /** The Volume Up key */ | |
17477 static const String VOLUMN_UP = "VolumeUp"; | |
17478 | |
17479 /** The Windows Logo key */ | |
17480 static const String WIN = "Win"; | |
17481 | |
17482 /** The Zoom key */ | |
17483 static const String ZOOM = "Zoom"; | |
17484 | |
17485 /** | |
17486 * The Backspace (Back) key. Note: This key value shall be also used for the | |
17487 * key labeled 'delete' MacOS keyboards when not modified by the 'Fn' key | |
17488 */ | |
17489 static const String BACKSPACE = "Backspace"; | |
17490 | |
17491 /** The Horizontal Tabulation (Tab) key */ | |
17492 static const String TAB = "Tab"; | |
17493 | |
17494 /** The Cancel key */ | |
17495 static const String CANCEL = "Cancel"; | |
17496 | |
17497 /** The Escape (Esc) key */ | |
17498 static const String ESC = "Esc"; | |
17499 | |
17500 /** The Space (Spacebar) key: */ | |
17501 static const String SPACEBAR = "Spacebar"; | |
17502 | |
17503 /** | |
17504 * The Delete (Del) Key. Note: This key value shall be also used for the key | |
17505 * labeled 'delete' MacOS keyboards when modified by the 'Fn' key | |
17506 */ | |
17507 static const String DEL = "Del"; | |
17508 | |
17509 /** The Combining Grave Accent (Greek Varia, Dead Grave) key */ | |
17510 static const String DEAD_GRAVE = "DeadGrave"; | |
17511 | |
17512 /** | |
17513 * The Combining Acute Accent (Stress Mark, Greek Oxia, Tonos, Dead Eacute) | |
17514 * key | |
17515 */ | |
17516 static const String DEAD_EACUTE = "DeadEacute"; | |
17517 | |
17518 /** The Combining Circumflex Accent (Hat, Dead Circumflex) key */ | |
17519 static const String DEAD_CIRCUMFLEX = "DeadCircumflex"; | |
17520 | |
17521 /** The Combining Tilde (Dead Tilde) key */ | |
17522 static const String DEAD_TILDE = "DeadTilde"; | |
17523 | |
17524 /** The Combining Macron (Long, Dead Macron) key */ | |
17525 static const String DEAD_MACRON = "DeadMacron"; | |
17526 | |
17527 /** The Combining Breve (Short, Dead Breve) key */ | |
17528 static const String DEAD_BREVE = "DeadBreve"; | |
17529 | |
17530 /** The Combining Dot Above (Derivative, Dead Above Dot) key */ | |
17531 static const String DEAD_ABOVE_DOT = "DeadAboveDot"; | |
17532 | |
17533 /** | |
17534 * The Combining Diaeresis (Double Dot Abode, Umlaut, Greek Dialytika, | |
17535 * Double Derivative, Dead Diaeresis) key | |
17536 */ | |
17537 static const String DEAD_UMLAUT = "DeadUmlaut"; | |
17538 | |
17539 /** The Combining Ring Above (Dead Above Ring) key */ | |
17540 static const String DEAD_ABOVE_RING = "DeadAboveRing"; | |
17541 | |
17542 /** The Combining Double Acute Accent (Dead Doubleacute) key */ | |
17543 static const String DEAD_DOUBLEACUTE = "DeadDoubleacute"; | |
17544 | |
17545 /** The Combining Caron (Hacek, V Above, Dead Caron) key */ | |
17546 static const String DEAD_CARON = "DeadCaron"; | |
17547 | |
17548 /** The Combining Cedilla (Dead Cedilla) key */ | |
17549 static const String DEAD_CEDILLA = "DeadCedilla"; | |
17550 | |
17551 /** The Combining Ogonek (Nasal Hook, Dead Ogonek) key */ | |
17552 static const String DEAD_OGONEK = "DeadOgonek"; | |
17553 | |
17554 /** | |
17555 * The Combining Greek Ypogegrammeni (Greek Non-Spacing Iota Below, Iota | |
17556 * Subscript, Dead Iota) key | |
17557 */ | |
17558 static const String DEAD_IOTA = "DeadIota"; | |
17559 | |
17560 /** | |
17561 * The Combining Katakana-Hiragana Voiced Sound Mark (Dead Voiced Sound) key | |
17562 */ | |
17563 static const String DEAD_VOICED_SOUND = "DeadVoicedSound"; | |
17564 | |
17565 /** | |
17566 * The Combining Katakana-Hiragana Semi-Voiced Sound Mark (Dead Semivoiced | |
17567 * Sound) key | |
17568 */ | |
17569 static const String DEC_SEMIVOICED_SOUND= "DeadSemivoicedSound"; | |
17570 | |
17571 /** | |
17572 * Key value used when an implementation is unable to identify another key | |
17573 * value, due to either hardware, platform, or software constraints | |
17574 */ | |
17575 static const String UNIDENTIFIED = "Unidentified"; | |
17576 } | |
17577 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
17578 // for details. All rights reserved. Use of this source code is governed by a | |
17579 // BSD-style license that can be found in the LICENSE file. | |
17580 | |
17581 | |
17582 /** | |
17583 * Internal class that does the actual calculations to determine keyCode and | |
17584 * charCode for keydown, keypress, and keyup events for all browsers. | |
17585 */ | |
17586 class _KeyboardEventHandler extends EventStreamProvider<KeyEvent> { | |
17587 // This code inspired by Closure's KeyHandling library. | |
17588 // http://closure-library.googlecode.com/svn/docs/closure_goog_events_keyhandl
er.js.source.html | |
17589 | |
17590 /** | |
17591 * The set of keys that have been pressed down without seeing their | |
17592 * corresponding keyup event. | |
17593 */ | |
17594 final List<KeyEvent> _keyDownList = <KeyEvent>[]; | |
17595 | |
17596 /** The type of KeyEvent we are tracking (keyup, keydown, keypress). */ | |
17597 final String _type; | |
17598 | |
17599 /** The element we are watching for events to happen on. */ | |
17600 final EventTarget _target; | |
17601 | |
17602 // The distance to shift from upper case alphabet Roman letters to lower case. | |
17603 static final int _ROMAN_ALPHABET_OFFSET = "a".codeUnits[0] - "A".codeUnits[0]; | |
17604 | |
17605 /** Custom Stream (Controller) to produce KeyEvents for the stream. */ | |
17606 _CustomKeyEventStreamImpl _stream; | |
17607 | |
17608 static const _EVENT_TYPE = 'KeyEvent'; | |
17609 | |
17610 /** | |
17611 * An enumeration of key identifiers currently part of the W3C draft for DOM3 | |
17612 * and their mappings to keyCodes. | |
17613 * http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set | |
17614 */ | |
17615 static const Map<String, int> _keyIdentifier = const { | |
17616 'Up': KeyCode.UP, | |
17617 'Down': KeyCode.DOWN, | |
17618 'Left': KeyCode.LEFT, | |
17619 'Right': KeyCode.RIGHT, | |
17620 'Enter': KeyCode.ENTER, | |
17621 'F1': KeyCode.F1, | |
17622 'F2': KeyCode.F2, | |
17623 'F3': KeyCode.F3, | |
17624 'F4': KeyCode.F4, | |
17625 'F5': KeyCode.F5, | |
17626 'F6': KeyCode.F6, | |
17627 'F7': KeyCode.F7, | |
17628 'F8': KeyCode.F8, | |
17629 'F9': KeyCode.F9, | |
17630 'F10': KeyCode.F10, | |
17631 'F11': KeyCode.F11, | |
17632 'F12': KeyCode.F12, | |
17633 'U+007F': KeyCode.DELETE, | |
17634 'Home': KeyCode.HOME, | |
17635 'End': KeyCode.END, | |
17636 'PageUp': KeyCode.PAGE_UP, | |
17637 'PageDown': KeyCode.PAGE_DOWN, | |
17638 'Insert': KeyCode.INSERT | |
17639 }; | |
17640 | |
17641 /** Return a stream for KeyEvents for the specified target. */ | |
17642 // Note: this actually functions like a factory constructor. | |
17643 CustomStream<KeyEvent> forTarget(EventTarget e, {bool useCapture: false}) { | |
17644 var handler = new _KeyboardEventHandler.initializeAllEventListeners( | |
17645 _type, e); | |
17646 return handler._stream; | |
17647 } | |
17648 | |
17649 /** | |
17650 * General constructor, performs basic initialization for our improved | |
17651 * KeyboardEvent controller. | |
17652 */ | |
17653 _KeyboardEventHandler(this._type): | |
17654 _stream = new _CustomKeyEventStreamImpl('event'), _target = null, | |
17655 super(_EVENT_TYPE); | |
17656 | |
17657 /** | |
17658 * Hook up all event listeners under the covers so we can estimate keycodes | |
17659 * and charcodes when they are not provided. | |
17660 */ | |
17661 _KeyboardEventHandler.initializeAllEventListeners(this._type, this._target) : | |
17662 super(_EVENT_TYPE) { | |
17663 throw 'Key event handling not supported in DDC'; | |
17664 /* | |
17665 Element.keyDownEvent.forTarget(_target, useCapture: true).listen( | |
17666 processKeyDown); | |
17667 Element.keyPressEvent.forTarget(_target, useCapture: true).listen( | |
17668 processKeyPress); | |
17669 Element.keyUpEvent.forTarget(_target, useCapture: true).listen( | |
17670 processKeyUp); | |
17671 _stream = new _CustomKeyEventStreamImpl(_type); | |
17672 */ | |
17673 } | |
17674 | |
17675 /** Determine if caps lock is one of the currently depressed keys. */ | |
17676 bool get _capsLockOn => | |
17677 _keyDownList.any((var element) => element.keyCode == KeyCode.CAPS_LOCK); | |
17678 | |
17679 /** | |
17680 * Given the previously recorded keydown key codes, see if we can determine | |
17681 * the keycode of this keypress [event]. (Generally browsers only provide | |
17682 * charCode information for keypress events, but with a little | |
17683 * reverse-engineering, we can also determine the keyCode.) Returns | |
17684 * KeyCode.UNKNOWN if the keycode could not be determined. | |
17685 */ | |
17686 int _determineKeyCodeForKeypress(KeyboardEvent event) { | |
17687 // Note: This function is a work in progress. We'll expand this function | |
17688 // once we get more information about other keyboards. | |
17689 for (var prevEvent in _keyDownList) { | |
17690 if (prevEvent._shadowCharCode == event.charCode) { | |
17691 return prevEvent.keyCode; | |
17692 } | |
17693 if ((event.shiftKey || _capsLockOn) && event.charCode >= "A".codeUnits[0] | |
17694 && event.charCode <= "Z".codeUnits[0] && event.charCode + | |
17695 _ROMAN_ALPHABET_OFFSET == prevEvent._shadowCharCode) { | |
17696 return prevEvent.keyCode; | |
17697 } | |
17698 } | |
17699 return KeyCode.UNKNOWN; | |
17700 } | |
17701 | |
17702 /** | |
17703 * Given the charater code returned from a keyDown [event], try to ascertain | |
17704 * and return the corresponding charCode for the character that was pressed. | |
17705 * This information is not shown to the user, but used to help polyfill | |
17706 * keypress events. | |
17707 */ | |
17708 int _findCharCodeKeyDown(KeyboardEvent event) { | |
17709 if (event.keyLocation == 3) { // Numpad keys. | |
17710 switch (event.keyCode) { | |
17711 case KeyCode.NUM_ZERO: | |
17712 // Even though this function returns _charCodes_, for some cases the | |
17713 // KeyCode == the charCode we want, in which case we use the keycode | |
17714 // constant for readability. | |
17715 return KeyCode.ZERO; | |
17716 case KeyCode.NUM_ONE: | |
17717 return KeyCode.ONE; | |
17718 case KeyCode.NUM_TWO: | |
17719 return KeyCode.TWO; | |
17720 case KeyCode.NUM_THREE: | |
17721 return KeyCode.THREE; | |
17722 case KeyCode.NUM_FOUR: | |
17723 return KeyCode.FOUR; | |
17724 case KeyCode.NUM_FIVE: | |
17725 return KeyCode.FIVE; | |
17726 case KeyCode.NUM_SIX: | |
17727 return KeyCode.SIX; | |
17728 case KeyCode.NUM_SEVEN: | |
17729 return KeyCode.SEVEN; | |
17730 case KeyCode.NUM_EIGHT: | |
17731 return KeyCode.EIGHT; | |
17732 case KeyCode.NUM_NINE: | |
17733 return KeyCode.NINE; | |
17734 case KeyCode.NUM_MULTIPLY: | |
17735 return 42; // Char code for * | |
17736 case KeyCode.NUM_PLUS: | |
17737 return 43; // + | |
17738 case KeyCode.NUM_MINUS: | |
17739 return 45; // - | |
17740 case KeyCode.NUM_PERIOD: | |
17741 return 46; // . | |
17742 case KeyCode.NUM_DIVISION: | |
17743 return 47; // / | |
17744 } | |
17745 } else if (event.keyCode >= 65 && event.keyCode <= 90) { | |
17746 // Set the "char code" for key down as the lower case letter. Again, this | |
17747 // will not show up for the user, but will be helpful in estimating | |
17748 // keyCode locations and other information during the keyPress event. | |
17749 return event.keyCode + _ROMAN_ALPHABET_OFFSET; | |
17750 } | |
17751 switch(event.keyCode) { | |
17752 case KeyCode.SEMICOLON: | |
17753 return KeyCode.FF_SEMICOLON; | |
17754 case KeyCode.EQUALS: | |
17755 return KeyCode.FF_EQUALS; | |
17756 case KeyCode.COMMA: | |
17757 return 44; // Ascii value for , | |
17758 case KeyCode.DASH: | |
17759 return 45; // - | |
17760 case KeyCode.PERIOD: | |
17761 return 46; // . | |
17762 case KeyCode.SLASH: | |
17763 return 47; // / | |
17764 case KeyCode.APOSTROPHE: | |
17765 return 96; // ` | |
17766 case KeyCode.OPEN_SQUARE_BRACKET: | |
17767 return 91; // [ | |
17768 case KeyCode.BACKSLASH: | |
17769 return 92; // \ | |
17770 case KeyCode.CLOSE_SQUARE_BRACKET: | |
17771 return 93; // ] | |
17772 case KeyCode.SINGLE_QUOTE: | |
17773 return 39; // ' | |
17774 } | |
17775 return event.keyCode; | |
17776 } | |
17777 | |
17778 /** | |
17779 * Returns true if the key fires a keypress event in the current browser. | |
17780 */ | |
17781 bool _firesKeyPressEvent(KeyEvent event) { | |
17782 if (!Device.isIE && !Device.isWebKit) { | |
17783 return true; | |
17784 } | |
17785 | |
17786 if (Device.userAgent.contains('Mac') && event.altKey) { | |
17787 return KeyCode.isCharacterKey(event.keyCode); | |
17788 } | |
17789 | |
17790 // Alt but not AltGr which is represented as Alt+Ctrl. | |
17791 if (event.altKey && !event.ctrlKey) { | |
17792 return false; | |
17793 } | |
17794 | |
17795 // Saves Ctrl or Alt + key for IE and WebKit, which won't fire keypress. | |
17796 if (!event.shiftKey && | |
17797 (_keyDownList.last.keyCode == KeyCode.CTRL || | |
17798 _keyDownList.last.keyCode == KeyCode.ALT || | |
17799 Device.userAgent.contains('Mac') && | |
17800 _keyDownList.last.keyCode == KeyCode.META)) { | |
17801 return false; | |
17802 } | |
17803 | |
17804 // Some keys with Ctrl/Shift do not issue keypress in WebKit. | |
17805 if (Device.isWebKit && event.ctrlKey && event.shiftKey && ( | |
17806 event.keyCode == KeyCode.BACKSLASH || | |
17807 event.keyCode == KeyCode.OPEN_SQUARE_BRACKET || | |
17808 event.keyCode == KeyCode.CLOSE_SQUARE_BRACKET || | |
17809 event.keyCode == KeyCode.TILDE || | |
17810 event.keyCode == KeyCode.SEMICOLON || event.keyCode == KeyCode.DASH || | |
17811 event.keyCode == KeyCode.EQUALS || event.keyCode == KeyCode.COMMA || | |
17812 event.keyCode == KeyCode.PERIOD || event.keyCode == KeyCode.SLASH || | |
17813 event.keyCode == KeyCode.APOSTROPHE || | |
17814 event.keyCode == KeyCode.SINGLE_QUOTE)) { | |
17815 return false; | |
17816 } | |
17817 | |
17818 switch (event.keyCode) { | |
17819 case KeyCode.ENTER: | |
17820 // IE9 does not fire keypress on ENTER. | |
17821 return !Device.isIE; | |
17822 case KeyCode.ESC: | |
17823 return !Device.isWebKit; | |
17824 } | |
17825 | |
17826 return KeyCode.isCharacterKey(event.keyCode); | |
17827 } | |
17828 | |
17829 /** | |
17830 * Normalize the keycodes to the IE KeyCodes (this is what Chrome, IE, and | |
17831 * Opera all use). | |
17832 */ | |
17833 int _normalizeKeyCodes(KeyboardEvent event) { | |
17834 // Note: This may change once we get input about non-US keyboards. | |
17835 if (Device.isFirefox) { | |
17836 switch(event.keyCode) { | |
17837 case KeyCode.FF_EQUALS: | |
17838 return KeyCode.EQUALS; | |
17839 case KeyCode.FF_SEMICOLON: | |
17840 return KeyCode.SEMICOLON; | |
17841 case KeyCode.MAC_FF_META: | |
17842 return KeyCode.META; | |
17843 case KeyCode.WIN_KEY_FF_LINUX: | |
17844 return KeyCode.WIN_KEY; | |
17845 } | |
17846 } | |
17847 return event.keyCode; | |
17848 } | |
17849 | |
17850 /** Handle keydown events. */ | |
17851 void processKeyDown(KeyboardEvent e) { | |
17852 // Ctrl-Tab and Alt-Tab can cause the focus to be moved to another window | |
17853 // before we've caught a key-up event. If the last-key was one of these | |
17854 // we reset the state. | |
17855 if (_keyDownList.length > 0 && | |
17856 (_keyDownList.last.keyCode == KeyCode.CTRL && !e.ctrlKey || | |
17857 _keyDownList.last.keyCode == KeyCode.ALT && !e.altKey || | |
17858 Device.userAgent.contains('Mac') && | |
17859 _keyDownList.last.keyCode == KeyCode.META && !e.metaKey)) { | |
17860 _keyDownList.clear(); | |
17861 } | |
17862 | |
17863 var event = new KeyEvent.wrap(e); | |
17864 event._shadowKeyCode = _normalizeKeyCodes(event); | |
17865 // Technically a "keydown" event doesn't have a charCode. This is | |
17866 // calculated nonetheless to provide us with more information in giving | |
17867 // as much information as possible on keypress about keycode and also | |
17868 // charCode. | |
17869 event._shadowCharCode = _findCharCodeKeyDown(event); | |
17870 if (_keyDownList.length > 0 && event.keyCode != _keyDownList.last.keyCode && | |
17871 !_firesKeyPressEvent(event)) { | |
17872 // Some browsers have quirks not firing keypress events where all other | |
17873 // browsers do. This makes them more consistent. | |
17874 processKeyPress(e); | |
17875 } | |
17876 _keyDownList.add(event); | |
17877 _stream.add(event); | |
17878 } | |
17879 | |
17880 /** Handle keypress events. */ | |
17881 void processKeyPress(KeyboardEvent event) { | |
17882 var e = new KeyEvent.wrap(event); | |
17883 // IE reports the character code in the keyCode field for keypress events. | |
17884 // There are two exceptions however, Enter and Escape. | |
17885 if (Device.isIE) { | |
17886 if (e.keyCode == KeyCode.ENTER || e.keyCode == KeyCode.ESC) { | |
17887 e._shadowCharCode = 0; | |
17888 } else { | |
17889 e._shadowCharCode = e.keyCode; | |
17890 } | |
17891 } else if (Device.isOpera) { | |
17892 // Opera reports the character code in the keyCode field. | |
17893 e._shadowCharCode = KeyCode.isCharacterKey(e.keyCode) ? e.keyCode : 0; | |
17894 } | |
17895 // Now we guestimate about what the keycode is that was actually | |
17896 // pressed, given previous keydown information. | |
17897 e._shadowKeyCode = _determineKeyCodeForKeypress(e); | |
17898 | |
17899 // Correct the key value for certain browser-specific quirks. | |
17900 if (e._shadowKeyIdentifier != null && | |
17901 _keyIdentifier.containsKey(e._shadowKeyIdentifier)) { | |
17902 // This is needed for Safari Windows because it currently doesn't give a | |
17903 // keyCode/which for non printable keys. | |
17904 e._shadowKeyCode = _keyIdentifier[e._shadowKeyIdentifier]; | |
17905 } | |
17906 e._shadowAltKey = _keyDownList.any((var element) => element.altKey); | |
17907 _stream.add(e); | |
17908 } | |
17909 | |
17910 /** Handle keyup events. */ | |
17911 void processKeyUp(KeyboardEvent event) { | |
17912 var e = new KeyEvent.wrap(event); | |
17913 KeyboardEvent toRemove = null; | |
17914 for (var key in _keyDownList) { | |
17915 if (key.keyCode == e.keyCode) { | |
17916 toRemove = key; | |
17917 } | |
17918 } | |
17919 if (toRemove != null) { | |
17920 _keyDownList.removeWhere((element) => element == toRemove); | |
17921 } else if (_keyDownList.length > 0) { | |
17922 // This happens when we've reached some international keyboard case we | |
17923 // haven't accounted for or we haven't correctly eliminated all browser | |
17924 // inconsistencies. Filing bugs on when this is reached is welcome! | |
17925 _keyDownList.removeLast(); | |
17926 } | |
17927 _stream.add(e); | |
17928 } | |
17929 } | |
17930 | |
17931 | |
17932 /** | |
17933 * Records KeyboardEvents that occur on a particular element, and provides a | |
17934 * stream of outgoing KeyEvents with cross-browser consistent keyCode and | |
17935 * charCode values despite the fact that a multitude of browsers that have | |
17936 * varying keyboard default behavior. | |
17937 * | |
17938 * Example usage: | |
17939 * | |
17940 * KeyboardEventStream.onKeyDown(document.body).listen( | |
17941 * keydownHandlerTest); | |
17942 * | |
17943 * This class is very much a work in progress, and we'd love to get information | |
17944 * on how we can make this class work with as many international keyboards as | |
17945 * possible. Bugs welcome! | |
17946 */ | |
17947 class KeyboardEventStream { | |
17948 | |
17949 /** Named constructor to produce a stream for onKeyPress events. */ | |
17950 static CustomStream<KeyEvent> onKeyPress(EventTarget target) => | |
17951 new _KeyboardEventHandler('keypress').forTarget(target); | |
17952 | |
17953 /** Named constructor to produce a stream for onKeyUp events. */ | |
17954 static CustomStream<KeyEvent> onKeyUp(EventTarget target) => | |
17955 new _KeyboardEventHandler('keyup').forTarget(target); | |
17956 | |
17957 /** Named constructor to produce a stream for onKeyDown events. */ | |
17958 static CustomStream<KeyEvent> onKeyDown(EventTarget target) => | |
17959 new _KeyboardEventHandler('keydown').forTarget(target); | |
17960 } | |
17961 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
17962 // for details. All rights reserved. Use of this source code is governed by a | |
17963 // BSD-style license that can be found in the LICENSE file. | |
17964 | |
17965 | |
17966 | |
17967 /** | |
17968 * Class which helps construct standard node validation policies. | |
17969 * | |
17970 * By default this will not accept anything, but the 'allow*' functions can be | |
17971 * used to expand what types of elements or attributes are allowed. | |
17972 * | |
17973 * All allow functions are additive- elements will be accepted if they are | |
17974 * accepted by any specific rule. | |
17975 * | |
17976 * It is important to remember that sanitization is not just intended to prevent | |
17977 * cross-site scripting attacks, but also to prevent information from being | |
17978 * displayed in unexpected ways. For example something displaying basic | |
17979 * formatted text may not expect `<video>` tags to appear. In this case an | |
17980 * empty NodeValidatorBuilder with just [allowTextElements] might be | |
17981 * appropriate. | |
17982 */ | |
17983 class NodeValidatorBuilder implements NodeValidator { | |
17984 | |
17985 final List<NodeValidator> _validators = <NodeValidator>[]; | |
17986 | |
17987 NodeValidatorBuilder() { | |
17988 } | |
17989 | |
17990 /** | |
17991 * Creates a new NodeValidatorBuilder which accepts common constructs. | |
17992 * | |
17993 * By default this will accept HTML5 elements and attributes with the default | |
17994 * [UriPolicy] and templating elements. | |
17995 * | |
17996 * Notable syntax which is filtered: | |
17997 * | |
17998 * * Only known-good HTML5 elements and attributes are allowed. | |
17999 * * All URLs must be same-origin, use [allowNavigation] and [allowImages] to | |
18000 * specify additional URI policies. | |
18001 * * Inline-styles are not allowed. | |
18002 * * Custom element tags are disallowed, use [allowCustomElement]. | |
18003 * * Custom tags extensions are disallowed, use [allowTagExtension]. | |
18004 * * SVG Elements are not allowed, use [allowSvg]. | |
18005 * | |
18006 * For scenarios where the HTML should only contain formatted text | |
18007 * [allowTextElements] is more appropriate. | |
18008 * | |
18009 * Use [allowSvg] to allow SVG elements. | |
18010 */ | |
18011 NodeValidatorBuilder.common() { | |
18012 allowHtml5(); | |
18013 allowTemplating(); | |
18014 } | |
18015 | |
18016 /** | |
18017 * Allows navigation elements- Form and Anchor tags, along with common | |
18018 * attributes. | |
18019 * | |
18020 * The UriPolicy can be used to restrict the locations the navigation elements | |
18021 * are allowed to direct to. By default this will use the default [UriPolicy]. | |
18022 */ | |
18023 void allowNavigation([UriPolicy uriPolicy]) { | |
18024 if (uriPolicy == null) { | |
18025 uriPolicy = new UriPolicy(); | |
18026 } | |
18027 add(new _SimpleNodeValidator.allowNavigation(uriPolicy)); | |
18028 } | |
18029 | |
18030 /** | |
18031 * Allows image elements. | |
18032 * | |
18033 * The UriPolicy can be used to restrict the locations the images may be | |
18034 * loaded from. By default this will use the default [UriPolicy]. | |
18035 */ | |
18036 void allowImages([UriPolicy uriPolicy]) { | |
18037 if (uriPolicy == null) { | |
18038 uriPolicy = new UriPolicy(); | |
18039 } | |
18040 add(new _SimpleNodeValidator.allowImages(uriPolicy)); | |
18041 } | |
18042 | |
18043 /** | |
18044 * Allow basic text elements. | |
18045 * | |
18046 * This allows a subset of HTML5 elements, specifically just these tags and | |
18047 * no attributes. | |
18048 * | |
18049 * * B | |
18050 * * BLOCKQUOTE | |
18051 * * BR | |
18052 * * EM | |
18053 * * H1 | |
18054 * * H2 | |
18055 * * H3 | |
18056 * * H4 | |
18057 * * H5 | |
18058 * * H6 | |
18059 * * HR | |
18060 * * I | |
18061 * * LI | |
18062 * * OL | |
18063 * * P | |
18064 * * SPAN | |
18065 * * UL | |
18066 */ | |
18067 void allowTextElements() { | |
18068 add(new _SimpleNodeValidator.allowTextElements()); | |
18069 } | |
18070 | |
18071 /** | |
18072 * Allow inline styles on elements. | |
18073 * | |
18074 * If [tagName] is not specified then this allows inline styles on all | |
18075 * elements. Otherwise tagName limits the styles to the specified elements. | |
18076 */ | |
18077 void allowInlineStyles({String tagName}) { | |
18078 if (tagName == null) { | |
18079 tagName = '*'; | |
18080 } else { | |
18081 tagName = tagName.toUpperCase(); | |
18082 } | |
18083 add(new _SimpleNodeValidator(null, allowedAttributes: ['$tagName::style'])); | |
18084 } | |
18085 | |
18086 /** | |
18087 * Allow common safe HTML5 elements and attributes. | |
18088 * | |
18089 * This list is based off of the Caja whitelists at: | |
18090 * https://code.google.com/p/google-caja/wiki/CajaWhitelists. | |
18091 * | |
18092 * Common things which are not allowed are script elements, style attributes | |
18093 * and any script handlers. | |
18094 */ | |
18095 void allowHtml5({UriPolicy uriPolicy}) { | |
18096 add(new _Html5NodeValidator(uriPolicy: uriPolicy)); | |
18097 } | |
18098 | |
18099 /** | |
18100 * Allow SVG elements and attributes except for known bad ones. | |
18101 */ | |
18102 void allowSvg() { | |
18103 throw 'SVG not supported with DDC'; | |
18104 // add(new _SvgNodeValidator()); | |
18105 } | |
18106 | |
18107 /** | |
18108 * Allow custom elements with the specified tag name and specified attributes. | |
18109 * | |
18110 * This will allow the elements as custom tags (such as <x-foo></x-foo>), | |
18111 * but will not allow tag extensions. Use [allowTagExtension] to allow | |
18112 * tag extensions. | |
18113 */ | |
18114 void allowCustomElement(String tagName, | |
18115 {UriPolicy uriPolicy, | |
18116 Iterable<String> attributes, | |
18117 Iterable<String> uriAttributes}) { | |
18118 | |
18119 var tagNameUpper = tagName.toUpperCase(); | |
18120 var attrs; | |
18121 if (attributes != null) { | |
18122 attrs = | |
18123 attributes.map((name) => '$tagNameUpper::${name.toLowerCase()}'); | |
18124 } | |
18125 var uriAttrs; | |
18126 if (uriAttributes != null) { | |
18127 uriAttrs = | |
18128 uriAttributes.map((name) => '$tagNameUpper::${name.toLowerCase()}'); | |
18129 } | |
18130 if (uriPolicy == null) { | |
18131 uriPolicy = new UriPolicy(); | |
18132 } | |
18133 | |
18134 add(new _CustomElementNodeValidator( | |
18135 uriPolicy, | |
18136 [tagNameUpper], | |
18137 attrs, | |
18138 uriAttrs, | |
18139 false, | |
18140 true)); | |
18141 } | |
18142 | |
18143 /** | |
18144 * Allow custom tag extensions with the specified type name and specified | |
18145 * attributes. | |
18146 * | |
18147 * This will allow tag extensions (such as <div is="x-foo"></div>), | |
18148 * but will not allow custom tags. Use [allowCustomElement] to allow | |
18149 * custom tags. | |
18150 */ | |
18151 void allowTagExtension(String tagName, String baseName, | |
18152 {UriPolicy uriPolicy, | |
18153 Iterable<String> attributes, | |
18154 Iterable<String> uriAttributes}) { | |
18155 | |
18156 var baseNameUpper = baseName.toUpperCase(); | |
18157 var tagNameUpper = tagName.toUpperCase(); | |
18158 var attrs; | |
18159 if (attributes != null) { | |
18160 attrs = | |
18161 attributes.map((name) => '$baseNameUpper::${name.toLowerCase()}'); | |
18162 } | |
18163 var uriAttrs; | |
18164 if (uriAttributes != null) { | |
18165 uriAttrs = | |
18166 uriAttributes.map((name) => '$baseNameUpper::${name.toLowerCase()}'); | |
18167 } | |
18168 if (uriPolicy == null) { | |
18169 uriPolicy = new UriPolicy(); | |
18170 } | |
18171 | |
18172 add(new _CustomElementNodeValidator( | |
18173 uriPolicy, | |
18174 [tagNameUpper, baseNameUpper], | |
18175 attrs, | |
18176 uriAttrs, | |
18177 true, | |
18178 false)); | |
18179 } | |
18180 | |
18181 void allowElement(String tagName, {UriPolicy uriPolicy, | |
18182 Iterable<String> attributes, | |
18183 Iterable<String> uriAttributes}) { | |
18184 | |
18185 allowCustomElement(tagName, uriPolicy: uriPolicy, | |
18186 attributes: attributes, | |
18187 uriAttributes: uriAttributes); | |
18188 } | |
18189 | |
18190 /** | |
18191 * Allow templating elements (such as <template> and template-related | |
18192 * attributes. | |
18193 * | |
18194 * This still requires other validators to allow regular attributes to be | |
18195 * bound (such as [allowHtml5]). | |
18196 */ | |
18197 void allowTemplating() { | |
18198 add(new _TemplatingNodeValidator()); | |
18199 } | |
18200 | |
18201 /** | |
18202 * Add an additional validator to the current list of validators. | |
18203 * | |
18204 * Elements and attributes will be accepted if they are accepted by any | |
18205 * validators. | |
18206 */ | |
18207 void add(NodeValidator validator) { | |
18208 _validators.add(validator); | |
18209 } | |
18210 | |
18211 bool allowsElement(Element element) { | |
18212 return _validators.any((v) => v.allowsElement(element)); | |
18213 } | |
18214 | |
18215 bool allowsAttribute(Element element, String attributeName, String value) { | |
18216 return _validators.any( | |
18217 (v) => v.allowsAttribute(element, attributeName, value)); | |
18218 } | |
18219 } | |
18220 | |
18221 class _SimpleNodeValidator implements NodeValidator { | |
18222 final Set<String> allowedElements = new Set<String>(); | |
18223 final Set<String> allowedAttributes = new Set<String>(); | |
18224 final Set<String> allowedUriAttributes = new Set<String>(); | |
18225 final UriPolicy uriPolicy; | |
18226 | |
18227 factory _SimpleNodeValidator.allowNavigation(UriPolicy uriPolicy) { | |
18228 return new _SimpleNodeValidator(uriPolicy, | |
18229 allowedElements: const [ | |
18230 'A', | |
18231 'FORM'], | |
18232 allowedAttributes: const [ | |
18233 'A::accesskey', | |
18234 'A::coords', | |
18235 'A::hreflang', | |
18236 'A::name', | |
18237 'A::shape', | |
18238 'A::tabindex', | |
18239 'A::target', | |
18240 'A::type', | |
18241 'FORM::accept', | |
18242 'FORM::autocomplete', | |
18243 'FORM::enctype', | |
18244 'FORM::method', | |
18245 'FORM::name', | |
18246 'FORM::novalidate', | |
18247 'FORM::target', | |
18248 ], | |
18249 allowedUriAttributes: const [ | |
18250 'A::href', | |
18251 'FORM::action', | |
18252 ]); | |
18253 } | |
18254 | |
18255 factory _SimpleNodeValidator.allowImages(UriPolicy uriPolicy) { | |
18256 return new _SimpleNodeValidator(uriPolicy, | |
18257 allowedElements: const [ | |
18258 'IMG' | |
18259 ], | |
18260 allowedAttributes: const [ | |
18261 'IMG::align', | |
18262 'IMG::alt', | |
18263 'IMG::border', | |
18264 'IMG::height', | |
18265 'IMG::hspace', | |
18266 'IMG::ismap', | |
18267 'IMG::name', | |
18268 'IMG::usemap', | |
18269 'IMG::vspace', | |
18270 'IMG::width', | |
18271 ], | |
18272 allowedUriAttributes: const [ | |
18273 'IMG::src', | |
18274 ]); | |
18275 } | |
18276 | |
18277 factory _SimpleNodeValidator.allowTextElements() { | |
18278 return new _SimpleNodeValidator(null, | |
18279 allowedElements: const [ | |
18280 'B', | |
18281 'BLOCKQUOTE', | |
18282 'BR', | |
18283 'EM', | |
18284 'H1', | |
18285 'H2', | |
18286 'H3', | |
18287 'H4', | |
18288 'H5', | |
18289 'H6', | |
18290 'HR', | |
18291 'I', | |
18292 'LI', | |
18293 'OL', | |
18294 'P', | |
18295 'SPAN', | |
18296 'UL', | |
18297 ]); | |
18298 } | |
18299 | |
18300 /** | |
18301 * Elements must be uppercased tag names. For example `'IMG'`. | |
18302 * Attributes must be uppercased tag name followed by :: followed by | |
18303 * lowercase attribute name. For example `'IMG:src'`. | |
18304 */ | |
18305 _SimpleNodeValidator(this.uriPolicy, | |
18306 {Iterable<String> allowedElements, Iterable<String> allowedAttributes, | |
18307 Iterable<String> allowedUriAttributes}) { | |
18308 this.allowedElements.addAll(allowedElements ?? const []); | |
18309 allowedAttributes = allowedAttributes ?? const []; | |
18310 allowedUriAttributes = allowedUriAttributes ?? const []; | |
18311 var legalAttributes = allowedAttributes.where( | |
18312 (x) => !_Html5NodeValidator._uriAttributes.contains(x)); | |
18313 var extraUriAttributes = allowedAttributes.where( | |
18314 (x) => _Html5NodeValidator._uriAttributes.contains(x)); | |
18315 this.allowedAttributes.addAll(legalAttributes); | |
18316 this.allowedUriAttributes.addAll(allowedUriAttributes); | |
18317 this.allowedUriAttributes.addAll(extraUriAttributes); | |
18318 } | |
18319 | |
18320 bool allowsElement(Element element) { | |
18321 return allowedElements.contains(Element._safeTagName(element)); | |
18322 } | |
18323 | |
18324 bool allowsAttribute(Element element, String attributeName, String value) { | |
18325 var tagName = Element._safeTagName(element); | |
18326 if (allowedUriAttributes.contains('$tagName::$attributeName')) { | |
18327 return uriPolicy.allowsUri(value); | |
18328 } else if (allowedUriAttributes.contains('*::$attributeName')) { | |
18329 return uriPolicy.allowsUri(value); | |
18330 } else if (allowedAttributes.contains('$tagName::$attributeName')) { | |
18331 return true; | |
18332 } else if (allowedAttributes.contains('*::$attributeName')) { | |
18333 return true; | |
18334 } else if (allowedAttributes.contains('$tagName::*')) { | |
18335 return true; | |
18336 } else if (allowedAttributes.contains('*::*')) { | |
18337 return true; | |
18338 } | |
18339 return false; | |
18340 } | |
18341 } | |
18342 | |
18343 class _CustomElementNodeValidator extends _SimpleNodeValidator { | |
18344 final bool allowTypeExtension; | |
18345 final bool allowCustomTag; | |
18346 | |
18347 _CustomElementNodeValidator(UriPolicy uriPolicy, | |
18348 Iterable<String> allowedElements, | |
18349 Iterable<String> allowedAttributes, | |
18350 Iterable<String> allowedUriAttributes, | |
18351 bool allowTypeExtension, | |
18352 bool allowCustomTag): | |
18353 | |
18354 this.allowTypeExtension = allowTypeExtension == true, | |
18355 this.allowCustomTag = allowCustomTag == true, | |
18356 super(uriPolicy, | |
18357 allowedElements: allowedElements, | |
18358 allowedAttributes: allowedAttributes, | |
18359 allowedUriAttributes: allowedUriAttributes); | |
18360 | |
18361 bool allowsElement(Element element) { | |
18362 if (allowTypeExtension) { | |
18363 var isAttr = element.attributes['is']; | |
18364 if (isAttr != null) { | |
18365 return allowedElements.contains(isAttr.toUpperCase()) && | |
18366 allowedElements.contains(Element._safeTagName(element)); | |
18367 } | |
18368 } | |
18369 return allowCustomTag && allowedElements.contains(Element._safeTagName(eleme
nt)); | |
18370 } | |
18371 | |
18372 bool allowsAttribute(Element element, String attributeName, String value) { | |
18373 if (allowsElement(element)) { | |
18374 if (allowTypeExtension && attributeName == 'is' && | |
18375 allowedElements.contains(value.toUpperCase())) { | |
18376 return true; | |
18377 } | |
18378 return super.allowsAttribute(element, attributeName, value); | |
18379 } | |
18380 return false; | |
18381 } | |
18382 } | |
18383 | |
18384 class _TemplatingNodeValidator extends _SimpleNodeValidator { | |
18385 static const _TEMPLATE_ATTRS = | |
18386 const <String>['bind', 'if', 'ref', 'repeat', 'syntax']; | |
18387 | |
18388 final Set<String> _templateAttrs; | |
18389 | |
18390 _TemplatingNodeValidator(): | |
18391 _templateAttrs = new Set<String>.from(_TEMPLATE_ATTRS), | |
18392 super(null, | |
18393 allowedElements: [ | |
18394 'TEMPLATE' | |
18395 ], | |
18396 allowedAttributes: _TEMPLATE_ATTRS.map((attr) => 'TEMPLATE::$attr')); | |
18397 | |
18398 bool allowsAttribute(Element element, String attributeName, String value) { | |
18399 if (super.allowsAttribute(element, attributeName, value)) { | |
18400 return true; | |
18401 } | |
18402 | |
18403 if (attributeName == 'template' && value == "") { | |
18404 return true; | |
18405 } | |
18406 | |
18407 if (element.attributes['template'] == "" ) { | |
18408 return _templateAttrs.contains(attributeName); | |
18409 } | |
18410 return false; | |
18411 } | |
18412 } | |
18413 | |
18414 /* | |
18415 class _SvgNodeValidator implements NodeValidator { | |
18416 bool allowsElement(Element element) { | |
18417 if (element is svg.ScriptElement) { | |
18418 return false; | |
18419 } | |
18420 // Firefox 37 has issues with creating foreign elements inside a | |
18421 // foreignobject tag as SvgElement. We don't want foreignobject contents | |
18422 // anyway, so just remove the whole tree outright. And we can't rely | |
18423 // on IE recognizing the SvgForeignObject type, so go by tagName. Bug 23144 | |
18424 if (element is svg.SvgElement && Element._safeTagName(element) == 'foreignOb
ject') { | |
18425 return false; | |
18426 } | |
18427 if (element is svg.SvgElement) { | |
18428 return true; | |
18429 } | |
18430 return false; | |
18431 } | |
18432 | |
18433 bool allowsAttribute(Element element, String attributeName, String value) { | |
18434 if (attributeName == 'is' || attributeName.startsWith('on')) { | |
18435 return false; | |
18436 } | |
18437 return allowsElement(element); | |
18438 } | |
18439 } | |
18440 */// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
18441 // for details. All rights reserved. Use of this source code is governed by a | |
18442 // BSD-style license that can be found in the LICENSE file. | |
18443 | |
18444 | |
18445 /** | |
18446 * Contains the set of standard values returned by HTMLDocument.getReadyState. | |
18447 */ | |
18448 abstract class ReadyState { | |
18449 /** | |
18450 * Indicates the document is still loading and parsing. | |
18451 */ | |
18452 static const String LOADING = "loading"; | |
18453 | |
18454 /** | |
18455 * Indicates the document is finished parsing but is still loading | |
18456 * subresources. | |
18457 */ | |
18458 static const String INTERACTIVE = "interactive"; | |
18459 | |
18460 /** | |
18461 * Indicates the document and all subresources have been loaded. | |
18462 */ | |
18463 static const String COMPLETE = "complete"; | |
18464 } | |
18465 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
18466 // for details. All rights reserved. Use of this source code is governed by a | |
18467 // BSD-style license that can be found in the LICENSE file. | |
18468 | |
18469 | |
18470 /** | |
18471 * A list which just wraps another list, for either intercepting list calls or | |
18472 * retyping the list (for example, from List<A> to List<B> where B extends A). | |
18473 */ | |
18474 class _WrappedList<E extends Node> extends ListBase<E> | |
18475 implements NodeListWrapper { | |
18476 final List _list; | |
18477 | |
18478 _WrappedList(this._list); | |
18479 | |
18480 // Iterable APIs | |
18481 | |
18482 Iterator<E> get iterator => new _WrappedIterator(_list.iterator); | |
18483 | |
18484 int get length => _list.length; | |
18485 | |
18486 // Collection APIs | |
18487 | |
18488 void add(E element) { _list.add(element); } | |
18489 | |
18490 bool remove(Object element) => _list.remove(element); | |
18491 | |
18492 void clear() { _list.clear(); } | |
18493 | |
18494 // List APIs | |
18495 | |
18496 E operator [](int index) => _list[index]; | |
18497 | |
18498 void operator []=(int index, E value) { _list[index] = value; } | |
18499 | |
18500 set length(int newLength) { _list.length = newLength; } | |
18501 | |
18502 void sort([int compare(E a, E b)]) { _list.sort(compare); } | |
18503 | |
18504 int indexOf(Object element, [int start = 0]) => _list.indexOf(element, start); | |
18505 | |
18506 int lastIndexOf(Object element, [int start]) => _list.lastIndexOf(element, sta
rt); | |
18507 | |
18508 void insert(int index, E element) => _list.insert(index, element); | |
18509 | |
18510 E removeAt(int index) => _list.removeAt(index); | |
18511 | |
18512 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { | |
18513 _list.setRange(start, end, iterable, skipCount); | |
18514 } | |
18515 | |
18516 void removeRange(int start, int end) { _list.removeRange(start, end); } | |
18517 | |
18518 void replaceRange(int start, int end, Iterable<E> iterable) { | |
18519 _list.replaceRange(start, end, iterable); | |
18520 } | |
18521 | |
18522 void fillRange(int start, int end, [E fillValue]) { | |
18523 _list.fillRange(start, end, fillValue); | |
18524 } | |
18525 | |
18526 List<Node> get rawList => _list; | |
18527 } | |
18528 | |
18529 /** | |
18530 * Iterator wrapper for _WrappedList. | |
18531 */ | |
18532 class _WrappedIterator<E> implements Iterator<E> { | |
18533 Iterator _iterator; | |
18534 | |
18535 _WrappedIterator(this._iterator); | |
18536 | |
18537 bool moveNext() { | |
18538 return _iterator.moveNext(); | |
18539 } | |
18540 | |
18541 E get current => _iterator.current; | |
18542 } | |
18543 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
18544 // for details. All rights reserved. Use of this source code is governed by a | |
18545 // BSD-style license that can be found in the LICENSE file. | |
18546 | |
18547 | |
18548 class _HttpRequestUtils { | |
18549 | |
18550 // Helper for factory HttpRequest.get | |
18551 static HttpRequest get(String url, | |
18552 onComplete(HttpRequest request), | |
18553 bool withCredentials) { | |
18554 final request = new HttpRequest(); | |
18555 request.open('GET', url, async: true); | |
18556 | |
18557 request.withCredentials = withCredentials; | |
18558 | |
18559 request.onReadyStateChange.listen((e) { | |
18560 if (request.readyState == HttpRequest.DONE) { | |
18561 onComplete(request); | |
18562 } | |
18563 }); | |
18564 | |
18565 request.send(); | |
18566 | |
18567 return request; | |
18568 } | |
18569 } | |
18570 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
18571 // for details. All rights reserved. Use of this source code is governed by a | |
18572 // BSD-style license that can be found in the LICENSE file. | |
18573 | |
18574 | |
18575 // Iterator for arrays with fixed size. | |
18576 class FixedSizeListIterator<T> implements Iterator<T> { | |
18577 final List<T> _array; | |
18578 final int _length; // Cache array length for faster access. | |
18579 int _position; | |
18580 T _current; | |
18581 | |
18582 FixedSizeListIterator(List<T> array) | |
18583 : _array = array, | |
18584 _position = -1, | |
18585 _length = array.length; | |
18586 | |
18587 bool moveNext() { | |
18588 int nextPosition = _position + 1; | |
18589 if (nextPosition < _length) { | |
18590 _current = _array[nextPosition]; | |
18591 _position = nextPosition; | |
18592 return true; | |
18593 } | |
18594 _current = null; | |
18595 _position = _length; | |
18596 return false; | |
18597 } | |
18598 | |
18599 T get current => _current; | |
18600 } | |
18601 | |
18602 // Iterator for arrays with variable size. | |
18603 class _VariableSizeListIterator<T> implements Iterator<T> { | |
18604 final List<T> _array; | |
18605 int _position; | |
18606 T _current; | |
18607 | |
18608 _VariableSizeListIterator(List<T> array) | |
18609 : _array = array, | |
18610 _position = -1; | |
18611 | |
18612 bool moveNext() { | |
18613 int nextPosition = _position + 1; | |
18614 if (nextPosition < _array.length) { | |
18615 _current = _array[nextPosition]; | |
18616 _position = nextPosition; | |
18617 return true; | |
18618 } | |
18619 _current = null; | |
18620 _position = _array.length; | |
18621 return false; | |
18622 } | |
18623 | |
18624 T get current => _current; | |
18625 } | |
18626 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
18627 // for details. All rights reserved. Use of this source code is governed by a | |
18628 // BSD-style license that can be found in the LICENSE file. | |
18629 | |
18630 | |
18631 // Conversions for Window. These check if the window is the local | |
18632 // window, and if it's not, wraps or unwraps it with a secure wrapper. | |
18633 // We need to test for EventTarget here as well as it's a base type. | |
18634 // We omit an unwrapper for Window as no methods take a non-local | |
18635 // window as a parameter. | |
18636 | |
18637 | |
18638 WindowBase _convertNativeToDart_Window(win) { | |
18639 if (win == null) return null; | |
18640 return _DOMWindowCrossFrame._createSafe(win); | |
18641 } | |
18642 | |
18643 EventTarget _convertNativeToDart_EventTarget(e) { | |
18644 if (e == null) { | |
18645 return null; | |
18646 } | |
18647 // Assume it's a Window if it contains the postMessage property. It may be | |
18648 // from a different frame - without a patched prototype - so we cannot | |
18649 // rely on Dart type checking. | |
18650 if (JS('bool', r'"postMessage" in #', e)) { | |
18651 var window = _DOMWindowCrossFrame._createSafe(e); | |
18652 // If it's a native window. | |
18653 if (window is EventTarget) { | |
18654 return window; | |
18655 } | |
18656 return null; | |
18657 } | |
18658 else | |
18659 return e; | |
18660 } | |
18661 | |
18662 EventTarget _convertDartToNative_EventTarget(e) { | |
18663 if (e is _DOMWindowCrossFrame) { | |
18664 return e._window; | |
18665 } else { | |
18666 return e; | |
18667 } | |
18668 } | |
18669 | |
18670 _convertNativeToDart_XHR_Response(o) { | |
18671 if (o is Document) { | |
18672 return o; | |
18673 } | |
18674 return convertNativeToDart_SerializedScriptValue(o); | |
18675 } | |
18676 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
18677 // for details. All rights reserved. Use of this source code is governed by a | |
18678 // BSD-style license that can be found in the LICENSE file. | |
18679 | |
18680 | |
18681 // TODO(vsm): Unify with Dartium version. | |
18682 class _DOMWindowCrossFrame implements WindowBase { | |
18683 // Private window. Note, this is a window in another frame, so it | |
18684 // cannot be typed as "Window" as its prototype is not patched | |
18685 // properly. Its fields and methods can only be accessed via JavaScript. | |
18686 final _window; | |
18687 | |
18688 // Fields. | |
18689 HistoryBase get history => | |
18690 _HistoryCrossFrame._createSafe(JS('HistoryBase', '#.history', _window)); | |
18691 LocationBase get location => | |
18692 _LocationCrossFrame._createSafe(JS('LocationBase', '#.location', _window)); | |
18693 | |
18694 // TODO(vsm): Add frames to navigate subframes. See 2312. | |
18695 | |
18696 bool get closed => JS('bool', '#.closed', _window); | |
18697 | |
18698 WindowBase get opener => _createSafe(JS('WindowBase', '#.opener', _window)); | |
18699 | |
18700 WindowBase get parent => _createSafe(JS('WindowBase', '#.parent', _window)); | |
18701 | |
18702 WindowBase get top => _createSafe(JS('WindowBase', '#.top', _window)); | |
18703 | |
18704 // Methods. | |
18705 void close() => JS('void', '#.close()', _window); | |
18706 | |
18707 void postMessage(var message, String targetOrigin, [List messagePorts = null])
{ | |
18708 if (messagePorts == null) { | |
18709 JS('void', '#.postMessage(#,#)', _window, | |
18710 convertDartToNative_SerializedScriptValue(message), targetOrigin); | |
18711 } else { | |
18712 JS('void', '#.postMessage(#,#,#)', _window, | |
18713 convertDartToNative_SerializedScriptValue(message), targetOrigin, | |
18714 messagePorts); | |
18715 } | |
18716 } | |
18717 | |
18718 // Implementation support. | |
18719 _DOMWindowCrossFrame(this._window); | |
18720 | |
18721 static WindowBase _createSafe(w) { | |
18722 if (identical(w, window)) { | |
18723 return w; | |
18724 } else { | |
18725 // TODO(vsm): Cache or implement equality. | |
18726 return new _DOMWindowCrossFrame(w); | |
18727 } | |
18728 } | |
18729 | |
18730 // TODO(efortuna): Remove this method. dartbug.com/16814 | |
18731 Events get on => throw new UnsupportedError( | |
18732 'You can only attach EventListeners to your own window.'); | |
18733 // TODO(efortuna): Remove this method. dartbug.com/16814 | |
18734 void _addEventListener([String type, EventListener listener, bool useCapture]) | |
18735 => throw new UnsupportedError( | |
18736 'You can only attach EventListeners to your own window.'); | |
18737 // TODO(efortuna): Remove this method. dartbug.com/16814 | |
18738 void addEventListener(String type, EventListener listener, [bool useCapture]) | |
18739 => throw new UnsupportedError( | |
18740 'You can only attach EventListeners to your own window.'); | |
18741 // TODO(efortuna): Remove this method. dartbug.com/16814 | |
18742 bool dispatchEvent(Event event) => throw new UnsupportedError( | |
18743 'You can only attach EventListeners to your own window.'); | |
18744 // TODO(efortuna): Remove this method. dartbug.com/16814 | |
18745 void _removeEventListener([String type, EventListener listener, | |
18746 bool useCapture]) => throw new UnsupportedError( | |
18747 'You can only attach EventListeners to your own window.'); | |
18748 // TODO(efortuna): Remove this method. dartbug.com/16814 | |
18749 void removeEventListener(String type, EventListener listener, | |
18750 [bool useCapture]) => throw new UnsupportedError( | |
18751 'You can only attach EventListeners to your own window.'); | |
18752 } | |
18753 | |
18754 class _LocationCrossFrame implements LocationBase { | |
18755 // Private location. Note, this is a location object in another frame, so it | |
18756 // cannot be typed as "Location" as its prototype is not patched | |
18757 // properly. Its fields and methods can only be accessed via JavaScript. | |
18758 var _location; | |
18759 | |
18760 set href(String val) => _setHref(_location, val); | |
18761 static void _setHref(location, val) { | |
18762 JS('void', '#.href = #', location, val); | |
18763 } | |
18764 | |
18765 // Implementation support. | |
18766 _LocationCrossFrame(this._location); | |
18767 | |
18768 static LocationBase _createSafe(location) { | |
18769 if (identical(location, window.location)) { | |
18770 return location; | |
18771 } else { | |
18772 // TODO(vsm): Cache or implement equality. | |
18773 return new _LocationCrossFrame(location); | |
18774 } | |
18775 } | |
18776 } | |
18777 | |
18778 class _HistoryCrossFrame implements HistoryBase { | |
18779 // Private history. Note, this is a history object in another frame, so it | |
18780 // cannot be typed as "History" as its prototype is not patched | |
18781 // properly. Its fields and methods can only be accessed via JavaScript. | |
18782 var _history; | |
18783 | |
18784 void back() => JS('void', '#.back()', _history); | |
18785 | |
18786 void forward() => JS('void', '#.forward()', _history); | |
18787 | |
18788 void go(int distance) => JS('void', '#.go(#)', _history, distance); | |
18789 | |
18790 // Implementation support. | |
18791 _HistoryCrossFrame(this._history); | |
18792 | |
18793 static HistoryBase _createSafe(h) { | |
18794 if (identical(h, window.history)) { | |
18795 return h; | |
18796 } else { | |
18797 // TODO(vsm): Cache or implement equality. | |
18798 return new _HistoryCrossFrame(h); | |
18799 } | |
18800 } | |
18801 } | |
18802 /** | |
18803 * A custom KeyboardEvent that attempts to eliminate cross-browser | |
18804 * inconsistencies, and also provide both keyCode and charCode information | |
18805 * for all key events (when such information can be determined). | |
18806 * | |
18807 * KeyEvent tries to provide a higher level, more polished keyboard event | |
18808 * information on top of the "raw" [KeyboardEvent]. | |
18809 * | |
18810 * The mechanics of using KeyEvents is a little different from the underlying | |
18811 * [KeyboardEvent]. To use KeyEvents, you need to create a stream and then add | |
18812 * KeyEvents to the stream, rather than using the [EventTarget.dispatchEvent]. | |
18813 * Here's an example usage: | |
18814 * | |
18815 * // Initialize a stream for the KeyEvents: | |
18816 * var stream = KeyEvent.keyPressEvent.forTarget(document.body); | |
18817 * // Start listening to the stream of KeyEvents. | |
18818 * stream.listen((keyEvent) => | |
18819 * window.console.log('KeyPress event detected ${keyEvent.charCode}')); | |
18820 * ... | |
18821 * // Add a new KeyEvent of someone pressing the 'A' key to the stream so | |
18822 * // listeners can know a KeyEvent happened. | |
18823 * stream.add(new KeyEvent('keypress', keyCode: 65, charCode: 97)); | |
18824 * | |
18825 * This class is very much a work in progress, and we'd love to get information | |
18826 * on how we can make this class work with as many international keyboards as | |
18827 * possible. Bugs welcome! | |
18828 */ | |
18829 @Experimental() | |
18830 class KeyEvent extends _WrappedEvent implements KeyboardEvent { | |
18831 /** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */ | |
18832 KeyboardEvent _parent; | |
18833 | |
18834 /** The "fixed" value of whether the alt key is being pressed. */ | |
18835 bool _shadowAltKey; | |
18836 | |
18837 /** Caculated value of what the estimated charCode is for this event. */ | |
18838 int _shadowCharCode; | |
18839 | |
18840 /** Caculated value of what the estimated keyCode is for this event. */ | |
18841 int _shadowKeyCode; | |
18842 | |
18843 /** Caculated value of what the estimated keyCode is for this event. */ | |
18844 int get keyCode => _shadowKeyCode; | |
18845 | |
18846 /** Caculated value of what the estimated charCode is for this event. */ | |
18847 int get charCode => this.type == 'keypress' ? _shadowCharCode : 0; | |
18848 | |
18849 /** Caculated value of whether the alt key is pressed is for this event. */ | |
18850 bool get altKey => _shadowAltKey; | |
18851 | |
18852 /** Caculated value of what the estimated keyCode is for this event. */ | |
18853 int get which => keyCode; | |
18854 | |
18855 /** Accessor to the underlying keyCode value is the parent event. */ | |
18856 int get _realKeyCode => JS('int', '#.keyCode', _parent); | |
18857 | |
18858 /** Accessor to the underlying charCode value is the parent event. */ | |
18859 int get _realCharCode => JS('int', '#.charCode', _parent); | |
18860 | |
18861 /** Accessor to the underlying altKey value is the parent event. */ | |
18862 bool get _realAltKey => JS('bool', '#.altKey', _parent); | |
18863 | |
18864 /** Shadows on top of the parent's currentTarget. */ | |
18865 EventTarget _currentTarget; | |
18866 | |
18867 /** | |
18868 * The value we want to use for this object's dispatch. Created here so it is | |
18869 * only invoked once. | |
18870 */ | |
18871 static final _keyboardEventDispatchRecord = _makeRecord(); | |
18872 | |
18873 /** Helper to statically create the dispatch record. */ | |
18874 static _makeRecord() { | |
18875 var interceptor = JS_INTERCEPTOR_CONSTANT(KeyboardEvent); | |
18876 return makeLeafDispatchRecord(interceptor); | |
18877 } | |
18878 | |
18879 /** Construct a KeyEvent with [parent] as the event we're emulating. */ | |
18880 KeyEvent.wrap(KeyboardEvent parent): super(parent) { | |
18881 _parent = parent; | |
18882 _shadowAltKey = _realAltKey; | |
18883 _shadowCharCode = _realCharCode; | |
18884 _shadowKeyCode = _realKeyCode; | |
18885 _currentTarget = _parent.currentTarget; | |
18886 } | |
18887 | |
18888 /** Programmatically create a new KeyEvent (and KeyboardEvent). */ | |
18889 factory KeyEvent(String type, | |
18890 {Window view, bool canBubble: true, bool cancelable: true, int keyCode: 0, | |
18891 int charCode: 0, int keyLocation: 1, bool ctrlKey: false, | |
18892 bool altKey: false, bool shiftKey: false, bool metaKey: false, | |
18893 EventTarget currentTarget}) { | |
18894 if (view == null) { | |
18895 view = window; | |
18896 } | |
18897 | |
18898 var eventObj; | |
18899 // In these two branches we create an underlying native KeyboardEvent, but | |
18900 // we set it with our specified values. Because we are doing custom setting | |
18901 // of certain values (charCode/keyCode, etc) only in this class (as opposed | |
18902 // to KeyboardEvent) and the way we set these custom values depends on the | |
18903 // type of underlying JS object, we do all the contruction for the | |
18904 // underlying KeyboardEvent here. | |
18905 if (canUseDispatchEvent) { | |
18906 // Currently works in everything but Internet Explorer. | |
18907 eventObj = new Event.eventType('Event', type, | |
18908 canBubble: canBubble, cancelable: cancelable); | |
18909 | |
18910 JS('void', '#.keyCode = #', eventObj, keyCode); | |
18911 JS('void', '#.which = #', eventObj, keyCode); | |
18912 JS('void', '#.charCode = #', eventObj, charCode); | |
18913 | |
18914 JS('void', '#.keyLocation = #', eventObj, keyLocation); | |
18915 JS('void', '#.ctrlKey = #', eventObj, ctrlKey); | |
18916 JS('void', '#.altKey = #', eventObj, altKey); | |
18917 JS('void', '#.shiftKey = #', eventObj, shiftKey); | |
18918 JS('void', '#.metaKey = #', eventObj, metaKey); | |
18919 } else { | |
18920 // Currently this works on everything but Safari. Safari throws an | |
18921 // "Attempting to change access mechanism for an unconfigurable property" | |
18922 // TypeError when trying to do the Object.defineProperty hack, so we avoid | |
18923 // this branch if possible. | |
18924 // Also, if we want this branch to work in FF, we also need to modify | |
18925 // _initKeyboardEvent to also take charCode and keyCode values to | |
18926 // initialize initKeyEvent. | |
18927 | |
18928 eventObj = new Event.eventType('KeyboardEvent', type, | |
18929 canBubble: canBubble, cancelable: cancelable); | |
18930 | |
18931 // Chromium Hack | |
18932 JS('void', "Object.defineProperty(#, 'keyCode', {" | |
18933 " get : function() { return this.keyCodeVal; } })", eventObj); | |
18934 JS('void', "Object.defineProperty(#, 'which', {" | |
18935 " get : function() { return this.keyCodeVal; } })", eventObj); | |
18936 JS('void', "Object.defineProperty(#, 'charCode', {" | |
18937 " get : function() { return this.charCodeVal; } })", eventObj); | |
18938 | |
18939 var keyIdentifier = _convertToHexString(charCode, keyCode); | |
18940 eventObj._initKeyboardEvent(type, canBubble, cancelable, view, | |
18941 keyIdentifier, keyLocation, ctrlKey, altKey, shiftKey, metaKey); | |
18942 JS('void', '#.keyCodeVal = #', eventObj, keyCode); | |
18943 JS('void', '#.charCodeVal = #', eventObj, charCode); | |
18944 } | |
18945 // Tell dart2js that it smells like a KeyboardEvent! | |
18946 setDispatchProperty(eventObj, _keyboardEventDispatchRecord); | |
18947 | |
18948 var keyEvent = new KeyEvent.wrap(eventObj); | |
18949 if (keyEvent._currentTarget == null) { | |
18950 keyEvent._currentTarget = currentTarget == null ? window : currentTarget; | |
18951 } | |
18952 return keyEvent; | |
18953 } | |
18954 | |
18955 // Currently known to work on all browsers but IE. | |
18956 static bool get canUseDispatchEvent => | |
18957 JS('bool', | |
18958 '(typeof document.body.dispatchEvent == "function")' | |
18959 '&& document.body.dispatchEvent.length > 0'); | |
18960 | |
18961 /** The currently registered target for this event. */ | |
18962 EventTarget get currentTarget => _currentTarget; | |
18963 | |
18964 // This is an experimental method to be sure. | |
18965 static String _convertToHexString(int charCode, int keyCode) { | |
18966 if (charCode != -1) { | |
18967 var hex = charCode.toRadixString(16); // Convert to hexadecimal. | |
18968 StringBuffer sb = new StringBuffer('U+'); | |
18969 for (int i = 0; i < 4 - hex.length; i++) sb.write('0'); | |
18970 sb.write(hex); | |
18971 return sb.toString(); | |
18972 } else { | |
18973 return KeyCode._convertKeyCodeToKeyName(keyCode); | |
18974 } | |
18975 } | |
18976 | |
18977 // TODO(efortuna): If KeyEvent is sufficiently successful that we want to make | |
18978 // it the default keyboard event handling, move these methods over to Element. | |
18979 /** Accessor to provide a stream of KeyEvents on the desired target. */ | |
18980 static EventStreamProvider<KeyEvent> keyDownEvent = | |
18981 new _KeyboardEventHandler('keydown'); | |
18982 /** Accessor to provide a stream of KeyEvents on the desired target. */ | |
18983 static EventStreamProvider<KeyEvent> keyUpEvent = | |
18984 new _KeyboardEventHandler('keyup'); | |
18985 /** Accessor to provide a stream of KeyEvents on the desired target. */ | |
18986 static EventStreamProvider<KeyEvent> keyPressEvent = | |
18987 new _KeyboardEventHandler('keypress'); | |
18988 | |
18989 /** Accessor to the clipboardData available for this event. */ | |
18990 DataTransfer get clipboardData => _parent.clipboardData; | |
18991 /** True if the ctrl key is pressed during this event. */ | |
18992 bool get ctrlKey => _parent.ctrlKey; | |
18993 int get detail => _parent.detail; | |
18994 /** | |
18995 * Accessor to the part of the keyboard that the key was pressed from (one of | |
18996 * KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT, | |
18997 * KeyLocation.NUMPAD, KeyLocation.MOBILE, KeyLocation.JOYSTICK). | |
18998 */ | |
18999 int get keyLocation => _parent.keyLocation; | |
19000 Point get layer => _parent.layer; | |
19001 /** True if the Meta (or Mac command) key is pressed during this event. */ | |
19002 bool get metaKey => _parent.metaKey; | |
19003 Point get page => _parent.page; | |
19004 /** True if the shift key was pressed during this event. */ | |
19005 bool get shiftKey => _parent.shiftKey; | |
19006 Window get view => _parent.view; | |
19007 void _initUIEvent(String type, bool canBubble, bool cancelable, | |
19008 Window view, int detail) { | |
19009 throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent."); | |
19010 } | |
19011 String get _shadowKeyIdentifier => JS('String', '#.keyIdentifier', _parent); | |
19012 | |
19013 int get _charCode => charCode; | |
19014 int get _keyCode => keyCode; | |
19015 String get _keyIdentifier { | |
19016 throw new UnsupportedError("keyIdentifier is unsupported."); | |
19017 } | |
19018 void _initKeyboardEvent(String type, bool canBubble, bool cancelable, | |
19019 Window view, String keyIdentifier, int keyLocation, bool ctrlKey, | |
19020 bool altKey, bool shiftKey, bool metaKey) { | |
19021 throw new UnsupportedError( | |
19022 "Cannot initialize a KeyboardEvent from a KeyEvent."); | |
19023 } | |
19024 int get _layerX => throw new UnsupportedError('Not applicable to KeyEvent'); | |
19025 int get _layerY => throw new UnsupportedError('Not applicable to KeyEvent'); | |
19026 int get _pageX => throw new UnsupportedError('Not applicable to KeyEvent'); | |
19027 int get _pageY => throw new UnsupportedError('Not applicable to KeyEvent'); | |
19028 @Experimental() // untriaged | |
19029 bool getModifierState(String keyArgument) => throw new UnimplementedError(); | |
19030 @Experimental() // untriaged | |
19031 int get location => throw new UnimplementedError(); | |
19032 @Experimental() // untriaged | |
19033 bool get repeat => throw new UnimplementedError(); | |
19034 dynamic get _get_view => throw new UnimplementedError(); | |
19035 } | |
19036 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
19037 // for details. All rights reserved. Use of this source code is governed by a | |
19038 // BSD-style license that can be found in the LICENSE file. | |
19039 | |
19040 class Platform { | |
19041 /** | |
19042 * Returns true if dart:typed_data types are supported on this | |
19043 * browser. If false, using these types will generate a runtime | |
19044 * error. | |
19045 */ | |
19046 static final supportsTypedData = JS('bool', '!!($global_.ArrayBuffer)'); | |
19047 | |
19048 /** | |
19049 * Returns true if SIMD types in dart:typed_data types are supported | |
19050 * on this browser. If false, using these types will generate a runtime | |
19051 * error. | |
19052 */ | |
19053 static final supportsSimd = false; | |
19054 } | |
19055 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
19056 // for details. All rights reserved. Use of this source code is governed by a | |
19057 // BSD-style license that can be found in the LICENSE file. | |
19058 | |
19059 | |
19060 /** | |
19061 * Helper class to implement custom events which wrap DOM events. | |
19062 */ | |
19063 class _WrappedEvent implements Event { | |
19064 final Event wrapped; | |
19065 | |
19066 /** The CSS selector involved with event delegation. */ | |
19067 String _selector; | |
19068 | |
19069 _WrappedEvent(this.wrapped); | |
19070 | |
19071 bool get bubbles => wrapped.bubbles; | |
19072 | |
19073 bool get cancelable => wrapped.cancelable; | |
19074 | |
19075 DataTransfer get clipboardData => wrapped.clipboardData; | |
19076 | |
19077 EventTarget get currentTarget => wrapped.currentTarget; | |
19078 | |
19079 bool get defaultPrevented => wrapped.defaultPrevented; | |
19080 | |
19081 int get eventPhase => wrapped.eventPhase; | |
19082 | |
19083 EventTarget get target => wrapped.target; | |
19084 | |
19085 int get timeStamp => wrapped.timeStamp; | |
19086 | |
19087 String get type => wrapped.type; | |
19088 | |
19089 void _initEvent(String eventTypeArg, bool canBubbleArg, | |
19090 bool cancelableArg) { | |
19091 throw new UnsupportedError( | |
19092 'Cannot initialize this Event.'); | |
19093 } | |
19094 | |
19095 void preventDefault() { | |
19096 wrapped.preventDefault(); | |
19097 } | |
19098 | |
19099 void stopImmediatePropagation() { | |
19100 wrapped.stopImmediatePropagation(); | |
19101 } | |
19102 | |
19103 void stopPropagation() { | |
19104 wrapped.stopPropagation(); | |
19105 } | |
19106 | |
19107 /** | |
19108 * A pointer to the element whose CSS selector matched within which an event | |
19109 * was fired. If this Event was not associated with any Event delegation, | |
19110 * accessing this value will throw an [UnsupportedError]. | |
19111 */ | |
19112 Element get matchingTarget { | |
19113 if (_selector == null) { | |
19114 throw new UnsupportedError('Cannot call matchingTarget if this Event did' | |
19115 ' not arise as a result of event delegation.'); | |
19116 } | |
19117 var currentTarget = this.currentTarget; | |
19118 var target = this.target; | |
19119 var matchedTarget; | |
19120 do { | |
19121 if (target.matches(_selector)) return target; | |
19122 target = target.parent; | |
19123 } while (target != null && target != currentTarget.parent); | |
19124 throw new StateError('No selector matched for populating matchedTarget.'); | |
19125 } | |
19126 | |
19127 /** | |
19128 * This event's path, taking into account shadow DOM. | |
19129 * | |
19130 * ## Other resources | |
19131 * | |
19132 * * [Shadow DOM extensions to Event] | |
19133 * (http://w3c.github.io/webcomponents/spec/shadow/#extensions-to-event) from | |
19134 * W3C. | |
19135 */ | |
19136 // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#ex
tensions-to-event | |
19137 @Experimental() | |
19138 List<Node> get path => wrapped.path; | |
19139 | |
19140 dynamic get _get_currentTarget => wrapped._get_currentTarget; | |
19141 | |
19142 dynamic get _get_target => wrapped._get_target; | |
19143 } | |
19144 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
19145 // for details. All rights reserved. Use of this source code is governed by a | |
19146 // BSD-style license that can be found in the LICENSE file. | |
19147 | |
19148 | |
19149 _wrapZone(callback(arg)) { | |
19150 // For performance reasons avoid wrapping if we are in the root zone. | |
19151 if (Zone.current == Zone.ROOT) return callback; | |
19152 if (callback == null) return null; | |
19153 return Zone.current.bindUnaryCallback(callback, runGuarded: true); | |
19154 } | |
19155 | |
19156 _wrapBinaryZone(callback(arg1, arg2)) { | |
19157 if (Zone.current == Zone.ROOT) return callback; | |
19158 if (callback == null) return null; | |
19159 return Zone.current.bindBinaryCallback(callback, runGuarded: true); | |
19160 } | |
19161 | |
19162 /** | |
19163 * Alias for [querySelector]. Note this function is deprecated because its | |
19164 * semantics will be changing in the future. | |
19165 */ | |
19166 @deprecated | |
19167 @Experimental() | |
19168 Element query(String relativeSelectors) => document.query(relativeSelectors); | |
19169 /** | |
19170 * Alias for [querySelectorAll]. Note this function is deprecated because its | |
19171 * semantics will be changing in the future. | |
19172 */ | |
19173 @deprecated | |
19174 @Experimental() | |
19175 ElementList<Element> queryAll(String relativeSelectors) => document.queryAll(rel
ativeSelectors); | |
19176 | |
19177 /** | |
19178 * Finds the first descendant element of this document that matches the | |
19179 * specified group of selectors. | |
19180 * | |
19181 * Unless your webpage contains multiple documents, the top-level | |
19182 * [querySelector] | |
19183 * method behaves the same as this method, so you should use it instead to | |
19184 * save typing a few characters. | |
19185 * | |
19186 * [selectors] should be a string using CSS selector syntax. | |
19187 * | |
19188 * var element1 = document.querySelector('.className'); | |
19189 * var element2 = document.querySelector('#id'); | |
19190 * | |
19191 * For details about CSS selector syntax, see the | |
19192 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
19193 */ | |
19194 Element querySelector(String selectors) => document.querySelector(selectors); | |
19195 | |
19196 /** | |
19197 * Finds all descendant elements of this document that match the specified | |
19198 * group of selectors. | |
19199 * | |
19200 * Unless your webpage contains multiple documents, the top-level | |
19201 * [querySelectorAll] | |
19202 * method behaves the same as this method, so you should use it instead to | |
19203 * save typing a few characters. | |
19204 * | |
19205 * [selectors] should be a string using CSS selector syntax. | |
19206 * | |
19207 * var items = document.querySelectorAll('.itemClassName'); | |
19208 * | |
19209 * For details about CSS selector syntax, see the | |
19210 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | |
19211 */ | |
19212 ElementList<Element> querySelectorAll(String selectors) => document.querySelecto
rAll(selectors); | |
19213 | |
19214 /// A utility for changing the Dart wrapper type for elements. | |
19215 abstract class ElementUpgrader { | |
19216 /// Upgrade the specified element to be of the Dart type this was created for. | |
19217 /// | |
19218 /// After upgrading the element passed in is invalid and the returned value | |
19219 /// should be used instead. | |
19220 Element upgrade(Element element); | |
19221 } | |
19222 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
19223 // for details. All rights reserved. Use of this source code is governed by a | |
19224 // BSD-style license that can be found in the LICENSE file. | |
19225 | |
19226 | |
19227 | |
19228 /** | |
19229 * Interface used to validate that only accepted elements and attributes are | |
19230 * allowed while parsing HTML strings into DOM nodes. | |
19231 * | |
19232 * In general, customization of validation behavior should be done via the | |
19233 * [NodeValidatorBuilder] class to mitigate the chances of incorrectly | |
19234 * implementing validation rules. | |
19235 */ | |
19236 abstract class NodeValidator { | |
19237 | |
19238 /** | |
19239 * Construct a default NodeValidator which only accepts whitelisted HTML5 | |
19240 * elements and attributes. | |
19241 * | |
19242 * If a uriPolicy is not specified then the default uriPolicy will be used. | |
19243 */ | |
19244 factory NodeValidator({UriPolicy uriPolicy}) => | |
19245 new _Html5NodeValidator(uriPolicy: uriPolicy); | |
19246 | |
19247 factory NodeValidator.throws(NodeValidator base) => | |
19248 new _ThrowsNodeValidator(base); | |
19249 | |
19250 /** | |
19251 * Returns true if the tagName is an accepted type. | |
19252 */ | |
19253 bool allowsElement(Element element); | |
19254 | |
19255 /** | |
19256 * Returns true if the attribute is allowed. | |
19257 * | |
19258 * The attributeName parameter will always be in lowercase. | |
19259 * | |
19260 * See [allowsElement] for format of tagName. | |
19261 */ | |
19262 bool allowsAttribute(Element element, String attributeName, String value); | |
19263 } | |
19264 | |
19265 /** | |
19266 * Performs sanitization of a node tree after construction to ensure that it | |
19267 * does not contain any disallowed elements or attributes. | |
19268 * | |
19269 * In general custom implementations of this class should not be necessary and | |
19270 * all validation customization should be done in custom NodeValidators, but | |
19271 * custom implementations of this class can be created to perform more complex | |
19272 * tree sanitization. | |
19273 */ | |
19274 abstract class NodeTreeSanitizer { | |
19275 | |
19276 /** | |
19277 * Constructs a default tree sanitizer which will remove all elements and | |
19278 * attributes which are not allowed by the provided validator. | |
19279 */ | |
19280 factory NodeTreeSanitizer(NodeValidator validator) => | |
19281 new _ValidatingTreeSanitizer(validator); | |
19282 | |
19283 /** | |
19284 * Called with the root of the tree which is to be sanitized. | |
19285 * | |
19286 * This method needs to walk the entire tree and either remove elements and | |
19287 * attributes which are not recognized as safe or throw an exception which | |
19288 * will mark the entire tree as unsafe. | |
19289 */ | |
19290 void sanitizeTree(Node node); | |
19291 | |
19292 /** | |
19293 * A sanitizer for trees that we trust. It does no validation and allows | |
19294 * any elements. It is also more efficient, since it can pass the text | |
19295 * directly through to the underlying APIs without creating a document | |
19296 * fragment to be sanitized. | |
19297 */ | |
19298 static const trusted = const _TrustedHtmlTreeSanitizer(); | |
19299 } | |
19300 | |
19301 /** | |
19302 * A sanitizer for trees that we trust. It does no validation and allows | |
19303 * any elements. | |
19304 */ | |
19305 class _TrustedHtmlTreeSanitizer implements NodeTreeSanitizer { | |
19306 const _TrustedHtmlTreeSanitizer(); | |
19307 | |
19308 sanitizeTree(Node node) {} | |
19309 } | |
19310 | |
19311 /** | |
19312 * Defines the policy for what types of uris are allowed for particular | |
19313 * attribute values. | |
19314 * | |
19315 * This can be used to provide custom rules such as allowing all http:// URIs | |
19316 * for image attributes but only same-origin URIs for anchor tags. | |
19317 */ | |
19318 abstract class UriPolicy { | |
19319 /** | |
19320 * Constructs the default UriPolicy which is to only allow Uris to the same | |
19321 * origin as the application was launched from. | |
19322 * | |
19323 * This will block all ftp: mailto: URIs. It will also block accessing | |
19324 * https://example.com if the app is running from http://example.com. | |
19325 */ | |
19326 factory UriPolicy() => new _SameOriginUriPolicy(); | |
19327 | |
19328 /** | |
19329 * Checks if the uri is allowed on the specified attribute. | |
19330 * | |
19331 * The uri provided may or may not be a relative path. | |
19332 */ | |
19333 bool allowsUri(String uri); | |
19334 } | |
19335 | |
19336 /** | |
19337 * Allows URIs to the same origin as the current application was loaded from | |
19338 * (such as https://example.com:80). | |
19339 */ | |
19340 class _SameOriginUriPolicy implements UriPolicy { | |
19341 final AnchorElement _hiddenAnchor = new AnchorElement(); | |
19342 final Location _loc = window.location; | |
19343 | |
19344 bool allowsUri(String uri) { | |
19345 _hiddenAnchor.href = uri; | |
19346 // IE leaves an empty hostname for same-origin URIs. | |
19347 return (_hiddenAnchor.hostname == _loc.hostname && | |
19348 _hiddenAnchor.port == _loc.port && | |
19349 _hiddenAnchor.protocol == _loc.protocol) || | |
19350 (_hiddenAnchor.hostname == '' && | |
19351 _hiddenAnchor.port == '' && | |
19352 (_hiddenAnchor.protocol == ':' || _hiddenAnchor.protocol == '')); | |
19353 } | |
19354 } | |
19355 | |
19356 | |
19357 class _ThrowsNodeValidator implements NodeValidator { | |
19358 final NodeValidator validator; | |
19359 | |
19360 _ThrowsNodeValidator(this.validator) {} | |
19361 | |
19362 bool allowsElement(Element element) { | |
19363 if (!validator.allowsElement(element)) { | |
19364 throw new ArgumentError(Element._safeTagName(element)); | |
19365 } | |
19366 return true; | |
19367 } | |
19368 | |
19369 bool allowsAttribute(Element element, String attributeName, String value) { | |
19370 if (!validator.allowsAttribute(element, attributeName, value)) { | |
19371 throw new ArgumentError('${Element._safeTagName(element)}[$attributeName="
$value"]'); | |
19372 } | |
19373 } | |
19374 } | |
19375 | |
19376 | |
19377 /** | |
19378 * Standard tree sanitizer which validates a node tree against the provided | |
19379 * validator and removes any nodes or attributes which are not allowed. | |
19380 */ | |
19381 class _ValidatingTreeSanitizer implements NodeTreeSanitizer { | |
19382 NodeValidator validator; | |
19383 _ValidatingTreeSanitizer(this.validator) {} | |
19384 | |
19385 void sanitizeTree(Node node) { | |
19386 void walk(Node node, Node parent) { | |
19387 sanitizeNode(node, parent); | |
19388 | |
19389 var child = node.lastChild; | |
19390 while (child != null) { | |
19391 // Child may be removed during the walk. | |
19392 var nextChild = child.previousNode; | |
19393 walk(child, node); | |
19394 child = nextChild; | |
19395 } | |
19396 } | |
19397 walk(node, null); | |
19398 } | |
19399 | |
19400 /// Aggressively try to remove node. | |
19401 void _removeNode(Node node, Node parent) { | |
19402 // If we have the parent, it's presumably already passed more sanitization | |
19403 // or is the fragment, so ask it to remove the child. And if that fails | |
19404 // try to set the outer html. | |
19405 if (parent == null) { | |
19406 node.remove(); | |
19407 } else { | |
19408 parent._removeChild(node); | |
19409 } | |
19410 } | |
19411 | |
19412 /// Sanitize the element, assuming we can't trust anything about it. | |
19413 void _sanitizeUntrustedElement(/* Element */ element, Node parent) { | |
19414 // If the _hasCorruptedAttributes does not successfully return false, | |
19415 // then we consider it corrupted and remove. | |
19416 // TODO(alanknight): This is a workaround because on Firefox | |
19417 // embed/object | |
19418 // tags typeof is "function", not "object". We don't recognize them, and | |
19419 // can't call methods. This does mean that you can't explicitly allow an | |
19420 // embed tag. The only thing that will let it through is a null | |
19421 // sanitizer that doesn't traverse the tree at all. But sanitizing while | |
19422 // allowing embeds seems quite unlikely. This is also the reason that we | |
19423 // can't declare the type of element, as an embed won't pass any type | |
19424 // check in dart2js. | |
19425 var corrupted = true; | |
19426 var attrs; | |
19427 var isAttr; | |
19428 try { | |
19429 // If getting/indexing attributes throws, count that as corrupt. | |
19430 attrs = element.attributes; | |
19431 isAttr = attrs['is']; | |
19432 var corruptedTest1 = Element._hasCorruptedAttributes(element); | |
19433 | |
19434 // On IE, erratically, the hasCorruptedAttributes test can return false, | |
19435 // even though it clearly is corrupted. A separate copy of the test | |
19436 // inlining just the basic check seems to help. | |
19437 corrupted = corruptedTest1 ? true : Element._hasCorruptedAttributesAdditio
nalCheck(element); | |
19438 } catch(e) {} | |
19439 var elementText = 'element unprintable'; | |
19440 try { | |
19441 elementText = element.toString(); | |
19442 } catch(e) {} | |
19443 try { | |
19444 var elementTagName = Element._safeTagName(element); | |
19445 _sanitizeElement(element, parent, corrupted, elementText, elementTagName, | |
19446 attrs, isAttr); | |
19447 } on ArgumentError { // Thrown by _ThrowsNodeValidator | |
19448 rethrow; | |
19449 } catch(e) { // Unexpected exception sanitizing -> remove | |
19450 _removeNode(element, parent); | |
19451 window.console.warn('Removing corrupted element $elementText'); | |
19452 } | |
19453 } | |
19454 | |
19455 /// Having done basic sanity checking on the element, and computed the | |
19456 /// important attributes we want to check, remove it if it's not valid | |
19457 /// or not allowed, either as a whole or particular attributes. | |
19458 void _sanitizeElement(Element element, Node parent, bool corrupted, | |
19459 String text, String tag, Map attrs, String isAttr) { | |
19460 if (false != corrupted) { | |
19461 _removeNode(element, parent); | |
19462 window.console.warn( | |
19463 'Removing element due to corrupted attributes on <$text>'); | |
19464 return; | |
19465 } | |
19466 if (!validator.allowsElement(element)) { | |
19467 _removeNode(element, parent); | |
19468 window.console.warn( | |
19469 'Removing disallowed element <$tag> from $parent'); | |
19470 return; | |
19471 } | |
19472 | |
19473 if (isAttr != null) { | |
19474 if (!validator.allowsAttribute(element, 'is', isAttr)) { | |
19475 _removeNode(element, parent); | |
19476 window.console.warn('Removing disallowed type extension ' | |
19477 '<$tag is="$isAttr">'); | |
19478 return; | |
19479 } | |
19480 } | |
19481 | |
19482 // TODO(blois): Need to be able to get all attributes, irrespective of | |
19483 // XMLNS. | |
19484 var keys = attrs.keys.toList(); | |
19485 for (var i = attrs.length - 1; i >= 0; --i) { | |
19486 var name = keys[i]; | |
19487 if (!validator.allowsAttribute(element, name.toLowerCase(), | |
19488 attrs[name])) { | |
19489 window.console.warn('Removing disallowed attribute ' | |
19490 '<$tag $name="${attrs[name]}">'); | |
19491 attrs.remove(name); | |
19492 } | |
19493 } | |
19494 | |
19495 if (element is TemplateElement) { | |
19496 TemplateElement template = element; | |
19497 sanitizeTree(template.content); | |
19498 } | |
19499 } | |
19500 | |
19501 /// Sanitize the node and its children recursively. | |
19502 void sanitizeNode(Node node, Node parent) { | |
19503 switch (node.nodeType) { | |
19504 case Node.ELEMENT_NODE: | |
19505 _sanitizeUntrustedElement(node, parent); | |
19506 break; | |
19507 case Node.COMMENT_NODE: | |
19508 case Node.DOCUMENT_FRAGMENT_NODE: | |
19509 case Node.TEXT_NODE: | |
19510 case Node.CDATA_SECTION_NODE: | |
19511 break; | |
19512 default: | |
19513 _removeNode(node, parent); | |
19514 } | |
19515 } | |
19516 } | |
19517 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
19518 // for details. All rights reserved. Use of this source code is governed by a | |
19519 // BSD-style license that can be found in the LICENSE file. | |
19520 | |
19521 // DO NOT EDIT - unless you are editing documentation as per: | |
19522 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation | |
19523 // Auto-generated dart:html library. | |
19524 | |
19525 | |
19526 import 'dart:_js_helper' show | |
19527 convertDartClosureToJS, Creates, JavaScriptIndexingBehavior, | |
19528 JSName, Native, Returns, ForceInline, | |
19529 findDispatchTagForInterceptorClass, setNativeSubclassDispatchRecord, | |
19530 makeLeafDispatchRecord; | |
19531 import 'dart:_interceptors' show | |
19532 Interceptor, JSExtendableArray, JSUInt31, | |
19533 findInterceptorConstructorForType, | |
19534 findConstructorForNativeSubclassType, | |
19535 getNativeInterceptor, | |
19536 setDispatchProperty; | |
19537 | |
19538 export 'dart:math' show Rectangle, Point; | |
19539 | |
19540 | |
19541 | |
19542 //part '../../../dom/src/dart2js_CustomElementSupport.dart'; | |
19543 | |
19544 | |
19545 /** | |
19546 * Top-level container for a web page, which is usually a browser tab or window. | |
19547 * | |
19548 * Each web page loaded in the browser has its own [Window], which is a | |
19549 * container for the web page. | |
19550 * | |
19551 * If the web page has any `<iframe>` elements, then each `<iframe>` has its own | |
19552 * [Window] object, which is accessible only to that `<iframe>`. | |
19553 * | |
19554 * See also: | |
19555 * | |
19556 * * [Window](https://developer.mozilla.org/en-US/docs/Web/API/window) from MD
N. | |
19557 */ | |
19558 | |
19559 final Window window = wrap_jso(JS('', '$global_')); | |
19560 | |
19561 /** | |
19562 * Root node for all content in a web page. | |
19563 */ | |
19564 HtmlDocument get document => wrap_jso(JS('HtmlDocument', 'document')); | |
19565 | |
19566 // Workaround for tags like <cite> that lack their own Element subclass -- | |
19567 // Dart issue 1990. | |
19568 @Native("HTMLElement") | |
19569 class HtmlElement extends Element { | |
19570 factory HtmlElement() { throw new UnsupportedError("Not supported"); } | |
19571 | |
19572 /** | |
19573 * Constructor instantiated by the DOM when a custom element has been created. | |
19574 * | |
19575 * This can only be called by subclasses from their created constructor. | |
19576 */ | |
19577 HtmlElement.created() : super.created(); | |
19578 HtmlElement.internal_() : super.internal_(); | |
19579 | |
19580 static HtmlElement internalCreateHtmlElement() { | |
19581 return new HtmlElement._internalWrap(); | |
19582 } | |
19583 | |
19584 factory HtmlElement._internalWrap() { | |
19585 return new HtmlElement.internal_(); | |
19586 } | |
19587 } | |
19588 | |
19589 // EntryArray type was removed, so explicitly adding it to allow support for | |
19590 // older Chrome versions. | |
19591 // Issue #12573. | |
19592 @Native("EntryArray") | |
19593 abstract class _EntryArray implements List<Entry> {} | |
19594 | |
19595 /** | |
19596 * Spawn a DOM isolate using the given URI in the same window. | |
19597 * This isolate is not concurrent. It runs on the browser thread | |
19598 * with full access to the DOM. | |
19599 * Note: this API is still evolving and may move to dart:isolate. | |
19600 */ | |
19601 @Experimental() | |
19602 Future<Isolate> spawnDomUri(Uri uri, List<String> args, message) { | |
19603 // TODO(17738): Implement this. | |
19604 throw new UnimplementedError(); | |
19605 } | |
19606 | |
19607 | |
19608 class DartHtmlDomObject { | |
19609 // FIXME(vsm): Make this final at least. Private? | |
19610 dynamic raw; | |
19611 | |
19612 DartHtmlDomObject(); | |
19613 DartHtmlDomObject.internal_(); | |
19614 } | |
19615 | |
19616 typedef _F1(x); | |
19617 | |
19618 final _wrapper = JS('', 'Symbol("dart_wrapper")'); | |
19619 | |
19620 /// Dartium functions that are a NOOP in dart2js. | |
19621 unwrap_jso(wrapped) { | |
19622 if (wrapped is DartHtmlDomObject) { | |
19623 return wrapped.raw; | |
19624 } | |
19625 if (wrapped is _F1) { | |
19626 if (JS('bool', '#.hasOwnProperty(#)', wrapped, _wrapper)) { | |
19627 return JS('', '#[#]', wrapped, _wrapper); | |
19628 } | |
19629 var f = (e) => wrapped(wrap_jso(e)); | |
19630 JS('', '#[#] = #', wrapped, _wrapper, f); | |
19631 return f; | |
19632 } | |
19633 return wrapped; | |
19634 } | |
19635 | |
19636 | |
19637 wrap_jso(jso) { | |
19638 if (jso == null || jso is bool || jso is num || jso is String) { | |
19639 return jso; | |
19640 } | |
19641 if (JS('bool', '#.hasOwnProperty(#)', jso, _wrapper)) { | |
19642 return JS('', '#[#]', jso, _wrapper); | |
19643 } | |
19644 var constructor = JS('', '#.constructor', jso) | |
19645 var f = null; | |
19646 String name; | |
19647 String skip = null; | |
19648 while (f == null) { | |
19649 name = JS('String', '#.name', constructor); | |
19650 f = getHtmlCreateFunction(name); | |
19651 if (f == null) { | |
19652 if (skip == null) { | |
19653 skip = name; | |
19654 } | |
19655 constructor = JS('', '#.__proto__', constructor); | |
19656 } | |
19657 } | |
19658 if (skip != null) { | |
19659 console.warn('Instantiated $name instead of $skip'); | |
19660 } | |
19661 var wrapped = f(); | |
19662 wrapped.raw = jso; | |
19663 JS('', '#[#] = #', jso, _wrapper, wrapped); | |
19664 return wrapped; | |
19665 } | |
19666 | |
19667 createCustomUpgrader(Type customElementClass, $this) => $this; | |
19668 | |
19669 // FIXME: Can we make this private? | |
19670 final htmlBlinkMap = { | |
19671 '_HistoryCrossFrame': () => _HistoryCrossFrame, | |
19672 '_LocationCrossFrame': () => _LocationCrossFrame, | |
19673 '_DOMWindowCrossFrame': () => _DOMWindowCrossFrame, | |
19674 // FIXME: Move these to better locations. | |
19675 'DateTime': () => DateTime, | |
19676 'JsObject': () => js.JsObjectImpl, | |
19677 'JsFunction': () => js.JsFunctionImpl, | |
19678 'JsArray': () => js.JsArrayImpl, | |
19679 'Attr': () => _Attr, | |
19680 'CSSStyleDeclaration': () => CssStyleDeclaration, | |
19681 'CharacterData': () => CharacterData, | |
19682 'ChildNode': () => ChildNode, | |
19683 'ClientRect': () => _ClientRect, | |
19684 'Comment': () => Comment, | |
19685 'Console': () => Console, | |
19686 'ConsoleBase': () => ConsoleBase, | |
19687 'CustomEvent': () => CustomEvent, | |
19688 'DOMImplementation': () => DomImplementation, | |
19689 'DOMTokenList': () => DomTokenList, | |
19690 'Document': () => Document, | |
19691 'DocumentFragment': () => DocumentFragment, | |
19692 'Element': () => Element, | |
19693 'Event': () => Event, | |
19694 'EventTarget': () => EventTarget, | |
19695 'HTMLAnchorElement': () => AnchorElement, | |
19696 'HTMLBaseElement': () => BaseElement, | |
19697 'HTMLBodyElement': () => BodyElement, | |
19698 'HTMLCollection': () => HtmlCollection, | |
19699 'HTMLDivElement': () => DivElement, | |
19700 'HTMLDocument': () => HtmlDocument, | |
19701 'HTMLElement': () => HtmlElement, | |
19702 'HTMLHeadElement': () => HeadElement, | |
19703 'HTMLHtmlElement': () => HtmlHtmlElement, | |
19704 'HTMLInputElement': () => InputElement, | |
19705 'HTMLStyleElement': () => StyleElement, | |
19706 'HTMLTemplateElement': () => TemplateElement, | |
19707 'History': () => History, | |
19708 'KeyboardEvent': () => KeyboardEvent, | |
19709 'Location': () => Location, | |
19710 'MouseEvent': () => MouseEvent, | |
19711 'NamedNodeMap': () => _NamedNodeMap, | |
19712 'Navigator': () => Navigator, | |
19713 'NavigatorCPU': () => NavigatorCpu, | |
19714 'Node': () => Node, | |
19715 'NodeList': () => NodeList, | |
19716 'ParentNode': () => ParentNode, | |
19717 'ProgressEvent': () => ProgressEvent, | |
19718 'Range': () => Range, | |
19719 'Screen': () => Screen, | |
19720 'ShadowRoot': () => ShadowRoot, | |
19721 'Text': () => Text, | |
19722 'UIEvent': () => UIEvent, | |
19723 'URLUtils': () => UrlUtils, | |
19724 'Window': () => Window, | |
19725 'XMLHttpRequest': () => HttpRequest, | |
19726 'XMLHttpRequestEventTarget': () => HttpRequestEventTarget, | |
19727 'XMLHttpRequestProgressEvent': () => _XMLHttpRequestProgressEvent, | |
19728 | |
19729 }; | |
19730 | |
19731 // FIXME: Can we make this private? | |
19732 final htmlBlinkFunctionMap = { | |
19733 'Attr': () => _Attr.internalCreate_Attr, | |
19734 'CSSStyleDeclaration': () => CssStyleDeclaration.internalCreateCssStyleDeclara
tion, | |
19735 'CharacterData': () => CharacterData.internalCreateCharacterData, | |
19736 'ClientRect': () => _ClientRect.internalCreate_ClientRect, | |
19737 'Comment': () => Comment.internalCreateComment, | |
19738 'Console': () => Console.internalCreateConsole, | |
19739 'ConsoleBase': () => ConsoleBase.internalCreateConsoleBase, | |
19740 'CustomEvent': () => CustomEvent.internalCreateCustomEvent, | |
19741 'DOMImplementation': () => DomImplementation.internalCreateDomImplementation, | |
19742 'DOMTokenList': () => DomTokenList.internalCreateDomTokenList, | |
19743 'Document': () => Document.internalCreateDocument, | |
19744 'DocumentFragment': () => DocumentFragment.internalCreateDocumentFragment, | |
19745 'Element': () => Element.internalCreateElement, | |
19746 'Event': () => Event.internalCreateEvent, | |
19747 'EventTarget': () => EventTarget.internalCreateEventTarget, | |
19748 'HTMLAnchorElement': () => AnchorElement.internalCreateAnchorElement, | |
19749 'HTMLBaseElement': () => BaseElement.internalCreateBaseElement, | |
19750 'HTMLBodyElement': () => BodyElement.internalCreateBodyElement, | |
19751 'HTMLCollection': () => HtmlCollection.internalCreateHtmlCollection, | |
19752 'HTMLDivElement': () => DivElement.internalCreateDivElement, | |
19753 'HTMLDocument': () => HtmlDocument.internalCreateHtmlDocument, | |
19754 'HTMLElement': () => HtmlElement.internalCreateHtmlElement, | |
19755 'HTMLHeadElement': () => HeadElement.internalCreateHeadElement, | |
19756 'HTMLHtmlElement': () => HtmlHtmlElement.internalCreateHtmlHtmlElement, | |
19757 'HTMLInputElement': () => InputElement.internalCreateInputElement, | |
19758 'HTMLStyleElement': () => StyleElement.internalCreateStyleElement, | |
19759 'HTMLTemplateElement': () => TemplateElement.internalCreateTemplateElement, | |
19760 'History': () => History.internalCreateHistory, | |
19761 'KeyboardEvent': () => KeyboardEvent.internalCreateKeyboardEvent, | |
19762 'Location': () => Location.internalCreateLocation, | |
19763 'MouseEvent': () => MouseEvent.internalCreateMouseEvent, | |
19764 'NamedNodeMap': () => _NamedNodeMap.internalCreate_NamedNodeMap, | |
19765 'Navigator': () => Navigator.internalCreateNavigator, | |
19766 'Node': () => Node.internalCreateNode, | |
19767 'NodeList': () => NodeList.internalCreateNodeList, | |
19768 'ProgressEvent': () => ProgressEvent.internalCreateProgressEvent, | |
19769 'Range': () => Range.internalCreateRange, | |
19770 'Screen': () => Screen.internalCreateScreen, | |
19771 'ShadowRoot': () => ShadowRoot.internalCreateShadowRoot, | |
19772 'Text': () => Text.internalCreateText, | |
19773 'UIEvent': () => UIEvent.internalCreateUIEvent, | |
19774 'Window': () => Window.internalCreateWindow, | |
19775 'XMLHttpRequest': () => HttpRequest.internalCreateHttpRequest, | |
19776 'XMLHttpRequestEventTarget': () => HttpRequestEventTarget.internalCreateHttpRe
questEventTarget, | |
19777 'XMLHttpRequestProgressEvent': () => _XMLHttpRequestProgressEvent.internalCrea
te_XMLHttpRequestProgressEvent, | |
19778 | |
19779 }; | |
19780 | |
19781 // TODO(terry): We may want to move this elsewhere if html becomes | |
19782 // a package to avoid dartium depending on pkg:html. | |
19783 getHtmlCreateFunction(String key) { | |
19784 var result; | |
19785 | |
19786 // TODO(vsm): Add Cross Frame and JS types here as well. | |
19787 | |
19788 // Check the html library. | |
19789 result = _getHtmlFunction(key); | |
19790 if (result != null) { | |
19791 return result; | |
19792 } | |
19793 return null; | |
19794 } | |
19795 | |
19796 Function _getHtmlFunction(String key) { | |
19797 if (htmlBlinkFunctionMap.containsKey(key)) { | |
19798 return htmlBlinkFunctionMap[key](); | |
19799 } | |
19800 return null; | |
19801 } | |
OLD | NEW |