Skip to content

Commit

Permalink
[src/Layout.js]: Cleaner line loop in <Loop E> (alignContent layout) ;
Browse files Browse the repository at this point in the history
  • Loading branch information
prenaux committed May 9, 2015
1 parent 14e264f commit 09f0c12
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 45 deletions.
20 changes: 5 additions & 15 deletions src/Layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,18 +822,9 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth) {
}
}

// find the first node on the first line
for (i = 0; i < node->children_count; ) {
int startIndex = i;
int lineIndex = -1;

// get the first child on the current line
child = node->get_child(node->context, i);
if (getPositionType(child) != CSS_POSITION_RELATIVE) {
++i;
continue;
}
lineIndex = child->line_index;
int endIndex = 0;
for (i = 0; i < linesCount; ++i) {
int startIndex = endIndex;

// compute the line's height and find the endIndex
float lineHeight = 0;
Expand All @@ -842,7 +833,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth) {
if (getPositionType(child) != CSS_POSITION_RELATIVE) {
continue;
}
if (child->line_index != lineIndex) {
if (child->line_index != i) {
break;
}
if (!isUndefined(child->layout.dimensions[dim[crossAxis]])) {
Expand All @@ -852,7 +843,7 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth) {
);
}
}
int endIndex = ii;
endIndex = ii;
lineHeight += crossDimLead;

for (ii = startIndex; ii < endIndex; ++ii) {
Expand All @@ -877,7 +868,6 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth) {
}

currentLead += lineHeight;
i = endIndex;
}
}

Expand Down
20 changes: 5 additions & 15 deletions src/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,18 +700,9 @@ var computeLayout = (function() {
}
}

// find the first node on the first line
for (i = 0; i < node.children.length; ) {
var/*int*/ startIndex = i;
var/*int*/ lineIndex = -1;

// get the first child on the current line
child = node.children[i];
if (getPositionType(child) !== CSS_POSITION_RELATIVE) {
++i;
continue;
}
lineIndex = child.lineIndex;
var/*int*/ endIndex = 0;
for (i = 0; i < linesCount; ++i) {
var/*int*/ startIndex = endIndex;

// compute the line's height and find the endIndex
var/*float*/ lineHeight = 0;
Expand All @@ -720,7 +711,7 @@ var computeLayout = (function() {
if (getPositionType(child) !== CSS_POSITION_RELATIVE) {
continue;
}
if (child.lineIndex !== lineIndex) {
if (child.lineIndex !== i) {
break;
}
if (!isUndefined(child.layout[dim[crossAxis]])) {
Expand All @@ -730,7 +721,7 @@ var computeLayout = (function() {
);
}
}
var/*int*/ endIndex = ii;
endIndex = ii;
lineHeight += crossDimLead;

for (ii = startIndex; ii < endIndex; ++ii) {
Expand All @@ -755,7 +746,6 @@ var computeLayout = (function() {
}

currentLead += lineHeight;
i = endIndex;
}
}

Expand Down
20 changes: 5 additions & 15 deletions src/java/src/com/facebook/csslayout/LayoutEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -751,18 +751,9 @@ private static void layoutNodeImpl(
}
}

// find the first node on the first line
for (i = 0; i < node.getChildCount(); ) {
int startIndex = i;
int lineIndex = -1;

// get the first child on the current line
child = node.getChildAt(i);
if (getPositionType(child) != CSSPositionType.RELATIVE) {
++i;
continue;
}
lineIndex = child.lineIndex;
int endIndex = 0;
for (i = 0; i < linesCount; ++i) {
int startIndex = endIndex;

// compute the line's height and find the endIndex
float lineHeight = 0;
Expand All @@ -771,7 +762,7 @@ private static void layoutNodeImpl(
if (getPositionType(child) != CSSPositionType.RELATIVE) {
continue;
}
if (child.lineIndex != lineIndex) {
if (child.lineIndex != i) {
break;
}
if (!CSSConstants.isUndefined(getLayoutDimension(child, getDim(crossAxis)))) {
Expand All @@ -781,7 +772,7 @@ private static void layoutNodeImpl(
);
}
}
int endIndex = ii;
endIndex = ii;
lineHeight = lineHeight + crossDimLead;

for (ii = startIndex; ii < endIndex; ++ii) {
Expand All @@ -806,7 +797,6 @@ private static void layoutNodeImpl(
}

currentLead = currentLead + lineHeight;
i = endIndex;
}
}

Expand Down

0 comments on commit 09f0c12

Please sign in to comment.