Skip to content
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

Closed
wants to merge 10 commits into from

Conversation

woehrl01
Copy link
Contributor

@woehrl01 woehrl01 commented Apr 2, 2017

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

Copy link
Contributor

@emilsjolander emilsjolander left a 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.

YGNodeStyleSetAlignItems(root, YGAlignStretch);
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexGrow(root, 0);
YGNodeStyleSetOverflow(root, YGOverflowHidden);
Copy link
Contributor

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

YGNodeStyleSetFlexGrow(root, 0);
YGNodeStyleSetOverflow(root, YGOverflowHidden);
YGNodeStyleSetAlignSelf(root, YGAlignAuto);
YGNodeStyleSetPositionType(root, YGPositionTypeRelative);
Copy link
Contributor

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

const YGNodeRef root = YGNodeNew();
YGNodeStyleSetHeight(root, 200);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn);
YGNodeStyleSetAlignItems(root, YGAlignStretch);
Copy link
Contributor

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

Copy link
Contributor Author

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.

YGNodeStyleSetOverflow(root, YGOverflowHidden);
YGNodeStyleSetAlignSelf(root, YGAlignAuto);
YGNodeStyleSetPositionType(root, YGPositionTypeRelative);
YGNodeStyleSetJustifyContent(root, YGJustifyFlexStart);
Copy link
Contributor

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

YGNodeStyleSetAlignSelf(root_child0, YGAlignStretch);
YGNodeStyleSetJustifyContent(root_child0, YGJustifyFlexStart);
YGNodeStyleSetOverflow(root_child0, YGOverflowHidden);
YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 100);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use YGEdgeALL instead?

@woehrl01
Copy link
Contributor Author

woehrl01 commented Apr 4, 2017

The test is not that obvious correct. The problem is:
The parent height is 200 and the padding is 100 on both sides so the available size is 0, the measure size is non zero. But as we haven't constraint the other side, We should be still growable in the width dimension.

In my opinion a measured node could still overflow it's parent, isn't it?

@emilsjolander
Copy link
Contributor

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.

@woehrl01
Copy link
Contributor Author

woehrl01 commented Apr 4, 2017

According to this fiddle it's overflowing.

@woehrl01
Copy link
Contributor Author

woehrl01 commented Apr 4, 2017

Btw. I'll update the test and remove the default values.

@emilsjolander
Copy link
Contributor

Why should this only handle at_most and not undefined?

@woehrl01 woehrl01 changed the title Measure nodes on AT_MOST with zero space Skip measuring of nodes with zero space only on EXACTLY Apr 5, 2017
@woehrl01
Copy link
Contributor Author

woehrl01 commented Apr 5, 2017

You're right it should also measure on the undefined mode, too.

@woehrl01 woehrl01 changed the title Skip measuring of nodes with zero space only on EXACTLY Fix skipping of measurement by returning correct size for non EXACT measurements Apr 5, 2017
@woehrl01
Copy link
Contributor Author

woehrl01 commented Apr 5, 2017

Sorry, I actually was wrong. We don't need to measure here, we just need to return the correct size in the "no available size" skipping. I moved the skipping to the calculation step to perform the same calculations. I just don't call measure but use a new gYGSizeZero for the measurement instead.

@facebook-github-bot
Copy link
Contributor

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

@emilsjolander
Copy link
Contributor

Seems measure_zero_space_should_grow test is failing after the last update. Could you have a look?

@woehrl01
Copy link
Contributor Author

woehrl01 commented Apr 7, 2017

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.

@woehrl01
Copy link
Contributor Author

woehrl01 commented Apr 7, 2017

I expanded the jsfiddle to some testcases which some of them definetly aren't rendered correct currently https://jsfiddle.net/uh9whoom/6/

@emilsjolander
Copy link
Contributor

@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.

@facebook-github-bot
Copy link
Contributor

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

@emilsjolander
Copy link
Contributor

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.

@woehrl01
Copy link
Contributor Author

woehrl01 commented Apr 7, 2017

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.

@woehrl01
Copy link
Contributor Author

woehrl01 commented Apr 7, 2017

But if this is introducing a breaking change. Maybe we should directly move to a more web compatible behaviour. What do you think?

@emilsjolander
Copy link
Contributor

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.

@woehrl01
Copy link
Contributor Author

woehrl01 commented Apr 7, 2017

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 👍 .

@emilsjolander
Copy link
Contributor

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.

@woehrl01 woehrl01 changed the title Fix skipping of measurement by returning correct size for non EXACT measurements Let measure behave more like on the web Apr 7, 2017
@facebook-github-bot
Copy link
Contributor

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

facebook-github-bot pushed a commit to facebook/litho that referenced this pull request Apr 13, 2017
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
@emilsjolander
Copy link
Contributor

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 :)

@emilsjolander emilsjolander reopened this Apr 13, 2017
Maxwell2022 pushed a commit to Maxwell2022/react-native that referenced this pull request Apr 19, 2017
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
@emilsjolander emilsjolander reopened this Apr 21, 2017
facebook-github-bot pushed a commit to facebook/litho that referenced this pull request Apr 27, 2017
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
facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Apr 27, 2017
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
thotegowda pushed a commit to thotegowda/react-native that referenced this pull request May 7, 2017
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
thotegowda pushed a commit to thotegowda/react-native that referenced this pull request May 7, 2017
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
vincentriemer pushed a commit to vincentriemer/yoga-dom that referenced this pull request May 9, 2018
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
vincentriemer pushed a commit to vincentriemer/yoga-dom that referenced this pull request May 9, 2018
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants