Fix negative value rounding issue for nodes across an axis #688

Open
jmaurice-unity wants to merge 3 commits from jmaurice-unity/rounding-nodes-shrink into main
jmaurice-unity commented 2017-12-19 09:20:35 -08:00 (Migrated from github.com)

This fix issue #683 the rounding calculation is incorrect if a node is crossing an axis and it will shrink it's width/height on layout calculation.

The following test reproduce the issue :

TEST(YogaTest, node_shrink_on_axis)
{
  const YGConfigRef config = YGConfigNew();
  const YGNodeRef root = YGNodeNewWithConfig(config);
  const YGNodeRef child = YGNodeNewWithConfig(config);

  YGNodeInsertChild(root, child, 0);

  YGNodeStyleSetWidth(child, 10);
  YGNodeStyleSetHeight(child, 10);
  YGNodeStyleSetPosition(root, YGEdgeLeft, -0.75f);
  YGNodeStyleSetPosition(root, YGEdgeTop, -0.75f);

  YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);

  ASSERT_FLOAT_EQ(YGNodeLayoutGetWidth(child), 10);
  ASSERT_FLOAT_EQ(YGNodeLayoutGetHeight(child), 10);

  YGNodeFreeRecursive(root);

  YGConfigFree(config);
}
This fix issue #683 the rounding calculation is incorrect if a node is crossing an axis and it will shrink it's width/height on layout calculation. The following test reproduce the issue : ``` TEST(YogaTest, node_shrink_on_axis) { const YGConfigRef config = YGConfigNew(); const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef child = YGNodeNewWithConfig(config); YGNodeInsertChild(root, child, 0); YGNodeStyleSetWidth(child, 10); YGNodeStyleSetHeight(child, 10); YGNodeStyleSetPosition(root, YGEdgeLeft, -0.75f); YGNodeStyleSetPosition(root, YGEdgeTop, -0.75f); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_FLOAT_EQ(YGNodeLayoutGetWidth(child), 10); ASSERT_FLOAT_EQ(YGNodeLayoutGetHeight(child), 10); YGNodeFreeRecursive(root); YGConfigFree(config); } ```
facebook-github-bot commented 2017-12-19 09:23:12 -08:00 (Migrated from github.com)

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. **If you are contributing on behalf of someone else (eg your employer)**, the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at [cla@fb.com](mailto:cla@fb.com?subject=CLA%20for%20facebook%2Fyoga%20%23688). Thanks!
facebook-github-bot commented 2018-01-04 12:50:55 -08:00 (Migrated from github.com)

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!
matthargett commented 2018-01-25 12:56:44 -08:00 (Migrated from github.com)

can you add the new test to the PR please?

can you add the new test to the PR please?
jmaurice-unity commented 2018-01-25 13:11:22 -08:00 (Migrated from github.com)

There's already a test above that reproduce the issue.

There's already a test above that reproduce the issue.
lunarraid commented 2018-03-05 11:30:16 -08:00 (Migrated from github.com)

What is the status of this? This bug is pretty heavily impacting my project and forcing me to run a branch with this fix. It would be nice to get this merged in.

What is the status of this? This bug is pretty heavily impacting my project and forcing me to run a branch with this fix. It would be nice to get this merged in.
facebook-github-bot (Migrated from github.com) reviewed 2019-01-28 12:49:50 -08:00
facebook-github-bot (Migrated from github.com) left a comment

@davidaurelio has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@davidaurelio has imported this pull request. If you are a Facebook employee, you can view this diff [on Phabricator](https://phabricator.internmc.facebook.com/D13847154).
facebook-github-bot (Migrated from github.com) reviewed 2019-01-28 13:23:31 -08:00
facebook-github-bot (Migrated from github.com) left a comment

@davidaurelio has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@davidaurelio has imported this pull request. If you are a Facebook employee, you can view this diff [on Phabricator](https://phabricator.internmc.facebook.com/D13847154).
facebook-github-bot (Migrated from github.com) reviewed 2019-01-29 03:05:44 -08:00
facebook-github-bot (Migrated from github.com) left a comment

@davidaurelio has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@davidaurelio has imported this pull request. If you are a Facebook employee, you can view this diff [on Phabricator](https://phabricator.internmc.facebook.com/D13847154).
facebook-github-bot (Migrated from github.com) reviewed 2019-01-29 03:44:48 -08:00
facebook-github-bot (Migrated from github.com) left a comment

@davidaurelio has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@davidaurelio has imported this pull request. If you are a Facebook employee, you can view this diff [on Phabricator](https://phabricator.internmc.facebook.com/D13859605).
facebook-github-bot (Migrated from github.com) reviewed 2019-01-29 12:36:07 -08:00
facebook-github-bot (Migrated from github.com) left a comment

@davidaurelio has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@davidaurelio has imported this pull request. If you are a Facebook employee, you can view this diff [on Phabricator](https://phabricator.internmc.facebook.com/D13866122).
facebook-github-bot commented 2023-01-20 18:27:25 -08:00 (Migrated from github.com)

@rozele has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@rozele has imported this pull request. If you are a Meta employee, you can view this diff [on Phabricator](https://www.internalfb.com/diff/D13866122).
facebook-github-bot commented 2023-01-24 07:00:39 -08:00 (Migrated from github.com)

@rozele has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@rozele has imported this pull request. If you are a Meta employee, you can view this diff [on Phabricator](https://www.internalfb.com/diff/D13866122).
facebook-github-bot commented 2023-02-02 07:53:13 -08:00 (Migrated from github.com)

@rozele merged this pull request in facebook/yoga@4266409934.

@rozele merged this pull request in facebook/yoga@42664099342c7a7e7e4765fbb3c2e0191d0269aa.
facebook-github-bot commented 2023-02-02 14:09:14 -08:00 (Migrated from github.com)

This pull request has been reverted by 996267dbcb.

This pull request has been **reverted** by 996267dbcb1cd809f19f8d8e47d075bb982e32a8.
NickGerleman commented 2023-02-02 22:59:15 -08:00 (Migrated from github.com)

As a heads up, it looks like this change ended up making subtle shifts to existing layouts in many of our screenshot tests, so this change was reverted to investigate.

As a heads up, it looks like this change ended up making subtle shifts to existing layouts in many of our screenshot tests, so this change was reverted to investigate.
This pull request has changes conflicting with the target branch.
  • yoga/Yoga.cpp
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin jmaurice-unity/rounding-nodes-shrink:jmaurice-unity/rounding-nodes-shrink
git checkout jmaurice-unity/rounding-nodes-shrink
Sign in to join this conversation.
No description provided.