mirror of
https://github.com/servo/servo.git
synced 2025-08-15 10:25:32 +01:00
Do not hoist floated fragments
Instead of hoisting floated fragments to be siblings of the fragment created by their containing block formatting context, keep them in "normal" fragment tree position and adjust their positioning to be relative to the containing block. This means that float fragments follow the existing invariants of the fragment tree and properly handle hit testing, painting order, and relative positioning. The tradeoff here is more complexity tracking the containing block offsets from the block formatting context (including handling collapsed margins), but less complexity dealing with hoisting / shared ownership in addition to the correctness benefits. Some tests are failing now because this change revealed some additional shortcomings with clearing block formatting context content size past the end of their contained floats. This will be fixed in a followup change. Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
cdec48328e
commit
25f6cc04a2
22 changed files with 250 additions and 296 deletions
|
@ -9,7 +9,7 @@ extern crate lazy_static;
|
|||
|
||||
use euclid::num::Zero;
|
||||
use layout::flow::float::{ClearSide, FloatBand, FloatBandNode, FloatBandTree, FloatContext};
|
||||
use layout::flow::float::{FloatSide, InlineWalls, PlacementInfo};
|
||||
use layout::flow::float::{ContainingBlockOffsets, FloatSide, PlacementInfo};
|
||||
use layout::geom::flow_relative::{Rect, Vec2};
|
||||
use quickcheck::{Arbitrary, Gen};
|
||||
use std::f32;
|
||||
|
@ -339,7 +339,7 @@ struct FloatInput {
|
|||
ceiling: u32,
|
||||
/// Distances from the logical left side of the block formatting context to the logical sides
|
||||
/// of the current containing block.
|
||||
walls: InlineWalls,
|
||||
cb_offset: ContainingBlockOffsets,
|
||||
}
|
||||
|
||||
impl Arbitrary for FloatInput {
|
||||
|
@ -366,7 +366,8 @@ impl Arbitrary for FloatInput {
|
|||
clear: new_clear_side(clear),
|
||||
},
|
||||
ceiling,
|
||||
walls: InlineWalls {
|
||||
cb_offset: ContainingBlockOffsets {
|
||||
top: Length::zero(),
|
||||
left: Length::new(left as f32),
|
||||
right: Length::new(right as f32),
|
||||
},
|
||||
|
@ -388,12 +389,12 @@ impl Arbitrary for FloatInput {
|
|||
this.info.clear = new_clear_side(clear_side);
|
||||
shrunk = true;
|
||||
}
|
||||
if let Some(left) = self.walls.left.px().shrink().next() {
|
||||
this.walls.left = Length::new(left);
|
||||
if let Some(left) = self.cb_offset.left.px().shrink().next() {
|
||||
this.cb_offset.left = Length::new(left);
|
||||
shrunk = true;
|
||||
}
|
||||
if let Some(right) = self.walls.right.px().shrink().next() {
|
||||
this.walls.right = Length::new(right);
|
||||
if let Some(right) = self.cb_offset.right.px().shrink().next() {
|
||||
this.cb_offset.right = Length::new(right);
|
||||
shrunk = true;
|
||||
}
|
||||
if let Some(ceiling) = self.ceiling.shrink().next() {
|
||||
|
@ -429,7 +430,7 @@ struct PlacedFloat {
|
|||
origin: Vec2<Length>,
|
||||
info: PlacementInfo,
|
||||
ceiling: Length,
|
||||
walls: InlineWalls,
|
||||
walls: ContainingBlockOffsets,
|
||||
}
|
||||
|
||||
impl Drop for FloatPlacement {
|
||||
|
@ -470,12 +471,12 @@ impl FloatPlacement {
|
|||
for float in floats {
|
||||
let ceiling = Length::new(float.ceiling as f32);
|
||||
float_context.lower_ceiling(ceiling);
|
||||
float_context.walls = float.walls;
|
||||
float_context.cb_bfc_distance = float.cb_offset;
|
||||
placed_floats.push(PlacedFloat {
|
||||
origin: float_context.add_float(&float.info),
|
||||
info: float.info,
|
||||
ceiling,
|
||||
walls: float.walls,
|
||||
walls: float.cb_offset,
|
||||
})
|
||||
}
|
||||
FloatPlacement {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue