mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
layout: Disallow margins from collapsing through blocks that have
floated children per CSS 2.1 § 8.3.1. Fixes the test failure in #10458.
This commit is contained in:
parent
4807dadf19
commit
e32455f7b8
2 changed files with 15 additions and 9 deletions
|
@ -809,6 +809,7 @@ impl BlockFlow {
|
||||||
// At this point, `cur_b` is at the content edge of our box. Now iterate over children.
|
// At this point, `cur_b` is at the content edge of our box. Now iterate over children.
|
||||||
let mut floats = self.base.floats.clone();
|
let mut floats = self.base.floats.clone();
|
||||||
let thread_id = self.base.thread_id;
|
let thread_id = self.base.thread_id;
|
||||||
|
let mut had_float_children = false;
|
||||||
for (child_index, kid) in self.base.child_iter_mut().enumerate() {
|
for (child_index, kid) in self.base.child_iter_mut().enumerate() {
|
||||||
if flow::base(kid).flags.contains(IS_ABSOLUTELY_POSITIONED) {
|
if flow::base(kid).flags.contains(IS_ABSOLUTELY_POSITIONED) {
|
||||||
// Assume that the *hypothetical box* for an absolute flow starts immediately
|
// Assume that the *hypothetical box* for an absolute flow starts immediately
|
||||||
|
@ -844,6 +845,7 @@ impl BlockFlow {
|
||||||
// before.
|
// before.
|
||||||
flow::mut_base(kid).floats = floats.clone();
|
flow::mut_base(kid).floats = floats.clone();
|
||||||
if flow::base(kid).flags.is_float() {
|
if flow::base(kid).flags.is_float() {
|
||||||
|
had_float_children = true;
|
||||||
flow::mut_base(kid).position.start.b = cur_b;
|
flow::mut_base(kid).position.start.b = cur_b;
|
||||||
{
|
{
|
||||||
let kid_block = kid.as_mut_block();
|
let kid_block = kid.as_mut_block();
|
||||||
|
@ -932,7 +934,8 @@ impl BlockFlow {
|
||||||
margin_collapse_info.finish_and_compute_collapsible_margins(
|
margin_collapse_info.finish_and_compute_collapsible_margins(
|
||||||
&self.fragment,
|
&self.fragment,
|
||||||
self.base.block_container_explicit_block_size,
|
self.base.block_container_explicit_block_size,
|
||||||
can_collapse_block_end_margin_with_kids);
|
can_collapse_block_end_margin_with_kids,
|
||||||
|
!had_float_children);
|
||||||
self.base.collapsible_margins = collapsible_margins;
|
self.base.collapsible_margins = collapsible_margins;
|
||||||
translate_including_floats(&mut cur_b, delta, &mut floats);
|
translate_including_floats(&mut cur_b, delta, &mut floats);
|
||||||
|
|
||||||
|
|
|
@ -126,17 +126,20 @@ impl MarginCollapseInfo {
|
||||||
pub fn finish_and_compute_collapsible_margins(mut self,
|
pub fn finish_and_compute_collapsible_margins(mut self,
|
||||||
fragment: &Fragment,
|
fragment: &Fragment,
|
||||||
containing_block_size: Option<Au>,
|
containing_block_size: Option<Au>,
|
||||||
can_collapse_block_end_margin_with_kids: bool)
|
can_collapse_block_end_margin_with_kids: bool,
|
||||||
|
mut may_collapse_through: bool)
|
||||||
-> (CollapsibleMargins, Au) {
|
-> (CollapsibleMargins, Au) {
|
||||||
let state = match self.state {
|
let state = match self.state {
|
||||||
MarginCollapseState::AccumulatingCollapsibleTopMargin => {
|
MarginCollapseState::AccumulatingCollapsibleTopMargin => {
|
||||||
let may_collapse_through = match fragment.style().content_block_size() {
|
may_collapse_through = may_collapse_through &&
|
||||||
LengthOrPercentageOrAuto::Auto => true,
|
match fragment.style().content_block_size() {
|
||||||
LengthOrPercentageOrAuto::Length(Au(0)) => true,
|
LengthOrPercentageOrAuto::Auto => true,
|
||||||
LengthOrPercentageOrAuto::Percentage(0.) => true,
|
LengthOrPercentageOrAuto::Length(Au(0)) => true,
|
||||||
LengthOrPercentageOrAuto::Percentage(_) if containing_block_size.is_none() => true,
|
LengthOrPercentageOrAuto::Percentage(0.) => true,
|
||||||
_ => false,
|
LengthOrPercentageOrAuto::Percentage(_) if
|
||||||
};
|
containing_block_size.is_none() => true,
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
|
||||||
if may_collapse_through {
|
if may_collapse_through {
|
||||||
match fragment.style().min_block_size() {
|
match fragment.style().min_block_size() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue