Struct style::stylesheets::TopLevelRuleParser
source · pub struct TopLevelRuleParser<'a, 'i> {
pub shared_lock: &'a SharedRwLock,
pub loader: Option<&'a dyn StylesheetLoader>,
pub context: ParserContext<'a>,
pub state: State,
pub dom_error: Option<RulesMutateError>,
pub insert_rule_context: Option<InsertRuleContext<'a>>,
pub allow_import_rules: AllowImportRules,
pub wants_first_declaration_block: bool,
pub first_declaration_block: PropertyDeclarationBlock,
pub declaration_parser_state: DeclarationParserState<'i>,
pub error_reporting_state: Vec<SelectorList<SelectorImpl>>,
pub rules: Vec<CssRule>,
}
Expand description
The parser for the top-level rules in a stylesheet.
Fields§
A reference to the lock we need to use to create rules.
loader: Option<&'a dyn StylesheetLoader>
A reference to a stylesheet loader if applicable, for @import
rules.
context: ParserContext<'a>
The top-level parser context.
state: State
The current state of the parser.
dom_error: Option<RulesMutateError>
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.
insert_rule_context: Option<InsertRuleContext<'a>>
The info we need insert a rule in a list.
allow_import_rules: AllowImportRules
Whether @import rules will be allowed.
wants_first_declaration_block: bool
Whether to keep declarations into first_declaration_block, rather than turning it into a nested declarations rule.
first_declaration_block: PropertyDeclarationBlock
The first declaration block, only relevant when wants_first_declaration_block is true.
declaration_parser_state: DeclarationParserState<'i>
Parser state for declaration blocks in either nested rules or style rules.
error_reporting_state: Vec<SelectorList<SelectorImpl>>
State we keep around only for error reporting purposes. Right now that contains just the selectors stack for nesting, if any.
TODO(emilio): This isn’t populated properly for insertRule()
but…
rules: Vec<CssRule>
The rules we’ve parsed so far.
Implementations§
source§impl<'a, 'i> TopLevelRuleParser<'a, 'i>
impl<'a, 'i> TopLevelRuleParser<'a, 'i>
fn nested(&mut self) -> &mut NestedRuleParser<'a, 'i>
sourcepub fn can_parse_declarations(&self) -> bool
pub fn can_parse_declarations(&self) -> bool
If we’re in a nested state, this returns whether declarations can be parsed. See RuleBodyItemParser::parse_declarations().
fn in_style_rule(&self) -> bool
fn in_page_rule(&self) -> bool
fn in_style_or_page_rule(&self) -> bool
sourcefn check_state(&mut self, new_state: State) -> bool
fn check_state(&mut self, new_state: State) -> bool
Checks whether we can parse a rule that would transition us to
new_state
.
This is usually a simple branch, but we may need more bookkeeping if
doing insertRule
from CSSOM.
Trait Implementations§
source§impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a, 'i>
impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a, 'i>
source§type Prelude = AtRulePrelude
type Prelude = AtRulePrelude
source§type AtRule = SourcePosition
type AtRule = SourcePosition
source§type Error = StyleParseErrorKind<'i>
type Error = StyleParseErrorKind<'i>
source§fn parse_prelude<'t>(
&mut self,
name: CowRcStr<'i>,
input: &mut Parser<'i, 't>,
) -> Result<AtRulePrelude, ParseError<'i>>
fn parse_prelude<'t>( &mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>, ) -> Result<AtRulePrelude, ParseError<'i>>
name
. Read moresource§fn parse_block<'t>(
&mut self,
prelude: AtRulePrelude,
start: &ParserState,
input: &mut Parser<'i, 't>,
) -> Result<Self::AtRule, ParseError<'i>>
fn parse_block<'t>( &mut self, prelude: AtRulePrelude, start: &ParserState, input: &mut Parser<'i, 't>, ) -> Result<Self::AtRule, ParseError<'i>>
{ /* ... */ }
block for the body of the at-rule. Read moresource§fn rule_without_block(
&mut self,
prelude: AtRulePrelude,
start: &ParserState,
) -> Result<Self::AtRule, ()>
fn rule_without_block( &mut self, prelude: AtRulePrelude, start: &ParserState, ) -> Result<Self::AtRule, ()>
source§impl<'a, 'i> QualifiedRuleParser<'i> for TopLevelRuleParser<'a, 'i>
impl<'a, 'i> QualifiedRuleParser<'i> for TopLevelRuleParser<'a, 'i>
source§type Prelude = SelectorList<SelectorImpl>
type Prelude = SelectorList<SelectorImpl>
source§type QualifiedRule = SourcePosition
type QualifiedRule = SourcePosition
source§type Error = StyleParseErrorKind<'i>
type Error = StyleParseErrorKind<'i>
source§fn parse_prelude<'t>(
&mut self,
input: &mut Parser<'i, 't>,
) -> Result<Self::Prelude, ParseError<'i>>
fn parse_prelude<'t>( &mut self, input: &mut Parser<'i, 't>, ) -> Result<Self::Prelude, ParseError<'i>>
source§fn parse_block<'t>(
&mut self,
prelude: Self::Prelude,
start: &ParserState,
input: &mut Parser<'i, 't>,
) -> Result<Self::QualifiedRule, ParseError<'i>>
fn parse_block<'t>( &mut self, prelude: Self::Prelude, start: &ParserState, input: &mut Parser<'i, 't>, ) -> Result<Self::QualifiedRule, ParseError<'i>>
{ /* ... */ }
block for the body of the qualified rule. Read moreAuto Trait Implementations§
impl<'a, 'i> Freeze for TopLevelRuleParser<'a, 'i>
impl<'a, 'i> !RefUnwindSafe for TopLevelRuleParser<'a, 'i>
impl<'a, 'i> !Send for TopLevelRuleParser<'a, 'i>
impl<'a, 'i> !Sync for TopLevelRuleParser<'a, 'i>
impl<'a, 'i> Unpin for TopLevelRuleParser<'a, 'i>
impl<'a, 'i> !UnwindSafe for TopLevelRuleParser<'a, 'i>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more