@@ -211,6 +211,14 @@ pub struct Tokenizer<'a> {
211
211
position : usize ,
212
212
/// Cache for `source_location()`
213
213
last_known_line_break : Cell < ( usize , usize ) > ,
214
+ var_functions : VarFunctions ,
215
+ }
216
+
217
+ #[ derive( Copy , Clone , PartialEq , Eq ) ]
218
+ enum VarFunctions {
219
+ DontCare ,
220
+ LookingForThem ,
221
+ SeenAtLeastOne ,
214
222
}
215
223
216
224
@@ -221,9 +229,22 @@ impl<'a> Tokenizer<'a> {
221
229
input : input,
222
230
position : 0 ,
223
231
last_known_line_break : Cell :: new ( ( 1 , 0 ) ) ,
232
+ var_functions : VarFunctions :: DontCare ,
224
233
}
225
234
}
226
235
236
+ #[ inline]
237
+ pub fn look_for_var_functions ( & mut self ) {
238
+ self . var_functions = VarFunctions :: LookingForThem ;
239
+ }
240
+
241
+ #[ inline]
242
+ pub fn seen_var_functions ( & mut self ) -> bool {
243
+ let seen = self . var_functions == VarFunctions :: SeenAtLeastOne ;
244
+ self . var_functions = VarFunctions :: DontCare ;
245
+ seen
246
+ }
247
+
227
248
#[ inline]
228
249
pub fn next ( & mut self ) -> Result < Token < ' a > , ( ) > {
229
250
next_token ( self ) . ok_or ( ( ) )
@@ -606,8 +627,15 @@ fn consume_ident_like<'a>(tokenizer: &mut Tokenizer<'a>) -> Token<'a> {
606
627
let value = consume_name ( tokenizer) ;
607
628
if !tokenizer. is_eof ( ) && tokenizer. next_char ( ) == '(' {
608
629
tokenizer. advance ( 1 ) ;
609
- if value. eq_ignore_ascii_case ( "url" ) { consume_url ( tokenizer) }
610
- else { Function ( value) }
630
+ if value. eq_ignore_ascii_case ( "url" ) {
631
+ consume_url ( tokenizer)
632
+ } else {
633
+ if tokenizer. var_functions == VarFunctions :: LookingForThem &&
634
+ value. eq_ignore_ascii_case ( "var" ) {
635
+ tokenizer. var_functions = VarFunctions :: SeenAtLeastOne ;
636
+ }
637
+ Function ( value)
638
+ }
611
639
} else {
612
640
Ident ( value)
613
641
}
0 commit comments