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

Unified Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineEventOverview.js

Issue 2662453004: DevTools: Update network overview with two level bars. (Closed)
Patch Set: fix compile error Created 3 years, 11 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/timeline/TimelineNetworkFlameChart.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/timeline/TimelineEventOverview.js
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineEventOverview.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineEventOverview.js
index 8d634e017cebd21bfd9a29237841c60416c76812..73ea48d95ec15a6eb6a17b046cadea988b78cd1c 100644
--- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineEventOverview.js
+++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineEventOverview.js
@@ -157,59 +157,29 @@ Timeline.TimelineEventOverviewNetwork = class extends Timeline.TimelineEventOver
*/
update() {
super.update();
- const height = this.height();
- const numBands = categoryBand(Timeline.TimelineUIUtils.NetworkCategory.Other) + 1;
- const devicePixelRatio = window.devicePixelRatio;
- const bandHeight = height - (numBands + 1) * devicePixelRatio;
- const timeOffset = this._model.minimumRecordTime();
- const timeSpan = this._model.maximumRecordTime() - timeOffset;
- const canvasWidth = this.width();
- const scale = canvasWidth / timeSpan;
- const ctx = this.context();
- const paths = [];
- for (const categoryName in Timeline.TimelineUIUtils.NetworkCategory) {
- const category = Timeline.TimelineUIUtils.NetworkCategory[categoryName];
- paths[categoryBand(category)] = {
- style: Timeline.TimelineUIUtils.networkCategoryColor(category),
- path: new Path2D()
- };
- }
- for (const request of this._model.networkRequests()) {
- const category = Timeline.TimelineUIUtils.networkRequestCategory(request);
- const band = categoryBand(category);
- const y = (numBands - band - 1) * devicePixelRatio;
- const s = Math.max(Math.floor((request.startTime - timeOffset) * scale), 0);
- const e = Math.min(Math.ceil((request.endTime - timeOffset) * scale + 1), canvasWidth);
- paths[band].path.rect(s, y, e - s, bandHeight);
- }
- for (const path of paths.reverse()) {
- ctx.globalAlpha = 1;
- ctx.fillStyle = path.style;
- ctx.fill(path.path);
- ctx.globalAlpha = 0.4;
- ctx.fillStyle = 'white';
- ctx.fill(path.path);
- }
-
- /**
- * @param {!Timeline.TimelineUIUtils.NetworkCategory} category
- * @return {number}
- */
- function categoryBand(category) {
- const categories = Timeline.TimelineUIUtils.NetworkCategory;
- switch (category) {
- case categories.HTML:
- return 0;
- case categories.Script:
- return 1;
- case categories.Style:
- return 2;
- case categories.Media:
- return 3;
- default:
- return 4;
- }
+ var bandHeight = this.height() / 2;
+ var timeOffset = this._model.minimumRecordTime();
+ var timeSpan = this._model.maximumRecordTime() - timeOffset;
+ var canvasWidth = this.width();
+ var scale = canvasWidth / timeSpan;
+ var highPath = new Path2D();
+ var lowPath = new Path2D();
+ var priorities = Protocol.Network.ResourcePriority;
+ var highPrioritySet = new Set([priorities.VeryHigh, priorities.High, priorities.Medium]);
+ for (var request of this._model.networkRequests()) {
+ var path = highPrioritySet.has(request.priority) ? highPath : lowPath;
+ var s = Math.max(Math.floor((request.startTime - timeOffset) * scale), 0);
+ var e = Math.min(Math.ceil((request.endTime - timeOffset) * scale + 1), canvasWidth);
+ path.rect(s, 0, e - s, bandHeight - 1);
}
+ var ctx = this.context();
+ ctx.save();
+ ctx.fillStyle = 'hsl(214, 60%, 60%)';
+ ctx.fill(/** @type {?} */ (highPath));
+ ctx.translate(0, bandHeight);
+ ctx.fillStyle = 'hsl(214, 80%, 80%)';
+ ctx.fill(/** @type {?} */ (lowPath));
+ ctx.restore();
}
};
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/timeline/TimelineNetworkFlameChart.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698