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

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: make imageDataForFrame map a parameter, not a member 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 46131e4820664dad19458d026bf9055906f2e1d4..5142ff8369354aacf5ba166645db28263ead1eff 100644
--- a/Source/devtools/front_end/components_lazy/FilmStripView.js
+++ b/Source/devtools/front_end/components_lazy/FilmStripView.js
@@ -61,9 +61,38 @@ WebInspector.FilmStripView.prototype = {
var frames = this._model.frames();
if (!frames.length)
return;
+ /** @type {!Map<!WebInspector.FilmStripModel.Frame, string>} */
+ var imageDataForFrame = new Map();
+
+ var pendingImages = frames.length;
+ for (var frame of frames)
+ frame.requestImageData(onImageData.bind(this, frame));
alph 2015/06/17 09:41:59 If you turn them into a promises, the code should
+
+ /**
+ * @this {WebInspector.FilmStripView}
+ * @param {!WebInspector.FilmStripModel.Frame} frame
+ * @param {?string} data
+ */
+ function onImageData(frame, data)
+ {
+ --pendingImages;
+ if (!data)
+ return;
+ imageDataForFrame.set(frame, data);
+ if (!pendingImages)
+ this._updateWhenImagesLoaded(imageDataForFrame);
+ }
+ },
+
+ /**
+ * @param {!Map<!WebInspector.FilmStripModel.Frame, string>} imageDataForFrame
+ */
+ _updateWhenImagesLoaded: function(imageDataForFrame)
+ {
this.contentElement.removeChildren();
this._label.remove();
var zeroTime = this._zeroTime;
+ var frames = this._model.frames();
/**
* @param {!WebInspector.FilmStripModel.Frame} frame
@@ -75,7 +104,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," + imageDataForFrame.get(frame);
if (!skipTimeLabel)
element.createChild("div", "time").textContent = Number.millisToString(time - zeroTime);
element.addEventListener("mousedown", this._onMouseEvent.bind(this, WebInspector.FilmStripView.Events.FrameSelected, time), false);
@@ -118,7 +147,7 @@ WebInspector.FilmStripView.prototype = {
// Calculate frame width basing on the first frame.
var tempElement = createElementWithClass("div", "frame");
- tempElement.createChild("div", "thumbnail").createChild("img").src = "data:image/jpg;base64," + frames[0].imageData;
+ tempElement.createChild("div", "thumbnail").createChild("img").src = "data:image/jpg;base64," + imageDataForFrame.get(frames[0]);
var frameWidth = Math.ceil(WebInspector.measurePreferredSize(tempElement, this.contentElement).width);
if (!frameWidth)
return;
@@ -181,6 +210,24 @@ WebInspector.FilmStripView.prototype = {
}
/**
+ * @param {!Image} image
+ * @param {!WebInspector.FilmStripModel.Frame} frame
+ */
+WebInspector.FilmStripView._loadImageForFrame = function(image, frame)
alph 2015/06/17 09:41:59 Can't find where is it used.
+{
+ frame.requestImageData(onGotImageData);
+
+ /**
+ * @param {?string} data
+ */
+ function onGotImageData(data)
+ {
+ if (data)
+ image.src = "data:image/jpg;base64," + data;
+ }
+}
+
+/**
* @constructor
* @extends {WebInspector.DialogDelegate}
* @param {!WebInspector.FilmStripModel.Frame} filmStripFrame
@@ -280,7 +327,16 @@ WebInspector.FilmStripView.DialogDelegate.prototype = {
_render: function()
{
var frame = this._frames[this._index];
- this._imageElement.src = "data:image/jpg;base64," + frame.imageData;
+ frame.requestImageData(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);
},

Powered by Google App Engine
This is Rietveld 408576698