77// option. This file may not be copied, modified, or distributed
88// except according to those terms.
99
10- #[ macro_use]
11- extern crate markup5ever;
12-
13- extern crate html5ever;
10+ #[ macro_use] extern crate html5ever;
1411
1512use std:: io;
1613use std:: default:: Default ;
1714use std:: collections:: HashMap ;
1815use std:: borrow:: Cow ;
1916
20- use html5ever:: { QualName , Attribute } ;
21- use html5ever:: tree_builder:: { TreeSink , QuirksMode , NodeOrText , AppendNode , AppendText } ;
17+ use html5ever:: { QualName , ExpandedName , Attribute } ;
18+ use html5ever:: tree_builder:: { TreeSink , QuirksMode , NodeOrText , AppendNode , AppendText , ElementFlags } ;
2219use html5ever:: parse_document;
2320use html5ever:: tendril:: * ;
2421
@@ -48,8 +45,8 @@ impl TreeSink for Sink {
4845 0
4946 }
5047
51- fn get_template_contents ( & mut self , target : usize ) -> usize {
52- if let Some ( & qualname ! ( html, "template" ) ) = self . names . get ( & target) {
48+ fn get_template_contents ( & mut self , target : & usize ) -> usize {
49+ if let Some ( expanded_name ! ( html "template" ) ) = self . names . get ( target) . map ( |n| n . expanded ( ) ) {
5350 target + 1
5451 } else {
5552 panic ! ( "not a template element" )
@@ -60,24 +57,15 @@ impl TreeSink for Sink {
6057 println ! ( "Set quirks mode to {:?}" , mode) ;
6158 }
6259
63- fn same_node ( & self , x : usize , y : usize ) -> bool {
64- x == y
65- }
66-
67- fn same_node_ref ( & self , x : & usize , y : & usize ) -> bool {
60+ fn same_node ( & self , x : & usize , y : & usize ) -> bool {
6861 x == y
6962 }
7063
71- fn elem_name ( & self , target : usize ) -> QualName {
72- self . names . get ( & target) . expect ( "not an element" ) . clone ( )
64+ fn elem_name ( & self , target : & usize ) -> ExpandedName {
65+ self . names . get ( target) . expect ( "not an element" ) . expanded ( )
7366 }
7467
75- fn elem_name_ref ( & self , target : & usize ) -> QualName {
76- self . names . get ( target) . expect ( "not an element" ) . clone ( )
77- }
78-
79-
80- fn create_element ( & mut self , name : QualName , _attrs : Vec < Attribute > ) -> usize {
68+ fn create_element ( & mut self , name : QualName , _: Vec < Attribute > , _: ElementFlags ) -> usize {
8169 let id = self . get_id ( ) ;
8270 println ! ( "Created {:?} as {}" , name, id) ;
8371 self . names . insert ( id, name) ;
@@ -95,13 +83,13 @@ impl TreeSink for Sink {
9583 unimplemented ! ( )
9684 }
9785
98- fn has_parent_node ( & self , _node : usize ) -> bool {
86+ fn has_parent_node ( & self , _node : & usize ) -> bool {
9987 // `node` will have a parent unless a script moved it, and we're
10088 // not running scripts. Therefore we can aways return true
10189 true
10290 }
10391
104- fn append ( & mut self , parent : usize , child : NodeOrText < usize > ) {
92+ fn append ( & mut self , parent : & usize , child : NodeOrText < usize > ) {
10593 match child {
10694 AppendNode ( n)
10795 => println ! ( "Append node {} to {}" , n, parent) ,
@@ -111,7 +99,7 @@ impl TreeSink for Sink {
11199 }
112100
113101 fn append_before_sibling ( & mut self ,
114- sibling : usize ,
102+ sibling : & usize ,
115103 new_node : NodeOrText < usize > ) {
116104 match new_node {
117105 AppendNode ( n)
@@ -128,37 +116,37 @@ impl TreeSink for Sink {
128116 println ! ( "Append doctype: {} {} {}" , name, public_id, system_id) ;
129117 }
130118
131- fn add_attrs_if_missing ( & mut self , target : usize , attrs : Vec < Attribute > ) {
132- assert ! ( self . names. contains_key( & target) , "not an element" ) ;
119+ fn add_attrs_if_missing ( & mut self , target : & usize , attrs : Vec < Attribute > ) {
120+ assert ! ( self . names. contains_key( target) , "not an element" ) ;
133121 println ! ( "Add missing attributes to {}:" , target) ;
134122 for attr in attrs. into_iter ( ) {
135123 println ! ( " {:?} = {}" , attr. name, attr. value) ;
136124 }
137125 }
138126
139- fn associate_with_form ( & mut self , _target : usize , _form : usize ) {
127+ fn associate_with_form ( & mut self , _target : & usize , _form : & usize ) {
140128 // No form owner support. Since same_tree always returns
141129 // true we cannot be sure that this associate_with_form call is
142130 // valid
143131 }
144132
145- fn remove_from_parent ( & mut self , target : usize ) {
133+ fn remove_from_parent ( & mut self , target : & usize ) {
146134 println ! ( "Remove {} from parent" , target) ;
147135 }
148136
149- fn reparent_children ( & mut self , node : usize , new_parent : usize ) {
137+ fn reparent_children ( & mut self , node : & usize , new_parent : & usize ) {
150138 println ! ( "Move children from {} to {}" , node, new_parent) ;
151139 }
152140
153- fn mark_script_already_started ( & mut self , node : usize ) {
141+ fn mark_script_already_started ( & mut self , node : & usize ) {
154142 println ! ( "Mark script {} as already started" , node) ;
155143 }
156144
157145 fn set_current_line ( & mut self , line_number : u64 ) {
158146 println ! ( "Set current line to {}" , line_number) ;
159147 }
160148
161- fn pop ( & mut self , elem : usize ) {
149+ fn pop ( & mut self , elem : & usize ) {
162150 println ! ( "Popped element {}" , elem) ;
163151 }
164152}
0 commit comments