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

Unified Diff: sdk/lib/html/html_common/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, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | sdk/lib/web_gl/dart2js/web_gl_dart2js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/html_common/conversions.dart
diff --git a/sdk/lib/html/html_common/conversions.dart b/sdk/lib/html/html_common/conversions.dart
index 2892b7d46ed1ff0514f6752a98df871b6de1c866..063c7e9389c0a86210320899b8f1ead858c71861 100644
--- a/sdk/lib/html/html_common/conversions.dart
+++ b/sdk/lib/html/html_common/conversions.dart
@@ -314,6 +314,49 @@ convertNativeToDart_AcceptStructuredClone(object, {mustCopy = false}) {
return copy;
}
+// Conversions for ImageData
+//
+// On Firefox, the returned ImageData is a plain object.
+
+class _TypedImageData implements ImageData {
+ final Uint8ClampedList data;
+ final int height;
+ final int width;
+
+ _TypedImageData(this.data, this.height, this.width);
+}
+
+ImageData convertNativeToDart_ImageData(nativeImageData) {
+
+ // None of the native getters that return ImageData have the type ImageData
+ // since that is incorrect for FireFox (which returns a plain Object). So we
+ // need something that tells the compiler that the ImageData class has been
+ // instantiated.
+ // TODO(sra): Remove this when all the ImageData returning APIs have been
+ // annotated as returning the union ImageData + Object.
+ JS('ImageData', '0');
+
+ if (nativeImageData is ImageData) return nativeImageData;
+
+ // On Firefox the above test fails because imagedata is a plain object.
+ // So we create a _TypedImageData.
+
+ return new _TypedImageData(
+ JS('var', '#.data', nativeImageData),
+ JS('var', '#.height', nativeImageData),
+ JS('var', '#.width', nativeImageData));
+}
+
+// We can get rid of this conversion if _TypedImageData implements the fields
+// with native names.
+convertDartToNative_ImageData(ImageData imageData) {
+ if (imageData is _TypedImageData) {
+ return JS('', '{data: #, height: #, width: #}',
+ imageData.data, imageData.height, imageData.width);
+ }
+ return imageData;
+}
+
bool isJavaScriptDate(value) => JS('bool', '# instanceof Date', value);
bool isJavaScriptRegExp(value) => JS('bool', '# instanceof RegExp', value);
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | sdk/lib/web_gl/dart2js/web_gl_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698