Commit 5059675d authored by Joel Einbinder's avatar Joel Einbinder Committed by Commit Bot

DevTools: Sort nested worker execution contexts as a tree

Workers are now sorted by target in the execution context selector

Bug: 848450
Change-Id: I90d3406befd880778fe04b61fa7b20fff679d6b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1502212
Commit-Queue: Joel Einbinder <einbinder@chromium.org>
Reviewed-by: default avatarErik Luo <luoe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#637898}
parent 9702f013
......@@ -419,6 +419,7 @@ SDK.ResourceTreeModel = class extends SDK.SDKModel {
_executionContextComparator(a, b) {
/**
* @param {!SDK.ResourceTreeFrame} frame
* @return {!Array<!SDK.ResourceTreeFrame>}
*/
function framePath(frame) {
let currentFrame = frame;
......
......@@ -708,9 +708,43 @@ SDK.ExecutionContext = class {
return 1;
}
const weightDiff = targetWeight(a.target()) - targetWeight(b.target());
/**
* @param {!SDK.Target} target
* @return {!Array<!SDK.Target>}
*/
function targetPath(target) {
let currentTarget = target;
const parents = [];
while (currentTarget) {
parents.push(currentTarget);
currentTarget = currentTarget.parentTarget();
}
return parents.reverse();
}
const tagetsA = targetPath(a.target());
const targetsB = targetPath(b.target());
let targetA;
let targetB;
for (let i = 0;; i++) {
if (!tagetsA[i] || !targetsB[i] || (tagetsA[i] !== targetsB[i])) {
targetA = tagetsA[i];
targetB = targetsB[i];
break;
}
}
if (!targetA && targetB)
return -1;
if (!targetB && targetA)
return 1;
if (targetA && targetB) {
const weightDiff = targetWeight(targetA) - targetWeight(targetB);
if (weightDiff)
return -weightDiff;
return targetA.id().localeCompare(targetB.id());
}
// Main world context should always go first.
if (a.isDefault)
......
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