Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Side by Side Diff: tools/dom/templates/html/dartium/html_dartium.darttemplate

Issue 1380603004: Revert "Preserve identity on wrap_jso hack. Has known failures" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
400 if (jsObject is! js.JsArray) {
401 var existing = jsObject['dartClass_instance'];
402 try {
403 if (unwrap_jso(existing) == jsObject) {
404 return existing;
405 }
406 } catch(e) {}
407 }
408 // Try the most general type conversions on it. 397 // Try the most general type conversions on it.
409 // TODO(alanknight): We may be able to do better. This maintains identity, 398 // TODO(alanknight): We may be able to do better. This maintains identity,
410 // which is useful, but expensive. And if we nest something that only 399 // which is useful, but expensive. And if we nest something that only
411 // this conversion handles, how does that work? e.g. a list of maps of eleme nts. 400 // this conversion handles, how does that work? e.g. a list of maps of eleme nts.
412 var converted = convertNativeToDart_SerializedScriptValue(jsObject); 401 var converted = convertNativeToDart_SerializedScriptValue(jsObject);
413 if (!identical(converted, jsObject)) { 402 if (!identical(converted, jsObject)) {
414 return converted; 403 return converted;
415 } 404 }
416 var constructor = jsObject['constructor']; 405 var constructor = jsObject['constructor'];
417 if (__interop_checks) { 406 if (__interop_checks) {
418 debug_or_assert("constructor != null", constructor != null); 407 debug_or_assert("constructor != null", constructor != null);
419 } 408 }
420 var jsTypeName = constructor['name']; 409 var jsTypeName = constructor['name'];
421 if (__interop_checks) { 410 if (__interop_checks) {
422 debug_or_assert("constructor != null && jsTypeName.length > 0", constructo r != null && jsTypeName.length > 0); 411 debug_or_assert("constructor != null && jsTypeName.length > 0", constructo r != null && jsTypeName.length > 0);
423 } 412 }
424 413
425 var dartClass_instance; 414 var dartClass_instance;
426 if (jsObject.hasProperty('dart_class')) { 415 if (jsObject.hasProperty('dart_class')) {
427 // Got a dart_class (it's a custom element) use it it's already set up. 416 // Got a dart_class (it's a custom element) use it it's already set up.
428 dartClass_instance = jsObject['dart_class']; 417 dartClass_instance = jsObject['dart_class'];
429 } else { 418 } else {
430 var func = getHtmlCreateFunction(jsTypeName); 419 var func = getHtmlCreateFunction(jsTypeName);
431 if (func != null) { 420 if (func != null) {
432 dartClass_instance = func(); 421 dartClass_instance = func();
433 dartClass_instance.blink_jsObject = jsObject; 422 dartClass_instance.blink_jsObject = jsObject;
434 jsObject['dartClass_instance'] = dartClass_instance;
435 } 423 }
436 } 424 }
437 return dartClass_instance; 425 return dartClass_instance;
438 } catch(e, stacktrace){ 426 } catch(e, stacktrace){
439 if (__interop_checks) { 427 if (__interop_checks) {
440 if (e is DebugAssertException) 428 if (e is DebugAssertException)
441 window.console.log("${e.message}\n ${stacktrace}"); 429 window.console.log("${e.message}\n ${stacktrace}");
442 else 430 else
443 window.console.log("${stacktrace}"); 431 window.console.log("${stacktrace}");
444 } 432 }
445 } 433 }
446 434
447 return null; 435 return null;
448 } 436 }
449 437
450
451 /** 438 /**
452 * Create Dart class that maps to the JS Type that is the JS type being 439 * Create Dart class that maps to the JS Type that is the JS type being
453 * extended using JS interop createCallback (we need the base type of the 440 * extended using JS interop createCallback (we need the base type of the
454 * custom element) not the Dart created constructor. 441 * custom element) not the Dart created constructor.
455 */ 442 */
456 wrap_jso_custom_element(jsObject) { 443 wrap_jso_custom_element(jsObject) {
457 try { 444 try {
458 if (jsObject is! js.JsObject) { 445 if (jsObject is! js.JsObject) {
459 // JS Interop converted the object to a Dart class e.g., Uint8ClampedList. 446 // JS Interop converted the object to a Dart class e.g., Uint8ClampedList.
460 return jsObject; 447 return jsObject;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 class JsoNativeFieldWrapper extends NativeFieldWrapperClass2 {} 542 class JsoNativeFieldWrapper extends NativeFieldWrapperClass2 {}
556 543
557 unwrap_jso(dartClass_instance) => dartClass_instance; 544 unwrap_jso(dartClass_instance) => dartClass_instance;
558 wrap_jso(jsObject) => jsObject; 545 wrap_jso(jsObject) => jsObject;
559 make_dart_rectangle(r) => r; 546 make_dart_rectangle(r) => r;
560 convertDartToNative_Dictionary(Map dict) => dict; 547 convertDartToNative_Dictionary(Map dict) => dict;
561 List convertDartToNative_StringArray(List<String> input) => input; 548 List convertDartToNative_StringArray(List<String> input) => input;
562 convertDartToNative_List(List input) => input; 549 convertDartToNative_List(List input) => input;
563 550
564 $endif 551 $endif
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698