mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Include leading margin in inline block size
According to the documentation for Fragment::position, the inline axis should include margin size, so we include it for blocks. Also fix place_float which assumed that it was not included and assign_inline_sizes which overrode the size set in set_inline_size_constraint_solutions. Typically this issue was hidden by large tile sizes, but fitted tiles makes it more common.
This commit is contained in:
parent
c87f34f877
commit
4c453ac519
3 changed files with 22 additions and 9 deletions
|
@ -1041,8 +1041,7 @@ impl BlockFlow {
|
|||
let info = PlacementInfo {
|
||||
size: LogicalSize::new(
|
||||
self.fragment.style.writing_mode,
|
||||
self.base.position.size.inline + self.fragment.margin.inline_start_end() +
|
||||
self.fragment.border_padding.inline_start_end(),
|
||||
self.base.position.size.inline,
|
||||
block_size + self.fragment.margin.block_start_end()),
|
||||
ceiling: clearance + float_info.float_ceiling,
|
||||
max_inline_size: float_info.containing_inline_size,
|
||||
|
@ -1619,10 +1618,6 @@ impl Flow for BlockFlow {
|
|||
let padding_and_borders = self.fragment.border_padding.inline_start_end();
|
||||
let content_inline_size = self.fragment.border_box.size.inline - padding_and_borders;
|
||||
|
||||
if self.is_float() {
|
||||
self.base.position.size.inline = content_inline_size;
|
||||
}
|
||||
|
||||
self.propagate_assigned_inline_size_to_children(inline_start_content_edge, content_inline_size, None);
|
||||
}
|
||||
|
||||
|
@ -1955,6 +1950,7 @@ pub trait ISizeAndMarginsComputer {
|
|||
block: &mut BlockFlow,
|
||||
solution: ISizeConstraintSolution) {
|
||||
let inline_size;
|
||||
let extra_inline_size_from_margin;
|
||||
{
|
||||
let fragment = block.fragment();
|
||||
fragment.margin.inline_start = solution.margin_inline_start;
|
||||
|
@ -1965,14 +1961,19 @@ pub trait ISizeAndMarginsComputer {
|
|||
|
||||
// The associated fragment has the border box of this flow.
|
||||
inline_size = solution.inline_size + fragment.border_padding.inline_start_end();
|
||||
fragment.border_box.size.inline = inline_size
|
||||
fragment.border_box.size.inline = inline_size;
|
||||
|
||||
// To calculate the total size of this block, we also need to account for any additional
|
||||
// size contribution from positive margins. Negative margins means the block isn't made
|
||||
// larger at all by the margin.
|
||||
extra_inline_size_from_margin = max(Au(0), fragment.margin.inline_start) +
|
||||
max(Au(0), fragment.margin.inline_end);
|
||||
}
|
||||
|
||||
// We also resize the block itself, to ensure that overflow is not calculated
|
||||
// as the inline-size of our parent. We might be smaller and we might be larger if we
|
||||
// overflow.
|
||||
let flow = flow::mut_base(block);
|
||||
flow.position.size.inline = inline_size;
|
||||
flow::mut_base(block).position.size.inline = inline_size + extra_inline_size_from_margin;
|
||||
}
|
||||
|
||||
/// Set the x coordinate of the given flow if it is absolutely positioned.
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
== position_fixed_overflow_a.html position_fixed_overflow_b.html
|
||||
== position_fixed_tile_edge.html position_fixed_tile_edge_ref.html
|
||||
== position_fixed_tile_edge_2.html position_fixed_tile_edge_ref.html
|
||||
== position_fixed_tile_edge_3.html position_fixed_tile_edge_ref.html
|
||||
== position_relative_a.html position_relative_b.html
|
||||
== position_relative_top_percentage_a.html position_relative_top_percentage_b.html
|
||||
== background_none_a.html background_none_b.html
|
||||
|
|
11
tests/ref/position_fixed_tile_edge_3.html
Normal file
11
tests/ref/position_fixed_tile_edge_3.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<html>
|
||||
<body>
|
||||
<div style="position: absolute; top: 0px; left: 0px;">
|
||||
<div style="position: absolute; background: green; margin-left: 512px; width: 20px; height: 20px;"></div>
|
||||
|
||||
<!-- This position:fixed sibling should force its sibling to be layerized. -->
|
||||
<div style="position: fixed;"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue