commit 718b5e8f6fc406bdbfd2bed4cffee13bc703c348 parent 93bffe98d4ef2abe2581981ce48e8c89178a275d Author: Jonathan Kew <jkew@mozilla.com> Date: Fri, 2 Jan 2026 19:35:57 +0000 Bug 2006803 - Handle cases where both keywords have axis=none in PositionArea::to_physical(). r=layout-anchor-positioning-reviewers,firefox-style-system-reviewers,emilio Differential Revision: https://phabricator.services.mozilla.com/D277769 Diffstat:
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/servo/components/style/values/specified/position.rs b/servo/components/style/values/specified/position.rs @@ -1380,9 +1380,20 @@ impl PositionArea { /// Turns this <position-area> value into a physical <position-area>. pub fn to_physical(mut self, cb_wm: WritingMode, self_wm: WritingMode) -> Self { self.make_missing_second_explicit(); - self.first = self.first.to_physical(cb_wm, self_wm, LogicalAxis::Block); - self.second = self.second.to_physical(cb_wm, self_wm, LogicalAxis::Inline); - self.canonicalize_order(); + // If both axes are None, to_physical and canonicalize_order are not useful. + // The first value refers to the block axis, the second to the inline axis; + // but as a physical type, they will be interpreted as the x- and y-axis + // respectively, so if the writing mode is horizontal we need to swap the + // values (block -> y, inline -> x). + if self.first.axis() == PositionAreaAxis::None && + self.second.axis() == PositionAreaAxis::None && + !cb_wm.is_vertical() { + std::mem::swap(&mut self.first, &mut self.second); + } else { + self.first = self.first.to_physical(cb_wm, self_wm, LogicalAxis::Block); + self.second = self.second.to_physical(cb_wm, self_wm, LogicalAxis::Inline); + self.canonicalize_order(); + } self } diff --git a/testing/web-platform/meta/css/css-anchor-position/position-area-anchor-outside.html.ini b/testing/web-platform/meta/css/css-anchor-position/position-area-anchor-outside.html.ini @@ -1,6 +0,0 @@ -[position-area-anchor-outside.html] - [Offsets for position-area: span-all center] - expected: FAIL - - [Offsets for position-area: center span-all] - expected: FAIL diff --git a/testing/web-platform/meta/css/css-anchor-position/position-area-anchor-partially-outside.html.ini b/testing/web-platform/meta/css/css-anchor-position/position-area-anchor-partially-outside.html.ini @@ -1,6 +0,0 @@ -[position-area-anchor-partially-outside.html] - [Offsets for position-area: span-all center] - expected: FAIL - - [Offsets for position-area: center span-all] - expected: FAIL