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

Side by Side Diff: tools/dom/src/dart2js_Conversions.dart

Issue 16336022: Fixing a number of Dart2JS compiler warnings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | « tools/dom/scripts/generator.py ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('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 Window. These check if the window is the local 6 // 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. 7 // 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. 8 // 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 9 // We omit an unwrapper for Window as no methods take a non-local
10 // window as a parameter. 10 // window as a parameter.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return e; 44 return e;
45 } 45 }
46 46
47 EventTarget _convertDartToNative_EventTarget(e) { 47 EventTarget _convertDartToNative_EventTarget(e) {
48 if (e is _DOMWindowCrossFrame) { 48 if (e is _DOMWindowCrossFrame) {
49 return e._window; 49 return e._window;
50 } else { 50 } else {
51 return e; 51 return e;
52 } 52 }
53 } 53 }
54
55 // Conversions for ImageData
56 //
57 // On Firefox, the returned ImageData is a plain object.
58
59 class _TypedImageData implements ImageData {
60 final Uint8ClampedList data;
61 final int height;
62 final int width;
63
64 _TypedImageData(this.data, this.height, this.width);
65 }
66
67 ImageData _convertNativeToDart_ImageData(nativeImageData) {
68
69 // None of the native getters that return ImageData have the type ImageData
70 // since that is incorrect for FireFox (which returns a plain Object). So we
71 // need something that tells the compiler that the ImageData class has been
72 // instantiated.
73 // TODO(sra): Remove this when all the ImageData returning APIs have been
74 // annotated as returning the union ImageData + Object.
75 JS('ImageData', '0');
76
77 if (nativeImageData is ImageData) return nativeImageData;
78
79 // On Firefox the above test fails because imagedata is a plain object.
80 // So we create a _TypedImageData.
81
82 return new _TypedImageData(
83 JS('var', '#.data', nativeImageData),
84 JS('var', '#.height', nativeImageData),
85 JS('var', '#.width', nativeImageData));
86 }
87
88 // We can get rid of this conversion if _TypedImageData implements the fields
89 // with native names.
90 _convertDartToNative_ImageData(ImageData imageData) {
91 if (imageData is _TypedImageData) {
92 return JS('', '{data: #, height: #, width: #}',
93 imageData.data, imageData.height, imageData.width);
94 }
95 return imageData;
96 }
OLDNEW
« no previous file with comments | « tools/dom/scripts/generator.py ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698