@@ -10,11 +10,11 @@ use crate::properties::ComputedValues;
1010use crate :: selector_parser:: { Direction , HorizontalDirection , SelectorParser } ;
1111use crate :: str:: starts_with_ignore_ascii_case;
1212use crate :: string_cache:: { Atom , Namespace , WeakAtom , WeakNamespace } ;
13- use crate :: values:: { AtomIdent , AtomString } ;
14- use cssparser:: { parse_nth , CowRcStr , SourceLocation , ToCss , Token } ;
13+ use crate :: values:: { AtomIdent , AtomString , CSSInteger } ;
14+ use cssparser:: { CowRcStr , SourceLocation , ToCss , Token } ;
1515use cssparser:: { BasicParseError , BasicParseErrorKind , Parser } ;
1616use dom:: { DocumentState , ElementState , HEADING_LEVEL_OFFSET } ;
17- use selectors:: parser:: { AnPlusB , SelectorParseErrorKind } ;
17+ use selectors:: parser:: SelectorParseErrorKind ;
1818use std:: fmt;
1919use style_traits:: { CssWriter , ParseError , StyleParseErrorKind , ToCss as ToCss_ } ;
2020use thin_vec:: ThinVec ;
@@ -48,11 +48,11 @@ pub struct CustomState(pub AtomIdent);
4848/// The properties that comprise a :heading() pseudoclass (e.g. a list of An+Bs).
4949/// https://drafts.csswg.org/selectors-5/#headings
5050#[ derive( Clone , Debug , Eq , MallocSizeOf , PartialEq , ToShmem ) ]
51- pub struct HeadingSelectorData ( pub ThinVec < AnPlusB > ) ;
51+ pub struct HeadingSelectorData ( pub ThinVec < CSSInteger > ) ;
5252
5353impl HeadingSelectorData {
5454 /// Matches the heading level from the given state against the list of
55- /// heading level AnPlusB selectors. If AnPlusBs intersect with the level packed in
55+ /// heading level selectors. If AnPlusBs intersect with the level packed in
5656 /// ElementState then this will return true.
5757 pub fn matches_state ( & self , state : ElementState ) -> bool {
5858 let bits = state. intersection ( ElementState :: HEADING_LEVEL_BITS ) . bits ( ) ;
@@ -68,7 +68,7 @@ impl HeadingSelectorData {
6868 }
6969 let level = ( bits >> HEADING_LEVEL_OFFSET ) as i32 ;
7070 debug_assert ! ( level > 0 && level < 16 ) ;
71- self . 0 . iter ( ) . any ( |anb| anb . matches_index ( level) )
71+ self . 0 . iter ( ) . any ( |item| * item == level)
7272 }
7373}
7474
@@ -132,12 +132,12 @@ impl ToCss for NonTSPseudoClass {
132132 }
133133 dest. write_str( "(" ) ?;
134134 let mut first = true ;
135- for anb in levels. 0 . iter( ) {
135+ for item in levels. 0 . iter( ) {
136136 if !first {
137137 dest. write_str( ", " ) ?;
138138 }
139139 first = false ;
140- anb . to_css( dest) ?;
140+ ToCss :: to_css( item , dest) ?;
141141 }
142142 return dest. write_str( ")" ) ;
143143 } ,
@@ -508,10 +508,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
508508 NonTSPseudoClass :: CustomState ( CustomState ( result) )
509509 } ,
510510 "heading" => {
511- let result = parser. parse_comma_separated( |input| {
512- let ( a, b) = parse_nth( input) ?;
513- Ok ( AnPlusB ( a, b) )
514- } ) ?;
511+ let result = parser. parse_comma_separated( |input| Ok ( input. expect_integer( ) ?) ) ?;
515512 if result. is_empty( ) {
516513 return Err ( parser. new_custom_error( StyleParseErrorKind :: UnspecifiedError ) ) ;
517514 }
0 commit comments