Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 * @implements {WebInspector.TracingManagerClient} | 8 * @implements {WebInspector.TracingManagerClient} |
| 9 * @param {!WebInspector.NetworkTimeCalculator} calculator | 9 * @param {!WebInspector.NetworkTimeCalculator} calculator |
| 10 */ | 10 */ |
| 11 WebInspector.NetworkFilmStripView = function(calculator) | 11 WebInspector.NetworkFilmStripView = function(calculator) |
| 12 { | 12 { |
| 13 WebInspector.HBox.call(this, true); | 13 WebInspector.HBox.call(this, true); |
| 14 this.registerRequiredCSS("network/networkFilmStripView.css"); | 14 this.registerRequiredCSS("network/networkFilmStripView.css"); |
| 15 this.element.classList.add("network-film-strip-view"); | 15 this.element.classList.add("network-film-strip-view"); |
| 16 this.contentElement.classList.add("shadow-network-film-strip-view"); | 16 this.contentElement.classList.add("shadow-network-film-strip-view"); |
| 17 | |
| 18 /** @type {!WebInspector.NetworkTimeCalculator} */ | 17 /** @type {!WebInspector.NetworkTimeCalculator} */ |
| 19 this._calculator = calculator; | 18 this._calculator = calculator; |
| 20 | 19 |
| 21 this.reset(); | 20 this.reset(); |
| 22 } | 21 } |
| 23 | 22 |
| 24 WebInspector.NetworkFilmStripView._maximumFrameCount = 60; | 23 WebInspector.NetworkFilmStripView._maximumFrameCount = 60; |
| 25 | 24 |
| 26 WebInspector.NetworkFilmStripView.Events = { | 25 WebInspector.NetworkFilmStripView.Events = { |
| 27 FrameSelected: "FrameSelected", | 26 FrameSelected: "FrameSelected", |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 } | 69 } |
| 71 } | 70 } |
| 72 } | 71 } |
| 73 | 72 |
| 74 if (!frames.length) { | 73 if (!frames.length) { |
| 75 this.reset(); | 74 this.reset(); |
| 76 return; | 75 return; |
| 77 } | 76 } |
| 78 this._label.remove(); | 77 this._label.remove(); |
| 79 | 78 |
| 80 for (var i = 0; i < frames.length; ++i) | 79 for (var i = 0; i < frames.length; ++i) { |
| 80 frames[i]._prevFrame = frames[i - 1]; | |
| 81 frames[i]._nextFrame = frames[i + 1]; | |
| 81 frames[i].show(this.contentElement); | 82 frames[i].show(this.contentElement); |
| 83 | |
| 84 } | |
| 82 this._frames = frames; | 85 this._frames = frames; |
| 83 this._updateTimeOffset(true); | 86 this._updateTimeOffset(true); |
| 84 }, | 87 }, |
| 85 | 88 |
| 86 reset: function() | 89 reset: function() |
| 87 { | 90 { |
| 88 this.contentElement.removeChildren(); | 91 this.contentElement.removeChildren(); |
| 89 /** @type {?number} */ | 92 /** @type {?number} */ |
| 90 this._timeOffset = null; | 93 this._timeOffset = null; |
| 91 /** @type {!Array.<!WebInspector.NetworkFilmStripFrame>} */ | 94 /** @type {!Array.<!WebInspector.NetworkFilmStripFrame>} */ |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 if (this._target) | 161 if (this._target) |
| 159 return; | 162 return; |
| 160 | 163 |
| 161 this.reset(); | 164 this.reset(); |
| 162 this._target = WebInspector.targetManager.mainTarget(); | 165 this._target = WebInspector.targetManager.mainTarget(); |
| 163 this._tracingModel = new WebInspector.TracingModel(new WebInspector.Temp FileBackingStorage("tracing")); | 166 this._tracingModel = new WebInspector.TracingModel(new WebInspector.Temp FileBackingStorage("tracing")); |
| 164 this._target.tracingManager.start(this, "-*,disabled-by-default-devtools .screenshot", ""); | 167 this._target.tracingManager.start(this, "-*,disabled-by-default-devtools .screenshot", ""); |
| 165 this._label.textContent = WebInspector.UIString("Recording frames..."); | 168 this._label.textContent = WebInspector.UIString("Recording frames..."); |
| 166 }, | 169 }, |
| 167 | 170 |
| 171 /** | |
| 172 * @return {boolean} | |
| 173 */ | |
| 174 isRecording: function() | |
| 175 { | |
| 176 return !!this._target; | |
| 177 }, | |
| 178 | |
| 168 stopRecording: function() | 179 stopRecording: function() |
| 169 { | 180 { |
| 170 if (!this._target) | 181 if (!this._target) |
| 171 return; | 182 return; |
| 172 | 183 |
| 173 this._target.tracingManager.stop(); | 184 this._target.tracingManager.stop(); |
| 174 this._target = null; | 185 this._target = null; |
| 175 }, | 186 }, |
| 176 | 187 |
| 177 /** | 188 /** |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 190 * @param {!WebInspector.NetworkFilmStripView} parent | 201 * @param {!WebInspector.NetworkFilmStripView} parent |
| 191 * @param {?string} imageData | 202 * @param {?string} imageData |
| 192 * @param {number} timestamp | 203 * @param {number} timestamp |
| 193 */ | 204 */ |
| 194 WebInspector.NetworkFilmStripFrame = function(parent, imageData, timestamp) | 205 WebInspector.NetworkFilmStripFrame = function(parent, imageData, timestamp) |
| 195 { | 206 { |
| 196 this._parent = parent; | 207 this._parent = parent; |
| 197 this._timestamp = timestamp; | 208 this._timestamp = timestamp; |
| 198 this._element = createElementWithClass("div", "frame"); | 209 this._element = createElementWithClass("div", "frame"); |
| 199 this._element.createChild("div", "thumbnail").createChild("img").src = "data :image/jpg;base64," + imageData; | 210 this._element.createChild("div", "thumbnail").createChild("img").src = "data :image/jpg;base64," + imageData; |
| 211 this._imageData = imageData; | |
| 200 this._timeLabel = this._element.createChild("div", "time"); | 212 this._timeLabel = this._element.createChild("div", "time"); |
| 201 this._element.addEventListener("mousedown", this._onMouseDown.bind(this), fa lse); | 213 this._element.addEventListener("mousedown", this._onMouseDown.bind(this), fa lse); |
| 214 this._element.addEventListener("dblclick", this._onDoubleClick.bind(this), f alse); | |
| 202 } | 215 } |
| 203 | 216 |
| 204 WebInspector.NetworkFilmStripFrame.prototype = { | 217 WebInspector.NetworkFilmStripFrame.prototype = { |
| 205 /** | 218 /** |
| 206 * @param {!Element} parent | 219 * @param {!Element} parent |
| 207 */ | 220 */ |
| 208 show: function(parent) | 221 show: function(parent) |
| 209 { | 222 { |
| 210 parent.appendChild(this._element); | 223 parent.appendChild(this._element); |
| 211 }, | 224 }, |
| 212 | 225 |
| 213 /** | 226 _onMouseDown: function() |
| 214 * @param {!Event} event | |
| 215 */ | |
| 216 _onMouseDown: function(event) | |
| 217 { | 227 { |
| 218 this._parent._selectFrame(this); | 228 this._parent._selectFrame(this); |
| 219 }, | 229 }, |
| 220 | 230 |
| 231 _onDoubleClick: function() | |
| 232 { | |
| 233 WebInspector.Dialog.show(WebInspector.Dialog.modalHostView().element, ne w WebInspector.NetworkFilmStripFrame.DialogDelegate(this)); | |
|
dgozman
2015/04/22 10:16:54
First parameter should be NetworkPanel.element.
pfeldman
2015/04/22 12:13:12
I was thinking that we introduced WebInspector.Dia
| |
| 234 }, | |
| 235 | |
| 221 /** | 236 /** |
| 222 * @return {number} | 237 * @return {number} |
| 223 */ | 238 */ |
| 224 timestamp: function() | 239 timestamp: function() |
| 225 { | 240 { |
| 226 return this._timestamp; | 241 return this._timestamp; |
| 227 }, | 242 }, |
| 228 | 243 |
| 229 /** | 244 /** |
| 230 * @param {number} offset | 245 * @param {number} offset |
| 231 */ | 246 */ |
| 232 _setTimeOffset: function(offset) | 247 _setTimeOffset: function(offset) |
| 233 { | 248 { |
| 234 this._timeLabel.textContent = Number.secondsToString(this._timestamp - o ffset); | 249 this._timeLabel.textContent = Number.secondsToString(this._timestamp - o ffset); |
| 235 } | 250 } |
| 236 } | 251 } |
| 252 | |
| 253 | |
| 254 /** | |
| 255 * @constructor | |
| 256 * @extends {WebInspector.DialogDelegate} | |
| 257 * @param {!WebInspector.NetworkFilmStripFrame} frame | |
| 258 */ | |
| 259 WebInspector.NetworkFilmStripFrame.DialogDelegate = function(frame) | |
| 260 { | |
| 261 WebInspector.DialogDelegate.call(this, createElementWithClass("div", "networ k-filmstrip-preview")); | |
| 262 this.element.tabIndex = 0; | |
| 263 this._frame = frame; | |
| 264 this._imageElement = this.element.createChild("img"); | |
| 265 | |
| 266 var footerElement = this.element.createChild("div", "network-filmstrip-previ ew-footer"); | |
| 267 footerElement.createChild("div", "flex-auto"); | |
| 268 var prevButton = createTextButton("\u25C0", this._onPrevFrame.bind(this), un defined, WebInspector.UIString("Previous frame")); | |
| 269 footerElement.appendChild(prevButton); | |
| 270 this._timeLabel = footerElement.createChild("div", "network-filmstrip-previe w-label"); | |
| 271 var nextButton = createTextButton("\u25B6", this._onNextFrame.bind(this), un defined, WebInspector.UIString("Next frame")); | |
| 272 footerElement.appendChild(nextButton); | |
| 273 footerElement.createChild("div", "flex-auto"); | |
| 274 | |
| 275 this._render(); | |
| 276 this.element.addEventListener("keydown", this._keyDown.bind(this), false); | |
| 277 } | |
| 278 | |
| 279 WebInspector.NetworkFilmStripFrame.DialogDelegate.prototype = { | |
| 280 /** | |
| 281 * @override | |
| 282 */ | |
| 283 focus: function() | |
| 284 { | |
| 285 this.element.focus(); | |
| 286 }, | |
| 287 | |
| 288 /** | |
| 289 * @param {!Event} event | |
| 290 */ | |
| 291 _keyDown: function(event) | |
| 292 { | |
|
dgozman
2015/04/22 10:16:54
Would be nice to support Home/End as well.
pfeldman
2015/04/22 12:13:12
Done.
| |
| 293 if (event.keyIdentifier === "Left") { | |
| 294 this._onPrevFrame(); | |
| 295 return; | |
| 296 } | |
| 297 | |
| 298 if (event.keyIdentifier === "Right") | |
| 299 this._onNextFrame(); | |
| 300 }, | |
| 301 | |
| 302 _onPrevFrame: function() | |
| 303 { | |
| 304 var prevFrame = this._frame._prevFrame; | |
| 305 if (prevFrame) { | |
| 306 this._frame = prevFrame; | |
| 307 this._render(); | |
| 308 } | |
| 309 }, | |
| 310 | |
| 311 _onNextFrame: function() | |
| 312 { | |
| 313 var nextFrame = this._frame._nextFrame; | |
| 314 if (nextFrame) { | |
| 315 this._frame = nextFrame; | |
| 316 this._render(); | |
| 317 } | |
| 318 }, | |
| 319 | |
| 320 _render: function() | |
| 321 { | |
| 322 this._imageElement.src = "data:image/jpg;base64," + this._frame._imageDa ta; | |
| 323 this._timeLabel.textContent = this._frame._timeLabel.textContent; | |
| 324 }, | |
| 325 | |
| 326 __proto__: WebInspector.DialogDelegate.prototype | |
| 327 } | |
| OLD | NEW |