| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 return dartClass_instance; | 383 return dartClass_instance; |
| 384 } | 384 } |
| 385 } | 385 } |
| 386 | 386 |
| 387 /** | 387 /** |
| 388 * Create Dart class that maps to the JS Type, add the JsObject as an expando | 388 * Create Dart class that maps to the JS Type, add the JsObject as an expando |
| 389 * on the Dart class and return the created Dart class. | 389 * on the Dart class and return the created Dart class. |
| 390 */ | 390 */ |
| 391 wrap_jso(jsObject) { | 391 wrap_jso(jsObject) { |
| 392 try { | 392 try { |
| 393 if (jsObject is! js.JsObject) { | 393 if (jsObject is! js.JsObject || jsObject == null) { |
| 394 // JS Interop converted the object to a Dart class e.g., Uint8ClampedList. | 394 // JS Interop converted the object to a Dart class e.g., Uint8ClampedList. |
| 395 // or it's a simple type. |
| 395 return jsObject; | 396 return jsObject; |
| 396 } | 397 } |
| 398 |
| 399 // TODO(alanknight): With upgraded custom elements this causes a failure bec
ause |
| 400 // we need a new wrapper after the type changes. We could possibly invalidat
e this |
| 401 // if the constructor name didn't match? |
| 402 if (jsObject.dartWrapper != null) { |
| 403 return jsObject.dartWrapper; |
| 404 } |
| 405 |
| 397 // Try the most general type conversions on it. | 406 // Try the most general type conversions on it. |
| 398 // TODO(alanknight): We may be able to do better. This maintains identity, | 407 // TODO(alanknight): We may be able to do better. This maintains identity, |
| 399 // which is useful, but expensive. And if we nest something that only | 408 // which is useful, but expensive. And if we nest something that only |
| 400 // this conversion handles, how does that work? e.g. a list of maps of eleme
nts. | 409 // this conversion handles, how does that work? e.g. a list of maps of eleme
nts. |
| 401 var converted = convertNativeToDart_SerializedScriptValue(jsObject); | 410 var converted = convertNativeToDart_SerializedScriptValue(jsObject); |
| 402 if (!identical(converted, jsObject)) { | 411 if (!identical(converted, jsObject)) { |
| 403 return converted; | 412 return converted; |
| 404 } | 413 } |
| 405 var constructor = jsObject['constructor']; | 414 var constructor = jsObject['constructor']; |
| 406 if (__interop_checks) { | 415 if (__interop_checks) { |
| 407 debug_or_assert("constructor != null", constructor != null); | 416 debug_or_assert("constructor != null", constructor != null); |
| 408 } | 417 } |
| 409 var jsTypeName = constructor['name']; | 418 var jsTypeName = constructor['name']; |
| 410 if (__interop_checks) { | 419 if (__interop_checks) { |
| 411 debug_or_assert("constructor != null && jsTypeName.length > 0", constructo
r != null && jsTypeName.length > 0); | 420 debug_or_assert("constructor != null && jsTypeName.length > 0", constructo
r != null && jsTypeName.length > 0); |
| 412 } | 421 } |
| 413 | 422 |
| 414 var dartClass_instance; | 423 var dartClass_instance; |
| 415 if (jsObject.hasProperty('dart_class')) { | 424 if (jsObject.hasProperty('dart_class')) { |
| 416 // Got a dart_class (it's a custom element) use it it's already set up. | 425 // Got a dart_class (it's a custom element) use it it's already set up. |
| 417 dartClass_instance = jsObject['dart_class']; | 426 dartClass_instance = jsObject['dart_class']; |
| 418 } else { | 427 } else { |
| 419 var func = getHtmlCreateFunction(jsTypeName); | 428 var func = getHtmlCreateFunction(jsTypeName); |
| 420 if (func != null) { | 429 if (func != null) { |
| 421 dartClass_instance = func(); | 430 dartClass_instance = func(); |
| 422 dartClass_instance.blink_jsObject = jsObject; | 431 dartClass_instance.blink_jsObject = jsObject; |
| 432 jsObject.dartWrapper = dartClass_instance; |
| 423 } | 433 } |
| 424 } | 434 } |
| 425 return dartClass_instance; | 435 return dartClass_instance; |
| 426 } catch(e, stacktrace){ | 436 } catch(e, stacktrace){ |
| 427 if (__interop_checks) { | 437 if (__interop_checks) { |
| 428 if (e is DebugAssertException) | 438 if (e is DebugAssertException) |
| 429 window.console.log("${e.message}\n ${stacktrace}"); | 439 window.console.log("${e.message}\n ${stacktrace}"); |
| 430 else | 440 else |
| 431 window.console.log("${stacktrace}"); | 441 window.console.log("${stacktrace}"); |
| 432 } | 442 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 class JsoNativeFieldWrapper extends NativeFieldWrapperClass2 {} | 552 class JsoNativeFieldWrapper extends NativeFieldWrapperClass2 {} |
| 543 | 553 |
| 544 unwrap_jso(dartClass_instance) => dartClass_instance; | 554 unwrap_jso(dartClass_instance) => dartClass_instance; |
| 545 wrap_jso(jsObject) => jsObject; | 555 wrap_jso(jsObject) => jsObject; |
| 546 make_dart_rectangle(r) => r; | 556 make_dart_rectangle(r) => r; |
| 547 convertDartToNative_Dictionary(Map dict) => dict; | 557 convertDartToNative_Dictionary(Map dict) => dict; |
| 548 List convertDartToNative_StringArray(List<String> input) => input; | 558 List convertDartToNative_StringArray(List<String> input) => input; |
| 549 convertDartToNative_List(List input) => input; | 559 convertDartToNative_List(List input) => input; |
| 550 | 560 |
| 551 $endif | 561 $endif |
| OLD | NEW |