Fix issue where padding for box sizing is resolved against wrong reference length (#1715)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1715 X-link: https://github.com/facebook/react-native/pull/46799 Content box impl had a bug where we resolved padding % against the same reference length as the dimensions. Padding should always be against containing block's width. This is also true for width, but not for height, which should be against containing block's height. This just pipes the width into our box sizing functions. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D63787577 fbshipit-source-id: e512338770f25b66506cabab5a7cde8f04397ea0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
990ec920ad
commit
e69fcb26bb
@@ -5,7 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* clang-format off
|
||||
* @generated SignedSource<<36f0f519320608e2c5c6eb6666be7efc>>
|
||||
* @generated SignedSource<<24bf988fec7e7f72a8f46ba74df63399>>
|
||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html
|
||||
*/
|
||||
|
||||
@@ -446,14 +446,15 @@ TEST(YogaTest, box_sizing_content_box_padding_only_percent) {
|
||||
YGNodeRef root = YGNodeNewWithConfig(config);
|
||||
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
|
||||
YGNodeStyleSetWidth(root, 100);
|
||||
YGNodeStyleSetHeight(root, 100);
|
||||
YGNodeStyleSetHeight(root, 150);
|
||||
|
||||
YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeLeft, 10);
|
||||
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeTop, 10);
|
||||
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeRight, 10);
|
||||
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeBottom, 10);
|
||||
YGNodeStyleSetWidthPercent(root_child0, 50);
|
||||
YGNodeStyleSetWidth(root_child0, 50);
|
||||
YGNodeStyleSetHeight(root_child0, 75);
|
||||
YGNodeStyleSetBoxSizing(root_child0, YGBoxSizingContentBox);
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
@@ -461,24 +462,24 @@ TEST(YogaTest, box_sizing_content_box_padding_only_percent) {
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
||||
ASSERT_FLOAT_EQ(95, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
||||
ASSERT_FLOAT_EQ(95, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
@@ -521,38 +522,39 @@ TEST(YogaTest, box_sizing_border_box_padding_only_percent) {
|
||||
YGNodeRef root = YGNodeNewWithConfig(config);
|
||||
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
|
||||
YGNodeStyleSetWidth(root, 100);
|
||||
YGNodeStyleSetHeight(root, 100);
|
||||
YGNodeStyleSetHeight(root, 150);
|
||||
|
||||
YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeLeft, 10);
|
||||
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeTop, 10);
|
||||
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeRight, 10);
|
||||
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeBottom, 10);
|
||||
YGNodeStyleSetWidthPercent(root_child0, 50);
|
||||
YGNodeStyleSetWidth(root_child0, 50);
|
||||
YGNodeStyleSetHeight(root_child0, 75);
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
||||
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
||||
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
|
Reference in New Issue
Block a user