Add feature to use percentage as value unit #258

Closed
woehrl01 wants to merge 43 commits from percentage-feature into master
woehrl01 commented 2016-11-22 15:35:42 -08:00 (Migrated from github.com)

Adds the feature to use percentage as a value unit.

You can use the function YGPx(float) and YGPercent(float) for convenience.

I did some benchmarks:

Without Percentage Feature - Release x86:

Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms

Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms


With Percentage Feature - Release x86:

Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms

Stack with flex: median: 0.000000 ms, stddev: 0.146969 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.129271 ms
Nested flex: median: 0.000000 ms, stddev: 0.481787 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.695898 ms

It is slightly faster, as I was able to reduce the calls to isnan().

Adds the feature to use percentage as a value unit. You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience. I did some benchmarks: ``` Without Percentage Feature - Release x86: Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms Nested flex: median: 0.000000 ms, stddev: 0.490101 ms Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms Nested flex: median: 0.000000 ms, stddev: 0.477791 ms Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms With Percentage Feature - Release x86: Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms Nested flex: median: 0.000000 ms, stddev: 0.489570 ms Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms Stack with flex: median: 0.000000 ms, stddev: 0.146969 ms Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.129271 ms Nested flex: median: 0.000000 ms, stddev: 0.481787 ms Huge nested layout: median: 21.000000 ms, stddev: 1.695898 ms ``` It is slightly faster, as I was able to reduce the calls to ```isnan()```.
emilsjolander commented 2016-11-23 03:18:53 -08:00 (Migrated from github.com)

This is really cool! I'm worried about perf, we need to benchmark this on low end android phones to get a sense of what the impact is. In a perfect world perf should only be effected when using percentage values. Percentage values are quite rare so impacting perf negatively for the rest of use cases is not great.

Some things I would like to see:

  • Description of why this should be added to css-layout. What use cases does it solve that are hard to solve with the current library?
  • Many more tests. We need to test how this works for width/height/flexBasis/minHeight/maxHeight/minWidth/maxWidth in both the main and cross axis. Also how does this interact with flex-grow and flex-shrink.

Looking forward to working together on this.

This is really cool! I'm worried about perf, we need to benchmark this on low end android phones to get a sense of what the impact is. In a perfect world perf should only be effected when using percentage values. Percentage values are quite rare so impacting perf negatively for the rest of use cases is not great. Some things I would like to see: - Description of why this should be added to css-layout. What use cases does it solve that are hard to solve with the current library? - Many more tests. We need to test how this works for width/height/flexBasis/minHeight/maxHeight/minWidth/maxWidth in both the main and cross axis. Also how does this interact with flex-grow and flex-shrink. Looking forward to working together on this.
emilsjolander commented 2016-11-23 03:36:03 -08:00 (Migrated from github.com)

Should the Px() and Percent() functions be prefixed with CSSLayout?

Prefix them with CSS.

> Should the Px() and Percent() functions be prefixed with CSSLayout? Prefix them with `CSS`.
woehrl01 commented 2016-11-23 05:03:04 -08:00 (Migrated from github.com)

We need to benchmark this on low end android phones to get a sense of what the impact is.

As I have non available in near future, could someone please try this on a low end device?

What use cases does it solve that are hard to solve with the current library?

Lot's of use cases can be solved via "spacer" views. But in my opinion this leads to less readable code on these places, as the intent isn't that clear anymore.

Additionally if you try to position an element absolute with percentage (e.g top: 20%, left: 10%) this shouldn't be possible at all, without having to creating a spacer view grid.

One use case I have is to layout boxes with wrapping, where I want to have two elements in a row. I would express this as FlexShrink: 0, FlexGrow: 0, FlexBasis: 50%.

But my personal prefered use case is to make my view code more readable and maintainable.

Many more tests.

Will do

Additional benefit

This is the start for units, em should be pretty easy to add (even so this can be calculated manually by now)

In a perfect world perf should only be effected when using percentage values

not sure if this is possible without doing a big refactoring. But I'll have a look.

> We need to benchmark this on low end android phones to get a sense of what the impact is. As I have non available in near future, could someone please try this on a low end device? > What use cases does it solve that are hard to solve with the current library? Lot's of use cases can be solved via "spacer" views. But in my opinion this leads to less readable code on these places, as the intent isn't that clear anymore. Additionally if you try to position an element absolute with percentage (e.g ```top: 20%```, ```left: 10%```) this shouldn't be possible at all, without having to creating a spacer view grid. One use case I have is to layout boxes with wrapping, where I want to have two elements in a row. I would express this as `FlexShrink: 0, FlexGrow: 0, FlexBasis: 50%`. But my personal prefered use case is to make my view code more readable and maintainable. > Many more tests. Will do > Additional benefit This is the start for units, ```em``` should be pretty easy to add (even so this can be calculated manually by now) > In a perfect world perf should only be effected when using percentage values not sure if this is possible without doing a big refactoring. But I'll have a look.
emilsjolander commented 2016-11-23 05:20:38 -08:00 (Migrated from github.com)

Would love concrete examples of what views benefit from this, not description of what it could be used for. I'm not really questioning the usefulness of it but it would be great to get a sense of the impact this has. In practice what layout problems does it solve. I myself find it very seldom that I would like to position something a percentage from the top/left as this generally does not scale very nicely. If there is a performance hit due to adding units I want to be able to show all the concrete benefits it brings.

Would love concrete examples of what views benefit from this, not description of what it could be used for. I'm not really questioning the usefulness of it but it would be great to get a sense of the impact this has. In practice what layout problems does it solve. I myself find it very seldom that I would like to position something a percentage from the top/left as this generally does not scale very nicely. If there is a performance hit due to adding units I want to be able to show all the concrete benefits it brings.
emilsjolander commented 2016-11-23 05:33:07 -08:00 (Migrated from github.com)

I can make sure to run some tests on perf on android. I won't have much time in the coming week though.

I can make sure to run some tests on perf on android. I won't have much time in the coming week though.
woehrl01 commented 2016-11-23 06:20:57 -08:00 (Migrated from github.com)

Sorry for bringing up a fictional example. The only real use case I had is the wrapping stuff, where I currently have to reimplement the wrapping logic, by boxing each line in its own container and distribute the elements across it. But I'm not able to express a minimal width on the containig elements, which I would like to.

e.g:

<div style="width: [dynamic]px; flex-wrap: wrap;flex-direction:row;display:flex">
 <div style="flex-shrink: 0; flex-grow: 1; flex-basis: 50%; height: 20px; min-width: 50px;background-color:blue;">
 </div>
 <div style="flex-shrink: 0; flex-grow: 1; flex-basis: 50%; height: 20px; min-width: 50px;background-color:red;">
 </div>
 <div style="flex-shrink: 0; flex-grow: 1; flex-basis: 50%; height: 20px; min-width: 50px;background-color:green;">
 </div>
 <div style="flex-shrink: 0; flex-grow: 1; flex-basis: 50%; height: 20px; min-width: 50px;background-color:yellow;">
 </div>
 <div style="flex-shrink: 0; flex-grow: 1; flex-basis: 50%; height: 20px; min-width: 50px;background-color:pink;">
 </div>
</div>

for a width with >= 100px you have two elements per row and < 100px you have a single element per row.

Sorry for bringing up a fictional example. The only real use case I had is the wrapping stuff, where I currently have to reimplement the wrapping logic, by boxing each line in its own container and distribute the elements across it. But I'm not able to express a minimal width on the containig elements, which I would like to. e.g: ``` <div style="width: [dynamic]px; flex-wrap: wrap;flex-direction:row;display:flex"> <div style="flex-shrink: 0; flex-grow: 1; flex-basis: 50%; height: 20px; min-width: 50px;background-color:blue;"> </div> <div style="flex-shrink: 0; flex-grow: 1; flex-basis: 50%; height: 20px; min-width: 50px;background-color:red;"> </div> <div style="flex-shrink: 0; flex-grow: 1; flex-basis: 50%; height: 20px; min-width: 50px;background-color:green;"> </div> <div style="flex-shrink: 0; flex-grow: 1; flex-basis: 50%; height: 20px; min-width: 50px;background-color:yellow;"> </div> <div style="flex-shrink: 0; flex-grow: 1; flex-basis: 50%; height: 20px; min-width: 50px;background-color:pink;"> </div> </div> ``` for a width with >= 100px you have two elements per row and < 100px you have a single element per row.
emilsjolander commented 2016-11-23 06:29:11 -08:00 (Migrated from github.com)

@woehrl01 Thanks for the update!

@woehrl01 Thanks for the update!
facebook-github-bot commented 2016-11-23 13:42:59 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/css-layout/pull/258/files/1a2592b50234c7e6662b7cf5247e4226e0eed7f3..c36edffdccc29af9b25c5bae49a7cf55fa30583a)
woehrl01 commented 2016-11-23 13:44:26 -08:00 (Migrated from github.com)

Ups, got it even faster than without this feature 😆 (same maschine), still interested in how this performs on android.

Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms

