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

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

Issue 2702113006: [DevTools] Full-size screenshots in device mode. (Closed)
Patch Set: Created 3 years, 10 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 656d38285fb3b038dadb75efac26d6da16504e5a..b0ae7476359342bee0b16b25ad4f519a137ef785 100644
--- a/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js
+++ b/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js
@@ -470,6 +470,35 @@ Emulation.DeviceModeView = class extends UI.VBox {
}
}
}
+
+ captureFullSizeScreenshot() {
+ SDK.DOMModel.muteHighlight();
+ this._model.captureFullSizeScreenshot(content => {
+ SDK.DOMModel.unmuteHighlight();
+ if (content === null)
+ return;
+ var canvas = createElement('canvas');
+ var pageImage = new Image();
+ pageImage.src = 'data:image/png;base64,' + content;
+ pageImage.onload = () => {
+ var ctx = canvas.getContext('2d');
+ ctx.imageSmoothingEnabled = false;
+ canvas.width = pageImage.width;
+ canvas.height = pageImage.height;
+ ctx.drawImage(pageImage, 0, 0);
+ var url = this._model.target() && this._model.target().inspectedURL();
+ var fileName = url ? url.trimURL().removeURLFragment() : '';
+ if (this._model.type() === Emulation.DeviceModeModel.Type.Device)
+ fileName += Common.UIString('(%s)', this._model.device().title);
+ var link = createElement('a');
+ link.download = fileName + '.png';
+ canvas.toBlob(function(blob) {
+ link.href = URL.createObjectURL(blob);
+ link.click();
+ });
+ };
+ });
+ }
};
/**

Powered by Google App Engine
This is Rietveld 408576698