From 52a74214da88c735b3e102f4867a25d3d88836e5 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 4 Jan 2023 09:14:58 -0600 Subject: [PATCH 1/4] don't remove realdom nodes when the element id changes --- packages/native-core/src/real_dom.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/native-core/src/real_dom.rs b/packages/native-core/src/real_dom.rs index f51cb9e04..08feb6acb 100644 --- a/packages/native-core/src/real_dom.rs +++ b/packages/native-core/src/real_dom.rs @@ -79,10 +79,6 @@ impl, V: FromAnyValue> RealDom { if self.node_id_mapping.len() <= element_id.0 { self.node_id_mapping.resize(element_id.0 + 1, None); } - if let Some(Some(old_id)) = self.node_id_mapping.get(element_id.0) { - // free the memory associated with the old node - self.tree.remove(*old_id); - } self.node_id_mapping[element_id.0] = Some(node_id); } From 93a95b82a4ef38276ecbe14439a79837414f3724 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 4 Jan 2023 11:18:32 -0600 Subject: [PATCH 2/4] bump lightningcss version --- packages/native-core/Cargo.toml | 2 +- packages/native-core/src/layout_attributes.rs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/native-core/Cargo.toml b/packages/native-core/Cargo.toml index ae0027d1a..592269078 100644 --- a/packages/native-core/Cargo.toml +++ b/packages/native-core/Cargo.toml @@ -25,7 +25,7 @@ crossbeam-deque = "0.8.2" dashmap = "5.4.0" # for parsing attributes -lightningcss = "1.0.0-alpha.38" +lightningcss = "1.0.0-alpha.39" [dev-dependencies] rand = "0.8.5" diff --git a/packages/native-core/src/layout_attributes.rs b/packages/native-core/src/layout_attributes.rs index 7d722d5de..d149a11ac 100644 --- a/packages/native-core/src/layout_attributes.rs +++ b/packages/native-core/src/layout_attributes.rs @@ -160,7 +160,9 @@ pub fn apply_layout_attributes(name: &str, value: &str, style: &mut Style) { align::ContentDistribution::SpaceEvenly => SpaceEvenly, align::ContentDistribution::Stretch => Stretch, }, - align::AlignContent::ContentPosition(_, position) => match position { + align::AlignContent::ContentPosition { + value: position, .. + } => match position { align::ContentPosition::Center => Center, align::ContentPosition::Start | align::ContentPosition::FlexStart => { FlexStart @@ -181,7 +183,9 @@ pub fn apply_layout_attributes(name: &str, value: &str, style: &mut Style) { _ => return, } } - align::JustifyContent::ContentPosition(_, position) => match position { + align::JustifyContent::ContentPosition { + value: position, .. + } => match position { align::ContentPosition::Center => Center, // start ignores -reverse flex-direction but there is no way to specify that in Taffy align::ContentPosition::Start | align::ContentPosition::FlexStart => { @@ -199,7 +203,9 @@ pub fn apply_layout_attributes(name: &str, value: &str, style: &mut Style) { align::AlignSelf::Auto => Auto, align::AlignSelf::Stretch => Stretch, align::AlignSelf::BaselinePosition(_) => Baseline, - align::AlignSelf::SelfPosition(_overflow, position) => match position { + align::AlignSelf::SelfPosition { + value: position, .. + } => match position { align::SelfPosition::Center => Center, align::SelfPosition::Start | align::SelfPosition::SelfStart @@ -216,7 +222,9 @@ pub fn apply_layout_attributes(name: &str, value: &str, style: &mut Style) { style.align_items = match align { align::AlignItems::BaselinePosition(_) => Baseline, align::AlignItems::Stretch => Stretch, - align::AlignItems::SelfPosition(_overflow, position) => match position { + align::AlignItems::SelfPosition { + value: position, .. + } => match position { align::SelfPosition::Center => Center, align::SelfPosition::FlexStart => FlexStart, align::SelfPosition::FlexEnd => FlexEnd, From 5e77b297f2566cb4415fdefcf613799d94f1fadb Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 4 Jan 2023 11:21:29 -0600 Subject: [PATCH 3/4] rename tui examples --- packages/tui/examples/{tui_all_events.rs => all_events.rs} | 0 packages/tui/examples/{tui_border.rs => border.rs} | 0 packages/tui/examples/{tui_buttons.rs => buttons.rs} | 0 packages/tui/examples/{tui_color_test.rs => color_test.rs} | 0 packages/tui/examples/{tui_colorpicker.rs => colorpicker.rs} | 0 packages/tui/examples/{tui_components.rs => components.rs} | 0 packages/tui/examples/{tui_flex.rs => flex.rs} | 0 packages/tui/examples/{tui_hover.rs => hover.rs} | 0 packages/tui/examples/{tui_list.rs => list.rs} | 0 packages/tui/examples/{tui_margin.rs => margin.rs} | 0 packages/tui/examples/{tui_quadrants.rs => quadrants.rs} | 0 packages/tui/examples/{tui_readme.rs => readme.rs} | 0 packages/tui/examples/{tui_task.rs => task.rs} | 0 packages/tui/examples/{tui_text.rs => text.rs} | 0 packages/tui/examples/{tui_widgets.rs => widgets.rs} | 0 15 files changed, 0 insertions(+), 0 deletions(-) rename packages/tui/examples/{tui_all_events.rs => all_events.rs} (100%) rename packages/tui/examples/{tui_border.rs => border.rs} (100%) rename packages/tui/examples/{tui_buttons.rs => buttons.rs} (100%) rename packages/tui/examples/{tui_color_test.rs => color_test.rs} (100%) rename packages/tui/examples/{tui_colorpicker.rs => colorpicker.rs} (100%) rename packages/tui/examples/{tui_components.rs => components.rs} (100%) rename packages/tui/examples/{tui_flex.rs => flex.rs} (100%) rename packages/tui/examples/{tui_hover.rs => hover.rs} (100%) rename packages/tui/examples/{tui_list.rs => list.rs} (100%) rename packages/tui/examples/{tui_margin.rs => margin.rs} (100%) rename packages/tui/examples/{tui_quadrants.rs => quadrants.rs} (100%) rename packages/tui/examples/{tui_readme.rs => readme.rs} (100%) rename packages/tui/examples/{tui_task.rs => task.rs} (100%) rename packages/tui/examples/{tui_text.rs => text.rs} (100%) rename packages/tui/examples/{tui_widgets.rs => widgets.rs} (100%) diff --git a/packages/tui/examples/tui_all_events.rs b/packages/tui/examples/all_events.rs similarity index 100% rename from packages/tui/examples/tui_all_events.rs rename to packages/tui/examples/all_events.rs diff --git a/packages/tui/examples/tui_border.rs b/packages/tui/examples/border.rs similarity index 100% rename from packages/tui/examples/tui_border.rs rename to packages/tui/examples/border.rs diff --git a/packages/tui/examples/tui_buttons.rs b/packages/tui/examples/buttons.rs similarity index 100% rename from packages/tui/examples/tui_buttons.rs rename to packages/tui/examples/buttons.rs diff --git a/packages/tui/examples/tui_color_test.rs b/packages/tui/examples/color_test.rs similarity index 100% rename from packages/tui/examples/tui_color_test.rs rename to packages/tui/examples/color_test.rs diff --git a/packages/tui/examples/tui_colorpicker.rs b/packages/tui/examples/colorpicker.rs similarity index 100% rename from packages/tui/examples/tui_colorpicker.rs rename to packages/tui/examples/colorpicker.rs diff --git a/packages/tui/examples/tui_components.rs b/packages/tui/examples/components.rs similarity index 100% rename from packages/tui/examples/tui_components.rs rename to packages/tui/examples/components.rs diff --git a/packages/tui/examples/tui_flex.rs b/packages/tui/examples/flex.rs similarity index 100% rename from packages/tui/examples/tui_flex.rs rename to packages/tui/examples/flex.rs diff --git a/packages/tui/examples/tui_hover.rs b/packages/tui/examples/hover.rs similarity index 100% rename from packages/tui/examples/tui_hover.rs rename to packages/tui/examples/hover.rs diff --git a/packages/tui/examples/tui_list.rs b/packages/tui/examples/list.rs similarity index 100% rename from packages/tui/examples/tui_list.rs rename to packages/tui/examples/list.rs diff --git a/packages/tui/examples/tui_margin.rs b/packages/tui/examples/margin.rs similarity index 100% rename from packages/tui/examples/tui_margin.rs rename to packages/tui/examples/margin.rs diff --git a/packages/tui/examples/tui_quadrants.rs b/packages/tui/examples/quadrants.rs similarity index 100% rename from packages/tui/examples/tui_quadrants.rs rename to packages/tui/examples/quadrants.rs diff --git a/packages/tui/examples/tui_readme.rs b/packages/tui/examples/readme.rs similarity index 100% rename from packages/tui/examples/tui_readme.rs rename to packages/tui/examples/readme.rs diff --git a/packages/tui/examples/tui_task.rs b/packages/tui/examples/task.rs similarity index 100% rename from packages/tui/examples/tui_task.rs rename to packages/tui/examples/task.rs diff --git a/packages/tui/examples/tui_text.rs b/packages/tui/examples/text.rs similarity index 100% rename from packages/tui/examples/tui_text.rs rename to packages/tui/examples/text.rs diff --git a/packages/tui/examples/tui_widgets.rs b/packages/tui/examples/widgets.rs similarity index 100% rename from packages/tui/examples/tui_widgets.rs rename to packages/tui/examples/widgets.rs From e3dd55533fd5223ca48f10175e7f72f8e9247aea Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 4 Jan 2023 11:38:34 -0600 Subject: [PATCH 4/4] handle removing a future that does not exist --- packages/core/src/scheduler/task.rs | 4 ++-- packages/core/src/scheduler/wait.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/scheduler/task.rs b/packages/core/src/scheduler/task.rs index 39c770a06..997953f8e 100644 --- a/packages/core/src/scheduler/task.rs +++ b/packages/core/src/scheduler/task.rs @@ -59,9 +59,9 @@ impl Scheduler { /// Drop the future with the given TaskId /// - /// This does nto abort the task, so you'll want to wrap it in an aborthandle if that's important to you + /// This does not abort the task, so you'll want to wrap it in an aborthandle if that's important to you pub fn remove(&self, id: TaskId) { - self.tasks.borrow_mut().remove(id.0); + self.tasks.borrow_mut().try_remove(id.0); } } diff --git a/packages/core/src/scheduler/wait.rs b/packages/core/src/scheduler/wait.rs index 9268cfeb0..8ec1776c2 100644 --- a/packages/core/src/scheduler/wait.rs +++ b/packages/core/src/scheduler/wait.rs @@ -34,7 +34,7 @@ impl VirtualDom { self.scopes[task.scope.0].spawned_tasks.remove(&id); // Remove it from the scheduler - tasks.remove(id.0); + tasks.try_remove(id.0); } }