Stack with flex: median: 0.000000 ms, stddev: 0.146969 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.129271 ms
Nested flex: median: 0.000000 ms, stddev: 0.481787 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.695898 ms
Ups, got it even faster than without this feature 😆 (same maschine), still interested in how this performs on android. ``` Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms Nested flex: median: 0.000000 ms, stddev: 0.489570 ms Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms Stack with flex: median: 0.000000 ms, stddev: 0.146969 ms Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.129271 ms Nested flex: median: 0.000000 ms, stddev: 0.481787 ms Huge nested layout: median: 21.000000 ms, stddev: 1.695898 ms ```
emilsjolander commented 2016-11-24 11:55:48 -08:00 (Migrated from github.com)

@woehrl01 awesome! I landed a diff yesterday for experiment support in gentest. I would suggest you focus on added a bunch of test cases now 👍

@woehrl01 awesome! I landed a diff yesterday for experiment support in gentest. I would suggest you focus on added a bunch of test cases now 👍
facebook-github-bot commented 2016-11-25 08:40:46 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/css-layout/pull/258/files/c36edffdccc29af9b25c5bae49a7cf55fa30583a..ccfa918cb30140f40c5a2eeca9b1387f11e97132)
facebook-github-bot commented 2016-11-25 08:42:45 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/css-layout/pull/258/files/ccfa918cb30140f40c5a2eeca9b1387f11e97132..a194c6198f8f445ebaa6875cb296e9ad9191e698)
facebook-github-bot commented 2016-11-25 09:37:55 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/css-layout/pull/258/files/a194c6198f8f445ebaa6875cb296e9ad9191e698..376c5e8426142e7ee1ee80867cff438e6745367c)
woehrl01 commented 2016-11-25 09:39:59 -08:00 (Migrated from github.com)

@emilsjolander Merged master branch. And got the first failing test. Will look into this further in the next days.

@emilsjolander Merged master branch. And got the first failing test. Will look into this further in the next days.
woehrl01 commented 2016-11-25 10:02:38 -08:00 (Migrated from github.com)

@emilsjolander the failing test is not introduced via this implementation. created a new issue #261 for tracking this.

@emilsjolander the failing test is not introduced via this implementation. created a new issue #261 for tracking this.
facebook-github-bot commented 2016-11-27 07:42:53 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/css-layout/pull/258/files/376c5e8426142e7ee1ee80867cff438e6745367c..35069ce23d8da41318cd7060821ff9420b9c666b)
facebook-github-bot commented 2016-11-27 13:03:30 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/css-layout/pull/258/files/35069ce23d8da41318cd7060821ff9420b9c666b..311224f26218dce67ec2c5de9772273dc5f67887)
facebook-github-bot commented 2016-11-27 13:28:20 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/css-layout/pull/258/files/311224f26218dce67ec2c5de9772273dc5f67887..2b16a7af9f03215af7fb6b1a5bc2fb8b0a5f1d29)
emilsjolander commented 2016-12-15 06:18:26 -08:00 (Migrated from github.com)

Please change enums.py and re-generate the enum files by running python enums.py 👍

Please change enums.py and re-generate the enum files by running `python enums.py` 👍
emilsjolander commented 2016-12-15 06:19:09 -08:00 (Migrated from github.com)

I think once this is rebased it will be pretty close to mergable

I think once this is rebased it will be pretty close to mergable
woehrl01 commented 2016-12-15 06:22:02 -08:00 (Migrated from github.com)

@emilsjolander sadly not. I already did a local rebase, but I found a test layout which doesn't get calculated correctly. Still want to find and fix that bug before I'll update the PR.

@emilsjolander sadly not. I already did a local rebase, but I found a test layout which doesn't get calculated correctly. Still want to find and fix that bug before I'll update the PR.
emilsjolander commented 2016-12-15 06:30:08 -08:00 (Migrated from github.com)

@woehrl01 Ok! Feel free to update the PR with your progress and I can help debug if you want.

@woehrl01 Ok! Feel free to update the PR with your progress and I can help debug if you want.
facebook-github-bot commented 2016-12-15 06:44:20 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/2b16a7af9f03215af7fb6b1a5bc2fb8b0a5f1d29..a84d55e3c5fbd7f54ba1f0dc44a255ee5aa40e2f)
woehrl01 commented 2016-12-15 06:49:49 -08:00 (Migrated from github.com)

@emilsjolander I would highly appreciate if you could take a look! I added some additional variables for easier debugging, I will remove them as soon as we could track down the bug.

@emilsjolander I would highly appreciate if you could take a look! I added some additional variables for easier debugging, I will remove them as soon as we could track down the bug.
woehrl01 commented 2016-12-15 07:16:33 -08:00 (Migrated from github.com)

@emilsjolander I have a trace, we need to calculate the padding/margin percentage only based on the parents width. see https://www.w3.org/TR/CSS2/box.html#margin-properties

The percentage is calculated with respect to the width of the generated box's containing block. Note that this is true for 'margin-top' and 'margin-bottom' as well. If the containing block's width depends on this element, then the resulting layout is undefined in CSS 2.1.

sorry for letting this slipping through. 😞

@emilsjolander I have a trace, we need to calculate the padding/margin percentage only based on the parents width. see https://www.w3.org/TR/CSS2/box.html#margin-properties > The percentage is calculated with respect to the width of the generated box's containing block. Note that this is true for 'margin-top' and 'margin-bottom' as well. If the containing block's width depends on this element, then the resulting layout is undefined in CSS 2.1. sorry for letting this slipping through. 😞
emilsjolander commented 2016-12-15 07:29:08 -08:00 (Migrated from github.com)

wait.. margin-top: 50% is 50% of the width?? this makes no sense.

wait.. margin-top: 50% is 50% of the width?? this makes no sense.
woehrl01 commented 2016-12-15 07:33:41 -08:00 (Migrated from github.com)

No, its 50% of the parents width. This SO answer explains it best why: http://stackoverflow.com/a/18295172

Couldn't believe this either at first 😄

No, its 50% of the parents width. This SO answer explains it best why: http://stackoverflow.com/a/18295172 Couldn't believe this either at first 😄
emilsjolander commented 2016-12-15 07:38:56 -08:00 (Migrated from github.com)

Oh wow that is super confusing.

Oh wow that is super confusing.
facebook-github-bot commented 2016-12-15 07:50:51 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/a84d55e3c5fbd7f54ba1f0dc44a255ee5aa40e2f..fc98df63d8115316907c24ea922bca5fb8f88b0b)
facebook-github-bot commented 2016-12-15 08:05:53 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/fc98df63d8115316907c24ea922bca5fb8f88b0b..54e943d4529742da6e59148c0d9eb8dd8aeb1e68)
woehrl01 commented 2016-12-15 08:05:54 -08:00 (Migrated from github.com)

@emilsjolander test is passing 👍 😄

@emilsjolander test is passing 👍 😄
emilsjolander commented 2016-12-15 08:22:31 -08:00 (Migrated from github.com)

This is starting to look very promising.

Could you

  • Remove unrelated changes
  • Add tests for absolute positioning
  • Add tests for border
  • Add tests for margin (only tested in nested test now would like something more specific as well)
  • Add tests for padding (only tested in nested test now would like something more specific as well)

Also i'm not sure about the best way on constructing these values. YGPx etc is pretty verbose but i'm also not a fan of exposing a global unprefixed px function.

This is starting to look very promising. Could you - Remove unrelated changes - Add tests for absolute positioning - Add tests for border - Add tests for margin (only tested in nested test now would like something more specific as well) - Add tests for padding (only tested in nested test now would like something more specific as well) Also i'm not sure about the best way on constructing these values. `YGPx` etc is pretty verbose but i'm also not a fan of exposing a global unprefixed `px` function.
facebook-github-bot commented 2016-12-16 02:05:43 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/54e943d4529742da6e59148c0d9eb8dd8aeb1e68..8b6079cdf7cdded07c0c186f8a2f545bc96d797a)
emilsjolander (Migrated from github.com) requested changes 2016-12-16 02:11:48 -08:00
@@ -0,0 +1,82 @@
<div id="percentage_width_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
emilsjolander (Migrated from github.com) commented 2016-12-16 02:10:56 -08:00

Indentation here seems a bit off. Could you please update your tests to look more like the others?


<div id="percentage_padding_should_calculate_based_only_on_width" experiments="Rounding" style="width: 200px; height: 100px;">
    <div style="flex-grow: 1; padding: 10%;">
        <div style="width: 10px; height: 10px;"></div>
    </div>
</div>
Indentation here seems a bit off. Could you please update your tests to look more like the others? ```html <div id="percentage_padding_should_calculate_based_only_on_width" experiments="Rounding" style="width: 200px; height: 100px;"> <div style="flex-grow: 1; padding: 10%;"> <div style="width: 10px; height: 10px;"></div> </div> </div> ```
emilsjolander (Migrated from github.com) commented 2016-12-16 02:11:44 -08:00

Still missing tests for % border values

Still missing tests for % border values
woehrl01 commented 2016-12-16 02:12:29 -08:00 (Migrated from github.com)

Remove unrelated changes
Add tests for absolute positioning
Add tests for margin (only tested in nested test now would like something more specific as well)
Add tests for padding (only tested in nested test now would like something more specific as well)

added those tests

Add tests for border

there is no need to write tests for border, as border can't have percentage in css.

Also i'm not sure about the best way on constructing these values. YGPx etc is pretty verbose but i'm also not a fan of exposing a global unprefixed px function.

