Chromium Code Reviews| 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 ce6aef2fe18dd3a2b95a5b1b6cb15d2951cdaedd..ce5f841e854773ac834d4105b30e2c70f77d287d 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,53 @@ Emulation.DeviceModeView = class extends UI.VBox { |
| } |
| } |
| } |
| + |
| + captureFullHeightScreenshot() { |
| + var mainTarget = SDK.targetManager.mainTarget(); |
| + if (!mainTarget) |
| + return; |
| + SDK.DOMModel.muteHighlight(); |
| + |
| + this._model.prepareForFullHeightScreenshot().then(() => { |
| + mainTarget.pageAgent().captureScreenshot(screenshotCaptured.bind(this)); |
|
dgozman
2017/01/13 23:38:48
Put this into model as well, and let it resetViewp
ahmetemirercin
2017/01/16 17:52:01
Done.
|
| + }); |
| + |
| + /** |
| + * @param {?Protocol.Error} error |
| + * @param {string} content |
| + * @this {Emulation.DeviceModeView} |
| + */ |
| + function screenshotCaptured(error, content) { |
| + this._model.resetViewport(); |
| + this._model.resetVisibleSize(); |
| + SDK.DOMModel.unmuteHighlight(); |
| + if (error) { |
| + console.error(error); |
| + 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, pageImage.width, pageImage.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); |
| + var link = createElement('a'); |
| + link.download = fileName + '.png'; |
| + canvas.toBlob(function(blob) { |
| + link.href = URL.createObjectURL(blob); |
| + link.click(); |
| + }); |
| + } |
| + } |
| + } |
| }; |
| /** |