@@ -118,6 +118,9 @@ pub struct TreeBuilder<Handle, Sink> {
118118
119119 /// Form element pointer.
120120 form_elem : RefCell < Option < Handle > > ,
121+
122+ /// selectedcontent element pointer.
123+ selectedcontent_elem : RefCell < Option < Handle > > ,
121124 //§ END
122125 /// Frameset-ok flag.
123126 frameset_ok : Cell < bool > ,
@@ -163,6 +166,7 @@ where
163166 active_formatting : Default :: default ( ) ,
164167 head_elem : Default :: default ( ) ,
165168 form_elem : Default :: default ( ) ,
169+ selectedcontent_elem : Default :: default ( ) ,
166170 frameset_ok : Cell :: new ( true ) ,
167171 ignore_lf : Default :: default ( ) ,
168172 foster_parenting : Default :: default ( ) ,
@@ -203,6 +207,7 @@ where
203207 active_formatting : Default :: default ( ) ,
204208 head_elem : Default :: default ( ) ,
205209 form_elem : RefCell :: new ( form_elem) ,
210+ selectedcontent_elem : Default :: default ( ) ,
206211 frameset_ok : Cell :: new ( true ) ,
207212 ignore_lf : Default :: default ( ) ,
208213 foster_parenting : Default :: default ( ) ,
@@ -285,6 +290,10 @@ where
285290 tracer. trace_handle ( form_elem) ;
286291 }
287292
293+ if let Some ( selectedcontent_elem) = self . selectedcontent_elem . borrow ( ) . as_ref ( ) {
294+ tracer. trace_handle ( selectedcontent_elem) ;
295+ }
296+
288297 if let Some ( context_elem) = self . context_elem . borrow ( ) . as_ref ( ) {
289298 tracer. trace_handle ( context_elem) ;
290299 }
@@ -923,6 +932,7 @@ where
923932 . borrow_mut ( )
924933 . pop ( )
925934 . expect ( "no current element" ) ;
935+
926936 self . sink . pop ( & elem) ;
927937 elem
928938 }
@@ -1392,6 +1402,10 @@ where
13921402
13931403 self . insert_at ( insertion_point, AppendNode ( elem. clone ( ) ) ) ;
13941404
1405+ if qname. local == local_name ! ( "selectedcontent" ) && self . selectedcontent_elem . borrow ( ) . is_none ( ) {
1406+ * self . selectedcontent_elem . borrow_mut ( ) = Some ( elem. clone ( ) ) ;
1407+ }
1408+
13951409 match push {
13961410 PushFlag :: Push => self . push ( & elem) ,
13971411 PushFlag :: NoPush => ( ) ,
@@ -1576,6 +1590,18 @@ where
15761590 self . remove_from_stack ( & node) ;
15771591 }
15781592
1593+ fn maybe_clone_option_into_selectedcontent ( & self , option : & Handle ) {
1594+ if let Some ( selectedcontent) = self . selectedcontent_elem . borrow ( ) . as_ref ( ) . cloned ( ) {
1595+ self . clone_option_into_selectedcontent ( option, & selectedcontent) ;
1596+ }
1597+ }
1598+
1599+ fn clone_option_into_selectedcontent ( & self , option : & Handle , selectedcontent : & Handle ) {
1600+ self . sink . reparent_children ( selectedcontent, & self . sink . get_document ( ) ) ;
1601+ let cloned_option = self . sink . clone_subtree ( option) ;
1602+ self . sink . reparent_children ( & cloned_option, selectedcontent) ;
1603+ }
1604+
15791605 //§ tree-construction
15801606 fn is_foreign ( & self , token : & Token ) -> bool {
15811607 if let Token :: Eof = * token {
0 commit comments