diff --git a/components/layout_2020/positioned.rs b/components/layout_2020/positioned.rs index 09dc1e22293..23964bea93b 100644 --- a/components/layout_2020/positioned.rs +++ b/components/layout_2020/positioned.rs @@ -875,17 +875,22 @@ pub(crate) fn relative_adjustement( style: &ComputedValues, containing_block: &ContainingBlock, ) -> LogicalVec2 { - // "If the height of the containing block is not specified explicitly (i.e., - // it depends on content height), and this element is not absolutely - // positioned, the value computes to 'auto'."" - // https://www.w3.org/TR/CSS2/visudet.html#the-height-property + // It's not completely clear what to do with indefinite percentages + // (https://github.com/w3c/csswg-drafts/issues/9353), so we match + // other browsers and treat them as 'auto' offsets. let cbis = containing_block.inline_size; - let cbbs = containing_block.block_size.auto_is(Au::zero); + let cbbs = containing_block.block_size; let box_offsets = style .box_offsets(containing_block) .map_inline_and_block_axes( |v| v.percentage_relative_to(cbis.into()), - |v| v.percentage_relative_to(cbbs.into()), + |v| match cbbs.non_auto() { + Some(cbbs) => v.percentage_relative_to(cbbs.into()), + None => match v.non_auto().and_then(|v| v.to_length()) { + Some(v) => LengthOrAuto::LengthPercentage(v), + None => LengthOrAuto::Auto, + }, + }, ); fn adjust(start: LengthOrAuto, end: LengthOrAuto) -> Length { match (start, end) { diff --git a/tests/wpt/meta/css/css-position/position-relative-007.html.ini b/tests/wpt/meta/css/css-position/position-relative-007.html.ini deleted file mode 100644 index b2940861997..00000000000 --- a/tests/wpt/meta/css/css-position/position-relative-007.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[position-relative-007.html] - expected: FAIL diff --git a/tests/wpt/meta/css/css-values/calc-offsets-relative-bottom-1.html.ini b/tests/wpt/meta/css/css-values/calc-offsets-relative-bottom-1.html.ini deleted file mode 100644 index 7655e59c091..00000000000 --- a/tests/wpt/meta/css/css-values/calc-offsets-relative-bottom-1.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[calc-offsets-relative-bottom-1.html] - expected: FAIL diff --git a/tests/wpt/meta/css/css-values/calc-offsets-relative-top-1.html.ini b/tests/wpt/meta/css/css-values/calc-offsets-relative-top-1.html.ini deleted file mode 100644 index ad15609b339..00000000000 --- a/tests/wpt/meta/css/css-values/calc-offsets-relative-top-1.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[calc-offsets-relative-top-1.html] - expected: FAIL