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

Unified Diff: Source/devtools/front_end/components_lazy/FilmStripView.js

Issue 1184383002: DevTools: adopt FilmStripModel to new screenshot recorder trace format (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/components_lazy/FilmStripView.js
diff --git a/Source/devtools/front_end/components_lazy/FilmStripView.js b/Source/devtools/front_end/components_lazy/FilmStripView.js
index f465199a78133c6e3611504a7015d46a87d0775f..f64d455511e0e6db438d4a6b26e0058fadd3dadd 100644
--- a/Source/devtools/front_end/components_lazy/FilmStripView.js
+++ b/Source/devtools/front_end/components_lazy/FilmStripView.js
@@ -63,7 +63,7 @@ WebInspector.FilmStripView.prototype = {
{
var time = frame.timestamp;
var element = createElementWithClass("div", "frame");
- element.createChild("div", "thumbnail").createChild("img").src = "data:image/jpg;base64," + frame.imageData;
+ element.createChild("div", "thumbnail").createChild("img").src = "data:image/jpg;base64," + this._imageDataForFrame.get(frame);
element.createChild("div", "time").textContent = Number.millisToString(time - this._zeroTime);
element.addEventListener("mousedown", this._onMouseEvent.bind(this, WebInspector.FilmStripView.Events.FrameSelected, time), false);
element.addEventListener("mouseenter", this._onMouseEvent.bind(this, WebInspector.FilmStripView.Events.FrameEnter, time), false);
@@ -101,9 +101,33 @@ WebInspector.FilmStripView.prototype = {
var frames = this._model.frames();
if (!frames.length)
return;
+ /** @type {!Map<!WebInspector.FilmStripModel.Frame, string>} */
+ this._imageDataForFrame = new Map();
alph 2015/06/18 13:10:34 What if another update is fired while promises are
+
+ var promises = [];
+ for (var frame of frames)
+ promises.push(frame.imageDataPromise().then(setImageData.bind(this, frame)));
+
+ Promise.all(promises).then(this._updateWhenImagesLoaded.bind(this));
+ /**
+ * @this {WebInspector.FilmStripView}
+ * @param {!WebInspector.FilmStripModel.Frame} frame
+ * @param {?string} data
+ */
+ function setImageData(frame, data)
+ {
+ if (data)
+ this._imageDataForFrame.set(frame, data);
+ }
+ },
+
+ _updateWhenImagesLoaded: function()
+ {
this.contentElement.removeChildren();
this._statusLabel.remove();
+ var frames = this._model.frames();
+
if (this._mode === WebInspector.FilmStripView.Modes.FrameBased) {
frames.map(this.createFrameElement.bind(this)).forEach(this.contentElement.appendChild.bind(this.contentElement));
return;
@@ -273,7 +297,16 @@ WebInspector.FilmStripView.DialogDelegate.prototype = {
_render: function()
{
var frame = this._frames[this._index];
- this._imageElement.src = "data:image/jpg;base64," + frame.imageData;
+ frame.imageDataPromise().then(onGotImageData.bind(this));
+ /**
+ * @param {?string} data
+ * @this {WebInspector.DialogDelegate}
+ */
+ function onGotImageData(data)
+ {
+ if (data)
+ this._imageElement.src = "data:image/jpg;base64," + data;
+ }
this._timeLabel.textContent = Number.millisToString(frame.timestamp - this._zeroTime);
},
« no previous file with comments | « Source/devtools/front_end/components_lazy/FilmStripModel.js ('k') | Source/devtools/front_end/sdk/TracingModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698