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

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

Issue 2811273004: [DevTools] Account for host device pixel ratio in Device Mode screenshots (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 async captureScreenshot() { 365 async captureScreenshot() {
366 SDK.DOMModel.muteHighlight(); 366 SDK.DOMModel.muteHighlight();
367 var screenshot = await this._model.captureScreenshot(false); 367 var screenshot = await this._model.captureScreenshot(false);
368 SDK.DOMModel.unmuteHighlight(); 368 SDK.DOMModel.unmuteHighlight();
369 if (screenshot === null) 369 if (screenshot === null)
370 return; 370 return;
371 371
372 var pageImage = new Image(); 372 var pageImage = new Image();
373 pageImage.src = 'data:image/png;base64,' + screenshot; 373 pageImage.src = 'data:image/png;base64,' + screenshot;
374 pageImage.onload = async () => { 374 pageImage.onload = async () => {
375 var scale = 1 / this._model.scale(); 375 var scale = window.devicePixelRatio / this._model.scale();
376 var outlineRect = this._model.outlineRect().scale(scale); 376 var outlineRect = this._model.outlineRect().scale(scale);
377 var screenRect = this._model.screenRect().scale(scale); 377 var screenRect = this._model.screenRect().scale(scale);
378 var visiblePageRect = this._model.visiblePageRect().scale(scale); 378 var visiblePageRect = this._model.visiblePageRect().scale(scale);
379 var contentLeft = screenRect.left + visiblePageRect.left - outlineRect.lef t; 379 var contentLeft = screenRect.left + visiblePageRect.left - outlineRect.lef t;
380 var contentTop = screenRect.top + visiblePageRect.top - outlineRect.top; 380 var contentTop = screenRect.top + visiblePageRect.top - outlineRect.top;
381 381
382 var canvas = createElement('canvas'); 382 var canvas = createElement('canvas');
383 canvas.width = Math.floor(outlineRect.width); 383 canvas.width = Math.floor(outlineRect.width);
384 canvas.height = Math.floor(outlineRect.height); 384 canvas.height = Math.floor(outlineRect.height);
385 var ctx = canvas.getContext('2d'); 385 var ctx = canvas.getContext('2d');
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 return Promise.resolve(); 546 return Promise.resolve();
547 } 547 }
548 548
549 /** 549 /**
550 * @param {number} size 550 * @param {number} size
551 */ 551 */
552 _onMarkerClick(size) { 552 _onMarkerClick(size) {
553 this._applyCallback.call(null, size); 553 this._applyCallback.call(null, size);
554 } 554 }
555 }; 555 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698