Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions gentest/fixtures/YGFlexBasisFitContentTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,3 @@
<div style="height: 500px;"></div>
</div>
</div>

<!-- Items with flex-basis inside a scroll container's auto-height
content container. With FixFlexBasisFitContent, flex-basis is
respected even when the content container's main axis size is
indefinite (NaN). Without the feature, flex-basis would be ignored. -->
<div id="flex_basis_in_scroll_content_container"
data-experiments="FixFlexBasisFitContent"
style="width: 200px; height: 300px; overflow: scroll;">
<div>
<div style="flex-basis: 200px;"></div>
<div style="flex-basis: 300px;"></div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<43053b7b4f9b08ef644e0bb63c44e78f>>
* @generated SignedSource<<94d885664d3bbf8c72280e1b61102fce>>
* generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGFlexBasisFitContentTest.html
*/

Expand Down Expand Up @@ -385,74 +385,6 @@ public void test_explicit_and_container_children_column() {
assertEquals(500f, root_child1_child0.getLayoutHeight(), 0.0f);
}

@Test
public void test_flex_basis_in_scroll_content_container() {
YogaConfig config = YogaConfigFactory.create();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.FIX_FLEX_BASIS_FIT_CONTENT, true);

final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(200f);
root.setHeight(300f);
root.setOverflow(YogaOverflow.SCROLL);

final YogaNode root_child0 = createNode(config);
root.addChildAt(root_child0, 0);

final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setFlexBasis(200f);
root_child0.addChildAt(root_child0_child0, 0);

final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setFlexBasis(300f);
root_child0.addChildAt(root_child0_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);

assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(500f, root_child0.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(200f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child0_child1.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(200f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(500f, root_child0.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);

assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(200f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child0_child1.getLayoutHeight(), 0.0f);
}

private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}
Expand Down
67 changes: 1 addition & 66 deletions javascript/tests/generated/YGFlexBasisFitContentTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<52cb2c57af8b80a23fa8217c15d0000a>>
* @generated SignedSource<<8265f8738bd09131df2e6ef29f0e34d7>>
* generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGFlexBasisFitContentTest.html
*/

Expand Down Expand Up @@ -362,68 +362,3 @@ test('explicit_and_container_children_column', () => {
expect(root_child1_child0.getComputedWidth()).toBe(200);
expect(root_child1_child0.getComputedHeight()).toBe(500);
});
test('flex_basis_in_scroll_content_container', () => {
const config = Yoga.Config.create();

config.setExperimentalFeatureEnabled(ExperimentalFeature.FixFlexBasisFitContent, true);

const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setWidth(200);
root.setHeight(300);
root.setOverflow(Overflow.Scroll);

const root_child0 = Yoga.Node.create(config);
root.insertChild(root_child0, 0);

const root_child0_child0 = Yoga.Node.create(config);
root_child0_child0.setFlexBasis(200);
root_child0.insertChild(root_child0_child0, 0);

const root_child0_child1 = Yoga.Node.create(config);
root_child0_child1.setFlexBasis(300);
root_child0.insertChild(root_child0_child1, 1);
root.calculateLayout(undefined, undefined, Direction.LTR);

expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(200);
expect(root.getComputedHeight()).toBe(300);

expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(500);

expect(root_child0_child0.getComputedLeft()).toBe(0);
expect(root_child0_child0.getComputedTop()).toBe(0);
expect(root_child0_child0.getComputedWidth()).toBe(200);
expect(root_child0_child0.getComputedHeight()).toBe(200);

expect(root_child0_child1.getComputedLeft()).toBe(0);
expect(root_child0_child1.getComputedTop()).toBe(200);
expect(root_child0_child1.getComputedWidth()).toBe(200);
expect(root_child0_child1.getComputedHeight()).toBe(300);

root.calculateLayout(undefined, undefined, Direction.RTL);

expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(200);
expect(root.getComputedHeight()).toBe(300);

expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(500);

expect(root_child0_child0.getComputedLeft()).toBe(0);
expect(root_child0_child0.getComputedTop()).toBe(0);
expect(root_child0_child0.getComputedWidth()).toBe(200);
expect(root_child0_child0.getComputedHeight()).toBe(200);

expect(root_child0_child1.getComputedLeft()).toBe(0);
expect(root_child0_child1.getComputedTop()).toBe(200);
expect(root_child0_child1.getComputedWidth()).toBe(200);
expect(root_child0_child1.getComputedHeight()).toBe(300);
});
70 changes: 1 addition & 69 deletions tests/generated/YGFlexBasisFitContentTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* clang-format off
* @generated SignedSource<<a42a4541e0d8b8808aedb4abd62c617b>>
* @generated SignedSource<<58bc4a8baa6798aea54b1c9f712a9e11>>
* generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGFlexBasisFitContentTest.html
*/

Expand Down Expand Up @@ -377,71 +377,3 @@ TEST(YogaTest, explicit_and_container_children_column) {
YGConfigFree(config);
}

TEST(YogaTest, flex_basis_in_scroll_content_container) {
YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureFixFlexBasisFitContent, true);

YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 300);
YGNodeStyleSetOverflow(root, YGOverflowScroll);

YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeInsertChild(root, root_child0, 0);

YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexBasis(root_child0_child0, 200);
YGNodeInsertChild(root_child0, root_child0_child0, 0);

YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexBasis(root_child0_child1, 300);
YGNodeInsertChild(root_child0, root_child0_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root));

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root_child0));

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child0_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child1));
ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child0_child1));

YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root));

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root_child0));

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child0_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child1));
ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child0_child1));

YGNodeFreeRecursive(root);

YGConfigFree(config);
}
14 changes: 13 additions & 1 deletion yoga/YGNodeStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,25 @@ void updateStyle(YGNodeRef node, IdxT idx, ValueT value) {
}
}

bool stylesEqualForConfig(
const Node* node,
const Style& first,
const Style& second) {
const auto config = node->getConfig();
const bool compareBoxSizing = config != nullptr &&
config->isExperimentalFeatureEnabled(
ExperimentalFeature::FixFlexBasisFitContent);
return first == second &&
(!compareBoxSizing || first.boxSizing() == second.boxSizing());
}

} // namespace

void YGNodeCopyStyle(YGNodeRef dstNode, YGNodeConstRef srcNode) {
auto dst = resolveRef(dstNode);
auto src = resolveRef(srcNode);

if (dst->style() != src->style()) {
if (!stylesEqualForConfig(dst, dst->style(), src->style())) {
dst->setStyle(src->style());
dst->markDirtyAndPropagate();
}
Expand Down
Loading
Loading