OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 /** | |
6 * @constructor | |
7 * @param {!WebInspector.NetworkLogView} networkLogView | |
8 */ | |
9 WebInspector.NetworkLogViewColumns = function(networkLogView) | |
10 { | |
11 this._networkLogView = networkLogView; | |
12 | |
13 var defaultColumnsVisibility = WebInspector.NetworkLogViewColumns._defaultCo lumnsVisibility; | |
14 /** @type {!WebInspector.Setting} */ | |
15 this._columnsVisibilitySetting = WebInspector.settings.createSetting("networ kLogColumnsVisibility", defaultColumnsVisibility); | |
16 var savedColumnsVisibility = this._columnsVisibilitySetting.get(); | |
17 /** @type {!Object.<boolean>} */ | |
18 var columnsVisibility = {}; | |
19 for (var columnId in defaultColumnsVisibility) | |
20 columnsVisibility[columnId] = savedColumnsVisibility.hasOwnProperty(colu mnId) ? savedColumnsVisibility[columnId] : defaultColumnsVisibility[columnId]; | |
21 this._columnsVisibilitySetting.set(columnsVisibility); | |
22 | |
23 /** @type {!Array<{time: number, element: !Element}>} */ | |
24 this._eventDividers = []; | |
25 | |
26 this._gridMode = true; | |
27 | |
28 /** @type {?WebInspector.DataGrid} */ | |
29 this._dataGrid = null; | |
30 /** @type {!Array.<!WebInspector.ColumnConfig>} */ | |
31 this._columns = []; | |
32 /** @type {!Object.<string, function(!WebInspector.NetworkDataGridNode, !Web Inspector.NetworkDataGridNode) : number>} */ | |
33 this._sortingFunctions = {}; | |
34 /** @type {!Object.<string, !WebInspector.NetworkTimeCalculator>} */ | |
35 this._calculators = {}; | |
36 /** @type {?Element} */ | |
37 this._timelineSortSelector = null; | |
38 | |
39 /** @type {?WebInspector.TimelineGrid} */ | |
40 this._timelineGrid = null; | |
41 | |
42 /** @type {!WebInspector.Linkifier} */ | |
43 this._popupLinkifier = new WebInspector.Linkifier(); | |
44 } | |
45 | |
46 WebInspector.NetworkLogViewColumns._responseHeaderColumns = ["Cache-Control", "C onnection", "Content-Encoding", "Content-Length", "ETag", "Keep-Alive", "Last-Mo dified", "Server", "Vary"]; | |
47 WebInspector.NetworkLogViewColumns._defaultColumnsVisibility = { | |
48 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, | |
49 "Cache-Control": false, "Connection": false, "Content-Encoding": false, "Con tent-Length": false, "ETag": false, "Keep-Alive": false, "Last-Modified": false, "Server": false, "Vary": false | |
50 }; | |
51 | |
52 /** | |
53 * @typedef {{ | |
54 * id: string, | |
55 * title: string, | |
56 * titleDOMFragment: !DocumentFragment, | |
57 * sortable: boolean, | |
58 * weight: number, | |
59 * sort: (?WebInspector.DataGrid.Order|undefined), | |
60 * align: (?WebInspector.DataGrid.Align|undefined), | |
61 * }} | |
62 */ | |
63 WebInspector.ColumnConfig; | |
64 | |
65 /** @type {!Object.<string, string>} */ | |
66 WebInspector.NetworkLogViewColumns._columnTitles = { | |
67 "name": WebInspector.UIString("Name"), | |
68 "method": WebInspector.UIString("Method"), | |
69 "status": WebInspector.UIString("Status"), | |
70 "protocol": WebInspector.UIString("Protocol"), | |
71 "scheme": WebInspector.UIString("Scheme"), | |
72 "domain": WebInspector.UIString("Domain"), | |
73 "remoteAddress": WebInspector.UIString("Remote Address"), | |
74 "type": WebInspector.UIString("Type"), | |
75 "initiator": WebInspector.UIString("Initiator"), | |
76 "cookies": WebInspector.UIString("Cookies"), | |
77 "setCookies": WebInspector.UIString("Set-Cookies"), | |
78 "size": WebInspector.UIString("Size"), | |
79 "time": WebInspector.UIString("Time"), | |
80 "connectionId": WebInspector.UIString("Connection Id"), | |
81 "priority": WebInspector.UIString("Priority"), | |
82 "timeline": WebInspector.UIString("Timeline"), | |
83 | |
84 // Response header columns | |
85 "Cache-Control": WebInspector.UIString("Cache-Control"), | |
86 "Connection": WebInspector.UIString("Connection"), | |
87 "Content-Encoding": WebInspector.UIString("Content-Encoding"), | |
88 "Content-Length": WebInspector.UIString("Content-Length"), | |
89 "ETag": WebInspector.UIString("ETag"), | |
90 "Keep-Alive": WebInspector.UIString("Keep-Alive"), | |
91 "Last-Modified": WebInspector.UIString("Last-Modified"), | |
92 "Server": WebInspector.UIString("Server"), | |
93 "Vary": WebInspector.UIString("Vary") | |
94 }; | |
95 | |
96 WebInspector.NetworkLogViewColumns.prototype = { | |
97 willHide: function() | |
98 { | |
99 this._popoverHelper.hidePopover(); | |
100 }, | |
101 | |
102 reset: function() | |
103 { | |
104 if (this._popoverHelper) | |
105 this._popoverHelper.hidePopover(); | |
dgozman
2016/07/05 18:12:31
Let's expose hidePopover() public method. This wil
Allada-Google
2016/07/07 16:31:35
As per our talk, we should try and keep these sepa
| |
106 this._timelineGrid.removeEventDividers(); | |
107 this.updateDividersIfNeeded(); | |
108 }, | |
109 | |
110 setupGrid: function() | |
111 { | |
112 this._timelineGrid = new WebInspector.TimelineGrid(); | |
113 this._timelineGrid.element.classList.add("network-timeline-grid"); | |
114 this._dataGrid.element.appendChild(this._timelineGrid.element); | |
115 | |
116 this._updateColumns(); | |
117 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortItems, this); | |
118 this._dataGrid.sortNodes(this._sortingFunctions.startTime, false); | |
119 this._patchTimelineHeader(); | |
120 | |
121 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this); | |
122 }, | |
123 | |
124 /** | |
125 * @return {!WebInspector.SortableDataGrid} dataGrid | |
126 */ | |
127 createGrid: function() | |
128 { | |
129 this._createSortingFunctions(); | |
130 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie w.element, this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this ._onHidePopover.bind(this)); | |
131 | |
132 var timeCalculator = this._networkLogView.timeCalculator(); | |
dgozman
2016/07/05 18:12:30
Let's pass these two as parameters and remove gett
Allada-Google
2016/07/07 16:31:35
Done.
| |
133 var durationCalculator = this._networkLogView.durationCalculator(); | |
134 | |
135 this._calculators.timeline = timeCalculator; | |
136 this._calculators.startTime = timeCalculator; | |
137 this._calculators.endTime = timeCalculator; | |
138 this._calculators.responseTime = timeCalculator; | |
139 this._calculators.duration = durationCalculator; | |
140 this._calculators.latency = durationCalculator; | |
141 | |
142 var columns = []; | |
143 columns.push({ | |
144 id: "name", | |
145 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Na me"), WebInspector.UIString("Path")), | |
146 title: WebInspector.NetworkLogViewColumns._columnTitles["name"], | |
147 weight: 20 | |
148 }); | |
149 | |
150 columns.push({ | |
151 id: "method", | |
152 title: WebInspector.NetworkLogViewColumns._columnTitles["method"], | |
153 weight: 6 | |
154 }); | |
155 | |
156 columns.push({ | |
157 id: "status", | |
158 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("St atus"), WebInspector.UIString("Text")), | |
159 title: WebInspector.NetworkLogViewColumns._columnTitles["status"], | |
160 weight: 6 | |
161 }); | |
162 | |
163 columns.push({ | |
164 id: "protocol", | |
165 title: WebInspector.NetworkLogViewColumns._columnTitles["protocol"], | |
166 weight: 6 | |
167 }); | |
168 | |
169 columns.push({ | |
170 id: "scheme", | |
171 title: WebInspector.NetworkLogViewColumns._columnTitles["scheme"], | |
172 weight: 6 | |
173 }); | |
174 | |
175 columns.push({ | |
176 id: "domain", | |
177 title: WebInspector.NetworkLogViewColumns._columnTitles["domain"], | |
178 weight: 6 | |
179 }); | |
180 | |
181 columns.push({ | |
182 id: "remoteAddress", | |
183 title: WebInspector.NetworkLogViewColumns._columnTitles["remoteAddre ss"], | |
184 weight: 10, | |
185 align: WebInspector.DataGrid.Align.Right | |
186 }); | |
187 | |
188 columns.push({ | |
189 id: "type", | |
190 title: WebInspector.NetworkLogViewColumns._columnTitles["type"], | |
191 weight: 6 | |
192 }); | |
193 | |
194 columns.push({ | |
195 id: "initiator", | |
196 title: WebInspector.NetworkLogViewColumns._columnTitles["initiator"] , | |
197 weight: 10 | |
198 }); | |
199 | |
200 columns.push({ | |
201 id: "cookies", | |
202 title: WebInspector.NetworkLogViewColumns._columnTitles["cookies"], | |
203 weight: 6, | |
204 align: WebInspector.DataGrid.Align.Right | |
205 }); | |
206 | |
207 columns.push({ | |
208 id: "setCookies", | |
209 title: WebInspector.NetworkLogViewColumns._columnTitles["setCookies" ], | |
210 weight: 6, | |
211 align: WebInspector.DataGrid.Align.Right | |
212 }); | |
213 | |
214 columns.push({ | |
215 id: "size", | |
216 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Si ze"), WebInspector.UIString("Content")), | |
217 title: WebInspector.NetworkLogViewColumns._columnTitles["size"], | |
218 weight: 6, | |
219 align: WebInspector.DataGrid.Align.Right | |
220 }); | |
221 | |
222 columns.push({ | |
223 id: "time", | |
224 titleDOMFragment: this._makeHeaderFragment(WebInspector.UIString("Ti me"), WebInspector.UIString("Latency")), | |
225 title: WebInspector.NetworkLogViewColumns._columnTitles["time"], | |
226 weight: 6, | |
227 align: WebInspector.DataGrid.Align.Right | |
228 }); | |
229 | |
230 columns.push({ | |
231 id: "priority", | |
232 title: WebInspector.NetworkLogViewColumns._columnTitles["priority"], | |
233 weight: 6 | |
234 }); | |
235 | |
236 columns.push({ | |
237 id: "connectionId", | |
238 title: WebInspector.NetworkLogViewColumns._columnTitles["connectionI d"], | |
239 weight: 6 | |
240 }); | |
241 | |
242 var responseHeaderColumns = WebInspector.NetworkLogViewColumns._response HeaderColumns; | |
243 for (var i = 0; i < responseHeaderColumns.length; ++i) { | |
244 var headerName = responseHeaderColumns[i]; | |
245 var descriptor = { | |
246 id: headerName, | |
247 title: WebInspector.NetworkLogViewColumns._columnTitles[headerNa me], | |
248 weight: 6 | |
249 }; | |
250 if (headerName === "Content-Length") | |
251 descriptor.align = WebInspector.DataGrid.Align.Right; | |
252 columns.push(descriptor); | |
253 } | |
254 | |
255 columns.push({ | |
256 id: "timeline", | |
257 title: WebInspector.NetworkLogViewColumns._columnTitles["timeline"], | |
258 sortable: false, | |
259 weight: 40, | |
260 sort: WebInspector.DataGrid.Order.Ascending | |
261 }); | |
262 | |
263 for (var column of columns) { | |
264 column.sortable = column.id !== "timeline"; | |
265 column.nonSelectable = column.id !== "name"; | |
266 } | |
267 this._columns = columns; | |
268 | |
269 this._networkLogView.switchViewMode(true); | |
270 | |
271 this._dataGrid = new WebInspector.SortableDataGrid(this._columns); | |
272 return this._dataGrid; | |
273 }, | |
274 | |
275 _createSortingFunctions: function() | |
276 { | |
277 this._sortingFunctions.name = WebInspector.NetworkDataGridNode.NameCompa rator; | |
278 this._sortingFunctions.method = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "requestMethod"); | |
279 this._sortingFunctions.status = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "statusCode"); | |
280 this._sortingFunctions.protocol = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "protocol"); | |
281 this._sortingFunctions.scheme = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "scheme"); | |
282 this._sortingFunctions.domain = WebInspector.NetworkDataGridNode.Request PropertyComparator.bind(null, "domain"); | |
283 this._sortingFunctions.remoteAddress = WebInspector.NetworkDataGridNode. RemoteAddressComparator; | |
284 this._sortingFunctions.type = WebInspector.NetworkDataGridNode.TypeCompa rator; | |
285 this._sortingFunctions.initiator = WebInspector.NetworkDataGridNode.Init iatorComparator; | |
286 this._sortingFunctions.cookies = WebInspector.NetworkDataGridNode.Reques tCookiesCountComparator; | |
287 this._sortingFunctions.setCookies = WebInspector.NetworkDataGridNode.Res ponseCookiesCountComparator; | |
288 this._sortingFunctions.size = WebInspector.NetworkDataGridNode.SizeCompa rator; | |
289 this._sortingFunctions.time = WebInspector.NetworkDataGridNode.RequestPr opertyComparator.bind(null, "duration"); | |
290 this._sortingFunctions.connectionId = WebInspector.NetworkDataGridNode.R equestPropertyComparator.bind(null, "connectionId"); | |
291 this._sortingFunctions.priority = WebInspector.NetworkDataGridNode.Initi alPriorityComparator; | |
292 this._sortingFunctions.timeline = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "startTime"); | |
293 this._sortingFunctions.startTime = WebInspector.NetworkDataGridNode.Requ estPropertyComparator.bind(null, "startTime"); | |
294 this._sortingFunctions.endTime = WebInspector.NetworkDataGridNode.Reques tPropertyComparator.bind(null, "endTime"); | |
295 this._sortingFunctions.responseTime = WebInspector.NetworkDataGridNode.R equestPropertyComparator.bind(null, "responseReceivedTime"); | |
296 this._sortingFunctions.duration = WebInspector.NetworkDataGridNode.Reque stPropertyComparator.bind(null, "duration"); | |
297 this._sortingFunctions.latency = WebInspector.NetworkDataGridNode.Reques tPropertyComparator.bind(null, "latency"); | |
298 | |
299 this._sortingFunctions["Cache-Control"] = WebInspector.NetworkDataGridNo de.ResponseHeaderStringComparator.bind(null, "Cache-Control"); | |
300 this._sortingFunctions["Connection"] = WebInspector.NetworkDataGridNode. ResponseHeaderStringComparator.bind(null, "Connection"); | |
301 this._sortingFunctions["Content-Encoding"] = WebInspector.NetworkDataGri dNode.ResponseHeaderStringComparator.bind(null, "Content-Encoding"); | |
302 this._sortingFunctions["Content-Length"] = WebInspector.NetworkDataGridN ode.ResponseHeaderNumberComparator.bind(null, "Content-Length"); | |
303 this._sortingFunctions["ETag"] = WebInspector.NetworkDataGridNode.Respon seHeaderStringComparator.bind(null, "ETag"); | |
304 this._sortingFunctions["Keep-Alive"] = WebInspector.NetworkDataGridNode. ResponseHeaderStringComparator.bind(null, "Keep-Alive"); | |
305 this._sortingFunctions["Last-Modified"] = WebInspector.NetworkDataGridNo de.ResponseHeaderDateComparator.bind(null, "Last-Modified"); | |
306 this._sortingFunctions["Server"] = WebInspector.NetworkDataGridNode.Resp onseHeaderStringComparator.bind(null, "Server"); | |
307 this._sortingFunctions["Vary"] = WebInspector.NetworkDataGridNode.Respon seHeaderStringComparator.bind(null, "Vary"); | |
308 }, | |
309 | |
310 _sortItems: function() | |
311 { | |
312 this._networkLogView.removeAllNodeHighlights(); | |
313 var columnIdentifier = this._dataGrid.sortColumnIdentifier(); | |
314 if (!columnIdentifier) | |
315 return; | |
316 if (columnIdentifier === "timeline") { | |
317 this._sortByTimeline(); | |
318 return; | |
319 } | |
320 var sortingFunction = this._sortingFunctions[columnIdentifier]; | |
321 if (!sortingFunction) | |
322 return; | |
323 | |
324 this._dataGrid.sortNodes(sortingFunction, !this._dataGrid.isSortOrderAsc ending()); | |
325 this._timelineSortSelector.selectedIndex = 0; | |
326 this._networkLogView.dataGridSorted(); | |
327 }, | |
328 | |
329 _sortByTimeline: function() | |
330 { | |
331 this._networkLogView.removeAllNodeHighlights(); | |
332 var selectedIndex = this._timelineSortSelector.selectedIndex; | |
333 if (!selectedIndex) | |
334 selectedIndex = 1; // Sort by start time by default. | |
335 var selectedOption = this._timelineSortSelector[selectedIndex]; | |
336 var value = selectedOption.value; | |
337 | |
338 this._networkLogView.setCalculator(this._calculators[value]); | |
339 var sortingFunction = this._sortingFunctions[value]; | |
340 this._dataGrid.sortNodes(sortingFunction); | |
341 | |
342 this._networkLogView.dataGridSorted(); | |
343 | |
344 this._dataGrid.markColumnAsSortedBy("timeline", selectedOption.sortOrder ); | |
345 }, | |
346 | |
347 _patchTimelineHeader: function() | |
348 { | |
349 var timelineSorting = createElement("select"); | |
350 | |
351 var option = createElement("option"); | |
352 option.value = "startTime"; | |
353 option.label = WebInspector.UIString("Timeline"); | |
354 option.disabled = true; | |
355 timelineSorting.appendChild(option); | |
356 | |
357 option = createElement("option"); | |
358 option.value = "startTime"; | |
359 option.label = WebInspector.UIString("Timeline \u2013 Start Time"); | |
360 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
361 timelineSorting.appendChild(option); | |
362 | |
363 option = createElement("option"); | |
364 option.value = "responseTime"; | |
365 option.label = WebInspector.UIString("Timeline \u2013 Response Time"); | |
366 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
367 timelineSorting.appendChild(option); | |
368 | |
369 option = createElement("option"); | |
370 option.value = "endTime"; | |
371 option.label = WebInspector.UIString("Timeline \u2013 End Time"); | |
372 option.sortOrder = WebInspector.DataGrid.Order.Ascending; | |
373 timelineSorting.appendChild(option); | |
374 | |
375 option = createElement("option"); | |
376 option.value = "duration"; | |
377 option.label = WebInspector.UIString("Timeline \u2013 Total Duration"); | |
378 option.sortOrder = WebInspector.DataGrid.Order.Descending; | |
379 timelineSorting.appendChild(option); | |
380 | |
381 option = createElement("option"); | |
382 option.value = "latency"; | |
383 option.label = WebInspector.UIString("Timeline \u2013 Latency"); | |
384 option.sortOrder = WebInspector.DataGrid.Order.Descending; | |
385 timelineSorting.appendChild(option); | |
386 | |
387 var header = this._dataGrid.headerTableHeader("timeline"); | |
388 header.replaceChild(timelineSorting, header.firstChild); | |
389 header.createChild("div", "sort-order-icon-container").createChild("div" , "sort-order-icon"); | |
390 | |
391 timelineSorting.selectedIndex = 1; | |
392 timelineSorting.addEventListener("click", function(event) { event.consum e(); }, false); | |
393 timelineSorting.addEventListener("change", this._sortByTimeline.bind(thi s), false); | |
394 this._timelineSortSelector = timelineSorting; | |
395 }, | |
396 | |
397 _updateColumns: function() | |
398 { | |
399 if (!this._dataGrid) | |
400 return; | |
401 var gridMode = this._gridMode; | |
402 var visibleColumns = {"name": true}; | |
403 if (gridMode) | |
404 visibleColumns["timeline"] = true; | |
405 if (gridMode) { | |
406 var columnsVisibility = this._columnsVisibilitySetting.get(); | |
407 for (var columnIdentifier in columnsVisibility) | |
408 visibleColumns[columnIdentifier] = columnsVisibility[columnIdent ifier]; | |
409 } | |
410 | |
411 this._dataGrid.setColumnsVisiblity(visibleColumns); | |
412 }, | |
413 | |
414 /** | |
415 * @param {boolean} gridMode | |
416 */ | |
417 switchViewMode: function(gridMode) | |
418 { | |
419 if (this._gridMode === gridMode) | |
420 return; | |
421 this._gridMode = gridMode; | |
422 | |
423 if (gridMode) { | |
424 if (this._dataGrid.selectedNode) | |
425 this._dataGrid.selectedNode.selected = false; | |
426 } else { | |
427 this._networkLogView.removeAllNodeHighlights(); | |
428 this._popoverHelper.hidePopover(); | |
429 } | |
430 | |
431 this._networkLogView.element.classList.toggle("brief-mode", !gridMode); | |
432 this._updateColumns(); | |
433 }, | |
434 | |
435 /** | |
436 * @param {string} columnIdentifier | |
437 */ | |
438 _toggleColumnVisibility: function(columnIdentifier) | |
439 { | |
440 var columnsVisibility = this._columnsVisibilitySetting.get(); | |
441 columnsVisibility[columnIdentifier] = !columnsVisibility[columnIdentifie r]; | |
442 this._columnsVisibilitySetting.set(columnsVisibility); | |
443 | |
444 this._updateColumns(); | |
445 }, | |
446 | |
447 /** | |
448 * @return {!Array.<string>} | |
449 */ | |
450 _getConfigurableColumnIDs: function() | |
451 { | |
452 if (this._configurableColumnIDs) | |
453 return this._configurableColumnIDs; | |
454 | |
455 var columnTitles = WebInspector.NetworkLogViewColumns._columnTitles; | |
456 function compare(id1, id2) | |
457 { | |
458 return columnTitles[id1].compareTo(columnTitles[id2]); | |
459 } | |
460 | |
461 var columnIDs = Object.keys(this._columnsVisibilitySetting.get()); | |
462 this._configurableColumnIDs = columnIDs.sort(compare); | |
463 return this._configurableColumnIDs; | |
464 }, | |
465 | |
466 /** | |
467 * @param {string} title | |
468 * @param {string} subtitle | |
469 * @return {!DocumentFragment} | |
470 */ | |
471 _makeHeaderFragment: function(title, subtitle) | |
472 { | |
473 var fragment = createDocumentFragment(); | |
474 fragment.createTextChild(title); | |
475 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; | |
476 subtitleDiv.createTextChild(subtitle); | |
477 return fragment; | |
478 }, | |
479 | |
480 /** | |
481 * @param {!Event} event | |
482 * @return {boolean} | |
483 */ | |
484 contextMenu: function(event) | |
485 { | |
486 if (!this._gridMode || !event.target.isSelfOrDescendant(this._dataGrid.h eaderTableBody)) | |
487 return false; | |
488 | |
489 var contextMenu = new WebInspector.ContextMenu(event); | |
490 | |
491 var columnsVisibility = this._columnsVisibilitySetting.get(); | |
492 var columnIDs = this._getConfigurableColumnIDs(); | |
493 var columnTitles = WebInspector.NetworkLogViewColumns._columnTitles; | |
494 for (var i = 0; i < columnIDs.length; ++i) { | |
495 var columnIdentifier = columnIDs[i]; | |
496 contextMenu.appendCheckboxItem(columnTitles[columnIdentifier], this. _toggleColumnVisibility.bind(this, columnIdentifier), !!columnsVisibility[column Identifier]); | |
497 } | |
498 contextMenu.show(); | |
499 return true; | |
500 }, | |
501 | |
502 updateDividersIfNeeded: function() | |
503 { | |
504 if (!this._networkLogView.isShowing()) { | |
505 this._networkLogView.scheduleRefresh(); | |
506 return; | |
507 } | |
508 | |
509 var timelineOffset = this._dataGrid.columnOffset("timeline"); | |
510 // Position timline grid location. | |
511 if (timelineOffset) | |
512 this._timelineGrid.element.style.left = timelineOffset + "px"; | |
513 | |
514 var calculator = this._networkLogView.calculator(); | |
515 calculator.setDisplayWindow(this._timelineGrid.dividersElement.clientWid th); | |
516 this._timelineGrid.updateDividers(calculator, 75); | |
517 | |
518 if (calculator.startAtZero) { | |
519 // If our current sorting method starts at zero, that means it shows all | |
520 // requests starting at the same point, and so onLoad event and DOMC ontent | |
521 // event lines really wouldn't make much sense here, so don't render them. | |
522 return; | |
523 } | |
524 | |
525 this._updateEventDividers(); | |
526 }, | |
527 | |
528 /** | |
529 * @param {!Element} element | |
530 * @param {!Event} event | |
531 * @return {!Element|!AnchorBox|undefined} | |
532 */ | |
533 _getPopoverAnchor: function(element, event) | |
534 { | |
535 if (!this._gridMode) | |
536 return; | |
537 var anchor = element.enclosingNodeOrSelfWithClass("network-graph-bar") | | element.enclosingNodeOrSelfWithClass("network-graph-label"); | |
538 if (anchor && anchor.parentElement.request && anchor.parentElement.reque st.timing) | |
539 return anchor; | |
540 anchor = element.enclosingNodeOrSelfWithClass("network-script-initiated" ); | |
541 if (anchor && anchor.request) { | |
542 var initiator = /** @type {!WebInspector.NetworkRequest} */ (anchor. request).initiator(); | |
543 if (initiator && initiator.stack) | |
544 return anchor; | |
545 } | |
546 }, | |
547 | |
548 /** | |
549 * @param {!Element} anchor | |
550 * @param {!WebInspector.Popover} popover | |
551 */ | |
552 _showPopover: function(anchor, popover) | |
553 { | |
554 var content; | |
555 if (anchor.classList.contains("network-script-initiated")) { | |
556 var request = /** @type {!WebInspector.NetworkRequest} */ (anchor.re quest); | |
557 var initiator = /** @type {!NetworkAgent.Initiator} */ (request.init iator()); | |
558 content = WebInspector.DOMPresentationUtils.buildStackTracePreviewCo ntents(request.target(), this._popupLinkifier, initiator.stack); | |
559 popover.setCanShrink(true); | |
560 } else { | |
561 content = WebInspector.RequestTimingView.createTimingTable(anchor.pa rentElement.request, this._networkLogView.timeCalculator().minimumBoundary()); | |
562 popover.setCanShrink(false); | |
563 } | |
564 popover.showForAnchor(content, anchor); | |
565 }, | |
566 | |
567 _onHidePopover: function() | |
568 { | |
569 this._popupLinkifier.reset(); | |
570 }, | |
571 | |
572 /** | |
573 * @param {!Array<number>} times | |
574 * @param {string} className | |
575 */ | |
576 addEventDividers: function(times, className) | |
577 { | |
578 for (var i = 0; i < times.length; ++i) { | |
579 var element = createElementWithClass("div", "network-event-divider " + className); | |
580 this._timelineGrid.addEventDivider(element); | |
581 this._eventDividers.push({time: times[i], element: element}); | |
582 } | |
583 // Update event dividers immediately | |
584 this._updateEventDividers(); | |
585 // Schedule refresh in case dividers change the calculator span. | |
586 this._networkLogView.scheduleRefresh(); | |
587 }, | |
588 | |
589 _updateEventDividers: function() | |
590 { | |
591 var calculator = this._networkLogView.calculator(); | |
592 for (var divider of this._eventDividers) { | |
593 var timePercent = calculator.computePercentageFromEventTime(divider. time); | |
594 divider.element.classList.toggle("invisible", timePercent < 0); | |
595 divider.element.style.left = timePercent + "%"; | |
596 } | |
597 }, | |
598 | |
599 hideEventDividers: function() | |
600 { | |
601 this._timelineGrid.hideEventDividers(); | |
602 }, | |
603 | |
604 showEventDividers: function() | |
605 { | |
606 this._timelineGrid.showEventDividers(); | |
607 }, | |
608 | |
609 /** | |
610 * @param {boolean} isLargeRows | |
611 */ | |
612 rowSizeUpdated: function(isLargeRows) | |
dgozman
2016/07/05 18:12:30
- rename to setLargeRows
- even better, we should
Allada-Google
2016/07/07 16:31:35
Done.
| |
613 { | |
614 this._timelineGrid.element.classList.toggle("small", !isLargeRows); | |
615 } | |
616 } | |
OLD | NEW |