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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineEventOverview.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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 458
459 /** 459 /**
460 * @param {?string} data 460 * @param {?string} data
461 * @return {!Promise<!HTMLImageElement>} 461 * @return {!Promise<!HTMLImageElement>}
462 */ 462 */
463 function createImage(data) { 463 function createImage(data) {
464 var fulfill; 464 var fulfill;
465 var promise = new Promise(f => fulfill = f); 465 var promise = new Promise(f => fulfill = f);
466 466
467 var image = /** @type {!HTMLImageElement} */ (createElement('img')); 467 var image = /** @type {!HTMLImageElement} */ (createElement('img'));
468 if (data) 468 if (data) {
469 image.src = 'data:image/jpg;base64,' + data; 469 image.src = 'data:image/jpg;base64,' + data;
470 if (image.complete) {
471 fulfill(image);
472 } else {
473 image.addEventListener('load', () => fulfill(image)); 470 image.addEventListener('load', () => fulfill(image));
474 image.addEventListener('error', () => fulfill(image)); 471 image.addEventListener('error', () => fulfill(image));
472 } else {
473 fulfill(image);
475 } 474 }
476 return promise; 475 return promise;
477 } 476 }
478 } 477 }
479 478
480 /** 479 /**
481 * @param {number} imageWidth 480 * @param {number} imageWidth
482 * @param {number} imageHeight 481 * @param {number} imageHeight
483 */ 482 */
484 _drawFrames(imageWidth, imageHeight) { 483 _drawFrames(imageWidth, imageHeight) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 counters[group] = this._quantDuration; 778 counters[group] = this._quantDuration;
780 this._callback(counters); 779 this._callback(counters);
781 interval -= this._quantDuration; 780 interval -= this._quantDuration;
782 } 781 }
783 this._counters = []; 782 this._counters = [];
784 this._counters[group] = interval; 783 this._counters[group] = interval;
785 this._lastTime = time; 784 this._lastTime = time;
786 this._remainder = this._quantDuration - interval; 785 this._remainder = this._quantDuration - interval;
787 } 786 }
788 }; 787 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698