Revert D76793705: Fix possible invalid measurements when width or height is zero pixels
Differential Revision: D76793705 Original commit changeset: ea4c00e68891 Original Phabricator Diff: D76793705 fbshipit-source-id: 95d6b66ab08e073da9fb07fd4094a7e30e2f453b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
27d632c697
commit
30291398f3
@@ -240,14 +240,3 @@
|
|||||||
<div style="position:relative; width:50px; height:50px;">
|
<div style="position:relative; width:50px; height:50px;">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="align_items_non_stretch_s526008"
|
|
||||||
style="flex-direction: column; width: 400px; height: 400px;">
|
|
||||||
<div style="flex-direction: row;">
|
|
||||||
<div style="flex-direction: column; align-items: flex-start;">
|
|
||||||
<div>
|
|
||||||
<div style="width: 0; height: 10px;"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* @generated SignedSource<<84597dd8b2c4f3aac1f21abe68f25308>>
|
* @generated SignedSource<<e8d11c0e97041bb2f1487f0d87363fdc>>
|
||||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -2293,86 +2293,6 @@ public class YGAlignItemsTest {
|
|||||||
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
|
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_align_items_non_stretch_s526008() {
|
|
||||||
YogaConfig config = YogaConfigFactory.create();
|
|
||||||
|
|
||||||
final YogaNode root = createNode(config);
|
|
||||||
root.setPositionType(YogaPositionType.ABSOLUTE);
|
|
||||||
root.setWidth(400f);
|
|
||||||
root.setHeight(400f);
|
|
||||||
|
|
||||||
final YogaNode root_child0 = createNode(config);
|
|
||||||
root_child0.setFlexDirection(YogaFlexDirection.ROW);
|
|
||||||
root.addChildAt(root_child0, 0);
|
|
||||||
|
|
||||||
final YogaNode root_child0_child0 = createNode(config);
|
|
||||||
root_child0_child0.setAlignItems(YogaAlign.FLEX_START);
|
|
||||||
root_child0.addChildAt(root_child0_child0, 0);
|
|
||||||
|
|
||||||
final YogaNode root_child0_child0_child0 = createNode(config);
|
|
||||||
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
|
||||||
|
|
||||||
final YogaNode root_child0_child0_child0_child0 = createNode(config);
|
|
||||||
root_child0_child0_child0_child0.setHeight(10f);
|
|
||||||
root_child0_child0_child0.addChildAt(root_child0_child0_child0_child0, 0);
|
|
||||||
root.setDirection(YogaDirection.LTR);
|
|
||||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
||||||
|
|
||||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
||||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
||||||
assertEquals(400f, root.getLayoutWidth(), 0.0f);
|
|
||||||
assertEquals(400f, root.getLayoutHeight(), 0.0f);
|
|
||||||
|
|
||||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
||||||
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
|
|
||||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
||||||
|
|
||||||
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
||||||
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
|
|
||||||
|
|
||||||
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
|
||||||
assertEquals(10f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
|
||||||
|
|
||||||
assertEquals(0f, root_child0_child0_child0_child0.getLayoutX(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0_child0_child0_child0.getLayoutY(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0_child0_child0_child0.getLayoutWidth(), 0.0f);
|
|
||||||
assertEquals(10f, root_child0_child0_child0_child0.getLayoutHeight(), 0.0f);
|
|
||||||
|
|
||||||
root.setDirection(YogaDirection.RTL);
|
|
||||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
|
||||||
|
|
||||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
|
||||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
|
||||||
assertEquals(400f, root.getLayoutWidth(), 0.0f);
|
|
||||||
assertEquals(400f, root.getLayoutHeight(), 0.0f);
|
|
||||||
|
|
||||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
|
||||||
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
|
|
||||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
|
||||||
|
|
||||||
assertEquals(400f, root_child0_child0.getLayoutX(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
|
|
||||||
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
|
|
||||||
|
|
||||||
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
|
||||||
assertEquals(10f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
|
||||||
|
|
||||||
assertEquals(0f, root_child0_child0_child0_child0.getLayoutX(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0_child0_child0_child0.getLayoutY(), 0.0f);
|
|
||||||
assertEquals(0f, root_child0_child0_child0_child0.getLayoutWidth(), 0.0f);
|
|
||||||
assertEquals(10f, root_child0_child0_child0_child0.getLayoutHeight(), 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
private YogaNode createNode(YogaConfig config) {
|
private YogaNode createNode(YogaConfig config) {
|
||||||
return mNodeFactory.create(config);
|
return mNodeFactory.create(config);
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* @generated SignedSource<<fd80af208d8635435f86ffa8f3810b39>>
|
* @generated SignedSource<<075a0b67003e5c4a1f51bd99da71c700>>
|
||||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -2442,88 +2442,3 @@ test('align_stretch_with_row_reverse', () => {
|
|||||||
config.free();
|
config.free();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
test('align_items_non_stretch_s526008', () => {
|
|
||||||
const config = Yoga.Config.create();
|
|
||||||
let root;
|
|
||||||
|
|
||||||
try {
|
|
||||||
root = Yoga.Node.create(config);
|
|
||||||
root.setPositionType(PositionType.Absolute);
|
|
||||||
root.setWidth(400);
|
|
||||||
root.setHeight(400);
|
|
||||||
|
|
||||||
const root_child0 = Yoga.Node.create(config);
|
|
||||||
root_child0.setFlexDirection(FlexDirection.Row);
|
|
||||||
root.insertChild(root_child0, 0);
|
|
||||||
|
|
||||||
const root_child0_child0 = Yoga.Node.create(config);
|
|
||||||
root_child0_child0.setAlignItems(Align.FlexStart);
|
|
||||||
root_child0.insertChild(root_child0_child0, 0);
|
|
||||||
|
|
||||||
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
||||||
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
||||||
|
|
||||||
const root_child0_child0_child0_child0 = Yoga.Node.create(config);
|
|
||||||
root_child0_child0_child0_child0.setHeight(10);
|
|
||||||
root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0);
|
|
||||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
||||||
|
|
||||||
expect(root.getComputedLeft()).toBe(0);
|
|
||||||
expect(root.getComputedTop()).toBe(0);
|
|
||||||
expect(root.getComputedWidth()).toBe(400);
|
|
||||||
expect(root.getComputedHeight()).toBe(400);
|
|
||||||
|
|
||||||
expect(root_child0.getComputedLeft()).toBe(0);
|
|
||||||
expect(root_child0.getComputedTop()).toBe(0);
|
|
||||||
expect(root_child0.getComputedWidth()).toBe(400);
|
|
||||||
expect(root_child0.getComputedHeight()).toBe(10);
|
|
||||||
|
|
||||||
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
||||||
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
||||||
expect(root_child0_child0.getComputedWidth()).toBe(0);
|
|
||||||
expect(root_child0_child0.getComputedHeight()).toBe(10);
|
|
||||||
|
|
||||||
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
||||||
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
||||||
expect(root_child0_child0_child0.getComputedWidth()).toBe(0);
|
|
||||||
expect(root_child0_child0_child0.getComputedHeight()).toBe(10);
|
|
||||||
|
|
||||||
expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
||||||
expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0);
|
|
||||||
expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(0);
|
|
||||||
expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(10);
|
|
||||||
|
|
||||||
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
||||||
|
|
||||||
expect(root.getComputedLeft()).toBe(0);
|
|
||||||
expect(root.getComputedTop()).toBe(0);
|
|
||||||
expect(root.getComputedWidth()).toBe(400);
|
|
||||||
expect(root.getComputedHeight()).toBe(400);
|
|
||||||
|
|
||||||
expect(root_child0.getComputedLeft()).toBe(0);
|
|
||||||
expect(root_child0.getComputedTop()).toBe(0);
|
|
||||||
expect(root_child0.getComputedWidth()).toBe(400);
|
|
||||||
expect(root_child0.getComputedHeight()).toBe(10);
|
|
||||||
|
|
||||||
expect(root_child0_child0.getComputedLeft()).toBe(400);
|
|
||||||
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
||||||
expect(root_child0_child0.getComputedWidth()).toBe(0);
|
|
||||||
expect(root_child0_child0.getComputedHeight()).toBe(10);
|
|
||||||
|
|
||||||
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
||||||
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
||||||
expect(root_child0_child0_child0.getComputedWidth()).toBe(0);
|
|
||||||
expect(root_child0_child0_child0.getComputedHeight()).toBe(10);
|
|
||||||
|
|
||||||
expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
||||||
expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0);
|
|
||||||
expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(0);
|
|
||||||
expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(10);
|
|
||||||
} finally {
|
|
||||||
if (typeof root !== 'undefined') {
|
|
||||||
root.freeRecursive();
|
|
||||||
}
|
|
||||||
|
|
||||||
config.free();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* clang-format off
|
* clang-format off
|
||||||
* @generated SignedSource<<1db57b05babb408c08efcec7dbdf16fb>>
|
* @generated SignedSource<<71295a398c89ea424490884a05e2c77c>>
|
||||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -2310,84 +2310,3 @@ TEST(YogaTest, align_stretch_with_row_reverse) {
|
|||||||
|
|
||||||
YGConfigFree(config);
|
YGConfigFree(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(YogaTest, align_items_non_stretch_s526008) {
|
|
||||||
YGConfigRef config = YGConfigNew();
|
|
||||||
|
|
||||||
YGNodeRef root = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
|
|
||||||
YGNodeStyleSetWidth(root, 400);
|
|
||||||
YGNodeStyleSetHeight(root, 400);
|
|
||||||
|
|
||||||
YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
|
||||||
YGNodeInsertChild(root, root_child0, 0);
|
|
||||||
|
|
||||||
YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeStyleSetAlignItems(root_child0_child0, YGAlignFlexStart);
|
|
||||||
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
|
||||||
|
|
||||||
YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
|
||||||
|
|
||||||
YGNodeRef root_child0_child0_child0_child0 = YGNodeNewWithConfig(config);
|
|
||||||
YGNodeStyleSetHeight(root_child0_child0_child0_child0, 10);
|
|
||||||
YGNodeInsertChild(root_child0_child0_child0, root_child0_child0_child0_child0, 0);
|
|
||||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
||||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root));
|
|
||||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0_child0_child0));
|
|
||||||
|
|
||||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
||||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root));
|
|
||||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0));
|
|
||||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0_child0_child0));
|
|
||||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0_child0_child0));
|
|
||||||
|
|
||||||
YGNodeFreeRecursive(root);
|
|
||||||
|
|
||||||
YGConfigFree(config);
|
|
||||||
}
|
|
||||||
|
@@ -415,12 +415,6 @@ static void measureNodeWithoutChildren(
|
|||||||
Dimension::Height);
|
Dimension::Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool isFixedSize(float dim, SizingMode sizingMode) {
|
|
||||||
return yoga::isDefined(dim) &&
|
|
||||||
(sizingMode == SizingMode::StretchFit ||
|
|
||||||
(sizingMode == SizingMode::FitContent && dim <= 0.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool measureNodeWithFixedSize(
|
static bool measureNodeWithFixedSize(
|
||||||
yoga::Node* const node,
|
yoga::Node* const node,
|
||||||
const Direction direction,
|
const Direction direction,
|
||||||
@@ -430,8 +424,12 @@ static bool measureNodeWithFixedSize(
|
|||||||
const SizingMode heightSizingMode,
|
const SizingMode heightSizingMode,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight) {
|
const float ownerHeight) {
|
||||||
if (isFixedSize(availableWidth, widthSizingMode) &&
|
if ((yoga::isDefined(availableWidth) &&
|
||||||
isFixedSize(availableHeight, heightSizingMode)) {
|
widthSizingMode == SizingMode::FitContent && availableWidth <= 0.0f) ||
|
||||||
|
(yoga::isDefined(availableHeight) &&
|
||||||
|
heightSizingMode == SizingMode::FitContent && availableHeight <= 0.0f) ||
|
||||||
|
(widthSizingMode == SizingMode::StretchFit &&
|
||||||
|
heightSizingMode == SizingMode::StretchFit)) {
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
boundAxis(
|
boundAxis(
|
||||||
node,
|
node,
|
||||||
|
Reference in New Issue
Block a user