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

Unified Diff: third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js

Issue 2592113003: Load data URI images in an async way according to spec (take 3) (Closed)
Patch Set: Fix browser test Created 4 years 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: third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js
diff --git a/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js b/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js
index e79a21f044972f003af4e91230e7625f9dcb6f57..73982cf1e1d6cb67699fa86cb1788bbe3bd99179 100644
--- a/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js
+++ b/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js
@@ -453,18 +453,21 @@ Emulation.DeviceModeView = class extends UI.VBox {
function paintScreenshot() {
var pageImage = new Image();
pageImage.src = 'data:image/png;base64,' + content;
- ctx.drawImage(
- pageImage, visiblePageRect.left, visiblePageRect.top, Math.min(pageImage.naturalWidth, screenRect.width),
- Math.min(pageImage.naturalHeight, screenRect.height));
- var url = mainTarget && mainTarget.inspectedURL();
- var fileName = url ? url.trimURL().removeURLFragment() : '';
- if (this._model.type() === Emulation.DeviceModeModel.Type.Device)
- fileName += Common.UIString('(%s)', this._model.device().title);
- // Trigger download.
- var link = createElement('a');
- link.download = fileName + '.png';
- link.href = canvas.toDataURL('image/png');
- link.click();
+ var scope = this;
+ setTimeout(function() {
dgozman 2016/12/27 07:08:24 Should this be pageImage.onload = ... ? Also, usin
+ ctx.drawImage(
+ pageImage, visiblePageRect.left, visiblePageRect.top, Math.min(pageImage.naturalWidth, screenRect.width),
+ Math.min(pageImage.naturalHeight, screenRect.height));
+ var url = mainTarget && mainTarget.inspectedURL();
+ var fileName = url ? url.trimURL().removeURLFragment() : '';
+ if (scope._model.type() === Emulation.DeviceModeModel.Type.Device)
+ fileName += Common.UIString('(%s)', scope._model.device().title);
+ // Trigger download.
+ var link = createElement('a');
+ link.download = fileName + '.png';
+ link.href = canvas.toDataURL('image/png');
+ link.click();
+ }, 0);
}
}
}
« no previous file with comments | « third_party/WebKit/Source/core/loader/ImageLoader.cpp ('k') | third_party/WebKit/Source/web/tests/ActivityLoggerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698