|
@@ -1,10 +1,13 @@
|
|
use crate::nodes::RenderReturn;
|
|
use crate::nodes::RenderReturn;
|
|
|
|
+use crate::{Attribute, AttributeValue};
|
|
use bumpalo::Bump;
|
|
use bumpalo::Bump;
|
|
|
|
+use std::cell::RefCell;
|
|
use std::cell::{Cell, UnsafeCell};
|
|
use std::cell::{Cell, UnsafeCell};
|
|
|
|
|
|
pub(crate) struct BumpFrame {
|
|
pub(crate) struct BumpFrame {
|
|
pub bump: UnsafeCell<Bump>,
|
|
pub bump: UnsafeCell<Bump>,
|
|
pub node: Cell<*const RenderReturn<'static>>,
|
|
pub node: Cell<*const RenderReturn<'static>>,
|
|
|
|
+ pub(crate) attributes_to_drop_before_reset: RefCell<Vec<*const Attribute<'static>>>,
|
|
}
|
|
}
|
|
|
|
|
|
impl BumpFrame {
|
|
impl BumpFrame {
|
|
@@ -13,6 +16,7 @@ impl BumpFrame {
|
|
Self {
|
|
Self {
|
|
bump: UnsafeCell::new(bump),
|
|
bump: UnsafeCell::new(bump),
|
|
node: Cell::new(std::ptr::null()),
|
|
node: Cell::new(std::ptr::null()),
|
|
|
|
+ attributes_to_drop_before_reset: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -31,8 +35,26 @@ impl BumpFrame {
|
|
unsafe { &*self.bump.get() }
|
|
unsafe { &*self.bump.get() }
|
|
}
|
|
}
|
|
|
|
|
|
- #[allow(clippy::mut_from_ref)]
|
|
|
|
- pub(crate) unsafe fn bump_mut(&self) -> &mut Bump {
|
|
|
|
- unsafe { &mut *self.bump.get() }
|
|
|
|
|
|
+ pub(crate) fn add_attribute_to_drop(&self, attribute: *const Attribute<'static>) {
|
|
|
|
+ self.attributes_to_drop_before_reset
|
|
|
|
+ .borrow_mut()
|
|
|
|
+ .push(attribute);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pub(crate) unsafe fn reset(&self) {
|
|
|
|
+ let mut attributes = self.attributes_to_drop_before_reset.borrow_mut();
|
|
|
|
+ attributes.drain(..).for_each(|attribute| {
|
|
|
|
+ let attribute = unsafe { &*attribute };
|
|
|
|
+ match &attribute.value {
|
|
|
|
+ AttributeValue::Any(l) => {
|
|
|
|
+ _ = l.take();
|
|
|
|
+ }
|
|
|
|
+ _ => (),
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ unsafe {
|
|
|
|
+ let bump = &mut *self.bump.get();
|
|
|
|
+ bump.reset();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|