Detailed changes
@@ -778,28 +778,28 @@ impl Interactivity {
});
}
- for listener in self.mouse_down_listeners.drain(..) {
+ for listener in self.mouse_down_listeners {
let interactive_bounds = interactive_bounds.clone();
cx.on_mouse_event(move |event: &MouseDownEvent, phase, cx| {
listener(event, &*interactive_bounds, phase, cx);
})
}
- for listener in self.mouse_up_listeners.drain(..) {
+ for listener in self.mouse_up_listeners {
let interactive_bounds = interactive_bounds.clone();
cx.on_mouse_event(move |event: &MouseUpEvent, phase, cx| {
listener(event, &*interactive_bounds, phase, cx);
})
}
- for listener in self.mouse_move_listeners.drain(..) {
+ for listener in self.mouse_move_listeners {
let interactive_bounds = interactive_bounds.clone();
cx.on_mouse_event(move |event: &MouseMoveEvent, phase, cx| {
listener(event, &*interactive_bounds, phase, cx);
})
}
- for listener in self.scroll_wheel_listeners.drain(..) {
+ for listener in self.scroll_wheel_listeners {
let interactive_bounds = interactive_bounds.clone();
cx.on_mouse_event(move |event: &ScrollWheelEvent, phase, cx| {
listener(event, &*interactive_bounds, phase, cx);
@@ -868,8 +868,8 @@ impl Interactivity {
}
}
- let click_listeners = mem::take(&mut self.click_listeners);
- let drag_listener = mem::take(&mut self.drag_listener);
+ let click_listeners = self.click_listeners;
+ let drag_listener = self.drag_listener;
if !click_listeners.is_empty() || drag_listener.is_some() {
let pending_mouse_down = element_state.pending_mouse_down.clone();
@@ -1086,13 +1086,13 @@ impl Interactivity {
self.key_context.clone(),
element_state.focus_handle.clone(),
|_, cx| {
- for listener in self.key_down_listeners.drain(..) {
+ for listener in self.key_down_listeners {
cx.on_key_event(move |event: &KeyDownEvent, phase, cx| {
listener(event, phase, cx);
})
}
- for listener in self.key_up_listeners.drain(..) {
+ for listener in self.key_up_listeners {
cx.on_key_event(move |event: &KeyUpEvent, phase, cx| {
listener(event, phase, cx);
})
@@ -208,11 +208,16 @@ impl AnyView {
cx: &mut WindowContext,
) {
cx.with_absolute_element_offset(origin, |cx| {
+ let start_time = std::time::Instant::now();
let (layout_id, rendered_element) = (self.layout)(self, cx);
+ let duration = start_time.elapsed();
+ println!("request layout: {:?}", duration);
+
let start_time = std::time::Instant::now();
cx.compute_layout(layout_id, available_space);
let duration = start_time.elapsed();
println!("compute layout: {:?}", duration);
+
let start_time = std::time::Instant::now();
(self.paint)(self, rendered_element, cx);
let duration = start_time.elapsed();
@@ -42,8 +42,26 @@ const ACTIVE_DRAG_Z_INDEX: u32 = 1;
/// A global stacking order, which is created by stacking successive z-index values.
/// Each z-index will always be interpreted in the context of its parent z-index.
-#[derive(Deref, DerefMut, Ord, PartialOrd, Eq, PartialEq, Clone, Default, Debug)]
-pub struct StackingOrder(pub(crate) SmallVec<[u32; 16]>);
+#[derive(Deref, DerefMut, Ord, PartialOrd, Eq, PartialEq, Clone, Debug)]
+pub struct StackingOrder(pub(crate) Arc<Vec<u32>>);
+
+impl Default for StackingOrder {
+ fn default() -> Self {
+ StackingOrder(Arc::new(Vec::new()))
+ }
+}
+
+impl StackingOrder {
+ /// Pushes a new z-index onto the stacking order.
+ pub fn push(&mut self, z_index: u32) {
+ Arc::make_mut(&mut self.0).push(z_index);
+ }
+
+ /// Pops the last z-index off the stacking order.
+ pub fn pop(&mut self) {
+ Arc::make_mut(&mut self.0).pop();
+ }
+}
/// Represents the two different phases when dispatching events.
#[derive(Default, Copy, Clone, Debug, Eq, PartialEq)]
@@ -2892,12 +2910,12 @@ impl AnyWindowHandle {
}
}
-#[cfg(any(test, feature = "test-support"))]
-impl From<SmallVec<[u32; 16]>> for StackingOrder {
- fn from(small_vec: SmallVec<[u32; 16]>) -> Self {
- StackingOrder(small_vec)
- }
-}
+// #[cfg(any(test, feature = "test-support"))]
+// impl From<SmallVec<[u32; 16]>> for StackingOrder {
+// fn from(small_vec: SmallVec<[u32; 16]>) -> Self {
+// StackingOrder(small_vec)
+// }
+// }
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum ElementId {
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>com.apple.security.get-task-allow</key>
+ <true/>
+ </dict>
+</plist>