-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let measure behave more like on the web #499
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain why? The test is not obvious to me.
tests/YGMeasureTest.cpp
Outdated
YGNodeStyleSetAlignItems(root, YGAlignStretch); | ||
YGNodeStyleSetAlignContent(root, YGAlignStretch); | ||
YGNodeStyleSetFlexGrow(root, 0); | ||
YGNodeStyleSetOverflow(root, YGOverflowHidden); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove overflow line. Should have no effect on test
tests/YGMeasureTest.cpp
Outdated
YGNodeStyleSetFlexGrow(root, 0); | ||
YGNodeStyleSetOverflow(root, YGOverflowHidden); | ||
YGNodeStyleSetAlignSelf(root, YGAlignAuto); | ||
YGNodeStyleSetPositionType(root, YGPositionTypeRelative); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relative is default, no need to set it
tests/YGMeasureTest.cpp
Outdated
const YGNodeRef root = YGNodeNew(); | ||
YGNodeStyleSetHeight(root, 200); | ||
YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); | ||
YGNodeStyleSetAlignItems(root, YGAlignStretch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stretch is default for align items. no need to set it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I adopted all the values form the issue.
tests/YGMeasureTest.cpp
Outdated
YGNodeStyleSetOverflow(root, YGOverflowHidden); | ||
YGNodeStyleSetAlignSelf(root, YGAlignAuto); | ||
YGNodeStyleSetPositionType(root, YGPositionTypeRelative); | ||
YGNodeStyleSetJustifyContent(root, YGJustifyFlexStart); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flex start is default for justify content. no need to set it
tests/YGMeasureTest.cpp
Outdated
YGNodeStyleSetAlignSelf(root_child0, YGAlignStretch); | ||
YGNodeStyleSetJustifyContent(root_child0, YGJustifyFlexStart); | ||
YGNodeStyleSetOverflow(root_child0, YGOverflowHidden); | ||
YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use YGEdgeALL instead?
The test is not that obvious correct. The problem is: In my opinion a measured node could still overflow it's parent, isn't it? |
Ok thanks for explaining. Growing the parent width makes sense in that case. Regarding overflow I don't know. I would look to web browsers for guidance on this. |
According to this fiddle it's overflowing. |
Btw. I'll update the test and remove the default values. |
Why should this only handle at_most and not undefined? |
You're right it should also measure on the undefined mode, too. |
Sorry, I actually was wrong. We don't need to |
@emilsjolander has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Seems measure_zero_space_should_grow test is failing after the last update. Could you have a look? |
It's failing as we don't measure anymore. I reduce the testcase for now. As enabling always measure would lead to a possible layoutbreaking change. This fixes the current behaviour. We need to discuss how the final behaviour should be and possibly introduce changes as some kind of flag? I think this should be fixed/handled in a separete PR. |
I expanded the jsfiddle to some testcases which some of them definetly aren't rendered correct currently https://jsfiddle.net/uh9whoom/6/ |
@woehrl01 As long as we are moving towards better web compatibility and not breaking any major existing use cases I'm happy. I would rather not introduce new flags unless absolutely necessary. |
@emilsjolander has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
This is causing some test failures on integration tests internally. I haven't tracked down why but it seems this causes nodes to be measured to larger sizes than before. |
Yes, it returns now a different size, it now behaves from the size like a node without a measure function. If there isn't any space. |
But if this is introducing a breaking change. Maybe we should directly move to a more web compatible behaviour. What do you think? |
Yeah that sounds good, much easier to land if we only breaks things once. |
Ok, but this will lead to that we will measure more often. I'll put up a bigger test suite and put up a PR. Could take me a bit 👍 . |
ok Thanks! Regarding increased measurements as long as it is in a couple edge cases that is fine. We will have a look once the code is up and i'll do some internal logging to figure out if we regressed # of measure calls in practice. |
@emilsjolander has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488 Closes facebook/yoga#499 Differential Revision: D4850458 Pulled By: emilsjolander fbshipit-source-id: be5e35a670ddcbf3cd426fc3c2a0c9b60a874cdc
Re-opening this as well. This caused fewer breakages but still some issues which I don't have time to resolve right away. I will try re-commiting this next week. Sorry about that :) |
Summary: Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488 Closes facebook/yoga#499 Differential Revision: D4850458 Pulled By: emilsjolander fbshipit-source-id: be5e35a670ddcbf3cd426fc3c2a0c9b60a874cdc
Summary: Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488 Closes facebook/yoga#499 Reviewed By: astreet Differential Revision: D4954008 Pulled By: emilsjolander fbshipit-source-id: 5b6d9afae0cdebe33f8b82b67620b3b4527d1efc
Summary: Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488 Closes facebook/yoga#499 Reviewed By: astreet Differential Revision: D4954008 Pulled By: emilsjolander fbshipit-source-id: 5b6d9afae0cdebe33f8b82b67620b3b4527d1efc
Summary: Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488 Closes facebook/yoga#499 Differential Revision: D4850458 Pulled By: emilsjolander fbshipit-source-id: be5e35a670ddcbf3cd426fc3c2a0c9b60a874cdc
Summary: Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488 Closes facebook/yoga#499 Reviewed By: astreet Differential Revision: D4954008 Pulled By: emilsjolander fbshipit-source-id: 5b6d9afae0cdebe33f8b82b67620b3b4527d1efc
Summary: Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488 Closes facebook/yoga#499 Differential Revision: D4850458 Pulled By: emilsjolander fbshipit-source-id: be5e35a670ddcbf3cd426fc3c2a0c9b60a874cdc
Summary: Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488 Closes facebook/yoga#499 Reviewed By: astreet Differential Revision: D4954008 Pulled By: emilsjolander fbshipit-source-id: 5b6d9afae0cdebe33f8b82b67620b3b4527d1efc
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix #488