Commit 1f840496 authored by caseq's avatar caseq Committed by Commit bot

Timeline: make prepareHighlightedEntryInfo return ?Promise<!Element>

BUG=

Review-Url: https://codereview.chromium.org/2314173003
Cr-Commit-Position: refs/heads/master@{#417475}
parent cb3445df
...@@ -138,7 +138,7 @@ WebInspector.ProfileFlameChartDataProvider.prototype = { ...@@ -138,7 +138,7 @@ WebInspector.ProfileFlameChartDataProvider.prototype = {
/** /**
* @override * @override
* @param {number} entryIndex * @param {number} entryIndex
* @return {?Array<!{title: string, value: (string|!Element)}>} * @return {?Element}
*/ */
prepareHighlightedEntryInfo: function(entryIndex) prepareHighlightedEntryInfo: function(entryIndex)
{ {
......
...@@ -448,7 +448,7 @@ WebInspector.CPUFlameChartDataProvider.prototype = { ...@@ -448,7 +448,7 @@ WebInspector.CPUFlameChartDataProvider.prototype = {
/** /**
* @override * @override
* @param {number} entryIndex * @param {number} entryIndex
* @return {?Array<!{title: string, value: (string|!Element)}>} * @return {?Element}
*/ */
prepareHighlightedEntryInfo: function(entryIndex) prepareHighlightedEntryInfo: function(entryIndex)
{ {
...@@ -494,7 +494,7 @@ WebInspector.CPUFlameChartDataProvider.prototype = { ...@@ -494,7 +494,7 @@ WebInspector.CPUFlameChartDataProvider.prototype = {
if (node.deoptReason) if (node.deoptReason)
pushEntryInfoRow(WebInspector.UIString("Not optimized"), node.deoptReason); pushEntryInfoRow(WebInspector.UIString("Not optimized"), node.deoptReason);
return entryInfo; return WebInspector.ProfileView.buildPopoverTable(entryInfo);
}, },
__proto__: WebInspector.ProfileFlameChartDataProvider.prototype __proto__: WebInspector.ProfileFlameChartDataProvider.prototype
......
...@@ -409,7 +409,7 @@ WebInspector.HeapFlameChartDataProvider.prototype = { ...@@ -409,7 +409,7 @@ WebInspector.HeapFlameChartDataProvider.prototype = {
/** /**
* @override * @override
* @param {number} entryIndex * @param {number} entryIndex
* @return {?Array<!{title: string, value: (string|!Element)}>} * @return {?Element}
*/ */
prepareHighlightedEntryInfo: function(entryIndex) prepareHighlightedEntryInfo: function(entryIndex)
{ {
...@@ -433,7 +433,7 @@ WebInspector.HeapFlameChartDataProvider.prototype = { ...@@ -433,7 +433,7 @@ WebInspector.HeapFlameChartDataProvider.prototype = {
if (link) if (link)
pushEntryInfoRow(WebInspector.UIString("URL"), link.textContent); pushEntryInfoRow(WebInspector.UIString("URL"), link.textContent);
linkifier.dispose(); linkifier.dispose();
return entryInfo; return WebInspector.ProfileView.buildPopoverTable(entryInfo);
}, },
__proto__: WebInspector.ProfileFlameChartDataProvider.prototype __proto__: WebInspector.ProfileFlameChartDataProvider.prototype
......
...@@ -72,6 +72,21 @@ WebInspector.ProfileView.ViewTypes = { ...@@ -72,6 +72,21 @@ WebInspector.ProfileView.ViewTypes = {
Heavy: "Heavy" Heavy: "Heavy"
} }
/**
* @param {!Array<!{title: string, value: string}>} entryInfo
* @return {!Element}
*/
WebInspector.ProfileView.buildPopoverTable = function(entryInfo)
{
var table = createElement("table");
for (var entry of entryInfo) {
var row = table.createChild("tr");
row.createChild("td").textContent = entry.title;
row.createChild("td").textContent = entry.value;
}
return table;
}
WebInspector.ProfileView.prototype = { WebInspector.ProfileView.prototype = {
focus: function() focus: function()
{ {
......
...@@ -139,7 +139,7 @@ WebInspector.TimelineFlameChartDataProviderBase.prototype = { ...@@ -139,7 +139,7 @@ WebInspector.TimelineFlameChartDataProviderBase.prototype = {
/** /**
* @override * @override
* @param {number} entryIndex * @param {number} entryIndex
* @return {?Array.<!{title: string, value: (string|!Element)}>} * @return {?Element}
*/ */
prepareHighlightedEntryInfo: function(entryIndex) prepareHighlightedEntryInfo: function(entryIndex)
{ {
...@@ -635,7 +635,7 @@ WebInspector.TimelineFlameChartDataProvider.prototype = { ...@@ -635,7 +635,7 @@ WebInspector.TimelineFlameChartDataProvider.prototype = {
/** /**
* @override * @override
* @param {number} entryIndex * @param {number} entryIndex
* @return {?Array.<!{title: string, value: (string|!Element)}>} * @return {?Element}
*/ */
prepareHighlightedEntryInfo: function(entryIndex) prepareHighlightedEntryInfo: function(entryIndex)
{ {
...@@ -666,8 +666,8 @@ WebInspector.TimelineFlameChartDataProvider.prototype = { ...@@ -666,8 +666,8 @@ WebInspector.TimelineFlameChartDataProvider.prototype = {
} else { } else {
return null; return null;
} }
var value = createElement("div"); var element = createElement("div");
var root = WebInspector.createShadowRootWithCoreStyles(value, "timeline/timelineFlamechartPopover.css"); var root = WebInspector.createShadowRootWithCoreStyles(element, "timeline/timelineFlamechartPopover.css");
var contents = root.createChild("div", "timeline-flamechart-popover"); var contents = root.createChild("div", "timeline-flamechart-popover");
contents.createChild("span", "timeline-info-time").textContent = time; contents.createChild("span", "timeline-info-time").textContent = time;
contents.createChild("span", "timeline-info-title").textContent = title; contents.createChild("span", "timeline-info-title").textContent = title;
...@@ -675,7 +675,7 @@ WebInspector.TimelineFlameChartDataProvider.prototype = { ...@@ -675,7 +675,7 @@ WebInspector.TimelineFlameChartDataProvider.prototype = {
warning.classList.add("timeline-info-warning"); warning.classList.add("timeline-info-warning");
contents.appendChild(warning); contents.appendChild(warning);
} }
return [{ title: "", value: value }]; return element;
}, },
/** /**
...@@ -1136,7 +1136,7 @@ WebInspector.TimelineFlameChartNetworkDataProvider.prototype = { ...@@ -1136,7 +1136,7 @@ WebInspector.TimelineFlameChartNetworkDataProvider.prototype = {
/** /**
* @override * @override
* @param {number} index * @param {number} index
* @return {?Array<!{title: string, value: (string|!Element)}>} * @return {?Element}
*/ */
prepareHighlightedEntryInfo: function(index) prepareHighlightedEntryInfo: function(index)
{ {
...@@ -1144,8 +1144,8 @@ WebInspector.TimelineFlameChartNetworkDataProvider.prototype = { ...@@ -1144,8 +1144,8 @@ WebInspector.TimelineFlameChartNetworkDataProvider.prototype = {
var request = /** @type {!WebInspector.TimelineModel.NetworkRequest} */ (this._requests[index]); var request = /** @type {!WebInspector.TimelineModel.NetworkRequest} */ (this._requests[index]);
if (!request.url) if (!request.url)
return null; return null;
var value = createElement("div"); var element = createElement("div");
var root = WebInspector.createShadowRootWithCoreStyles(value, "timeline/timelineFlamechartPopover.css"); var root = WebInspector.createShadowRootWithCoreStyles(element, "timeline/timelineFlamechartPopover.css");
var contents = root.createChild("div", "timeline-flamechart-popover"); var contents = root.createChild("div", "timeline-flamechart-popover");
var duration = request.endTime - request.startTime; var duration = request.endTime - request.startTime;
if (request.startTime && isFinite(duration)) if (request.startTime && isFinite(duration))
...@@ -1156,7 +1156,7 @@ WebInspector.TimelineFlameChartNetworkDataProvider.prototype = { ...@@ -1156,7 +1156,7 @@ WebInspector.TimelineFlameChartNetworkDataProvider.prototype = {
div.style.color = this._colorForPriority(request.priority) || "black"; div.style.color = this._colorForPriority(request.priority) || "black";
} }
contents.createChild("span").textContent = request.url.trimMiddle(maxURLChars); contents.createChild("span").textContent = request.url.trimMiddle(maxURLChars);
return [{ title: "", value: value }]; return element;
}, },
/** /**
......
...@@ -215,7 +215,7 @@ WebInspector.FlameChartDataProvider.prototype = { ...@@ -215,7 +215,7 @@ WebInspector.FlameChartDataProvider.prototype = {
/** /**
* @param {number} entryIndex * @param {number} entryIndex
* @return {?Array.<!{title: string, value: (string|!Element)}>} * @return {?Element}
*/ */
prepareHighlightedEntryInfo: function(entryIndex) { }, prepareHighlightedEntryInfo: function(entryIndex) { },
...@@ -813,12 +813,20 @@ WebInspector.FlameChart.prototype = { ...@@ -813,12 +813,20 @@ WebInspector.FlameChart.prototype = {
*/ */
_updatePopover: function(entryIndex) _updatePopover: function(entryIndex)
{ {
if (entryIndex !== this._highlightedEntryIndex) { if (entryIndex === this._highlightedEntryIndex) {
this._entryInfo.removeChildren(); this._updatePopoverOffset();
var entryInfo = this._dataProvider.prepareHighlightedEntryInfo(entryIndex); return;
if (entryInfo) }
this._entryInfo.appendChild(this._buildEntryInfo(entryInfo)); this._entryInfo.removeChildren();
var popoverElement = this._dataProvider.prepareHighlightedEntryInfo(entryIndex);
if (popoverElement) {
this._entryInfo.appendChild(popoverElement);
this._updatePopoverOffset();
} }
},
_updatePopoverOffset: function()
{
var mouseX = this._lastMouseOffsetX; var mouseX = this._lastMouseOffsetX;
var mouseY = this._lastMouseOffsetY; var mouseY = this._lastMouseOffsetY;
var parentWidth = this._entryInfo.parentElement.clientWidth; var parentWidth = this._entryInfo.parentElement.clientWidth;
...@@ -1841,24 +1849,6 @@ WebInspector.FlameChart.prototype = { ...@@ -1841,24 +1849,6 @@ WebInspector.FlameChart.prototype = {
return this._visibleLevelOffsets[level]; return this._visibleLevelOffsets[level];
}, },
/**
* @param {!Array<!{title: string, value: (string|!Element)}>} entryInfo
* @return {!Element}
*/
_buildEntryInfo: function(entryInfo)
{
var infoTable = createElementWithClass("table", "info-table");
for (var entry of entryInfo) {
var row = infoTable.createChild("tr");
row.createChild("td", "title").textContent = entry.title;
if (typeof entry.value === "string")
row.createChild("td").textContent = entry.value;
else
row.createChild("td").appendChild(entry.value);
}
return infoTable;
},
/** /**
* @param {!CanvasRenderingContext2D} context * @param {!CanvasRenderingContext2D} context
* @param {string} text * @param {string} text
......
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