Struct style::parser::ParserContext
source · pub struct ParserContext<'a> {
pub stylesheet_origin: Origin,
pub url_data: &'a UrlExtraData,
pub parsing_mode: ParsingMode,
pub quirks_mode: QuirksMode,
error_reporter: Option<&'a dyn ParseErrorReporter>,
pub namespaces: Cow<'a, Namespaces>,
pub use_counters: Option<&'a UseCounters>,
pub nesting_context: NestingContext,
}
Expand description
The data that the parser needs from outside in order to parse a stylesheet.
Fields§
§stylesheet_origin: Origin
The Origin
of the stylesheet, whether it’s a user, author or
user-agent stylesheet.
url_data: &'a UrlExtraData
The extra data we need for resolving url values.
parsing_mode: ParsingMode
The mode to use when parsing.
quirks_mode: QuirksMode
The quirks mode of this stylesheet.
error_reporter: Option<&'a dyn ParseErrorReporter>
The active error reporter, or none if error reporting is disabled.
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: NestingContext
Current 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.
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