feat: support desktop more completely

This commit is contained in:
Jonathan Kelley committed 2021-10-05 03:37:15 -04:00
1 parent a2b0c50a34
commit efd0e9b564
25 files changed
+701 -441

No files matched your search

+1 -19
View File
@@ -467,7 +467,7 @@ impl<'bump> DiffMachine<'bump> {
if !has_comitted {
has_comitted = true;
edits.push(PushRoot {
id: root.unwrap().as_u64(),
root: root.unwrap().as_u64(),
});
}
};
@@ -1026,14 +1026,6 @@ impl<'bump> DiffMachine<'bump> {
}
}
fn replace_and_create_one_with_many(
&mut self,
old: &'bump VNode<'bump>,
new: &'bump [VNode<'bump>],
) {
//
}
fn replace_and_create_many_with_one(
&mut self,
old: &'bump [VNode<'bump>],
@@ -1130,13 +1122,3 @@ impl<'bump> DiffMachine<'bump> {
}
}
}
fn compare_strs(a: &str, b: &str) -> bool {
// Check by pointer, optimizing for static strs
if !std::ptr::eq(a, b) {
// If the pointers are different then check by value
a == b
} else {
true
}
}
-6
View File
@@ -39,7 +39,6 @@ pub(crate) struct DiffStack<'bump> {
instructions: Vec<DiffInstruction<'bump>>,
nodes_created_stack: SmallVec<[usize; 10]>,
pub scope_stack: SmallVec<[ScopeId; 5]>,
pub element_id_stack: SmallVec<[ElementId; 5]>,
}
impl<'bump> DiffStack<'bump> {
@@ -48,7 +47,6 @@ impl<'bump> DiffStack<'bump> {
instructions: Vec::with_capacity(1000),
nodes_created_stack: smallvec![],
scope_stack: smallvec![],
element_id_stack: smallvec![],
}
}
@@ -82,10 +80,6 @@ impl<'bump> DiffStack<'bump> {
self.nodes_created_stack.push(count);
}
pub fn _push_element_id(&mut self, id: ElementId) {
self.element_id_stack.push(id);
}
pub fn create_node(&mut self, node: &'bump VNode<'bump>, and: MountType<'bump>) {
self.nodes_created_stack.push(0);
self.instructions.push(DiffInstruction::Mount { and });
-2
View File
@@ -13,8 +13,6 @@ use std::{
cell::{Cell, RefCell},
fmt::Debug,
ops::Deref,
rc::Rc,
sync::Arc,
};
pub use on::*;
+12 -12
View File
@@ -23,7 +23,7 @@ impl<'a> Mutations<'a> {
// Navigation
pub(crate) fn push_root(&mut self, root: ElementId) {
let id = root.as_u64();
self.edits.push(PushRoot { id });
self.edits.push(PushRoot { root: id });
}
pub(crate) fn pop(&mut self) {
@@ -53,7 +53,7 @@ impl<'a> Mutations<'a> {
// Create
pub(crate) fn create_text_node(&mut self, text: &'a str, id: ElementId) {
let id = id.as_u64();
self.edits.push(CreateTextNode { text, id });
self.edits.push(CreateTextNode { text, root: id });
}
pub(crate) fn create_element(
@@ -64,14 +64,14 @@ impl<'a> Mutations<'a> {
) {
let id = id.as_u64();
match ns {
Some(ns) => self.edits.push(CreateElementNs { id, ns, tag }),
None => self.edits.push(CreateElement { id, tag }),
Some(ns) => self.edits.push(CreateElementNs { root: id, ns, tag }),
None => self.edits.push(CreateElement { root: id, tag }),
}
}
// placeholders are nodes that don't get rendered but still exist as an "anchor" in the real dom
pub(crate) fn create_placeholder(&mut self, id: ElementId) {
let id = id.as_u64();
self.edits.push(CreatePlaceholder { id });
self.edits.push(CreatePlaceholder { root: id });
}
// events
@@ -87,7 +87,7 @@ impl<'a> Mutations<'a> {
self.edits.push(NewEventListener {
scope,
event_name: event,
mounted_node_id: element_id,
root: element_id,
});
}
pub(crate) fn remove_event_listener(&mut self, event: &'static str) {
@@ -159,7 +159,7 @@ impl<'a> NodeRefMutation<'a> {
)]
pub enum DomEdit<'bump> {
PushRoot {
id: u64,
root: u64,
},
PopRoot,
@@ -187,24 +187,24 @@ pub enum DomEdit<'bump> {
CreateTextNode {
text: &'bump str,
id: u64,
root: u64,
},
CreateElement {
tag: &'bump str,
id: u64,
root: u64,
},
CreateElementNs {
tag: &'bump str,
id: u64,
root: u64,
ns: &'static str,
},
CreatePlaceholder {
id: u64,
root: u64,
},
NewEventListener {
event_name: &'static str,
scope: ScopeId,
mounted_node_id: u64,
root: u64,
},
RemoveEventListener {
event: &'static str,
+2
View File
@@ -506,6 +506,8 @@ impl Scheduler {
}
}
log::debug!("work with deadline completed: {:#?}", committed_mutations);
committed_mutations
}
-1
View File
@@ -7,7 +7,6 @@ use std::{
future::Future,
pin::Pin,
rc::Rc,
sync::Arc,
};
/// Every component in Dioxus is represented by a `Scope`.