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: boolWhether 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: LayoutCacheMapPer-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 ImageCacheImage 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: GetSystemTimeCallbackCallback 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>
impl<'a, T: ParsedFontTrait> LayoutContext<'a, T>
Sourcepub fn debug_log_inner(&mut self, message: String)
pub fn debug_log_inner(&mut self, message: String)
Internal method - called by debug_log! macro after checking has_debug()
Sourcepub fn debug_info_inner(&mut self, message: String)
pub fn debug_info_inner(&mut self, message: String)
Internal method - called by debug_info! macro after checking has_debug()
Sourcepub fn debug_warning_inner(&mut self, message: String)
pub fn debug_warning_inner(&mut self, message: String)
Internal method - called by debug_warning! macro after checking has_debug()
Sourcepub fn debug_error_inner(&mut self, message: String)
pub fn debug_error_inner(&mut self, message: String)
Internal method - called by debug_error! macro after checking has_debug()
Sourcepub fn debug_box_props_inner(&mut self, message: String)
pub fn debug_box_props_inner(&mut self, message: String)
Internal method - called by debug_box_props! macro after checking has_debug()
Sourcepub fn debug_css_getter_inner(&mut self, message: String)
pub fn debug_css_getter_inner(&mut self, message: String)
Internal method - called by debug_css_getter! macro after checking has_debug()
Sourcepub fn debug_bfc_layout_inner(&mut self, message: String)
pub fn debug_bfc_layout_inner(&mut self, message: String)
Internal method - called by debug_bfc_layout! macro after checking has_debug()
Sourcepub fn debug_ifc_layout_inner(&mut self, message: String)
pub fn debug_ifc_layout_inner(&mut self, message: String)
Internal method - called by debug_ifc_layout! macro after checking has_debug()
Sourcepub fn debug_table_layout_inner(&mut self, message: String)
pub fn debug_table_layout_inner(&mut self, message: String)
Internal method - called by debug_table_layout! macro after checking has_debug()
Sourcepub fn debug_display_type_inner(&mut self, message: String)
pub fn debug_display_type_inner(&mut self, message: String)
Internal method - called by debug_display_type! macro after checking has_debug()
pub fn debug_info(&mut self, message: impl Into<String>)
pub fn debug_warning(&mut self, message: impl Into<String>)
pub fn debug_error(&mut self, message: impl Into<String>)
pub fn debug_log(&mut self, message: &str)
pub fn debug_box_props(&mut self, message: impl Into<String>)
pub fn debug_css_getter(&mut self, message: impl Into<String>)
pub fn debug_bfc_layout(&mut self, message: impl Into<String>)
pub fn debug_ifc_layout(&mut self, message: impl Into<String>)
pub fn debug_table_layout(&mut self, message: impl Into<String>)
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> 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