mirror of
https://github.com/servo/servo.git
synced 2025-06-15 03:44:30 +00:00
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.
59 lines
1.3 KiB
Rust
59 lines
1.3 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
#![deny(unsafe_code)]
|
|
|
|
#[macro_use]
|
|
extern crate log;
|
|
#[macro_use]
|
|
extern crate serde;
|
|
|
|
mod cell;
|
|
pub mod context;
|
|
pub mod data;
|
|
pub mod display_list;
|
|
mod dom_traversal;
|
|
pub mod element_data;
|
|
mod flexbox;
|
|
pub mod flow;
|
|
mod formatting_contexts;
|
|
mod fragments;
|
|
pub mod geom;
|
|
#[macro_use]
|
|
pub mod layout_debug;
|
|
mod opaque_node;
|
|
mod positioned;
|
|
pub mod query;
|
|
mod replaced;
|
|
mod sizing;
|
|
mod style_ext;
|
|
pub mod traversal;
|
|
pub mod wrapper;
|
|
|
|
pub use flow::{BoxTree, FragmentTree};
|
|
|
|
use crate::geom::flow_relative::Vec2;
|
|
use style::properties::ComputedValues;
|
|
use style::values::computed::{Length, LengthOrAuto};
|
|
|
|
pub struct ContainingBlock<'a> {
|
|
inline_size: Length,
|
|
block_size: LengthOrAuto,
|
|
style: &'a ComputedValues,
|
|
}
|
|
|
|
struct DefiniteContainingBlock<'a> {
|
|
size: Vec2<Length>,
|
|
style: &'a ComputedValues,
|
|
}
|
|
|
|
impl<'a> From<&'_ DefiniteContainingBlock<'a>> for ContainingBlock<'a> {
|
|
fn from(definite: &DefiniteContainingBlock<'a>) -> Self {
|
|
ContainingBlock {
|
|
inline_size: definite.size.inline,
|
|
block_size: LengthOrAuto::LengthPercentage(definite.size.block),
|
|
style: definite.style,
|
|
}
|
|
}
|
|
}
|