Skip to content

Commit cfd0ae3

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[tools] Remember the current view in the URL fragment.
Change-Id: I516914b3b64269571c0932a8bcada3891b266c15 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425361 Reviewed-by: Brian Quinlan <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 5cfae22 commit cfd0ae3

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

runtime/tools/binary_size

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,19 @@ function showDominatorTree(v) {
397397
topTile.style.width = w;
398398
topTile.style.height = h;
399399
setBody(topTile);
400+
401+
// Encode the current view into the URL fragment.
402+
if (v == root) {
403+
window.location.hash = "";
404+
} else {
405+
var fragment = v.name;
406+
v = v.parent;
407+
while (v != root) {
408+
fragment = v.name + "," + fragment;
409+
v = v.parent;
410+
}
411+
window.location.hash = fragment;
412+
}
400413
}
401414
402415
function setBody(div) {
@@ -413,9 +426,24 @@ function setParents(v) {
413426
setParents(child);
414427
});
415428
}
416-
417429
setParents(root);
418-
showDominatorTree(root);
430+
431+
let v = root;
432+
let fragments = window.location.hash.substring(1).split(",");
433+
for (let i = 0; i < fragments.length; i++) {
434+
let fragment = fragments[i];
435+
let foundChild = null;
436+
for (let j = 0; j < v.children.length; j++) {
437+
let child = v.children[j];
438+
if (child.name == fragment) {
439+
foundChild = child;
440+
break;
441+
}
442+
}
443+
if (foundChild == null) break; // Not found, end search.
444+
v = foundChild;
445+
}
446+
showDominatorTree(v);
419447
420448
</script>
421449
</body>

0 commit comments

Comments
 (0)