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

Unified Diff: Source/devtools/front_end/TimelineView.js

Issue 180273023: DevTools: encapsulate presentation model in timeline view. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/TimelineView.js
diff --git a/Source/devtools/front_end/TimelineView.js b/Source/devtools/front_end/TimelineView.js
index f35382ad3495cb69aacb2aa5009fc0aa23992621..a7cc3114987de08d4f80e5ad0ab6a7042d12d7f1 100644
--- a/Source/devtools/front_end/TimelineView.js
+++ b/Source/devtools/front_end/TimelineView.js
@@ -35,10 +35,8 @@
* @implements {WebInspector.TimelineModeView}
* @param {!WebInspector.TimelineModeViewDelegate} delegate
* @param {!WebInspector.TimelineModel} model
- * @param {!WebInspector.TimelinePresentationModel} presentationModel
- * @param {?WebInspector.TimelineFrameModel} frameModel
*/
-WebInspector.TimelineView = function(delegate, model, presentationModel, frameModel)
+WebInspector.TimelineView = function(delegate, model)
{
WebInspector.View.call(this);
this.element.classList.add("timeline-view");
@@ -46,8 +44,7 @@ WebInspector.TimelineView = function(delegate, model, presentationModel, frameMo
this._delegate = delegate;
this._model = model;
- this._presentationModel = presentationModel;
- this._frameModel = frameModel;
+ this._presentationModel = new WebInspector.TimelinePresentationModel(model, delegate);
caseq 2014/03/04 15:47:49 drop delegagte
pfeldman 2014/03/04 16:01:29 Done.
this._calculator = new WebInspector.TimelineCalculator(model);
this._linkifier = new WebInspector.Linkifier();
@@ -70,6 +67,14 @@ WebInspector.TimelineView = function(delegate, model, presentationModel, frameMo
WebInspector.TimelineView.prototype = {
/**
+ * @param {?WebInspector.TimelineFrameModel} frameModel
+ */
+ setFrameModel: function(frameModel)
+ {
+ this._frameModel = frameModel;
+ },
+
+ /**
* @return {!WebInspector.SplitView}
*/
_createRecordsView: function()
@@ -121,7 +126,7 @@ WebInspector.TimelineView.prototype = {
this._timelineGrid.removeEventDividers();
var clientWidth = this._graphRowsElementWidth;
var dividers = [];
- var eventDividerRecords = this._presentationModel.eventDividerRecords();
+ var eventDividerRecords = this._model.eventDividerRecords();
for (var i = 0; i < eventDividerRecords.length; ++i) {
var record = eventDividerRecords[i];
@@ -194,27 +199,8 @@ WebInspector.TimelineView.prototype = {
*/
addRecord: function(record)
{
- if (this._innerAddRecordToTimeline(record))
- this._invalidateAndScheduleRefresh(false, false);
- },
-
- /**
- * @param {!WebInspector.TimelineModel.Record} record
- * @return {boolean}
- */
- _innerAddRecordToTimeline: function(record)
- {
- if (record.type === WebInspector.TimelineModel.RecordType.GPUTask)
- return record.startTime < this._windowEndTime;
-
- var hasVisibleRecords = false;
- var presentationModel = this._presentationModel;
- function checkVisible(record)
- {
- hasVisibleRecords |= presentationModel.isVisible(record);
- }
- WebInspector.TimelineModel.forAllRecords([record], checkVisible);
- return hasVisibleRecords;
+ this._presentationModel.addRecord(record);
+ this._invalidateAndScheduleRefresh(false, false);
},
/**
@@ -260,6 +246,7 @@ WebInspector.TimelineView.prototype = {
this._linkifier.reset();
this._closeRecordDetails();
this._automaticallySizeWindow = true;
+ this._presentationModel.reset();
},
reset: function()
@@ -276,9 +263,13 @@ WebInspector.TimelineView.prototype = {
return [this._containerElement];
},
- refreshRecords: function()
+ /**
+ * @param {?RegExp} textFilter
+ */
+ refreshRecords: function(textFilter)
{
this._automaticallySizeWindow = false;
+ this._presentationModel.setTextFilter(textFilter);
this._invalidateAndScheduleRefresh(false, true);
},
@@ -456,7 +447,6 @@ WebInspector.TimelineView.prototype = {
for (var parent = recordToReveal.presentationParent(); parent !== this._rootRecord(); parent = parent.presentationParent()) {
if (!parent.collapsed())
continue;
- this._presentationModel.invalidateFilteredRecords();
caseq 2014/03/04 15:47:49 Why is this gone?
pfeldman 2014/03/04 16:01:29 Done.
parent.setCollapsed(false);
needRefresh = true;
}
@@ -493,7 +483,7 @@ WebInspector.TimelineView.prototype = {
this._automaticallySizeWindow = false;
this._selectRecord(null);
// If we're at the top, always use real timeline start as a left window bound so that expansion arrow padding logic works.
- var windowStartTime = startIndex ? recordsInWindow[startIndex].record().startTime : this._presentationModel.minimumRecordTime();
+ var windowStartTime = startIndex ? recordsInWindow[startIndex].record().startTime : this._model.minimumRecordTime();
var windowEndTime = recordsInWindow[Math.max(0, lastVisibleLine - 1)].record().endTime;
this._delegate.requestWindowTimes(windowStartTime, windowEndTime);
recordsInWindow = this._presentationModel.filteredRecords();
@@ -574,9 +564,9 @@ WebInspector.TimelineView.prototype = {
_refreshAllUtilizationBars: function()
{
- this._refreshUtilizationBars(WebInspector.UIString("CPU"), this._presentationModel.mainThreadTasks(), this._cpuBarsElement);
+ this._refreshUtilizationBars(WebInspector.UIString("CPU"), this._model.mainThreadTasks(), this._cpuBarsElement);
if (WebInspector.experimentsSettings.gpuTimeline.isEnabled())
- this._refreshUtilizationBars(WebInspector.UIString("GPU"), this._presentationModel.gpuThreadTasks(), this._gpuBarsElement);
+ this._refreshUtilizationBars(WebInspector.UIString("GPU"), this._model.gpuThreadTasks(), this._gpuBarsElement);
},
/**
@@ -721,11 +711,10 @@ WebInspector.TimelineView.prototype = {
switch (event.keyIdentifier) {
case "Left":
if (record.presentationParent()) {
- if ((!record.expandable() || record.collapsed()) && record.presentationParent() !== this._presentationModel.rootRecord()) {
+ if ((!record.hasPresentationChildren() || record.collapsed()) && record.presentationParent() !== this._presentationModel.rootRecord()) {
caseq 2014/03/04 15:47:49 This seems to be different from the old logic.
pfeldman 2014/03/04 16:01:29 Done.
this._selectRecord(record.presentationParent());
} else {
record.setCollapsed(true);
- record.clicked = true;
this._invalidateAndScheduleRefresh(true, true);
}
}
@@ -738,9 +727,8 @@ WebInspector.TimelineView.prototype = {
event.consume(true);
break;
case "Right":
- if (record.expandable() && record.collapsed()) {
+ if (record.hasPresentationChildren() && record.collapsed()) {
caseq 2014/03/04 15:47:49 ditto
pfeldman 2014/03/04 16:01:29 Done.
record.setCollapsed(false);
- record.clicked = true;
this._invalidateAndScheduleRefresh(true, true);
} else {
if (++index >= recordsInWindow.length)
@@ -1054,7 +1042,7 @@ WebInspector.TimelineRecordListRow.prototype = {
}
this._expandArrowElement.enableStyleClass("parent", presentationRecord.hasPresentationChildren());
- this._expandArrowElement.enableStyleClass("expanded", presentationRecord.visibleChildrenCount());
+ this._expandArrowElement.enableStyleClass("expanded", !!presentationRecord.visibleChildrenCount());
this._record.setListRow(this);
},
@@ -1076,7 +1064,6 @@ WebInspector.TimelineRecordListRow.prototype = {
_onExpandClick: function(event)
{
this._record.setCollapsed(!this._record.collapsed());
- this._record.clicked = true;
this._scheduleRefresh();
event.consume(true);
},
@@ -1204,7 +1191,6 @@ WebInspector.TimelineRecordGraphRow.prototype = {
_expand: function()
{
this._record.setCollapsed(!this._record.collapsed());
- this._record.clicked = true;
this._scheduleRefresh();
},

Powered by Google App Engine
This is Rietveld 408576698