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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** 4 /**
5 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 Emulation.DeviceModeView = class extends UI.VBox { 7 Emulation.DeviceModeView = class extends UI.VBox {
8 constructor() { 8 constructor() {
9 super(true); 9 super(true);
10 this.setMinimumSize(150, 150); 10 this.setMinimumSize(150, 150);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 fileName += Common.UIString('(%s)', this._model.device().title); 463 fileName += Common.UIString('(%s)', this._model.device().title);
464 // Trigger download. 464 // Trigger download.
465 var link = createElement('a'); 465 var link = createElement('a');
466 link.download = fileName + '.png'; 466 link.download = fileName + '.png';
467 link.href = canvas.toDataURL('image/png'); 467 link.href = canvas.toDataURL('image/png');
468 link.click(); 468 link.click();
469 }; 469 };
470 } 470 }
471 } 471 }
472 } 472 }
473
474 captureFullSizeScreenshot() {
475 SDK.DOMModel.muteHighlight();
476 this._model.captureFullSizeScreenshot(content => {
477 SDK.DOMModel.unmuteHighlight();
478 if (content === null)
479 return;
480 var canvas = createElement('canvas');
481 var pageImage = new Image();
482 pageImage.src = 'data:image/png;base64,' + content;
483 pageImage.onload = () => {
484 var ctx = canvas.getContext('2d');
485 ctx.imageSmoothingEnabled = false;
486 canvas.width = pageImage.width;
487 canvas.height = pageImage.height;
488 ctx.drawImage(pageImage, 0, 0);
489 var url = this._model.target() && this._model.target().inspectedURL();
490 var fileName = url ? url.trimURL().removeURLFragment() : '';
491 if (this._model.type() === Emulation.DeviceModeModel.Type.Device)
492 fileName += Common.UIString('(%s)', this._model.device().title);
493 var link = createElement('a');
494 link.download = fileName + '.png';
495 canvas.toBlob(function(blob) {
496 link.href = URL.createObjectURL(blob);
497 link.click();
498 });
499 };
500 });
501 }
473 }; 502 };
474 503
475 /** 504 /**
476 * @unrestricted 505 * @unrestricted
477 */ 506 */
478 Emulation.DeviceModeView.Ruler = class extends UI.VBox { 507 Emulation.DeviceModeView.Ruler = class extends UI.VBox {
479 /** 508 /**
480 * @param {boolean} horizontal 509 * @param {boolean} horizontal
481 * @param {function(number)} applyCallback 510 * @param {function(number)} applyCallback
482 */ 511 */
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 return Promise.resolve(); 594 return Promise.resolve();
566 } 595 }
567 596
568 /** 597 /**
569 * @param {number} size 598 * @param {number} size
570 */ 599 */
571 _onMarkerClick(size) { 600 _onMarkerClick(size) {
572 this._applyCallback.call(null, size); 601 this._applyCallback.call(null, size);
573 } 602 }
574 }; 603 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698