Reduce render allocations and redundant work in core components

This commit is contained in:
2026-11-09 14:35:15 +07:00
parent 73f7dc31d4
commit 122f9b12ae
19 changed files with 174 additions and 139 deletions
+9 -7
View File
@@ -34,8 +34,8 @@ impl Tooltip {
{
let text = text.into();
let anchor_id = anchor_id.into();
move |_window, cx| {
let anchor = anchor_bounds(&anchor_id, cx);
move |window, cx| {
let anchor = anchor_bounds(window.window_handle().window_id(), &anchor_id, cx);
cx.new(|_| Self {
text: text.clone(),
anchor,
@@ -92,11 +92,13 @@ impl Render for Tooltip {
let origin = window.mouse_position() + point(px(1.), px(1.));
let viewport_height = window.viewport_size().height;
let height = anchor_bounds(&ElementId::from(PANEL_BOUNDS_ID), cx)
.map(|bounds| bounds.size.height)
.unwrap_or_else(|| {
text_size * 1.5 + window.rem_size() * 0.5 + BORDER_WIDTH * 2.0
});
let height = anchor_bounds(
window.window_handle().window_id(),
&ElementId::from(PANEL_BOUNDS_ID),
cx,
)
.map(|bounds| bounds.size.height)
.unwrap_or_else(|| text_size * 1.5 + window.rem_size() * 0.5 + BORDER_WIDTH * 2.0);
let below = viewport_height - spacing_unit - parent.bottom();
let above = parent.top() - spacing_unit;