pub struct LayoutCache { /* private fields */ }Implementations§
Source§impl LayoutCache
impl LayoutCache
pub fn new() -> Self
Sourcepub fn get_layout(&self, cache_id: &CacheId) -> Option<&Arc<UnifiedLayout>>
pub fn get_layout(&self, cache_id: &CacheId) -> Option<&Arc<UnifiedLayout>>
Get a layout from the cache by its ID
Sourcepub fn get_all_layout_ids(&self) -> Vec<CacheId> ⓘ
pub fn get_all_layout_ids(&self) -> Vec<CacheId> ⓘ
Get all layout cache IDs (for iteration/debugging)
Sourcepub fn use_old_layout(
old_constraints: &UnifiedConstraints,
new_constraints: &UnifiedConstraints,
old_content: &[InlineContent],
new_content: &[InlineContent],
) -> bool
pub fn use_old_layout( old_constraints: &UnifiedConstraints, new_constraints: &UnifiedConstraints, old_content: &[InlineContent], new_content: &[InlineContent], ) -> bool
Check if we can reuse an old layout based on layout-affecting parameters.
This function compares only the parameters that affect glyph positions, not rendering-only parameters like color or text-decoration.
§Parameters
old_constraints: The constraints used for the cached layoutnew_constraints: The constraints for the new layout requestold_content: The content used for the cached layoutnew_content: The new content to layout
§Returns
trueif the old layout can be reused (only rendering changed)falseif a new layout is needed (layout-affecting params changed)
Source§impl LayoutCache
impl LayoutCache
Sourcepub fn layout_flow<T: ParsedFontTrait>(
&mut self,
content: &[InlineContent],
style_overrides: &[StyleOverride],
flow_chain: &[LayoutFragment],
font_chain_cache: &HashMap<FontChainKey, FontFallbackChain>,
fc_cache: &FcFontCache,
loaded_fonts: &LoadedFonts<T>,
debug_messages: &mut Option<Vec<LayoutDebugMessage>>,
) -> Result<FlowLayout, LayoutError>
pub fn layout_flow<T: ParsedFontTrait>( &mut self, content: &[InlineContent], style_overrides: &[StyleOverride], flow_chain: &[LayoutFragment], font_chain_cache: &HashMap<FontChainKey, FontFallbackChain>, fc_cache: &FcFontCache, loaded_fonts: &LoadedFonts<T>, debug_messages: &mut Option<Vec<LayoutDebugMessage>>, ) -> Result<FlowLayout, LayoutError>
New top-level entry point for flowing layout across multiple regions.
This function orchestrates the entire layout pipeline, but instead of fitting
content into a single set of constraints, it flows the content through an
ordered sequence of LayoutFragments.
§CSS Inline Layout Module Level 3: Pipeline Implementation
This implements the inline formatting context with 5 stages:
§Stage 1: Logical Analysis (InlineContent -> LogicalItem)
\u2705 IMPLEMENTED: Parses raw content into logical units
- Handles text runs, inline-blocks, replaced elements
- Applies style overrides at character level
- Implements \u00a7 2.2: Content size contribution calculation
§Stage 2: BiDi Reordering (LogicalItem -> VisualItem)
\u2705 IMPLEMENTED: Uses CSS ‘direction’ property per CSS Writing Modes
- Reorders items for right-to-left text (Arabic, Hebrew)
- Respects containing block direction (not auto-detection)
- Conforms to Unicode BiDi Algorithm (UAX #9)
§Stage 3: Shaping (VisualItem -> ShapedItem)
\u2705 IMPLEMENTED: Converts text to glyphs
- Uses HarfBuzz for OpenType shaping
- Handles ligatures, kerning, contextual forms
- Caches shaped results for performance
§Stage 4: Text Orientation Transformations
\u26a0\ufe0f PARTIAL: Applies text-orientation for vertical text
- Uses constraints from first fragment only
- \u274c TODO: Should re-orient if fragments have different writing modes
§Stage 5: Flow Loop (ShapedItem -> PositionedItem)
\u2705 IMPLEMENTED: Breaks lines and positions content
- Calls perform_fragment_layout for each fragment
- Uses BreakCursor to flow content across fragments
- Implements \u00a7 5: Line breaking and hyphenation
§Missing Features from CSS Inline-3:
- \u00a7 3.3: initial-letter (drop caps)
- \u00a7 4: vertical-align (only baseline supported)
- \u00a7 6: text-box-trim (leading trim)
- \u00a7 7: inline-sizing (aspect-ratio for inline-blocks)
§Arguments
content- The rawInlineContentto be laid out.style_overrides- Character-level style changes.flow_chain- An ordered slice ofLayoutFragmentdefining the regions (e.g., columns, pages) that the content should flow through.font_chain_cache- Pre-resolved font chains (from FontManager.font_chain_cache)fc_cache- The fontconfig cache for font lookupsloaded_fonts- Pre-loaded fonts, keyed by FontId
§Returns
A FlowLayout struct containing the positioned items for each fragment that
was filled, and any content that did not fit in the final fragment.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LayoutCache
impl RefUnwindSafe for LayoutCache
impl Send for LayoutCache
impl Sync for LayoutCache
impl Unpin for LayoutCache
impl UnwindSafe for LayoutCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more