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

Unified Diff: ui/file_manager/gallery/js/image_editor/image_util.js

Issue 1608143002: support animated GIF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
Index: ui/file_manager/gallery/js/image_editor/image_util.js
diff --git a/ui/file_manager/gallery/js/image_editor/image_util.js b/ui/file_manager/gallery/js/image_editor/image_util.js
index 4d93c7a6a9d44d976f5def126f017db10e6c96a9..3fc7a2915b3b675145245c60ff81d1f91d4dfee3 100644
--- a/ui/file_manager/gallery/js/image_editor/image_util.js
+++ b/ui/file_manager/gallery/js/image_editor/image_util.js
@@ -440,7 +440,6 @@ ImageUtil.ImageLoader = function(document, metadataModel) {
*/
this.metadataModel_ = metadataModel;
- this.image_ = new Image();
this.generation_ = 0;
/**
@@ -480,7 +479,8 @@ ImageUtil.ImageLoader.prototype.load = function(item, callback, opt_delay) {
this.entry_ = entry;
this.callback_ = callback;
- var targetImage = this.image_;
+ var targetImage = assertInstanceof(this.document_.createElement('img'),
+ HTMLImageElement);
// The transform fetcher is not cancellable so we need a generation counter.
var generation = ++this.generation_;
@@ -491,7 +491,7 @@ ImageUtil.ImageLoader.prototype.load = function(item, callback, opt_delay) {
var onTransform = function(image, opt_transform) {
if (generation === this.generation_) {
this.convertImage_(
- image, opt_transform || { scaleX: 1, scaleY: 1, rotate90: 0});
+ image, opt_transform);
yawano 2016/01/20 06:41:33 nit: this line also fits in one line.
ryoh 2016/01/21 03:19:55 Done.
}
};
onTransform = onTransform.bind(this);
@@ -540,9 +540,6 @@ ImageUtil.ImageLoader.prototype.load = function(item, callback, opt_delay) {
if (generation !== this.generation_)
return;
- // Target current image.
- targetImage = this.image_;
-
// Obtain target URL.
if (FileType.isRaw(entry)) {
var timestamp =
@@ -610,14 +607,6 @@ ImageUtil.ImageLoader.prototype.cancel = function() {
clearTimeout(this.timeout_);
this.timeout_ = 0;
}
- if (this.image_) {
- this.image_.onload = function() {};
- this.image_.onerror = function() {};
- // Force to free internal image by assigning empty image.
- this.image_.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAA' +
- 'AAABAAEAAAICTAEAOw==';
- this.image_ = document.createElement('img');
- }
this.generation_++; // Silence the transform fetcher if it is in progress.
};
@@ -627,6 +616,18 @@ ImageUtil.ImageLoader.prototype.cancel = function() {
* @private
*/
ImageUtil.ImageLoader.prototype.convertImage_ = function(image, transform) {
+ if (!transform ||
+ (transform.rotate90 === 0 &&
+ transform.scaleX === 1 &&
+ transform.scaleY === 1)) {
+ try {
hirono 2016/01/20 06:07:09 Why is this try closure needed?
ryoh 2016/01/21 03:19:55 It's copied from here: https://code.google.com/p/c
+ setTimeout(this.callback_, 0, image);
+ } catch (e) {
+ console.error(e);
+ }
+ this.callback_ = null;
+ return;
+ }
var canvas = this.document_.createElement('canvas');
if (transform.rotate90 & 1) { // Rotated +/-90deg, swap the dimensions.

Powered by Google App Engine
This is Rietveld 408576698