OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // DO NOT EDIT | 5 // DO NOT EDIT |
6 // Auto-generated dart:html library. | 6 // Auto-generated dart:html library. |
7 | 7 |
8 /** | 8 /** |
9 * HTML elements and other resources for web-based applications that need to | 9 * HTML elements and other resources for web-based applications that need to |
10 * interact with the browser and the DOM (Document Object Model). | 10 * interact with the browser and the DOM (Document Object Model). |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 if (__interop_checks) { | 413 if (__interop_checks) { |
414 debug_or_assert("constructor != null", constructor != null); | 414 debug_or_assert("constructor != null", constructor != null); |
415 } | 415 } |
416 var jsTypeName = constructor['name']; | 416 var jsTypeName = constructor['name']; |
417 if (__interop_checks) { | 417 if (__interop_checks) { |
418 debug_or_assert("constructor != null && jsTypeName.length > 0", constructo r != null && jsTypeName.length > 0); | 418 debug_or_assert("constructor != null && jsTypeName.length > 0", constructo r != null && jsTypeName.length > 0); |
419 } | 419 } |
420 | 420 |
421 var dartClass_instance; | 421 var dartClass_instance; |
422 if (jsObject.hasProperty('dart_class')) { | 422 if (jsObject.hasProperty('dart_class')) { |
423 // Got a dart_class (it's a custom element) use it it's already set up. | 423 // Got a dart_class (it's a custom element) use it it's already set up |
424 dartClass_instance = jsObject['dart_class']; | 424 // make sure it's upgraded. |
425 dartClass_instance = _upgradeHtmlElement(jsObject['dart_class']); | |
425 } else { | 426 } else { |
426 var localName = jsObject['localName']; | 427 var localName = jsObject['localName']; |
427 var customElementClass = _knownCustomeElements[localName]; | 428 var customElementClass = _knownCustomeElements[localName]; |
428 // Custom Element to upgrade. | 429 // Custom Element to upgrade. |
429 if (jsTypeName == 'HTMLElement' && customElementClass != null) { | 430 if (jsTypeName == 'HTMLElement' && customElementClass != null) { |
430 try { | 431 try { |
431 dartClass_instance = _blink.Blink_Utils.constructElement(customElement Class, jsObject); | 432 dartClass_instance = _blink.Blink_Utils.constructElement(customElement Class, jsObject); |
432 } finally { | 433 } finally { |
433 dartClass_instance.blink_jsObject = jsObject; | 434 dartClass_instance.blink_jsObject = jsObject; |
434 jsObject['dart_class'] = dartClass_instance; | 435 jsObject['dart_class'] = dartClass_instance; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 window.console.log("${e.message}\n ${stacktrace}"); | 489 window.console.log("${e.message}\n ${stacktrace}"); |
489 else | 490 else |
490 window.console.log("${stacktrace}"); | 491 window.console.log("${stacktrace}"); |
491 } | 492 } |
492 | 493 |
493 // Problem? | 494 // Problem? |
494 return null; | 495 return null; |
495 } | 496 } |
496 } | 497 } |
497 | 498 |
499 // Upgrade a Dart HtmlElement to the user's Dart custom element class. | |
500 _upgradeHtmlElement(dartInstance) { | |
501 var dartInstanceMirror = reflect(dartInstance); | |
502 if (dartInstanceMirror.type.qualifiedName == #dart.dom.html.HtmlElement) { | |
Alan Knight
2015/10/07 16:21:29
Could you do this with dartInstance.runtimeType ==
| |
503 // Must be exactly HtmlElement not something derived from it. | |
504 var jsObject = dartInstance.blink_jsObject; | |
505 var localName = dartInstance.localName; | |
506 var customElementClass = _knownCustomeElements[localName]; | |
507 // Custom Element to upgrade. | |
508 if (customElementClass != null) { | |
509 try { | |
510 dartInstance = _blink.Blink_Utils.constructElement(customElementClass, j sObject); | |
511 } finally { | |
512 dartInstance.blink_jsObject = jsObject; | |
513 jsObject['dart_class'] = dartInstance; | |
514 js.setDartHtmlWrapperFor(jsObject, dartInstance); | |
515 } | |
516 } | |
517 } | |
518 | |
519 return dartInstance; | |
520 } | |
521 | |
498 class DebugAssertException implements Exception { | 522 class DebugAssertException implements Exception { |
499 String message; | 523 String message; |
500 DebugAssertException(this.message); | 524 DebugAssertException(this.message); |
501 } | 525 } |
502 | 526 |
503 debug_or_assert(message, expression) { | 527 debug_or_assert(message, expression) { |
504 if (!expression) { | 528 if (!expression) { |
505 throw new DebugAssertException("$message"); | 529 throw new DebugAssertException("$message"); |
506 } | 530 } |
507 } | 531 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 | 623 |
600 unwrap_jso(dartClass_instance) => dartClass_instance; | 624 unwrap_jso(dartClass_instance) => dartClass_instance; |
601 wrap_jso(jsObject) => jsObject; | 625 wrap_jso(jsObject) => jsObject; |
602 make_dart_rectangle(r) => r; | 626 make_dart_rectangle(r) => r; |
603 convertDartToNative_Dictionary(Map dict) => dict; | 627 convertDartToNative_Dictionary(Map dict) => dict; |
604 List convertDartToNative_StringArray(List<String> input) => input; | 628 List convertDartToNative_StringArray(List<String> input) => input; |
605 convertDartToNative_List(List input) => input; | 629 convertDartToNative_List(List input) => input; |
606 createCustomUpgrader(Type customElementClass, $this) => $this; | 630 createCustomUpgrader(Type customElementClass, $this) => $this; |
607 | 631 |
608 $endif | 632 $endif |
OLD | NEW |