mirror of
https://github.com/servo/servo.git
synced 2025-08-16 10:55:34 +01:00
style: Fix indentation of multiple CssParserContext construction.
This commit is contained in:
parent
92e9f12bd0
commit
7a5a35f5e0
6 changed files with 132 additions and 103 deletions
|
@ -313,8 +313,11 @@ impl<'a, 'b, R: ParseErrorReporter> NestedRuleParser<'a, 'b, R> {
|
|||
input: &mut Parser,
|
||||
rule_type: CssRuleType
|
||||
) -> Arc<Locked<CssRules>> {
|
||||
let context =
|
||||
ParserContext::new_with_rule_type(self.context, rule_type, self.namespaces);
|
||||
let context = ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
rule_type,
|
||||
self.namespaces,
|
||||
);
|
||||
|
||||
let nested_parser = NestedRuleParser {
|
||||
stylesheet_origin: self.stylesheet_origin,
|
||||
|
@ -439,33 +442,32 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
|
|||
) -> Result<CssRule, ParseError<'i>> {
|
||||
match prelude {
|
||||
AtRuleBlockPrelude::FontFace(location) => {
|
||||
let context =
|
||||
ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::FontFace,
|
||||
self.namespaces,
|
||||
);
|
||||
let context = ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::FontFace,
|
||||
self.namespaces,
|
||||
);
|
||||
|
||||
Ok(CssRule::FontFace(Arc::new(self.shared_lock.wrap(
|
||||
parse_font_face_block(&context, self.error_context, input, location).into()))))
|
||||
}
|
||||
AtRuleBlockPrelude::FontFeatureValues(family_names, location) => {
|
||||
let context =
|
||||
ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::FontFeatureValues,
|
||||
self.namespaces,
|
||||
);
|
||||
let context = ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::FontFeatureValues,
|
||||
self.namespaces,
|
||||
);
|
||||
|
||||
Ok(CssRule::FontFeatureValues(Arc::new(self.shared_lock.wrap(
|
||||
FontFeatureValuesRule::parse(&context, self.error_context, input, family_names, location)))))
|
||||
}
|
||||
AtRuleBlockPrelude::CounterStyle(name) => {
|
||||
let context =
|
||||
ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::CounterStyle,
|
||||
self.namespaces,
|
||||
);
|
||||
let context = ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::CounterStyle,
|
||||
self.namespaces,
|
||||
);
|
||||
|
||||
Ok(CssRule::CounterStyle(Arc::new(self.shared_lock.wrap(
|
||||
parse_counter_style_body(name, &context, self.error_context, input)?.into()))))
|
||||
}
|
||||
|
@ -477,12 +479,12 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
|
|||
}))))
|
||||
}
|
||||
AtRuleBlockPrelude::Supports(cond, location) => {
|
||||
let eval_context =
|
||||
ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::Style,
|
||||
self.namespaces,
|
||||
);
|
||||
let eval_context = ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::Style,
|
||||
self.namespaces,
|
||||
);
|
||||
|
||||
let enabled = cond.eval(&eval_context);
|
||||
Ok(CssRule::Supports(Arc::new(self.shared_lock.wrap(SupportsRule {
|
||||
condition: cond,
|
||||
|
@ -492,22 +494,21 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
|
|||
}))))
|
||||
}
|
||||
AtRuleBlockPrelude::Viewport => {
|
||||
let context =
|
||||
ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::Viewport,
|
||||
self.namespaces,
|
||||
);
|
||||
let context = ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::Viewport,
|
||||
self.namespaces,
|
||||
);
|
||||
|
||||
Ok(CssRule::Viewport(Arc::new(self.shared_lock.wrap(
|
||||
ViewportRule::parse(&context, self.error_context, input)?))))
|
||||
}
|
||||
AtRuleBlockPrelude::Keyframes(name, prefix, location) => {
|
||||
let context =
|
||||
ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::Keyframes,
|
||||
self.namespaces,
|
||||
);
|
||||
let context = ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::Keyframes,
|
||||
self.namespaces,
|
||||
);
|
||||
|
||||
Ok(CssRule::Keyframes(Arc::new(self.shared_lock.wrap(KeyframesRule {
|
||||
name: name,
|
||||
|
@ -517,12 +518,12 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
|
|||
}))))
|
||||
}
|
||||
AtRuleBlockPrelude::Page(location) => {
|
||||
let context =
|
||||
ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::Page,
|
||||
self.namespaces,
|
||||
);
|
||||
let context = ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::Page,
|
||||
self.namespaces,
|
||||
);
|
||||
|
||||
let declarations = parse_property_declaration_list(&context, self.error_context, input);
|
||||
Ok(CssRule::Page(Arc::new(self.shared_lock.wrap(PageRule {
|
||||
block: Arc::new(self.shared_lock.wrap(declarations)),
|
||||
|
@ -573,12 +574,12 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for NestedRulePa
|
|||
prelude: QualifiedRuleParserPrelude,
|
||||
input: &mut Parser<'i, 't>
|
||||
) -> Result<CssRule, ParseError<'i>> {
|
||||
let context =
|
||||
ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::Style,
|
||||
self.namespaces,
|
||||
);
|
||||
let context = ParserContext::new_with_rule_type(
|
||||
self.context,
|
||||
CssRuleType::Style,
|
||||
self.namespaces,
|
||||
);
|
||||
|
||||
let declarations = parse_property_declaration_list(&context, self.error_context, input);
|
||||
Ok(CssRule::Style(Arc::new(self.shared_lock.wrap(StyleRule {
|
||||
selectors: prelude.selectors,
|
||||
|
|
|
@ -309,13 +309,16 @@ impl StylesheetInDocument for DocumentStyleSheet {
|
|||
|
||||
impl Stylesheet {
|
||||
/// Updates an empty stylesheet from a given string of text.
|
||||
pub fn update_from_str<R>(existing: &Stylesheet,
|
||||
css: &str,
|
||||
url_data: UrlExtraData,
|
||||
stylesheet_loader: Option<&StylesheetLoader>,
|
||||
error_reporter: &R,
|
||||
line_number_offset: u32)
|
||||
where R: ParseErrorReporter
|
||||
pub fn update_from_str<R>(
|
||||
existing: &Stylesheet,
|
||||
css: &str,
|
||||
url_data: UrlExtraData,
|
||||
stylesheet_loader: Option<&StylesheetLoader>,
|
||||
error_reporter: &R,
|
||||
line_number_offset: u32,
|
||||
)
|
||||
where
|
||||
R: ParseErrorReporter,
|
||||
{
|
||||
let namespaces = RwLock::new(Namespaces::default());
|
||||
let (rules, source_map_url, source_url) =
|
||||
|
@ -359,14 +362,14 @@ impl Stylesheet {
|
|||
let mut input = ParserInput::new_with_line_number_offset(css, line_number_offset);
|
||||
let mut input = Parser::new(&mut input);
|
||||
|
||||
let context =
|
||||
ParserContext::new(
|
||||
origin,
|
||||
url_data,
|
||||
None,
|
||||
ParsingMode::DEFAULT,
|
||||
quirks_mode
|
||||
);
|
||||
let context = ParserContext::new(
|
||||
origin,
|
||||
url_data,
|
||||
None,
|
||||
ParsingMode::DEFAULT,
|
||||
quirks_mode
|
||||
);
|
||||
|
||||
let error_context = ParserErrorContext { error_reporter };
|
||||
|
||||
let rule_parser = TopLevelRuleParser {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue