diff --git a/React/Layout/Layout.c b/React/Layout/Layout.c index da1e2559f..22412a8d5 100644 --- a/React/Layout/Layout.c +++ b/React/Layout/Layout.c @@ -7,7 +7,7 @@ */ // NOTE: this file is auto-copied from https://github.com/facebook/css-layout -// @generated SignedSource<<0c8bd7e17fc12884003809cf282b0988>> +// @generated SignedSource<<484d0d17453521463896ce24d946412b>> #include @@ -1786,17 +1786,28 @@ void layoutNode(css_node_t* node, float availableWidth, float availableHeight, c // parameters don't change. gCurrentGenerationCount++; - // If the caller didn't specify a height/width, use the dimensions - // specified in the style. - if (isUndefined(availableWidth) && isStyleDimDefined(node, CSS_FLEX_DIRECTION_ROW)) { - availableWidth = node->style.dimensions[CSS_WIDTH] + getMarginAxis(node, CSS_FLEX_DIRECTION_ROW); - } - if (isUndefined(availableHeight) && isStyleDimDefined(node, CSS_FLEX_DIRECTION_COLUMN)) { - availableHeight = node->style.dimensions[CSS_HEIGHT] + getMarginAxis(node, CSS_FLEX_DIRECTION_COLUMN); + css_measure_mode_t widthMeasureMode = CSS_MEASURE_MODE_UNDEFINED; + css_measure_mode_t heightMeasureMode = CSS_MEASURE_MODE_UNDEFINED; + + if (!isUndefined(availableWidth)) { + widthMeasureMode = CSS_MEASURE_MODE_EXACTLY; + } else if (isStyleDimDefined(node, CSS_FLEX_DIRECTION_ROW)) { + availableWidth = node->style.dimensions[dim[CSS_FLEX_DIRECTION_ROW]] + getMarginAxis(node, CSS_FLEX_DIRECTION_ROW); + widthMeasureMode = CSS_MEASURE_MODE_EXACTLY; + } else if (node->style.maxDimensions[CSS_WIDTH] >= 0.0) { + availableWidth = node->style.maxDimensions[CSS_WIDTH]; + widthMeasureMode = CSS_MEASURE_MODE_AT_MOST; } - css_measure_mode_t widthMeasureMode = isUndefined(availableWidth) ? CSS_MEASURE_MODE_UNDEFINED : CSS_MEASURE_MODE_EXACTLY; - css_measure_mode_t heightMeasureMode = isUndefined(availableHeight) ? CSS_MEASURE_MODE_UNDEFINED : CSS_MEASURE_MODE_EXACTLY; + if (!isUndefined(availableHeight)) { + heightMeasureMode = CSS_MEASURE_MODE_EXACTLY; + } else if (isStyleDimDefined(node, CSS_FLEX_DIRECTION_COLUMN)) { + availableHeight = node->style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] + getMarginAxis(node, CSS_FLEX_DIRECTION_COLUMN); + heightMeasureMode = CSS_MEASURE_MODE_EXACTLY; + } else if (node->style.maxDimensions[CSS_HEIGHT] >= 0.0) { + availableHeight = node->style.maxDimensions[CSS_HEIGHT]; + heightMeasureMode = CSS_MEASURE_MODE_AT_MOST; + } if (layoutNodeInternal(node, availableWidth, availableHeight, parentDirection, widthMeasureMode, heightMeasureMode, true, "initial")) { diff --git a/React/Layout/README b/React/Layout/README index e04447bbc..9d85b26ff 100644 --- a/React/Layout/README +++ b/React/Layout/README @@ -1,7 +1,7 @@ The source of truth for css-layout is: https://github.com/facebook/css-layout The code here should be kept in sync with GitHub. -HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/383d8a6b3dcbdb978e012e29040e1a43157765c6 +HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/a1f36b53f5464c8ee7abc311765dc3ecb1b879c6 There is generated code in: - README (this file) diff --git a/ReactAndroid/src/main/java/com/facebook/csslayout/LayoutEngine.java b/ReactAndroid/src/main/java/com/facebook/csslayout/LayoutEngine.java index 042b25366..582fc44aa 100644 --- a/ReactAndroid/src/main/java/com/facebook/csslayout/LayoutEngine.java +++ b/ReactAndroid/src/main/java/com/facebook/csslayout/LayoutEngine.java @@ -7,7 +7,7 @@ */ // NOTE: this file is auto-copied from https://github.com/facebook/css-layout -// @generated SignedSource<> +// @generated SignedSource<> package com.facebook.csslayout; @@ -234,19 +234,30 @@ public class LayoutEngine { // parameters don't change. layoutContext.currentGenerationCount++; - // If the caller didn't specify a height/width, use the dimensions - // specified in the style. - if (Float.isNaN(availableWidth) && node.style.dimensions[DIMENSION_WIDTH] >= 0.0) { + CSSMeasureMode widthMeasureMode = CSSMeasureMode.UNDEFINED; + CSSMeasureMode heightMeasureMode = CSSMeasureMode.UNDEFINED; + + if (!Float.isNaN(availableWidth)) { + widthMeasureMode = CSSMeasureMode.EXACTLY; + } else if (node.style.dimensions[DIMENSION_WIDTH] >= 0.0) { float marginAxisRow = (node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW])); availableWidth = node.style.dimensions[DIMENSION_WIDTH] + marginAxisRow; - } - if (Float.isNaN(availableHeight) && node.style.dimensions[DIMENSION_HEIGHT] >= 0.0) { - float marginAxisColumn = (node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])); - availableHeight = node.style.dimensions[DIMENSION_HEIGHT] + marginAxisColumn; + widthMeasureMode = CSSMeasureMode.EXACTLY; + } else if (node.style.maxWidth >= 0.0) { + availableWidth = node.style.maxWidth; + widthMeasureMode = CSSMeasureMode.AT_MOST; } - CSSMeasureMode widthMeasureMode = Float.isNaN(availableWidth) ? CSSMeasureMode.UNDEFINED : CSSMeasureMode.EXACTLY; - CSSMeasureMode heightMeasureMode = Float.isNaN(availableHeight) ? CSSMeasureMode.UNDEFINED : CSSMeasureMode.EXACTLY; + if (!Float.isNaN(availableHeight)) { + heightMeasureMode = CSSMeasureMode.EXACTLY; + } else if (node.style.dimensions[DIMENSION_HEIGHT] >= 0.0) { + float marginAxisColumn = (node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])); + availableHeight = node.style.dimensions[DIMENSION_HEIGHT] + marginAxisColumn; + heightMeasureMode = CSSMeasureMode.EXACTLY; + } else if (node.style.maxHeight >= 0.0) { + availableHeight = node.style.maxHeight; + heightMeasureMode = CSSMeasureMode.AT_MOST; + } if (layoutNodeInternal(layoutContext, node, availableWidth, availableHeight, parentDirection, widthMeasureMode, heightMeasureMode, true, "initial")) { setPosition(node, node.layout.direction); diff --git a/ReactAndroid/src/main/java/com/facebook/csslayout/README b/ReactAndroid/src/main/java/com/facebook/csslayout/README index e04447bbc..9d85b26ff 100644 --- a/ReactAndroid/src/main/java/com/facebook/csslayout/README +++ b/ReactAndroid/src/main/java/com/facebook/csslayout/README @@ -1,7 +1,7 @@ The source of truth for css-layout is: https://github.com/facebook/css-layout The code here should be kept in sync with GitHub. -HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/383d8a6b3dcbdb978e012e29040e1a43157765c6 +HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/a1f36b53f5464c8ee7abc311765dc3ecb1b879c6 There is generated code in: - README (this file)