Revert D9286928: [yoga] Solve width bug when the size is less than min
Differential Revision: D9286928 Original commit changeset: 915269602cda fbshipit-source-id: a4c23bf335b82fbbf3928a524a61374a6cf6ffb1
This commit is contained in:
committed by
Facebook Github Bot
parent
b872751d68
commit
abc9fdb37c
@@ -86,18 +86,3 @@
|
|||||||
<div style="height: 10px;"></div>
|
<div style="height: 10px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="justify_content_min_width_with_padding_child_width_greater_than_parent" style="width: 1000px; height: 1584px;">
|
|
||||||
<div style="flex-direction: row; align-content: stretch;">
|
|
||||||
<div style="flex-direction: row; justify-content: center; align-content: stretch; min-width: 400px; padding-left: 100px; padding-right: 100px;">
|
|
||||||
<div style="height: 100px; width: 300px; align-content: stretch; flex-direction: row;"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="justify_content_min_width_with_padding_child_width_greater_than_parent" style="width: 1080px; height: 1584px;">
|
|
||||||
<div style="flex-direction: row; align-content: stretch;">
|
|
||||||
<div style="flex-direction: row; justify-content: center; align-content: stretch; min-width: 400px; padding-left: 100px; padding-right: 100px;">
|
|
||||||
<div style="height: 100px; width: 199px; align-content: stretch; flex-direction: row;"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
@@ -1,12 +1,11 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
// @Generated by gentest/gentest.rb from
|
|
||||||
// gentest/fixtures/YGJustifyContentTest.html
|
// @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
@@ -736,164 +735,6 @@ TEST(YogaTest, justify_content_row_min_width_and_margin) {
|
|||||||
YGConfigFree(config);
|
YGConfigFree(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(
|
|
||||||
YogaTest,
|
|
||||||
justify_content_min_width_with_padding_child_width_greater_than_parent) {
|
|
||||||
const YGConfigRef config = YGConfigNew();
|
|
||||||
|
|
||||||
const YGNodeRef root = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeStyleSetAlignContent(root, YGAlignStretch);
|
|
||||||
YGNodeStyleSetWidth(root, 1000);
|
|
||||||
YGNodeStyleSetHeight(root, 1584);
|
|
||||||
|
|
||||||
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
|
||||||
YGNodeStyleSetAlignContent(root_child0, YGAlignStretch);
|
|
||||||
YGNodeInsertChild(root, root_child0, 0);
|
|
||||||
|
|
||||||
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeStyleSetFlexDirection(root_child0_child0, YGFlexDirectionRow);
|
|
||||||
YGNodeStyleSetJustifyContent(root_child0_child0, YGJustifyCenter);
|
|
||||||
YGNodeStyleSetAlignContent(root_child0_child0, YGAlignStretch);
|
|
||||||
YGNodeStyleSetMinWidth(root_child0_child0, 400);
|
|
||||||
YGNodeStyleSetPadding(root_child0_child0, YGEdgeHorizontal, 100);
|
|
||||||
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
|
||||||
|
|
||||||
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeStyleSetFlexDirection(root_child0_child0_child0, YGFlexDirectionRow);
|
|
||||||
YGNodeStyleSetAlignContent(root_child0_child0_child0, YGAlignStretch);
|
|
||||||
YGNodeStyleSetWidth(root_child0_child0_child0, 300);
|
|
||||||
YGNodeStyleSetHeight(root_child0_child0_child0, 100);
|
|
||||||
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
|
||||||
|
|
||||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
||||||
ASSERT_FLOAT_EQ(1000, YGNodeLayoutGetWidth(root));
|
|
||||||
ASSERT_FLOAT_EQ(1584, YGNodeLayoutGetHeight(root));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(1000, YGNodeLayoutGetWidth(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
|
||||||
|
|
||||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
||||||
ASSERT_FLOAT_EQ(1000, YGNodeLayoutGetWidth(root));
|
|
||||||
ASSERT_FLOAT_EQ(1584, YGNodeLayoutGetHeight(root));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(1000, YGNodeLayoutGetWidth(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
|
||||||
|
|
||||||
YGNodeFreeRecursive(root);
|
|
||||||
|
|
||||||
YGConfigFree(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(
|
|
||||||
YogaTest,
|
|
||||||
justify_content_min_width_with_padding_child_width_lower_than_parent) {
|
|
||||||
const YGConfigRef config = YGConfigNew();
|
|
||||||
|
|
||||||
const YGNodeRef root = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeStyleSetAlignContent(root, YGAlignStretch);
|
|
||||||
YGNodeStyleSetWidth(root, 1080);
|
|
||||||
YGNodeStyleSetHeight(root, 1584);
|
|
||||||
|
|
||||||
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
|
||||||
YGNodeStyleSetAlignContent(root_child0, YGAlignStretch);
|
|
||||||
YGNodeInsertChild(root, root_child0, 0);
|
|
||||||
|
|
||||||
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeStyleSetFlexDirection(root_child0_child0, YGFlexDirectionRow);
|
|
||||||
YGNodeStyleSetJustifyContent(root_child0_child0, YGJustifyCenter);
|
|
||||||
YGNodeStyleSetAlignContent(root_child0_child0, YGAlignStretch);
|
|
||||||
YGNodeStyleSetMinWidth(root_child0_child0, 400);
|
|
||||||
YGNodeStyleSetPadding(root_child0_child0, YGEdgeHorizontal, 100);
|
|
||||||
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
|
||||||
|
|
||||||
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeStyleSetFlexDirection(root_child0_child0_child0, YGFlexDirectionRow);
|
|
||||||
YGNodeStyleSetAlignContent(root_child0_child0_child0, YGAlignStretch);
|
|
||||||
YGNodeStyleSetWidth(root_child0_child0_child0, 199);
|
|
||||||
YGNodeStyleSetHeight(root_child0_child0_child0, 100);
|
|
||||||
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
|
||||||
|
|
||||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
||||||
ASSERT_FLOAT_EQ(1080, YGNodeLayoutGetWidth(root));
|
|
||||||
ASSERT_FLOAT_EQ(1584, YGNodeLayoutGetHeight(root));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(1080, YGNodeLayoutGetWidth(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(101, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(199, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
|
||||||
|
|
||||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
||||||
ASSERT_FLOAT_EQ(1080, YGNodeLayoutGetWidth(root));
|
|
||||||
ASSERT_FLOAT_EQ(1584, YGNodeLayoutGetHeight(root));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(1080, YGNodeLayoutGetWidth(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(680, YGNodeLayoutGetLeft(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(101, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(199, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
|
||||||
//
|
|
||||||
YGNodeFreeRecursive(root);
|
|
||||||
|
|
||||||
YGConfigFree(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(YogaTest, justify_content_row_max_width_and_margin) {
|
TEST(YogaTest, justify_content_row_max_width_and_margin) {
|
||||||
const YGConfigRef config = YGConfigNew();
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
* This source code is licensed under the MIT license found in the
|
||||||
* file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html
|
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPaddingTest.html
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
@@ -2396,13 +2396,20 @@ static void YGJustifyMainAxis(
|
|||||||
const bool& performLayout) {
|
const bool& performLayout) {
|
||||||
const YGStyle& style = node->getStyle();
|
const YGStyle& style = node->getStyle();
|
||||||
|
|
||||||
// If we are using "at most" rules in the main axis, make sure that
|
// If we are using "at most" rules in the main axis. Calculate the remaining
|
||||||
// remainingFreeSpace is 0 when min main dimension is not given
|
// space when constraint by the min size defined for the main axis.
|
||||||
if (measureModeMainDim == YGMeasureModeAtMost &&
|
if (measureModeMainDim == YGMeasureModeAtMost &&
|
||||||
collectedFlexItemsValues.remainingFreeSpace > 0) {
|
collectedFlexItemsValues.remainingFreeSpace > 0) {
|
||||||
if (style.minDimensions[dim[mainAxis]].unit == YGUnitUndefined ||
|
if (style.minDimensions[dim[mainAxis]].unit != YGUnitUndefined &&
|
||||||
YGResolveValue(style.minDimensions[dim[mainAxis]], mainAxisownerSize)
|
!YGResolveValue(style.minDimensions[dim[mainAxis]], mainAxisownerSize)
|
||||||
.isUndefined()) {
|
.isUndefined()) {
|
||||||
|
collectedFlexItemsValues.remainingFreeSpace = YGFloatMax(
|
||||||
|
0,
|
||||||
|
YGUnwrapFloatOptional(YGResolveValue(
|
||||||
|
style.minDimensions[dim[mainAxis]], mainAxisownerSize)) -
|
||||||
|
(availableInnerMainDim -
|
||||||
|
collectedFlexItemsValues.remainingFreeSpace));
|
||||||
|
} else {
|
||||||
collectedFlexItemsValues.remainingFreeSpace = 0;
|
collectedFlexItemsValues.remainingFreeSpace = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user