mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-30 17:33:21 +08:00
Use AT_MOST measurespec when onyl max dimension is defined
Summary: https://github.com/facebook/css-layout/pull/200 Make use of max dimension styles to allow root to be measured with AT_MOST measure mode Reviewed By: IanChilds Differential Revision: D3513505 fbshipit-source-id: 169f49717e896eb6270b52fb7115ce005aa0e3a8
This commit is contained in:
committed by
Facebook Github Bot 4
parent
3ddf3db551
commit
89a53b687c
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
// NOTE: this file is auto-copied from https://github.com/facebook/css-layout
|
||||
// @generated SignedSource<<0c8bd7e17fc12884003809cf282b0988>>
|
||||
// @generated SignedSource<<484d0d17453521463896ce24d946412b>>
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
@@ -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")) {
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
// NOTE: this file is auto-copied from https://github.com/facebook/css-layout
|
||||
// @generated SignedSource<<c5a4eadcd6d93bc6d989cba73caa12a7>>
|
||||
// @generated SignedSource<<deeb1f1cd05dfd70ce35f67c6eebf277>>
|
||||
|
||||
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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user