mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Fix percentage height calculation, absolute containing block height calculations.
It's not possible to correctly determine during the css cascade whether the container height is explicitly specified. Additionally, the spec https://drafts.csswg.org/css2/visudet.html#the-height-property says this should affect the *used* height, rather than the computed height. This significantly improves the layout in #6643.
This commit is contained in:
parent
ffe4bd25a4
commit
b9fea3deb3
10 changed files with 151 additions and 119 deletions
|
@ -126,29 +126,34 @@ impl MarginCollapseInfo {
|
|||
|
||||
pub fn finish_and_compute_collapsible_margins(mut self,
|
||||
fragment: &Fragment,
|
||||
containing_block_size: Option<Au>,
|
||||
can_collapse_block_end_margin_with_kids: bool)
|
||||
-> (CollapsibleMargins, Au) {
|
||||
let state = match self.state {
|
||||
MarginCollapseState::AccumulatingCollapsibleTopMargin => {
|
||||
match fragment.style().content_block_size() {
|
||||
LengthOrPercentageOrAuto::Auto | LengthOrPercentageOrAuto::Length(Au(0)) |
|
||||
LengthOrPercentageOrAuto::Percentage(0.) => {
|
||||
match fragment.style().min_block_size() {
|
||||
LengthOrPercentage::Length(Au(0)) | LengthOrPercentage::Percentage(0.) => {
|
||||
FinalMarginState::MarginsCollapseThrough
|
||||
},
|
||||
_ => {
|
||||
// If the fragment has non-zero min-block-size, margins may not
|
||||
// collapse through it.
|
||||
FinalMarginState::BottomMarginCollapses
|
||||
}
|
||||
let may_collapse_through = match fragment.style().content_block_size() {
|
||||
LengthOrPercentageOrAuto::Auto => true,
|
||||
LengthOrPercentageOrAuto::Length(Au(0)) => true,
|
||||
LengthOrPercentageOrAuto::Percentage(0.) => true,
|
||||
LengthOrPercentageOrAuto::Percentage(_) if containing_block_size.is_none() => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
if may_collapse_through {
|
||||
match fragment.style().min_block_size() {
|
||||
LengthOrPercentage::Length(Au(0)) | LengthOrPercentage::Percentage(0.) => {
|
||||
FinalMarginState::MarginsCollapseThrough
|
||||
},
|
||||
_ => {
|
||||
// If the fragment has non-zero min-block-size, margins may not
|
||||
// collapse through it.
|
||||
FinalMarginState::BottomMarginCollapses
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
// If the fragment has an explicitly specified block-size, margins may not
|
||||
// collapse through it.
|
||||
FinalMarginState::BottomMarginCollapses
|
||||
}
|
||||
} else {
|
||||
// If the fragment has an explicitly specified block-size, margins may not
|
||||
// collapse through it.
|
||||
FinalMarginState::BottomMarginCollapses
|
||||
}
|
||||
}
|
||||
MarginCollapseState::AccumulatingMarginIn => FinalMarginState::BottomMarginCollapses,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue