mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Run rustfmt on selectors, servo_arc, and style.
This was generated with: ./mach cargo fmt --package selectors && ./mach cargo fmt --package servo_arc && ./mach cargo fmt --package style Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
This commit is contained in:
parent
f7ae1a37e3
commit
c99bcdd4b8
181 changed files with 9981 additions and 7933 deletions
|
@ -5,7 +5,7 @@
|
|||
//! Specified time values.
|
||||
|
||||
use cssparser::{Parser, Token};
|
||||
use parser::{ParserContext, Parse};
|
||||
use parser::{Parse, ParserContext};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use style_traits::values::specified::AllowedNumericType;
|
||||
|
@ -34,7 +34,11 @@ pub enum TimeUnit {
|
|||
impl Time {
|
||||
/// Returns a time value that represents `seconds` seconds.
|
||||
pub fn from_seconds(seconds: CSSFloat) -> Self {
|
||||
Time { seconds, unit: TimeUnit::Second, was_calc: false }
|
||||
Time {
|
||||
seconds,
|
||||
unit: TimeUnit::Second,
|
||||
was_calc: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `0s`.
|
||||
|
@ -48,18 +52,18 @@ impl Time {
|
|||
}
|
||||
|
||||
/// Parses a time according to CSS-VALUES § 6.2.
|
||||
pub fn parse_dimension(
|
||||
value: CSSFloat,
|
||||
unit: &str,
|
||||
was_calc: bool
|
||||
) -> Result<Time, ()> {
|
||||
pub fn parse_dimension(value: CSSFloat, unit: &str, was_calc: bool) -> Result<Time, ()> {
|
||||
let (seconds, unit) = match_ignore_ascii_case! { unit,
|
||||
"s" => (value, TimeUnit::Second),
|
||||
"ms" => (value / 1000.0, TimeUnit::Millisecond),
|
||||
_ => return Err(())
|
||||
};
|
||||
|
||||
Ok(Time { seconds, unit, was_calc })
|
||||
Ok(Time {
|
||||
seconds,
|
||||
unit,
|
||||
was_calc,
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns a `Time` value from a CSS `calc()` expression.
|
||||
|
@ -74,7 +78,7 @@ impl Time {
|
|||
fn parse_with_clamping_mode<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
clamping_mode: AllowedNumericType
|
||||
clamping_mode: AllowedNumericType,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
use style_traits::ParsingMode;
|
||||
|
||||
|
@ -86,13 +90,16 @@ impl Time {
|
|||
// values for SMIL regardless of clamping_mode, but in this Time
|
||||
// value case, the value does not animate for SMIL at all, so we use
|
||||
// ParsingMode::DEFAULT directly.
|
||||
Ok(&Token::Dimension { value, ref unit, .. }) if clamping_mode.is_ok(ParsingMode::DEFAULT, value) => {
|
||||
Ok(&Token::Dimension {
|
||||
value, ref unit, ..
|
||||
}) if clamping_mode.is_ok(ParsingMode::DEFAULT, value) =>
|
||||
{
|
||||
return Time::parse_dimension(value, unit, /* from_calc = */ false)
|
||||
.map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
.map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
Ok(&Token::Function(ref name)) if name.eq_ignore_ascii_case("calc") => {}
|
||||
Ok(&Token::Function(ref name)) if name.eq_ignore_ascii_case("calc") => {},
|
||||
Ok(t) => return Err(location.new_unexpected_token_error(t.clone())),
|
||||
Err(e) => return Err(e.into())
|
||||
Err(e) => return Err(e.into()),
|
||||
}
|
||||
match input.parse_nested_block(|i| CalcNode::parse_time(context, i)) {
|
||||
Ok(time) if clamping_mode.is_ok(ParsingMode::DEFAULT, time.seconds) => Ok(time),
|
||||
|
@ -103,7 +110,7 @@ impl Time {
|
|||
/// Parses a non-negative time value.
|
||||
pub fn parse_non_negative<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Self::parse_with_clamping_mode(context, input, AllowedNumericType::NonNegative)
|
||||
}
|
||||
|
@ -126,7 +133,10 @@ impl ToComputedValue for Time {
|
|||
}
|
||||
|
||||
impl Parse for Time {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Self::parse_with_clamping_mode(context, input, AllowedNumericType::All)
|
||||
}
|
||||
}
|
||||
|
@ -143,11 +153,11 @@ impl ToCss for Time {
|
|||
TimeUnit::Second => {
|
||||
self.seconds.to_css(dest)?;
|
||||
dest.write_str("s")?;
|
||||
}
|
||||
},
|
||||
TimeUnit::Millisecond => {
|
||||
(self.seconds * 1000.).to_css(dest)?;
|
||||
dest.write_str("ms")?;
|
||||
}
|
||||
},
|
||||
}
|
||||
if self.was_calc {
|
||||
dest.write_str(")")?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue