Skip to main content

LayoutContext

Struct LayoutContext 

Source
pub struct LayoutContext<'a, T: ParsedFontTrait> {
Show 16 fields pub styled_dom: &'a StyledDom, pub font_manager: &'a FontManager<T>, pub text_selections: &'a BTreeMap<DomId, TextSelection>, pub debug_messages: &'a mut Option<Vec<LayoutDebugMessage>>, pub counters: &'a mut HashMap<(usize, String), i32>, pub viewport_size: LogicalSize, pub fragmentation_context: Option<&'a mut FragmentationContext>, pub cursor_is_visible: bool, pub cursor_locations: Vec<(DomId, NodeId, TextCursor)>, pub preedit_text: Option<String>, pub dirty_text_overrides: BTreeMap<(DomId, NodeId), String>, pub cache_map: LayoutCacheMap, pub image_cache: &'a ImageCache, pub system_style: Option<Arc<SystemStyle>>, pub get_system_time_fn: GetSystemTimeCallback, pub scrollbar_style_cache: RefCell<HashMap<NodeId, ComputedScrollbarStyle>>,
}
Expand description

Central context for a single layout pass.

Fields§

§styled_dom: &'a StyledDom§font_manager: &'a FontManager<T>§text_selections: &'a BTreeMap<DomId, TextSelection>

Text selections for rendering highlights. Populated from MultiCursorState.

§debug_messages: &'a mut Option<Vec<LayoutDebugMessage>>§counters: &'a mut HashMap<(usize, String), i32>§viewport_size: LogicalSize§fragmentation_context: Option<&'a mut FragmentationContext>

Fragmentation context for CSS Paged Media (PDF generation) When Some, layout respects page boundaries and generates one DisplayList per page

§cursor_is_visible: bool

Whether the text cursor should be drawn (managed by CursorManager blink timer) When false, the cursor is in the “off” phase of blinking and should not be rendered. When true (default), the cursor is visible.

§cursor_locations: Vec<(DomId, NodeId, TextCursor)>

All active cursor locations from MultiCursorState / CursorManager. Each entry is (dom_id, node_id, cursor). Multiple entries = multi-cursor mode. Empty = no active cursor. The last entry is the primary cursor.

§preedit_text: Option<String>

IME preedit (composition) text to render inline at the cursor position. When Some, the text should be rendered with an underline decoration.

§dirty_text_overrides: BTreeMap<(DomId, NodeId), String>

Text content overrides from in-progress edits (dirty_text_nodes). When a text node has been edited but not yet committed to the DOM, the layout pipeline should read from here instead of StyledDom. Key: (DomId, NodeId of the text node), Value: the edited text string.

§cache_map: LayoutCacheMap

Per-node multi-slot cache (Taffy-inspired 9+1 architecture). Moved out of LayoutCache via std::mem::take for the duration of layout, then moved back after the layout pass completes.

§image_cache: &'a ImageCache

Image cache for resolving background-image: url(...) references.

§system_style: Option<Arc<SystemStyle>>

System style containing colors, fonts, metrics, and theme information. Used for selection colors, caret styling, and other system-themed elements.

§get_system_time_fn: GetSystemTimeCallback

Callback to get the current system time. Used for profiling inside layout. On WASM targets (where std::time::Instant::now() panics), callers should supply a no-op or platform-specific implementation.

§scrollbar_style_cache: RefCell<HashMap<NodeId, ComputedScrollbarStyle>>

Memoised get_scrollbar_style results, keyed by DOM node id. compute_scrollbar_info_core is called many times per node per layout pass (BFC path + Taffy flex/grid path + display list), and each call previously did 9 cascade walks. Once populated, subsequent callers in the same LayoutContext (a single render) return a clone.

Uses RefCell so shared &self borrows (e.g. in the Taffy bridge’s get_core_container_style) can mutate the cache without lifting the ctx to &mut. Keyed by NodeId so entries span DOMs in iframe-style nested documents if that ever becomes a thing.

Implementations§

Source§

impl<'a, T: ParsedFontTrait> LayoutContext<'a, T>

Source

pub fn has_debug(&self) -> bool

Check if debug messages are enabled (for use with lazy macros)

Source

pub fn debug_log_inner(&mut self, message: String)

Internal method - called by debug_log! macro after checking has_debug()

Source

pub fn debug_info_inner(&mut self, message: String)

Internal method - called by debug_info! macro after checking has_debug()

Source

pub fn debug_warning_inner(&mut self, message: String)

Internal method - called by debug_warning! macro after checking has_debug()

Source

pub fn debug_error_inner(&mut self, message: String)

Internal method - called by debug_error! macro after checking has_debug()

Source

pub fn debug_box_props_inner(&mut self, message: String)

Internal method - called by debug_box_props! macro after checking has_debug()

Source

pub fn debug_css_getter_inner(&mut self, message: String)

Internal method - called by debug_css_getter! macro after checking has_debug()

Source

pub fn debug_bfc_layout_inner(&mut self, message: String)

Internal method - called by debug_bfc_layout! macro after checking has_debug()

Source

pub fn debug_ifc_layout_inner(&mut self, message: String)

Internal method - called by debug_ifc_layout! macro after checking has_debug()

Source

pub fn debug_table_layout_inner(&mut self, message: String)

Internal method - called by debug_table_layout! macro after checking has_debug()

Source

pub fn debug_display_type_inner(&mut self, message: String)

Internal method - called by debug_display_type! macro after checking has_debug()

Source

pub fn debug_info(&mut self, message: impl Into<String>)

Source

pub fn debug_warning(&mut self, message: impl Into<String>)

Source

pub fn debug_error(&mut self, message: impl Into<String>)

Source

pub fn debug_log(&mut self, message: &str)

Source

pub fn debug_box_props(&mut self, message: impl Into<String>)

Source

pub fn debug_css_getter(&mut self, message: impl Into<String>)

Source

pub fn debug_bfc_layout(&mut self, message: impl Into<String>)

Source

pub fn debug_ifc_layout(&mut self, message: impl Into<String>)

Source

pub fn debug_table_layout(&mut self, message: impl Into<String>)

Source

pub fn debug_display_type(&mut self, message: impl Into<String>)

Auto Trait Implementations§

§

impl<'a, T> !Freeze for LayoutContext<'a, T>

§

impl<'a, T> !RefUnwindSafe for LayoutContext<'a, T>

§

impl<'a, T> Send for LayoutContext<'a, T>

§

impl<'a, T> !Sync for LayoutContext<'a, T>

§

impl<'a, T> Unpin for LayoutContext<'a, T>

§

impl<'a, T> UnsafeUnpin for LayoutContext<'a, T>

§

impl<'a, T> !UnwindSafe for LayoutContext<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.