I already added two function e.g. YGNodeStyleSetWidthWithUnit and one only YGNodeStyleSetWidth which takes only float and means pixel.

My idea was to use *WithUnit in any interop code, it maybe should be used with an enum instead of the YGPx, e.g. YGNodeStyleSetWidthWithUnit(root, 14, YGUnitPercent). And to keep the "old" for not having a breaking change and to be able to set those values less verbose on C code.

For C# I'd suggest having a struct with implicit convertion from float and an extension method to make something like:

node.Height = 10f;
node.Width = 5.Percent()

For Java you can use overloads

node.SetHeight(10);
node.SetHeight(10, YGUnitPercent);
> Remove unrelated changes > Add tests for absolute positioning > Add tests for margin (only tested in nested test now would like something more specific as well) > Add tests for padding (only tested in nested test now would like something more specific as well) added those tests > Add tests for border there is no need to write tests for border, as border can't have percentage in css. > Also i'm not sure about the best way on constructing these values. YGPx etc is pretty verbose but i'm also not a fan of exposing a global unprefixed px function. I already added two function e.g. ```YGNodeStyleSetWidthWithUnit``` and one only ```YGNodeStyleSetWidth``` which takes only ```float``` and means pixel. My idea was to use ```*WithUnit``` in any interop code, it maybe should be used with an enum instead of the YGPx, e.g. ```YGNodeStyleSetWidthWithUnit(root, 14, YGUnitPercent)```. And to keep the "old" for not having a breaking change and to be able to set those values less verbose on ```C``` code. For C# I'd suggest having a struct with implicit convertion from ```float``` and an extension method to make something like: ``` node.Height = 10f; node.Width = 5.Percent() ``` For Java you can use overloads ``` node.SetHeight(10); node.SetHeight(10, YGUnitPercent); ```
woehrl01 (Migrated from github.com) reviewed 2016-12-16 02:16:13 -08:00
@@ -0,0 +1,82 @@
<div id="percentage_width_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
woehrl01 (Migrated from github.com) commented 2016-12-16 02:16:13 -08:00

there is no need to write tests for border, as border can't have percentage in css.

there is no need to write tests for border, as border can't have percentage in css.
facebook-github-bot commented 2016-12-16 02:16:46 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/8b6079cdf7cdded07c0c186f8a2f545bc96d797a..9cce30c91f7567637328903f7d36140dac8e9806)
emilsjolander commented 2016-12-16 02:22:28 -08:00 (Migrated from github.com)

there is no need to write tests for border, as border can't have percentage in css.

So consistent.

YGNodeStyleSetWidthWithUnit

Didn't see that, cool. It's pretty verbose and ads a lot of functions to the API. I think the API for this is worth thinking a bit about before merging, I'll try to see if I can figure out something better. Feel free to post more suggestions as well.

5.Percent()

This seems super magical to me. But if that is the standard why for doing such things in C# then by all means. I would probably prefer an enum in both java and c#.

** Travis is failing **

> there is no need to write tests for border, as border can't have percentage in css. So consistent. > YGNodeStyleSetWidthWithUnit Didn't see that, cool. It's pretty verbose and ads a lot of functions to the API. I think the API for this is worth thinking a bit about before merging, I'll try to see if I can figure out something better. Feel free to post more suggestions as well. > 5.Percent() This seems super magical to me. But if that is the standard why for doing such things in C# then by all means. I would probably prefer an enum in both java and c#. ** Travis is failing **
facebook-github-bot commented 2016-12-16 02:29:58 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/9cce30c91f7567637328903f7d36140dac8e9806..f84583c00216cd8133edb66f21768daf7347b8da)
woehrl01 commented 2016-12-16 02:38:01 -08:00 (Migrated from github.com)

Regarding C:

I think we should have multiple functions to not break many users and still make this opt-in for the ones who want to use percentage. But maybe as a second layer? YGNodeStyleSetWidth is calling YGNodeStyleSetWidthWithUnit in a thin wrapper? Not sure if this overhead is worth it.

Regarding C#:

Was just an idea, could also be something like:

node.Width = YogaPercent.Of(5f);

If you use an enum for C# you miss the change to use Properties, also there is this YogaNode.Create(). I would personaly still prefere the "object initializer syntax":

var n = new YogaNode{
    Width = 5,
    Height = YogaPercent.Of(10)
}
Regarding C: I think we should have multiple functions to not break many users and still make this opt-in for the ones who want to use percentage. But maybe as a second layer? ```YGNodeStyleSetWidth``` is calling ```YGNodeStyleSetWidthWithUnit``` in a thin wrapper? Not sure if this overhead is worth it. Regarding C#: Was just an idea, could also be something like: ```csharp node.Width = YogaPercent.Of(5f); ``` If you use an enum for C# you miss the change to use Properties, also there is this ```YogaNode.Create()```. I would personaly still prefere the "object initializer syntax": ```csharp var n = new YogaNode{ Width = 5, Height = YogaPercent.Of(10) } ```
facebook-github-bot commented 2016-12-16 02:42:56 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/f84583c00216cd8133edb66f21768daf7347b8da..e258d9867dd47848de4b91fadc99d1edecfe1f33)
emilsjolander commented 2016-12-16 02:45:27 -08:00 (Migrated from github.com)

I'll finish up reviewing the algorithm + test changes later today / early next week.

Regarding C

I like that you are thinking about not breaking the API but in this case i'm holding off on marking a stable release for changes such as this one. Also very few projects depend directly on the C version and instead use the wrappers. As I said I think it is worth taking some time and thinking about this API.

Regarding C#

Makes sense.

I'll finish up reviewing the algorithm + test changes later today / early next week. > Regarding C I like that you are thinking about not breaking the API but in this case i'm holding off on marking a stable release for changes such as this one. Also very few projects depend directly on the C version and instead use the wrappers. As I said I think it is worth taking some time and thinking about this API. > Regarding C# Makes sense.
woehrl01 commented 2016-12-16 02:55:17 -08:00 (Migrated from github.com)

Travis is still failing, because of the not exposed possibility of percentage in Java, I expect for C# to have the same problem.

Take your time reviewing and thinking about a good API. As soon as we have a well-conceived idea I'm happy to make the required changes.

Travis is still failing, because of the not exposed possibility of percentage in Java, I expect for C# to have the same problem. Take your time reviewing and thinking about a good API. As soon as we have a well-conceived idea I'm happy to make the required changes.
emilsjolander (Migrated from github.com) requested changes 2016-12-18 22:39:23 -08:00
@@ -21,6 +21,13 @@ typedef enum YGFlexDirection {
YGFlexDirectionRowReverse,
emilsjolander (Migrated from github.com) commented 2016-12-18 22:12:54 -08:00

YGUnitModeCount?? should be YGUnitCount probably. Did you forget to re-generate after changes?

YGUnitModeCount?? should be YGUnitCount probably. Did you forget to re-generate after changes?
emilsjolander (Migrated from github.com) commented 2016-12-18 22:21:08 -08:00

return YGValue {
.value = ...,
.defined = ...,
.unit = ...,
};

return YGValue { .value = ..., .defined = ..., .unit = ..., };
emilsjolander (Migrated from github.com) commented 2016-12-18 22:27:26 -08:00

YGValueToFloat is not very descriptive of what the function does. I would prefer YGValueResolve or something similar. What do you think?

`YGValueToFloat` is not very descriptive of what the function does. I would prefer `YGValueResolve` or something similar. What do you think?
emilsjolander (Migrated from github.com) commented 2016-12-18 22:22:01 -08:00

Create a YGValueUndefined static instance which you just copy here and below.

Create a `YGValueUndefined` static instance which you just copy here and below.
emilsjolander (Migrated from github.com) commented 2016-12-18 22:22:23 -08:00

return YGValue { ... };

return YGValue { ... };
emilsjolander (Migrated from github.com) commented 2016-12-18 22:22:29 -08:00

return YGValue { ... };

return YGValue { ... };
@@ -504,1 +600,4 @@
return YGFloatIsUndefined(b);
}
return fabs(a - b) < 0.0001f;
}
emilsjolander (Migrated from github.com) commented 2016-12-18 22:24:58 -08:00

just check for .defined. this function just makes it more verbose.

just check for `.defined`. this function just makes it more verbose.
@@ -1193,3 +1287,3 @@
YGNodeMarginForAxis(child, YGFlexDirectionColumn);
YGNodeMarginForAxis(child, YGFlexDirectionColumn, width);
}
emilsjolander (Migrated from github.com) commented 2016-12-18 22:38:17 -08:00

Position percentages are calculated based on the same axis as the position (https://jsfiddle.net/jckmwztt/15/) this is different from margin and padding and instead similar to width and height. So this (and other locations) should be YGFlexDirectionColumn, height

Position percentages are calculated based on the same axis as the position (https://jsfiddle.net/jckmwztt/15/) this is different from margin and padding and instead similar to width and height. So this (and other locations) should be `YGFlexDirectionColumn, height`
@@ -38,6 +38,11 @@ typedef struct YGSize {
float height;
emilsjolander (Migrated from github.com) commented 2016-12-18 22:13:11 -08:00

remove empty line

remove empty line
emilsjolander (Migrated from github.com) commented 2016-12-18 22:13:35 -08:00

space before { (actually just run format.sh)

space before { (actually just run format.sh)
@@ -85,3 +90,3 @@
WIN_EXPORT bool YGValueIsUndefined(const float value);
WIN_EXPORT bool YGFloatIsUndefined(const float value);
emilsjolander (Migrated from github.com) commented 2016-12-18 22:16:31 -08:00

No reason to have this function as we export the defined member of YGValue

No reason to have this function as we export the `defined` member of `YGValue`
@@ -110,1 +115,4 @@
#define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const float paramName); \
WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, const float paramName); \
emilsjolander (Migrated from github.com) commented 2016-12-18 22:18:49 -08:00

Let's remove the *WithUnit APIs and just use units everywhere. This makes the API smaller and more concise. Also it forces the user to think about units.

Let's remove the *WithUnit APIs and just use units everywhere. This makes the API smaller and more concise. Also it forces the user to think about units.
woehrl01 (Migrated from github.com) reviewed 2016-12-18 22:55:57 -08:00
@@ -110,1 +115,4 @@
#define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const float paramName); \
WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, const float paramName); \
woehrl01 (Migrated from github.com) commented 2016-12-18 22:55:57 -08:00

How should we return the units in the getter? Should I use YGValue in both get + set or use (float, YGUnitPixel) in the set and return only the float in get?

How should we return the units in the getter? Should I use YGValue in both get + set or use (float, YGUnitPixel) in the set and return only the float in get?
woehrl01 (Migrated from github.com) reviewed 2016-12-18 22:58:07 -08:00
woehrl01 (Migrated from github.com) commented 2016-12-18 22:58:07 -08:00

Please don't let me use this syntax here and at the other spots. Visual Studio (at least VS13 which I use) doesn't recognize this syntax, which would need me to change this one everytime I need to compile. (thats the reason I missed some tests at first)

Please don't let me use this syntax here and at the other spots. Visual Studio (at least VS13 which I use) doesn't recognize this syntax, which would need me to change this one everytime I need to compile. (thats the reason I missed some tests at first)
woehrl01 (Migrated from github.com) reviewed 2016-12-18 22:58:19 -08:00
woehrl01 (Migrated from github.com) commented 2016-12-18 22:58:19 -08:00

sounds good!

sounds good!
woehrl01 (Migrated from github.com) reviewed 2016-12-18 23:00:05 -08:00
woehrl01 (Migrated from github.com) commented 2016-12-18 23:00:05 -08:00

you mean a "global" instance? I could use this in YGComputedEdgeValue, too.

you mean a "global" instance? I could use this in ```YGComputedEdgeValue```, too.
woehrl01 (Migrated from github.com) reviewed 2016-12-18 23:00:55 -08:00
@@ -1193,3 +1287,3 @@
YGNodeMarginForAxis(child, YGFlexDirectionColumn);
YGNodeMarginForAxis(child, YGFlexDirectionColumn, width);
}
woehrl01 (Migrated from github.com) commented 2016-12-18 23:00:55 -08:00

nice catch, thanks!

nice catch, thanks!
emilsjolander (Migrated from github.com) reviewed 2016-12-18 23:09:51 -08:00
@@ -110,1 +115,4 @@
#define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const float paramName); \
WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, const float paramName); \
emilsjolander (Migrated from github.com) commented 2016-12-18 23:09:51 -08:00

The getter should return a YGValue as well.

The getter should return a YGValue as well.
emilsjolander (Migrated from github.com) reviewed 2016-12-18 23:12:57 -08:00
emilsjolander (Migrated from github.com) commented 2016-12-18 23:12:57 -08:00

VS15 has support for this syntax and it is used throughout the project so i suggest upgrading. I would prefer it and it is part of C99. Is there a reason you are using a old VS build? if there are legit usages for old VS then I would be OK with leaving as is.

VS15 has support for this syntax and it is used throughout the project so i suggest upgrading. I would prefer it and it is part of C99. Is there a reason you are using a old VS build? if there are legit usages for old VS then I would be OK with leaving as is.
emilsjolander (Migrated from github.com) reviewed 2016-12-18 23:13:56 -08:00
emilsjolander (Migrated from github.com) commented 2016-12-18 23:13:56 -08:00

yes, easy to mix up terminology when working with many languages 😕

yes, easy to mix up terminology when working with many languages 😕
woehrl01 (Migrated from github.com) reviewed 2016-12-18 23:42:19 -08:00
woehrl01 (Migrated from github.com) commented 2016-12-18 23:42:19 -08:00

none, except licence. If VS15 supports this I'm fine, making this change.

none, except licence. If VS15 supports this I'm fine, making this change.
emilsjolander (Migrated from github.com) reviewed 2016-12-18 23:46:32 -08:00
emilsjolander (Migrated from github.com) commented 2016-12-18 23:46:32 -08:00

I think it does from searching google :p please double check yourself

I think it does from searching google :p please double check yourself
facebook-github-bot commented 2016-12-19 10:16:13 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/e258d9867dd47848de4b91fadc99d1edecfe1f33..a7003b6821c357157d1af394061ccd5b768c3507)
woehrl01 (Migrated from github.com) reviewed 2016-12-19 10:16:53 -08:00
woehrl01 (Migrated from github.com) commented 2016-12-19 10:16:53 -08:00

sorry, just downloaded VS15 community and I can't get it to compile with this syntax 😞

sorry, just downloaded VS15 community and I can't get it to compile with this syntax 😞
facebook-github-bot commented 2016-12-19 10:18:49 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/a7003b6821c357157d1af394061ccd5b768c3507..1af3a763218b61d2bc962119d603571192e7f996)
facebook-github-bot commented 2016-12-19 10:20:46 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/1af3a763218b61d2bc962119d603571192e7f996..26ad37af79edaa88e451a9b0f08eb0bdd518aa04)
woehrl01 (Migrated from github.com) reviewed 2016-12-19 10:23:01 -08:00
@@ -38,6 +38,11 @@ typedef struct YGSize {
float height;
woehrl01 (Migrated from github.com) commented 2016-12-19 10:23:01 -08:00

I would like to do this, but setting everything up on my maschine would be a huge job. As I have no linux runtime currently available, and also no clang localy. It would be greate if you could run this, after your import, if you don't mind. Same for enum.py, currently I have no python installed. If not I'll try my best to set this up locally, could take a while (the clang environment).

I would like to do this, but setting everything up on my maschine would be a huge job. As I have no linux runtime currently available, and also no clang localy. It would be greate if you could run this, after your import, if you don't mind. Same for enum.py, currently I have no python installed. If not I'll try my best to set this up locally, could take a while (the clang environment).
facebook-github-bot commented 2016-12-19 10:28:20 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/26ad37af79edaa88e451a9b0f08eb0bdd518aa04..9ea8e73dd529c75f18ddd8f2339d01f5f3ca4f73)
woehrl01 (Migrated from github.com) reviewed 2016-12-19 10:28:57 -08:00
woehrl01 (Migrated from github.com) commented 2016-12-19 10:28:56 -08:00

ups, got it to work, just can't return it at the same time. 😕

ups, got it to work, just can't return it at the same time. 😕
facebook-github-bot commented 2016-12-19 10:35:45 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/9ea8e73dd529c75f18ddd8f2339d01f5f3ca4f73..a6bdf6abf12f8a8dce93a21c565fa5e96462f7bf)
facebook-github-bot commented 2016-12-19 10:42:05 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/a6bdf6abf12f8a8dce93a21c565fa5e96462f7bf..fae6b6352f6fb0be5126f6285733415200edc9e0)
emilsjolander (Migrated from github.com) approved these changes 2016-12-19 11:58:21 -08:00
emilsjolander (Migrated from github.com) left a comment

Looking very good. Two tiny changes just

Looking very good. Two tiny changes just
@@ -38,6 +38,11 @@ typedef struct YGSize {
float height;
emilsjolander (Migrated from github.com) commented 2016-12-19 11:56:48 -08:00

isDefined

isDefined
@@ -108,12 +113,26 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \
emilsjolander (Migrated from github.com) commented 2016-12-19 11:57:20 -08:00

##name##( -> ##name(

##name##( -> ##name(
woehrl01 (Migrated from github.com) reviewed 2016-12-19 12:09:04 -08:00
@@ -38,6 +38,11 @@ typedef struct YGSize {
float height;
woehrl01 (Migrated from github.com) commented 2016-12-19 12:09:04 -08:00

great idea!

great idea!
facebook-github-bot commented 2016-12-19 12:11:23 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/fae6b6352f6fb0be5126f6285733415200edc9e0..cac8d3715b7a58620c8ad28890ca468ed3b4af13)
emilsjolander commented 2016-12-19 13:01:34 -08:00 (Migrated from github.com)

There are some merge conflicts according to github, otherwise looks good. Will try to import internally tomorrow.

There are some merge conflicts according to github, otherwise looks good. Will try to import internally tomorrow.
facebook-github-bot commented 2016-12-19 14:05:00 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/cac8d3715b7a58620c8ad28890ca468ed3b4af13..1cb7ca431d92c34eaa29bd5e71f2fbee122194b7)
woehrl01 commented 2016-12-19 14:05:50 -08:00 (Migrated from github.com)

did a merge with the upstream and modified the c# wrapper. All c# tests are green for me.

did a merge with the upstream and modified the c# wrapper. All c# tests are green for me.
facebook-github-bot commented 2016-12-19 14:17:49 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/1cb7ca431d92c34eaa29bd5e71f2fbee122194b7..d1d0618d4c7f333d3d0a930918d11a688f16bc9a)
facebook-github-bot commented 2016-12-19 14:48:16 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/d1d0618d4c7f333d3d0a930918d11a688f16bc9a..08eb9ff8f7ed2e90e1667a08d72a95416f76efc8)
facebook-github-bot commented 2016-12-19 22:33:55 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/08eb9ff8f7ed2e90e1667a08d72a95416f76efc8..2424fc2b12e98d433f046b4e3d3c52f981d73722)
emilsjolander commented 2016-12-20 00:24:59 -08:00 (Migrated from github.com)

Seems like the benchmarks, csharp, and java tests are still failing. I can take a look tomorrow

Seems like the benchmarks, csharp, and java tests are still failing. I can take a look tomorrow
facebook-github-bot commented 2016-12-20 00:30:37 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/2424fc2b12e98d433f046b4e3d3c52f981d73722..306e16fbb845bbb13b0d30f0327cf37c78ae1395)
facebook-github-bot commented 2016-12-20 00:31:39 -08:00 (Migrated from github.com)

@woehrl01 updated the pull request - view changes

@woehrl01 updated the pull request - [view changes](https://github.com/facebook/yoga/pull/258/files/306e16fbb845bbb13b0d30f0327cf37c78ae1395..abf97d6613f6250128e9ff196658d9f173e6faa9)
woehrl01 commented 2016-12-20 00:34:31 -08:00 (Migrated from github.com)

It would be great if you could take a look at java. It's ages for me the last time I did some JNI.

It would be great if you could take a look at java. It's ages for me the last time I did some JNI.
emilsjolander commented 2016-12-20 01:00:43 -08:00 (Migrated from github.com)

The java version will take a bit more work to update. I'm not super familiar with JNI either tbh. But i'll have a look this week.

The java version will take a bit more work to update. I'm not super familiar with JNI either tbh. But i'll have a look this week.
woehrl01 commented 2016-12-20 11:15:35 -08:00 (Migrated from github.com)

Did some performance improvements (~20%) on my pc:

Stack with flex: median: 0.000000 ms, stddev: 0.143384 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.129271 ms
Nested flex: median: 0.000000 ms, stddev: 0.432434 ms
Huge nested layout: median: 17.000000 ms, stddev: 3.835411 ms

Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.121552 ms
Nested flex: median: 0.000000 ms, stddev: 0.439180 ms
Huge nested layout: median: 16.000000 ms, stddev: 1.645686 ms
Did some performance improvements (~20%) on my pc: ``` Stack with flex: median: 0.000000 ms, stddev: 0.143384 ms Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.129271 ms Nested flex: median: 0.000000 ms, stddev: 0.432434 ms Huge nested layout: median: 17.000000 ms, stddev: 3.835411 ms Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.121552 ms Nested flex: median: 0.000000 ms, stddev: 0.439180 ms Huge nested layout: median: 16.000000 ms, stddev: 1.645686 ms ```
facebook-github-bot commented 2016-12-22 03:04:00 -08:00 (Migrated from github.com)

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

@emilsjolander has imported this pull request. If you are a Facebook employee, you can view this diff [on Phabricator](https://phabricator.intern.facebook.com/D4361945).
emilsjolander commented 2016-12-22 03:58:56 -08:00 (Migrated from github.com)

@woehrl01 While implementing the JNI bindings I thought of a slightly different way to implement this. Wanted to get your thoughts on it.

Instead of YGValue we store the YGUnit and the isDefined flag as part of the numeric value itself. We could reserve a couple bits in the unit's value for these flags. This would require switching from float values to uint64 types, the first 32 bits storing the meta data and the second 32 bits storing the floating point value.

This would allow for a couple things.

  • Not changing the API. YGNodeStyleSetWidth(node, 10) would still set the width of a node to the pixel value of 10.
  • Only require calling a YGValue constructor when using percentage (which should be much more seldom than pixel values). YGNodeStyleSetWidth(node, YGPercent(10)) would set the width of the node to 10%.

The major downside is that we would no longer allow setting a floating point value directly as the parameter is now a integer, YGNodeStyleSetWidth(node, 10.5) would be a compile time error. We might be OK with this though as setting half pixels on styles is generally discouraged anyways. The thing to keep in mind here is platforms not using Yoga with pixels but points instead (iOS). This would require them to transform pixel value to points before passing values to Yoga (but we control the bindings here so the end user should not need to care). @dshahidehpour What do you think about this?

This idea came from the implementing the java bindings as there we need to do this either way to avoid allocations and passing larger objects over JNI which can be much more expensive than primitive types such as floats and integers.

@woehrl01 While implementing the JNI bindings I thought of a slightly different way to implement this. Wanted to get your thoughts on it. Instead of `YGValue` we store the `YGUnit` and the `isDefined` flag as part of the numeric value itself. We could reserve a couple bits in the unit's value for these flags. This would require switching from `float` values to `uint64` types, the first 32 bits storing the meta data and the second 32 bits storing the floating point value. This would allow for a couple things. - Not changing the API. `YGNodeStyleSetWidth(node, 10)` would still set the width of a node to the pixel value of 10. - Only require calling a `YGValue` constructor when using percentage (which should be much more seldom than pixel values). `YGNodeStyleSetWidth(node, YGPercent(10))` would set the width of the node to 10%. The major downside is that we would no longer allow setting a floating point value directly as the parameter is now a integer, `YGNodeStyleSetWidth(node, 10.5)` would be a compile time error. We might be OK with this though as setting half pixels on styles is generally discouraged anyways. The thing to keep in mind here is platforms not using Yoga with pixels but points instead (iOS). This would require them to transform pixel value to points before passing values to Yoga (but we control the bindings here so the end user should not need to care). @dshahidehpour What do you think about this? This idea came from the implementing the java bindings as there we need to do this either way to avoid allocations and passing larger objects over JNI which can be much more expensive than primitive types such as floats and integers.
woehrl01 commented 2016-12-22 04:22:23 -08:00 (Migrated from github.com)

@emilsjolander
Sounds good! I have an extended idea on top of it.

if you call YGNodeStyleSetWidth(node, 10) you will set an u_int64 where the upper bits are fully 0. Which means we provide an int in the lower. If we call it with YGNodeStyleSetWidth(node, YGPx(10.5)) we store the lower as a float and add an additional flag in the upper bits to detect this. So we can still set floating values via the api, we just need to be explicitly use YGPx then.

Idea 1: Regarding points and pixel. Maybe we should rename it and use Points instead of Pixel all over.
Idea 2: We extend the Api with an additonal Points value factor (like setting the logger). So we can also do the rounding with higher density + an additional YGUnitPoints where we calculate unit.value * densityFactor which addionally provides subpixel rounding.

@emilsjolander Sounds good! I have an extended idea on top of it. if you call ```YGNodeStyleSetWidth(node, 10)``` you will set an u_int64 where the upper bits are fully 0. Which means we provide an int in the lower. If we call it with ```YGNodeStyleSetWidth(node, YGPx(10.5))``` we store the lower as a float and add an additional flag in the upper bits to detect this. So we can still set floating values via the api, we just need to be explicitly use ```YGPx``` then. Idea 1: Regarding points and pixel. Maybe we should rename it and use Points instead of Pixel all over. Idea 2: We extend the Api with an additonal Points value factor (like setting the logger). So we can also do the rounding with higher density + an additional YGUnitPoints where we calculate ```unit.value * densityFactor``` which addionally provides subpixel rounding.
d16r commented 2016-12-22 04:23:02 -08:00 (Migrated from github.com)

The major downside is that we would no longer allow setting a floating point value directly as the parameter is now a integer, YGNodeStyleSetWidth(node, 10.5) would be a compile time error.

I think this is a huge piece of functionality to throw away. As you correctly stated in your comment, iOS deals with Points, not Pixels. If someone gave us a design where they wanted to something to be 21 pixels wide (very reasonable), it would no longer be possible to use Yoga on iOS because this is how you would define value so of 21 pixels:

YGNodeStyleSetWidth(node, 10.5); // non-retina phones.
YGNodeStyleSetWidth(node, 7) // retina-phones.

So, I'm very much against that.

Only require calling a YGValue constructor when using percentage (which should be much more seldom than pixel values). YGNodeStyleSetWidth(node, YGPercent(10)) would set the width of the node to 10%.

I like this API, but, I think we would have to rename YGPx to something else. I don't think that Yoga should know (or care) what the units of a coordinate system are. It should only care that you are dealing with absolute values or ratio values (percents). For all we care, someone could be using Yoga to calculate the layout of their new backyard and all the measurements are in meters.

cc: @emilsjolander

> The major downside is that we would no longer allow setting a floating point value directly as the parameter is now a integer, YGNodeStyleSetWidth(node, 10.5) would be a compile time error. I think this is a huge piece of functionality to throw away. As you correctly stated in your comment, iOS deals with Points, not Pixels. If someone gave us a design where they wanted to something to be 21 *pixels* wide (very reasonable), it would no longer be possible to use Yoga on iOS because this is how you would define value so of 21 pixels: ```objc YGNodeStyleSetWidth(node, 10.5); // non-retina phones. YGNodeStyleSetWidth(node, 7) // retina-phones. ``` So, I'm very much against that. > Only require calling a YGValue constructor when using percentage (which should be much more seldom than pixel values). YGNodeStyleSetWidth(node, YGPercent(10)) would set the width of the node to 10%. I like this API, but, I think we would have to rename `YGPx` to something else. I don't think that Yoga should know (or care) what the units of a coordinate system are. It should only care that you are dealing with absolute values or ratio values (percents). For all we care, someone could be using Yoga to calculate the layout of their new backyard and all the measurements are in meters. cc: @emilsjolander
emilsjolander commented 2016-12-22 04:30:15 -08:00 (Migrated from github.com)

We are going to need to introduce some notion of Points into Yoga at some point. Currently pixel rounding (behind experiment) is kinda broken on iOS as it does not take the point scale factor into account.

So we could end up with an API similar to this where pixel values have to be integers but both points and percentage values can be floating point. The point scale factor would also be taken into account when performing pixel rounding.

YGSetPointScaleFactor([UIScreen mainScreen].scale)
YGNodeStyleSetWidth(node, 10)
YGNodeStyleSetWidth(node, YGPoint(10.0))
YGNodeStyleSetWidth(node, YGPercent(10.0))

I agree that the API for iOS developers still has to be nice. But I think this is where YogaKit plays a vital role. YogaKit allows us to hide some of this detail behind the scenes and always just default to point values and setting the scale factor automatically.

@dshahidehpour how does that sound? I'm not by any means certain about this.

We are going to need to introduce some notion of Points into Yoga at some point. Currently pixel rounding (behind experiment) is kinda broken on iOS as it does not take the point scale factor into account. So we could end up with an API similar to this where pixel values have to be integers but both points and percentage values can be floating point. The point scale factor would also be taken into account when performing pixel rounding. ```C YGSetPointScaleFactor([UIScreen mainScreen].scale) YGNodeStyleSetWidth(node, 10) YGNodeStyleSetWidth(node, YGPoint(10.0)) YGNodeStyleSetWidth(node, YGPercent(10.0)) ``` I agree that the API for iOS developers still has to be nice. But I think this is where `YogaKit` plays a vital role. `YogaKit` allows us to hide some of this detail behind the scenes and always just default to point values and setting the scale factor automatically. @dshahidehpour how does that sound? I'm not by any means certain about this.
woehrl01 commented 2016-12-22 04:40:18 -08:00 (Migrated from github.com)

@emilsjolander do you want to replace the struct inside the c, too? Could reduce the memory footprint of new nodes as currently we do not perfectly memory align due to the bool flag.

@emilsjolander do you want to replace the struct inside the c, too? Could reduce the memory footprint of new nodes as currently we do not perfectly memory align due to the bool flag.
emilsjolander commented 2016-12-22 04:42:01 -08:00 (Migrated from github.com)

@woehrl01 yeah, as I see it YGValue would just be an alias for a uint64_t. But please don't start making any changes yet as we aren't certain about this yet 👍 Don't want you to waste any time

@woehrl01 yeah, as I see it `YGValue` would just be an alias for a `uint64_t`. But please don't start making any changes yet as we aren't certain about this yet 👍 Don't want you to waste any time
woehrl01 commented 2016-12-22 04:44:21 -08:00 (Migrated from github.com)

@emilsjolander no worries 😄 . But how about negative values? YGNodeStyleSetPosition(node, YGEdgeTop, -10) would possibly throw some warnings.

@emilsjolander no worries 😄 . But how about negative values? ```YGNodeStyleSetPosition(node, YGEdgeTop, -10)``` would possibly throw some warnings.
emilsjolander commented 2016-12-22 04:46:36 -08:00 (Migrated from github.com)

haha yeah, so perhaps int64_t and not uint64_t :p

haha yeah, so perhaps `int64_t` and not `uint64_t` :p
d16r commented 2016-12-22 04:55:33 -08:00 (Migrated from github.com)

We are going to need to introduce some notion of Points into Yoga at some point. Currently pixel rounding (behind experiment) is kinda broken on iOS as it does not take the point scale factor into account.

Regardless of whether or not the experiment is running, we always round the values in YogaKit to make sure they correct. YGRoundPixelValue does take the devices scale into account.

So we could end up with an API similar to this where pixel values have to be integers but both points and percentage values can be floating point. The point scale factor would also be taken into account when performing pixel rounding.

That sounds kinda complex to me. Wouldn't it make more sense to remove units from this library completely and generalize it? I'd rather leave the burden of points, pixels to YogaKit and keep the C-library agnostic of different units.

> We are going to need to introduce some notion of Points into Yoga at some point. Currently pixel rounding (behind experiment) is kinda broken on iOS as it does not take the point scale factor into account. Regardless of whether or not the experiment is running, we always round the values in `YogaKit` to make sure they [correct](https://github.com/facebook/yoga/blob/master/YogaKit/UIView%2BYoga.m#L381). `YGRoundPixelValue` does take the devices scale into account. > So we could end up with an API similar to this where pixel values have to be integers but both points and percentage values can be floating point. The point scale factor would also be taken into account when performing pixel rounding. That sounds kinda complex to me. Wouldn't it make more sense to remove units from this library completely and generalize it? I'd rather leave the burden of points, pixels to `YogaKit` and keep the C-library agnostic of different units.
emilsjolander commented 2016-12-22 05:22:59 -08:00 (Migrated from github.com)

Regardless of whether or not the experiment is running, we always round the values in YogaKit to make sure they correct. YGRoundPixelValue does take the devices scale into account.

Other platforms also have some notion of 'Points'. Moving this into Yoga would allow us to keep the rounding logic in one place.

That sounds kinda complex to me.

I don't disagree. I would prefer if we could have an api more like this. Where the default scale factor is 1, making pixels the default but allowing users to specify another scale factor to use the value as a point (would not be part of this PR but a possible future addition).

YGSetPixelScaleFactor([UIScreen mainScreen].scale)
YGNodeStyleSetWidth(node, 10.0)
YGNodeStyleSetWidth(node, YGPercent(10.0))

However this is not possible as we can't store bit flags on a floating point value. So the alternative then is to have any api where percentage values are specified via a different function call, which I would be fine with as well.

YGNodeStyleSetWidth(node, 10.0)
YGNodeStyleSetWidthPercent(node, 10.0)

--

I think it boils down to having on of these two APIs. (I included the scale factor api for show but that would be a different pull request ofc).

1

YGSetPointScaleFactor([UIScreen mainScreen].scale)
YGNodeStyleSetWidth(node, 10)
YGNodeStyleSetWidth(node, YGPoint(10.0))
YGNodeStyleSetWidth(node, YGPercent(10.0))

2

YGSetPixelScaleFactor([UIScreen mainScreen].scale)
YGNodeStyleSetWidth(node, 10.0)
YGNodeStyleSetWidthPercent(node, 10.0)

--

I think I prefer 2 as that would allow all existing code to function as it currently does and make it clear when using percentage values. A previous version of this PR had a very similar API YGNodeStyleSetWidthWithUnit but in that case there would be two ways of setting pixel values which I would prefer not to have. The argument can be made that exposing a Unit setter would allow the addition of more units in the future without adding to the API, however I don't see us adding other units in the near future (I could of course be very wrong on this point).

What option do you both prefer? Or would you prefer a third alternative?

> Regardless of whether or not the experiment is running, we always round the values in YogaKit to make sure they correct. YGRoundPixelValue does take the devices scale into account. Other platforms also have some notion of 'Points'. Moving this into Yoga would allow us to keep the rounding logic in one place. > That sounds kinda complex to me. I don't disagree. I would prefer if we could have an api more like this. Where the default scale factor is 1, making pixels the default but allowing users to specify another scale factor to use the value as a point (would not be part of this PR but a possible future addition). ```c YGSetPixelScaleFactor([UIScreen mainScreen].scale) YGNodeStyleSetWidth(node, 10.0) YGNodeStyleSetWidth(node, YGPercent(10.0)) ``` However this is not possible as we can't store bit flags on a floating point value. So the alternative then is to have any api where percentage values are specified via a different function call, which I would be fine with as well. ```c YGNodeStyleSetWidth(node, 10.0) YGNodeStyleSetWidthPercent(node, 10.0) ``` -- I think it boils down to having on of these two APIs. (I included the scale factor api for show but that would be a different pull request ofc). ### 1 ```c YGSetPointScaleFactor([UIScreen mainScreen].scale) YGNodeStyleSetWidth(node, 10) YGNodeStyleSetWidth(node, YGPoint(10.0)) YGNodeStyleSetWidth(node, YGPercent(10.0)) ``` ### 2 ```c YGSetPixelScaleFactor([UIScreen mainScreen].scale) YGNodeStyleSetWidth(node, 10.0) YGNodeStyleSetWidthPercent(node, 10.0) ``` -- I think I prefer 2 as that would allow all existing code to function as it currently does and make it clear when using percentage values. A previous version of this PR had a very similar API `YGNodeStyleSetWidthWithUnit` but in that case there would be two ways of setting pixel values which I would prefer not to have. The argument can be made that exposing a `Unit` setter would allow the addition of more units in the future without adding to the API, however I don't see us adding other units in the near future (I could of course be very wrong on this point). What option do you both prefer? Or would you prefer a third alternative?
d16r commented 2016-12-22 05:25:33 -08:00 (Migrated from github.com)

I would also prefer #2!

I would also prefer #2!
woehrl01 commented 2016-12-22 05:34:08 -08:00 (Migrated from github.com)

I would still prefer to provide the unit with one function call. I think this would make the interop call much simpler, as we don't have to call different functions.

I would not like to have a .width + .widthPercent method inside my code or do some magic trickery behind the setters.

So if want to have an "no unit" setter and no "struct" setter, I would make a

YGNodeStyleSetWidthWithUnit(node, 10.0, YGUnitPercent)

Not sure how you want to return the value in the getter, if there is percentage set?

you would need to guess if you need to call YGNodeStyleGetWidthPercent() or YGNodeStyleGetWidth()

Calling set with a different type, where get returns another is also not very ideal.

So I would prefere nummero 1 😄

I would still prefer to provide the unit with one function call. I think this would make the interop call much simpler, as we don't have to call different functions. I would not like to have a ```.width``` + ```.widthPercent``` method inside my code or do some magic trickery behind the setters. So if want to have an "no unit" setter and no "struct" setter, I would make a ``` YGNodeStyleSetWidthWithUnit(node, 10.0, YGUnitPercent) ``` Not sure how you want to return the value in the getter, if there is percentage set? you would need to guess if you need to call ```YGNodeStyleGetWidthPercent()``` or ```YGNodeStyleGetWidth()``` Calling set with a different type, where get returns another is also not very ideal. So I would prefere nummero 1 😄
emilsjolander commented 2016-12-22 05:39:52 -08:00 (Migrated from github.com)

Even with option 2 the return value of the getters would be of the current YGValue type, otherwise as you say you would have to guess the correct getter.

I think this would make the interop call much simpler.

I don't think the language bindings have to match the C API exactly. The language bindings should use an API with suites that language best. in java this will probably be setWidthPercent() but as the .NET bindings use properties and not methods a YGValue type abstraction in c# would probably make most sense.

Even with option 2 the return value of the getters would be of the current `YGValue` type, otherwise as you say you would have to guess the correct getter. > I think this would make the interop call much simpler. I don't think the language bindings have to match the C API exactly. The language bindings should use an API with suites that language best. in java this will probably be `setWidthPercent()` but as the .NET bindings use properties and not methods a `YGValue` type abstraction in c# would probably make most sense.
woehrl01 commented 2016-12-22 05:46:43 -08:00 (Migrated from github.com)

I don't think the language bindings have to match the C API exactly

I fully agree, thats the reason I would like to make the C API as generic as possible. Which leads me to your first suggestion. I also think that in Java setWidthPercent() could be a great name.

> I don't think the language bindings have to match the C API exactly I fully agree, thats the reason I would like to make the C API as generic as possible. Which leads me to your first suggestion. I also think that in Java ```setWidthPercent()``` could be a great name.
emilsjolander commented 2016-12-22 06:10:23 -08:00 (Migrated from github.com)

I think leaving YGNodeStyleSetWidth(node, 10.0) working as it does today is a good idea because

  1. Most code does not use percentage values so keeping that short and concise is nice.
  2. It does not break any current usages. (I know I previously mentioned this is not a huge issue. It is a nice benefit however and I have been made aware of more users of the pure C api)

So I think the only open question right now is wether to have

  1. YGNodeStyleSetWidthPercent(YGNode, float)
  2. YGNodeStyleSetWidthWithUnit(YGNode, YGUnit, float)

In 2, YGNodeStyleSetWidth(YGNode, float) would just be a shorthand for YGNodeStyleSetWidthWithUnit(YGNode, YGUnitPixel, float).

I prefer YGNodeStyleSetWidthPercent(YGNode, float) as it is a more clear name and the main benefit of the more generic YGNodeStyleSetWidthWithUnit(YGNode, YGUnitPixel, float) is the ability to add more units later which I don't expect we will and if we do then we can tackle it then. I don't want to create a very generic solution where one is not needed.

As I earlier the return value of the getters will still need to be of type YGValue.

I think leaving `YGNodeStyleSetWidth(node, 10.0)` working as it does today is a good idea because 1. Most code does not use percentage values so keeping that short and concise is nice. 2. It does not break any current usages. (I know I previously mentioned this is not a huge issue. It is a nice benefit however and I have been made aware of more users of the pure C api) So I think the only open question right now is wether to have 1. `YGNodeStyleSetWidthPercent(YGNode, float)` 2. `YGNodeStyleSetWidthWithUnit(YGNode, YGUnit, float)` In 2, `YGNodeStyleSetWidth(YGNode, float)` would just be a shorthand for `YGNodeStyleSetWidthWithUnit(YGNode, YGUnitPixel, float)`. I prefer `YGNodeStyleSetWidthPercent(YGNode, float)` as it is a more clear name and the main benefit of the more generic `YGNodeStyleSetWidthWithUnit(YGNode, YGUnitPixel, float)` is the ability to add more units later which I don't expect we will and if we do then we can tackle it then. I don't want to create a very generic solution where one is not needed. As I earlier the return value of the getters will still need to be of type `YGValue`.
woehrl01 commented 2016-12-22 07:15:38 -08:00 (Migrated from github.com)

I totally understand the thoughts behind that API. The only thing the bugs me, is that the getter and setter have different types or at least there isn't any matching method pair.

Having this kind of api, is not very self explaining, imo:

void YGNodeStyleSetWidth(YGNode, float)
void YGNodeStyleSetWidthPercent(YGNode, float)
YGValue YGNodeStyleGetWidth(YGNode)
I totally understand the thoughts behind that API. The only thing the bugs me, is that the getter and setter have different types or at least there isn't any matching method pair. Having this kind of api, is not very self explaining, imo: ``` void YGNodeStyleSetWidth(YGNode, float) void YGNodeStyleSetWidthPercent(YGNode, float) YGValue YGNodeStyleGetWidth(YGNode) ```
woehrl01 commented 2016-12-22 07:41:12 -08:00 (Migrated from github.com)

@emilsjolander @dshahidehpour By the way: if you both think this is the prefered way, I'm totally fine doing this. I just want to play some kind of devil's advocate and challenge the decision.

@emilsjolander @dshahidehpour By the way: if you both think this is the prefered way, I'm totally fine doing this. I just want to play some kind of devil's advocate and challenge the decision.
woehrl01 commented 2016-12-22 23:08:21 -08:00 (Migrated from github.com)

@emilsjolander some additional ideas / thoughts:

What I like about suggestion 2:

  1. It's hard to abuse it. We don't have to check if the provided values, are a matching UnitType as we provide the unit via the function name.

  2. We could hide the unit enum completely and add an additonal "UndefinedUnit", so we don't have to do some magic bit fiddling in the upper part for an "isDefined" bit.

Not sure if it's a good idea to do a typedef for YGValue because of the implicit cast possibilities. I'd prefere a struct like YGSize.

@emilsjolander some additional ideas / thoughts: What I like about suggestion 2: 1. It's hard to abuse it. We don't have to check if the provided values, are a matching UnitType as we provide the unit via the function name. 1. We could hide the unit enum completely and add an additonal "UndefinedUnit", so we don't have to do some magic bit fiddling in the upper part for an "isDefined" bit. Not sure if it's a good idea to do a typedef for ```YGValue``` because of the implicit cast possibilities. I'd prefere a struct like ```YGSize```.
emilsjolander commented 2016-12-23 01:42:28 -08:00 (Migrated from github.com)

Having this kind of api, is not very self explaining, imo:

Agreed, it is not perfect. I think it is the best option now though. Let's make sure to document it!

Not sure if it's a good idea to do a typedef for YGValue...

No reason to do any bit fiddling with this api. Keep the YGValue struct and YGUnit as is in the current state.

> Having this kind of api, is not very self explaining, imo: Agreed, it is not perfect. I think it is the best option now though. Let's make sure to document it! > Not sure if it's a good idea to do a typedef for YGValue... No reason to do any bit fiddling with this api. Keep the `YGValue` struct and `YGUnit` as is in the current state.
woehrl01 commented 2016-12-23 01:56:43 -08:00 (Migrated from github.com)

No reason to do any bit fiddling with this api. Keep the YGValue struct and YGUnit as is in the current state.

what's your opinion about the idea of putting Definied as a "unit"? As an undefined YGPx + undefined YGPercent doesn't really make sense, imo.

so we can at least reduce the byte for the bool flag and won't leak any implementation detail into the YGValue return struct.

> No reason to do any bit fiddling with this api. Keep the YGValue struct and YGUnit as is in the current state. what's your opinion about the idea of putting Definied as a "unit"? As an undefined YGPx + undefined YGPercent doesn't really make sense, imo. so we can at least reduce the byte for the bool flag and won't leak any implementation detail into the YGValue return struct.
emilsjolander commented 2016-12-23 01:58:55 -08:00 (Migrated from github.com)

I'm fine with that 👍

I'm fine with that 👍
woehrl01 commented 2016-12-23 02:05:15 -08:00 (Migrated from github.com)

@emilsjolander Cool 👍 ! If there aren't any other opinions, I'd like to summarize our decision before I "get my hands dirty": 👏

  1. Change the setter into two setters -> SetWidth(node, float) + SetWidthPercent(node, float)
  2. Substitute the bool undefined flag, with an additonal enum type YGUnitUndefined
  3. Keep the getter as is.

Questions/Brainstorm:
How about the naming of the unit for pixel? As @dshahidehpour pointed out, some users won't care, should this be named differently? Maybe YGUnitAbsolute, YGUnitRelative instead of pixel and percent?

@emilsjolander Cool 👍 ! If there aren't any other opinions, I'd like to summarize our decision before I "get my hands dirty": 👏 1. Change the setter into two setters -> ```SetWidth(node, float)``` + ```SetWidthPercent(node, float)``` 1. Substitute the bool undefined flag, with an additonal enum type ```YGUnitUndefined``` 1. Keep the getter as is. Questions/Brainstorm: How about the naming of the unit for pixel? As @dshahidehpour pointed out, some users won't care, should this be named differently? Maybe ```YGUnitAbsolute```, ```YGUnitRelative``` instead of pixel and percent?
emilsjolander commented 2016-12-23 02:08:03 -08:00 (Migrated from github.com)

Summary looks good. Again, you can leave the JNI stuff to me if you want. Regarding YGUnitPixel I think it is fine as is. Most usages are pixels or some form of pixel abstraction such as points. Trying to generalize to any possible unit just makes it more confusing imho.

Summary looks good. Again, you can leave the JNI stuff to me if you want. Regarding `YGUnitPixel` I think it is fine as is. Most usages are pixels or some form of pixel abstraction such as points. Trying to generalize to any possible unit just makes it more confusing imho.
woehrl01 commented 2016-12-23 02:18:44 -08:00 (Migrated from github.com)

you can leave the JNI stuff to me if you want

That would be great, thanks!

Trying to generalize to any possible unit just makes it more confusing

agree 👍

> you can leave the JNI stuff to me if you want That would be great, thanks! > Trying to generalize to any possible unit just makes it more confusing agree 👍
emilsjolander (Migrated from github.com) reviewed 2016-12-23 13:53:34 -08:00
emilsjolander (Migrated from github.com) left a comment

Tests still include a bunch of statements such as YGNodeStyleSetWidth(root, YGPx(100)) which should be YGNodeStyleSetWidth(root, 100) according to the previous discussions.

Tests still include a bunch of statements such as `YGNodeStyleSetWidth(root, YGPx(100))` which should be `YGNodeStyleSetWidth(root, 100)` according to the previous discussions.
@@ -8,6 +8,12 @@
# Visual studio code
.vscode
*.pdb
emilsjolander (Migrated from github.com) commented 2016-12-23 13:48:55 -08:00

please mirror these changes in .hgignore

please mirror these changes in .hgignore
@@ -17,6 +17,11 @@ ENUMS = {
'LTR',
emilsjolander (Migrated from github.com) commented 2016-12-23 13:51:01 -08:00

indentation

indentation
emilsjolander commented 2016-12-23 13:54:23 -08:00 (Migrated from github.com)

Tests still include a bunch of statements such as YGNodeStyleSetWidth(root, YGPx(100)) which should be YGNodeStyleSetWidth(root, 100) according to the previous discussions.

Disregard. I see you still have commits you are pushing 👍

> Tests still include a bunch of statements such as YGNodeStyleSetWidth(root, YGPx(100)) which should be YGNodeStyleSetWidth(root, 100) according to the previous discussions. Disregard. I see you still have commits you are pushing 👍
emilsjolander (Migrated from github.com) reviewed 2016-12-23 13:57:12 -08:00
@@ -17,6 +17,11 @@ ENUMS = {
'LTR',
'RTL',
emilsjolander (Migrated from github.com) commented 2016-12-23 13:57:12 -08:00

'Unit' is still wrongly indented compared to other enums

'Unit' is still wrongly indented compared to other enums
woehrl01 (Migrated from github.com) reviewed 2016-12-23 13:58:18 -08:00
@@ -17,6 +17,11 @@ ENUMS = {
'LTR',
'RTL',
woehrl01 (Migrated from github.com) commented 2016-12-23 13:58:18 -08:00

😖 sorry, will do (all my editors are configured to use tabs instead of spaces)

😖 sorry, will do (all my editors are configured to use tabs instead of spaces)
emilsjolander commented 2016-12-23 14:04:52 -08:00 (Migrated from github.com)

benchmarks, C tests, and c# tests are failing. Once those are passing i'll import and fix the java and obj-c bits.

benchmarks, C tests, and c# tests are failing. Once those are passing i'll import and fix the java and obj-c bits.
woehrl01 commented 2016-12-23 14:18:43 -08:00 (Migrated from github.com)

As I don't have clang, could you please lead me to the right direction how to fix this:

yoga/Yoga.c:171:169: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
    .border = { [YGEdgeLeft] = __builtin_nanf("0x7fc00000"), [YGEdgeTop] = __builtin_nanf("0x7fc00000"), [YGEdgeRight] = __builtin_nanf("0x7fc00000"), [YGEdgeBottom] = __builtin_nanf("0x7fc00000"), [YGEdgeStart] = __builtin_nanf("0x7fc00000"), [YGEdgeEnd] = __builtin_nanf("0x7fc00000"), [YGEdgeHorizontal] = __builtin_nanf("0x7fc00000"), [YGEdgeVertical] = __builtin_nanf("0x7fc00000"), [YGEdgeAll] = __builtin_nanf("0x7fc00000"), },

edit: got it

As I don't have clang, could you please lead me to the right direction how to fix this: ``` yoga/Yoga.c:171:169: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] .border = { [YGEdgeLeft] = __builtin_nanf("0x7fc00000"), [YGEdgeTop] = __builtin_nanf("0x7fc00000"), [YGEdgeRight] = __builtin_nanf("0x7fc00000"), [YGEdgeBottom] = __builtin_nanf("0x7fc00000"), [YGEdgeStart] = __builtin_nanf("0x7fc00000"), [YGEdgeEnd] = __builtin_nanf("0x7fc00000"), [YGEdgeHorizontal] = __builtin_nanf("0x7fc00000"), [YGEdgeVertical] = __builtin_nanf("0x7fc00000"), [YGEdgeAll] = __builtin_nanf("0x7fc00000"), }, ``` edit: got it
emilsjolander commented 2016-12-23 14:19:23 -08:00 (Migrated from github.com)

@woehrl01 In addition to the float extension methods could we add an implicit conversion operator from float -> pixel YGValue? https://msdn.microsoft.com/en-us/library/85w54y0a.aspx

@woehrl01 In addition to the float extension methods could we add an implicit conversion operator from float -> pixel YGValue? https://msdn.microsoft.com/en-us/library/85w54y0a.aspx
woehrl01 commented 2016-12-23 14:20:13 -08:00 (Migrated from github.com)

@woehrl01 In addition to the float extension methods could we add an implicit conversion operator from float -> pixel YGValue? https://msdn.microsoft.com/en-us/library/85w54y0a.aspx

should be already there (YogaValue.cs line: 69)

> @woehrl01 In addition to the float extension methods could we add an implicit conversion operator from float -> pixel YGValue? https://msdn.microsoft.com/en-us/library/85w54y0a.aspx should be already there (YogaValue.cs line: 69)
emilsjolander commented 2016-12-23 14:23:33 -08:00 (Migrated from github.com)

should be already there

Then we should be able to remove the .Px() from the tests right?

> should be already there Then we should be able to remove the `.Px()` from the tests right?
woehrl01 commented 2016-12-23 14:24:46 -08:00 (Migrated from github.com)

Then we should be able to remove the .Px() from the tests right?

true, will do. gimme a minute. 🕐

> Then we should be able to remove the .Px() from the tests right? true, will do. gimme a minute. 🕐
emilsjolander commented 2016-12-23 14:35:52 -08:00 (Migrated from github.com)

I'm happy to start importing this now. Just want to make sure you don't have anything else in the process of being committed?

I'm happy to start importing this now. Just want to make sure you don't have anything else in the process of being committed?
woehrl01 commented 2016-12-23 14:40:30 -08:00 (Migrated from github.com)

No additional changes 👍 if you have no further requests 😉

No additional changes 👍 if you have no further requests 😉
facebook-github-bot commented 2016-12-23 14:45:41 -08:00 (Migrated from github.com)

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

@emilsjolander has imported this pull request. If you are a Facebook employee, you can view this diff [on Phabricator](https://phabricator.intern.facebook.com/D4361945).
srhise commented 2016-12-23 20:28:54 -08:00 (Migrated from github.com)

This may be a dumb question, but how and when can one start to utilize this feature in RN? I'm not familiar with how yoga is versioned into RN. Amazing and very useful work here! Thank you!

This may be a dumb question, but how and when can one start to utilize this feature in RN? I'm not familiar with how yoga is versioned into RN. Amazing and very useful work here! Thank you!
emilsjolander commented 2016-12-24 00:41:14 -08:00 (Migrated from github.com)

@srhise once this is merged RN will be able to expose it by adding percent to their API. I have no ETA to give on this.

@srhise once this is merged RN will be able to expose it by adding percent to their API. I have no ETA to give on this.

Pull request closed

Sign in to join this conversation.
No description provided.