Struct style::stylesheets::TopLevelRuleParser
[−]
[src]
pub struct TopLevelRuleParser<'a, R: 'a> { pub stylesheet_origin: Origin, pub shared_lock: &'a SharedRwLock, pub loader: Option<&'a StylesheetLoader>, pub context: ParserContext<'a>, pub error_context: ParserErrorContext<'a, R>, pub state: State, pub had_hierarchy_error: bool, pub namespaces: &'a mut Namespaces, }
The parser for the top-level rules in a stylesheet.
Fields
stylesheet_origin: Origin
The origin of the stylesheet we're parsing.
A reference to the lock we need to use to create rules.
loader: Option<&'a StylesheetLoader>
A reference to a stylesheet loader if applicable, for @import
rules.
context: ParserContext<'a>
The top-level parser context.
This won't contain any namespaces, and only nested parsers created with
ParserContext::new_with_rule_type
will.
error_context: ParserErrorContext<'a, R>
The context required for reporting parse errors.
state: State
The current state of the parser.
had_hierarchy_error: bool
Whether we have tried to parse was invalid due to being in the wrong
place (e.g. an @import rule was found while in the Body
state). Reset
to false
when take_had_hierarchy_error
is called.
namespaces: &'a mut Namespaces
The namespace map we use for parsing. Needs to start as Some()
, and
will be taken out after parsing namespace rules, and that reference will
be moved to ParserContext
.
Methods
impl<'b, R> TopLevelRuleParser<'b, R>
[src]
pub fn state(&self) -> State
[src]
Returns the current state of the parser.
pub fn take_had_hierarchy_error(&mut self) -> bool
[src]
Returns whether we previously tried to parse a rule that was invalid due to being in the wrong place (e.g. an @import rule was found after a regular style rule). The state of this flag is reset when this function is called.
Trait Implementations
impl<'a, 'i, R: ParseErrorReporter> AtRuleParser<'i> for TopLevelRuleParser<'a, R>
[src]
type PreludeNoBlock = AtRuleNonBlockPrelude
The intermediate representation of prelude of an at-rule without block;
type PreludeBlock = AtRuleBlockPrelude
The intermediate representation of prelude of an at-rule with block;
type AtRule = CssRule
The finished representation of an at-rule.
type Error = StyleParseErrorKind<'i>
The error type that is included in the ParseError value that can be returned.
fn parse_prelude<'t>(
&mut self,
name: CowRcStr<'i>,
input: &mut Parser<'i, 't>
) -> Result<AtRuleType<AtRuleNonBlockPrelude, AtRuleBlockPrelude>, ParseError<'i>>
[src]
&mut self,
name: CowRcStr<'i>,
input: &mut Parser<'i, 't>
) -> Result<AtRuleType<AtRuleNonBlockPrelude, AtRuleBlockPrelude>, ParseError<'i>>
Parse the prelude of an at-rule with the given name
. Read more
fn parse_block<'t>(
&mut self,
prelude: AtRuleBlockPrelude,
input: &mut Parser<'i, 't>
) -> Result<CssRule, ParseError<'i>>
[src]
&mut self,
prelude: AtRuleBlockPrelude,
input: &mut Parser<'i, 't>
) -> Result<CssRule, ParseError<'i>>
Parse the content of a { /* ... */ }
block for the body of the at-rule. Read more
fn rule_without_block(&mut self, prelude: AtRuleNonBlockPrelude) -> CssRule
[src]
End an at-rule which doesn't have block. Return the finished representation of the at-rule. Read more
impl<'a, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for TopLevelRuleParser<'a, R>
[src]
type Prelude = QualifiedRuleParserPrelude
The intermediate representation of a qualified rule prelude.
type QualifiedRule = CssRule
The finished representation of a qualified rule.
type Error = StyleParseErrorKind<'i>
The error type that is included in the ParseError value that can be returned.
fn parse_prelude<'t>(
&mut self,
input: &mut Parser<'i, 't>
) -> Result<QualifiedRuleParserPrelude, ParseError<'i>>
[src]
&mut self,
input: &mut Parser<'i, 't>
) -> Result<QualifiedRuleParserPrelude, ParseError<'i>>
Parse the prelude of a qualified rule. For style rules, this is as Selector list. Read more
fn parse_block<'t>(
&mut self,
prelude: QualifiedRuleParserPrelude,
input: &mut Parser<'i, 't>
) -> Result<CssRule, ParseError<'i>>
[src]
&mut self,
prelude: QualifiedRuleParserPrelude,
input: &mut Parser<'i, 't>
) -> Result<CssRule, ParseError<'i>>
Parse the content of a { /* ... */ }
block for the body of the qualified rule. Read more