| 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 | |
| 6 // Conversions for Window. These check if the window is the local | 5 // Conversions for Window. These check if the window is the local |
| 7 // window, and if it's not, wraps or unwraps it with a secure wrapper. | 6 // window, and if it's not, wraps or unwraps it with a secure wrapper. |
| 8 // We need to test for EventTarget here as well as it's a base type. | 7 // We need to test for EventTarget here as well as it's a base type. |
| 9 // We omit an unwrapper for Window as no methods take a non-local | 8 // We omit an unwrapper for Window as no methods take a non-local |
| 10 // window as a parameter. | 9 // window as a parameter. |
| 11 | 10 |
| 12 part of html; | 11 part of html; |
| 13 | 12 |
| 14 WindowBase _convertNativeToDart_Window(win) { | 13 WindowBase _convertNativeToDart_Window(win) { |
| 15 if (win == null) return null; | 14 if (win == null) return null; |
| 16 return _DOMWindowCrossFrame._createSafe(win); | 15 return _DOMWindowCrossFrame._createSafe(win); |
| 17 } | 16 } |
| 18 | 17 |
| 19 EventTarget _convertNativeToDart_EventTarget(e) { | 18 EventTarget _convertNativeToDart_EventTarget(e) { |
| 20 if (e == null) { | 19 if (e == null) { |
| 21 return null; | 20 return null; |
| 22 } | 21 } |
| 23 // Assume it's a Window if it contains the postMessage property. It may be | 22 // Assume it's a Window if it contains the postMessage property. It may be |
| 24 // from a different frame - without a patched prototype - so we cannot | 23 // from a different frame - without a patched prototype - so we cannot |
| 25 // rely on Dart type checking. | 24 // rely on Dart type checking. |
| 26 if (JS('bool', r'"postMessage" in #', e)) { | 25 if (JS('bool', r'"postMessage" in #', e)) { |
| 27 var window = _DOMWindowCrossFrame._createSafe(e); | 26 var window = _DOMWindowCrossFrame._createSafe(e); |
| 28 // If it's a native window. | 27 // If it's a native window. |
| 29 if (window is EventTarget) { | 28 if (window is EventTarget) { |
| 30 return window; | 29 return window; |
| 31 } | 30 } |
| 32 return null; | 31 return null; |
| 33 } | 32 } else |
| 34 else | |
| 35 return e; | 33 return e; |
| 36 } | 34 } |
| 37 | 35 |
| 38 EventTarget _convertDartToNative_EventTarget(e) { | 36 EventTarget _convertDartToNative_EventTarget(e) { |
| 39 if (e is _DOMWindowCrossFrame) { | 37 if (e is _DOMWindowCrossFrame) { |
| 40 return e._window; | 38 return e._window; |
| 41 } else { | 39 } else { |
| 42 return e; | 40 return e; |
| 43 } | 41 } |
| 44 } | 42 } |
| 45 | 43 |
| 46 _convertNativeToDart_XHR_Response(o) { | 44 _convertNativeToDart_XHR_Response(o) { |
| 47 if (o is Document) { | 45 if (o is Document) { |
| 48 return o; | 46 return o; |
| 49 } | 47 } |
| 50 return convertNativeToDart_SerializedScriptValue(o); | 48 return convertNativeToDart_SerializedScriptValue(o); |
| 51 } | 49 } |
| OLD | NEW |