mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Properly root the running animation list in a RootedVec
This commit is contained in:
parent
1327ebd52f
commit
26ab0f82a8
3 changed files with 29 additions and 11 deletions
|
@ -668,11 +668,25 @@ pub struct RootedVec<'a, T: 'static + JSTraceable> {
|
||||||
root: &'a mut RootableVec<T>,
|
root: &'a mut RootableVec<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: 'static + JSTraceable + DomObject> RootedVec<'a, JS<T>> {
|
impl<'a, T: 'static + JSTraceable> RootedVec<'a, T> {
|
||||||
/// Create a vector of items of type T that is rooted for
|
/// Create a vector of items of type T that is rooted for
|
||||||
/// the lifetime of this struct
|
/// the lifetime of this struct
|
||||||
pub fn new<I: Iterator<Item = Root<T>>>(root: &'a mut RootableVec<JS<T>>, iter: I)
|
pub fn new(root: &'a mut RootableVec<T>) -> Self {
|
||||||
-> RootedVec<'a, JS<T>> {
|
unsafe {
|
||||||
|
RootedTraceableSet::add(root);
|
||||||
|
}
|
||||||
|
RootedVec {
|
||||||
|
root: root,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, T: 'static + JSTraceable + DomObject> RootedVec<'a, JS<T>> {
|
||||||
|
/// Create a vector of items of type JS<T> that is rooted for
|
||||||
|
/// the lifetime of this struct
|
||||||
|
pub fn from_iter<I>(root: &'a mut RootableVec<JS<T>>, iter: I) -> Self
|
||||||
|
where I: Iterator<Item = Root<T>>
|
||||||
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
RootedTraceableSet::add(root);
|
RootedTraceableSet::add(root);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1521,8 +1521,11 @@ impl Document {
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#run-the-animation-frame-callbacks
|
/// https://html.spec.whatwg.org/multipage/#run-the-animation-frame-callbacks
|
||||||
pub fn run_the_animation_frame_callbacks(&self) {
|
pub fn run_the_animation_frame_callbacks(&self) {
|
||||||
let mut animation_frame_list =
|
rooted_vec!(let mut animation_frame_list);
|
||||||
mem::replace(&mut *self.animation_frame_list.borrow_mut(), vec![]);
|
mem::swap(
|
||||||
|
&mut *animation_frame_list,
|
||||||
|
&mut *self.animation_frame_list.borrow_mut());
|
||||||
|
|
||||||
self.running_animation_callbacks.set(true);
|
self.running_animation_callbacks.set(true);
|
||||||
let timing = self.window.Performance().Now();
|
let timing = self.window.Performance().Now();
|
||||||
|
|
||||||
|
@ -1538,7 +1541,7 @@ impl Document {
|
||||||
// message quickly followed by an AnimationCallbacksPresent message.
|
// message quickly followed by an AnimationCallbacksPresent message.
|
||||||
if self.animation_frame_list.borrow().is_empty() {
|
if self.animation_frame_list.borrow().is_empty() {
|
||||||
mem::swap(&mut *self.animation_frame_list.borrow_mut(),
|
mem::swap(&mut *self.animation_frame_list.borrow_mut(),
|
||||||
&mut animation_frame_list);
|
&mut *animation_frame_list);
|
||||||
let global_scope = self.window.upcast::<GlobalScope>();
|
let global_scope = self.window.upcast::<GlobalScope>();
|
||||||
let event = ConstellationMsg::ChangeRunningAnimationsState(global_scope.pipeline_id(),
|
let event = ConstellationMsg::ChangeRunningAnimationsState(global_scope.pipeline_id(),
|
||||||
AnimationState::NoAnimationCallbacksPresent);
|
AnimationState::NoAnimationCallbacksPresent);
|
||||||
|
|
|
@ -537,14 +537,15 @@ macro_rules! document_and_element_event_handlers(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! rooted_vec {
|
macro_rules! rooted_vec {
|
||||||
(let mut $name:ident) => {
|
(let mut $name:ident) => {
|
||||||
rooted_vec!(let mut $name <- ::std::iter::empty())
|
let mut root = $crate::dom::bindings::trace::RootableVec::new_unrooted();
|
||||||
|
let mut $name = $crate::dom::bindings::trace::RootedVec::new(&mut root);
|
||||||
};
|
};
|
||||||
(let $name:ident <- $iter:expr) => {
|
(let $name:ident <- $iter:expr) => {
|
||||||
let mut __root = $crate::dom::bindings::trace::RootableVec::new_unrooted();
|
let mut root = $crate::dom::bindings::trace::RootableVec::new_unrooted();
|
||||||
let $name = $crate::dom::bindings::trace::RootedVec::new(&mut __root, $iter);
|
let $name = $crate::dom::bindings::trace::RootedVec::from_iter(&mut root, $iter);
|
||||||
};
|
};
|
||||||
(let mut $name:ident <- $iter:expr) => {
|
(let mut $name:ident <- $iter:expr) => {
|
||||||
let mut __root = $crate::dom::bindings::trace::RootableVec::new_unrooted();
|
let mut root = $crate::dom::bindings::trace::RootableVec::new_unrooted();
|
||||||
let mut $name = $crate::dom::bindings::trace::RootedVec::new(&mut __root, $iter);
|
let mut $name = $crate::dom::bindings::trace::RootedVec::from_iter(&mut root, $iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue