mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-02 09:08:58 +08:00
Fix width being ignored when has a value of 0
Summary: 8f6a96adbc added a test in isDimDefined that checks if `value > 0.0`, but unfortunately, it did not faithfully port the JavaScript version which is `value >= 0.0`: https://github.com/facebook/css-layout/blob/master/src/Layout.js#L306. Sadly, no test covered this so it went unnoticed.
Closes https://github.com/facebook/css-layout/pull/134
Reviewed By: @svcscm
Differential Revision: D2481773
Pulled By: @vjeux
This commit is contained in:
committed by
facebook-github-bot-8
parent
656126a2f1
commit
bd36e40258
@@ -451,7 +451,7 @@ static float getDimWithMargin(css_node_t *node, css_flex_direction_t axis) {
|
||||
|
||||
static bool isDimDefined(css_node_t *node, css_flex_direction_t axis) {
|
||||
float value = node->style.dimensions[dim[axis]];
|
||||
return !isUndefined(value) && value > 0.0;
|
||||
return !isUndefined(value) && value >= 0.0;
|
||||
}
|
||||
|
||||
static bool isPosDefined(css_node_t *node, css_position_t position) {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
// NOTE: this file is auto-copied from https://github.com/facebook/css-layout
|
||||
// @generated SignedSource<<4cabe0d63a4ed878edf6b5be8762746a>>
|
||||
// @generated SignedSource<<b8b881922a917015f33e0b1d70b8202b>>
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
@@ -256,7 +256,7 @@ public class LayoutEngine {
|
||||
boolean isResolvedRowDimDefined = !Float.isNaN(node.layout.dimensions[dim[resolvedRowAxis]]);
|
||||
|
||||
float width = CSSConstants.UNDEFINED;
|
||||
if ((!Float.isNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] > 0.0)) {
|
||||
if ((!Float.isNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] >= 0.0)) {
|
||||
width = node.style.dimensions[DIMENSION_WIDTH];
|
||||
} else if (isResolvedRowDimDefined) {
|
||||
width = node.layout.dimensions[dim[resolvedRowAxis]];
|
||||
@@ -269,8 +269,8 @@ public class LayoutEngine {
|
||||
// We only need to give a dimension for the text if we haven't got any
|
||||
// for it computed yet. It can either be from the style attribute or because
|
||||
// the element is flexible.
|
||||
boolean isRowUndefined = !(!Float.isNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] > 0.0) && !isResolvedRowDimDefined;
|
||||
boolean isColumnUndefined = !(!Float.isNaN(node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]) && node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] > 0.0) &&
|
||||
boolean isRowUndefined = !(!Float.isNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] >= 0.0) && !isResolvedRowDimDefined;
|
||||
boolean isColumnUndefined = !(!Float.isNaN(node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]) && node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0) &&
|
||||
Float.isNaN(node.layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]);
|
||||
|
||||
// Let's not measure the text if we already know both dimensions
|
||||
@@ -381,7 +381,7 @@ public class LayoutEngine {
|
||||
if (alignItem == CSSAlign.STRETCH &&
|
||||
child.style.positionType == CSSPositionType.RELATIVE &&
|
||||
isCrossDimDefined &&
|
||||
!(!Float.isNaN(child.style.dimensions[dim[crossAxis]]) && child.style.dimensions[dim[crossAxis]] > 0.0)) {
|
||||
!(!Float.isNaN(child.style.dimensions[dim[crossAxis]]) && child.style.dimensions[dim[crossAxis]] >= 0.0)) {
|
||||
child.layout.dimensions[dim[crossAxis]] = Math.max(
|
||||
boundAxis(child, crossAxis, node.layout.dimensions[dim[crossAxis]] -
|
||||
paddingAndBorderAxisCross - (child.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + child.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]))),
|
||||
@@ -404,7 +404,7 @@ public class LayoutEngine {
|
||||
for (ii = 0; ii < 2; ii++) {
|
||||
axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;
|
||||
if (!Float.isNaN(node.layout.dimensions[dim[axis]]) &&
|
||||
!(!Float.isNaN(child.style.dimensions[dim[axis]]) && child.style.dimensions[dim[axis]] > 0.0) &&
|
||||
!(!Float.isNaN(child.style.dimensions[dim[axis]]) && child.style.dimensions[dim[axis]] >= 0.0) &&
|
||||
!Float.isNaN(child.style.position[leading[axis]]) &&
|
||||
!Float.isNaN(child.style.position[trailing[axis]])) {
|
||||
child.layout.dimensions[dim[axis]] = Math.max(
|
||||
@@ -448,7 +448,7 @@ public class LayoutEngine {
|
||||
} else {
|
||||
maxWidth = CSSConstants.UNDEFINED;
|
||||
if (!isMainRowDirection) {
|
||||
if ((!Float.isNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] > 0.0)) {
|
||||
if ((!Float.isNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] >= 0.0)) {
|
||||
maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] -
|
||||
paddingAndBorderAxisResolvedRow;
|
||||
} else {
|
||||
@@ -582,7 +582,7 @@ public class LayoutEngine {
|
||||
);
|
||||
|
||||
maxWidth = CSSConstants.UNDEFINED;
|
||||
if ((!Float.isNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] > 0.0)) {
|
||||
if ((!Float.isNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] >= 0.0)) {
|
||||
maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] -
|
||||
paddingAndBorderAxisResolvedRow;
|
||||
} else if (!isMainRowDirection) {
|
||||
@@ -877,7 +877,7 @@ public class LayoutEngine {
|
||||
axis = (ii != 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;
|
||||
|
||||
if (!Float.isNaN(node.layout.dimensions[dim[axis]]) &&
|
||||
!(!Float.isNaN(currentAbsoluteChild.style.dimensions[dim[axis]]) && currentAbsoluteChild.style.dimensions[dim[axis]] > 0.0) &&
|
||||
!(!Float.isNaN(currentAbsoluteChild.style.dimensions[dim[axis]]) && currentAbsoluteChild.style.dimensions[dim[axis]] >= 0.0) &&
|
||||
!Float.isNaN(currentAbsoluteChild.style.position[leading[axis]]) &&
|
||||
!Float.isNaN(currentAbsoluteChild.style.position[trailing[axis]])) {
|
||||
currentAbsoluteChild.layout.dimensions[dim[axis]] = Math.max(
|
||||
|
||||
Reference in New Issue
Block a user