@@ -3,6 +3,7 @@ use selectors::{SelectorList, parser::SelectorImpl};
33use std:: fmt;
44use std:: cell:: RefCell ;
55use crate :: media_query:: * ;
6+ use crate :: properties:: * ;
67
78#[ derive( Debug , Clone ) ]
89pub struct Selectors ;
@@ -155,7 +156,7 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser {
155156 type PreludeNoBlock = AtRulePrelude ;
156157 type PreludeBlock = AtRulePrelude ;
157158 type AtRule = ( SourcePosition , CssRule ) ;
158- type Error = selectors :: parser :: SelectorParseErrorKind < ' i > ;
159+ type Error = ( ) ;
159160
160161 fn parse_prelude < ' t > (
161162 & mut self ,
@@ -288,7 +289,7 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser {
288289impl < ' a , ' i > QualifiedRuleParser < ' i > for TopLevelRuleParser {
289290 type Prelude = SelectorList < Selectors > ;
290291 type QualifiedRule = ( SourcePosition , CssRule ) ;
291- type Error = selectors :: parser :: SelectorParseErrorKind < ' i > ;
292+ type Error = ( ) ;
292293
293294 #[ inline]
294295 fn parse_prelude < ' t > (
@@ -358,20 +359,20 @@ impl ToCss for ImportRule {
358359#[ derive( Debug ) ]
359360pub struct StyleRule {
360361 pub selectors : SelectorList < Selectors > ,
361- pub declarations : Vec < ( String , Vec < Value > ) >
362+ pub declarations : Vec < Property >
362363}
363364
364365impl ToCss for StyleRule {
365366 fn to_css < W > ( & self , dest : & mut W ) -> fmt:: Result where W : fmt:: Write {
366367 // dest.write_str(&self.selectors)?;
367368 self . selectors . to_css ( dest) ?;
368369 dest. write_str ( " { " ) ?;
369- for ( key, val) in self . declarations . iter ( ) {
370- dest. write_str ( "\n " ) ?;
371- dest. write_str ( key) ?;
372- dest. write_str ( ": " ) ?;
373- // dest.write_str(val)?;
374- }
370+ // for (key, val) in self.declarations.iter() {
371+ // dest.write_str("\n ")?;
372+ // dest.write_str(key)?;
373+ // dest.write_str(": ")?;
374+ // // dest.write_str(val)?;
375+ // }
375376 dest. write_str ( "\n }" )
376377 }
377378}
@@ -424,7 +425,7 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser {
424425 type PreludeNoBlock = AtRulePrelude ;
425426 type PreludeBlock = AtRulePrelude ;
426427 type AtRule = CssRule ;
427- type Error = selectors :: parser :: SelectorParseErrorKind < ' i > ;
428+ type Error = ( ) ;
428429
429430 fn parse_prelude < ' t > (
430431 & mut self ,
@@ -648,33 +649,33 @@ pub enum Value {
648649 Url ( String )
649650}
650651
651- fn exhaust < ' i > ( input : & mut cssparser:: Parser < ' i , ' _ > ) -> Vec < Value > {
652+ // fn exhaust<'i>(input: &mut cssparser::Parser<'i, '_>) -> Vec<Value> {
652653 // let start = input.position();
653654 // while input.next().is_ok() {}
654655 // input.slice_from(start)
655- let mut val = vec ! [ ] ;
656- loop {
657- if let Ok ( tok) = input. next ( ) {
658- println ! ( "{:?}" , tok) ;
659- match tok {
660- Token :: UnquotedUrl ( ref url) => val. push ( Value :: Url ( ( & * * url) . into ( ) ) ) ,
661- Token :: Function ( ref name) if name. eq_ignore_ascii_case ( "url" ) => {
662- let url = input. parse_nested_block ( |input| {
663- input. expect_string ( ) . map_err ( Into :: into) . map ( |s| s. clone ( ) )
664- } )
665- . map_err ( ParseError :: < ( ) > :: basic) ;
666- if let Ok ( url) = url {
667- val. push ( Value :: Url ( ( & * url) . into ( ) ) ) ;
668- }
669- } ,
670- _ => { }
671- }
672- } else {
673- break
674- }
675- }
676- val
677- }
656+ // let mut val = vec![];
657+ // loop {
658+ // if let Ok(tok) = input.next() {
659+ // println!("{:?}", tok);
660+ // match tok {
661+ // Token::UnquotedUrl(ref url) => val.push(Value::Url((&**url).into())),
662+ // Token::Function(ref name) if name.eq_ignore_ascii_case("url") => {
663+ // let url = input.parse_nested_block(|input| {
664+ // input.expect_string().map_err(Into::into).map(|s| s.clone())
665+ // })
666+ // .map_err(ParseError::<()>::basic);
667+ // if let Ok(url) = url {
668+ // val.push(Value::Url((&*url).into()));
669+ // }
670+ // },
671+ // _ => {}
672+ // }
673+ // } else {
674+ // break
675+ // }
676+ // }
677+ // val
678+ // }
678679
679680struct SelectorParser ;
680681impl < ' i > selectors:: parser:: Parser < ' i > for SelectorParser {
@@ -685,7 +686,7 @@ impl<'i> selectors::parser::Parser<'i> for SelectorParser {
685686impl < ' a , ' b , ' i > QualifiedRuleParser < ' i > for NestedRuleParser {
686687 type Prelude = SelectorList < Selectors > ;
687688 type QualifiedRule = CssRule ;
688- type Error = selectors :: parser :: SelectorParseErrorKind < ' i > ;
689+ type Error = ( ) ;
689690
690691 fn parse_prelude < ' t > (
691692 & mut self ,
@@ -696,7 +697,10 @@ impl<'a, 'b, 'i> QualifiedRuleParser<'i> for NestedRuleParser {
696697 // namespaces: self.namespaces,
697698 // url_data: Some(self.context.url_data),
698699 } ;
699- SelectorList :: parse ( & selector_parser, input)
700+ match SelectorList :: parse ( & selector_parser, input) {
701+ Ok ( x) => Ok ( x) ,
702+ Err ( _) => Err ( input. new_error ( BasicParseErrorKind :: QualifiedRuleInvalid ) )
703+ }
700704 // Ok(exhaust(input))
701705 }
702706
@@ -727,22 +731,22 @@ struct PropertyDeclarationParser;
727731
728732/// Parse a declaration within {} block: `color: blue`
729733impl < ' i > cssparser:: DeclarationParser < ' i > for PropertyDeclarationParser {
730- type Declaration = ( String , Vec < Value > ) ;
731- type Error = selectors :: parser :: SelectorParseErrorKind < ' i > ;
734+ type Declaration = Property ;
735+ type Error = ( ) ;
732736
733737 fn parse_value < ' t > (
734738 & mut self ,
735739 name : CowRcStr < ' i > ,
736740 input : & mut cssparser:: Parser < ' i , ' t > ,
737741 ) -> Result < Self :: Declaration , cssparser:: ParseError < ' i , Self :: Error > > {
738- Ok ( ( name. as_ref ( ) . into ( ) , exhaust ( input) . into ( ) ) )
742+ Property :: parse ( name, input)
739743 }
740744}
741745
742746/// Default methods reject all at rules.
743747impl < ' i > AtRuleParser < ' i > for PropertyDeclarationParser {
744748 type PreludeNoBlock = ( ) ;
745749 type PreludeBlock = ( ) ;
746- type AtRule = ( String , Vec < Value > ) ;
747- type Error = selectors :: parser :: SelectorParseErrorKind < ' i > ;
750+ type AtRule = Property ;
751+ type Error = ( ) ;
748752}
0 commit comments