mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Simplify the namespace setup for stylesheet parsing.
This commit is contained in:
parent
26ef0f6178
commit
bbd85ccbda
3 changed files with 156 additions and 78 deletions
|
@ -7,7 +7,6 @@
|
|||
use context::QuirksMode;
|
||||
use cssparser::{Parser, SourcePosition, UnicodeRange};
|
||||
use error_reporting::ParseErrorReporter;
|
||||
use parking_lot::RwLock;
|
||||
use style_traits::OneOrMoreCommaSeparated;
|
||||
use stylesheets::{CssRuleType, Origin, UrlExtraData, Namespaces};
|
||||
|
||||
|
@ -82,8 +81,8 @@ pub struct ParserContext<'a> {
|
|||
pub parsing_mode: ParsingMode,
|
||||
/// The quirks mode of this stylesheet.
|
||||
pub quirks_mode: QuirksMode,
|
||||
/// The list of all namespaces active in the current stylesheet
|
||||
pub namespaces: Option<&'a RwLock<Namespaces>>,
|
||||
/// The currently active namespaces.
|
||||
pub namespaces: Option<&'a Namespaces>,
|
||||
}
|
||||
|
||||
impl<'a> ParserContext<'a> {
|
||||
|
@ -108,19 +107,21 @@ impl<'a> ParserContext<'a> {
|
|||
}
|
||||
|
||||
/// Create a parser context for on-the-fly parsing in CSSOM
|
||||
pub fn new_for_cssom(url_data: &'a UrlExtraData,
|
||||
error_reporter: &'a ParseErrorReporter,
|
||||
rule_type: Option<CssRuleType>,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode: QuirksMode)
|
||||
-> ParserContext<'a> {
|
||||
pub fn new_for_cssom(
|
||||
url_data: &'a UrlExtraData,
|
||||
error_reporter: &'a ParseErrorReporter,
|
||||
rule_type: Option<CssRuleType>,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode: QuirksMode
|
||||
) -> ParserContext<'a> {
|
||||
Self::new(Origin::Author, url_data, error_reporter, rule_type, parsing_mode, quirks_mode)
|
||||
}
|
||||
|
||||
/// Create a parser context based on a previous context, but with a modified rule type.
|
||||
pub fn new_with_rule_type(context: &'a ParserContext,
|
||||
rule_type: Option<CssRuleType>)
|
||||
-> ParserContext<'a> {
|
||||
pub fn new_with_rule_type(
|
||||
context: &'a ParserContext,
|
||||
rule_type: Option<CssRuleType>
|
||||
) -> ParserContext<'a> {
|
||||
ParserContext {
|
||||
stylesheet_origin: context.stylesheet_origin,
|
||||
url_data: context.url_data,
|
||||
|
@ -134,13 +135,14 @@ impl<'a> ParserContext<'a> {
|
|||
}
|
||||
|
||||
/// Create a parser context for inline CSS which accepts additional line offset argument.
|
||||
pub fn new_with_line_number_offset(stylesheet_origin: Origin,
|
||||
url_data: &'a UrlExtraData,
|
||||
error_reporter: &'a ParseErrorReporter,
|
||||
line_number_offset: u64,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode: QuirksMode)
|
||||
-> ParserContext<'a> {
|
||||
pub fn new_with_line_number_offset(
|
||||
stylesheet_origin: Origin,
|
||||
url_data: &'a UrlExtraData,
|
||||
error_reporter: &'a ParseErrorReporter,
|
||||
line_number_offset: u64,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode: QuirksMode
|
||||
) -> ParserContext<'a> {
|
||||
ParserContext {
|
||||
stylesheet_origin: stylesheet_origin,
|
||||
url_data: url_data,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue