layout: Add a InlineFormattingContextBuilder (#32415)

The main change here is that collapsed and `text-transform`'d text is
computed as it's processed by DOM traversal. This single transformed
text is stored in the root of the `InlineFormattingContext`.

This will eventually allow performing linebreaking and shaping of the
entire inline formatting context at once. Allowing for intelligent
processing of linebreaking and also shaping across elements. This
matches more closely what LayoutNG does.

This shouldn't have any (or negligable) behavioral changes, but will
allow us to prevent linebreaking inside of clusters in a followup
change.

Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
This commit is contained in:
Martin Robinson 2024-06-03 16:46:53 +02:00 committed by GitHub
parent 00b77ce73c
commit 48ab8d8847
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 964 additions and 805 deletions

View file

@ -6,6 +6,7 @@
//! Flow layout, also known as block-and-inline layout.
use app_units::Au;
use inline::InlineFormattingContext;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use serde::Serialize;
use servo_arc::Arc;
@ -22,7 +23,6 @@ use crate::context::LayoutContext;
use crate::flow::float::{
ContainingBlockPositionInfo, FloatBox, PlacementAmongFloats, SequentialLayoutState,
};
use crate::flow::inline::InlineFormattingContext;
use crate::formatting_contexts::{
Baselines, IndependentFormattingContext, IndependentLayout, NonReplacedFormattingContext,
};
@ -39,9 +39,7 @@ use crate::ContainingBlock;
mod construct;
pub mod float;
pub mod inline;
mod line;
mod root;
pub mod text_run;
pub(crate) use construct::BlockContainerBuilder;
pub use root::{BoxTree, CanvasBackground};
@ -194,7 +192,7 @@ impl BlockLevelBox {
}
}
struct FlowLayout {
pub(crate) struct FlowLayout {
pub fragments: Vec<Fragment>,
pub content_block_size: Length,
pub collapsible_margins_in_children: CollapsedBlockMargins,
@ -205,7 +203,7 @@ struct FlowLayout {
}
#[derive(Clone, Copy)]
struct CollapsibleWithParentStartMargin(bool);
pub(crate) struct CollapsibleWithParentStartMargin(bool);
/// The contentes of a BlockContainer created to render a list marker
/// for a list that has `list-style-position: outside`.