File tree Expand file tree Collapse file tree 3 files changed +29
-11
lines changed
Expand file tree Collapse file tree 3 files changed +29
-11
lines changed Original file line number Diff line number Diff line change @@ -668,11 +668,25 @@ pub struct RootedVec<'a, T: 'static + JSTraceable> {
668668 root : & ' a mut RootableVec < T > ,
669669}
670670
671- impl < ' a , T : ' static + JSTraceable + DomObject > RootedVec < ' a , JS < T > > {
671+ impl < ' a , T : ' static + JSTraceable > RootedVec < ' a , T > {
672672 /// Create a vector of items of type T that is rooted for
673673 /// the lifetime of this struct
674- pub fn new < I : Iterator < Item = Root < T > > > ( root : & ' a mut RootableVec < JS < T > > , iter : I )
675- -> RootedVec < ' a , JS < T > > {
674+ pub fn new ( root : & ' a mut RootableVec < T > ) -> Self {
675+ unsafe {
676+ RootedTraceableSet :: add ( root) ;
677+ }
678+ RootedVec {
679+ root : root,
680+ }
681+ }
682+ }
683+
684+ impl < ' a , T : ' static + JSTraceable + DomObject > RootedVec < ' a , JS < T > > {
685+ /// Create a vector of items of type JS<T> that is rooted for
686+ /// the lifetime of this struct
687+ pub fn from_iter < I > ( root : & ' a mut RootableVec < JS < T > > , iter : I ) -> Self
688+ where I : Iterator < Item = Root < T > >
689+ {
676690 unsafe {
677691 RootedTraceableSet :: add ( root) ;
678692 }
Original file line number Diff line number Diff line change @@ -1521,8 +1521,11 @@ impl Document {
15211521
15221522 /// https://html.spec.whatwg.org/multipage/#run-the-animation-frame-callbacks
15231523 pub fn run_the_animation_frame_callbacks ( & self ) {
1524- let mut animation_frame_list =
1525- mem:: replace ( & mut * self . animation_frame_list . borrow_mut ( ) , vec ! [ ] ) ;
1524+ rooted_vec ! ( let mut animation_frame_list) ;
1525+ mem:: swap (
1526+ & mut * animation_frame_list,
1527+ & mut * self . animation_frame_list . borrow_mut ( ) ) ;
1528+
15261529 self . running_animation_callbacks . set ( true ) ;
15271530 let timing = self . window . Performance ( ) . Now ( ) ;
15281531
@@ -1538,7 +1541,7 @@ impl Document {
15381541 // message quickly followed by an AnimationCallbacksPresent message.
15391542 if self . animation_frame_list . borrow ( ) . is_empty ( ) {
15401543 mem:: swap ( & mut * self . animation_frame_list . borrow_mut ( ) ,
1541- & mut animation_frame_list) ;
1544+ & mut * animation_frame_list) ;
15421545 let global_scope = self . window . upcast :: < GlobalScope > ( ) ;
15431546 let event = ConstellationMsg :: ChangeRunningAnimationsState ( global_scope. pipeline_id ( ) ,
15441547 AnimationState :: NoAnimationCallbacksPresent ) ;
Original file line number Diff line number Diff line change @@ -537,14 +537,15 @@ macro_rules! document_and_element_event_handlers(
537537#[ macro_export]
538538macro_rules! rooted_vec {
539539 ( let mut $name: ident) => {
540- rooted_vec!( let mut $name <- :: std:: iter:: empty( ) )
540+ let mut root = $crate:: dom:: bindings:: trace:: RootableVec :: new_unrooted( ) ;
541+ let mut $name = $crate:: dom:: bindings:: trace:: RootedVec :: new( & mut root) ;
541542 } ;
542543 ( let $name: ident <- $iter: expr) => {
543- let mut __root = $crate:: dom:: bindings:: trace:: RootableVec :: new_unrooted( ) ;
544- let $name = $crate:: dom:: bindings:: trace:: RootedVec :: new ( & mut __root , $iter) ;
544+ let mut root = $crate:: dom:: bindings:: trace:: RootableVec :: new_unrooted( ) ;
545+ let $name = $crate:: dom:: bindings:: trace:: RootedVec :: from_iter ( & mut root , $iter) ;
545546 } ;
546547 ( let mut $name: ident <- $iter: expr) => {
547- let mut __root = $crate:: dom:: bindings:: trace:: RootableVec :: new_unrooted( ) ;
548- let mut $name = $crate:: dom:: bindings:: trace:: RootedVec :: new ( & mut __root , $iter) ;
548+ let mut root = $crate:: dom:: bindings:: trace:: RootableVec :: new_unrooted( ) ;
549+ let mut $name = $crate:: dom:: bindings:: trace:: RootedVec :: from_iter ( & mut root , $iter) ;
549550 }
550551}
You can’t perform that action at this time.
0 commit comments