Reduce render allocations and redundant work in core components
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user