diff --git a/components/layout/block.rs b/components/layout/block.rs index e61ad3104c8..b01a31804b2 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -1465,8 +1465,8 @@ impl Flow for BlockFlow { // Find the maximum inline-size from children. let mut computation = self.fragment.compute_intrinsic_inline_sizes(); - let mut left_float_width = Au(0); - let mut right_float_width = Au(0); + let (mut left_float_width, mut right_float_width) = (Au(0), Au(0)); + let (mut left_float_width_accumulator, mut right_float_width_accumulator) = (Au(0), Au(0)); for kid in self.base.child_iter() { let is_absolutely_positioned = flow::base(kid).flags.contains(IS_ABSOLUTELY_POSITIONED); @@ -1477,6 +1477,15 @@ impl Flow for BlockFlow { max(computation.content_intrinsic_sizes.minimum_inline_size, child_base.intrinsic_inline_sizes.minimum_inline_size); + if child_base.flags.contains(CLEARS_LEFT) { + left_float_width = Au::max(left_float_width, left_float_width_accumulator); + left_float_width_accumulator = Au(0) + } + if child_base.flags.contains(CLEARS_RIGHT) { + right_float_width = Au::max(right_float_width, right_float_width_accumulator); + right_float_width_accumulator = Au(0) + } + match float_kind { float::T::none => { computation.content_intrinsic_sizes.preferred_inline_size = @@ -1484,11 +1493,11 @@ impl Flow for BlockFlow { child_base.intrinsic_inline_sizes.preferred_inline_size); } float::T::left => { - left_float_width = left_float_width + + left_float_width_accumulator = left_float_width_accumulator + child_base.intrinsic_inline_sizes.preferred_inline_size; } float::T::right => { - right_float_width = right_float_width + + right_float_width_accumulator = right_float_width_accumulator + child_base.intrinsic_inline_sizes.preferred_inline_size; } } @@ -1500,6 +1509,8 @@ impl Flow for BlockFlow { // FIXME(pcwalton): This should consider all float descendants, not just children. // FIXME(pcwalton): This is not well-spec'd; INTRINSIC specifies to do this, but CSS-SIZING // says not to. In practice, Gecko and WebKit both do this. + left_float_width = Au::max(left_float_width, left_float_width_accumulator); + right_float_width = Au::max(right_float_width, right_float_width_accumulator); computation.content_intrinsic_sizes.preferred_inline_size = max(computation.content_intrinsic_sizes.preferred_inline_size, left_float_width + right_float_width); diff --git a/components/layout/construct.rs b/components/layout/construct.rs index c72de1d122a..c0480e8562c 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -822,7 +822,7 @@ impl<'a> FlowConstructor<'a> { block_flow)); let fragment = Fragment::new(node, fragment_info); - let mut fragment_accumulator = InlineFragmentsAccumulator::from_inline_node(node); + let mut fragment_accumulator = InlineFragmentsAccumulator::new(); fragment_accumulator.fragments.push_back(fragment); let construction_item = diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 8b60b4cfc72..7ad0e8895ad 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -882,8 +882,7 @@ impl Fragment { SpecificFragmentInfo::Generic | SpecificFragmentInfo::GeneratedContent(_) | SpecificFragmentInfo::Iframe(_) | - SpecificFragmentInfo::Image(_) | - SpecificFragmentInfo::InlineBlock(_) => { + SpecificFragmentInfo::Image(_) => { QuantitiesIncludedInIntrinsicInlineSizes::all() } SpecificFragmentInfo::Table | SpecificFragmentInfo::TableCell => { @@ -918,7 +917,8 @@ impl Fragment { SpecificFragmentInfo::ScannedText(_) | SpecificFragmentInfo::TableColumn(_) | SpecificFragmentInfo::UnscannedText(_) | - SpecificFragmentInfo::InlineAbsoluteHypothetical(_) => { + SpecificFragmentInfo::InlineAbsoluteHypothetical(_) | + SpecificFragmentInfo::InlineBlock(_) => { QuantitiesIncludedInIntrinsicInlineSizes::empty() } } diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 5409dba1486..4d54d502ec8 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -115,6 +115,7 @@ flaky_cpu == append_style_a.html append_style_b.html == first_of_type_pseudo_a.html first_of_type_pseudo_b.html == fixed_width_overrides_child_intrinsic_width_a.html fixed_width_overrides_child_intrinsic_width_ref.html == float_clearance_a.html float_clearance_ref.html +== float_clearance_intrinsic_width_a.html float_clearance_intrinsic_width_ref.html == float_intrinsic_height.html float_intrinsic_height_ref.html == float_intrinsic_width_a.html float_intrinsic_width_ref.html == float_right_intrinsic_width_a.html float_right_intrinsic_width_ref.html @@ -161,6 +162,7 @@ flaky_cpu == append_style_a.html append_style_b.html != inline_background_a.html inline_background_ref.html == inline_block_baseline_a.html inline_block_baseline_ref.html == inline_block_border_a.html inline_block_border_ref.html +== inline_block_border_intrinsic_size_a.html inline_block_border_intrinsic_size_ref.html == inline_block_img_a.html inline_block_img_ref.html == inline_block_margin_a.html inline_block_margin_ref.html == inline_block_min_width.html inline_block_min_width_ref.html diff --git a/tests/ref/float_clearance_intrinsic_width_a.html b/tests/ref/float_clearance_intrinsic_width_a.html new file mode 100644 index 00000000000..2e9704a5914 --- /dev/null +++ b/tests/ref/float_clearance_intrinsic_width_a.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + diff --git a/tests/ref/float_clearance_intrinsic_width_ref.html b/tests/ref/float_clearance_intrinsic_width_ref.html new file mode 100644 index 00000000000..3d498ea2b87 --- /dev/null +++ b/tests/ref/float_clearance_intrinsic_width_ref.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + diff --git a/tests/ref/inline_block_border_intrinsic_size_a.html b/tests/ref/inline_block_border_intrinsic_size_a.html new file mode 100644 index 00000000000..7e8a7e0be19 --- /dev/null +++ b/tests/ref/inline_block_border_intrinsic_size_a.html @@ -0,0 +1,26 @@ + + + + + + + + + + diff --git a/tests/ref/inline_block_border_intrinsic_size_ref.html b/tests/ref/inline_block_border_intrinsic_size_ref.html new file mode 100644 index 00000000000..b11fd4f1b8e --- /dev/null +++ b/tests/ref/inline_block_border_intrinsic_size_ref.html @@ -0,0 +1,25 @@ + + + + + + + + + +