mirror of
https://github.com/servo/servo.git
synced 2025-08-12 17:05:33 +01:00
Format remaining files
This commit is contained in:
parent
bf47f90da6
commit
cb07debcb6
252 changed files with 5944 additions and 3744 deletions
|
@ -172,9 +172,7 @@ impl SupportsCondition {
|
|||
}
|
||||
|
||||
/// <https://drafts.csswg.org/css-conditional-3/#supports_condition_in_parens>
|
||||
fn parse_in_parens<'i, 't>(
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
fn parse_in_parens<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
// Whitespace is normally taken care of in `Parser::next`,
|
||||
// but we want to not include it in `pos` for the SupportsCondition::FutureSyntax cases.
|
||||
while input.try(Parser::expect_whitespace).is_ok() {}
|
||||
|
@ -183,9 +181,8 @@ impl SupportsCondition {
|
|||
// FIXME: remove clone() when lifetimes are non-lexical
|
||||
match input.next()?.clone() {
|
||||
Token::ParenthesisBlock => {
|
||||
let nested = input.try(|input| {
|
||||
input.parse_nested_block(parse_condition_or_declaration)
|
||||
});
|
||||
let nested =
|
||||
input.try(|input| input.parse_nested_block(parse_condition_or_declaration));
|
||||
if nested.is_ok() {
|
||||
return nested;
|
||||
}
|
||||
|
@ -209,11 +206,7 @@ impl SupportsCondition {
|
|||
}
|
||||
|
||||
/// Evaluate a supports condition
|
||||
pub fn eval(
|
||||
&self,
|
||||
cx: &ParserContext,
|
||||
namespaces: &Namespaces,
|
||||
) -> bool {
|
||||
pub fn eval(&self, cx: &ParserContext, namespaces: &Namespaces) -> bool {
|
||||
match *self {
|
||||
SupportsCondition::Not(ref cond) => !cond.eval(cx, namespaces),
|
||||
SupportsCondition::Parenthesized(ref cond) => cond.eval(cx, namespaces),
|
||||
|
@ -300,7 +293,7 @@ impl ToCss for SupportsCondition {
|
|||
dest.write_str("selector(")?;
|
||||
selector.to_css(dest)?;
|
||||
dest.write_str(")")
|
||||
}
|
||||
},
|
||||
SupportsCondition::MozBoolPref(ref name) => {
|
||||
dest.write_str("-moz-bool-pref(")?;
|
||||
let name =
|
||||
|
@ -328,51 +321,51 @@ impl ToCss for RawSelector {
|
|||
|
||||
impl RawSelector {
|
||||
/// Tries to evaluate a `selector()` function.
|
||||
pub fn eval(
|
||||
&self,
|
||||
context: &ParserContext,
|
||||
namespaces: &Namespaces,
|
||||
) -> bool {
|
||||
pub fn eval(&self, context: &ParserContext, namespaces: &Namespaces) -> bool {
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
if unsafe { !::gecko_bindings::structs::StaticPrefs_sVarCache_layout_css_supports_selector_enabled } {
|
||||
if unsafe {
|
||||
!::gecko_bindings::structs::StaticPrefs_sVarCache_layout_css_supports_selector_enabled
|
||||
} {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
let mut input = ParserInput::new(&self.0);
|
||||
let mut input = Parser::new(&mut input);
|
||||
input.parse_entirely(|input| -> Result<(), CssParseError<()>> {
|
||||
let parser = SelectorParser {
|
||||
namespaces,
|
||||
stylesheet_origin: context.stylesheet_origin,
|
||||
url_data: Some(context.url_data),
|
||||
};
|
||||
input
|
||||
.parse_entirely(|input| -> Result<(), CssParseError<()>> {
|
||||
let parser = SelectorParser {
|
||||
namespaces,
|
||||
stylesheet_origin: context.stylesheet_origin,
|
||||
url_data: Some(context.url_data),
|
||||
};
|
||||
|
||||
#[allow(unused_variables)]
|
||||
let selector = Selector::<SelectorImpl>::parse(&parser, input)
|
||||
.map_err(|_| input.new_custom_error(()))?;
|
||||
#[allow(unused_variables)]
|
||||
let selector = Selector::<SelectorImpl>::parse(&parser, input)
|
||||
.map_err(|_| input.new_custom_error(()))?;
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
use selector_parser::PseudoElement;
|
||||
use selectors::parser::Component;
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
use selector_parser::PseudoElement;
|
||||
use selectors::parser::Component;
|
||||
|
||||
let has_any_unknown_webkit_pseudo =
|
||||
selector.has_pseudo_element() &&
|
||||
selector.iter_raw_match_order().any(|component| {
|
||||
matches!(
|
||||
*component,
|
||||
Component::PseudoElement(PseudoElement::UnknownWebkit(..))
|
||||
)
|
||||
});
|
||||
if has_any_unknown_webkit_pseudo {
|
||||
return Err(input.new_custom_error(()));
|
||||
let has_any_unknown_webkit_pseudo = selector.has_pseudo_element() && selector
|
||||
.iter_raw_match_order()
|
||||
.any(|component| {
|
||||
matches!(
|
||||
*component,
|
||||
Component::PseudoElement(PseudoElement::UnknownWebkit(..))
|
||||
)
|
||||
});
|
||||
if has_any_unknown_webkit_pseudo {
|
||||
return Err(input.new_custom_error(()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}).is_ok()
|
||||
Ok(())
|
||||
})
|
||||
.is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,20 +405,22 @@ impl Declaration {
|
|||
|
||||
let mut input = ParserInput::new(&self.0);
|
||||
let mut input = Parser::new(&mut input);
|
||||
input.parse_entirely(|input| -> Result<(), CssParseError<()>> {
|
||||
let prop = input.expect_ident_cloned().unwrap();
|
||||
input.expect_colon().unwrap();
|
||||
input
|
||||
.parse_entirely(|input| -> Result<(), CssParseError<()>> {
|
||||
let prop = input.expect_ident_cloned().unwrap();
|
||||
input.expect_colon().unwrap();
|
||||
|
||||
let id =
|
||||
PropertyId::parse(&prop, context).map_err(|_| input.new_custom_error(()))?;
|
||||
let id =
|
||||
PropertyId::parse(&prop, context).map_err(|_| input.new_custom_error(()))?;
|
||||
|
||||
let mut declarations = SourcePropertyDeclaration::new();
|
||||
input.parse_until_before(Delimiter::Bang, |input| {
|
||||
PropertyDeclaration::parse_into(&mut declarations, id, &context, input)
|
||||
.map_err(|_| input.new_custom_error(()))
|
||||
})?;
|
||||
let _ = input.try(parse_important);
|
||||
Ok(())
|
||||
}).is_ok()
|
||||
let mut declarations = SourcePropertyDeclaration::new();
|
||||
input.parse_until_before(Delimiter::Bang, |input| {
|
||||
PropertyDeclaration::parse_into(&mut declarations, id, &context, input)
|
||||
.map_err(|_| input.new_custom_error(()))
|
||||
})?;
|
||||
let _ = input.try(parse_important);
|
||||
Ok(())
|
||||
})
|
||||
.is_ok()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue