Skip to content
Permalink
Browse files

Fix flexbox trace loading problem in layout_viewer

  • Loading branch information
shinglyu committed Dec 28, 2016
1 parent 4b2d80a commit 22ffdf8018e5b2707c2dfba06c39e875eabf8654
Showing with 25 additions and 9 deletions.
  1. +25 −9 etc/layout_viewer/viewer.html
@@ -80,17 +80,28 @@ <h1> Servo Layout Viewer </h1>
<script src="js/formatters.min.js"></script>

<script>
function get_base(trace_node) {
if (typeof(trace_node.data.base) == "undefined" && typeof(trace_node.data.block_flow) != "undefined") {
return trace_node.data.block_flow.base;
}
else {
return trace_node.data.base;
}
}

function create_flow_tree(trace_node) {
var base = get_base(trace_node);

var node = {
text: trace_node.class + " (" + trace_node.data.base.id + ")",
id: trace_node.data.base.id,
text: trace_node.class + " (" + base.id + ")",
id: base.id,
icon: "dummy",
href: "#diff-" + trace_node.data.base.id
href: "#diff-" + base.id
};

var children = [];
for (var i=0 ; i < trace_node.data.base.children.length ; ++i) {
children.push(create_flow_tree(trace_node.data.base.children[i]));
for (var i=0 ; i < base.children.length ; ++i) {
children.push(create_flow_tree(base.children[i]));
}

if (children.length > 0) {
@@ -101,13 +112,14 @@ <h1> Servo Layout Viewer </h1>
}

function create_flow_hash(trace_node, flow_hash) {
flow_hash[trace_node.data.base.id] = trace_node;
var base = get_base(trace_node);
flow_hash[base.id] = trace_node;

for (var i=0 ; i < trace_node.data.base.children.length ; ++i) {
create_flow_hash(trace_node.data.base.children[i], flow_hash);
for (var i=0 ; i < base.children.length ; ++i) {
create_flow_hash(base.children[i], flow_hash);
}

delete trace_node.data.base.children;
delete base.children;
}

function flatten_trace(trace_node) {
@@ -177,6 +189,10 @@ <h1> Servo Layout Viewer </h1>
if (obj.id !== undefined) {
return obj.id;
}
if (obj.index !== undefined) {
// FlexItem and FlexLine
return obj.index;
}
return JSON.stringify(obj);
}
}).diff(flow_left, flow_right);

0 comments on commit 22ffdf8

Please sign in to comment.
You can’t perform that action at this time.