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

Side by Side Diff: Source/devtools/front_end/TimelineView.js

Issue 137853005: TimelinePanel: introduce StackView and use it instead of _timelineMemorySplitter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comments addressed Created 6 years, 11 months 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 this._presentationModel.addFilter(this._windowFilter); 60 this._presentationModel.addFilter(this._windowFilter);
61 this._presentationModel.addFilter(new WebInspector.TimelineCategoryFilter()) ; 61 this._presentationModel.addFilter(new WebInspector.TimelineCategoryFilter()) ;
62 this._presentationModel.addFilter(this._durationFilter); 62 this._presentationModel.addFilter(this._durationFilter);
63 63
64 this._frameMode = mode === WebInspector.TimelinePanel.Mode.Frames; 64 this._frameMode = mode === WebInspector.TimelinePanel.Mode.Frames;
65 this._boundariesAreValid = true; 65 this._boundariesAreValid = true;
66 this._scrollTop = 0; 66 this._scrollTop = 0;
67 67
68 // Create layout componets. 68 // Create layout componets.
69 69
70 // -------------------------------
71 // | Overview |
72 // |-------------------------------| 70 // |-------------------------------|
73 // | | | | 71 // | | | |
74 // | | Records | | 72 // | | Records | |
75 // | | | Details | 73 // | | | Details |
76 // |----------------| | 74 // |----------------| |
77 // | | Memory | | 75 // | | Memory | |
78 // ------------------------------- 76 // -------------------------------
79 77
80 // Create top level properties splitter. 78 // Create top level properties splitter.
81 this._detailsSplitView = new WebInspector.SplitView(false, "timeline-details "); 79 this._detailsSplitView = new WebInspector.SplitView(false, "timeline-details ");
82 this._detailsSplitView.element.classList.remove("fill"); 80 this._detailsSplitView.element.classList.remove("fill");
83 this._detailsSplitView.element.classList.add("timeline-details-split"); 81 this._detailsSplitView.element.classList.add("timeline-details-split");
84 this._detailsSplitView.sidebarElement().classList.add("timeline-details"); 82 this._detailsSplitView.sidebarElement().classList.add("timeline-details");
85 this._detailsSplitView.show(this.element); 83 this._detailsSplitView.show(this.element);
86 this._detailsSplitView.mainElement().classList.add("vbox"); 84 this._detailsSplitView.mainElement().classList.add("vbox");
87 this._detailsSplitView.setMainElementConstraints(undefined, 40); 85 this._detailsSplitView.setMainElementConstraints(undefined, 40);
88 this._detailsView = new WebInspector.TimelineDetailsView(); 86 this._detailsView = new WebInspector.TimelineDetailsView();
89 this._detailsSplitView.setSidebarView(this._detailsView); 87 this._detailsSplitView.setSidebarView(this._detailsView);
90 this._detailsSplitView.installResizer(this._detailsView.titleElement()); 88 this._detailsSplitView.installResizer(this._detailsView.titleElement());
91 89
92 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve nts.DockSideChanged, this._dockSideChanged.bind(this)); 90 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve nts.DockSideChanged, this._dockSideChanged.bind(this));
93 WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(thi s._dockSideChanged.bind(this)); 91 WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(thi s._dockSideChanged.bind(this));
94 this._dockSideChanged(); 92 this._dockSideChanged();
95 93
96 this._searchableView = new WebInspector.SearchableView(this); 94 this._searchableView = new WebInspector.SearchableView(this);
97 this._detailsSplitView.setMainView(this._searchableView); 95 this._detailsSplitView.setMainView(this._searchableView);
98 96
99 // Create records sidebar as a top memory splitter child. 97 this._recordsView = this._createRecordsView();
100 this._recordsView = new WebInspector.SidebarView(WebInspector.SidebarView.Si debarPosition.Start, "timeline-split");
101 this._recordsView.addEventListener(WebInspector.SidebarView.EventTypes.Resiz ed, this._sidebarResized, this);
102 this._recordsView.setSecondIsSidebar(false);
103 this._containerElement = this._recordsView.element;
104 this._containerElement.tabIndex = 0;
105 this._containerElement.id = "timeline-container";
106 this._containerElement.addEventListener("scroll", this._onScroll.bind(this), false);
107 98
108 // Create records list in the records sidebar. 99 this._stackView = new WebInspector.StackView(false);
109 this._recordsView.sidebarElement().classList.add("vbox"); 100 this._stackView.show(this._searchableView.element);
110 this._recordsView.sidebarElement().createChild("div", "timeline-records-titl e").textContent = WebInspector.UIString("RECORDS"); 101 this._recordsViewMainElement = this._stackView.appendView(this._recordsView, "timeline-records").mainElement();
111 this._sidebarListElement = this._recordsView.sidebarElement().createChild("d iv", "timeline-records-list"); 102 this._recordsViewMainElement.appendChild(this._timelineGrid.gridHeaderElemen t);
112 103
113 // Create grid in the records main area. 104 if (this._currentMode === WebInspector.TimelinePanel.Mode.Memory) {
114 this._gridContainer = new WebInspector.ViewWithResizeCallback(this._onViewpo rtResize.bind(this)); 105 // Create memory statistics as a bottom memory splitter child.
115 this._gridContainer.element.classList.add("fill"); 106 this._memoryStatistics = new WebInspector.CountersGraph(this, this._mode l);
116 this._gridContainer.element.id = "resources-container-content"; 107 this._stackView.appendView(this._memoryStatistics, "timeline-memory");
117 this._recordsView.setMainView(this._gridContainer); 108 this._memoryStatistics.setMainTimelineGrid(this._timelineGrid);
118 this._timelineGrid = new WebInspector.TimelineGrid(); 109 }
119 this._itemsGraphsElement = this._timelineGrid.itemsGraphsElement;
120 this._itemsGraphsElement.id = "timeline-graphs";
121 this._gridContainer.element.appendChild(this._timelineGrid.element);
122 this._timelineGrid.gridHeaderElement.id = "timeline-grid-header";
123 this._timelineGrid.gridHeaderElement.classList.add("fill");
124
125 // Create gap elements
126 this._topGapElement = this._itemsGraphsElement.createChild("div", "timeline- gap");
127 this._graphRowsElement = this._itemsGraphsElement.createChild("div");
128 this._bottomGapElement = this._itemsGraphsElement.createChild("div", "timeli ne-gap");
129 this._expandElements = this._itemsGraphsElement.createChild("div");
130 this._expandElements.id = "orphan-expand-elements";
131
132 // Create gpu tasks containers.
133 this._mainThreadTasks = /** @type {!Array.<!TimelineAgent.TimelineEvent>} */ ([]);
134 this._gpuTasks = /** @type {!Array.<!TimelineAgent.TimelineEvent>} */ ([]);
135 var utilizationStripsElement = this._timelineGrid.gridHeaderElement.createCh ild("div", "timeline-utilization-strips vbox");
136 this._cpuBarsElement = utilizationStripsElement.createChild("div", "timeline -utilization-strip");
137 if (WebInspector.experimentsSettings.gpuTimeline.isEnabled())
138 this._gpuBarsElement = utilizationStripsElement.createChild("div", "time line-utilization-strip gpu");
139
140 // Create memory splitter as a left child of properties.
141 this._timelineMemorySplitter = new WebInspector.SplitView(false, "timeline-m emory");
142 this._timelineMemorySplitter.element.classList.remove("fill");
143 this._timelineMemorySplitter.element.classList.add("timeline-memory-split");
144 this._timelineMemorySplitter.show(this._searchableView.element);
145 this._timelineMemorySplitter.setMainView(this._recordsView);
146
147 // Create memory statistics as a bottom memory splitter child.
148 this._memoryStatistics = new WebInspector.CountersGraph(this, this._model);
149 this._timelineMemorySplitter.setSidebarView(this._memoryStatistics);
150 this._timelineMemorySplitter.installResizer(this._memoryStatistics.resizeEle ment());
151
152 this._memoryStatistics.setMainTimelineGrid(this._timelineGrid);
153 this._timelineMemorySplitter.mainElement().appendChild(this._timelineGrid.gr idHeaderElement);
154 if (this._currentMode === WebInspector.TimelinePanel.Mode.Memory)
155 this._timelineMemorySplitter.showBoth();
156 else
157 this._timelineMemorySplitter.showOnlyFirst();
158
159 this._popoverHelper = new WebInspector.PopoverHelper(this.element, this._get PopoverAnchor.bind(this), this._showPopover.bind(this));
160 110
161 this.element.addEventListener("mousemove", this._mouseMove.bind(this), false ); 111 this.element.addEventListener("mousemove", this._mouseMove.bind(this), false );
162 this.element.addEventListener("mouseout", this._mouseOut.bind(this), false); 112 this.element.addEventListener("mouseout", this._mouseOut.bind(this), false);
163 this.element.addEventListener("keydown", this._keyDown.bind(this), false); 113 this.element.addEventListener("keydown", this._keyDown.bind(this), false);
164 114
165 this._expandOffset = 15; 115 this._expandOffset = 15;
166 116
167 this._windowStartTime = 0; 117 this._windowStartTime = 0;
168 this._windowEndTime = Infinity; 118 this._windowEndTime = Infinity;
169 119
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 continue; 163 continue;
214 var filter = new WebInspector.CheckboxFilterUI(category.name, category.t itle); 164 var filter = new WebInspector.CheckboxFilterUI(category.name, category.t itle);
215 filters._categoryFiltersUI[category.name] = filter; 165 filters._categoryFiltersUI[category.name] = filter;
216 } 166 }
217 WebInspector.TimelineView._commonUIFilters = filters; 167 WebInspector.TimelineView._commonUIFilters = filters;
218 return filters; 168 return filters;
219 } 169 }
220 170
221 WebInspector.TimelineView.prototype = { 171 WebInspector.TimelineView.prototype = {
222 /** 172 /**
173 * @return {!WebInspector.SidebarView}
174 */
175 _createRecordsView: function()
176 {
177 // Create records sidebar as a top memory splitter child.
178 var recordsView = new WebInspector.SidebarView(WebInspector.SidebarView. SidebarPosition.Start, "timeline-split");
179 recordsView.addEventListener(WebInspector.SidebarView.EventTypes.Resized , this._sidebarResized, this);
180 recordsView.setSecondIsSidebar(false);
181 this._containerElement = recordsView.element;
182 this._containerElement.tabIndex = 0;
183 this._containerElement.id = "timeline-container";
184 this._containerElement.addEventListener("scroll", this._onScroll.bind(th is), false);
185
186 // Create records list in the records sidebar.
187 recordsView.sidebarElement().classList.add("vbox");
188 recordsView.sidebarElement().createChild("div", "timeline-records-title" ).textContent = WebInspector.UIString("RECORDS");
189 this._sidebarListElement = recordsView.sidebarElement().createChild("div ", "timeline-records-list");
190
191 // Create grid in the records main area.
192 this._gridContainer = new WebInspector.ViewWithResizeCallback(this._onVi ewportResize.bind(this));
193 this._gridContainer.element.classList.add("fill");
194 this._gridContainer.element.id = "resources-container-content";
195 recordsView.setMainView(this._gridContainer);
196 this._timelineGrid = new WebInspector.TimelineGrid();
197 this._itemsGraphsElement = this._timelineGrid.itemsGraphsElement;
198 this._itemsGraphsElement.id = "timeline-graphs";
199 this._gridContainer.element.appendChild(this._timelineGrid.element);
200 this._timelineGrid.gridHeaderElement.id = "timeline-grid-header";
201 this._timelineGrid.gridHeaderElement.classList.add("fill");
202
203 // Create gap elements
204 this._topGapElement = this._itemsGraphsElement.createChild("div", "timel ine-gap");
205 this._graphRowsElement = this._itemsGraphsElement.createChild("div");
206 this._bottomGapElement = this._itemsGraphsElement.createChild("div", "ti meline-gap");
207 this._expandElements = this._itemsGraphsElement.createChild("div");
208 this._expandElements.id = "orphan-expand-elements";
209
210 // Create gpu tasks containers.
211 /** @type {!Array.<!TimelineAgent.TimelineEvent>} */
212 this._mainThreadTasks = ([]);
213 /** @type {!Array.<!TimelineAgent.TimelineEvent>} */
214 this._gpuTasks = ([]);
215 var utilizationStripsElement = this._timelineGrid.gridHeaderElement.crea teChild("div", "timeline-utilization-strips vbox");
216 this._cpuBarsElement = utilizationStripsElement.createChild("div", "time line-utilization-strip");
217 if (WebInspector.experimentsSettings.gpuTimeline.isEnabled())
218 this._gpuBarsElement = utilizationStripsElement.createChild("div", " timeline-utilization-strip gpu");
219
220 return recordsView;
221 },
222
223 /**
223 * @return {!WebInspector.SearchableView} 224 * @return {!WebInspector.SearchableView}
224 */ 225 */
225 searchableView: function() 226 searchableView: function()
226 { 227 {
227 return this._searchableView; 228 return this._searchableView;
228 }, 229 },
229 230
230 /** 231 /**
231 * @return {boolean} 232 * @return {boolean}
232 */ 233 */
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 _onViewportResize: function() 542 _onViewportResize: function()
542 { 543 {
543 this._resize(this._recordsView.sidebarWidth()); 544 this._resize(this._recordsView.sidebarWidth());
544 }, 545 },
545 546
546 /** 547 /**
547 * @param {number} sidebarWidth 548 * @param {number} sidebarWidth
548 */ 549 */
549 _resize: function(sidebarWidth) 550 _resize: function(sidebarWidth)
550 { 551 {
551 this._closeRecordDetails();
552 this._graphRowsElementWidth = this._graphRowsElement.offsetWidth; 552 this._graphRowsElementWidth = this._graphRowsElement.offsetWidth;
553 this._containerElementHeight = this._containerElement.clientHeight; 553 this._containerElementHeight = this._containerElement.clientHeight;
554 this._timelineGrid.gridHeaderElement.style.width = this._itemsGraphsElem ent.offsetWidth + "px"; 554 this._timelineGrid.gridHeaderElement.style.width = this._itemsGraphsElem ent.offsetWidth + "px";
555 this._scheduleRefresh(false, true); 555 this._scheduleRefresh(false, true);
556 }, 556 },
557 557
558 _resetView: function() 558 _resetView: function()
559 { 559 {
560 this._presentationModel.reset(); 560 this._presentationModel.reset();
561 this._boundariesAreValid = false; 561 this._boundariesAreValid = false;
562 this._adjustScrollPosition(0); 562 this._adjustScrollPosition(0);
563 this._closeRecordDetails();
564 this._allRecordsCount = 0; 563 this._allRecordsCount = 0;
565 this._automaticallySizeWindow = true; 564 this._automaticallySizeWindow = true;
566 this._mainThreadTasks = []; 565 this._mainThreadTasks = [];
567 this._gpuTasks = []; 566 this._gpuTasks = [];
568 }, 567 },
569 568
570 _onRecordsCleared: function() 569 _onRecordsCleared: function()
571 { 570 {
572 this._windowStartTime = 0; 571 this._windowStartTime = 0;
573 this._windowEndTime = Infinity; 572 this._windowEndTime = Infinity;
(...skipping 24 matching lines...) Expand all
598 if (!WebInspector.TimelinePanel._categoryStylesInitialized) { 597 if (!WebInspector.TimelinePanel._categoryStylesInitialized) {
599 WebInspector.TimelinePanel._categoryStylesInitialized = true; 598 WebInspector.TimelinePanel._categoryStylesInitialized = true;
600 this._injectCategoryStyles(); 599 this._injectCategoryStyles();
601 } 600 }
602 this._onViewportResize(); 601 this._onViewportResize();
603 this._refresh(); 602 this._refresh();
604 }, 603 },
605 604
606 willHide: function() 605 willHide: function()
607 { 606 {
608 this._closeRecordDetails();
609 WebInspector.View.prototype.willHide.call(this); 607 WebInspector.View.prototype.willHide.call(this);
610 }, 608 },
611 609
612 _onScroll: function(event) 610 _onScroll: function(event)
613 { 611 {
614 this._closeRecordDetails();
615 this._scrollTop = this._containerElement.scrollTop; 612 this._scrollTop = this._containerElement.scrollTop;
616 var dividersTop = Math.max(0, this._scrollTop); 613 var dividersTop = Math.max(0, this._scrollTop);
617 this._timelineGrid.setScrollAndDividerTop(this._scrollTop, dividersTop); 614 this._timelineGrid.setScrollAndDividerTop(this._scrollTop, dividersTop);
618 this._scheduleRefresh(true, true); 615 this._scheduleRefresh(true, true);
619 }, 616 },
620 617
621 /** 618 /**
622 * @param {boolean} preserveBoundaries 619 * @param {boolean} preserveBoundaries
623 * @param {boolean} userGesture 620 * @param {boolean} userGesture
624 */ 621 */
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 this._invalidateAndScheduleRefresh(false, true); 751 this._invalidateAndScheduleRefresh(false, true);
755 this._selectRecord(null); 752 this._selectRecord(null);
756 }, 753 },
757 754
758 /** 755 /**
759 * @param {boolean} preserveBoundaries 756 * @param {boolean} preserveBoundaries
760 * @param {boolean} userGesture 757 * @param {boolean} userGesture
761 */ 758 */
762 _scheduleRefresh: function(preserveBoundaries, userGesture) 759 _scheduleRefresh: function(preserveBoundaries, userGesture)
763 { 760 {
764 this._closeRecordDetails();
765 this._boundariesAreValid &= preserveBoundaries; 761 this._boundariesAreValid &= preserveBoundaries;
766 762
767 if (!this.isShowing()) 763 if (!this.isShowing())
768 return; 764 return;
769 765
770 if (preserveBoundaries || userGesture) 766 if (preserveBoundaries || userGesture)
771 this._refresh(); 767 this._refresh();
772 else { 768 else {
773 if (!this._refreshTimeout) 769 if (!this._refreshTimeout)
774 this._refreshTimeout = setTimeout(this._refresh.bind(this), 300) ; 770 this._refreshTimeout = setTimeout(this._refresh.bind(this), 300) ;
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 else if (anchor._tasksInfo) 1201 else if (anchor._tasksInfo)
1206 popover.show(this._presentationModel.generateMainThreadBarPopupC ontent(anchor._tasksInfo), anchor, null, null, WebInspector.Popover.Orientation. Bottom); 1202 popover.show(this._presentationModel.generateMainThreadBarPopupC ontent(anchor._tasksInfo), anchor, null, null, WebInspector.Popover.Orientation. Bottom);
1207 } 1203 }
1208 1204
1209 function showCallback(popupContent) 1205 function showCallback(popupContent)
1210 { 1206 {
1211 popover.show(popupContent, anchor); 1207 popover.show(popupContent, anchor);
1212 } 1208 }
1213 }, 1209 },
1214 1210
1215 _closeRecordDetails: function()
pfeldman 2014/01/15 11:44:37 Why did this go?
1216 {
1217 this._popoverHelper.hidePopover();
1218 },
1219
1220 _injectCategoryStyles: function() 1211 _injectCategoryStyles: function()
1221 { 1212 {
1222 var style = document.createElement("style"); 1213 var style = document.createElement("style");
1223 var categories = WebInspector.TimelinePresentationModel.categories(); 1214 var categories = WebInspector.TimelinePresentationModel.categories();
1224 1215
1225 style.textContent = Object.values(categories).map(WebInspector.TimelineP resentationModel.createStyleRuleForCategory).join("\n"); 1216 style.textContent = Object.values(categories).map(WebInspector.TimelineP resentationModel.createStyleRuleForCategory).join("\n");
1226 document.head.appendChild(style); 1217 document.head.appendChild(style);
1227 }, 1218 },
1228 1219
1229 jumpToNextSearchResult: function() 1220 jumpToNextSearchResult: function()
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 * @param {boolean} vertical 1876 * @param {boolean} vertical
1886 */ 1877 */
1887 setVertical: function(vertical) 1878 setVertical: function(vertical)
1888 { 1879 {
1889 this._contentElement.enableStyleClass("hbox", !vertical); 1880 this._contentElement.enableStyleClass("hbox", !vertical);
1890 this._contentElement.enableStyleClass("vbox", vertical); 1881 this._contentElement.enableStyleClass("vbox", vertical);
1891 }, 1882 },
1892 1883
1893 __proto__: WebInspector.View.prototype 1884 __proto__: WebInspector.View.prototype
1894 } 1885 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698