@@ -6,9 +6,7 @@ use std::str;
6
6
7
7
use encoding:: label:: encoding_from_whatwg_label;
8
8
use encoding:: all:: UTF_8 ;
9
- use encoding:: Encoding ;
10
- use encoding:: DecodeReplace ;
11
- use encoding:: decode;
9
+ use encoding:: { EncodingObj , DecodeReplace , decode} ;
12
10
13
11
use tokenizer:: { tokenize, Tokenizer } ;
14
12
use parser:: { parse_stylesheet_rules, StylesheetParser } ;
@@ -33,8 +31,8 @@ use parser::{parse_stylesheet_rules, StylesheetParser};
33
31
/// A 2-tuple of a decoded Unicode string
34
32
/// and the `Encoding` object that was used.
35
33
pub fn decode_stylesheet_bytes ( css : & [ u8 ] , protocol_encoding_label : Option < & str > ,
36
- environment_encoding : Option < & ' static Encoding > )
37
- -> ( ~str , & ' static Encoding ) {
34
+ environment_encoding : Option < EncodingObj > )
35
+ -> ( ~str , EncodingObj ) {
38
36
// http://dev.w3.org/csswg/css-syntax/#the-input-byte-stream
39
37
match protocol_encoding_label {
40
38
None => ( ) ,
@@ -56,7 +54,7 @@ pub fn decode_stylesheet_bytes(css: &[u8], protocol_encoding_label: Option<&str>
56
54
None => ( ) ,
57
55
Some ( fallback) => match fallback. name ( ) {
58
56
"utf-16be" | "utf-16le"
59
- => return decode_replace ( css, UTF_8 as & ' static Encoding ) ,
57
+ => return decode_replace ( css, UTF_8 as EncodingObj ) ,
60
58
_ => return decode_replace ( css, fallback) ,
61
59
}
62
60
}
@@ -67,12 +65,12 @@ pub fn decode_stylesheet_bytes(css: &[u8], protocol_encoding_label: Option<&str>
67
65
None => ( ) ,
68
66
Some ( fallback) => return decode_replace ( css, fallback)
69
67
}
70
- return decode_replace ( css, UTF_8 as & ' static Encoding )
68
+ return decode_replace ( css, UTF_8 as EncodingObj )
71
69
}
72
70
73
71
74
72
#[ inline]
75
- fn decode_replace ( input : & [ u8 ] , fallback_encoding : & ' static Encoding ) -> ( ~str , & ' static Encoding ) {
73
+ fn decode_replace ( input : & [ u8 ] , fallback_encoding : EncodingObj ) -> ( ~str , EncodingObj ) {
76
74
let ( result, used_encoding) = decode ( input, DecodeReplace , fallback_encoding) ;
77
75
( result. unwrap ( ) , used_encoding)
78
76
}
@@ -94,8 +92,8 @@ fn decode_replace(input: &[u8], fallback_encoding: &'static Encoding)-> (~str, &
94
92
/// and the `Encoding` object that was used.
95
93
pub fn parse_stylesheet_rules_from_bytes (
96
94
css_bytes : & [ u8 ] , protocol_encoding_label : Option < & str > ,
97
- environment_encoding : Option < & ' static Encoding > )
98
- -> ( StylesheetParser < Tokenizer > , & ' static Encoding ) {
95
+ environment_encoding : Option < EncodingObj > )
96
+ -> ( StylesheetParser < Tokenizer > , EncodingObj ) {
99
97
let ( css_unicode, encoding) = decode_stylesheet_bytes (
100
98
css_bytes, protocol_encoding_label, environment_encoding) ;
101
99
( parse_stylesheet_rules ( tokenize ( css_unicode) ) , encoding)
0 commit comments