| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 346 } |
| 347 | 347 |
| 348 | 348 |
| 349 /****************************************************************************** | 349 /****************************************************************************** |
| 350 ********** ********** | 350 ********** ********** |
| 351 ********** JS Interop Support ********** | 351 ********** JS Interop Support ********** |
| 352 ********** ********** | 352 ********** ********** |
| 353 ******************************************************************************/ | 353 ******************************************************************************/ |
| 354 | 354 |
| 355 // List of known tagName to DartClass for custom elements, used for upgrade. | 355 // List of known tagName to DartClass for custom elements, used for upgrade. |
| 356 var _knownCustomElements = new Map<String, Type>(); | 356 var _knownCustomElements = new Map<String, Map<Type, String>>(); |
| 357 | 357 |
| 358 void _addCustomElementType(String tagName, Type dartClass) { | 358 void _addCustomElementType(String tagName, Type dartClass, [String extendTag]) { |
| 359 _knownCustomElements[tagName] = dartClass; | 359 _knownCustomElements[tagName] = |
| 360 {'type': dartClass, 'extends': extendTag != null ? extendTag : "" }; |
| 360 } | 361 } |
| 361 | 362 |
| 362 Type _getCustomElementType(object) => _knownCustomElements[_getCustomElementName
(object)]; | 363 Type _getCustomElementType(object) { |
| 364 var entry = _knownCustomElements[_getCustomElementName(object)]; |
| 365 if (entry != null) { |
| 366 return entry['type']; |
| 367 } |
| 368 return null; |
| 369 } |
| 370 |
| 371 String _getCustomElementExtends(object) { |
| 372 var entry = _knownCustomElements[_getCustomElementName(object)]; |
| 373 if (entry != null) { |
| 374 return entry['extends']; |
| 375 } |
| 376 return null; |
| 377 } |
| 378 |
| 379 _getCustomElement(object) => _knownCustomElements[_getCustomElementName(object)]
; |
| 363 | 380 |
| 364 // Return the tag name or is attribute of the custom element or data binding. | 381 // Return the tag name or is attribute of the custom element or data binding. |
| 365 String _getCustomElementName(element) { | 382 String _getCustomElementName(element) { |
| 366 var jsObject; | 383 var jsObject; |
| 367 var tag = ""; | 384 var tag = ""; |
| 368 var runtimeType = element.runtimeType; | 385 var runtimeType = element.runtimeType; |
| 369 if (runtimeType == HtmlElement) { | 386 if (runtimeType == HtmlElement) { |
| 370 tag = element.localName; | 387 tag = element.localName; |
| 371 } else if (runtimeType == TemplateElement) { | 388 } else if (runtimeType == TemplateElement) { |
| 372 // Data binding with a Dart class. | 389 // Data binding with a Dart class. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 js.setDartHtmlWrapperFor(jsObject, jsObject); | 498 js.setDartHtmlWrapperFor(jsObject, jsObject); |
| 482 return jsObject; | 499 return jsObject; |
| 483 } | 500 } |
| 484 | 501 |
| 485 var dartClass_instance; | 502 var dartClass_instance; |
| 486 if (jsObject.hasProperty('dart_class')) { | 503 if (jsObject.hasProperty('dart_class')) { |
| 487 // Got a dart_class (it's a custom element) use it it's already set up | 504 // Got a dart_class (it's a custom element) use it it's already set up |
| 488 // make sure it's upgraded. | 505 // make sure it's upgraded. |
| 489 dartClass_instance = _upgradeHtmlElement(jsObject['dart_class']); | 506 dartClass_instance = _upgradeHtmlElement(jsObject['dart_class']); |
| 490 } else { | 507 } else { |
| 491 var customElementClass = _getCustomElementType(jsObject); | 508 var customElementClass = null; |
| 509 var extendsTag = ""; |
| 510 var custom = _getCustomElement(jsObject); |
| 511 if (custom != null) { |
| 512 customElementClass = custom['type']; |
| 513 extendsTag = custom['extends']; |
| 514 } |
| 492 // Custom Element to upgrade. | 515 // Custom Element to upgrade. |
| 493 if (jsTypeName == 'HTMLElement' && customElementClass != null) { | 516 if (jsTypeName == 'HTMLElement' && customElementClass != null && extendsTa
g == "") { |
| 494 try { | 517 try { |
| 495 dartClass_instance = _blink.Blink_Utils.constructElement(customElement
Class, jsObject); | 518 dartClass_instance = _blink.Blink_Utils.constructElement(customElement
Class, jsObject); |
| 496 } finally { | 519 } finally { |
| 497 dartClass_instance.blink_jsObject = jsObject; | 520 dartClass_instance.blink_jsObject = jsObject; |
| 498 jsObject['dart_class'] = dartClass_instance; | 521 jsObject['dart_class'] = dartClass_instance; |
| 499 js.setDartHtmlWrapperFor(jsObject, dartClass_instance); | 522 js.setDartHtmlWrapperFor(jsObject, dartClass_instance); |
| 500 } | 523 } |
| 501 } else { | 524 } else { |
| 502 // TODO(terry): Verify with jakemacd that this is right? | 525 // TODO(terry): Verify with jakemacd that this is right? |
| 503 // If we every get an auto-binding we're matching previous non-JS Intero
p | 526 // If we every get an auto-binding we're matching previous non-JS Intero
p |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 | 788 |
| 766 unwrap_jso(dartClass_instance) => dartClass_instance; | 789 unwrap_jso(dartClass_instance) => dartClass_instance; |
| 767 wrap_jso(jsObject) => jsObject; | 790 wrap_jso(jsObject) => jsObject; |
| 768 make_dart_rectangle(r) => r; | 791 make_dart_rectangle(r) => r; |
| 769 convertDartToNative_Dictionary(Map dict) => dict; | 792 convertDartToNative_Dictionary(Map dict) => dict; |
| 770 List convertDartToNative_StringArray(List<String> input) => input; | 793 List convertDartToNative_StringArray(List<String> input) => input; |
| 771 convertDartToNative_List(List input) => input; | 794 convertDartToNative_List(List input) => input; |
| 772 createCustomUpgrader(Type customElementClass, $this) => $this; | 795 createCustomUpgrader(Type customElementClass, $this) => $this; |
| 773 | 796 |
| 774 $endif | 797 $endif |
| OLD | NEW |