diff options
author | Oriol Brufau <obrufau@igalia.com> | 2025-04-03 08:47:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-03 15:47:56 +0000 |
commit | 9d6e1f67fbe06fc56131d85da99ca4dc1380d007 (patch) | |
tree | b3edc96c44d4060314576774f7443c26b4f30f9c /components/layout_2020 | |
parent | 0e99539dab4c059ba3c3750cfda42e246ce8b4f0 (diff) | |
download | servo-9d6e1f67fbe06fc56131d85da99ca4dc1380d007.tar.gz servo-9d6e1f67fbe06fc56131d85da99ca4dc1380d007.zip |
layout: Improve style conversion for Taffy (#36311)
This imports the following changes from Blitz:
- Map position:sticky to relative rather than absolute position
https://github.com/DioxusLabs/blitz/commit/16a7c1654455bee62e83854f83304a2931b29a0d
- Map left and right alignment from Stylo
https://github.com/DioxusLabs/blitz/commit/c71cc681d8c877dbd30853b3c4a2a7449c6450e4
- Improve mapping of align-items/self
https://github.com/DioxusLabs/blitz/commit/7bf2a25e756c1310a9e4603b4757e20548b961e2
Fixes: #35998
Testing:
-
`/css/css-grid/alignment/grid-align-justify-margin-border-padding.html`
- `/css/css-grid/alignment/grid-align.html`
-
`/css/css-grid/alignment/grid-column-axis-alignment-sticky-positioned-items-001.html`
- `/css/css-grid/alignment/grid-gutters-and-alignment.html`
-
`/css/css-grid/alignment/grid-item-alignment-with-orthogonal-flows.html`
-
`/css/css-grid/alignment/grid-row-axis-alignment-sticky-positioned-items-001.html`
- `/css/css-grid/alignment/grid-self-alignment.html`
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Diffstat (limited to 'components/layout_2020')
-rw-r--r-- | components/layout_2020/taffy/stylo_taffy/convert.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/components/layout_2020/taffy/stylo_taffy/convert.rs b/components/layout_2020/taffy/stylo_taffy/convert.rs index 29e76b516ad..03fbec292a4 100644 --- a/components/layout_2020/taffy/stylo_taffy/convert.rs +++ b/components/layout_2020/taffy/stylo_taffy/convert.rs @@ -138,7 +138,7 @@ pub fn position(input: stylo::Position) -> taffy::Position { // TODO: support position:fixed and sticky stylo::Position::Absolute => taffy::Position::Absolute, stylo::Position::Fixed => taffy::Position::Absolute, - stylo::Position::Sticky => taffy::Position::Absolute, + stylo::Position::Sticky => taffy::Position::Relative, } } @@ -170,6 +170,8 @@ pub fn content_alignment(input: stylo::ContentDistribution) -> Option<taffy::Ali stylo::AlignFlags::AUTO => None, stylo::AlignFlags::START => Some(taffy::AlignContent::Start), stylo::AlignFlags::END => Some(taffy::AlignContent::End), + stylo::AlignFlags::LEFT => Some(taffy::AlignContent::Start), + stylo::AlignFlags::RIGHT => Some(taffy::AlignContent::End), stylo::AlignFlags::FLEX_START => Some(taffy::AlignContent::FlexStart), stylo::AlignFlags::STRETCH => Some(taffy::AlignContent::Stretch), stylo::AlignFlags::FLEX_END => Some(taffy::AlignContent::FlexEnd), @@ -185,13 +187,17 @@ pub fn content_alignment(input: stylo::ContentDistribution) -> Option<taffy::Ali #[inline] pub fn item_alignment(input: stylo::AlignFlags) -> Option<taffy::AlignItems> { match input.value() { - stylo::AlignFlags::NORMAL => None, stylo::AlignFlags::AUTO => None, + stylo::AlignFlags::NORMAL => Some(taffy::AlignItems::Stretch), stylo::AlignFlags::STRETCH => Some(taffy::AlignItems::Stretch), stylo::AlignFlags::FLEX_START => Some(taffy::AlignItems::FlexStart), stylo::AlignFlags::FLEX_END => Some(taffy::AlignItems::FlexEnd), + stylo::AlignFlags::SELF_START => Some(taffy::AlignItems::Start), + stylo::AlignFlags::SELF_END => Some(taffy::AlignItems::End), stylo::AlignFlags::START => Some(taffy::AlignItems::Start), stylo::AlignFlags::END => Some(taffy::AlignItems::End), + stylo::AlignFlags::LEFT => Some(taffy::AlignItems::Start), + stylo::AlignFlags::RIGHT => Some(taffy::AlignItems::End), stylo::AlignFlags::CENTER => Some(taffy::AlignItems::Center), stylo::AlignFlags::BASELINE => Some(taffy::AlignItems::Baseline), // Should never be hit. But no real reason to panic here. |