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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.HBox} 7 * @extends {WebInspector.HBox}
8 */ 8 */
9 WebInspector.FilmStripView = function() 9 WebInspector.FilmStripView = function()
10 { 10 {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 var frames = filmStripModel.frames(); 50 var frames = filmStripModel.frames();
51 if (!frames.length) { 51 if (!frames.length) {
52 this.reset(); 52 this.reset();
53 return; 53 return;
54 } 54 }
55 this.update(); 55 this.update();
56 }, 56 },
57 57
58 /** 58 /**
59 * @param {!WebInspector.FilmStripModel.Frame} frame 59 * @param {!WebInspector.FilmStripModel.Frame} frame
60 * @return {!Element} 60 * @return {!Promise<!Element>}
61 */ 61 */
62 createFrameElement: function(frame) 62 createFrameElement: function(frame)
63 { 63 {
64 var time = frame.timestamp; 64 var time = frame.timestamp;
65 var element = createElementWithClass("div", "frame"); 65 var element = createElementWithClass("div", "frame");
66 element.createChild("div", "thumbnail").createChild("img").src = "data:i mage/jpg;base64," + frame.imageData; 66 var imageElement = element.createChild("div", "thumbnail").createChild(" img");
67 element.createChild("div", "time").textContent = Number.millisToString(t ime - this._zeroTime); 67 element.createChild("div", "time").textContent = Number.millisToString(t ime - this._zeroTime);
68 element.addEventListener("mousedown", this._onMouseEvent.bind(this, WebI nspector.FilmStripView.Events.FrameSelected, time), false); 68 element.addEventListener("mousedown", this._onMouseEvent.bind(this, WebI nspector.FilmStripView.Events.FrameSelected, time), false);
69 element.addEventListener("mouseenter", this._onMouseEvent.bind(this, Web Inspector.FilmStripView.Events.FrameEnter, time), false); 69 element.addEventListener("mouseenter", this._onMouseEvent.bind(this, Web Inspector.FilmStripView.Events.FrameEnter, time), false);
70 element.addEventListener("mouseout", this._onMouseEvent.bind(this, WebIn spector.FilmStripView.Events.FrameExit, time), false); 70 element.addEventListener("mouseout", this._onMouseEvent.bind(this, WebIn spector.FilmStripView.Events.FrameExit, time), false);
71 element.addEventListener("dblclick", this._onDoubleClick.bind(this, fram e), false); 71 element.addEventListener("dblclick", this._onDoubleClick.bind(this, fram e), false);
72 return element; 72
73 return frame.imageDataPromise().then(WebInspector.FilmStripView._setImag eData.bind(null, imageElement)).then(returnElement);
74 /**
75 * @return {!Element}
76 */
77 function returnElement()
78 {
79 return element;
80 }
73 }, 81 },
74 82
75 /** 83 /**
76 * @param {number} time 84 * @param {number} time
77 * @return {!WebInspector.FilmStripModel.Frame} 85 * @return {!WebInspector.FilmStripModel.Frame}
78 */ 86 */
79 frameByTime: function(time) 87 frameByTime: function(time)
80 { 88 {
81 /** 89 /**
82 * @param {number} time 90 * @param {number} time
(...skipping 11 matching lines...) Expand all
94 return frames[index]; 102 return frames[index];
95 }, 103 },
96 104
97 update: function() 105 update: function()
98 { 106 {
99 if (!this._model) 107 if (!this._model)
100 return; 108 return;
101 var frames = this._model.frames(); 109 var frames = this._model.frames();
102 if (!frames.length) 110 if (!frames.length)
103 return; 111 return;
112
104 this.contentElement.removeChildren(); 113 this.contentElement.removeChildren();
105 this._statusLabel.remove(); 114 this._statusLabel.remove();
106 115
107 if (this._mode === WebInspector.FilmStripView.Modes.FrameBased) { 116 if (this._mode === WebInspector.FilmStripView.Modes.FrameBased) {
108 frames.map(this.createFrameElement.bind(this)).forEach(this.contentE lement.appendChild.bind(this.contentElement)); 117 Promise.all(frames.map(this.createFrameElement.bind(this))).spread(t his.contentElement.appendChildren.bind(this.contentElement));
109 return; 118 return;
110 } 119 }
111 120
112 var width = this.contentElement.clientWidth; 121 var width = this.contentElement.clientWidth;
113 var scale = this._spanTime / width; 122 var scale = this._spanTime / width;
114 var element0 = this.createFrameElement(frames[0]); // Calculate frame w idth basing on the first frame. 123 this.createFrameElement(frames[0]).then(continueWhenFrameImageLoaded.bin d(this)); // Calculate frame width basing on the first frame.
115 var frameWidth = Math.ceil(WebInspector.measurePreferredSize(element0, t his.contentElement).width);
116 if (!frameWidth)
117 return;
118 124
119 for (var pos = frameWidth; pos < width; pos += frameWidth) { 125 /**
120 var time = pos * scale + this._zeroTime; 126 * @this {WebInspector.FilmStripView}
121 var frame = this.frameByTime(time); 127 * @param {!Element} element0
122 var element = this.contentElement.appendChild(this.createFrameElemen t(frame)); 128 */
123 element.style.width = frameWidth + "px"; 129 function continueWhenFrameImageLoaded(element0)
130 {
131 var frameWidth = Math.ceil(WebInspector.measurePreferredSize(element 0, this.contentElement).width);
132 if (!frameWidth)
133 return;
134
135 var promises = [];
136 for (var pos = frameWidth; pos < width; pos += frameWidth) {
137 var time = pos * scale + this._zeroTime;
138 promises.push(this.createFrameElement(this.frameByTime(time)).th en(fixWidth));
139 }
140 Promise.all(promises).spread(this.contentElement.appendChildren.bind (this.contentElement));
141 /**
142 * @param {!Element} element
143 * @return {!Element}
144 */
145 function fixWidth(element)
146 {
147 element.style.width = frameWidth + "px";
148 return element;
149 }
124 } 150 }
125 }, 151 },
126 152
127 /** 153 /**
128 * @override 154 * @override
129 */ 155 */
130 onResize: function() 156 onResize: function()
131 { 157 {
132 if (this._mode === WebInspector.FilmStripView.Modes.FrameBased) 158 if (this._mode === WebInspector.FilmStripView.Modes.FrameBased)
133 return; 159 return;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 193
168 setFetching: function() 194 setFetching: function()
169 { 195 {
170 this._statusLabel.textContent = WebInspector.UIString("Fetching frames.. ."); 196 this._statusLabel.textContent = WebInspector.UIString("Fetching frames.. .");
171 }, 197 },
172 198
173 __proto__: WebInspector.HBox.prototype 199 __proto__: WebInspector.HBox.prototype
174 } 200 }
175 201
176 /** 202 /**
203 * @param {!Element} imageElement
204 * @param {?string} data
205 */
206 WebInspector.FilmStripView._setImageData = function(imageElement, data)
207 {
208 if (data)
209 imageElement.src = "data:image/jpg;base64," + data;
210 }
211
212 /**
177 * @constructor 213 * @constructor
178 * @extends {WebInspector.DialogDelegate} 214 * @extends {WebInspector.DialogDelegate}
179 * @param {!WebInspector.FilmStripModel.Frame} filmStripFrame 215 * @param {!WebInspector.FilmStripModel.Frame} filmStripFrame
180 * @param {number=} zeroTime 216 * @param {number=} zeroTime
181 */ 217 */
182 WebInspector.FilmStripView.DialogDelegate = function(filmStripFrame, zeroTime) 218 WebInspector.FilmStripView.DialogDelegate = function(filmStripFrame, zeroTime)
183 { 219 {
184 WebInspector.DialogDelegate.call(this); 220 WebInspector.DialogDelegate.call(this);
185 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element); 221 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element);
186 shadowRoot.appendChild(WebInspector.Widget.createStyleElement("components_la zy/filmStripDialog.css")); 222 shadowRoot.appendChild(WebInspector.Widget.createStyleElement("components_la zy/filmStripDialog.css"));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 302
267 _onLastFrame: function() 303 _onLastFrame: function()
268 { 304 {
269 this._index = this._frames.length - 1; 305 this._index = this._frames.length - 1;
270 this._render(); 306 this._render();
271 }, 307 },
272 308
273 _render: function() 309 _render: function()
274 { 310 {
275 var frame = this._frames[this._index]; 311 var frame = this._frames[this._index];
276 this._imageElement.src = "data:image/jpg;base64," + frame.imageData; 312 frame.imageDataPromise().then(WebInspector.FilmStripView._setImageData.b ind(null, this._imageElement));
277 this._timeLabel.textContent = Number.millisToString(frame.timestamp - th is._zeroTime); 313 this._timeLabel.textContent = Number.millisToString(frame.timestamp - th is._zeroTime);
278 }, 314 },
279 315
280 __proto__: WebInspector.DialogDelegate.prototype 316 __proto__: WebInspector.DialogDelegate.prototype
281 } 317 }
OLDNEW
« 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