OLD | NEW |
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 17 matching lines...) Expand all Loading... |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 /** | 32 /** |
33 * @constructor | 33 * @constructor |
34 * @extends {WebInspector.HBox} | 34 * @extends {WebInspector.HBox} |
35 * @implements {WebInspector.TimelineModeView} | 35 * @implements {WebInspector.TimelineModeView} |
36 * @param {!WebInspector.TimelineModeViewDelegate} delegate | 36 * @param {!WebInspector.TimelineModeViewDelegate} delegate |
37 * @param {!WebInspector.TimelineModel} model | 37 * @param {!WebInspector.TimelineModel} model |
38 * @param {!WebInspector.TimelineUIUtils} uiUtils | |
39 */ | 38 */ |
40 WebInspector.TimelineView = function(delegate, model, uiUtils) | 39 WebInspector.TimelineView = function(delegate, model) |
41 { | 40 { |
42 WebInspector.HBox.call(this); | 41 WebInspector.HBox.call(this); |
43 this.element.classList.add("timeline-view"); | 42 this.element.classList.add("timeline-view"); |
44 | 43 |
45 this._delegate = delegate; | 44 this._delegate = delegate; |
46 this._model = model; | 45 this._model = model; |
47 this._uiUtils = uiUtils; | 46 this._presentationModel = new WebInspector.TimelinePresentationModel(model); |
48 this._presentationModel = new WebInspector.TimelinePresentationModel(model,
uiUtils); | |
49 this._calculator = new WebInspector.TimelineCalculator(model); | 47 this._calculator = new WebInspector.TimelineCalculator(model); |
50 this._linkifier = new WebInspector.Linkifier(); | 48 this._linkifier = new WebInspector.Linkifier(); |
51 this._frameStripByFrame = new Map(); | 49 this._frameStripByFrame = new Map(); |
52 | 50 |
53 this._boundariesAreValid = true; | 51 this._boundariesAreValid = true; |
54 this._scrollTop = 0; | 52 this._scrollTop = 0; |
55 | 53 |
56 this._recordsView = this._createRecordsView(); | 54 this._recordsView = this._createRecordsView(); |
57 this._recordsView.addEventListener(WebInspector.SplitView.Events.SidebarSize
Changed, this._sidebarResized, this); | 55 this._recordsView.addEventListener(WebInspector.SplitView.Events.SidebarSize
Changed, this._sidebarResized, this); |
58 this._recordsView.show(this.element); | 56 this._recordsView.show(this.element); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 var clientWidth = this._graphRowsElementWidth; | 126 var clientWidth = this._graphRowsElementWidth; |
129 var dividers = []; | 127 var dividers = []; |
130 var eventDividerRecords = this._model.eventDividerRecords(); | 128 var eventDividerRecords = this._model.eventDividerRecords(); |
131 | 129 |
132 for (var i = 0; i < eventDividerRecords.length; ++i) { | 130 for (var i = 0; i < eventDividerRecords.length; ++i) { |
133 var record = eventDividerRecords[i]; | 131 var record = eventDividerRecords[i]; |
134 var position = this._calculator.computePosition(record.startTime()); | 132 var position = this._calculator.computePosition(record.startTime()); |
135 var dividerPosition = Math.round(position); | 133 var dividerPosition = Math.round(position); |
136 if (dividerPosition < 0 || dividerPosition >= clientWidth || divider
s[dividerPosition]) | 134 if (dividerPosition < 0 || dividerPosition >= clientWidth || divider
s[dividerPosition]) |
137 continue; | 135 continue; |
138 var title = this._uiUtils.titleForRecord(record); | 136 var title = WebInspector.TimelineUIUtils.titleForRecord(record); |
139 var divider = this._uiUtils.createEventDivider(record.type(), title)
; | 137 var divider = WebInspector.TimelineUIUtils.createEventDivider(record
.type(), title); |
140 divider.style.left = dividerPosition + "px"; | 138 divider.style.left = dividerPosition + "px"; |
141 dividers[dividerPosition] = divider; | 139 dividers[dividerPosition] = divider; |
142 } | 140 } |
143 this._timelineGrid.addEventDividers(dividers); | 141 this._timelineGrid.addEventDividers(dividers); |
144 }, | 142 }, |
145 | 143 |
146 _updateFrameBars: function(frames) | 144 _updateFrameBars: function(frames) |
147 { | 145 { |
148 var clientWidth = this._graphRowsElementWidth; | 146 var clientWidth = this._graphRowsElementWidth; |
149 if (this._frameContainer) { | 147 if (this._frameContainer) { |
(...skipping 22 matching lines...) Expand all Loading... |
172 frameStrip._frame = frame; | 170 frameStrip._frame = frame; |
173 this._frameStripByFrame.set(frame, frameStrip); | 171 this._frameStripByFrame.set(frame, frameStrip); |
174 | 172 |
175 const minWidthForFrameInfo = 60; | 173 const minWidthForFrameInfo = 60; |
176 if (width > minWidthForFrameInfo) | 174 if (width > minWidthForFrameInfo) |
177 frameStrip.textContent = Number.millisToString(frame.endTime - f
rame.startTime, true); | 175 frameStrip.textContent = Number.millisToString(frame.endTime - f
rame.startTime, true); |
178 | 176 |
179 this._frameContainer.appendChild(frameStrip); | 177 this._frameContainer.appendChild(frameStrip); |
180 | 178 |
181 if (actualStart > 0) { | 179 if (actualStart > 0) { |
182 var frameMarker = this._uiUtils.createBeginFrameDivider(); | 180 var frameMarker = WebInspector.TimelineUIUtils.createEventDivide
r(WebInspector.TracingTimelineModel.RecordType.BeginFrame); |
183 frameMarker.style.left = frameStart + "px"; | 181 frameMarker.style.left = frameStart + "px"; |
184 dividers.push(frameMarker); | 182 dividers.push(frameMarker); |
185 } | 183 } |
186 } | 184 } |
187 this._timelineGrid.addEventDividers(dividers); | 185 this._timelineGrid.addEventDividers(dividers); |
188 this._headerElement.appendChild(this._frameContainer); | 186 this._headerElement.appendChild(this._frameContainer); |
189 }, | 187 }, |
190 | 188 |
191 _onFrameDoubleClicked: function(event) | 189 _onFrameDoubleClicked: function(event) |
192 { | 190 { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 * @param {?WebInspector.TimelinePresentationModel.Record} presentationRecor
d | 324 * @param {?WebInspector.TimelinePresentationModel.Record} presentationRecor
d |
327 */ | 325 */ |
328 _selectRecord: function(presentationRecord) | 326 _selectRecord: function(presentationRecord) |
329 { | 327 { |
330 if (presentationRecord.coalesced()) { | 328 if (presentationRecord.coalesced()) { |
331 // Presentation record does not have model record to highlight. | 329 // Presentation record does not have model record to highlight. |
332 this._innerSetSelectedRecord(presentationRecord); | 330 this._innerSetSelectedRecord(presentationRecord); |
333 var aggregatedStats = {}; | 331 var aggregatedStats = {}; |
334 var presentationChildren = presentationRecord.presentationChildren()
; | 332 var presentationChildren = presentationRecord.presentationChildren()
; |
335 for (var i = 0; i < presentationChildren.length; ++i) | 333 for (var i = 0; i < presentationChildren.length; ++i) |
336 this._uiUtils.aggregateTimeForRecord(aggregatedStats, presentati
onChildren[i].record()); | 334 WebInspector.TimelineUIUtils.aggregateTimeForRecord(aggregatedSt
ats, presentationChildren[i].record()); |
337 var idle = presentationRecord.endTime() - presentationRecord.startTi
me(); | 335 var idle = presentationRecord.endTime() - presentationRecord.startTi
me(); |
338 for (var category in aggregatedStats) | 336 for (var category in aggregatedStats) |
339 idle -= aggregatedStats[category]; | 337 idle -= aggregatedStats[category]; |
340 aggregatedStats["idle"] = idle; | 338 aggregatedStats["idle"] = idle; |
341 | 339 |
342 var contentHelper = new WebInspector.TimelineDetailsContentHelper(nu
ll, null, true); | 340 var contentHelper = new WebInspector.TimelineDetailsContentHelper(nu
ll, null, true); |
343 var pieChart = WebInspector.TimelineUIUtils.generatePieChart(aggrega
tedStats); | 341 var pieChart = WebInspector.TimelineUIUtils.generatePieChart(aggrega
tedStats); |
344 var title = this._uiUtils.titleForRecord(presentationRecord.record()
); | 342 var title = WebInspector.TimelineUIUtils.titleForRecord(presentation
Record.record()); |
345 contentHelper.appendTextRow(WebInspector.UIString("Type"), title); | 343 contentHelper.appendTextRow(WebInspector.UIString("Type"), title); |
346 contentHelper.appendElementRow(WebInspector.UIString("Aggregated Tim
e"), pieChart); | 344 contentHelper.appendElementRow(WebInspector.UIString("Aggregated Tim
e"), pieChart); |
347 this._delegate.showInDetails(contentHelper.element); | 345 this._delegate.showInDetails(contentHelper.element); |
348 return; | 346 return; |
349 } | 347 } |
350 this._delegate.select(WebInspector.TimelineSelection.fromRecord(presenta
tionRecord.record())); | 348 this._delegate.select(WebInspector.TimelineSelection.fromRecord(presenta
tionRecord.record())); |
351 }, | 349 }, |
352 | 350 |
353 /** | 351 /** |
354 * @param {?WebInspector.TimelineSelection} selection | 352 * @param {?WebInspector.TimelineSelection} selection |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 } else { | 568 } else { |
571 if (!listRowElement) { | 569 if (!listRowElement) { |
572 listRowElement = new WebInspector.TimelineRecordListRow(this
._linkifier, selectRecordCallback, scheduleRefreshCallback).element; | 570 listRowElement = new WebInspector.TimelineRecordListRow(this
._linkifier, selectRecordCallback, scheduleRefreshCallback).element; |
573 this._sidebarListElement.appendChild(listRowElement); | 571 this._sidebarListElement.appendChild(listRowElement); |
574 } | 572 } |
575 if (!graphRowElement) { | 573 if (!graphRowElement) { |
576 graphRowElement = new WebInspector.TimelineRecordGraphRow(th
is._itemsGraphsElement, selectRecordCallback, scheduleRefreshCallback).element; | 574 graphRowElement = new WebInspector.TimelineRecordGraphRow(th
is._itemsGraphsElement, selectRecordCallback, scheduleRefreshCallback).element; |
577 this._graphRowsElement.appendChild(graphRowElement); | 575 this._graphRowsElement.appendChild(graphRowElement); |
578 } | 576 } |
579 | 577 |
580 listRowElement.row.update(record, visibleTop, this._uiUtils); | 578 listRowElement.row.update(record, visibleTop); |
581 graphRowElement.row.update(record, this._calculator, this._expan
dOffset, i, this._uiUtils); | 579 graphRowElement.row.update(record, this._calculator, this._expan
dOffset, i); |
582 if (this._lastSelectedRecord === record) { | 580 if (this._lastSelectedRecord === record) { |
583 listRowElement.row.renderAsSelected(true); | 581 listRowElement.row.renderAsSelected(true); |
584 graphRowElement.row.renderAsSelected(true); | 582 graphRowElement.row.renderAsSelected(true); |
585 } | 583 } |
586 | 584 |
587 listRowElement = listRowElement.nextSibling; | 585 listRowElement = listRowElement.nextSibling; |
588 graphRowElement = graphRowElement.nextSibling; | 586 graphRowElement = graphRowElement.nextSibling; |
589 } | 587 } |
590 } | 588 } |
591 | 589 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 { | 824 { |
827 if (!rowElement || !rowElement.row) | 825 if (!rowElement || !rowElement.row) |
828 return false; | 826 return false; |
829 var presentationRecord = rowElement.row._record; | 827 var presentationRecord = rowElement.row._record; |
830 if (presentationRecord.coalesced()) | 828 if (presentationRecord.coalesced()) |
831 return false; | 829 return false; |
832 var record = presentationRecord.record(); | 830 var record = presentationRecord.record(); |
833 if (this._highlightedQuadRecord === record) | 831 if (this._highlightedQuadRecord === record) |
834 return true; | 832 return true; |
835 | 833 |
836 var quad = this._uiUtils.highlightQuadForRecord(record); | 834 var quad = record.traceEvent().highlightQuad; |
837 var target = record.target(); | 835 var target = record.target(); |
838 if (!quad || !target) | 836 if (!quad || !target) |
839 return false; | 837 return false; |
840 this._highlightedQuadRecord = record; | 838 this._highlightedQuadRecord = record; |
841 target.domAgent().highlightQuad(quad, WebInspector.Color.PageHighlight.C
ontent.toProtocolRGBA(), WebInspector.Color.PageHighlight.ContentOutline.toProto
colRGBA()); | 839 target.domAgent().highlightQuad(quad, WebInspector.Color.PageHighlight.C
ontent.toProtocolRGBA(), WebInspector.Color.PageHighlight.ContentOutline.toProto
colRGBA()); |
842 return true; | 840 return true; |
843 }, | 841 }, |
844 | 842 |
845 _hideQuadHighlight: function() | 843 _hideQuadHighlight: function() |
846 { | 844 { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 | 1041 |
1044 this._dataElement = this.element.createChild("span", "data dimmed"); | 1042 this._dataElement = this.element.createChild("span", "data dimmed"); |
1045 this._scheduleRefresh = scheduleRefresh; | 1043 this._scheduleRefresh = scheduleRefresh; |
1046 this._selectRecord = selectRecord; | 1044 this._selectRecord = selectRecord; |
1047 } | 1045 } |
1048 | 1046 |
1049 WebInspector.TimelineRecordListRow.prototype = { | 1047 WebInspector.TimelineRecordListRow.prototype = { |
1050 /** | 1048 /** |
1051 * @param {!WebInspector.TimelinePresentationModel.Record} presentationRecor
d | 1049 * @param {!WebInspector.TimelinePresentationModel.Record} presentationRecor
d |
1052 * @param {number} offset | 1050 * @param {number} offset |
1053 * @param {!WebInspector.TimelineUIUtils} uiUtils | |
1054 */ | 1051 */ |
1055 update: function(presentationRecord, offset, uiUtils) | 1052 update: function(presentationRecord, offset) |
1056 { | 1053 { |
1057 this._record = presentationRecord; | 1054 this._record = presentationRecord; |
1058 var record = presentationRecord.record(); | 1055 var record = presentationRecord.record(); |
1059 this._offset = offset; | 1056 this._offset = offset; |
1060 | 1057 |
1061 this.element.className = "timeline-tree-item timeline-category-" + uiUti
ls.categoryForRecord(record).name; | 1058 this.element.className = "timeline-tree-item timeline-category-" + WebIn
spector.TimelineUIUtils.categoryForRecord(record).name; |
1062 var paddingLeft = 5; | 1059 var paddingLeft = 5; |
1063 var step = -3; | 1060 var step = -3; |
1064 for (var currentRecord = presentationRecord.presentationParent() ? prese
ntationRecord.presentationParent().presentationParent() : null; currentRecord; c
urrentRecord = currentRecord.presentationParent()) | 1061 for (var currentRecord = presentationRecord.presentationParent() ? prese
ntationRecord.presentationParent().presentationParent() : null; currentRecord; c
urrentRecord = currentRecord.presentationParent()) |
1065 paddingLeft += 12 / (Math.max(1, step++)); | 1062 paddingLeft += 12 / (Math.max(1, step++)); |
1066 this.element.style.paddingLeft = paddingLeft + "px"; | 1063 this.element.style.paddingLeft = paddingLeft + "px"; |
1067 if (record.thread() !== WebInspector.TimelineModel.MainThreadName) | 1064 if (record.thread() !== WebInspector.TimelineModel.MainThreadName) |
1068 this.element.classList.add("background"); | 1065 this.element.classList.add("background"); |
1069 | 1066 |
1070 this._typeElement.textContent = uiUtils.titleForRecord(record); | 1067 this._typeElement.textContent = WebInspector.TimelineUIUtils.titleForRec
ord(record); |
1071 | 1068 |
1072 if (this._dataElement.firstChild) | 1069 if (this._dataElement.firstChild) |
1073 this._dataElement.removeChildren(); | 1070 this._dataElement.removeChildren(); |
1074 | 1071 |
1075 this._warningElement.classList.toggle("hidden", !presentationRecord.hasW
arnings() && !presentationRecord.childHasWarnings()); | 1072 this._warningElement.classList.toggle("hidden", !presentationRecord.hasW
arnings() && !presentationRecord.childHasWarnings()); |
1076 this._warningElement.classList.toggle("timeline-tree-item-child-warning"
, presentationRecord.childHasWarnings() && !presentationRecord.hasWarnings()); | 1073 this._warningElement.classList.toggle("timeline-tree-item-child-warning"
, presentationRecord.childHasWarnings() && !presentationRecord.hasWarnings()); |
1077 | 1074 |
1078 if (presentationRecord.coalesced()) { | 1075 if (presentationRecord.coalesced()) { |
1079 this._dataElement.createTextChild(WebInspector.UIString("× %d", pres
entationRecord.presentationChildren().length)); | 1076 this._dataElement.createTextChild(WebInspector.UIString("× %d", pres
entationRecord.presentationChildren().length)); |
1080 } else { | 1077 } else { |
1081 var detailsNode = uiUtils.buildDetailsNode(record, this._linkifier); | 1078 var detailsNode = WebInspector.TimelineUIUtils.buildDetailsNodeForTr
aceEvent(record.traceEvent(), this._linkifier); |
1082 if (detailsNode) { | 1079 if (detailsNode) { |
1083 this._dataElement.createTextChild("("); | 1080 this._dataElement.createTextChild("("); |
1084 this._dataElement.appendChild(detailsNode); | 1081 this._dataElement.appendChild(detailsNode); |
1085 this._dataElement.createTextChild(")"); | 1082 this._dataElement.createTextChild(")"); |
1086 } | 1083 } |
1087 } | 1084 } |
1088 | 1085 |
1089 this._expandArrowElement.classList.toggle("parent", presentationRecord.e
xpandable()); | 1086 this._expandArrowElement.classList.toggle("parent", presentationRecord.e
xpandable()); |
1090 this._expandArrowElement.classList.toggle("expanded", !!presentationReco
rd.visibleChildrenCount()); | 1087 this._expandArrowElement.classList.toggle("expanded", !!presentationReco
rd.visibleChildrenCount()); |
1091 this._record.setListRow(this); | 1088 this._record.setListRow(this); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 this._selectRecord = selectRecord; | 1174 this._selectRecord = selectRecord; |
1178 this._scheduleRefresh = scheduleRefresh; | 1175 this._scheduleRefresh = scheduleRefresh; |
1179 } | 1176 } |
1180 | 1177 |
1181 WebInspector.TimelineRecordGraphRow.prototype = { | 1178 WebInspector.TimelineRecordGraphRow.prototype = { |
1182 /** | 1179 /** |
1183 * @param {!WebInspector.TimelinePresentationModel.Record} presentationRecor
d | 1180 * @param {!WebInspector.TimelinePresentationModel.Record} presentationRecor
d |
1184 * @param {!WebInspector.TimelineCalculator} calculator | 1181 * @param {!WebInspector.TimelineCalculator} calculator |
1185 * @param {number} expandOffset | 1182 * @param {number} expandOffset |
1186 * @param {number} index | 1183 * @param {number} index |
1187 * @param {!WebInspector.TimelineUIUtils} uiUtils | |
1188 */ | 1184 */ |
1189 update: function(presentationRecord, calculator, expandOffset, index, uiUtil
s) | 1185 update: function(presentationRecord, calculator, expandOffset, index) |
1190 { | 1186 { |
1191 this._record = presentationRecord; | 1187 this._record = presentationRecord; |
1192 var record = presentationRecord.record(); | 1188 var record = presentationRecord.record(); |
1193 this.element.className = "timeline-graph-side timeline-category-" + uiUt
ils.categoryForRecord(record).name; | 1189 this.element.className = "timeline-graph-side timeline-category-" + WebI
nspector.TimelineUIUtils.categoryForRecord(record).name; |
1194 if (record.thread() !== WebInspector.TimelineModel.MainThreadName) | 1190 if (record.thread() !== WebInspector.TimelineModel.MainThreadName) |
1195 this.element.classList.add("background"); | 1191 this.element.classList.add("background"); |
1196 | 1192 |
1197 var barPosition = calculator.computeBarGraphWindowPosition(presentationR
ecord); | 1193 var barPosition = calculator.computeBarGraphWindowPosition(presentationR
ecord); |
1198 this._barElement.style.left = barPosition.left + "px"; | 1194 this._barElement.style.left = barPosition.left + "px"; |
1199 this._barElement.style.width = barPosition.width + "px"; | 1195 this._barElement.style.width = barPosition.width + "px"; |
1200 this._barCpuElement.style.left = barPosition.left + "px"; | 1196 this._barCpuElement.style.left = barPosition.left + "px"; |
1201 this._barCpuElement.style.width = barPosition.cpuWidth + "px"; | 1197 this._barCpuElement.style.width = barPosition.cpuWidth + "px"; |
1202 this._expandElement._update(presentationRecord, index, barPosition.left
- expandOffset, barPosition.width); | 1198 this._expandElement._update(presentationRecord, index, barPosition.left
- expandOffset, barPosition.width); |
1203 this._record.setGraphRow(this); | 1199 this._record.setGraphRow(this); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 } else { | 1288 } else { |
1293 this._element.classList.add("hidden"); | 1289 this._element.classList.add("hidden"); |
1294 } | 1290 } |
1295 }, | 1291 }, |
1296 | 1292 |
1297 _dispose: function() | 1293 _dispose: function() |
1298 { | 1294 { |
1299 this._element.remove(); | 1295 this._element.remove(); |
1300 } | 1296 } |
1301 } | 1297 } |
OLD | NEW |