@@ -9,6 +9,7 @@ use std::fmt::Write;
99use crate :: selector:: { Selectors , SelectorParser } ;
1010use crate :: rules:: keyframes:: { KeyframeListParser , KeyframesRule } ;
1111use crate :: rules:: font_face:: { FontFaceRule , FontFaceDeclarationParser } ;
12+ use crate :: rules:: page:: { PageSelector , PageRule } ;
1213use crate :: declaration:: { Declaration , DeclarationHandler } ;
1314
1415#[ derive( Eq , PartialEq , Clone ) ]
@@ -97,7 +98,7 @@ pub enum AtRulePrelude {
9798 /// A @keyframes rule, with its animation name and vendor prefix if exists.
9899 Keyframes ( String ) , //(KeyframesName, Option<VendorPrefix>),
99100 /// A @page rule prelude.
100- Page ,
101+ Page ( Vec < PageSelector > ) ,
101102 /// A @document rule, with its conditional.
102103 Document , //(DocumentCondition),
103104 /// A @import rule prelude.
@@ -381,7 +382,8 @@ pub enum CssRule {
381382 Import ( ImportRule ) ,
382383 Style ( StyleRule ) ,
383384 Keyframes ( KeyframesRule ) ,
384- FontFace ( FontFaceRule )
385+ FontFace ( FontFaceRule ) ,
386+ Page ( PageRule )
385387}
386388
387389impl ToCss for CssRule {
@@ -392,6 +394,7 @@ impl ToCss for CssRule {
392394 CssRule :: Style ( style) => style. to_css ( dest) ,
393395 CssRule :: Keyframes ( keyframes) => keyframes. to_css ( dest) ,
394396 CssRule :: FontFace ( font_face) => font_face. to_css ( dest) ,
397+ CssRule :: Page ( font_face) => font_face. to_css ( dest) ,
395398 }
396399 }
397400}
@@ -491,13 +494,10 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser {
491494
492495 Ok ( AtRuleType :: WithBlock ( AtRulePrelude :: Keyframes ( name. into( ) ) ) )
493496 } ,
494- // "page" => {
495- // if cfg!(feature = "gecko") {
496- // Ok(AtRuleType::WithBlock(AtRuleBlockPrelude::Page))
497- // } else {
498- // Err(input.new_custom_error(StyleParseErrorKind::UnsupportedAtRule(name.clone())))
499- // }
500- // },
497+ "page" => {
498+ let selectors = input. try_parse( |input| input. parse_comma_separated( PageSelector :: parse) ) . unwrap_or_default( ) ;
499+ Ok ( AtRuleType :: WithBlock ( AtRulePrelude :: Page ( selectors) ) )
500+ } ,
501501 // "-moz-document" => {
502502 // if !cfg!(feature = "gecko") {
503503 // return Err(input.new_custom_error(
@@ -616,19 +616,16 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser {
616616 // source_location: start.source_location(),
617617 } ) )
618618 } ,
619- // AtRuleBlockPrelude::Page => {
620- // let context = ParserContext::new_with_rule_type(
621- // self.context,
622- // CssRuleType::Page,
623- // self.namespaces,
624- // );
625-
626- // let declarations = parse_property_declaration_list(&context, input, None);
627- // Ok(CssRule::Page(Arc::new(self.shared_lock.wrap(PageRule {
628- // block: Arc::new(self.shared_lock.wrap(declarations)),
629- // source_location: start.source_location(),
630- // }))))
631- // },
619+ AtRulePrelude :: Page ( selectors) => {
620+ let parser = DeclarationListParser :: new ( input, PropertyDeclarationParser ) ;
621+ let declarations: Vec < _ > = parser. flatten ( ) . collect ( ) ;
622+ Ok ( CssRule :: Page ( PageRule {
623+ selectors,
624+ declarations : DeclarationBlock {
625+ declarations
626+ }
627+ } ) )
628+ } ,
632629 // AtRuleBlockPrelude::Document(condition) => {
633630 // if !cfg!(feature = "gecko") {
634631 // unreachable!()
0 commit comments