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

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

Issue 183893010: DevTools: extract TimelineModel.Record from TimelinePresentationModel.Record. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 var timeSpan = this._model.maximumRecordTime() - timeOffset; 68 var timeSpan = this._model.maximumRecordTime() - timeOffset;
69 var scale = this._canvas.width / timeSpan; 69 var scale = this._canvas.width / timeSpan;
70 70
71 var lastBarByGroup = []; 71 var lastBarByGroup = [];
72 72
73 this._context.fillStyle = "rgba(0, 0, 0, 0.05)"; 73 this._context.fillStyle = "rgba(0, 0, 0, 0.05)";
74 for (var i = 1; i < WebInspector.TimelineEventOverview._numberOfStrips; i += 2) 74 for (var i = 1; i < WebInspector.TimelineEventOverview._numberOfStrips; i += 2)
75 this._context.fillRect(0.5, i * stripHeight + 0.5, this._canvas.widt h, stripHeight); 75 this._context.fillRect(0.5, i * stripHeight + 0.5, this._canvas.widt h, stripHeight);
76 76
77 /** 77 /**
78 * @param {!WebInspector.TimelineModel.Record} record
78 * @this {WebInspector.TimelineEventOverview} 79 * @this {WebInspector.TimelineEventOverview}
79 */ 80 */
80 function appendRecord(record) 81 function appendRecord(record)
81 { 82 {
82 if (record.type === WebInspector.TimelineModel.RecordType.BeginFrame ) 83 if (record.type === WebInspector.TimelineModel.RecordType.BeginFrame )
83 return; 84 return;
84 var recordStart = Math.floor((record.startTime - timeOffset) * scale ); 85 var recordStart = Math.floor((record.startTime - timeOffset) * scale );
85 var recordEnd = Math.ceil((record.endTime - timeOffset) * scale); 86 var recordEnd = Math.ceil((record.endTime - timeOffset) * scale);
86 var category = WebInspector.TimelineUIUtils.categoryForRecord(record ); 87 var category = WebInspector.TimelineUIUtils.categoryForRecord(record );
87 if (category.overviewStripGroupIndex < 0) 88 if (category.overviewStripGroupIndex < 0)
88 return; 89 return;
89 var bar = lastBarByGroup[category.overviewStripGroupIndex]; 90 var bar = lastBarByGroup[category.overviewStripGroupIndex];
90 // This bar may be merged with previous -- so just adjust the previo us bar. 91 // This bar may be merged with previous -- so just adjust the previo us bar.
91 const barsMergeThreshold = 2; 92 const barsMergeThreshold = 2;
92 if (bar && bar.category === category && bar.end + barsMergeThreshold >= recordStart) { 93 if (bar && bar.category === category && bar.end + barsMergeThreshold >= recordStart) {
93 if (recordEnd > bar.end) 94 if (recordEnd > bar.end)
94 bar.end = recordEnd; 95 bar.end = recordEnd;
95 return; 96 return;
96 } 97 }
97 if (bar) 98 if (bar)
98 this._renderBar(bar.start, bar.end, stripHeight, bar.category); 99 this._renderBar(bar.start, bar.end, stripHeight, bar.category);
99 lastBarByGroup[category.overviewStripGroupIndex] = { start: recordSt art, end: recordEnd, category: category }; 100 lastBarByGroup[category.overviewStripGroupIndex] = { start: recordSt art, end: recordEnd, category: category };
100 } 101 }
101 WebInspector.TimelinePresentationModel.forAllRecords(this._model.records , appendRecord.bind(this)); 102 this._model.forAllRecords(appendRecord.bind(this));
102 for (var i = 0; i < lastBarByGroup.length; ++i) { 103 for (var i = 0; i < lastBarByGroup.length; ++i) {
103 if (lastBarByGroup[i]) 104 if (lastBarByGroup[i])
104 this._renderBar(lastBarByGroup[i].start, lastBarByGroup[i].end, stripHeight, lastBarByGroup[i].category); 105 this._renderBar(lastBarByGroup[i].start, lastBarByGroup[i].end, stripHeight, lastBarByGroup[i].category);
105 } 106 }
106 }, 107 },
107 108
108 _onCategoryVisibilityChanged: function() 109 _onCategoryVisibilityChanged: function()
109 { 110 {
110 this.update(); 111 this.update();
111 }, 112 },
(...skipping 18 matching lines...) Expand all
130 this._context.scale(1, innerStripHeight / WebInspector.TimelineEventOver view._stripGradientHeight); 131 this._context.scale(1, innerStripHeight / WebInspector.TimelineEventOver view._stripGradientHeight);
131 this._context.fillStyle = category.hidden ? this._disabledCategoryFillSt yle : this._fillStyles[category.name]; 132 this._context.fillStyle = category.hidden ? this._disabledCategoryFillSt yle : this._fillStyles[category.name];
132 this._context.fillRect(0, 0, width, WebInspector.TimelineEventOverview._ stripGradientHeight); 133 this._context.fillRect(0, 0, width, WebInspector.TimelineEventOverview._ stripGradientHeight);
133 this._context.strokeStyle = category.hidden ? this._disabledCategoryBord erStyle : category.borderColor; 134 this._context.strokeStyle = category.hidden ? this._disabledCategoryBord erStyle : category.borderColor;
134 this._context.strokeRect(0, 0, width, WebInspector.TimelineEventOverview ._stripGradientHeight); 135 this._context.strokeRect(0, 0, width, WebInspector.TimelineEventOverview ._stripGradientHeight);
135 this._context.restore(); 136 this._context.restore();
136 }, 137 },
137 138
138 __proto__: WebInspector.TimelineOverviewBase.prototype 139 __proto__: WebInspector.TimelineOverviewBase.prototype
139 } 140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698