Improve block absolute auto resolution#922
Conversation
|
@AustinMReppert Did you mean to write a proper PR description? Also, was AI used in creating this PR? (AI assisted or even generated PRs are allowed but will be reviewed differently to human-written PRs). The fixtures can be auto formatted with |
|
It was mostly handwritten against the spec. I did use AI to find the original bug and to create some of the test cases. I am hoping to track down #923 before I finish this PR. |
|
Planning to finish this on the weekend. Still needs to be cleaned up. |
|
Feel free to just |
There was a problem hiding this comment.
I encourage you do look at the Rect, Size, Point and Line types from https://github.com/DioxusLabs/taffy/blob/main/src/geometry.rs You should be able to write the same code here significantly less verbosely using these types, their traits impls (they impl things like Add and Sub) and their helper methods.
e.g. border.top + padding.top + padding.bottom + border.bottom; might become padding_border.vertical_axis_sum()
| computed_margin_left = margin_left.unwrap_or(0.0); | ||
| computed_margin_right = margin_right.unwrap_or(0.0); |
There was a problem hiding this comment.
These variables are already set to these values above.
| // Otherwise, set 'auto' values for 'margin-left' and 'margin-right' to 0, and pick the one of the following six rules that applies. | ||
| // These are already our initial values chosen above, so no need to do anything. | ||
|
|
||
| if left.is_none() && width.is_none() && right.is_some() { |
There was a problem hiding this comment.
This if-else chain could be a match
|
This should be mostly ready. I plan to remove a few of the tests tomorrow morning. |
|
The entire |
I had added a few test scenarios to the initial PR, but they passed even with the old implementation. I don't think they added any value. |
Improve Block Layout for Non-Replaced Absolutely Positioned Elements
Why did you make this PR?
The current block implementation does not closely follow the spec. This leads to many edge cases with the block algorithm. This PR addresses improves the layout for non-replaced elements.
Changes that will affect external library users must update RELEASES.md before they will be merged.
None
Context
Discuss any context that may be needed for reviewers to understand the changes you've made.
This may include related issues, previous discussion, or links to documentation or code.
Feedback wanted
Which parts of this PR were you unsure about? Which parts were particularly tricky?
Taffy does not have shrink-to-fit, so I just used content-size.
If you're stuck on part of the changes or want feedback early, open a draft PR and list the items that need to be completed here using a checklist.
The following WPT tests should now pass in Blitz. There were no regressed WPT tests. Running against /css
PASS css/CSS2/positioning/absolute-non-replaced-height-013.html
PASS css/CSS2/positioning/absolute-non-replaced-max-height-011.xht
PASS css/CSS2/positioning/absolute-non-replaced-width-025.xht
PASS css/CSS2/positioning/absolute-non-replaced-width-027.xht
PASS css/css-grid/abspos/grid-positioned-items-and-autofit-tracks-004.html
PASS css/css-grid/abspos/grid-positioned-items-and-autofit-tracks-005.html
PASS css/css-grid/abspos/grid-positioned-items-and-autofit-tracks-006.html
PASS css/css-grid/alignment/grid-content-distribution-with-collapsed-tracks-005.html
PASS css/css-grid/alignment/grid-content-distribution-with-collapsed-tracks-007.html
PASS css/css-grid/alignment/grid-content-distribution-with-collapsed-tracks-009.html
PASS css/css-grid/alignment/grid-content-distribution-with-collapsed-tracks-010.html
PASS css/css-grid/alignment/grid-content-distribution-with-collapsed-tracks-012.html
PASS css/css-grid/alignment/grid-content-distribution-with-collapsed-tracks-014.html
PASS css/css-grid/alignment/grid-content-distribution-with-collapsed-tracks-015.html
PASS css/css-grid/alignment/grid-content-distribution-with-collapsed-tracks-017.html
PASS css/css-grid/alignment/grid-content-distribution-with-collapsed-tracks-019.html
PASS css/css-grid/alignment/grid-content-distribution-with-collapsed-tracks-020.html
PASS css/css-grid/alignment/grid-content-distribution-with-collapsed-tracks-022.html
PASS css/css-grid/alignment/grid-content-distribution-with-collapsed-tracks-024.html
PASS css/css-grid/grid-definition/grid-auto-fill-columns-001.html
PASS css/css-grid/grid-definition/grid-auto-fill-rows-001.html
PASS css/css-grid/grid-definition/grid-auto-fit-columns-001.html
PASS css/css-grid/grid-definition/grid-auto-fit-rows-001.html
PASS css/css-grid/subgrid/parent-repeat-auto-fit-001.html
PASS css/css-grid/subgrid/parent-repeat-auto-fit-002.html
PASS css/css-position/position-absolute-margin-auto-001.html