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

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: Fixed more devtools reliance on sync loading Created 3 years, 12 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: 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..ce6aef2fe18dd3a2b95a5b1b6cb15d2951cdaedd 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,20 @@ 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();
+ pageImage.onload = () => {
+ 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();
+ };
}
}
}

Powered by Google App Engine
This is Rietveld 408576698