OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> | 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> |
4 * Copyright (C) 2011 Google Inc. All rights reserved. | 4 * Copyright (C) 2011 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 this.registerRequiredCSS("network/networkLogView.css"); | 44 this.registerRequiredCSS("network/networkLogView.css"); |
45 | 45 |
46 this._networkHideDataURLSetting = WebInspector.settings.createSetting("netwo rkHideDataURL", false); | 46 this._networkHideDataURLSetting = WebInspector.settings.createSetting("netwo rkHideDataURL", false); |
47 this._networkResourceTypeFiltersSetting = WebInspector.settings.createSettin g("networkResourceTypeFilters", {}); | 47 this._networkResourceTypeFiltersSetting = WebInspector.settings.createSettin g("networkResourceTypeFilters", {}); |
48 this._networkShowPrimaryLoadWaterfallSetting = WebInspector.settings.createS etting("networkShowPrimaryLoadWaterfall", false); | 48 this._networkShowPrimaryLoadWaterfallSetting = WebInspector.settings.createS etting("networkShowPrimaryLoadWaterfall", false); |
49 | 49 |
50 this._filterBar = filterBar; | 50 this._filterBar = filterBar; |
51 this._progressBarContainer = progressBarContainer; | 51 this._progressBarContainer = progressBarContainer; |
52 this._networkLogLargeRowsSetting = networkLogLargeRowsSetting; | 52 this._networkLogLargeRowsSetting = networkLogLargeRowsSetting; |
53 | 53 |
54 var defaultColumnsVisibility = WebInspector.NetworkLogView._defaultColumnsVi sibility; | 54 this._columnsView = new WebInspector.NetworkLogViewColumns(this); |
dgozman
2016/07/01 00:54:23
this._columns
Allada-Google
2016/07/01 01:28:39
Done.
| |
55 this._columnsVisibilitySetting = WebInspector.settings.createSetting("networ kLogColumnsVisibility", defaultColumnsVisibility); | |
56 var savedColumnsVisibility = this._columnsVisibilitySetting.get(); | |
57 var columnsVisibility = {}; | |
58 for (var columnId in defaultColumnsVisibility) | |
59 columnsVisibility[columnId] = savedColumnsVisibility.hasOwnProperty(colu mnId) ? savedColumnsVisibility[columnId] : defaultColumnsVisibility[columnId]; | |
60 this._columnsVisibilitySetting.set(columnsVisibility); | |
61 | 55 |
62 /** @type {!Map.<string, !WebInspector.NetworkDataGridNode>} */ | 56 /** @type {!Map.<string, !WebInspector.NetworkDataGridNode>} */ |
63 this._nodesByRequestId = new Map(); | 57 this._nodesByRequestId = new Map(); |
64 /** @type {!Object.<string, boolean>} */ | 58 /** @type {!Object.<string, boolean>} */ |
65 this._staleRequestIds = {}; | 59 this._staleRequestIds = {}; |
66 /** @type {number} */ | 60 /** @type {number} */ |
67 this._mainRequestLoadTime = -1; | 61 this._mainRequestLoadTime = -1; |
68 /** @type {number} */ | 62 /** @type {number} */ |
69 this._mainRequestDOMContentLoadedTime = -1; | 63 this._mainRequestDOMContentLoadedTime = -1; |
70 this._matchedRequestCount = 0; | 64 this._matchedRequestCount = 0; |
71 /** @type {!Array<{time: number, element: !Element}>} */ | |
72 this._eventDividers = []; | |
73 this._highlightedSubstringChanges = []; | 65 this._highlightedSubstringChanges = []; |
74 | 66 |
75 /** @type {!Array.<!WebInspector.NetworkLogView.Filter>} */ | 67 /** @type {!Array.<!WebInspector.NetworkLogView.Filter>} */ |
76 this._filters = []; | 68 this._filters = []; |
77 /** @type {?WebInspector.NetworkLogView.Filter} */ | 69 /** @type {?WebInspector.NetworkLogView.Filter} */ |
78 this._timeFilter = null; | 70 this._timeFilter = null; |
79 | 71 |
80 this._currentMatchedRequestNode = null; | 72 this._currentMatchedRequestNode = null; |
81 this._currentMatchedRequestIndex = -1; | 73 this._currentMatchedRequestIndex = -1; |
82 | 74 |
83 /** @type {!WebInspector.Linkifier} */ | 75 /** @type {!WebInspector.Linkifier} */ |
84 this._popupLinkifier = new WebInspector.Linkifier(); | |
85 /** @type {!WebInspector.Linkifier} */ | |
86 this.linkifier = new WebInspector.Linkifier(); | 76 this.linkifier = new WebInspector.Linkifier(); |
87 | 77 |
88 this._gridMode = true; | |
89 this._recording = false; | 78 this._recording = false; |
90 this._preserveLog = false; | 79 this._preserveLog = false; |
91 | 80 |
92 /** @type {number} */ | 81 /** @type {number} */ |
93 this._rowHeight = 0; | 82 this._rowHeight = 0; |
94 | 83 |
95 this._addFilters(); | 84 this._addFilters(); |
96 this._resetSuggestionBuilder(); | 85 this._resetSuggestionBuilder(); |
97 this._initializeView(); | 86 this._initializeView(); |
98 | 87 |
99 WebInspector.moduleSetting("networkColorCodeResourceTypes").addChangeListene r(this._invalidateAllItems, this); | 88 WebInspector.moduleSetting("networkColorCodeResourceTypes").addChangeListene r(this._invalidateAllItems, this); |
100 this._networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, thi s); | 89 this._networkLogLargeRowsSetting.addChangeListener(this._updateRowsSize, thi s); |
101 | 90 |
102 WebInspector.targetManager.observeTargets(this); | 91 WebInspector.targetManager.observeTargets(this); |
103 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.EventTypes.RequestStarted, this._onRequestStarted, this ); | 92 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.EventTypes.RequestStarted, this._onRequestStarted, this ); |
104 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.EventTypes.RequestUpdated, this._onRequestUpdated, this ); | 93 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.EventTypes.RequestUpdated, this._onRequestUpdated, this ); |
105 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.EventTypes.RequestFinished, this._onRequestUpdated, thi s); | 94 WebInspector.targetManager.addModelListener(WebInspector.NetworkManager, Web Inspector.NetworkManager.EventTypes.RequestFinished, this._onRequestUpdated, thi s); |
106 } | 95 } |
107 | 96 |
108 WebInspector.NetworkLogView._isFilteredOutSymbol = Symbol("isFilteredOut"); | 97 WebInspector.NetworkLogView._isFilteredOutSymbol = Symbol("isFilteredOut"); |
109 WebInspector.NetworkLogView._isMatchingSearchQuerySymbol = Symbol("isMatchingSea rchQuery"); | 98 WebInspector.NetworkLogView._isMatchingSearchQuerySymbol = Symbol("isMatchingSea rchQuery"); |
110 | 99 |
111 WebInspector.NetworkLogView.HTTPSchemas = {"http": true, "https": true, "ws": tr ue, "wss": true}; | 100 WebInspector.NetworkLogView.HTTPSchemas = {"http": true, "https": true, "ws": tr ue, "wss": true}; |
112 WebInspector.NetworkLogView._responseHeaderColumns = ["Cache-Control", "Connecti on", "Content-Encoding", "Content-Length", "ETag", "Keep-Alive", "Last-Modified" , "Server", "Vary"]; | 101 |
113 WebInspector.NetworkLogView._defaultColumnsVisibility = { | |
114 method: false, status: true, protocol: false, scheme: false, domain: false, remoteAddress: false, type: true, initiator: true, cookies: false, setCookies: f alse, size: true, time: true, priority: false, connectionId: false, | |
115 "Cache-Control": false, "Connection": false, "Content-Encoding": false, "Con tent-Length": false, "ETag": false, "Keep-Alive": false, "Last-Modified": false, "Server": false, "Vary": false | |
116 }; | |
117 WebInspector.NetworkLogView._defaultRefreshDelay = 200; | 102 WebInspector.NetworkLogView._defaultRefreshDelay = 200; |
118 | 103 |
119 WebInspector.NetworkLogView._waterfallMinOvertime = 1; | 104 WebInspector.NetworkLogView._waterfallMinOvertime = 1; |
120 WebInspector.NetworkLogView._waterfallMaxOvertime = 3; | 105 WebInspector.NetworkLogView._waterfallMaxOvertime = 3; |
121 | 106 |
122 /** @enum {string} */ | 107 /** @enum {string} */ |
123 WebInspector.NetworkLogView.FilterType = { | 108 WebInspector.NetworkLogView.FilterType = { |
124 Domain: "domain", | 109 Domain: "domain", |
125 HasResponseHeader: "has-response-header", | 110 HasResponseHeader: "has-response-header", |
126 Is: "is", | 111 Is: "is", |
(...skipping 17 matching lines...) Expand all Loading... | |
144 } | 129 } |
145 | 130 |
146 /** @enum {string} */ | 131 /** @enum {string} */ |
147 WebInspector.NetworkLogView.IsFilterType = { | 132 WebInspector.NetworkLogView.IsFilterType = { |
148 Running: "running" | 133 Running: "running" |
149 }; | 134 }; |
150 | 135 |
151 /** @type {!Array.<string>} */ | 136 /** @type {!Array.<string>} */ |
152 WebInspector.NetworkLogView._searchKeys = Object.values(WebInspector.NetworkLogV iew.FilterType); | 137 WebInspector.NetworkLogView._searchKeys = Object.values(WebInspector.NetworkLogV iew.FilterType); |
153 | 138 |
154 /** @type {!Object.<string, string>} */ | |
155 WebInspector.NetworkLogView._columnTitles = { | |
156 "name": WebInspector.UIString("Name"), | |
157 "method": WebInspector.UIString("Method"), | |
158 "status": WebInspector.UIString("Status"), | |
159 "protocol": WebInspector.UIString("Protocol"), | |
160 "scheme": WebInspector.UIString("Scheme"), | |
161 "domain": WebInspector.UIString("Domain"), | |
162 "remoteAddress": WebInspector.UIString("Remote Address"), | |
163 "type": WebInspector.UIString("Type"), | |
164 "initiator": WebInspector.UIString("Initiator"), | |
165 "cookies": WebInspector.UIString("Cookies"), | |
166 "setCookies": WebInspector.UIString("Set-Cookies"), | |
167 "size": WebInspector.UIString("Size"), | |
168 "time": WebInspector.UIString("Time"), | |
169 "connectionId": WebInspector.UIString("Connection Id"), | |
170 "priority": WebInspector.UIString("Priority"), | |
171 "timeline": WebInspector.UIString("Timeline"), | |
172 | |
173 // Response header columns | |
174 "Cache-Control": WebInspector.UIString("Cache-Control"), | |
175 "Connection": WebInspector.UIString("Connection"), | |
176 "Content-Encoding": WebInspector.UIString("Content-Encoding"), | |
177 "Content-Length": WebInspector.UIString("Content-Length"), | |
178 "ETag": WebInspector.UIString("ETag"), | |
179 "Keep-Alive": WebInspector.UIString("Keep-Alive"), | |
180 "Last-Modified": WebInspector.UIString("Last-Modified"), | |
181 "Server": WebInspector.UIString("Server"), | |
182 "Vary": WebInspector.UIString("Vary") | |
183 }; | |
184 | |
185 WebInspector.NetworkLogView.prototype = { | 139 WebInspector.NetworkLogView.prototype = { |
186 /** | 140 /** |
187 * @param {boolean} recording | 141 * @param {boolean} recording |
188 */ | 142 */ |
189 setRecording: function(recording) | 143 setRecording: function(recording) |
190 { | 144 { |
191 this._recording = recording; | 145 this._recording = recording; |
192 this._updateSummaryBar(); | 146 this._updateSummaryBar(); |
193 }, | 147 }, |
194 | 148 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 */ | 187 */ |
234 setWindow: function(start, end) | 188 setWindow: function(start, end) |
235 { | 189 { |
236 if (!start && !end) { | 190 if (!start && !end) { |
237 this._timeFilter = null; | 191 this._timeFilter = null; |
238 this._timeCalculator.setWindow(null); | 192 this._timeCalculator.setWindow(null); |
239 } else { | 193 } else { |
240 this._timeFilter = WebInspector.NetworkLogView._requestTimeFilter.bi nd(null, start, end); | 194 this._timeFilter = WebInspector.NetworkLogView._requestTimeFilter.bi nd(null, start, end); |
241 this._timeCalculator.setWindow(new WebInspector.NetworkTimeBoundary( start, end)); | 195 this._timeCalculator.setWindow(new WebInspector.NetworkTimeBoundary( start, end)); |
242 } | 196 } |
243 this._updateDividersIfNeeded(); | 197 this._columnsView.updateDividersIfNeeded(); |
244 this._filterRequests(); | 198 this._filterRequests(); |
245 }, | 199 }, |
246 | 200 |
247 clearSelection: function() | 201 clearSelection: function() |
248 { | 202 { |
249 if (this._dataGrid.selectedNode) | 203 if (this._dataGrid.selectedNode) |
250 this._dataGrid.selectedNode.deselect(); | 204 this._dataGrid.selectedNode.deselect(); |
251 }, | 205 }, |
252 | 206 |
253 _addFilters: function() | 207 _addFilters: function() |
(...skipping 25 matching lines...) Expand all Loading... | |
279 this._suggestionBuilder.addItem(WebInspector.NetworkLogView.FilterType.L argerThan, "10k"); | 233 this._suggestionBuilder.addItem(WebInspector.NetworkLogView.FilterType.L argerThan, "10k"); |
280 this._suggestionBuilder.addItem(WebInspector.NetworkLogView.FilterType.L argerThan, "1M"); | 234 this._suggestionBuilder.addItem(WebInspector.NetworkLogView.FilterType.L argerThan, "1M"); |
281 this._textFilterUI.setSuggestionBuilder(this._suggestionBuilder); | 235 this._textFilterUI.setSuggestionBuilder(this._suggestionBuilder); |
282 }, | 236 }, |
283 | 237 |
284 /** | 238 /** |
285 * @param {!WebInspector.Event} event | 239 * @param {!WebInspector.Event} event |
286 */ | 240 */ |
287 _filterChanged: function(event) | 241 _filterChanged: function(event) |
288 { | 242 { |
289 this._removeAllNodeHighlights(); | 243 this.removeAllNodeHighlights(); |
290 this._parseFilterQuery(this._textFilterUI.value()); | 244 this._parseFilterQuery(this._textFilterUI.value()); |
291 this._filterRequests(); | 245 this._filterRequests(); |
292 }, | 246 }, |
293 | 247 |
294 _initializeView: function() | 248 _initializeView: function() |
295 { | 249 { |
296 this.element.id = "network-container"; | 250 this.element.id = "network-container"; |
297 | 251 |
298 this._createSortingFunctions(); | 252 this._columnsView.initializeView(); |
299 this._createCalculators(); | 253 this._createCalculators(); |
254 this._columnsView.setupColumns(); | |
dgozman
2016/07/01 00:54:23
Let's combine initializeView with setupColumns?
Allada-Google
2016/07/01 01:28:39
Done.
| |
300 this._createTable(); | 255 this._createTable(); |
301 this._createTimelineGrid(); | |
302 this._summaryBarElement = this.element.createChild("div", "network-summa ry-bar"); | 256 this._summaryBarElement = this.element.createChild("div", "network-summa ry-bar"); |
303 | 257 |
304 this._updateRowsSize(); | 258 this._updateRowsSize(); |
305 | |
306 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this. _getPopoverAnchor.bind(this), this._showPopover.bind(this), this._onHidePopover. bind(this)); | |
307 this.switchViewMode(true); | |
308 }, | 259 }, |
309 | 260 |
310 _showRecordingHint: function() | 261 _showRecordingHint: function() |
311 { | 262 { |
312 this._hideRecordingHint(); | 263 this._hideRecordingHint(); |
313 this._recordingHint = this.element.createChild("div", "network-status-pa ne fill"); | 264 this._recordingHint = this.element.createChild("div", "network-status-pa ne fill"); |
314 var hintText = this._recordingHint.createChild("div", "recording-hint"); | 265 var hintText = this._recordingHint.createChild("div", "recording-hint"); |
315 var reloadShortcutNode = this._recordingHint.createChild("b"); | 266 var reloadShortcutNode = this._recordingHint.createChild("b"); |
316 reloadShortcutNode.textContent = WebInspector.shortcutRegistry.shortcutD escriptorsForAction("main.reload")[0].name; | 267 reloadShortcutNode.textContent = WebInspector.shortcutRegistry.shortcutD escriptorsForAction("main.reload")[0].name; |
317 | 268 |
(...skipping 20 matching lines...) Expand all Loading... | |
338 * @override | 289 * @override |
339 * @return {!Array.<!Element>} | 290 * @return {!Array.<!Element>} |
340 */ | 291 */ |
341 elementsToRestoreScrollPositionsFor: function() | 292 elementsToRestoreScrollPositionsFor: function() |
342 { | 293 { |
343 if (!this._dataGrid) // Not initialized yet. | 294 if (!this._dataGrid) // Not initialized yet. |
344 return []; | 295 return []; |
345 return [this._dataGrid.scrollContainer]; | 296 return [this._dataGrid.scrollContainer]; |
346 }, | 297 }, |
347 | 298 |
348 _createTimelineGrid: function() | |
349 { | |
350 this._timelineGrid = new WebInspector.TimelineGrid(); | |
351 this._timelineGrid.element.classList.add("network-timeline-grid"); | |
352 this._dataGrid.element.appendChild(this._timelineGrid.element); | |
353 }, | |
354 | |
355 _createTable: function() | 299 _createTable: function() |
356 { | 300 { |
357 var columns = []; | 301 this._dataGrid = this._columnsView.createGrid(); |
358 columns.push({ | |
359 id: "name", | |
360 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Na me"), WebInspector.UIString("Path")), | |
361 title: WebInspector.NetworkLogView._columnTitles["name"], | |
362 weight: 20 | |
363 }); | |
364 | |
365 columns.push({ | |
366 id: "method", | |
367 title: WebInspector.NetworkLogView._columnTitles["method"], | |
368 weight: 6 | |
369 }); | |
370 | |
371 columns.push({ | |
372 id: "status", | |
373 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("St atus"), WebInspector.UIString("Text")), | |
374 title: WebInspector.NetworkLogView._columnTitles["status"], | |
375 weight: 6 | |
376 }); | |
377 | |
378 columns.push({ | |
379 id: "protocol", | |
380 title: WebInspector.NetworkLogView._columnTitles["protocol"], | |
381 weight: 6 | |
382 }); | |
383 | |
384 columns.push({ | |
385 id: "scheme", | |
386 title: WebInspector.NetworkLogView._columnTitles["scheme"], | |
387 weight: 6 | |
388 }); | |
389 | |
390 columns.push({ | |
391 id: "domain", | |
392 title: WebInspector.NetworkLogView._columnTitles["domain"], | |
393 weight: 6 | |
394 }); | |
395 | |
396 columns.push({ | |
397 id: "remoteAddress", | |
398 title: WebInspector.NetworkLogView._columnTitles["remoteAddress"], | |
399 weight: 10, | |
400 align: WebInspector.DataGrid.Align.Right | |
401 }); | |
402 | |
403 columns.push({ | |
404 id: "type", | |
405 title: WebInspector.NetworkLogView._columnTitles["type"], | |
406 weight: 6 | |
407 }); | |
408 | |
409 columns.push({ | |
410 id: "initiator", | |
411 title: WebInspector.NetworkLogView._columnTitles["initiator"], | |
412 weight: 10 | |
413 }); | |
414 | |
415 columns.push({ | |
416 id: "cookies", | |
417 title: WebInspector.NetworkLogView._columnTitles["cookies"], | |
418 weight: 6, | |
419 align: WebInspector.DataGrid.Align.Right | |
420 }); | |
421 | |
422 columns.push({ | |
423 id: "setCookies", | |
424 title: WebInspector.NetworkLogView._columnTitles["setCookies"], | |
425 weight: 6, | |
426 align: WebInspector.DataGrid.Align.Right | |
427 }); | |
428 | |
429 columns.push({ | |
430 id: "size", | |
431 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Si ze"), WebInspector.UIString("Content")), | |
432 title: WebInspector.NetworkLogView._columnTitles["size"], | |
433 weight: 6, | |
434 align: WebInspector.DataGrid.Align.Right | |
435 }); | |
436 | |
437 columns.push({ | |
438 id: "time", | |
439 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Ti me"), WebInspector.UIString("Latency")), | |
440 title: WebInspector.NetworkLogView._columnTitles["time"], | |
441 weight: 6, | |
442 align: WebInspector.DataGrid.Align.Right | |
443 }); | |
444 | |
445 columns.push({ | |
446 id: "priority", | |
447 title: WebInspector.NetworkLogView._columnTitles["priority"], | |
448 weight: 6 | |
449 }); | |
450 | |
451 columns.push({ | |
452 id: "connectionId", | |
453 title: WebInspector.NetworkLogView._columnTitles["connectionId"], | |
454 weight: 6 | |
455 }); | |
456 | |
457 var responseHeaderColumns = WebInspector.NetworkLogView._responseHeaderC olumns; | |
458 for (var i = 0; i < responseHeaderColumns.length; ++i) { | |
459 var headerName = responseHeaderColumns[i]; | |
460 var descriptor = { | |
461 id: headerName, | |
462 title: WebInspector.NetworkLogView._columnTitles[headerName], | |
463 weight: 6 | |
464 }; | |
465 if (headerName === "Content-Length") | |
466 descriptor.align = WebInspector.DataGrid.Align.Right; | |
467 columns.push(descriptor); | |
468 } | |
469 | |
470 columns.push({ | |
471 id: "timeline", | |
472 title: WebInspector.NetworkLogView._columnTitles["timeline"], | |
473 sortable: false, | |
474 weight: 40, | |
475 sort: WebInspector.DataGrid.Order.Ascending | |
476 }); | |
477 | |
478 for (var column of columns) { | |
479 column.sortable = column.id !== "timeline"; | |
480 column.nonSelectable = column.id !== "name"; | |
481 } | |
482 | |
483 this._dataGrid = new WebInspector.SortableDataGrid(columns); | |
484 this._dataGrid.setStickToBottom(true); | 302 this._dataGrid.setStickToBottom(true); |
485 this._updateColumns(); | |
486 this._dataGrid.setName("networkLog"); | 303 this._dataGrid.setName("networkLog"); |
487 this._dataGrid.setResizeMethod(WebInspector.DataGrid.ResizeMethod.Last); | 304 this._dataGrid.setResizeMethod(WebInspector.DataGrid.ResizeMethod.Last); |
488 this._dataGrid.element.classList.add("network-log-grid"); | 305 this._dataGrid.element.classList.add("network-log-grid"); |
489 this._dataGrid.element.addEventListener("contextmenu", this._contextMenu .bind(this), true); | 306 this._dataGrid.element.addEventListener("contextmenu", this._contextMenu .bind(this), true); |
490 this._dataGrid.element.addEventListener("mousedown", this._dataGridMouse Down.bind(this), true); | 307 this._dataGrid.element.addEventListener("mousedown", this._dataGridMouse Down.bind(this), true); |
491 this._dataGrid.element.addEventListener("mousemove", this._dataGridMouse Move.bind(this), true); | 308 this._dataGrid.element.addEventListener("mousemove", this._dataGridMouse Move.bind(this), true); |
492 this._dataGrid.element.addEventListener("mouseleave", this._highlightIni tiatorChain.bind(this, null), true); | 309 this._dataGrid.element.addEventListener("mouseleave", this._highlightIni tiatorChain.bind(this, null), true); |
493 this._dataGrid.asWidget().show(this.element); | 310 this._dataGrid.asWidget().show(this.element); |
494 | 311 |
495 // Event listeners need to be added _after_ we attach to the document, s o that owner document is properly update. | 312 // Event listeners need to be added _after_ we attach to the document, s o that owner document is properly update. |
496 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortItems, this); | 313 this._columnsView.setDataGrid(this._dataGrid); |
dgozman
2016/07/01 00:54:23
DataGrid was created by columns, no need to set it
Allada-Google
2016/07/01 01:28:39
Done.
| |
497 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this._updateDividersIfNeeded, this); | |
498 | |
499 this._patchTimelineHeader(); | |
500 this._dataGrid.sortNodes(this._sortingFunctions.startTime, false); | |
501 }, | 314 }, |
502 | 315 |
503 /** | 316 /** |
504 * @param {!Event} event | 317 * @param {!Event} event |
505 */ | 318 */ |
506 _dataGridMouseDown: function(event) | 319 _dataGridMouseDown: function(event) |
507 { | 320 { |
508 if ((!this._dataGrid.selectedNode && event.button) || event.target.enclo singNodeOrSelfWithNodeName("a")) | 321 if ((!this._dataGrid.selectedNode && event.button) || event.target.enclo singNodeOrSelfWithNodeName("a")) |
509 event.consume(); | 322 event.consume(); |
510 }, | 323 }, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 } | 360 } |
548 | 361 |
549 for (var node of this._nodesByRequestId.values()) { | 362 for (var node of this._nodesByRequestId.values()) { |
550 if (!node.dataGrid) | 363 if (!node.dataGrid) |
551 continue; | 364 continue; |
552 node.element().classList.toggle("network-node-on-initiator-path", no de.request() !== request && initiators.has(node.request())); | 365 node.element().classList.toggle("network-node-on-initiator-path", no de.request() !== request && initiators.has(node.request())); |
553 node.element().classList.toggle("network-node-on-initiated-path", no de.request() !== request && initiated.has(node.request())); | 366 node.element().classList.toggle("network-node-on-initiated-path", no de.request() !== request && initiated.has(node.request())); |
554 } | 367 } |
555 }, | 368 }, |
556 | 369 |
557 /** | |
558 * @param {string} title | |
559 * @param {string} subtitle | |
560 * @return {!DocumentFragment} | |
561 */ | |
562 _makeHeaderFragment: function(title, subtitle) | |
563 { | |
564 var fragment = createDocumentFragment(); | |
565 fragment.createTextChild(title); | |
566 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; | |
567 subtitleDiv.createTextChild(subtitle); | |
568 return fragment; | |
569 }, | |
570 | |
571 _patchTimelineHeader: function() | |
572 { | |
573 var timelineSorting = createElement("select"); | |
574 | |
575 var option = createElement("option"); | |
576 option.value = "startTime"; | |
577 option.label = WebInspector.UIString("Timeline"); | |
578 option.disabled = true; | |
579 timelineSorting.appendChild(option); | |
580 | |
581 option = createElement("option"); | |
582 option.value = "startTime"; | |
583 option.label = WebInspector.UIString("Timeline \u2013 Start Time"); | |
584 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
585 timelineSorting.appendChild(option); | |
586 | |
587 option = createElement("option"); | |
588 option.value = "responseTime"; | |
589 option.label = WebInspector.UIString("Timeline \u2013 Response Time"); | |
590 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
591 timelineSorting.appendChild(option); | |
592 | |
593 option = createElement("option"); | |
594 option.value = "endTime"; | |
595 option.label = WebInspector.UIString("Timeline \u2013 End Time"); | |
596 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
597 timelineSorting.appendChild(option); | |
598 | |
599 option = createElement("option"); | |
600 option.value = "duration"; | |
601 option.label = WebInspector.UIString("Timeline \u2013 Total Duration"); | |
602 option.sortOrder = WebInspector.DataGrid.Order.Descending; | |
603 timelineSorting.appendChild(option); | |
604 | |
605 option = createElement("option"); | |
606 option.value = "latency"; | |
607 option.label = WebInspector.UIString("Timeline \u2013 Latency"); | |
608 option.sortOrder = WebInspector.DataGrid.Order.Descending; | |
609 timelineSorting.appendChild(option); | |
610 | |
611 var header = this._dataGrid.headerTableHeader("timeline"); | |
612 header.replaceChild(timelineSorting, header.firstChild); | |
613 header.createChild("div", "sort-order-icon-container").createChild("div" , "sort-order-icon"); | |
614 | |
615 timelineSorting.selectedIndex = 1; | |
616 timelineSorting.addEventListener("click", function(event) { event.consum e(); }, false); | |
617 timelineSorting.addEventListener("change", this._sortByTimeline.bind(thi s), false); | |
618 this._timelineSortSelector = timelineSorting; | |
619 }, | |
620 | |
621 _createSortingFunctions: function() | |
622 { | |
623 this._sortingFunctions = {}; | |
624 this._sortingFunctions.name = WebInspector.NetworkDataGridNode.NameCompa rator; | |
625 this._sortingFunctions.method = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "requestMethod"); | |
626 this._sortingFunctions.status = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "statusCode"); | |
627 this._sortingFunctions.protocol = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "protocol"); | |
628 this._sortingFunctions.scheme = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "scheme"); | |
629 this._sortingFunctions.domain = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "domain"); | |
630 this._sortingFunctions.remoteAddress = WebInspector.NetworkDataGridNode. RemoteAddressComparator; | |
631 this._sortingFunctions.type = WebInspector.NetworkDataGridNode.TypeCompa rator; | |
632 this._sortingFunctions.initiator = WebInspector.NetworkDataGridNode.Init iatorComparator; | |
633 this._sortingFunctions.cookies = WebInspector.NetworkDataGridNode.Reques tCookiesCountComparator; | |
634 this._sortingFunctions.setCookies = WebInspector.NetworkDataGridNode.Res ponseCookiesCountComparator; | |
635 this._sortingFunctions.size = WebInspector.NetworkDataGridNode.SizeCompa rator; | |
636 this._sortingFunctions.time = WebInspector.NetworkDataGridNode.RequestPr opertyComparator.bind(null, "duration"); | |
637 this._sortingFunctions.connectionId = WebInspector.NetworkDataGridNode.R equestPropertyComparator.bind(null, "connectionId"); | |
638 this._sortingFunctions.priority = WebInspector.NetworkDataGridNode.Initi alPriorityComparator; | |
639 this._sortingFunctions.timeline = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "startTime"); | |
640 this._sortingFunctions.startTime = WebInspector.NetworkDataGridNode.Requ estPropertyComparator.bind(null, "startTime"); | |
641 this._sortingFunctions.endTime = WebInspector.NetworkDataGridNode.Reques tPropertyComparator.bind(null, "endTime"); | |
642 this._sortingFunctions.responseTime = WebInspector.NetworkDataGridNode.R equestPropertyComparator.bind(null, "responseReceivedTime"); | |
643 this._sortingFunctions.duration = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "duration"); | |
644 this._sortingFunctions.latency = WebInspector.NetworkDataGridNode.Reques tPropertyComparator.bind(null, "latency"); | |
645 | |
646 this._sortingFunctions["Cache-Control"] = WebInspector.NetworkDataGridNo de.ResponseHeaderStringComparator.bind(null, "Cache-Control"); | |
647 this._sortingFunctions["Connection"] = WebInspector.NetworkDataGridNode. ResponseHeaderStringComparator.bind(null, "Connection"); | |
648 this._sortingFunctions["Content-Encoding"] = WebInspector.NetworkDataGri dNode.ResponseHeaderStringComparator.bind(null, "Content-Encoding"); | |
649 this._sortingFunctions["Content-Length"] = WebInspector.NetworkDataGridN ode.ResponseHeaderNumberComparator.bind(null, "Content-Length"); | |
650 this._sortingFunctions["ETag"] = WebInspector.NetworkDataGridNode.Respon seHeaderStringComparator.bind(null, "ETag"); | |
651 this._sortingFunctions["Keep-Alive"] = WebInspector.NetworkDataGridNode. ResponseHeaderStringComparator.bind(null, "Keep-Alive"); | |
652 this._sortingFunctions["Last-Modified"] = WebInspector.NetworkDataGridNo de.ResponseHeaderDateComparator.bind(null, "Last-Modified"); | |
653 this._sortingFunctions["Server"] = WebInspector.NetworkDataGridNode.Resp onseHeaderStringComparator.bind(null, "Server"); | |
654 this._sortingFunctions["Vary"] = WebInspector.NetworkDataGridNode.Respon seHeaderStringComparator.bind(null, "Vary"); | |
655 }, | |
656 | |
657 _createCalculators: function() | 370 _createCalculators: function() |
dgozman
2016/07/01 00:54:23
Let's inline this function.
Allada-Google
2016/07/01 01:28:39
Done.
| |
658 { | 371 { |
659 /** @type {!WebInspector.NetworkTransferTimeCalculator} */ | 372 /** @type {!WebInspector.NetworkTransferTimeCalculator} */ |
660 this._timeCalculator = new WebInspector.NetworkTransferTimeCalculator(); | 373 this._timeCalculator = new WebInspector.NetworkTransferTimeCalculator(); |
661 /** @type {!WebInspector.NetworkTransferDurationCalculator} */ | 374 /** @type {!WebInspector.NetworkTransferDurationCalculator} */ |
662 this._durationCalculator = new WebInspector.NetworkTransferDurationCalcu lator(); | 375 this._durationCalculator = new WebInspector.NetworkTransferDurationCalcu lator(); |
663 | 376 |
664 /** @type {!Object.<string, !WebInspector.NetworkTimeCalculator>} */ | |
665 this._calculators = {}; | |
666 this._calculators.timeline = this._timeCalculator; | |
667 this._calculators.startTime = this._timeCalculator; | |
668 this._calculators.endTime = this._timeCalculator; | |
669 this._calculators.responseTime = this._timeCalculator; | |
670 this._calculators.duration = this._durationCalculator; | |
671 this._calculators.latency = this._durationCalculator; | |
672 | |
673 this._calculator = this._timeCalculator; | 377 this._calculator = this._timeCalculator; |
674 }, | 378 }, |
675 | 379 |
676 _sortItems: function() | |
677 { | |
678 this._removeAllNodeHighlights(); | |
679 var columnIdentifier = this._dataGrid.sortColumnIdentifier(); | |
680 if (columnIdentifier === "timeline") { | |
681 this._sortByTimeline(); | |
682 return; | |
683 } | |
684 var sortingFunction = this._sortingFunctions[columnIdentifier]; | |
685 if (!sortingFunction) | |
686 return; | |
687 | |
688 this._dataGrid.sortNodes(sortingFunction, !this._dataGrid.isSortOrderAsc ending()); | |
689 this._highlightNthMatchedRequestForSearch(this._updateMatchCountAndFindM atchIndex(this._currentMatchedRequestNode), false); | |
690 this._timelineSortSelector.selectedIndex = 0; | |
691 }, | |
692 | |
693 _sortByTimeline: function() | |
694 { | |
695 this._removeAllNodeHighlights(); | |
696 var selectedIndex = this._timelineSortSelector.selectedIndex; | |
697 if (!selectedIndex) | |
698 selectedIndex = 1; // Sort by start time by default. | |
699 var selectedOption = this._timelineSortSelector[selectedIndex]; | |
700 var value = selectedOption.value; | |
701 | |
702 this._setCalculator(this._calculators[value]); | |
703 var sortingFunction = this._sortingFunctions[value]; | |
704 this._dataGrid.sortNodes(sortingFunction); | |
705 this._highlightNthMatchedRequestForSearch(this._updateMatchCountAndFindM atchIndex(this._currentMatchedRequestNode), false); | |
706 this._dataGrid.markColumnAsSortedBy("timeline", selectedOption.sortOrder ); | |
707 }, | |
708 | |
709 _updateSummaryBar: function() | 380 _updateSummaryBar: function() |
710 { | 381 { |
711 var requestsNumber = this._nodesByRequestId.size; | 382 var requestsNumber = this._nodesByRequestId.size; |
712 | 383 |
713 if (!requestsNumber) { | 384 if (!requestsNumber) { |
714 this._showRecordingHint(); | 385 this._showRecordingHint(); |
715 return; | 386 return; |
716 } | 387 } |
717 this._hideRecordingHint(); | 388 this._hideRecordingHint(); |
718 | 389 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
771 } | 442 } |
772 if (this._mainRequestLoadTime !== -1) { | 443 if (this._mainRequestLoadTime !== -1) { |
773 appendChunk(separator); | 444 appendChunk(separator); |
774 var loadText = WebInspector.UIString("Load: %s", Number.secondsT oString(this._mainRequestLoadTime - baseTime)); | 445 var loadText = WebInspector.UIString("Load: %s", Number.secondsT oString(this._mainRequestLoadTime - baseTime)); |
775 appendChunk(loadText).classList.add("summary-red"); | 446 appendChunk(loadText).classList.add("summary-red"); |
776 } | 447 } |
777 } | 448 } |
778 summaryBar.title = text; | 449 summaryBar.title = text; |
779 }, | 450 }, |
780 | 451 |
781 _scheduleRefresh: function() | 452 scheduleRefresh: function() |
782 { | 453 { |
783 if (this._needsRefresh) | 454 if (this._needsRefresh) |
784 return; | 455 return; |
785 | 456 |
786 this._needsRefresh = true; | 457 this._needsRefresh = true; |
787 | 458 |
788 if (this.isShowing() && !this._refreshTimeout) | 459 if (this.isShowing() && !this._refreshTimeout) |
789 this._refreshTimeout = setTimeout(this.refresh.bind(this), WebInspec tor.NetworkLogView._defaultRefreshDelay); | 460 this._refreshTimeout = setTimeout(this.refresh.bind(this), WebInspec tor.NetworkLogView._defaultRefreshDelay); |
790 }, | 461 }, |
791 | 462 |
792 _updateDividersIfNeeded: function() | |
793 { | |
794 if (!this.isShowing()) { | |
795 this._scheduleRefresh(); | |
796 return; | |
797 } | |
798 | |
799 var timelineOffset = this._dataGrid.columnOffset("timeline"); | |
800 // Position timline grid location. | |
801 if (timelineOffset) | |
802 this._timelineGrid.element.style.left = timelineOffset + "px"; | |
803 | |
804 var calculator = this.calculator(); | |
805 calculator.setDisplayWindow(this._timelineGrid.dividersElement.clientWid th); | |
806 this._timelineGrid.updateDividers(calculator, 75); | |
807 | |
808 if (calculator.startAtZero) { | |
809 // If our current sorting method starts at zero, that means it shows all | |
810 // requests starting at the same point, and so onLoad event and DOMC ontent | |
811 // event lines really wouldn't make much sense here, so don't render them. | |
812 return; | |
813 } | |
814 | |
815 this._updateEventDividers(); | |
816 }, | |
817 | |
818 /** | 463 /** |
819 * @param {!Array<number>} times | 464 * @param {!Array<number>} times |
820 */ | 465 */ |
821 addFilmStripFrames: function(times) | 466 addFilmStripFrames: function(times) |
822 { | 467 { |
823 this._addEventDividers(times, "network-frame-divider"); | 468 this._columnsView.addEventDividers(times, "network-frame-divider"); |
824 }, | 469 }, |
825 | 470 |
826 /** | 471 /** |
827 * @param {number} time | 472 * @param {number} time |
828 */ | 473 */ |
829 selectFilmStripFrame: function(time) | 474 selectFilmStripFrame: function(time) |
830 { | 475 { |
831 for (var divider of this._eventDividers) | 476 for (var divider of this._eventDividers) |
832 divider.element.classList.toggle("network-frame-divider-selected", d ivider.time === time); | 477 divider.element.classList.toggle("network-frame-divider-selected", d ivider.time === time); |
833 }, | 478 }, |
834 | 479 |
835 clearFilmStripFrame: function() | 480 clearFilmStripFrame: function() |
836 { | 481 { |
837 for (var divider of this._eventDividers) | 482 for (var divider of this._eventDividers) |
838 divider.element.classList.toggle("network-frame-divider-selected", f alse); | 483 divider.element.classList.toggle("network-frame-divider-selected", f alse); |
839 }, | 484 }, |
840 | 485 |
841 /** | |
842 * @param {!Array<number>} times | |
843 * @param {string} className | |
844 */ | |
845 _addEventDividers: function(times, className) | |
846 { | |
847 for (var i = 0; i < times.length; ++i) { | |
848 var element = createElementWithClass("div", "network-event-divider " + className); | |
849 this._timelineGrid.addEventDivider(element); | |
850 this._eventDividers.push({time: times[i], element: element}); | |
851 } | |
852 // Update event dividers immediately | |
853 this._updateEventDividers(); | |
854 // Schedule refresh in case dividers change the calculator span. | |
855 this._scheduleRefresh(); | |
856 }, | |
857 | |
858 _updateEventDividers: function() | |
859 { | |
860 var calculator = this.calculator(); | |
861 for (var divider of this._eventDividers) { | |
862 var timePercent = calculator.computePercentageFromEventTime(divider. time); | |
863 divider.element.classList.toggle("invisible", timePercent < 0); | |
864 divider.element.style.left = timePercent + "%"; | |
865 } | |
866 }, | |
867 | |
868 _refreshIfNeeded: function() | 486 _refreshIfNeeded: function() |
869 { | 487 { |
870 if (this._needsRefresh) | 488 if (this._needsRefresh) |
871 this.refresh(); | 489 this.refresh(); |
872 }, | 490 }, |
873 | 491 |
874 _invalidateAllItems: function() | 492 _invalidateAllItems: function() |
875 { | 493 { |
876 var requestIds = this._nodesByRequestId.keysArray(); | 494 var requestIds = this._nodesByRequestId.keysArray(); |
877 for (var i = 0; i < requestIds.length; ++i) | 495 for (var i = 0; i < requestIds.length; ++i) |
878 this._staleRequestIds[requestIds[i]] = true; | 496 this._staleRequestIds[requestIds[i]] = true; |
879 this.refresh(); | 497 this.refresh(); |
880 }, | 498 }, |
881 | 499 |
882 /** | 500 /** |
883 * @return {!WebInspector.NetworkTimeCalculator} | 501 * @return {!WebInspector.NetworkTimeCalculator} |
884 */ | 502 */ |
885 timeCalculator: function() | 503 timeCalculator: function() |
886 { | 504 { |
887 return this._timeCalculator; | 505 return this._timeCalculator; |
888 }, | 506 }, |
889 | 507 |
890 /** | 508 /** |
891 * @return {!WebInspector.NetworkTimeCalculator} | 509 * @return {!WebInspector.NetworkTimeCalculator} |
892 */ | 510 */ |
511 durationCalculator: function() | |
512 { | |
513 return this._durationCalculator; | |
514 }, | |
515 | |
516 /** | |
517 * @return {!WebInspector.NetworkTimeCalculator} | |
518 */ | |
893 calculator: function() | 519 calculator: function() |
894 { | 520 { |
895 return this._calculator; | 521 return this._calculator; |
896 }, | 522 }, |
897 | 523 |
898 /** | 524 /** |
899 * @param {!WebInspector.NetworkTimeCalculator} x | 525 * @param {!WebInspector.NetworkTimeCalculator} x |
900 */ | 526 */ |
901 _setCalculator: function(x) | 527 setCalculator: function(x) |
902 { | 528 { |
903 if (!x || this._calculator === x) | 529 if (!x || this._calculator === x) |
904 return; | 530 return; |
905 | 531 |
906 this._calculator = x; | 532 this._calculator = x; |
907 this._calculator.reset(); | 533 this._calculator.reset(); |
908 | 534 |
909 if (this._calculator.startAtZero) | 535 if (this._calculator.startAtZero) |
910 this._timelineGrid.hideEventDividers(); | 536 this._columnsView.hideEventDividers(); |
911 else | 537 else |
912 this._timelineGrid.showEventDividers(); | 538 this._columnsView.showEventDividers(); |
913 | 539 |
914 this._invalidateAllItems(); | 540 this._invalidateAllItems(); |
915 }, | 541 }, |
916 | 542 |
917 /** | 543 /** |
918 * @param {!WebInspector.Event} event | 544 * @param {!WebInspector.Event} event |
919 */ | 545 */ |
920 _loadEventFired: function(event) | 546 _loadEventFired: function(event) |
921 { | 547 { |
922 if (!this._recording) | 548 if (!this._recording) |
923 return; | 549 return; |
924 | 550 |
925 var data = /** @type {number} */ (event.data); | 551 var data = /** @type {number} */ (event.data); |
926 if (data) { | 552 if (data) { |
927 this._mainRequestLoadTime = data; | 553 this._mainRequestLoadTime = data; |
928 this._addEventDividers([data], "network-red-divider"); | 554 this._columnsView.addEventDividers([data], "network-red-divider"); |
929 } | 555 } |
930 }, | 556 }, |
931 | 557 |
932 /** | 558 /** |
933 * @param {!WebInspector.Event} event | 559 * @param {!WebInspector.Event} event |
934 */ | 560 */ |
935 _domContentLoadedEventFired: function(event) | 561 _domContentLoadedEventFired: function(event) |
936 { | 562 { |
937 if (!this._recording) | 563 if (!this._recording) |
938 return; | 564 return; |
939 var data = /** @type {number} */ (event.data); | 565 var data = /** @type {number} */ (event.data); |
940 if (data) { | 566 if (data) { |
941 this._mainRequestDOMContentLoadedTime = data; | 567 this._mainRequestDOMContentLoadedTime = data; |
942 this._addEventDividers([data], "network-blue-divider"); | 568 this._columnsView.addEventDividers([data], "network-blue-divider"); |
943 } | 569 } |
944 }, | 570 }, |
945 | 571 |
946 wasShown: function() | 572 wasShown: function() |
947 { | 573 { |
948 this._refreshIfNeeded(); | 574 this._refreshIfNeeded(); |
949 }, | 575 }, |
950 | 576 |
951 willHide: function() | 577 willHide: function() |
952 { | 578 { |
953 this._popoverHelper.hidePopover(); | 579 this._columnsView.willHide(); |
954 }, | 580 }, |
955 | 581 |
956 refresh: function() | 582 refresh: function() |
957 { | 583 { |
958 this._needsRefresh = false; | 584 this._needsRefresh = false; |
959 if (this._refreshTimeout) { | 585 if (this._refreshTimeout) { |
960 clearTimeout(this._refreshTimeout); | 586 clearTimeout(this._refreshTimeout); |
961 delete this._refreshTimeout; | 587 delete this._refreshTimeout; |
962 } | 588 } |
963 | 589 |
964 this._removeAllNodeHighlights(); | 590 this.removeAllNodeHighlights(); |
965 | 591 |
966 var oldBoundary = this.calculator().boundary(); | 592 var oldBoundary = this.calculator().boundary(); |
967 this._timeCalculator.updateBoundariesForEventTime(this._mainRequestLoadT ime); | 593 this._timeCalculator.updateBoundariesForEventTime(this._mainRequestLoadT ime); |
968 this._durationCalculator.updateBoundariesForEventTime(this._mainRequestL oadTime); | 594 this._durationCalculator.updateBoundariesForEventTime(this._mainRequestL oadTime); |
969 this._timeCalculator.updateBoundariesForEventTime(this._mainRequestDOMCo ntentLoadedTime); | 595 this._timeCalculator.updateBoundariesForEventTime(this._mainRequestDOMCo ntentLoadedTime); |
970 this._durationCalculator.updateBoundariesForEventTime(this._mainRequestD OMContentLoadedTime); | 596 this._durationCalculator.updateBoundariesForEventTime(this._mainRequestD OMContentLoadedTime); |
971 | 597 |
972 var dataGrid = this._dataGrid; | 598 var dataGrid = this._dataGrid; |
973 var rootNode = dataGrid.rootNode(); | 599 var rootNode = dataGrid.rootNode(); |
974 /** @type {!Array<!WebInspector.NetworkDataGridNode> } */ | 600 /** @type {!Array<!WebInspector.NetworkDataGridNode> } */ |
(...skipping 28 matching lines...) Expand all Loading... | |
1003 node[WebInspector.NetworkLogView._isMatchingSearchQuerySymbol] = thi s._matchRequest(request); | 629 node[WebInspector.NetworkLogView._isMatchingSearchQuerySymbol] = thi s._matchRequest(request); |
1004 } | 630 } |
1005 | 631 |
1006 for (var node of nodesToRefresh) | 632 for (var node of nodesToRefresh) |
1007 node.refresh(); | 633 node.refresh(); |
1008 | 634 |
1009 this._highlightNthMatchedRequestForSearch(this._updateMatchCountAndFindM atchIndex(this._currentMatchedRequestNode), false); | 635 this._highlightNthMatchedRequestForSearch(this._updateMatchCountAndFindM atchIndex(this._currentMatchedRequestNode), false); |
1010 | 636 |
1011 if (!this.calculator().boundary().equals(oldBoundary)) { | 637 if (!this.calculator().boundary().equals(oldBoundary)) { |
1012 // The boundaries changed, so all item graphs are stale. | 638 // The boundaries changed, so all item graphs are stale. |
1013 this._updateDividersIfNeeded(); | 639 this._columnsView.updateDividersIfNeeded(); |
1014 var nodes = this._nodesByRequestId.valuesArray(); | 640 var nodes = this._nodesByRequestId.valuesArray(); |
1015 for (var i = 0; i < nodes.length; ++i) | 641 for (var i = 0; i < nodes.length; ++i) |
1016 nodes[i].refreshGraph(); | 642 nodes[i].refreshGraph(); |
1017 } | 643 } |
1018 | 644 |
1019 this._staleRequestIds = {}; | 645 this._staleRequestIds = {}; |
1020 this._updateSummaryBar(); | 646 this._updateSummaryBar(); |
1021 }, | 647 }, |
1022 | 648 |
1023 reset: function() | 649 reset: function() |
1024 { | 650 { |
1025 this._requestWithHighlightedInitiators = null; | 651 this._requestWithHighlightedInitiators = null; |
1026 this.dispatchEventToListeners(WebInspector.NetworkLogView.EventTypes.Req uestSelected, null); | 652 this.dispatchEventToListeners(WebInspector.NetworkLogView.EventTypes.Req uestSelected, null); |
1027 | 653 |
1028 this._clearSearchMatchedList(); | 654 this._clearSearchMatchedList(); |
1029 if (this._popoverHelper) | 655 |
1030 this._popoverHelper.hidePopover(); | 656 this._columnsView.reset(); |
1031 | 657 |
1032 this._timeFilter = null; | 658 this._timeFilter = null; |
1033 this._calculator.reset(); | 659 this._calculator.reset(); |
1034 | 660 |
1035 this._timeCalculator.setWindow(null); | 661 this._timeCalculator.setWindow(null); |
1036 | 662 |
1037 var nodes = this._nodesByRequestId.valuesArray(); | 663 var nodes = this._nodesByRequestId.valuesArray(); |
1038 for (var i = 0; i < nodes.length; ++i) | 664 for (var i = 0; i < nodes.length; ++i) |
1039 nodes[i].dispose(); | 665 nodes[i].dispose(); |
1040 | 666 |
1041 this._nodesByRequestId.clear(); | 667 this._nodesByRequestId.clear(); |
1042 this._staleRequestIds = {}; | 668 this._staleRequestIds = {}; |
1043 this._resetSuggestionBuilder(); | 669 this._resetSuggestionBuilder(); |
1044 | 670 |
1045 this._mainRequestLoadTime = -1; | 671 this._mainRequestLoadTime = -1; |
1046 this._mainRequestDOMContentLoadedTime = -1; | 672 this._mainRequestDOMContentLoadedTime = -1; |
1047 this._eventDividers = []; | 673 this._eventDividers = []; |
1048 this._timelineGrid.removeEventDividers(); | |
1049 | 674 |
1050 if (this._dataGrid) { | 675 if (this._dataGrid) { |
1051 this._dataGrid.rootNode().removeChildren(); | 676 this._dataGrid.rootNode().removeChildren(); |
1052 this._updateDividersIfNeeded(); | |
1053 this._updateSummaryBar(); | 677 this._updateSummaryBar(); |
1054 } | 678 } |
1055 }, | 679 }, |
1056 | 680 |
1057 /** | 681 /** |
1058 * @param {string} filterString | 682 * @param {string} filterString |
1059 */ | 683 */ |
1060 setTextFilterValue: function(filterString) | 684 setTextFilterValue: function(filterString) |
1061 { | 685 { |
1062 this._textFilterUI.setValue(filterString); | 686 this._textFilterUI.setValue(filterString); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1143 var cookies = request.responseCookies; | 767 var cookies = request.responseCookies; |
1144 for (var i = 0, l = cookies ? cookies.length : 0; i < l; ++i) { | 768 for (var i = 0, l = cookies ? cookies.length : 0; i < l; ++i) { |
1145 var cookie = cookies[i]; | 769 var cookie = cookies[i]; |
1146 this._suggestionBuilder.addItem(WebInspector.NetworkLogView.FilterTy pe.SetCookieDomain, cookie.domain()); | 770 this._suggestionBuilder.addItem(WebInspector.NetworkLogView.FilterTy pe.SetCookieDomain, cookie.domain()); |
1147 this._suggestionBuilder.addItem(WebInspector.NetworkLogView.FilterTy pe.SetCookieName, cookie.name()); | 771 this._suggestionBuilder.addItem(WebInspector.NetworkLogView.FilterTy pe.SetCookieName, cookie.name()); |
1148 this._suggestionBuilder.addItem(WebInspector.NetworkLogView.FilterTy pe.SetCookieValue, cookie.value()); | 772 this._suggestionBuilder.addItem(WebInspector.NetworkLogView.FilterTy pe.SetCookieValue, cookie.value()); |
1149 } | 773 } |
1150 | 774 |
1151 this._staleRequestIds[request.requestId] = true; | 775 this._staleRequestIds[request.requestId] = true; |
1152 this.dispatchEventToListeners(WebInspector.NetworkLogView.EventTypes.Upd ateRequest, request); | 776 this.dispatchEventToListeners(WebInspector.NetworkLogView.EventTypes.Upd ateRequest, request); |
1153 this._scheduleRefresh(); | 777 this.scheduleRefresh(); |
1154 }, | 778 }, |
1155 | 779 |
1156 /** | 780 /** |
1157 * @param {!WebInspector.Event} event | 781 * @param {!WebInspector.Event} event |
1158 */ | 782 */ |
1159 _mainFrameNavigated: function(event) | 783 _mainFrameNavigated: function(event) |
1160 { | 784 { |
1161 if (!this._recording) | 785 if (!this._recording) |
1162 return; | 786 return; |
1163 | 787 |
(...skipping 22 matching lines...) Expand all Loading... | |
1186 break; | 810 break; |
1187 } | 811 } |
1188 } | 812 } |
1189 }, | 813 }, |
1190 | 814 |
1191 /** | 815 /** |
1192 * @param {boolean} gridMode | 816 * @param {boolean} gridMode |
1193 */ | 817 */ |
1194 switchViewMode: function(gridMode) | 818 switchViewMode: function(gridMode) |
1195 { | 819 { |
1196 if (this._gridMode === gridMode) | 820 this._columnsView.switchViewMode(gridMode); |
1197 return; | |
1198 this._gridMode = gridMode; | |
1199 | |
1200 if (gridMode) { | |
1201 if (this._dataGrid.selectedNode) | |
1202 this._dataGrid.selectedNode.selected = false; | |
1203 } else { | |
1204 this._removeAllNodeHighlights(); | |
1205 this._popoverHelper.hidePopover(); | |
1206 } | |
1207 | |
1208 this.element.classList.toggle("brief-mode", !gridMode); | |
1209 this._updateColumns(); | |
1210 }, | 821 }, |
1211 | 822 |
1212 /** | 823 /** |
1213 * @return {number} | 824 * @return {number} |
1214 */ | 825 */ |
1215 rowHeight: function() | 826 rowHeight: function() |
1216 { | 827 { |
1217 return this._rowHeight; | 828 return this._rowHeight; |
1218 }, | 829 }, |
1219 | 830 |
1220 _updateRowsSize: function() | 831 _updateRowsSize: function() |
1221 { | 832 { |
1222 var largeRows = !!this._networkLogLargeRowsSetting.get(); | 833 var largeRows = !!this._networkLogLargeRowsSetting.get(); |
1223 this._rowHeight = largeRows ? 41 : 21; | 834 this._rowHeight = largeRows ? 41 : 21; |
1224 this._dataGrid.element.classList.toggle("small", !largeRows); | 835 this._dataGrid.element.classList.toggle("small", !largeRows); |
1225 this._timelineGrid.element.classList.toggle("small", !largeRows); | 836 this._columnsView.rowSizeUpdated(largeRows); |
1226 this._dataGrid.scheduleUpdate(); | 837 this._dataGrid.scheduleUpdate(); |
1227 }, | 838 }, |
1228 | 839 |
1229 /** | 840 /** |
1230 * @param {!Element} element | |
1231 * @param {!Event} event | |
1232 * @return {!Element|!AnchorBox|undefined} | |
1233 */ | |
1234 _getPopoverAnchor: function(element, event) | |
1235 { | |
1236 if (!this._gridMode) | |
1237 return; | |
1238 var anchor = element.enclosingNodeOrSelfWithClass("network-graph-bar") | | element.enclosingNodeOrSelfWithClass("network-graph-label"); | |
1239 if (anchor && anchor.parentElement.request && anchor.parentElement.reque st.timing) | |
1240 return anchor; | |
1241 anchor = element.enclosingNodeOrSelfWithClass("network-script-initiated" ); | |
1242 if (anchor && anchor.request) { | |
1243 var initiator = /** @type {!WebInspector.NetworkRequest} */ (anchor. request).initiator(); | |
1244 if (initiator && initiator.stack) | |
1245 return anchor; | |
1246 } | |
1247 }, | |
1248 | |
1249 /** | |
1250 * @param {!Element} anchor | |
1251 * @param {!WebInspector.Popover} popover | |
1252 */ | |
1253 _showPopover: function(anchor, popover) | |
1254 { | |
1255 var content; | |
1256 if (anchor.classList.contains("network-script-initiated")) { | |
1257 var request = /** @type {!WebInspector.NetworkRequest} */ (anchor.re quest); | |
1258 var initiator = /** @type {!NetworkAgent.Initiator} */ (request.init iator()); | |
1259 content = WebInspector.DOMPresentationUtils.buildStackTracePreviewCo ntents(request.target(), this._popupLinkifier, initiator.stack); | |
1260 popover.setCanShrink(true); | |
1261 } else { | |
1262 content = WebInspector.RequestTimingView.createTimingTable(anchor.pa rentElement.request, this._timeCalculator.minimumBoundary()); | |
1263 popover.setCanShrink(false); | |
1264 } | |
1265 popover.showForAnchor(content, anchor); | |
1266 }, | |
1267 | |
1268 _onHidePopover: function() | |
1269 { | |
1270 this._popupLinkifier.reset(); | |
1271 }, | |
1272 | |
1273 _updateColumns: function() | |
1274 { | |
1275 if (!this._dataGrid) | |
1276 return; | |
1277 var gridMode = this._gridMode; | |
1278 var visibleColumns = {"name": true}; | |
1279 if (gridMode) | |
1280 visibleColumns["timeline"] = true; | |
1281 if (gridMode) { | |
1282 var columnsVisibility = this._columnsVisibilitySetting.get(); | |
1283 for (var columnIdentifier in columnsVisibility) | |
1284 visibleColumns[columnIdentifier] = columnsVisibility[columnIdent ifier]; | |
1285 } | |
1286 | |
1287 this._dataGrid.setColumnsVisiblity(visibleColumns); | |
1288 }, | |
1289 | |
1290 /** | |
1291 * @param {string} columnIdentifier | |
1292 */ | |
1293 _toggleColumnVisibility: function(columnIdentifier) | |
1294 { | |
1295 var columnsVisibility = this._columnsVisibilitySetting.get(); | |
1296 columnsVisibility[columnIdentifier] = !columnsVisibility[columnIdentifie r]; | |
1297 this._columnsVisibilitySetting.set(columnsVisibility); | |
1298 | |
1299 this._updateColumns(); | |
1300 }, | |
1301 | |
1302 /** | |
1303 * @return {!Array.<string>} | |
1304 */ | |
1305 _getConfigurableColumnIDs: function() | |
1306 { | |
1307 if (this._configurableColumnIDs) | |
1308 return this._configurableColumnIDs; | |
1309 | |
1310 var columnTitles = WebInspector.NetworkLogView._columnTitles; | |
1311 function compare(id1, id2) | |
1312 { | |
1313 return columnTitles[id1].compareTo(columnTitles[id2]); | |
1314 } | |
1315 | |
1316 var columnIDs = Object.keys(this._columnsVisibilitySetting.get()); | |
1317 this._configurableColumnIDs = columnIDs.sort(compare); | |
1318 return this._configurableColumnIDs; | |
1319 }, | |
1320 | |
1321 /** | |
1322 * @param {!Event} event | 841 * @param {!Event} event |
1323 */ | 842 */ |
1324 _contextMenu: function(event) | 843 _contextMenu: function(event) |
1325 { | 844 { |
845 if (this._columnsView.contextMenu(event)) | |
846 return; | |
1326 var contextMenu = new WebInspector.ContextMenu(event); | 847 var contextMenu = new WebInspector.ContextMenu(event); |
1327 | 848 |
1328 if (this._gridMode && event.target.isSelfOrDescendant(this._dataGrid.hea derTableBody)) { | |
1329 var columnsVisibility = this._columnsVisibilitySetting.get(); | |
1330 var columnIDs = this._getConfigurableColumnIDs(); | |
1331 var columnTitles = WebInspector.NetworkLogView._columnTitles; | |
1332 for (var i = 0; i < columnIDs.length; ++i) { | |
1333 var columnIdentifier = columnIDs[i]; | |
1334 contextMenu.appendCheckboxItem(columnTitles[columnIdentifier], t his._toggleColumnVisibility.bind(this, columnIdentifier), !!columnsVisibility[co lumnIdentifier]); | |
1335 } | |
1336 contextMenu.show(); | |
1337 return; | |
1338 } | |
1339 | |
1340 var gridNode = this._dataGrid.dataGridNodeFromNode(event.target); | 849 var gridNode = this._dataGrid.dataGridNodeFromNode(event.target); |
1341 var request = gridNode && gridNode.request(); | 850 var request = gridNode && gridNode.request(); |
1342 | 851 |
1343 /** | 852 /** |
1344 * @param {string} url | 853 * @param {string} url |
1345 */ | 854 */ |
1346 function openResourceInNewTab(url) | 855 function openResourceInNewTab(url) |
1347 { | 856 { |
1348 InspectorFrontendHost.openInNewTab(url); | 857 InspectorFrontendHost.openInNewTab(url); |
1349 } | 858 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1507 | 1016 |
1508 _clearSearchMatchedList: function() | 1017 _clearSearchMatchedList: function() |
1509 { | 1018 { |
1510 this._matchedRequestCount = -1; | 1019 this._matchedRequestCount = -1; |
1511 this._currentMatchedRequestNode = null; | 1020 this._currentMatchedRequestNode = null; |
1512 this._removeAllHighlights(); | 1021 this._removeAllHighlights(); |
1513 }, | 1022 }, |
1514 | 1023 |
1515 _removeAllHighlights: function() | 1024 _removeAllHighlights: function() |
1516 { | 1025 { |
1517 this._removeAllNodeHighlights(); | 1026 this.removeAllNodeHighlights(); |
1518 for (var i = 0; i < this._highlightedSubstringChanges.length; ++i) | 1027 for (var i = 0; i < this._highlightedSubstringChanges.length; ++i) |
1519 WebInspector.revertDomChanges(this._highlightedSubstringChanges[i]); | 1028 WebInspector.revertDomChanges(this._highlightedSubstringChanges[i]); |
1520 this._highlightedSubstringChanges = []; | 1029 this._highlightedSubstringChanges = []; |
1521 }, | 1030 }, |
1522 | 1031 |
1032 onWillSort: function() | |
1033 { | |
1034 this.removeAllNodeHighlights(); | |
dgozman
2016/07/01 00:54:23
Just call this one directly instead of onWillSort.
Allada-Google
2016/07/01 01:28:39
Done.
| |
1035 }, | |
1036 | |
1037 onSorted: function() | |
dgozman
2016/07/01 00:54:23
dataGridSorted
Allada-Google
2016/07/01 01:28:39
Done.
| |
1038 { | |
1039 this._highlightNthMatchedRequestForSearch(this._updateMatchCountAndFindM atchIndex(this._currentMatchedRequestNode), false); | |
1040 }, | |
1041 | |
1523 /** | 1042 /** |
1524 * @param {number} n | 1043 * @param {number} n |
1525 * @param {boolean} reveal | 1044 * @param {boolean} reveal |
1526 */ | 1045 */ |
1527 _highlightNthMatchedRequestForSearch: function(n, reveal) | 1046 _highlightNthMatchedRequestForSearch: function(n, reveal) |
1528 { | 1047 { |
1529 this._removeAllHighlights(); | 1048 this._removeAllHighlights(); |
1530 | 1049 |
1531 /** @type {!Array.<!WebInspector.NetworkDataGridNode>} */ | 1050 /** @type {!Array.<!WebInspector.NetworkDataGridNode>} */ |
1532 var nodes = this._dataGrid.rootNode().children; | 1051 var nodes = this._dataGrid.rootNode().children; |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1819 delete this._searchRegex; | 1338 delete this._searchRegex; |
1820 this._clearSearchMatchedList(); | 1339 this._clearSearchMatchedList(); |
1821 this.dispatchEventToListeners(WebInspector.NetworkLogView.EventTypes.Sea rchCountUpdated, 0); | 1340 this.dispatchEventToListeners(WebInspector.NetworkLogView.EventTypes.Sea rchCountUpdated, 0); |
1822 }, | 1341 }, |
1823 | 1342 |
1824 /** | 1343 /** |
1825 * @param {!WebInspector.NetworkRequest} request | 1344 * @param {!WebInspector.NetworkRequest} request |
1826 */ | 1345 */ |
1827 revealAndHighlightRequest: function(request) | 1346 revealAndHighlightRequest: function(request) |
1828 { | 1347 { |
1829 this._removeAllNodeHighlights(); | 1348 this.removeAllNodeHighlights(); |
1830 | 1349 |
1831 var node = this._nodesByRequestId.get(request.requestId); | 1350 var node = this._nodesByRequestId.get(request.requestId); |
1832 if (node) { | 1351 if (node) { |
1833 node.reveal(); | 1352 node.reveal(); |
1834 this._highlightNode(node); | 1353 this._highlightNode(node); |
1835 } | 1354 } |
1836 }, | 1355 }, |
1837 | 1356 |
1838 _removeAllNodeHighlights: function() | 1357 removeAllNodeHighlights: function() |
1839 { | 1358 { |
1840 if (this._highlightedNode) { | 1359 if (this._highlightedNode) { |
1841 this._highlightedNode.element().classList.remove("highlighted-row"); | 1360 this._highlightedNode.element().classList.remove("highlighted-row"); |
1842 delete this._highlightedNode; | 1361 delete this._highlightedNode; |
1843 } | 1362 } |
1844 }, | 1363 }, |
1845 | 1364 |
1846 /** | 1365 /** |
1847 * @param {!WebInspector.NetworkDataGridNode} node | 1366 * @param {!WebInspector.NetworkDataGridNode} node |
1848 */ | 1367 */ |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2190 return false; | 1709 return false; |
2191 return true; | 1710 return true; |
2192 } | 1711 } |
2193 | 1712 |
2194 WebInspector.NetworkLogView.EventTypes = { | 1713 WebInspector.NetworkLogView.EventTypes = { |
2195 RequestSelected: "RequestSelected", | 1714 RequestSelected: "RequestSelected", |
2196 SearchCountUpdated: "SearchCountUpdated", | 1715 SearchCountUpdated: "SearchCountUpdated", |
2197 SearchIndexUpdated: "SearchIndexUpdated", | 1716 SearchIndexUpdated: "SearchIndexUpdated", |
2198 UpdateRequest: "UpdateRequest" | 1717 UpdateRequest: "UpdateRequest" |
2199 }; | 1718 }; |
OLD | NEW |