Add an implementation of the core float and clear placement logic in layout

2020, not yet wired to the rest of layout.

This commit implements an object that handles the 10 rules in CSS 2.1:

https://www.w3.org/TR/CSS2/visuren.html#float-position

The implementation strategy is that of a persistent balanced binary search tree
of float bands. Binary search trees are commonly used for implementing float
positioning; e.g. by WebKit.  Persistence enables each object that interacts
with floats to efficiently contain a snapshot of the float list at the time
that object was laid out. That way, incremental layout can invalidate and start
reflow at any point in a containing block.

This commit features extensive use of
[QuickCheck](https://github.com/BurntSushi/quickcheck) to ensure that the rules
of the CSS specification are followed.

Because this is not yet connected to layout, floats will not actually be laid
out in Web pages yet.

Note that unit tests as set up in Servo currently require types that they
access to be public. Therefore, some internal layout 2020 types that were
previously private have been made public. This is somewhat unfortunate.

Part of #25167.
This commit is contained in:
Patrick Walton 2020-07-06 18:44:59 -07:00
parent 48bf169101
commit 5b36d211b4
10 changed files with 1354 additions and 20 deletions

View file

@ -16,10 +16,10 @@ pub mod display_list;
mod dom_traversal;
pub mod element_data;
mod flexbox;
mod flow;
pub mod flow;
mod formatting_contexts;
mod fragments;
mod geom;
pub mod geom;
#[macro_use]
pub mod layout_debug;
mod opaque_node;
@ -37,7 +37,7 @@ use crate::geom::flow_relative::Vec2;
use style::properties::ComputedValues;
use style::values::computed::{Length, LengthOrAuto};
struct ContainingBlock<'a> {
pub struct ContainingBlock<'a> {
inline_size: Length,
block_size: LengthOrAuto,
style: &'a ComputedValues,