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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
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 return jsObject; | 395 return jsObject; |
396 } | 396 } |
| 397 |
| 398 // To preserve identity, if we already have a wrapper for this, return it. |
| 399 var existing = jsObject['dartClass_instance']; |
| 400 if (existing != null) { |
| 401 return existing; |
| 402 } |
397 // Try the most general type conversions on it. | 403 // Try the most general type conversions on it. |
398 // TODO(alanknight): We may be able to do better. This maintains identity, | 404 // 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 | 405 // 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. | 406 // this conversion handles, how does that work? e.g. a list of maps of eleme
nts. |
401 var converted = convertNativeToDart_SerializedScriptValue(jsObject); | 407 var converted = convertNativeToDart_SerializedScriptValue(jsObject); |
402 if (!identical(converted, jsObject)) { | 408 if (!identical(converted, jsObject)) { |
403 return converted; | 409 return converted; |
404 } | 410 } |
405 var constructor = jsObject['constructor']; | 411 var constructor = jsObject['constructor']; |
406 if (__interop_checks) { | 412 if (__interop_checks) { |
407 debug_or_assert("constructor != null", constructor != null); | 413 debug_or_assert("constructor != null", constructor != null); |
408 } | 414 } |
409 var jsTypeName = constructor['name']; | 415 var jsTypeName = constructor['name']; |
410 if (__interop_checks) { | 416 if (__interop_checks) { |
411 debug_or_assert("constructor != null && jsTypeName.length > 0", constructo
r != null && jsTypeName.length > 0); | 417 debug_or_assert("constructor != null && jsTypeName.length > 0", constructo
r != null && jsTypeName.length > 0); |
412 } | 418 } |
413 | 419 |
414 var dartClass_instance; | 420 var dartClass_instance; |
415 if (jsObject.hasProperty('dart_class')) { | 421 if (jsObject.hasProperty('dart_class')) { |
416 // Got a dart_class (it's a custom element) use it it's already set up. | 422 // Got a dart_class (it's a custom element) use it it's already set up. |
417 dartClass_instance = jsObject['dart_class']; | 423 dartClass_instance = jsObject['dart_class']; |
418 } else { | 424 } else { |
419 var func = getHtmlCreateFunction(jsTypeName); | 425 var func = getHtmlCreateFunction(jsTypeName); |
420 if (func != null) { | 426 if (func != null) { |
421 dartClass_instance = func(); | 427 dartClass_instance = func(); |
422 dartClass_instance.blink_jsObject = jsObject; | 428 dartClass_instance.blink_jsObject = jsObject; |
| 429 jsObject['dartClass_instance'] = dartClass_instance; |
423 } | 430 } |
424 } | 431 } |
425 return dartClass_instance; | 432 return dartClass_instance; |
426 } catch(e, stacktrace){ | 433 } catch(e, stacktrace){ |
427 if (__interop_checks) { | 434 if (__interop_checks) { |
428 if (e is DebugAssertException) | 435 if (e is DebugAssertException) |
429 window.console.log("${e.message}\n ${stacktrace}"); | 436 window.console.log("${e.message}\n ${stacktrace}"); |
430 else | 437 else |
431 window.console.log("${stacktrace}"); | 438 window.console.log("${stacktrace}"); |
432 } | 439 } |
433 } | 440 } |
434 | 441 |
435 return null; | 442 return null; |
436 } | 443 } |
437 | 444 |
| 445 |
438 /** | 446 /** |
439 * Create Dart class that maps to the JS Type that is the JS type being | 447 * Create Dart class that maps to the JS Type that is the JS type being |
440 * extended using JS interop createCallback (we need the base type of the | 448 * extended using JS interop createCallback (we need the base type of the |
441 * custom element) not the Dart created constructor. | 449 * custom element) not the Dart created constructor. |
442 */ | 450 */ |
443 wrap_jso_custom_element(jsObject) { | 451 wrap_jso_custom_element(jsObject) { |
444 try { | 452 try { |
445 if (jsObject is! js.JsObject) { | 453 if (jsObject is! js.JsObject) { |
446 // JS Interop converted the object to a Dart class e.g., Uint8ClampedList. | 454 // JS Interop converted the object to a Dart class e.g., Uint8ClampedList. |
447 return jsObject; | 455 return jsObject; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 class JsoNativeFieldWrapper extends NativeFieldWrapperClass2 {} | 550 class JsoNativeFieldWrapper extends NativeFieldWrapperClass2 {} |
543 | 551 |
544 unwrap_jso(dartClass_instance) => dartClass_instance; | 552 unwrap_jso(dartClass_instance) => dartClass_instance; |
545 wrap_jso(jsObject) => jsObject; | 553 wrap_jso(jsObject) => jsObject; |
546 make_dart_rectangle(r) => r; | 554 make_dart_rectangle(r) => r; |
547 convertDartToNative_Dictionary(Map dict) => dict; | 555 convertDartToNative_Dictionary(Map dict) => dict; |
548 List convertDartToNative_StringArray(List<String> input) => input; | 556 List convertDartToNative_StringArray(List<String> input) => input; |
549 convertDartToNative_List(List input) => input; | 557 convertDartToNative_List(List input) => input; |
550 | 558 |
551 $endif | 559 $endif |
OLD | NEW |