@@ -244,6 +244,15 @@ impl<'a> Tokenizer<'a> {
244244 seen
245245 }
246246
247+ #[ inline]
248+ pub fn see_function ( & mut self , name : & str ) {
249+ if self . var_functions == SeenStatus :: LookingForThem {
250+ if name. eq_ignore_ascii_case ( "var" ) {
251+ self . var_functions = SeenStatus :: SeenAtLeastOne ;
252+ }
253+ }
254+ }
255+
247256 #[ inline]
248257 pub fn look_for_viewport_percentages ( & mut self ) {
249258 self . viewport_percentages = SeenStatus :: LookingForThem ;
@@ -256,6 +265,18 @@ impl<'a> Tokenizer<'a> {
256265 seen
257266 }
258267
268+ #[ inline]
269+ pub fn see_dimension ( & mut self , unit : & str ) {
270+ if self . viewport_percentages == SeenStatus :: LookingForThem {
271+ if unit. eq_ignore_ascii_case ( "vh" ) ||
272+ unit. eq_ignore_ascii_case ( "vw" ) ||
273+ unit. eq_ignore_ascii_case ( "vmin" ) ||
274+ unit. eq_ignore_ascii_case ( "vmax" ) {
275+ self . viewport_percentages = SeenStatus :: SeenAtLeastOne ;
276+ }
277+ }
278+ }
279+
259280 #[ inline]
260281 pub fn next ( & mut self ) -> Result < Token < ' a > , ( ) > {
261282 next_token ( self )
@@ -699,10 +720,7 @@ fn consume_ident_like<'a>(tokenizer: &mut Tokenizer<'a>) -> Token<'a> {
699720 if value. eq_ignore_ascii_case ( "url" ) {
700721 consume_unquoted_url ( tokenizer) . unwrap_or ( Function ( value) )
701722 } else {
702- if tokenizer. var_functions == SeenStatus :: LookingForThem &&
703- value. eq_ignore_ascii_case ( "var" ) {
704- tokenizer. var_functions = SeenStatus :: SeenAtLeastOne ;
705- }
723+ tokenizer. see_function ( & value) ;
706724 Function ( value)
707725 }
708726 } else {
@@ -887,14 +905,7 @@ fn consume_numeric<'a>(tokenizer: &mut Tokenizer<'a>) -> Token<'a> {
887905 let value = value as f32 ;
888906 if is_ident_start ( tokenizer) {
889907 let unit = consume_name ( tokenizer) ;
890- if tokenizer. viewport_percentages == SeenStatus :: LookingForThem {
891- if unit. eq_ignore_ascii_case ( "vh" ) ||
892- unit. eq_ignore_ascii_case ( "vw" ) ||
893- unit. eq_ignore_ascii_case ( "vmin" ) ||
894- unit. eq_ignore_ascii_case ( "vmax" ) {
895- tokenizer. viewport_percentages = SeenStatus :: SeenAtLeastOne ;
896- }
897- }
908+ tokenizer. see_dimension ( & unit) ;
898909 Dimension {
899910 value : value,
900911 int_value : int_value,
0 commit comments