Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat indefinite percentages as auto offsets in relative positioning #31484

Merged
merged 2 commits into from Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions components/layout_2020/positioned.rs
Expand Up @@ -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) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.