resolve merge conflicts

This commit is contained in:
daviskoh
2015-02-17 21:30:41 -05:00
9 changed files with 139 additions and 38 deletions

View File

@@ -100,8 +100,10 @@ var layoutTestUtils = (function() {
getIframe(iframe);
}
if (typeof computeLayout === 'function') {
var realComputeLayout = computeLayout;
if (typeof computeLayout === 'object') {
var fillNodes = computeLayout.fillNodes;
var extractNodes = computeLayout.extractNodes;
var realComputeLayout = computeLayout.computeLayout;
}
function roundLayout(layout) {
@@ -143,34 +145,6 @@ var layoutTestUtils = (function() {
}
function computeCSSLayout(rootNode) {
function fillNodes(node) {
node.layout = {
width: undefined,
height: undefined,
top: 0,
left: 0
};
if (!node.style) {
node.style = {};
}
if (!node.children || node.style.measure) {
node.children = [];
}
node.children.forEach(fillNodes);
}
function extractNodes(node) {
var layout = node.layout;
delete node.layout;
if (node.children.length > 0) {
layout.children = node.children.map(extractNodes);
} else {
delete node.children;
}
return layout;
}
fillNodes(rootNode);
realComputeLayout(rootNode);
return roundLayout(extractNodes(rootNode));
@@ -257,6 +231,14 @@ var layoutTestUtils = (function() {
return namedLayout;
}
function testFillNodes(node, filledNode) {
expect(fillNodes(node)).toEqual(filledNode);
}
function testExtractNodes(node, extractedNode) {
expect(extractNodes(node)).toEqual(extractedNode);
}
function testNamedLayout(name, layoutA, layoutB) {
expect(nameLayout(name, layoutA))
.toEqual(nameLayout(name, layoutB));
@@ -404,6 +386,8 @@ var layoutTestUtils = (function() {
testNamedLayout('expected-dom', expectedLayout, domLayout);
testNamedLayout('layout-dom', layout, domLayout);
},
testFillNodes: testFillNodes,
testExtractNodes: testExtractNodes,
testRandomLayout: function(node) {
expect({node: node, layout: computeCSSLayout(node)})
.toEqual({node: node, layout: computeDOMLayout(node)});