wip: working down warnings

This commit is contained in:
Jonathan Kelley committed 2021-09-02 00:10:09 -04:00
1 parent a652090dc5
commit 958c02a26e
6 files changed
+77 -71

No files matched your search

-4
View File
@@ -40,10 +40,6 @@ impl ActiveFrame {
self.wip_frame_mut().bump.reset()
}
pub fn update_head_node<'a>(&mut self, node: VNode<'a>) {
self.wip_frame_mut().head_node = unsafe { std::mem::transmute(node) };
}
/// The "work in progress frame" represents the frame that is currently being worked on.
pub fn wip_frame(&self) -> &BumpFrame {
match self.generation.get() & 1 == 0 {
+32 -28
View File
@@ -294,15 +294,18 @@ impl<'bump> DiffMachine<'bump> {
self.stack.add_child_count(1);
let cur_scope_id = self.stack.current_scope().unwrap();
let scope = self.vdom.get_scope(cur_scope_id).unwrap();
if let Some(cur_scope_id) = self.stack.current_scope() {
let scope = self.vdom.get_scope(cur_scope_id).unwrap();
listeners.iter().for_each(|listener| {
self.attach_listener_to_scope(listener, scope);
listener.mounted_node.set(Some(real_id));
self.mutations
.new_event_listener(listener, cur_scope_id.clone());
});
listeners.iter().for_each(|listener| {
self.attach_listener_to_scope(listener, scope);
listener.mounted_node.set(Some(real_id));
self.mutations
.new_event_listener(listener, cur_scope_id.clone());
});
} else {
log::warn!("create element called with no scope on the stack - this is an error for a live dom");
}
for attr in *attributes {
self.mutations.set_attribute(attr);
@@ -465,28 +468,29 @@ impl<'bump> DiffMachine<'bump> {
//
// TODO: take a more efficient path than this
let cur_scope_id = self.stack.current_scope().unwrap();
let scope = self.vdom.get_scope(cur_scope_id).unwrap();
if let Some(cur_scope_id) = self.stack.current_scope() {
let scope = self.vdom.get_scope(cur_scope_id).unwrap();
if old.listeners.len() == new.listeners.len() {
for (old_l, new_l) in old.listeners.iter().zip(new.listeners.iter()) {
if old_l.event != new_l.event {
please_commit(&mut self.mutations.edits);
self.mutations.remove_event_listener(old_l.event);
self.mutations.new_event_listener(new_l, cur_scope_id);
if old.listeners.len() == new.listeners.len() {
for (old_l, new_l) in old.listeners.iter().zip(new.listeners.iter()) {
if old_l.event != new_l.event {
please_commit(&mut self.mutations.edits);
self.mutations.remove_event_listener(old_l.event);
self.mutations.new_event_listener(new_l, cur_scope_id);
}
new_l.mounted_node.set(old_l.mounted_node.get());
self.attach_listener_to_scope(new_l, scope);
}
} else {
please_commit(&mut self.mutations.edits);
for listener in old.listeners {
self.mutations.remove_event_listener(listener.event);
}
for listener in new.listeners {
listener.mounted_node.set(Some(root));
self.mutations.new_event_listener(listener, cur_scope_id);
self.attach_listener_to_scope(listener, scope);
}
new_l.mounted_node.set(old_l.mounted_node.get());
self.attach_listener_to_scope(new_l, scope);
}
} else {
please_commit(&mut self.mutations.edits);
for listener in old.listeners {
self.mutations.remove_event_listener(listener.event);
}
for listener in new.listeners {
listener.mounted_node.set(Some(root));
self.mutations.new_event_listener(listener, cur_scope_id);
self.attach_listener_to_scope(listener, scope);
}
}
+2 -1
View File
@@ -45,6 +45,7 @@ pub(crate) mod innerlude {
pub use crate::nodes::*;
pub use crate::scheduler::*;
pub use crate::scope::*;
pub use crate::test_dom::*;
pub use crate::util::*;
pub use crate::virtual_dom::*;
@@ -57,7 +58,7 @@ pub(crate) mod innerlude {
pub use crate::innerlude::{
format_args_f, html, rsx, Context, DiffInstruction, DioxusElement, DomEdit, DomTree, ElementId,
EventPriority, LazyNodes, MountType, Mutations, NodeFactory, Properties, ScopeId,
SuspendedContext, SyntheticEvent, UiEvent, VNode, VirtualDom, FC,
SuspendedContext, SyntheticEvent, TestDom, UiEvent, VNode, VirtualDom, FC,
};
pub mod prelude {
+8 -8
View File
@@ -62,7 +62,7 @@ impl Scope {
//
// Scopes cannot be made anywhere else except for this file
// Therefore, their lifetimes are connected exclusively to the virtual dom
pub fn new<'creator_node>(
pub(crate) fn new<'creator_node>(
caller: Rc<WrappedCaller>,
arena_idx: ScopeId,
parent: Option<ScopeId>,
@@ -211,15 +211,11 @@ impl Scope {
}
}
pub fn root(&self) -> &VNode {
self.frames.fin_head()
}
pub fn child_nodes<'a>(&'a self) -> ScopeChildren {
pub(crate) fn child_nodes<'a>(&'a self) -> ScopeChildren {
unsafe { self.child_nodes.shorten_lifetime() }
}
pub fn call_suspended_node<'a>(&'a self, task: u64) {
pub(crate) fn call_suspended_node<'a>(&'a self, task: u64) {
let g = self.suspended_nodes.borrow_mut();
if let Some(suspended) = g.get(&task) {
@@ -239,7 +235,7 @@ impl Scope {
}
}
pub fn consume_garbage(&self) -> Vec<&VNode> {
pub(crate) fn consume_garbage(&self) -> Vec<&VNode> {
self.pending_garbage
.borrow_mut()
.drain(..)
@@ -251,4 +247,8 @@ impl Scope {
})
.collect::<Vec<_>>()
}
pub fn root(&self) -> &VNode {
self.frames.fin_head()
}
}
+2 -2
View File
@@ -12,9 +12,10 @@ pub struct TestDom {
impl TestDom {
pub fn new() -> TestDom {
let bump = Bump::new();
let scheduler = Scheduler::new();
let mut scheduler = Scheduler::new();
TestDom { bump, scheduler }
}
pub fn new_factory<'a>(&'a self) -> NodeFactory<'a> {
NodeFactory::new(&self.bump)
}
@@ -30,7 +31,6 @@ impl TestDom {
let mutations = Mutations::new();
let mut machine = DiffMachine::new(mutations, &self.scheduler.pool);
machine.stack.push(DiffInstruction::DiffNode { new, old });
machine.mutations
}