pub fn from_font_context(ctx: &crate::text3::cache::FontContext) -> Result<Self, crate::solver3::LayoutError> {
parsed_fonts: std::sync::Arc<std::sync::Mutex<std::collections::HashMap<rust_fontconfig::FontId, FontRef>>>,
eprintln!("[MEM] warm.inline {:>6} KiB (shaped text in CachedInlineLayout)", tr.warm_inline_layout_bytes / 1024);
eprintln!("[MEM] cache_map {:>7} KiB (Taffy-style 9+1 slots per node)", sc.cache_map_bytes / 1024);
eprintln!("[MEM] logical_items {:>7} KiB ({} entries)", tc.logical_items_bytes / 1024, tc.logical_items_entries);
eprintln!("[MEM] visual_items {:>7} KiB ({} entries)", tc.visual_items_bytes / 1024, tc.visual_items_entries);
eprintln!("[MEM] shaped_items {:>7} KiB ({} entries)", tc.shaped_items_bytes / 1024, tc.shaped_items_entries);
eprintln!("[MEM] per_item_shaped {:>7} KiB ({} entries)", tc.per_item_shaped_bytes / 1024, tc.per_item_shaped_entries);
eprintln!("[MEM] after layout: current rss={:.1} MiB peak rss={:.1} MiB (unreturned={:.1} MiB)",
eprintln!("[MEM] accounted / rss = {:.1}% — the gap is allocator overhead + unreturned transient pages + fonts/images + misc",
let initial_opacity = if info.visibility == azul_css::props::style::scrollbar::ScrollbarVisibilityMode::Always {
let vviews = self.scan_for_virtual_views(&styled_dom, &tree, &self.layout_cache.calculated_positions);
pub fn set_scroll_position(&mut self, dom_id: DomId, node_id: NodeId, scroll: ScrollPosition) {
/// Set selection state for a DOM (no-op: selection_manager removed, multi_cursor handles this)
pub fn create_cursor_blink_timer(&self, _window_state: &FullWindowState) -> crate::timer::Timer {
interval: azul_core::task::OptionDuration::Some(Duration::System(SystemTimeDiff::from_millis(interval_ms))),
if self.text_edit_manager.multi_cursor.as_ref().map(|mc| mc.node_id.dom == pending.dom_id && mc.node_id.node.into_crate_internal() == Some(pending.text_node_id)).unwrap_or(false)
|| self.text_edit_manager.multi_cursor.as_ref().map(|mc| mc.node_id.dom == pending.dom_id && mc.node_id.node.into_crate_internal() == Some(pending.container_node_id)).unwrap_or(false)
let text_layout = self.get_inline_layout_for_node(pending.dom_id, pending.text_node_id).cloned();
let layout_idx = match layout_tree.nodes.iter().position(|node| node.dom_node_id == target_node_id) {
{ let _ = (0xE5_000003u32 | ((self.layout_cache.calculated_positions.len() as u32 & 0xfff) << 8)); }
let search_text = if word_range.start.cluster_id.source_run == word_range.end.cluster_id.source_run {
if let Some(InlineContent::Text(run)) = content.get(word_range.start.cluster_id.source_run as usize) {
azul_core::selection::Selection::Range(r) => Some(r.end.cluster_id.start_byte_in_run as usize),
let cursor_in_viewport = match current_window_state.mouse_state.cursor_position.get_position() {
pub fn set_system_style(&mut self, system_style: std::sync::Arc<azul_css::system::SystemStyle>) {
self.icu_localizer = crate::icu::IcuLocalizerHandle::from_system_language(&system_style.language);
affected_nodes.insert(focused_node, (text_input_event, false)); // false = no re-layout yet
timestamp: azul_core::task::Instant::Tick(azul_core::task::SystemTick { tick_counter: 0 }),
timestamp: azul_core::task::Instant::Tick(azul_core::task::SystemTick { tick_counter: 0 }),
pub fn get_text_before_textinput(&self, dom_id: DomId, node_id: NodeId) -> Vec<InlineContent> {
/// 2. Re-runs the text3 layout pipeline (create_logical_items -> reorder -> shape -> fragment)
/// updates the `inline_layout_result` on layout tree nodes, the `DomLayoutResult.display_list`
perform_fragment_layout(&mut cursor, logical_items, constraints, &mut None, &loaded_fonts).ok()
let layout = self.fragment_layout_from_shaped(&logical_items, &shaped_items, constraints)?;
/// 2. Find the IFC layout via `inline_layout_result` (IFC root) or `ifc_membership` (text node)
/// * `Option<Vec<DomNodeId>>` - Affected nodes that need re-rendering, None if click didn't hit text
let mut found_selection: Option<(DomId, NodeId, SelectionRange, azul_core::geom::LogicalPosition)> = None;
// Try to get hit test from HoverManager first (fast path, uses WebRender's point_relative_to_item)
let (cached_layout, ifc_root_node_id) = if let Some(ref cached) = warm_node.inline_layout_result {
Some(ifc_root_warm) => match (ifc_root_warm.inline_layout_result.as_ref(), tree.get(membership.ifc_root_layout_index).and_then(|n| n.dom_node_id)) {
// The contenteditable attribute is typically on a parent div, not on the IFC root or text node
/// * `start_position` - Initial click position in logical coordinates (unused, anchor is stored)
/// This is NOT reading from the system clipboard - use `clipboard_manager.get_paste_content()`
/// This method handles manual VirtualView re-rendering triggered by `trigger_virtual_view_rerender()`.