mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Treat indefinite percentages as auto offsets in relative positioning (#31484)
* Treat indefinite percentages as auto offsets in relative positioning Instead of just resolving the percentages against zero. The spec is not clear (https://github.com/w3c/csswg-drafts/issues/9353), but this way we match Gecko, Blink and WebKit. * Update test expectations
This commit is contained in:
parent
3e6b92df13
commit
a977729a9e
4 changed files with 11 additions and 12 deletions
|
@ -875,17 +875,22 @@ pub(crate) fn relative_adjustement(
|
|||
style: &ComputedValues,
|
||||
containing_block: &ContainingBlock,
|
||||
) -> LogicalVec2<Length> {
|
||||
// "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) {
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
[position-relative-007.html]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[calc-offsets-relative-bottom-1.html]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[calc-offsets-relative-top-1.html]
|
||||
expected: FAIL
|
Loading…
Add table
Add a link
Reference in a new issue