Commit d3f912b5 authored by yurys@chromium.org's avatar yurys@chromium.org

Remove title() from TimelineModel.Record

title is a presentation entity and shouldn't be exposed on model record. TimelineUIUtils should be used to retrieve it.

BUG=361045
R=loislo@chromium.org

Review URL: https://codereview.chromium.org/336183005

git-svn-id: svn://svn.chromium.org/blink/trunk@176503 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 9b86811c
...@@ -90,7 +90,8 @@ WebInspector.TimelineFlameChartDataProvider.prototype = { ...@@ -90,7 +90,8 @@ WebInspector.TimelineFlameChartDataProvider.prototype = {
else if (record === this._gpuThreadRecord) else if (record === this._gpuThreadRecord)
return WebInspector.UIString("GPU"); return WebInspector.UIString("GPU");
var details = WebInspector.TimelineUIUtilsImpl.buildDetailsNode(record, this._linkifier, this._model.loadedFromFile()); var details = WebInspector.TimelineUIUtilsImpl.buildDetailsNode(record, this._linkifier, this._model.loadedFromFile());
return details ? WebInspector.UIString("%s (%s)", record.title(), details.textContent) : record.title(); var title = WebInspector.TimelineUIUtilsImpl.recordTitle(record);
return details ? WebInspector.UIString("%s (%s)", title, details.textContent) : title;
}, },
/** /**
......
...@@ -370,11 +370,6 @@ WebInspector.TimelineModel.Record.prototype = { ...@@ -370,11 +370,6 @@ WebInspector.TimelineModel.Record.prototype = {
*/ */
category: function() { }, category: function() { },
/**
* @return {string}
*/
title: function() { },
/** /**
* @return {number} * @return {number}
*/ */
...@@ -435,13 +430,7 @@ WebInspector.TimelineModel.Record.prototype = { ...@@ -435,13 +430,7 @@ WebInspector.TimelineModel.Record.prototype = {
/** /**
* @return {?Array.<string>} * @return {?Array.<string>}
*/ */
warnings: function() { }, warnings: function() { }
/**
* @param {!RegExp} regExp
* @return {boolean}
*/
testContentMatching: function(regExp) { }
} }
/** /**
......
...@@ -423,14 +423,6 @@ WebInspector.TimelineModel.RecordImpl.prototype = { ...@@ -423,14 +423,6 @@ WebInspector.TimelineModel.RecordImpl.prototype = {
return WebInspector.TimelineUIUtils.recordStyle(this).category; return WebInspector.TimelineUIUtils.recordStyle(this).category;
}, },
/**
* @return {string}
*/
title: function()
{
return WebInspector.TimelineUIUtils.recordTitle(this, this._model);
},
/** /**
* @return {number} * @return {number}
*/ */
...@@ -555,19 +547,7 @@ WebInspector.TimelineModel.RecordImpl.prototype = { ...@@ -555,19 +547,7 @@ WebInspector.TimelineModel.RecordImpl.prototype = {
warnings: function() warnings: function()
{ {
return this._warnings; return this._warnings;
}, }
/**
* @param {!RegExp} regExp
* @return {boolean}
*/
testContentMatching: function(regExp)
{
var tokens = [this.title()];
for (var key in this._record.data)
tokens.push(this._record.data[key])
return regExp.test(tokens.join("|"));
}
} }
/** /**
......
...@@ -98,7 +98,7 @@ WebInspector.TimelinePanel = function() ...@@ -98,7 +98,7 @@ WebInspector.TimelinePanel = function()
this._categoryFilter = new WebInspector.TimelineCategoryFilter(); this._categoryFilter = new WebInspector.TimelineCategoryFilter();
this._durationFilter = new WebInspector.TimelineIsLongFilter(); this._durationFilter = new WebInspector.TimelineIsLongFilter();
this._textFilter = new WebInspector.TimelineTextFilter(); this._textFilter = new WebInspector.TimelineTextFilter(this._uiUtils);
this._model.addFilter(new WebInspector.TimelineHiddenFilter()); this._model.addFilter(new WebInspector.TimelineHiddenFilter());
this._model.addFilter(this._categoryFilter); this._model.addFilter(this._categoryFilter);
...@@ -937,7 +937,7 @@ WebInspector.TimelinePanel.prototype = { ...@@ -937,7 +937,7 @@ WebInspector.TimelinePanel.prototype = {
if (record.endTime() < this._windowStartTime || if (record.endTime() < this._windowStartTime ||
record.startTime() > this._windowEndTime) record.startTime() > this._windowEndTime)
return; return;
if (record.testContentMatching(searchRegExp)) if (this._uiUtils.testContentMatching(record, searchRegExp))
matches.push(record); matches.push(record);
} }
this._model.forAllFilteredRecords(processRecord.bind(this)); this._model.forAllFilteredRecords(processRecord.bind(this));
...@@ -986,7 +986,8 @@ WebInspector.TimelinePanel.prototype = { ...@@ -986,7 +986,8 @@ WebInspector.TimelinePanel.prototype = {
switch (this._selection.type()) { switch (this._selection.type()) {
case WebInspector.TimelineSelection.Type.Record: case WebInspector.TimelineSelection.Type.Record:
var record = /** @type {!WebInspector.TimelineModel.Record} */ (this._selection.object()); var record = /** @type {!WebInspector.TimelineModel.Record} */ (this._selection.object());
this._uiUtils.generateDetailsContent(record, this._model, this._detailsLinkifier, this.showInDetails.bind(this, record.title()), this._model.loadedFromFile()); var title = this._uiUtils.titleForRecord(record);
this._uiUtils.generateDetailsContent(record, this._model, this._detailsLinkifier, this.showInDetails.bind(this, title), this._model.loadedFromFile());
break; break;
case WebInspector.TimelineSelection.Type.TraceEvent: case WebInspector.TimelineSelection.Type.TraceEvent:
var event = /** @type {!WebInspector.TracingModel.Event} */ (this._selection.object()); var event = /** @type {!WebInspector.TracingModel.Event} */ (this._selection.object());
...@@ -1379,10 +1380,12 @@ WebInspector.TimelineIsLongFilter.prototype = { ...@@ -1379,10 +1380,12 @@ WebInspector.TimelineIsLongFilter.prototype = {
/** /**
* @constructor * @constructor
* @extends {WebInspector.TimelineModel.Filter} * @extends {WebInspector.TimelineModel.Filter}
* @param {!WebInspector.TimelineUIUtils} uiUtils
*/ */
WebInspector.TimelineTextFilter = function() WebInspector.TimelineTextFilter = function(uiUtils)
{ {
WebInspector.TimelineModel.Filter.call(this); WebInspector.TimelineModel.Filter.call(this);
this._uiUtils = uiUtils;
} }
WebInspector.TimelineTextFilter.prototype = { WebInspector.TimelineTextFilter.prototype = {
...@@ -1409,7 +1412,7 @@ WebInspector.TimelineTextFilter.prototype = { ...@@ -1409,7 +1412,7 @@ WebInspector.TimelineTextFilter.prototype = {
*/ */
accept: function(record) accept: function(record)
{ {
return !this._regex || record.testContentMatching(this._regex); return !this._regex || this._uiUtils.testContentMatching(record, this._regex);
}, },
__proto__: WebInspector.TimelineModel.Filter.prototype __proto__: WebInspector.TimelineModel.Filter.prototype
......
...@@ -83,6 +83,14 @@ WebInspector.TimelineUIUtils.prototype = { ...@@ -83,6 +83,14 @@ WebInspector.TimelineUIUtils.prototype = {
{ {
throw new Error("Not implemented."); throw new Error("Not implemented.");
}, },
/**
* @param {!WebInspector.TimelineModel.Record} record
* @return {string}
*/
titleForRecord: function(record)
{
throw new Error("Not implemented.");
},
/** /**
* @param {!WebInspector.TimelineModel.Record} record * @param {!WebInspector.TimelineModel.Record} record
* @param {!WebInspector.Linkifier} linkifier * @param {!WebInspector.Linkifier} linkifier
...@@ -110,6 +118,15 @@ WebInspector.TimelineUIUtils.prototype = { ...@@ -110,6 +118,15 @@ WebInspector.TimelineUIUtils.prototype = {
* @return {!Element} * @return {!Element}
*/ */
createEventDivider: function(recordType, title) createEventDivider: function(recordType, title)
{
throw new Error("Not implemented.");
},
/**
* @param {!WebInspector.TimelineModel.Record} record
* @param {!RegExp} regExp
* @return {boolean}
*/
testContentMatching: function(record, regExp)
{ {
throw new Error("Not implemented."); throw new Error("Not implemented.");
} }
...@@ -242,25 +259,6 @@ WebInspector.TimelineUIUtils.generateMainThreadBarPopupContent = function(model, ...@@ -242,25 +259,6 @@ WebInspector.TimelineUIUtils.generateMainThreadBarPopupContent = function(model,
return contentHelper.contentTable(); return contentHelper.contentTable();
} }
/**
* @param {!WebInspector.TimelineModel.Record} record
* @param {!WebInspector.TimelineModel} model
* @return {string}
*/
WebInspector.TimelineUIUtils.recordTitle = function(record, model)
{
var recordData = record.data();
if (record.type() === WebInspector.TimelineModel.RecordType.TimeStamp)
return recordData["message"];
if (record.type() === WebInspector.TimelineModel.RecordType.JSFrame)
return recordData["functionName"];
if (WebInspector.TimelineUIUtilsImpl.isEventDivider(record)) {
var startTime = Number.millisToString(record.startTime() - model.minimumRecordTime());
return WebInspector.UIString("%s at %s", WebInspector.TimelineUIUtils.recordStyle(record).title, startTime, true);
}
return WebInspector.TimelineUIUtils.recordStyle(record).title;
}
/** /**
* @param {!Object} total * @param {!Object} total
* @param {!Object} addend * @param {!Object} addend
......
...@@ -72,6 +72,15 @@ WebInspector.TimelineUIUtilsImpl.prototype = { ...@@ -72,6 +72,15 @@ WebInspector.TimelineUIUtilsImpl.prototype = {
} }
}, },
/**
* @param {!WebInspector.TimelineModel.Record} record
* @return {string}
*/
titleForRecord: function(record)
{
return WebInspector.TimelineUIUtilsImpl.recordTitle(record);
},
/** /**
* @param {!WebInspector.TimelineModel.Record} record * @param {!WebInspector.TimelineModel.Record} record
* @param {!WebInspector.Linkifier} linkifier * @param {!WebInspector.Linkifier} linkifier
...@@ -105,6 +114,20 @@ WebInspector.TimelineUIUtilsImpl.prototype = { ...@@ -105,6 +114,20 @@ WebInspector.TimelineUIUtilsImpl.prototype = {
return WebInspector.TimelineUIUtilsImpl._createEventDivider(recordType, title); return WebInspector.TimelineUIUtilsImpl._createEventDivider(recordType, title);
}, },
/**
* @param {!WebInspector.TimelineModel.Record} record
* @param {!RegExp} regExp
* @return {boolean}
*/
testContentMatching: function(record, regExp)
{
var tokens = [WebInspector.TimelineUIUtilsImpl.recordTitle(record)];
var data = record.data();
for (var key in data)
tokens.push(data[key])
return regExp.test(tokens.join("|"));
},
__proto__: WebInspector.TimelineUIUtils.prototype __proto__: WebInspector.TimelineUIUtils.prototype
} }
...@@ -117,6 +140,24 @@ WebInspector.TimelineUIUtilsImpl._coalescableRecordTypes[WebInspector.TimelineMo ...@@ -117,6 +140,24 @@ WebInspector.TimelineUIUtilsImpl._coalescableRecordTypes[WebInspector.TimelineMo
WebInspector.TimelineUIUtilsImpl._coalescableRecordTypes[WebInspector.TimelineModel.RecordType.ResizeImage] = 1; WebInspector.TimelineUIUtilsImpl._coalescableRecordTypes[WebInspector.TimelineModel.RecordType.ResizeImage] = 1;
/**
* @param {!WebInspector.TimelineModel.Record} record
* @return {string}
*/
WebInspector.TimelineUIUtilsImpl.recordTitle = function(record)
{
var recordData = record.data();
if (record.type() === WebInspector.TimelineModel.RecordType.TimeStamp)
return recordData["message"];
if (record.type() === WebInspector.TimelineModel.RecordType.JSFrame)
return recordData["functionName"];
if (WebInspector.TimelineUIUtilsImpl.isEventDivider(record)) {
var startTime = Number.millisToString(record.startTime() - record._model.minimumRecordTime());
return WebInspector.UIString("%s at %s", WebInspector.TimelineUIUtils.recordStyle(record).title, startTime, true);
}
return WebInspector.TimelineUIUtils.recordStyle(record).title;
}
/** /**
* @param {!WebInspector.TimelineModel.Record} record * @param {!WebInspector.TimelineModel.Record} record
* @return {boolean} * @return {boolean}
......
...@@ -40,11 +40,11 @@ ...@@ -40,11 +40,11 @@
WebInspector.TimelineView = function(delegate, model, uiUtils) WebInspector.TimelineView = function(delegate, model, uiUtils)
{ {
WebInspector.HBox.call(this); WebInspector.HBox.call(this);
this._uiUtils = uiUtils;
this.element.classList.add("timeline-view"); this.element.classList.add("timeline-view");
this._delegate = delegate; this._delegate = delegate;
this._model = model; this._model = model;
this._uiUtils = uiUtils;
this._presentationModel = new WebInspector.TimelinePresentationModel(model, uiUtils); this._presentationModel = new WebInspector.TimelinePresentationModel(model, uiUtils);
this._calculator = new WebInspector.TimelineCalculator(model); this._calculator = new WebInspector.TimelineCalculator(model);
this._linkifier = new WebInspector.Linkifier(); this._linkifier = new WebInspector.Linkifier();
...@@ -135,7 +135,8 @@ WebInspector.TimelineView.prototype = { ...@@ -135,7 +135,8 @@ WebInspector.TimelineView.prototype = {
var dividerPosition = Math.round(position); var dividerPosition = Math.round(position);
if (dividerPosition < 0 || dividerPosition >= clientWidth || dividers[dividerPosition]) if (dividerPosition < 0 || dividerPosition >= clientWidth || dividers[dividerPosition])
continue; continue;
var divider = this._uiUtils.createEventDivider(record.type(), record.title()); var title = this._uiUtils.titleForRecord(record);
var divider = this._uiUtils.createEventDivider(record.type(), title);
divider.style.left = dividerPosition + "px"; divider.style.left = dividerPosition + "px";
dividers[dividerPosition] = divider; dividers[dividerPosition] = divider;
} }
...@@ -1065,7 +1066,7 @@ WebInspector.TimelineRecordListRow.prototype = { ...@@ -1065,7 +1066,7 @@ WebInspector.TimelineRecordListRow.prototype = {
if (record.thread()) if (record.thread())
this.element.classList.add("background"); this.element.classList.add("background");
this._typeElement.textContent = record.title(); this._typeElement.textContent = uiUtils.titleForRecord(record);
if (this._dataElement.firstChild) if (this._dataElement.firstChild)
this._dataElement.removeChildren(); this._dataElement.removeChildren();
......
...@@ -537,14 +537,6 @@ WebInspector.TracingTimelineModel.TraceEventRecord.prototype = { ...@@ -537,14 +537,6 @@ WebInspector.TracingTimelineModel.TraceEventRecord.prototype = {
return style.category; return style.category;
}, },
/**
* @return {string}
*/
title: function()
{
return WebInspector.TracingTimelineUIUtils.styleForTraceEvent(this._event.name).title;
},
/** /**
* @return {number} * @return {number}
*/ */
...@@ -659,21 +651,6 @@ WebInspector.TracingTimelineModel.TraceEventRecord.prototype = { ...@@ -659,21 +651,6 @@ WebInspector.TracingTimelineModel.TraceEventRecord.prototype = {
return null; return null;
}, },
/**
* @param {!RegExp} regExp
* @return {boolean}
*/
testContentMatching: function(regExp)
{
var tokens = [this.title()];
var data = this._event.args.data;
if (data) {
for (var key in data)
tokens.push(data[key]);
}
return regExp.test(tokens.join("|"));
},
/** /**
* @return {!WebInspector.TracingModel.Event} * @return {!WebInspector.TracingModel.Event}
*/ */
......
...@@ -66,6 +66,15 @@ WebInspector.TracingTimelineUIUtils.prototype = { ...@@ -66,6 +66,15 @@ WebInspector.TracingTimelineUIUtils.prototype = {
return record.traceEvent().highlightQuad || null; return record.traceEvent().highlightQuad || null;
}, },
/**
* @param {!WebInspector.TimelineModel.Record} record
* @return {string}
*/
titleForRecord: function(record)
{
return WebInspector.TracingTimelineUIUtils.styleForTraceEvent(record.traceEvent().name).title;
},
/** /**
* @param {!WebInspector.TimelineModel.Record} record * @param {!WebInspector.TimelineModel.Record} record
* @param {!WebInspector.Linkifier} linkifier * @param {!WebInspector.Linkifier} linkifier
...@@ -102,6 +111,24 @@ WebInspector.TracingTimelineUIUtils.prototype = { ...@@ -102,6 +111,24 @@ WebInspector.TracingTimelineUIUtils.prototype = {
return WebInspector.TracingTimelineUIUtils._createEventDivider(recordType, title); return WebInspector.TracingTimelineUIUtils._createEventDivider(recordType, title);
}, },
/**
* @param {!WebInspector.TimelineModel.Record} record
* @param {!RegExp} regExp
* @return {boolean}
*/
testContentMatching: function(record, regExp)
{
var traceEvent = record.traceEvent();
var title = WebInspector.TracingTimelineUIUtils.styleForTraceEvent(traceEvent.name).title;
var tokens = [title];
for (var argName in traceEvent.args) {
var argValue = traceEvent.args[argName];
for (var key in argValue)
tokens.push(argValue[key]);
}
return regExp.test(tokens.join("|"));
},
__proto__: WebInspector.TimelineUIUtils.prototype __proto__: WebInspector.TimelineUIUtils.prototype
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment