move extractLayoutNode out of layout.js

This commit is contained in:
Christopher Chedeau
2014-04-27 12:37:26 -07:00
parent a0ffafe37d
commit 490a7c74d5
2 changed files with 14 additions and 20 deletions

View File

@@ -51,8 +51,20 @@ var layoutTestUtils = (function() {
node.children.forEach(fillNodes); 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); fillNodes(rootNode);
return realComputeLayout(rootNode); realComputeLayout(rootNode);
return extractNodes(rootNode);
} }
function computeDOMLayout(node) { function computeDOMLayout(node) {

View File

@@ -1,17 +1,6 @@
var computeLayout = (function() { var computeLayout = (function() {
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;
}
function capitalizeFirst(str) { function capitalizeFirst(str) {
return str.charAt(0).toUpperCase() + str.slice(1); return str.charAt(0).toUpperCase() + str.slice(1);
} }
@@ -198,7 +187,7 @@ var computeLayout = (function() {
var CSS_POSITION_RELATIVE = 'relative'; var CSS_POSITION_RELATIVE = 'relative';
var CSS_POSITION_ABSOLUTE = 'absolute'; var CSS_POSITION_ABSOLUTE = 'absolute';
function layoutNode(node) { return function layoutNode(node) {
var/*css_flex_direction_t*/ mainAxis = getFlexDirection(node); var/*css_flex_direction_t*/ mainAxis = getFlexDirection(node);
var/*css_flex_direction_t*/ crossAxis = mainAxis === CSS_FLEX_DIRECTION_ROW ? var/*css_flex_direction_t*/ crossAxis = mainAxis === CSS_FLEX_DIRECTION_ROW ?
CSS_FLEX_DIRECTION_COLUMN : CSS_FLEX_DIRECTION_COLUMN :
@@ -459,13 +448,6 @@ var computeLayout = (function() {
} }
} }
} }
var fn = function(node) {
layoutNode(node);
return extractNodes(node);
};
fn.layoutNode = layoutNode;
return fn;
})(); })();