Commit 7d60ac92 authored by yurys@chromium.org's avatar yurys@chromium.org

Don't create TimelineModel.RecordImpl in TimelinePresentationModel.js

TimelinePresentationModel.Record now has three implementations: one for root record, one for coealesced record and one for representing actual TimelineModel.Record. This allows it to work fine with Timeline based on trace events.

BUG=361045
R=caseq@chromium.org

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

git-svn-id: svn://svn.chromium.org/blink/trunk@176205 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e09741d1
......@@ -207,7 +207,7 @@ InspectorTest.dumpTimelineRecord = function(record, detailsCallback, level, filt
// Dump just the record name, indenting output on separate lines for subrecords
InspectorTest.dumpPresentationRecord = function(presentationRecord, detailsCallback, level, filterTypes)
{
var record = presentationRecord.record();
var record = !presentationRecord.presentationParent() ? null : presentationRecord.record();
if (typeof level !== "number")
level = 0;
var prefix = "";
......@@ -218,13 +218,14 @@ InspectorTest.dumpPresentationRecord = function(presentationRecord, detailsCallb
prefix = prefix + "> ";
if (presentationRecord.coalesced()) {
suffix = " x " + presentationRecord.presentationChildren().length;
} else if (record.type() === WebInspector.TimelineModel.RecordType.TimeStamp
|| record.type() === WebInspector.TimelineModel.RecordType.ConsoleTime) {
} else if (record && (record.type() === WebInspector.TimelineModel.RecordType.TimeStamp
|| record.type() === WebInspector.TimelineModel.RecordType.ConsoleTime)) {
suffix = " : " + record.data().message;
}
if (detailsCallback)
suffix += " " + detailsCallback(record);
InspectorTest.addResult(prefix + InspectorTest._timelineAgentTypeToString(record.type()) + suffix);
suffix += " " + detailsCallback(presentationRecord);
var typeString = record ? InspectorTest._timelineAgentTypeToString(record.type()) : "Root";
InspectorTest.addResult(prefix + typeString + suffix);
var numChildren = presentationRecord.presentationChildren() ? presentationRecord.presentationChildren().length : 0;
for (var i = 0; i < numChildren; ++i) {
......
......@@ -7,11 +7,11 @@
function initialize_TimelineCoalescing()
{
InspectorTest.dumpStats = function(record)
InspectorTest.dumpStats = function(presentationRecord)
{
if (record.type() === "Root")
if (!presentationRecord.presentationParent())
return "";
var aggregatedStats = record.aggregatedStats();
var aggregatedStats = presentationRecord.presentationAggregatedStats();
var timeByCategory = "";
for (category in aggregatedStats) {
......@@ -19,8 +19,8 @@ InspectorTest.dumpStats = function(record)
timeByCategory += ", ";
timeByCategory += category + ": " + aggregatedStats[category].toFixed(5);
}
var duration = (record.endTime() - record.startTime()).toFixed(5);
var durationTillLastChild = (record.endTime() - record.startTime()).toFixed(5);
var duration = (presentationRecord.endTime() - presentationRecord.startTime()).toFixed(5);
var durationTillLastChild = (presentationRecord.endTime() - presentationRecord.startTime()).toFixed(5);
return "duration: " + duration + ":" + durationTillLastChild + (timeByCategory ? " (" + timeByCategory + ")" : "");
}
......
......@@ -32,7 +32,7 @@
* @constructor
* @implements {WebInspector.FlameChartDataProvider}
* @implements {WebInspector.TimelineFlameChart.SelectionProvider}
* @param {!WebInspector.TimelineModel} model
* @param {!WebInspector.TimelineModelImpl} model
* @param {!WebInspector.TimelineFrameModelBase} frameModel
*/
WebInspector.TimelineFlameChartDataProvider = function(model, frameModel)
......@@ -816,7 +816,7 @@ WebInspector.TimelineFlameChart = function(delegate, model, tracingModel, frameM
this._model = model;
this._dataProvider = tracingModel
? new WebInspector.TracingBasedTimelineFlameChartDataProvider(tracingModel, frameModel, model.target())
: new WebInspector.TimelineFlameChartDataProvider(model, frameModel);
: new WebInspector.TimelineFlameChartDataProvider(/** @type {!WebInspector.TimelineModelImpl} */(model), frameModel);
this._mainView = new WebInspector.FlameChart(this._dataProvider, this, true);
this._mainView.show(this.element);
this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStarted, this._onRecordingStarted, this);
......
......@@ -6,7 +6,7 @@
WebInspector.TimelineJSProfileProcessor = { };
/**
* @param {!WebInspector.TimelineModel} timelineModel
* @param {!WebInspector.TimelineModelImpl} timelineModel
* @param {!ProfilerAgent.CPUProfile} jsProfile
*/
WebInspector.TimelineJSProfileProcessor.mergeJSProfileIntoTimeline = function(timelineModel, jsProfile)
......
......@@ -164,7 +164,6 @@ WebInspector.TimelineModelImpl.prototype = {
* @param {!TimelineAgent.TimelineEvent} payload
* @param {?WebInspector.TimelineModel.Record} parentRecord
* @return {!WebInspector.TimelineModel.Record}
* @this {!WebInspector.TimelineModel}
*/
_innerAddRecord: function(payload, parentRecord)
{
......@@ -292,7 +291,7 @@ WebInspector.TimelineModelImpl.InterRecordBindings.prototype = {
/**
* @constructor
* @implements {WebInspector.TimelineModel.Record}
* @param {!WebInspector.TimelineModel} model
* @param {!WebInspector.TimelineModelImpl} model
* @param {!TimelineAgent.TimelineEvent} timelineEvent
* @param {?WebInspector.TimelineModel.Record} parentRecord
*/
......
......@@ -129,8 +129,8 @@ WebInspector.TimelineView.prototype = {
for (var i = 0; i < eventDividerRecords.length; ++i) {
var record = eventDividerRecords[i];
var positions = this._calculator.computeBarGraphWindowPosition(record);
var dividerPosition = Math.round(positions.left);
var position = this._calculator.computePosition(record.startTime());
var dividerPosition = Math.round(position);
if (dividerPosition < 0 || dividerPosition >= clientWidth || dividers[dividerPosition])
continue;
var divider = WebInspector.TimelineUIUtils.createEventDivider(record.type(), WebInspector.TimelineUIUtils.recordTitle(record, this._model));
......@@ -531,8 +531,8 @@ WebInspector.TimelineView.prototype = {
this._automaticallySizeWindow = false;
this._clearSelection();
// 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._model.minimumRecordTime();
var windowEndTime = recordsInWindow[Math.max(0, lastVisibleLine - 1)].record().endTime();
var windowStartTime = startIndex ? recordsInWindow[startIndex].startTime() : this._model.minimumRecordTime();
var windowEndTime = recordsInWindow[Math.max(0, lastVisibleLine - 1)].endTime();
this._delegate.requestWindowTimes(windowStartTime, windowEndTime);
recordsInWindow = this._presentationModel.filteredRecords();
endIndex = Math.min(recordsInWindow.length, lastVisibleLine);
......@@ -566,7 +566,7 @@ WebInspector.TimelineView.prototype = {
var lastChildIndex = i + record.visibleChildrenCount();
if (lastChildIndex >= startIndex && lastChildIndex < endIndex) {
var expandElement = new WebInspector.TimelineExpandableElement(this._expandElements);
var positions = this._calculator.computeBarGraphWindowPosition(record.record());
var positions = this._calculator.computeBarGraphWindowPosition(record);
expandElement._update(record, i, positions.left - this._expandOffset, positions.width);
}
} else {
......@@ -824,7 +824,10 @@ WebInspector.TimelineView.prototype = {
{
if (!rowElement || !rowElement.row)
return false;
var record = rowElement.row._record.record();
var presentationRecord = rowElement.row._record;
if (presentationRecord.collapsed())
return false;
var record = presentationRecord.record();
if (this._highlightedQuadRecord === record)
return true;
this._highlightedQuadRecord = record;
......@@ -920,7 +923,7 @@ WebInspector.TimelineCalculator.prototype = {
},
/**
* @param {!WebInspector.TimelineModel.Record} record
* @param {!WebInspector.TimelinePresentationModel.Record} record
* @return {!{start: number, end: number, cpuWidth: number}}
*/
computeBarGraphPercentages: function(record)
......@@ -932,7 +935,7 @@ WebInspector.TimelineCalculator.prototype = {
},
/**
* @param {!WebInspector.TimelineModel.Record} record
* @param {!WebInspector.TimelinePresentationModel.Record} record
* @return {!{left: number, width: number, cpuWidth: number}}
*/
computeBarGraphWindowPosition: function(record)
......@@ -1193,7 +1196,7 @@ WebInspector.TimelineRecordGraphRow.prototype = {
if (record.thread())
this.element.classList.add("background");
var barPosition = calculator.computeBarGraphWindowPosition(record);
var barPosition = calculator.computeBarGraphWindowPosition(presentationRecord);
this._barElement.style.left = barPosition.left + "px";
this._barElement.style.width = barPosition.width + "px";
this._barCpuElement.style.left = barPosition.left + "px";
......
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