From d4c2edc72fd225017911de9d76839de428b6a5eb Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 2 Jul 2023 16:31:43 +0200 Subject: [PATCH 01/21] feat: Proper event bubbling --- core/src/events.rs | 51 ++++----------------------------------------- examples/aaa.rs | 39 ++++++++++++++++++++++++++++++++++ renderer/src/app.rs | 2 +- 3 files changed, 44 insertions(+), 48 deletions(-) create mode 100644 examples/aaa.rs diff --git a/core/src/events.rs b/core/src/events.rs index 972d111da..0eb76b281 100644 --- a/core/src/events.rs +++ b/core/src/events.rs @@ -4,9 +4,7 @@ use dioxus_native_core::NodeId; use freya_dom::prelude::FreyaDOM; use freya_layout::Layers; -use freya_node_state::{Fill, Style}; use rustc_hash::FxHashMap; -use skia_safe::Color; pub use crate::dom_events::DomEvent; pub use crate::events_processor::EventsProcessor; @@ -123,26 +121,6 @@ fn get_derivated_events(event_name: &str) -> Vec<&str> { } } -const STACKED_EVENTS: [&str; 13] = [ - "mouseover", - "mouseenter", - "mouseleave", - "click", - "keydown", - "keyup", - "touchcancel", - "touchend", - "touchmove", - "touchstart", - "pointerover", - "pointerenter", - "pointerleave", -]; - -const FIRST_CAPTURED_EVENTS: [&str; 1] = ["wheel"]; - -const LAST_CAPTURED_EVENTS: [&str; 3] = ["click", "touchstart", "touchend"]; - /// Measure what DOM events could be emited fn measure_dom_events( potential_events: &mut NodesEvents, @@ -155,43 +133,22 @@ fn measure_dom_events( for (event_name, event_nodes) in potential_events.iter_mut() { let derivated_events = get_derivated_events(event_name.as_str()); - let mut found_nodes: Vec<(&NodeId, FreyaEvent)> = Vec::new(); + let mut found_node: Option<(&NodeId, FreyaEvent)> = None; for derivated_event_name in derivated_events { let listeners = rdom.get_listening_sorted(derivated_event_name); - 'event_nodes: for (node_id, request) in event_nodes.iter() { + for (node_id, request) in event_nodes.iter() { for listener in &listeners { if listener.id() == *node_id { - let Style { background, .. } = &*listener.get::