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

Side by Side 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, 11 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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 ctx.setLineDash([10, 10]); 446 ctx.setLineDash([10, 10]);
447 ctx.strokeRect(screenRect.left + 1, screenRect.top + 1, screenRect.width - 2, screenRect.height - 2); 447 ctx.strokeRect(screenRect.left + 1, screenRect.top + 1, screenRect.width - 2, screenRect.height - 2);
448 } 448 }
449 449
450 /** 450 /**
451 * @this {Emulation.DeviceModeView} 451 * @this {Emulation.DeviceModeView}
452 */ 452 */
453 function paintScreenshot() { 453 function paintScreenshot() {
454 var pageImage = new Image(); 454 var pageImage = new Image();
455 pageImage.src = 'data:image/png;base64,' + content; 455 pageImage.src = 'data:image/png;base64,' + content;
456 ctx.drawImage( 456 pageImage.onload = () => {
457 pageImage, visiblePageRect.left, visiblePageRect.top, Math.min(pageI mage.naturalWidth, screenRect.width), 457 ctx.drawImage(
458 Math.min(pageImage.naturalHeight, screenRect.height)); 458 pageImage, visiblePageRect.left, visiblePageRect.top, Math.min(pag eImage.naturalWidth, screenRect.width),
459 var url = mainTarget && mainTarget.inspectedURL(); 459 Math.min(pageImage.naturalHeight, screenRect.height));
460 var fileName = url ? url.trimURL().removeURLFragment() : ''; 460 var url = mainTarget && mainTarget.inspectedURL();
461 if (this._model.type() === Emulation.DeviceModeModel.Type.Device) 461 var fileName = url ? url.trimURL().removeURLFragment() : '';
462 fileName += Common.UIString('(%s)', this._model.device().title); 462 if (this._model.type() === Emulation.DeviceModeModel.Type.Device)
463 // Trigger download. 463 fileName += Common.UIString('(%s)', this._model.device().title);
464 var link = createElement('a'); 464 // Trigger download.
465 link.download = fileName + '.png'; 465 var link = createElement('a');
466 link.href = canvas.toDataURL('image/png'); 466 link.download = fileName + '.png';
467 link.click(); 467 link.href = canvas.toDataURL('image/png');
468 link.click();
469 };
468 } 470 }
469 } 471 }
470 } 472 }
471 }; 473 };
472 474
473 /** 475 /**
474 * @unrestricted 476 * @unrestricted
475 */ 477 */
476 Emulation.DeviceModeView.Ruler = class extends UI.VBox { 478 Emulation.DeviceModeView.Ruler = class extends UI.VBox {
477 /** 479 /**
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 return Promise.resolve(); 565 return Promise.resolve();
564 } 566 }
565 567
566 /** 568 /**
567 * @param {number} size 569 * @param {number} size
568 */ 570 */
569 _onMarkerClick(size) { 571 _onMarkerClick(size) {
570 this._applyCallback.call(null, size); 572 this._applyCallback.call(null, size);
571 } 573 }
572 }; 574 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698