OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.VBox} | 7 * @extends {WebInspector.VBox} |
8 * @param {number} rowHeight | 8 * @param {number} rowHeight |
9 * @param {number} headerHeight | 9 * @param {number} headerHeight |
10 * @param {!WebInspector.NetworkTransferTimeCalculator} calculator | 10 * @param {!WebInspector.NetworkTransferTimeCalculator} calculator |
(...skipping 18 matching lines...) Expand all Loading... |
29 this._rowHeight = rowHeight; | 29 this._rowHeight = rowHeight; |
30 this._headerHeight = headerHeight; | 30 this._headerHeight = headerHeight; |
31 this._calculator = calculator; | 31 this._calculator = calculator; |
32 | 32 |
33 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._get
PopoverAnchor.bind(this), this._showPopover.bind(this)); | 33 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._get
PopoverAnchor.bind(this), this._showPopover.bind(this)); |
34 this._popoverHelper.setTimeout(300, 300); | 34 this._popoverHelper.setTimeout(300, 300); |
35 | 35 |
36 this._vScrollElement = this.contentElement.createChild("div", "network-timel
ine-v-scroll"); | 36 this._vScrollElement = this.contentElement.createChild("div", "network-timel
ine-v-scroll"); |
37 this._vScrollElement.addEventListener("scroll", this._onScroll.bind(this), {
passive: true }); | 37 this._vScrollElement.addEventListener("scroll", this._onScroll.bind(this), {
passive: true }); |
38 this._vScrollElement.addEventListener("mousewheel", this._onMouseWheel.bind(
this), { passive: true }); | 38 this._vScrollElement.addEventListener("mousewheel", this._onMouseWheel.bind(
this), { passive: true }); |
39 this._vScrollContent = this._vScrollElement.createChild("div"); | 39 this._vScrollContent = this._vScrollElement.createChild("div", "network-time
line-v-scroll-content"); |
40 | 40 |
41 this.element.addEventListener("mousewheel", this._onMouseWheel.bind(this), {
passive: true }); | 41 this.element.addEventListener("mousewheel", this._onMouseWheel.bind(this), {
passive: true }); |
42 this.element.addEventListener("mousemove", this._onMouseMove.bind(this), tru
e); | 42 this.element.addEventListener("mousemove", this._onMouseMove.bind(this), tru
e); |
43 this.element.addEventListener("mouseleave", this.setHoveredRequest.bind(this
, null), true); | 43 this.element.addEventListener("mouseleave", this.setHoveredRequest.bind(this
, null), true); |
44 | 44 |
45 this._boundScrollContainer = scrollContainer; | 45 this._boundScrollContainer = scrollContainer; |
46 this._boundScrollContainer.addEventListener("mousewheel", event => { | 46 this._boundScrollContainer.addEventListener("mousewheel", event => { |
47 event.consume(true); | 47 event.consume(true); |
48 this._onMouseWheel(event); | 48 this._onMouseWheel(event); |
49 }, true); | 49 }, true); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 { | 170 { |
171 this._rowHeight = height; | 171 this._rowHeight = height; |
172 }, | 172 }, |
173 | 173 |
174 /** | 174 /** |
175 * @param {number} height | 175 * @param {number} height |
176 */ | 176 */ |
177 setHeaderHeight: function(height) | 177 setHeaderHeight: function(height) |
178 { | 178 { |
179 this._headerHeight = height; | 179 this._headerHeight = height; |
| 180 this._vScrollElement.style.marginTop = height + "px"; |
180 }, | 181 }, |
181 | 182 |
182 /** | 183 /** |
183 * @param {!WebInspector.NetworkTimeCalculator} calculator | 184 * @param {!WebInspector.NetworkTimeCalculator} calculator |
184 */ | 185 */ |
185 setCalculator: function(calculator) | 186 setCalculator: function(calculator) |
186 { | 187 { |
187 this._calculator = calculator; | 188 this._calculator = calculator; |
188 }, | 189 }, |
189 | 190 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 }, | 238 }, |
238 | 239 |
239 /** | 240 /** |
240 * @param {!{requests: !Array<!WebInspector.NetworkRequest>, navigationReque
st: ?WebInspector.NetworkRequest}=} requestData | 241 * @param {!{requests: !Array<!WebInspector.NetworkRequest>, navigationReque
st: ?WebInspector.NetworkRequest}=} requestData |
241 */ | 242 */ |
242 update: function(requestData) | 243 update: function(requestData) |
243 { | 244 { |
244 if (requestData) { | 245 if (requestData) { |
245 this._requestData = requestData.requests; | 246 this._requestData = requestData.requests; |
246 this._navigationRequest = requestData.navigationRequest; | 247 this._navigationRequest = requestData.navigationRequest; |
| 248 this._calculateCanvasSize(); |
247 } | 249 } |
248 this.element.window().cancelAnimationFrame(this._updateRequestID); | 250 this.element.window().cancelAnimationFrame(this._updateRequestID); |
249 this._updateRequestID = null; | 251 this._updateRequestID = null; |
250 | 252 |
251 this._startTime = this._calculator.minimumBoundary(); | 253 this._startTime = this._calculator.minimumBoundary(); |
252 this._endTime = this._calculator.maximumBoundary(); | 254 this._endTime = this._calculator.maximumBoundary(); |
253 this._resetCanvas(); | 255 this._resetCanvas(); |
254 this._draw(); | 256 this._draw(); |
255 }, | 257 }, |
256 | 258 |
(...skipping 13 matching lines...) Expand all Loading... |
270 this._canvas.style.width = this._offsetWidth + "px"; | 272 this._canvas.style.width = this._offsetWidth + "px"; |
271 this._canvas.style.height = this._offsetHeight + "px"; | 273 this._canvas.style.height = this._offsetHeight + "px"; |
272 }, | 274 }, |
273 | 275 |
274 /** | 276 /** |
275 * @override | 277 * @override |
276 */ | 278 */ |
277 onResize: function() | 279 onResize: function() |
278 { | 280 { |
279 WebInspector.VBox.prototype.onResize.call(this); | 281 WebInspector.VBox.prototype.onResize.call(this); |
280 this._offsetWidth = this.contentElement.offsetWidth; | 282 this._calculateCanvasSize(); |
| 283 this.scheduleDraw(); |
| 284 }, |
| 285 |
| 286 _calculateCanvasSize: function() |
| 287 { |
| 288 var scrollbarWidth = this._vScrollElement.offsetWidth; |
| 289 // Offset by 1 px because css needs 1px to compute height and add scroll
bar. |
| 290 if (scrollbarWidth) |
| 291 scrollbarWidth -= 1; |
| 292 this._offsetWidth = this.contentElement.offsetWidth - scrollbarWidth; |
281 this._offsetHeight = this.contentElement.offsetHeight; | 293 this._offsetHeight = this.contentElement.offsetHeight; |
282 this.scheduleDraw(); | |
283 }, | 294 }, |
284 | 295 |
285 /** | 296 /** |
286 * @param {!WebInspector.RequestTimeRangeNames} type | 297 * @param {!WebInspector.RequestTimeRangeNames} type |
287 * @return {string} | 298 * @return {string} |
288 */ | 299 */ |
289 _colorForType: function(type) | 300 _colorForType: function(type) |
290 { | 301 { |
291 var types = WebInspector.RequestTimeRangeNames; | 302 var types = WebInspector.RequestTimeRangeNames; |
292 switch (type) { | 303 switch (type) { |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 color = this._rowNavigationRequestColor; | 639 color = this._rowNavigationRequestColor; |
629 | 640 |
630 context.fillStyle = color; | 641 context.fillStyle = color; |
631 context.rect(0, y, this._offsetWidth, this._rowHeight); | 642 context.rect(0, y, this._offsetWidth, this._rowHeight); |
632 context.fill(); | 643 context.fill(); |
633 context.restore(); | 644 context.restore(); |
634 }, | 645 }, |
635 | 646 |
636 __proto__: WebInspector.VBox.prototype | 647 __proto__: WebInspector.VBox.prototype |
637 } | 648 } |
OLD | NEW |