Phase 9: Keyed widgets (9.1 + 9.2)

9.1: Add content_hash field to Element, computed during VDOM evaluation
  from type_name + properties + children content_hashes via DefaultHasher.

9.2: Assign stable iced::widget::Id to text_input and scrollable widgets
  so Iced preserves widget state (cursor position, scroll offset) across
  frames. Ids are cached in a thread_local HashMap to avoid leaks.

9.3 skipped: iced::Element is not Clone and contains Box<dyn Widget>,
  making element-level caching impractical without unsafe lifetime hacks.
This commit is contained in:
Glint Dev
2026-07-24 19:53:02 +03:00
parent 28bd450787
commit b6fa841d11
3 changed files with 40 additions and 1 deletions

View File

@@ -167,6 +167,7 @@ pub struct Element<'a> {
pub children: Vec<Element<'a>>,
pub computed_style: ComputedStyle,
pub element_id: ElementId,
pub content_hash: u64,
}
impl<'a> Element<'a> {
@@ -183,6 +184,7 @@ impl<'a> Element<'a> {
children: Vec::with_capacity(4),
computed_style: ComputedStyle::default(),
element_id: ElementId(u32::MAX),
content_hash: 0,
}
}
@@ -193,6 +195,7 @@ impl<'a> Element<'a> {
children: Vec::with_capacity(4),
computed_style: ComputedStyle::default(),
element_id: id,
content_hash: 0,
}
}
}