Simplified logic distributing flex space.
This commit is contained in:
17
src/Layout.c
17
src/Layout.c
@@ -579,8 +579,9 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth) {
|
|||||||
float baseMainDim;
|
float baseMainDim;
|
||||||
float boundMainDim;
|
float boundMainDim;
|
||||||
|
|
||||||
// Iterate over every child-> If the flex share of remaining space doesn't
|
// Iterate over every child in the axis. If the flex share of remaining
|
||||||
// meet min/max bounds, remove this child from flex calculations.
|
// space doesn't meet min/max bounds, remove this child from flex
|
||||||
|
// calculations.
|
||||||
for (i = startLine; i < endLine; ++i) {
|
for (i = startLine; i < endLine; ++i) {
|
||||||
child = node->get_child(node->context, i);
|
child = node->get_child(node->context, i);
|
||||||
if (isFlex(child)) {
|
if (isFlex(child)) {
|
||||||
@@ -609,15 +610,9 @@ static void layoutNodeImpl(css_node_t *node, float parentMaxWidth) {
|
|||||||
if (isFlex(child)) {
|
if (isFlex(child)) {
|
||||||
// At this point we know the final size of the element in the main
|
// At this point we know the final size of the element in the main
|
||||||
// dimension
|
// dimension
|
||||||
baseMainDim = flexibleMainDim * getFlex(child) +
|
child->layout.dimensions[dim[mainAxis]] = boundAxis(child, mainAxis,
|
||||||
getPaddingAndBorderAxis(child, mainAxis);
|
flexibleMainDim * getFlex(child) + getPaddingAndBorderAxis(child, mainAxis)
|
||||||
boundMainDim = boundAxis(child, mainAxis, baseMainDim);
|
);
|
||||||
|
|
||||||
if (baseMainDim == boundMainDim) {
|
|
||||||
child->layout.dimensions[dim[mainAxis]] = baseMainDim;
|
|
||||||
} else {
|
|
||||||
child->layout.dimensions[dim[mainAxis]] = boundMainDim;
|
|
||||||
}
|
|
||||||
|
|
||||||
maxWidth = CSS_UNDEFINED;
|
maxWidth = CSS_UNDEFINED;
|
||||||
if (isDimDefined(node, CSS_FLEX_DIRECTION_ROW)) {
|
if (isDimDefined(node, CSS_FLEX_DIRECTION_ROW)) {
|
||||||
|
@@ -501,15 +501,9 @@ var computeLayout = (function() {
|
|||||||
if (isFlex(child)) {
|
if (isFlex(child)) {
|
||||||
// At this point we know the final size of the element in the main
|
// At this point we know the final size of the element in the main
|
||||||
// dimension
|
// dimension
|
||||||
baseMainDim = flexibleMainDim * getFlex(child) +
|
child.layout[dim[mainAxis]] = boundAxis(child, mainAxis,
|
||||||
getPaddingAndBorderAxis(child, mainAxis);
|
flexibleMainDim * getFlex(child) + getPaddingAndBorderAxis(child, mainAxis)
|
||||||
boundMainDim = boundAxis(child, mainAxis, baseMainDim);
|
);
|
||||||
|
|
||||||
if (baseMainDim === boundMainDim) {
|
|
||||||
child.layout[dim[mainAxis]] = baseMainDim;
|
|
||||||
} else {
|
|
||||||
child.layout[dim[mainAxis]] = boundMainDim;
|
|
||||||
}
|
|
||||||
|
|
||||||
maxWidth = CSS_UNDEFINED;
|
maxWidth = CSS_UNDEFINED;
|
||||||
if (isDimDefined(node, CSS_FLEX_DIRECTION_ROW)) {
|
if (isDimDefined(node, CSS_FLEX_DIRECTION_ROW)) {
|
||||||
|
@@ -524,8 +524,9 @@ public class LayoutEngine {
|
|||||||
float baseMainDim;
|
float baseMainDim;
|
||||||
float boundMainDim;
|
float boundMainDim;
|
||||||
|
|
||||||
// Iterate over every child. If the flex share of remaining space doesn't
|
// Iterate over every child in the axis. If the flex share of remaining
|
||||||
// meet min/max bounds, remove this child from flex calculations.
|
// space doesn't meet min/max bounds, remove this child from flex
|
||||||
|
// calculations.
|
||||||
for (i = startLine; i < endLine; ++i) {
|
for (i = startLine; i < endLine; ++i) {
|
||||||
child = node.getChildAt(i);
|
child = node.getChildAt(i);
|
||||||
if (isFlex(child)) {
|
if (isFlex(child)) {
|
||||||
@@ -554,15 +555,9 @@ public class LayoutEngine {
|
|||||||
if (isFlex(child)) {
|
if (isFlex(child)) {
|
||||||
// At this point we know the final size of the element in the main
|
// At this point we know the final size of the element in the main
|
||||||
// dimension
|
// dimension
|
||||||
baseMainDim = flexibleMainDim * getFlex(child) +
|
setLayoutDimension(child, getDim(mainAxis), boundAxis(child, mainAxis,
|
||||||
getPaddingAndBorderAxis(child, mainAxis);
|
flexibleMainDim * getFlex(child) + getPaddingAndBorderAxis(child, mainAxis)
|
||||||
boundMainDim = boundAxis(child, mainAxis, baseMainDim);
|
));
|
||||||
|
|
||||||
if (baseMainDim == boundMainDim) {
|
|
||||||
setLayoutDimension(child, getDim(mainAxis), baseMainDim);
|
|
||||||
} else {
|
|
||||||
setLayoutDimension(child, getDim(mainAxis), boundMainDim);
|
|
||||||
}
|
|
||||||
|
|
||||||
maxWidth = CSSConstants.UNDEFINED;
|
maxWidth = CSSConstants.UNDEFINED;
|
||||||
if (isDimDefined(node, CSSFlexDirection.ROW)) {
|
if (isDimDefined(node, CSSFlexDirection.ROW)) {
|
||||||
|
Reference in New Issue
Block a user