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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/NetworkLogViewColumns.js

Issue 2450603005: [Devtools] Moved NetworkTimelineColumn to NetworkLogViewColumns P2 (Closed)
Patch Set: [Devtools] Moved NetworkTimelineColumn to NetworkLogViewColumns P2 Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * @param {!WebInspector.NetworkLogView} networkLogView 7 * @param {!WebInspector.NetworkLogView} networkLogView
8 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator 8 * @param {!WebInspector.NetworkTransferTimeCalculator} timeCalculator
9 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculator 9 * @param {!WebInspector.NetworkTransferDurationCalculator} durationCalculator
10 * @param {!WebInspector.Setting} networkLogLargeRowsSetting 10 * @param {!WebInspector.Setting} networkLogLargeRowsSetting
(...skipping 23 matching lines...) Expand all
34 /** @type {!Array<{time: number, element: !Element}>} */ 34 /** @type {!Array<{time: number, element: !Element}>} */
35 this._eventDividers = []; 35 this._eventDividers = [];
36 36
37 this._gridMode = true; 37 this._gridMode = true;
38 38
39 /** @type {!Array.<!WebInspector.NetworkLogViewColumns.Descriptor>} */ 39 /** @type {!Array.<!WebInspector.NetworkLogViewColumns.Descriptor>} */
40 this._columns = []; 40 this._columns = [];
41 41
42 /** @type {?WebInspector.TimelineGrid} */ 42 /** @type {?WebInspector.TimelineGrid} */
43 this._timelineGrid = null; 43 this._timelineGrid = null;
44 this._timelineHeaderElement = null;
45 this._timelineRequestsAreStale = false;
44 46
45 /** @type {!WebInspector.Linkifier} */ 47 /** @type {!WebInspector.Linkifier} */
46 this._popupLinkifier = new WebInspector.Linkifier(); 48 this._popupLinkifier = new WebInspector.Linkifier();
47 49
48 /** @type {!Map<string, !WebInspector.NetworkTimeCalculator>} */ 50 /** @type {!Map<string, !WebInspector.NetworkTimeCalculator>} */
49 this._calculatorsMap = new Map(); 51 this._calculatorsMap = new Map();
50 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorTypes .Time, timeCalculator); 52 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorTypes .Time, timeCalculator);
51 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorTypes .Duration, durationCalculator); 53 this._calculatorsMap.set(WebInspector.NetworkLogViewColumns._calculatorTypes .Duration, durationCalculator);
52 54
53 this._setupDataGrid(); 55 this._setupDataGrid();
56 if (Runtime.experiments.isEnabled("canvasNetworkTimeline"))
57 this._setupTimeline();
58
59 this._updateRowsSize();
54 }; 60 };
55 WebInspector.NetworkLogViewColumns._initialSortColumn = "timeline"; 61 WebInspector.NetworkLogViewColumns._initialSortColumn = "timeline";
56 62
57 /** 63 /**
58 * @typedef {{ 64 * @typedef {{
59 * id: string, 65 * id: string,
60 * title: string, 66 * title: string,
61 * titleDOMFragment: (!DocumentFragment|undefined), 67 * titleDOMFragment: (!DocumentFragment|undefined),
62 * subtitle: (string|null), 68 * subtitle: (string|null),
63 * visible: boolean, 69 * visible: boolean,
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 if (columnConfig.subtitle) 402 if (columnConfig.subtitle)
397 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnC onfig.title, columnConfig.subtitle); 403 columnConfig.titleDOMFragment = this._makeHeaderFragment(columnC onfig.title, columnConfig.subtitle);
398 this._columns.push(columnConfig); 404 this._columns.push(columnConfig);
399 } 405 }
400 this._loadColumns(); 406 this._loadColumns();
401 407
402 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie w.element); 408 this._popoverHelper = new WebInspector.PopoverHelper(this._networkLogVie w.element);
403 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this ), this._showPopover.bind(this), this._onHidePopover.bind(this)); 409 this._popoverHelper.initializeCallbacks(this._getPopoverAnchor.bind(this ), this._showPopover.bind(this), this._onHidePopover.bind(this));
404 410
405 this._dataGrid = new WebInspector.SortableDataGrid(this._columns.map(Web Inspector.NetworkLogViewColumns._convertToDataGridDescriptor)); 411 this._dataGrid = new WebInspector.SortableDataGrid(this._columns.map(Web Inspector.NetworkLogViewColumns._convertToDataGridDescriptor));
412 this._dataGrid.element.addEventListener("mousedown", event => {
413 if ((!this._dataGrid.selectedNode && event.button) || event.target.e nclosingNodeOrSelfWithNodeName("a"))
414 event.consume();
415 }, true);
406 416
407 this._updateColumns(); 417 this._updateColumns();
408 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortHandler, this); 418 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._sortHandler, this);
409 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this); 419 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.ColumnsResi zed, this.updateDividersIfNeeded, this);
410 this._dataGrid.setHeaderContextMenuCallback(this._innerHeaderContextMenu .bind(this)); 420 this._dataGrid.setHeaderContextMenuCallback(this._innerHeaderContextMenu .bind(this));
411 421
412 this._timelineGrid = new WebInspector.TimelineGrid(); 422 this._timelineGrid = new WebInspector.TimelineGrid();
413 this._timelineGrid.element.classList.add("network-timeline-grid"); 423 this._timelineGrid.element.classList.add("network-timeline-grid");
414 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline")) 424 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline"))
415 this._dataGrid.element.appendChild(this._timelineGrid.element); 425 this._dataGrid.element.appendChild(this._timelineGrid.element);
416 426
417 this._setupDropdownColumns(); 427 this._setupDropdownColumns();
418 428
419 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._ initialSortColumn, WebInspector.DataGrid.Order.Ascending); 429 this._dataGrid.markColumnAsSortedBy(WebInspector.NetworkLogViewColumns._ initialSortColumn, WebInspector.DataGrid.Order.Ascending);
420 430
421 this._updateRowsSize();
422
423 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) { 431 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) {
424 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo rkPanelSplitViewTimeline"); 432 this._splitWidget = new WebInspector.SplitWidget(true, false, "netwo rkPanelSplitViewTimeline");
425 this._splitWidget.setSidebarWidget(this._dataGrid.asWidget()); 433 this._splitWidget.setSidebarWidget(this._dataGrid.asWidget());
426 } 434 }
427 }, 435 },
428 436
437 _setupTimeline: function()
438 {
439 var dataGridScroller = this._dataGrid.scrollContainer;
440 this._timelineColumn = new WebInspector.NetworkTimelineColumn(this._netw orkLogView.rowHeight(), this._networkLogView.calculator(), dataGridScroller);
441 this._dataGrid.setScrollContainer(this._timelineColumn.getScrollContaine r());
442 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.PaddingChan ged, () => this._timelineColumn.setScrollHeight(dataGridScroller.scrollHeight));
443 this._dataGrid.addEventListener(WebInspector.ViewportDataGrid.Events.Vie wportCalculated, this._redrawTimelineColumn.bind(this));
444
445 this._timelineColumn.addEventListener(WebInspector.NetworkTimelineColumn .Events.RequestHovered, event => this._networkLogView.setHoveredRequest(/** @typ e {?WebInspector.NetworkRequest} */ (event.data)));
446
447 this._createTimelineHeader();
448 this._timelineColumn.contentElement.classList.add("network-timeline-view ");
449
450 this._splitWidget.setMainWidget(this._timelineColumn);
451
452 this.switchViewMode(false);
453 },
454
455 _redrawTimelineColumn: function()
456 {
457 if (!this._timelineRequestsAreStale) {
458 this._timelineColumn.update();
459 return;
460 }
461 var currentNode = this._dataGrid.rootNode();
462 var requestData = {
463 requests: [],
464 navigationRequest: null
465 };
466 while (currentNode = currentNode.traverseNextNode(true)) {
467 if (currentNode.isNavigationRequest())
468 requestData.navigationRequest = currentNode.request();
469 requestData.requests.push(currentNode.request());
470 }
471 this._timelineColumn.update(requestData);
472 },
473
474 /**
475 * @param {?WebInspector.NetworkRequest} request
476 */
477 setHoveredRequest: function(request)
478 {
479 if (Runtime.experiments.isEnabled("canvasNetworkTimeline"))
480 this._timelineColumn.setHoveredRequest(request);
481 },
482
483 _createTimelineHeader: function()
484 {
485 this._timelineHeaderElement = this._timelineColumn.contentElement.create Child("div", "network-timeline-header");
486 this._timelineHeaderElement.addEventListener("click", timelineHeaderClic ked.bind(this));
487 this._timelineHeaderElement.addEventListener("contextmenu", event => thi s._innerHeaderContextMenu(new WebInspector.ContextMenu(event)));
488 var innerElement = this._timelineHeaderElement.createChild("div");
489 innerElement.textContent = WebInspector.UIString("Timeline");
490 this._timelineColumnSortIcon = this._timelineHeaderElement.createChild(" div", "sort-order-icon-container").createChild("div", "sort-order-icon");
491
492 /**
493 * @this {WebInspector.NetworkLogViewColumns}
494 */
495 function timelineHeaderClicked()
496 {
497 var sortOrders = WebInspector.DataGrid.Order;
498 var sortOrder = this._dataGrid.sortOrder() === sortOrders.Ascending ? sortOrders.Descending : sortOrders.Ascending;
499 this._dataGrid.markColumnAsSortedBy("timeline", sortOrder);
500 this._sortHandler();
501 }
502 },
503
504 /**
505 * @param {!WebInspector.NetworkTimeCalculator} x
506 */
507 setCalculator: function(x)
508 {
509 if (Runtime.experiments.isEnabled("canvasNetworkTimeline"))
510 this._timelineColumn.setCalculator(x);
511 },
512
513 dataChanged: function()
514 {
515 if (Runtime.experiments.isEnabled("canvasNetworkTimeline"))
516 this._timelineRequestsAreStale = true;
517 },
518
519 _updateRowsSize: function()
520 {
521 var largeRows = !!this._networkLogLargeRowsSetting.get();
522 this._dataGrid.element.classList.toggle("small", !largeRows);
523 this._dataGrid.scheduleUpdate();
524
525 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline"))
526 return;
527 this._timelineColumn.setRowHeight(this._networkLogView.rowHeight());
528 // TODO(allada) Make these non-magic numbers.
529 this._timelineColumn.setHeaderHeight(largeRows ? 31 : 27);
530 this._timelineHeaderElement.classList.toggle("small", !largeRows);
531 this._timelineGrid.element.classList.toggle("small", !this._networkLogLa rgeRowsSetting.get());
532 },
533
429 /** 534 /**
430 * @param {!Element} element 535 * @param {!Element} element
431 */ 536 */
432 show: function(element) 537 show: function(element)
433 { 538 {
434 if (Runtime.experiments.isEnabled("canvasNetworkTimeline")) 539 if (Runtime.experiments.isEnabled("canvasNetworkTimeline"))
435 this._splitWidget.show(element); 540 this._splitWidget.show(element);
436 else 541 else
437 this._dataGrid.asWidget().show(element); 542 this._dataGrid.asWidget().show(element);
438 }, 543 },
439 544
440 /** 545 /**
441 * @return {!WebInspector.SplitWidget}
442 */
443 splitWidget: function()
444 {
445 // This is a temporary function used until the move of timelinecolumn in to NetworkLogViewColumns is done.
446 return this._splitWidget;
447 },
448
449 /**
450 * @return {!WebInspector.SortableDataGrid} dataGrid 546 * @return {!WebInspector.SortableDataGrid} dataGrid
451 */ 547 */
452 dataGrid: function() 548 dataGrid: function()
453 { 549 {
454 return this._dataGrid; 550 return this._dataGrid;
455 }, 551 },
456 552
457 _setupDropdownColumns: function() 553 _setupDropdownColumns: function()
458 { 554 {
459 for (var columnConfig of this._columns) { 555 for (var columnConfig of this._columns) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 if (columnConfig.sortConfig && columnConfig.sortConfig.entries) { 587 if (columnConfig.sortConfig && columnConfig.sortConfig.entries) {
492 this._sortByDropdownItem(columnConfig); 588 this._sortByDropdownItem(columnConfig);
493 return; 589 return;
494 } 590 }
495 if (!columnConfig.sortConfig.sortingFunction) 591 if (!columnConfig.sortConfig.sortingFunction)
496 return; 592 return;
497 593
498 this._networkLogView.removeAllNodeHighlights(); 594 this._networkLogView.removeAllNodeHighlights();
499 this._dataGrid.sortNodes(columnConfig.sortConfig.sortingFunction, !this. _dataGrid.isSortOrderAscending()); 595 this._dataGrid.sortNodes(columnConfig.sortConfig.sortingFunction, !this. _dataGrid.isSortOrderAscending());
500 this._networkLogView.dataGridSorted(); 596 this._networkLogView.dataGridSorted();
597
598 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline"))
599 return;
600
601 this._timelineColumnSortIcon.classList.remove("sort-ascending", "sort-de scending");
602
603 if (this._dataGrid.sortColumnId() === "timeline") {
604 if (this._dataGrid.sortOrder() === WebInspector.DataGrid.Order.Ascen ding)
605 this._timelineColumnSortIcon.classList.add("sort-ascending");
606 else
607 this._timelineColumnSortIcon.classList.add("sort-descending");
608 }
609
610 this._timelineRequestsAreStale = true;
611
501 }, 612 },
502 613
503 /** 614 /**
504 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig 615 * @param {!WebInspector.NetworkLogViewColumns.Descriptor} columnConfig
505 */ 616 */
506 _sortByDropdownItem: function(columnConfig) 617 _sortByDropdownItem: function(columnConfig)
507 { 618 {
508 this._networkLogView.removeAllNodeHighlights(); 619 this._networkLogView.removeAllNodeHighlights();
509 var selectedIndex = columnConfig.selectBox.selectedIndex; 620 var selectedIndex = columnConfig.selectBox.selectedIndex;
510 if (!selectedIndex) 621 if (!selectedIndex)
511 selectedIndex = 1; // Sort by first item by default. 622 selectedIndex = 1; // Sort by first item by default.
512 var selectedItemConfig = columnConfig.sortConfig.entries[selectedIndex - 1]; // -1 because of placeholder. 623 var selectedItemConfig = columnConfig.sortConfig.entries[selectedIndex - 1]; // -1 because of placeholder.
513 var selectedOption = columnConfig.selectBox[selectedIndex]; 624 var selectedOption = columnConfig.selectBox[selectedIndex];
514 var value = selectedOption.value; 625 var value = selectedOption.value;
515 626
516 this._dataGrid.sortNodes(selectedItemConfig.sortingFunction); 627 this._dataGrid.sortNodes(selectedItemConfig.sortingFunction);
517 this._dataGrid.markColumnAsSortedBy(columnConfig.id, /** @type {!WebInsp ector.DataGrid.Order} */ (selectedItemConfig.sort)); 628 this._dataGrid.markColumnAsSortedBy(columnConfig.id, /** @type {!WebInsp ector.DataGrid.Order} */ (selectedItemConfig.sort));
518 if (selectedItemConfig.calculator) 629 if (selectedItemConfig.calculator)
519 this._networkLogView.setCalculator(this._calculatorsMap.get(selected ItemConfig.calculator)); 630 this._networkLogView.setCalculator(this._calculatorsMap.get(selected ItemConfig.calculator));
520 columnConfig.selectBox.options[0].label = selectedItemConfig.title; 631 columnConfig.selectBox.options[0].label = selectedItemConfig.title;
521 columnConfig.selectBox.selectedIndex = 0; 632 columnConfig.selectBox.selectedIndex = 0;
522 this._networkLogView.dataGridSorted(); 633 this._networkLogView.dataGridSorted();
634
635 // TODO(allada) This entire function will be removed when the timeline c omes out of exp, so copying code above for now.
636 if (!Runtime.experiments.isEnabled("canvasNetworkTimeline"))
637 return;
638
639 this._timelineColumnSortIcon.classList.remove("sort-ascending", "sort-de scending");
640
641 if (this._dataGrid.sortColumnId() === "timeline") {
642 if (this._dataGrid.sortOrder() === WebInspector.DataGrid.Order.Ascen ding)
643 this._timelineColumnSortIcon.classList.add("sort-ascending");
644 else
645 this._timelineColumnSortIcon.classList.add("sort-descending");
646 }
647
648 this._timelineRequestsAreStale = true;
523 }, 649 },
524 650
525 _updateColumns: function() 651 _updateColumns: function()
526 { 652 {
527 if (!this._dataGrid) 653 if (!this._dataGrid)
528 return; 654 return;
529 var visibleColumns = /** @type {!Object.<string, boolean>} */ ({}); 655 var visibleColumns = /** @type {!Object.<string, boolean>} */ ({});
530 if (this._gridMode) { 656 if (this._gridMode) {
531 for (var columnConfig of this._columns) 657 for (var columnConfig of this._columns)
532 visibleColumns[columnConfig.id] = (columnConfig.visible || !colu mnConfig.hideable); 658 visibleColumns[columnConfig.id] = (columnConfig.visible || !colu mnConfig.hideable);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 _makeHeaderFragment: function(title, subtitle) 739 _makeHeaderFragment: function(title, subtitle)
614 { 740 {
615 var fragment = createDocumentFragment(); 741 var fragment = createDocumentFragment();
616 fragment.createTextChild(title); 742 fragment.createTextChild(title);
617 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ; 743 var subtitleDiv = fragment.createChild("div", "network-header-subtitle") ;
618 subtitleDiv.createTextChild(subtitle); 744 subtitleDiv.createTextChild(subtitle);
619 return fragment; 745 return fragment;
620 }, 746 },
621 747
622 /** 748 /**
623 * @param {!MouseEvent} event
624 */
625 headerContextMenuEvent: function(event)
626 {
627 // TODO(allada) Remove this entire function when new timeline moves to t his file.
628 this._innerHeaderContextMenu(new WebInspector.ContextMenu(event));
629 },
630
631 /**
632 * @param {!WebInspector.ContextMenu} contextMenu 749 * @param {!WebInspector.ContextMenu} contextMenu
633 */ 750 */
634 _innerHeaderContextMenu: function(contextMenu) 751 _innerHeaderContextMenu: function(contextMenu)
635 { 752 {
636 var columnConfigs = this._columns.filter(columnConfig => columnConfig.hi deable); 753 var columnConfigs = this._columns.filter(columnConfig => columnConfig.hi deable);
637 var nonResponseHeaders = columnConfigs.filter(columnConfig => !columnCon fig.isResponseHeader); 754 var nonResponseHeaders = columnConfigs.filter(columnConfig => !columnCon fig.isResponseHeader);
638 for (var columnConfig of nonResponseHeaders) 755 for (var columnConfig of nonResponseHeaders)
639 contextMenu.appendCheckboxItem(columnConfig.title, this._toggleColum nVisibility.bind(this, columnConfig), columnConfig.visible); 756 contextMenu.appendCheckboxItem(columnConfig.title, this._toggleColum nVisibility.bind(this, columnConfig), columnConfig.visible);
640 757
641 contextMenu.appendSeparator(); 758 contextMenu.appendSeparator();
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 selectFilmStripFrame: function(time) 981 selectFilmStripFrame: function(time)
865 { 982 {
866 for (var divider of this._eventDividers) 983 for (var divider of this._eventDividers)
867 divider.element.classList.toggle("network-frame-divider-selected", d ivider.time === time); 984 divider.element.classList.toggle("network-frame-divider-selected", d ivider.time === time);
868 }, 985 },
869 986
870 clearFilmStripFrame: function() 987 clearFilmStripFrame: function()
871 { 988 {
872 for (var divider of this._eventDividers) 989 for (var divider of this._eventDividers)
873 divider.element.classList.toggle("network-frame-divider-selected", f alse); 990 divider.element.classList.toggle("network-frame-divider-selected", f alse);
874 },
875
876 _updateRowsSize: function()
877 {
878 if (Runtime.experiments.isEnabled("canvasNetworkTimeline"))
879 return;
880 this._timelineGrid.element.classList.toggle("small", !this._networkLogLa rgeRowsSetting.get());
881 } 991 }
882 }; 992 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698