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); |
}, |