mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
layout: Fix a couple of issues relating to intrinsic widths of inline
blocks. * Stop double-counting border and padding for inline-block fragments. (Test case: `inline_block_border_intrinsic_size_a.html`.) * Take clearance into account when determining intrinsic widths of blocks containing floats. Improves the Amazon headers.
This commit is contained in:
parent
a346f95e68
commit
33087497ac
8 changed files with 118 additions and 8 deletions
|
@ -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);
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
25
tests/ref/float_clearance_intrinsic_width_a.html
Normal file
25
tests/ref/float_clearance_intrinsic_width_a.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
#nav-your-account {
|
||||
background: lightblue;
|
||||
display: inline-block;
|
||||
}
|
||||
.nav-button-title {
|
||||
float: left;
|
||||
clear: both;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a id="nav-your-account">
|
||||
<div class="nav-button-title">Hello.</div>
|
||||
<div class="nav-button-title">Account</div>
|
||||
<div class="nav-button-title">Account</div>
|
||||
<div class="nav-button-title">Account</div>
|
||||
<div class="nav-button-title">Account</div>
|
||||
<div class="nav-button-title">Account</div>
|
||||
</a>
|
||||
</body>
|
||||
</html>
|
21
tests/ref/float_clearance_intrinsic_width_ref.html
Normal file
21
tests/ref/float_clearance_intrinsic_width_ref.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
#nav-your-account {
|
||||
background: lightblue;
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a id="nav-your-account">
|
||||
<div class="nav-button-title">Hello.</div>
|
||||
<div class="nav-button-title">Account</div>
|
||||
<div class="nav-button-title">Account</div>
|
||||
<div class="nav-button-title">Account</div>
|
||||
<div class="nav-button-title">Account</div>
|
||||
<div class="nav-button-title">Account</div>
|
||||
</a>
|
||||
</body>
|
||||
</html>
|
26
tests/ref/inline_block_border_intrinsic_size_a.html
Normal file
26
tests/ref/inline_block_border_intrinsic_size_a.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
}
|
||||
.nav-button-outer {
|
||||
background: red;
|
||||
display: inline-block;
|
||||
}
|
||||
.nav-down-arrow {
|
||||
display: inline-block;
|
||||
border-style: solid;
|
||||
border-color: black;
|
||||
border-width: 10px 200px 0 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a class="nav-button-outer"><span class="nav-down-arrow"></span></a>
|
||||
</body>
|
||||
</html>
|
25
tests/ref/inline_block_border_intrinsic_size_ref.html
Normal file
25
tests/ref/inline_block_border_intrinsic_size_ref.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
}
|
||||
.nav-button-outer {
|
||||
display: inline-block;
|
||||
}
|
||||
.nav-down-arrow {
|
||||
display: inline-block;
|
||||
border-style: solid;
|
||||
border-color: black;
|
||||
border-width: 10px 200px 0 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a class="nav-button-outer"><span class="nav-down-arrow"></span></a>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue