@@ -4,7 +4,9 @@ use std::default::Default;
44
55use html5ever:: tree_builder:: { ElementFlags , NodeOrText , QuirksMode , TreeSink } ;
66use html5ever:: { Attribute , QualName } ;
7+
78use markup5ever:: ExpandedName ;
9+ use markup5ever:: { local_name, namespace_url, ns} ;
810
911use tendril:: StrTendril ;
1012
@@ -59,8 +61,8 @@ impl NodeEnum {
5961 fn script_or_style ( & self ) -> ScriptOrStyle {
6062 match * self {
6163 Element ( ref name, ..) => match name. expanded ( ) {
62- expanded_name ! ( html "script" ) => ScriptOrStyle :: Script ,
63- expanded_name ! ( html "style" ) => ScriptOrStyle :: Style ,
64+ markup5ever :: expanded_name!( html "script" ) => ScriptOrStyle :: Script ,
65+ markup5ever :: expanded_name!( html "style" ) => ScriptOrStyle :: Style ,
6466 _ => ScriptOrStyle :: Neither ,
6567 } ,
6668 _ => ScriptOrStyle :: Neither ,
@@ -91,10 +93,10 @@ impl Node {
9193 fn new ( id : Id , node : NodeEnum ) -> Node {
9294 Node {
9395 parent : Parent :: None ,
94- id : id ,
96+ id,
9597 children : vec ! [ ] ,
9698 last_string : false ,
97- node : node ,
99+ node,
98100 }
99101 }
100102
@@ -195,7 +197,7 @@ impl TreeSink for FlatDom {
195197 fn get_template_contents ( & mut self , target : & Self :: Handle ) -> Self :: Handle {
196198 if let Element ( _, _, true ) = self . node ( * target) . node {
197199 // Use template element as document fragment
198- target. clone ( )
200+ * target
199201 } else {
200202 panic ! ( "not a template element!" )
201203 }
@@ -336,7 +338,7 @@ impl TreeSink for FlatDom {
336338// NIF Encoding
337339
338340mod atoms {
339- atoms ! {
341+ rustler :: atoms! {
340342 nil,
341343
342344 parent,
@@ -379,20 +381,20 @@ mod atoms {
379381// Unsure if this is a great way of doing it, but it's the way
380382// that produced the cleanest and least noisy code.
381383
382- struct QNW < ' a > ( & ' a QualName ) ;
384+ struct Qnw < ' a > ( & ' a QualName ) ;
383385
384- impl < ' b > Encoder for QNW < ' b > {
386+ impl < ' b > Encoder for Qnw < ' b > {
385387 fn encode < ' a > ( & self , env : Env < ' a > ) -> Term < ' a > {
386- let local: & str = & * self . 0 . local ;
388+ let local: & str = & self . 0 . local ;
387389 local. encode ( env)
388390 }
389391}
390392
391- struct STW < ' a > ( & ' a StrTendril ) ;
393+ struct Stw < ' a > ( & ' a StrTendril ) ;
392394
393- impl < ' b > Encoder for STW < ' b > {
395+ impl < ' b > Encoder for Stw < ' b > {
394396 fn encode < ' a > ( & self , env : Env < ' a > ) -> Term < ' a > {
395- let data: & str = & * self . 0 ;
397+ let data: & str = self . 0 ;
396398 data. encode ( env)
397399 }
398400}
@@ -437,7 +439,7 @@ impl Encoder for DataType {
437439// Node
438440
439441fn split_ns_and_tag ( ns_tag : & str ) -> ( & str , & str ) {
440- let first_colon = ns_tag. find ( ':' ) . unwrap_or_else ( || ns_tag. len ( ) ) ;
442+ let first_colon = ns_tag. find ( ':' ) . unwrap_or ( ns_tag. len ( ) ) ;
441443 match ns_tag. split_at ( first_colon) {
442444 ( tag, "" ) => ( "" , tag) ,
443445 ( ns, tag) => ( ns, & tag[ 1 ..] ) ,
@@ -477,7 +479,7 @@ impl Encoder for Node {
477479 document_comment_atom,
478480 self . parent. encode( env) ,
479481 self . id. encode( env) ,
480- STW ( content) . encode( env) ,
482+ Stw ( content) . encode( env) ,
481483 ] ;
482484 Term :: map_from_arrays ( env, & keys, & values) . ok ( ) . unwrap ( )
483485 }
@@ -492,7 +494,7 @@ impl Encoder for Node {
492494 self . parent. encode( env) ,
493495 self . id. encode( env) ,
494496 data_type. encode( env) ,
495- STW ( content) . encode( env) ,
497+ Stw ( content) . encode( env) ,
496498 ] ;
497499 Term :: map_from_arrays ( env, & keys, & values) . ok ( ) . unwrap ( )
498500 }
@@ -514,9 +516,9 @@ impl Encoder for Node {
514516 document_doctype_atom,
515517 self . parent. encode( env) ,
516518 self . id. encode( env) ,
517- STW ( name) . encode( env) ,
518- STW ( public) . encode( env) ,
519- STW ( system) . encode( env) ,
519+ Stw ( name) . encode( env) ,
520+ Stw ( public) . encode( env) ,
521+ Stw ( system) . encode( env) ,
520522 ] ;
521523 Term :: map_from_arrays ( env, & keys, & values) . ok ( ) . unwrap ( )
522524 }
@@ -529,10 +531,10 @@ impl Encoder for Node {
529531 let tag_atom = atoms:: tag ( ) . encode ( env) ;
530532 let attributes_atom = atoms:: attributes ( ) . encode ( env) ;
531533 let children_atom = atoms:: children ( ) . encode ( env) ;
532- let ( namespace, tag) = ns_and_tag ( & name) ;
534+ let ( namespace, tag) = ns_and_tag ( name) ;
533535 let attribute_terms: Vec < Term < ' a > > = attributes
534536 . iter ( )
535- . map ( |a| ( QNW ( & a. name ) , STW ( & a. value ) ) . encode ( env) )
537+ . map ( |a| ( Qnw ( & a. name ) , Stw ( & a. value ) ) . encode ( env) )
536538 . collect ( ) ;
537539 let keys = vec ! [
538540 struct_atom,
@@ -564,8 +566,8 @@ impl Encoder for Node {
564566 document_pi_atom,
565567 self . parent. encode( env) ,
566568 self . id. encode( env) ,
567- STW ( target) . encode( env) ,
568- STW ( data) . encode( env) ,
569+ Stw ( target) . encode( env) ,
570+ Stw ( data) . encode( env) ,
569571 ] ;
570572 Term :: map_from_arrays ( env, & keys, & values) . ok ( ) . unwrap ( )
571573 }
@@ -578,7 +580,7 @@ impl Encoder for Node {
578580 document_text_atom,
579581 self . parent. encode( env) ,
580582 self . id. encode( env) ,
581- STW ( content) . encode( env) ,
583+ Stw ( content) . encode( env) ,
582584 ] ;
583585 Term :: map_from_arrays ( env, & keys, & values) . ok ( ) . unwrap ( )
584586 }
0 commit comments