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

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: Fix browser test Created 3 years, 12 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 var scope = this;
457 pageImage, visiblePageRect.left, visiblePageRect.top, Math.min(pageI mage.naturalWidth, screenRect.width), 457 setTimeout(function() {
dgozman 2016/12/27 07:08:24 Should this be pageImage.onload = ... ? Also, usin
458 Math.min(pageImage.naturalHeight, screenRect.height)); 458 ctx.drawImage(
459 var url = mainTarget && mainTarget.inspectedURL(); 459 pageImage, visiblePageRect.left, visiblePageRect.top, Math.min(pag eImage.naturalWidth, screenRect.width),
460 var fileName = url ? url.trimURL().removeURLFragment() : ''; 460 Math.min(pageImage.naturalHeight, screenRect.height));
461 if (this._model.type() === Emulation.DeviceModeModel.Type.Device) 461 var url = mainTarget && mainTarget.inspectedURL();
462 fileName += Common.UIString('(%s)', this._model.device().title); 462 var fileName = url ? url.trimURL().removeURLFragment() : '';
463 // Trigger download. 463 if (scope._model.type() === Emulation.DeviceModeModel.Type.Device)
464 var link = createElement('a'); 464 fileName += Common.UIString('(%s)', scope._model.device().title);
465 link.download = fileName + '.png'; 465 // Trigger download.
466 link.href = canvas.toDataURL('image/png'); 466 var link = createElement('a');
467 link.click(); 467 link.download = fileName + '.png';
468 link.href = canvas.toDataURL('image/png');
469 link.click();
470 }, 0);
468 } 471 }
469 } 472 }
470 } 473 }
471 }; 474 };
472 475
473 /** 476 /**
474 * @unrestricted 477 * @unrestricted
475 */ 478 */
476 Emulation.DeviceModeView.Ruler = class extends UI.VBox { 479 Emulation.DeviceModeView.Ruler = class extends UI.VBox {
477 /** 480 /**
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 return Promise.resolve(); 566 return Promise.resolve();
564 } 567 }
565 568
566 /** 569 /**
567 * @param {number} size 570 * @param {number} size
568 */ 571 */
569 _onMarkerClick(size) { 572 _onMarkerClick(size) {
570 this._applyCallback.call(null, size); 573 this._applyCallback.call(null, size);
571 } 574 }
572 }; 575 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/ImageLoader.cpp ('k') | third_party/WebKit/Source/web/tests/ActivityLoggerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698