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

Side by Side Diff: lib/html/src/dart2js_Conversions.dart

Issue 11074005: Wrap Window in case it's a window from a different page / frame. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comment Created 8 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 | Annotate | Revision Log
« no previous file with comments | « lib/html/scripts/systemhtml.py ('k') | lib/html/src/dart2js_DOMImplementation.dart » ('j') | 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 5
6 // Conversions for IDBKey. 6 // Conversions for IDBKey.
7 // 7 //
8 // Per http://www.w3.org/TR/IndexedDB/#key-construct 8 // Per http://www.w3.org/TR/IndexedDB/#key-construct
9 // 9 //
10 // "A value is said to be a valid key if it is one of the following types: Array 10 // "A value is said to be a valid key if it is one of the following types: Array
11 // JavaScript objects [ECMA-262], DOMString [WEBIDL], Date [ECMA-262] or float 11 // JavaScript objects [ECMA-262], DOMString [WEBIDL], Date [ECMA-262] or float
12 // [WEBIDL]. However Arrays are only valid keys if every item in the array is 12 // [WEBIDL]. However Arrays are only valid keys if every item in the array is
13 // defined and is a valid key (i.e. sparse arrays can not be valid keys) and if 13 // defined and is a valid key (i.e. sparse arrays can not be valid keys) and if
14 // the Array doesn't directly or indirectly contain itself. Any non-numeric 14 // the Array doesn't directly or indirectly contain itself. Any non-numeric
15 // properties are ignored, and thus does not affect whether the Array is a valid 15 // properties are ignored, and thus does not affect whether the Array is a valid
16 // key. Additionally, if the value is of type float, it is only a valid key if 16 // key. Additionally, if the value is of type float, it is only a valid key if
17 // it is not NaN, and if the value is of type Date it is only a valid key if its 17 // it is not NaN, and if the value is of type Date it is only a valid key if its
18 // [[PrimitiveValue]] internal property, as defined by [ECMA-262], is not NaN." 18 // [[PrimitiveValue]] internal property, as defined by [ECMA-262], is not NaN."
19 19
20 // What is required is to ensure that an Lists in the key are actually 20 // What is required is to ensure that an Lists in the key are actually
21 // JavaScript arrays, and any Dates are JavaScript Dates. 21 // JavaScript arrays, and any Dates are JavaScript Dates.
22 22
23 // Conversions for Window. These check if the window is the local
24 // window, and if it's not, wraps or unwraps it with a secure wrapper.
25 // We need to test for EventTarget here as well as it's a base type.
26 // We omit an unwrapper for Window as no methods take a non-local
27 // window as a parameter.
28
29 Window _convertNativeToDart_Window(win) {
30 return _DOMWindowCrossFrameImpl._createSafe(win);
31 }
32
33 EventTarget _convertNativeToDart_EventTarget(e) {
34 // Assume it's a Window if it contains the setInterval property. It may be
35 // from a different frame - without a patched prototype - so we cannot
36 // rely on Dart type checking.
37 if (JS('bool', r'"setInterval" in #', e))
38 return _DOMWindowCrossFrameImpl._createSafe(event);
39 else
40 return e;
41 }
42
43 EventTarget _convertDartToNative_EventTarget(e) {
44 if (e is _DOMWindowCrossFrameImpl) {
45 return e._window;
46 } else {
47 return e;
48 }
49 }
50
23 // Conversions for ImageData 51 // Conversions for ImageData
24 // 52 //
25 // On Firefox, the returned ImageData is a plain object. 53 // On Firefox, the returned ImageData is a plain object.
26 54
27 class _TypedImageData implements ImageData { 55 class _TypedImageData implements ImageData {
28 final Uint8ClampedArray data; 56 final Uint8ClampedArray data;
29 final int height; 57 final int height;
30 final int width; 58 final int width;
31 59
32 _TypedImageData(this.data, this.height, this.width); 60 _TypedImageData(this.data, this.height, this.width);
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 431 }
404 432
405 433
406 bool _isJavaScriptDate(value) => JS('bool', '# instanceof Date', value); 434 bool _isJavaScriptDate(value) => JS('bool', '# instanceof Date', value);
407 bool _isJavaScriptRegExp(value) => JS('bool', '# instanceof RegExp', value); 435 bool _isJavaScriptRegExp(value) => JS('bool', '# instanceof RegExp', value);
408 bool _isJavaScriptArray(value) => JS('bool', '# instanceof Array', value); 436 bool _isJavaScriptArray(value) => JS('bool', '# instanceof Array', value);
409 bool _isJavaScriptSimpleObject(value) => 437 bool _isJavaScriptSimpleObject(value) =>
410 JS('bool', 'Object.getPrototypeOf(#) === Object.prototype', value); 438 JS('bool', 'Object.getPrototypeOf(#) === Object.prototype', value);
411 bool _isImmutableJavaScriptArray(value) => 439 bool _isImmutableJavaScriptArray(value) =>
412 JS('bool', r'!!(#.immutable$list)', value); 440 JS('bool', r'!!(#.immutable$list)', value);
OLDNEW
« no previous file with comments | « lib/html/scripts/systemhtml.py ('k') | lib/html/src/dart2js_DOMImplementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698