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

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

Issue 337023004: Don't create TimelineModel.RecordImpl in TimelinePresentationModel.js (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 _updateEventDividers: function() 123 _updateEventDividers: function()
124 { 124 {
125 this._timelineGrid.removeEventDividers(); 125 this._timelineGrid.removeEventDividers();
126 var clientWidth = this._graphRowsElementWidth; 126 var clientWidth = this._graphRowsElementWidth;
127 var dividers = []; 127 var dividers = [];
128 var eventDividerRecords = this._model.eventDividerRecords(); 128 var eventDividerRecords = this._model.eventDividerRecords();
129 129
130 for (var i = 0; i < eventDividerRecords.length; ++i) { 130 for (var i = 0; i < eventDividerRecords.length; ++i) {
131 var record = eventDividerRecords[i]; 131 var record = eventDividerRecords[i];
132 var positions = this._calculator.computeBarGraphWindowPosition(recor d); 132 var position = this._calculator.computePosition(record.startTime());
133 var dividerPosition = Math.round(positions.left); 133 var dividerPosition = Math.round(position);
134 if (dividerPosition < 0 || dividerPosition >= clientWidth || divider s[dividerPosition]) 134 if (dividerPosition < 0 || dividerPosition >= clientWidth || divider s[dividerPosition])
135 continue; 135 continue;
136 var divider = WebInspector.TimelineUIUtils.createEventDivider(record .type(), WebInspector.TimelineUIUtils.recordTitle(record, this._model)); 136 var divider = WebInspector.TimelineUIUtils.createEventDivider(record .type(), WebInspector.TimelineUIUtils.recordTitle(record, this._model));
137 divider.style.left = dividerPosition + "px"; 137 divider.style.left = dividerPosition + "px";
138 dividers[dividerPosition] = divider; 138 dividers[dividerPosition] = divider;
139 } 139 }
140 this._timelineGrid.addEventDividers(dividers); 140 this._timelineGrid.addEventDividers(dividers);
141 }, 141 },
142 142
143 _updateFrameBars: function(frames) 143 _updateFrameBars: function(frames)
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 var headerHeight = WebInspector.TimelinePanel.headerHeight; 524 var headerHeight = WebInspector.TimelinePanel.headerHeight;
525 525
526 // Convert visible area to visible indexes. Always include top-level rec ord for a visible nested record. 526 // Convert visible area to visible indexes. Always include top-level rec ord for a visible nested record.
527 var startIndex = Math.max(0, Math.min(Math.floor((visibleTop - headerHei ght) / rowHeight), recordsInWindow.length - 1)); 527 var startIndex = Math.max(0, Math.min(Math.floor((visibleTop - headerHei ght) / rowHeight), recordsInWindow.length - 1));
528 var endIndex = Math.min(recordsInWindow.length, Math.ceil(visibleBottom / rowHeight)); 528 var endIndex = Math.min(recordsInWindow.length, Math.ceil(visibleBottom / rowHeight));
529 var lastVisibleLine = Math.max(0, Math.floor((visibleBottom - headerHeig ht) / rowHeight)); 529 var lastVisibleLine = Math.max(0, Math.floor((visibleBottom - headerHeig ht) / rowHeight));
530 if (this._automaticallySizeWindow && recordsInWindow.length > lastVisibl eLine) { 530 if (this._automaticallySizeWindow && recordsInWindow.length > lastVisibl eLine) {
531 this._automaticallySizeWindow = false; 531 this._automaticallySizeWindow = false;
532 this._clearSelection(); 532 this._clearSelection();
533 // If we're at the top, always use real timeline start as a left win dow bound so that expansion arrow padding logic works. 533 // If we're at the top, always use real timeline start as a left win dow bound so that expansion arrow padding logic works.
534 var windowStartTime = startIndex ? recordsInWindow[startIndex].recor d().startTime() : this._model.minimumRecordTime(); 534 var windowStartTime = startIndex ? recordsInWindow[startIndex].start Time() : this._model.minimumRecordTime();
535 var windowEndTime = recordsInWindow[Math.max(0, lastVisibleLine - 1) ].record().endTime(); 535 var windowEndTime = recordsInWindow[Math.max(0, lastVisibleLine - 1) ].endTime();
536 this._delegate.requestWindowTimes(windowStartTime, windowEndTime); 536 this._delegate.requestWindowTimes(windowStartTime, windowEndTime);
537 recordsInWindow = this._presentationModel.filteredRecords(); 537 recordsInWindow = this._presentationModel.filteredRecords();
538 endIndex = Math.min(recordsInWindow.length, lastVisibleLine); 538 endIndex = Math.min(recordsInWindow.length, lastVisibleLine);
539 } 539 }
540 540
541 // Resize gaps first. 541 // Resize gaps first.
542 this._topGapElement.style.height = (startIndex * rowHeight) + "px"; 542 this._topGapElement.style.height = (startIndex * rowHeight) + "px";
543 this._recordsView.sidebarElement().firstElementChild.style.flexBasis = ( startIndex * rowHeight + headerHeight) + "px"; 543 this._recordsView.sidebarElement().firstElementChild.style.flexBasis = ( startIndex * rowHeight + headerHeight) + "px";
544 this._bottomGapElement.style.height = (recordsInWindow.length - endIndex ) * rowHeight + "px"; 544 this._bottomGapElement.style.height = (recordsInWindow.length - endIndex ) * rowHeight + "px";
545 var rowsHeight = headerHeight + recordsInWindow.length * rowHeight; 545 var rowsHeight = headerHeight + recordsInWindow.length * rowHeight;
(...skipping 13 matching lines...) Expand all
559 this._itemsGraphsElement.removeChild(this._expandElements); 559 this._itemsGraphsElement.removeChild(this._expandElements);
560 this._expandElements.removeChildren(); 560 this._expandElements.removeChildren();
561 561
562 for (var i = 0; i < endIndex; ++i) { 562 for (var i = 0; i < endIndex; ++i) {
563 var record = recordsInWindow[i]; 563 var record = recordsInWindow[i];
564 564
565 if (i < startIndex) { 565 if (i < startIndex) {
566 var lastChildIndex = i + record.visibleChildrenCount(); 566 var lastChildIndex = i + record.visibleChildrenCount();
567 if (lastChildIndex >= startIndex && lastChildIndex < endIndex) { 567 if (lastChildIndex >= startIndex && lastChildIndex < endIndex) {
568 var expandElement = new WebInspector.TimelineExpandableEleme nt(this._expandElements); 568 var expandElement = new WebInspector.TimelineExpandableEleme nt(this._expandElements);
569 var positions = this._calculator.computeBarGraphWindowPositi on(record.record()); 569 var positions = this._calculator.computeBarGraphWindowPositi on(record);
570 expandElement._update(record, i, positions.left - this._expa ndOffset, positions.width); 570 expandElement._update(record, i, positions.left - this._expa ndOffset, positions.width);
571 } 571 }
572 } else { 572 } else {
573 if (!listRowElement) { 573 if (!listRowElement) {
574 listRowElement = new WebInspector.TimelineRecordListRow(this ._linkifier, selectRecordCallback, scheduleRefreshCallback).element; 574 listRowElement = new WebInspector.TimelineRecordListRow(this ._linkifier, selectRecordCallback, scheduleRefreshCallback).element;
575 this._sidebarListElement.appendChild(listRowElement); 575 this._sidebarListElement.appendChild(listRowElement);
576 } 576 }
577 if (!graphRowElement) { 577 if (!graphRowElement) {
578 graphRowElement = new WebInspector.TimelineRecordGraphRow(th is._itemsGraphsElement, selectRecordCallback, scheduleRefreshCallback).element; 578 graphRowElement = new WebInspector.TimelineRecordGraphRow(th is._itemsGraphsElement, selectRecordCallback, scheduleRefreshCallback).element;
579 this._graphRowsElement.appendChild(graphRowElement); 579 this._graphRowsElement.appendChild(graphRowElement);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 }, 817 },
818 818
819 /** 819 /**
820 * @param {?Element} rowElement 820 * @param {?Element} rowElement
821 * @return {boolean} 821 * @return {boolean}
822 */ 822 */
823 _highlightQuad: function(rowElement) 823 _highlightQuad: function(rowElement)
824 { 824 {
825 if (!rowElement || !rowElement.row) 825 if (!rowElement || !rowElement.row)
826 return false; 826 return false;
827 var record = rowElement.row._record.record(); 827 var presentationRecord = rowElement.row._record;
828 if (presentationRecord.collapsed())
829 return false;
830 var record = presentationRecord.record();
828 if (this._highlightedQuadRecord === record) 831 if (this._highlightedQuadRecord === record)
829 return true; 832 return true;
830 this._highlightedQuadRecord = record; 833 this._highlightedQuadRecord = record;
831 834
832 var quad = record.highlightQuad(); 835 var quad = record.highlightQuad();
833 if (!quad) 836 if (!quad)
834 return false; 837 return false;
835 record.target().domAgent().highlightQuad(quad, WebInspector.Color.PageHi ghlight.Content.toProtocolRGBA(), WebInspector.Color.PageHighlight.ContentOutlin e.toProtocolRGBA()); 838 record.target().domAgent().highlightQuad(quad, WebInspector.Color.PageHi ghlight.Content.toProtocolRGBA(), WebInspector.Color.PageHighlight.ContentOutlin e.toProtocolRGBA());
836 return true; 839 return true;
837 }, 840 },
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 /** 916 /**
914 * @param {number} time 917 * @param {number} time
915 * @return {number} 918 * @return {number}
916 */ 919 */
917 computePosition: function(time) 920 computePosition: function(time)
918 { 921 {
919 return (time - this._minimumBoundary) / this.boundarySpan() * this._work ingArea + this._paddingLeft; 922 return (time - this._minimumBoundary) / this.boundarySpan() * this._work ingArea + this._paddingLeft;
920 }, 923 },
921 924
922 /** 925 /**
923 * @param {!WebInspector.TimelineModel.Record} record 926 * @param {!WebInspector.TimelinePresentationModel.Record} record
924 * @return {!{start: number, end: number, cpuWidth: number}} 927 * @return {!{start: number, end: number, cpuWidth: number}}
925 */ 928 */
926 computeBarGraphPercentages: function(record) 929 computeBarGraphPercentages: function(record)
927 { 930 {
928 var start = (record.startTime() - this._minimumBoundary) / this.boundary Span() * 100; 931 var start = (record.startTime() - this._minimumBoundary) / this.boundary Span() * 100;
929 var end = (record.startTime() + record.selfTime() - this._minimumBoundar y) / this.boundarySpan() * 100; 932 var end = (record.startTime() + record.selfTime() - this._minimumBoundar y) / this.boundarySpan() * 100;
930 var cpuWidth = (record.endTime() - record.startTime()) / this.boundarySp an() * 100; 933 var cpuWidth = (record.endTime() - record.startTime()) / this.boundarySp an() * 100;
931 return {start: start, end: end, cpuWidth: cpuWidth}; 934 return {start: start, end: end, cpuWidth: cpuWidth};
932 }, 935 },
933 936
934 /** 937 /**
935 * @param {!WebInspector.TimelineModel.Record} record 938 * @param {!WebInspector.TimelinePresentationModel.Record} record
936 * @return {!{left: number, width: number, cpuWidth: number}} 939 * @return {!{left: number, width: number, cpuWidth: number}}
937 */ 940 */
938 computeBarGraphWindowPosition: function(record) 941 computeBarGraphWindowPosition: function(record)
939 { 942 {
940 var percentages = this.computeBarGraphPercentages(record); 943 var percentages = this.computeBarGraphPercentages(record);
941 var widthAdjustment = 0; 944 var widthAdjustment = 0;
942 945
943 var left = this.computePosition(record.startTime()); 946 var left = this.computePosition(record.startTime());
944 var width = (percentages.end - percentages.start) / 100 * this._workingA rea; 947 var width = (percentages.end - percentages.start) / 100 * this._workingA rea;
945 if (width < WebInspector.TimelineCalculator._minWidth) { 948 if (width < WebInspector.TimelineCalculator._minWidth) {
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 * @param {number} index 1189 * @param {number} index
1187 */ 1190 */
1188 update: function(presentationRecord, calculator, expandOffset, index) 1191 update: function(presentationRecord, calculator, expandOffset, index)
1189 { 1192 {
1190 this._record = presentationRecord; 1193 this._record = presentationRecord;
1191 var record = presentationRecord.record(); 1194 var record = presentationRecord.record();
1192 this.element.className = "timeline-graph-side timeline-category-" + reco rd.category().name; 1195 this.element.className = "timeline-graph-side timeline-category-" + reco rd.category().name;
1193 if (record.thread()) 1196 if (record.thread())
1194 this.element.classList.add("background"); 1197 this.element.classList.add("background");
1195 1198
1196 var barPosition = calculator.computeBarGraphWindowPosition(record); 1199 var barPosition = calculator.computeBarGraphWindowPosition(presentationR ecord);
1197 this._barElement.style.left = barPosition.left + "px"; 1200 this._barElement.style.left = barPosition.left + "px";
1198 this._barElement.style.width = barPosition.width + "px"; 1201 this._barElement.style.width = barPosition.width + "px";
1199 this._barCpuElement.style.left = barPosition.left + "px"; 1202 this._barCpuElement.style.left = barPosition.left + "px";
1200 this._barCpuElement.style.width = barPosition.cpuWidth + "px"; 1203 this._barCpuElement.style.width = barPosition.cpuWidth + "px";
1201 this._expandElement._update(presentationRecord, index, barPosition.left - expandOffset, barPosition.width); 1204 this._expandElement._update(presentationRecord, index, barPosition.left - expandOffset, barPosition.width);
1202 this._record.setGraphRow(this); 1205 this._record.setGraphRow(this);
1203 }, 1206 },
1204 1207
1205 /** 1208 /**
1206 * @param {?Event} event 1209 * @param {?Event} event
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 this._element.classList.remove("hidden"); 1293 this._element.classList.remove("hidden");
1291 } else 1294 } else
1292 this._element.classList.add("hidden"); 1295 this._element.classList.add("hidden");
1293 }, 1296 },
1294 1297
1295 _dispose: function() 1298 _dispose: function()
1296 { 1299 {
1297 this._element.remove(); 1300 this._element.remove();
1298 } 1301 }
1299 } 1302 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698