Skip to content

Commit

Permalink
Fix flexbox trace loading problem in layout_viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
shinglyu committed Dec 28, 2016
1 parent 4b2d80a commit 22ffdf8
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions etc/layout_viewer/viewer.html
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 22ffdf8

Please sign in to comment.