pub struct ParserContext<'a> {
    pub stylesheet_origin: Origin,
    pub url_data: &'a UrlExtraData,
    pub parsing_mode: ParsingMode,
    pub quirks_mode: QuirksMode,
    pub namespaces: Cow<'a, Namespaces>,
    pub use_counters: Option<&'a UseCounters>,
    pub nesting_context: NestingContext,
    /* private fields */
}Expand description
The data that the parser needs from outside in order to parse a stylesheet.
Fields§
§stylesheet_origin: OriginThe Origin of the stylesheet, whether it’s a user, author or
user-agent stylesheet.
url_data: &'a UrlExtraDataThe extra data we need for resolving url values.
parsing_mode: ParsingModeThe mode to use when parsing.
quirks_mode: QuirksModeThe quirks mode of this stylesheet.
namespaces: Cow<'a, Namespaces>The currently active namespaces.
use_counters: Option<&'a UseCounters>The use counters we want to record while parsing style rules, if any.
nesting_context: NestingContextCurrent nesting context.
Implementations§
Source§impl<'a> ParserContext<'a>
 
impl<'a> ParserContext<'a>
Sourcepub fn new(
    stylesheet_origin: Origin,
    url_data: &'a UrlExtraData,
    rule_type: Option<CssRuleType>,
    parsing_mode: ParsingMode,
    quirks_mode: QuirksMode,
    namespaces: Cow<'a, Namespaces>,
    error_reporter: Option<&'a dyn ParseErrorReporter>,
    use_counters: Option<&'a UseCounters>,
) -> Self
 
pub fn new( stylesheet_origin: Origin, url_data: &'a UrlExtraData, rule_type: Option<CssRuleType>, parsing_mode: ParsingMode, quirks_mode: QuirksMode, namespaces: Cow<'a, Namespaces>, error_reporter: Option<&'a dyn ParseErrorReporter>, use_counters: Option<&'a UseCounters>, ) -> Self
Create a parser context.
Sourcepub fn nest_for_rule<R>(
    &mut self,
    rule_type: CssRuleType,
    cb: impl FnOnce(&mut Self) -> R,
) -> R
 
pub fn nest_for_rule<R>( &mut self, rule_type: CssRuleType, cb: impl FnOnce(&mut Self) -> R, ) -> R
Temporarily sets the rule_type and executes the callback function, returning its result.
Sourcepub fn in_page_rule(&self) -> bool
 
pub fn in_page_rule(&self) -> bool
Whether we’re in a @page rule.
Sourcepub fn allows_important_declarations(&self) -> bool
 
pub fn allows_important_declarations(&self) -> bool
Returns whether !important declarations are forbidden.
Sourcepub fn rule_types(&self) -> CssRuleTypes
 
pub fn rule_types(&self) -> CssRuleTypes
Get the rule type, which assumes that one is available.
Sourcepub fn error_reporting_enabled(&self) -> bool
 
pub fn error_reporting_enabled(&self) -> bool
Returns whether CSS error reporting is enabled.
Sourcepub fn log_css_error(
    &self,
    location: SourceLocation,
    error: ContextualParseError<'_>,
)
 
pub fn log_css_error( &self, location: SourceLocation, error: ContextualParseError<'_>, )
Record a CSS parse error with this context’s error reporting.
Sourcepub fn in_ua_sheet(&self) -> bool
 
pub fn in_ua_sheet(&self) -> bool
Whether we’re in a user-agent stylesheet.
Sourcepub fn chrome_rules_enabled(&self) -> bool
 
pub fn chrome_rules_enabled(&self) -> bool
Returns whether chrome-only rules should be parsed.
Sourcepub fn allows_computational_dependence(&self) -> bool
 
pub fn allows_computational_dependence(&self) -> bool
Whether the parsing mode allows units or functions that are not computationally independent.
Auto Trait Implementations§
impl<'a> Freeze for ParserContext<'a>
impl<'a> !RefUnwindSafe for ParserContext<'a>
impl<'a> !Send for ParserContext<'a>
impl<'a> !Sync for ParserContext<'a>
impl<'a> Unpin for ParserContext<'a>
impl<'a> !UnwindSafe for ParserContext<'a>
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