mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Run "cargo +nightly fmt" for style components in servo
The directories changed: * servo/components/selectors/ * servo/components/style/ * servo/components/style_derive/ * servo/ports/geckolib/ Per review request, disable rustfmt in `components_to_transform_3d_matrix()` to preserve the format for a call to `Transform3D::new`. My mozilla-central is at https://hg.mozilla.org/mozilla-central/rev/d1ae84015c22f2034435b47194fdced878072035 My nightly rust is 1.66.0-nightly (8b705839c 2022-09-26). Differential Revision: https://phabricator.services.mozilla.com/D158234
This commit is contained in:
parent
1a9198a5ef
commit
3da52edffc
60 changed files with 684 additions and 489 deletions
|
@ -7,7 +7,7 @@
|
|||
//! https://drafts.csswg.org/mediaqueries-4/#typedef-media-condition
|
||||
//! https://drafts.csswg.org/css-contain-3/#typedef-container-condition
|
||||
|
||||
use super::{QueryFeatureExpression, FeatureType, FeatureFlags};
|
||||
use super::{FeatureFlags, FeatureType, QueryFeatureExpression};
|
||||
use crate::parser::ParserContext;
|
||||
use crate::values::computed;
|
||||
use cssparser::{Parser, Token};
|
||||
|
@ -197,7 +197,8 @@ impl QueryCondition {
|
|||
if let Ok(inner) = input.try_parse(|i| Self::parse(context, i, feature_type)) {
|
||||
return Ok(QueryCondition::InParens(Box::new(inner)));
|
||||
}
|
||||
let expr = QueryFeatureExpression::parse_in_parenthesis_block(context, input, feature_type)?;
|
||||
let expr =
|
||||
QueryFeatureExpression::parse_in_parenthesis_block(context, input, feature_type)?;
|
||||
Ok(QueryCondition::Feature(expr))
|
||||
})
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! Query features.
|
||||
|
||||
use crate::parser::ParserContext;
|
||||
use crate::values::computed::{self, CSSPixelLength, Resolution, Ratio};
|
||||
use crate::values::computed::{self, CSSPixelLength, Ratio, Resolution};
|
||||
use crate::Atom;
|
||||
use cssparser::Parser;
|
||||
use std::fmt;
|
||||
|
@ -66,10 +66,8 @@ macro_rules! keyword_evaluator {
|
|||
fn __parse<'i, 't>(
|
||||
context: &$crate::parser::ParserContext,
|
||||
input: &mut $crate::cssparser::Parser<'i, 't>,
|
||||
) -> Result<
|
||||
$crate::queries::feature::KeywordDiscriminant,
|
||||
::style_traits::ParseError<'i>,
|
||||
> {
|
||||
) -> Result<$crate::queries::feature::KeywordDiscriminant, ::style_traits::ParseError<'i>>
|
||||
{
|
||||
let kw = <$keyword_type as $crate::parser::Parse>::parse(context, input)?;
|
||||
Ok(kw as $crate::queries::feature::KeywordDiscriminant)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//! `(width >= 400px)`.
|
||||
|
||||
use super::feature::{Evaluator, QueryFeatureDescription};
|
||||
use super::feature::{KeywordDiscriminant, FeatureFlags};
|
||||
use super::feature::{FeatureFlags, KeywordDiscriminant};
|
||||
use crate::parser::{Parse, ParserContext};
|
||||
use crate::str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase};
|
||||
use crate::values::computed::{self, Ratio, ToComputedValue};
|
||||
|
@ -43,7 +43,10 @@ impl FeatureType {
|
|||
}
|
||||
|
||||
fn find_feature(&self, name: &Atom) -> Option<(usize, &'static QueryFeatureDescription)> {
|
||||
self.features().iter().enumerate().find(|(_, f)| f.name == *name)
|
||||
self.features()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|(_, f)| f.name == *name)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,8 +95,12 @@ impl Operator {
|
|||
// context.
|
||||
match self {
|
||||
Self::Equal => false,
|
||||
Self::GreaterThan | Self::GreaterThanEqual => matches!(right_op, Self::GreaterThan | Self::GreaterThanEqual),
|
||||
Self::LessThan | Self::LessThanEqual => matches!(right_op, Self::LessThan | Self::LessThanEqual),
|
||||
Self::GreaterThan | Self::GreaterThanEqual => {
|
||||
matches!(right_op, Self::GreaterThan | Self::GreaterThanEqual)
|
||||
},
|
||||
Self::LessThan | Self::LessThanEqual => {
|
||||
matches!(right_op, Self::LessThan | Self::LessThanEqual)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,9 +485,7 @@ impl QueryFeatureExpression {
|
|||
let right = match right_op {
|
||||
Some(op) => {
|
||||
if !left_op.is_compatible_with(op) {
|
||||
return Err(
|
||||
input.new_custom_error(StyleParseErrorKind::UnspecifiedError)
|
||||
);
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
Some((op, QueryExpressionValue::parse(feature, context, input)?))
|
||||
},
|
||||
|
@ -583,9 +588,8 @@ impl QueryFeatureExpression {
|
|||
match self.feature().evaluator {
|
||||
Evaluator::Length(eval) => {
|
||||
let v = eval(context);
|
||||
self.kind.evaluate(v, |v| {
|
||||
expect!(Length, v).to_computed_value(context)
|
||||
})
|
||||
self.kind
|
||||
.evaluate(v, |v| expect!(Length, v).to_computed_value(context))
|
||||
},
|
||||
Evaluator::Integer(eval) => {
|
||||
let v = eval(context);
|
||||
|
@ -594,14 +598,15 @@ impl QueryFeatureExpression {
|
|||
Evaluator::Float(eval) => {
|
||||
let v = eval(context);
|
||||
self.kind.evaluate(v, |v| *expect!(Float, v))
|
||||
}
|
||||
},
|
||||
Evaluator::NumberRatio(eval) => {
|
||||
let ratio = eval(context);
|
||||
// A ratio of 0/0 behaves as the ratio 1/0, so we need to call used_value()
|
||||
// to convert it if necessary.
|
||||
// FIXME: we may need to update here once
|
||||
// https://github.com/w3c/csswg-drafts/issues/4954 got resolved.
|
||||
self.kind.evaluate(ratio, |v| expect!(NumberRatio, v).used_value())
|
||||
self.kind
|
||||
.evaluate(ratio, |v| expect!(NumberRatio, v).used_value())
|
||||
},
|
||||
Evaluator::Resolution(eval) => {
|
||||
let v = eval(context).dppx();
|
||||
|
@ -610,11 +615,17 @@ impl QueryFeatureExpression {
|
|||
})
|
||||
},
|
||||
Evaluator::Enumerated { evaluator, .. } => {
|
||||
let computed = self.kind.non_ranged_value().map(|v| *expect!(Enumerated, v));
|
||||
let computed = self
|
||||
.kind
|
||||
.non_ranged_value()
|
||||
.map(|v| *expect!(Enumerated, v));
|
||||
evaluator(context, computed)
|
||||
},
|
||||
Evaluator::BoolInteger(eval) => {
|
||||
let computed = self.kind.non_ranged_value().map(|v| *expect!(BoolInteger, v));
|
||||
let computed = self
|
||||
.kind
|
||||
.non_ranged_value()
|
||||
.map(|v| *expect!(BoolInteger, v));
|
||||
let boolean = eval(context);
|
||||
computed.map_or(boolean, |v| v == boolean)
|
||||
},
|
||||
|
|
|
@ -16,4 +16,4 @@ pub mod values;
|
|||
|
||||
pub use self::condition::QueryCondition;
|
||||
pub use self::feature::FeatureFlags;
|
||||
pub use self::feature_expression::{QueryFeatureExpression, FeatureType};
|
||||
pub use self::feature_expression::{FeatureType, QueryFeatureExpression};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue