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

Replace Number type with a simpler Option<f32> #144

Merged
merged 14 commits into from
Jun 11, 2022

Conversation

alice-i-cecile
Copy link
Collaborator

Objective

Number is an unhelpful name, and had leaked into the public interface.

This was actually just representing an Option<f32>, and badly obscuring this fact.

Fixes #83.

Feedback wanted

I particularly want feedback on the logic in the new-ish MaybeMath trait. This isn't entirely consistent with the behavior of the previous implementations on Number, but those implementations were surprising in ways that seemed wrong.

I can of course revert them to match exactly, but we should be sure we're following the spec (or at least Chrome's implementation of the spec).

@alice-i-cecile alice-i-cecile added usability Make the library more comfortable to use code quality Make the code cleaner or prettier. labels Jun 11, 2022
src/math.rs Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile added the blocked Cannot be advanced until something else changes label Jun 11, 2022
@alice-i-cecile
Copy link
Collaborator Author

alice-i-cecile commented Jun 11, 2022

Tests are failing, likely due to my tweaks to the Option handling behavior.

@mockersf has promised us a regenerated set of tests and associated bug fixes; I'd like to merge this change after that is in.

@alice-i-cecile alice-i-cecile marked this pull request as draft June 11, 2022 00:37
src/flexbox.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@Weibye Weibye left a comment

Choose a reason for hiding this comment

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

See comments; I'm unable to spot any other changes in the code that would alter the behaviour of the algorithm.

That being said, I like this change!

src/flexbox.rs Outdated Show resolved Hide resolved
src/math.rs Show resolved Hide resolved
src/flexbox.rs Show resolved Hide resolved
) -> Size<Number> {
Size {
width: node_size.width.or_else(parent_size.width - constants.margin.horizontal_axis_sum())
- constants.padding_border.horizontal_axis_sum(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The original implementation here was wrong; padding should only be subtracted if the node width is undefined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

None of the tests seem to care either way about this change though 🙃

@alice-i-cecile alice-i-cecile marked this pull request as ready for review June 11, 2022 21:15
@alice-i-cecile alice-i-cecile added breaking-change A change that breaks our public interface and removed blocked Cannot be advanced until something else changes labels Jun 11, 2022
@alice-i-cecile alice-i-cecile enabled auto-merge (squash) June 11, 2022 21:16
@alice-i-cecile alice-i-cecile merged commit 7283137 into DioxusLabs:main Jun 11, 2022
jkelleyrtp pushed a commit that referenced this pull request Oct 10, 2022
* Update RELEASES.md

* Implement extension traits for Option<f32>

* Replace usages of Number with Option<f32>

* Rename module from number.rs to math.rs

* Note removal of associated traits

* Make behavior of maybe_sub consistent

* Thanks clippy!

* dead_code XD

* Update math operations to be consistent with previous impl

* Reduce churn in PR

* Follow line length calculation spec correctly

* Fix undefined math logic for MaybeMath trait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change A change that breaks our public interface code quality Make the code cleaner or prettier. usability Make the library more comfortable to use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace Number enum with Option<f32>
3 participants