mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Rustfmt has changed its default style :/
This commit is contained in:
parent
82fc6d9f49
commit
be69f9c3e6
207 changed files with 1200 additions and 1339 deletions
|
@ -8,13 +8,13 @@
|
|||
//! computed values and need yet another intermediate representation. This
|
||||
//! module's raison d'être is to ultimately contain all these types.
|
||||
|
||||
use app_units::Au;
|
||||
use crate::properties::PropertyId;
|
||||
use crate::values::computed::length::CalcLengthOrPercentage;
|
||||
use crate::values::computed::url::ComputedUrl;
|
||||
use crate::values::computed::Angle as ComputedAngle;
|
||||
use crate::values::computed::BorderCornerRadius as ComputedBorderCornerRadius;
|
||||
use crate::values::CSSFloat;
|
||||
use app_units::Au;
|
||||
use euclid::{Point2D, Size2D};
|
||||
use smallvec::SmallVec;
|
||||
use std::cmp;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
//! Computed types for CSS values related to borders.
|
||||
|
||||
use app_units::Au;
|
||||
use crate::values::animated::ToAnimatedZero;
|
||||
use crate::values::computed::length::{LengthOrPercentage, NonNegativeLength};
|
||||
use crate::values::computed::{Number, NumberOrPercentage};
|
||||
|
@ -15,6 +14,7 @@ use crate::values::generics::border::BorderRadius as GenericBorderRadius;
|
|||
use crate::values::generics::border::BorderSpacing as GenericBorderSpacing;
|
||||
use crate::values::generics::rect::Rect;
|
||||
use crate::values::generics::size::Size;
|
||||
use app_units::Au;
|
||||
|
||||
pub use crate::values::specified::border::BorderImageRepeat;
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
//! Computed values for font properties
|
||||
|
||||
use app_units::Au;
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
#[cfg(feature = "gecko")]
|
||||
use crate::gecko_bindings::sugar::refptr::RefPtr;
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -19,6 +17,8 @@ use crate::values::specified::font::{self as specified, MAX_FONT_WEIGHT, MIN_FON
|
|||
use crate::values::specified::length::{FontBaseSize, NoCalcLength};
|
||||
use crate::values::CSSFloat;
|
||||
use crate::Atom;
|
||||
use app_units::Au;
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
use cssparser::{serialize_identifier, CssStringWriter, Parser};
|
||||
#[cfg(feature = "gecko")]
|
||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
//! `<length>` computed values, and related ones.
|
||||
|
||||
use super::{Context, Number, Percentage, ToComputedValue};
|
||||
use app_units::Au;
|
||||
use crate::values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
|
||||
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
|
||||
use crate::values::generics::length::MaxLength as GenericMaxLength;
|
||||
|
@ -15,6 +14,7 @@ use crate::values::generics::NonNegative;
|
|||
use crate::values::specified::length::ViewportPercentageLength;
|
||||
use crate::values::specified::length::{AbsoluteLength, FontBaseSize, FontRelativeLength};
|
||||
use crate::values::{specified, Auto, CSSFloat, Either, IsAuto, Normal};
|
||||
use app_units::Au;
|
||||
use ordered_float::NotNan;
|
||||
use std::fmt::{self, Write};
|
||||
use std::ops::{Add, Neg};
|
||||
|
|
|
@ -241,11 +241,7 @@ where
|
|||
(
|
||||
&ShapeSource::Shape(ref this, ref this_box),
|
||||
&ShapeSource::Shape(ref other, ref other_box),
|
||||
)
|
||||
if this_box == other_box =>
|
||||
{
|
||||
this.compute_squared_distance(other)
|
||||
},
|
||||
) if this_box == other_box => this.compute_squared_distance(other),
|
||||
(&ShapeSource::Path(ref this), &ShapeSource::Path(ref other))
|
||||
if this.fill == other.fill =>
|
||||
{
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
//! Generic types for font stuff.
|
||||
|
||||
use crate::parser::{Parse, ParserContext};
|
||||
use app_units::Au;
|
||||
use byteorder::{BigEndian, ReadBytesExt};
|
||||
use crate::parser::{Parse, ParserContext};
|
||||
use cssparser::Parser;
|
||||
use num_traits::One;
|
||||
use std::fmt::{self, Write};
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
//! Generic types for text properties.
|
||||
|
||||
use app_units::Au;
|
||||
use crate::parser::ParserContext;
|
||||
use crate::values::animated::{Animate, Procedure, ToAnimatedZero};
|
||||
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
|
||||
use app_units::Au;
|
||||
use cssparser::Parser;
|
||||
use style_traits::ParseError;
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
//! Generic types for CSS values that are related to transformations.
|
||||
|
||||
use app_units::Au;
|
||||
use crate::values::computed::length::Length as ComputedLength;
|
||||
use crate::values::computed::length::LengthOrPercentage as ComputedLengthOrPercentage;
|
||||
use crate::values::specified::angle::Angle as SpecifiedAngle;
|
||||
use crate::values::specified::length::Length as SpecifiedLength;
|
||||
use crate::values::specified::length::LengthOrPercentage as SpecifiedLengthOrPercentage;
|
||||
use crate::values::{computed, CSSFloat};
|
||||
use app_units::Au;
|
||||
use euclid::{self, Rect, Transform3D};
|
||||
use num_traits::Zero;
|
||||
use std::fmt::{self, Write};
|
||||
|
|
|
@ -93,10 +93,7 @@ where
|
|||
}
|
||||
|
||||
/// Convenience void type to disable some properties and values through types.
|
||||
#[cfg_attr(
|
||||
feature = "servo",
|
||||
derive(Deserialize, MallocSizeOf, Serialize)
|
||||
)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, MallocSizeOf, Serialize))]
|
||||
#[derive(
|
||||
Clone, Copy, Debug, PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToComputedValue, ToCss,
|
||||
)]
|
||||
|
|
|
@ -193,7 +193,7 @@ impl Angle {
|
|||
AllowUnitlessZeroAngle::No => Err(()),
|
||||
},
|
||||
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {
|
||||
return input.parse_nested_block(|i| CalcNode::parse_angle(context, i))
|
||||
return input.parse_nested_block(|i| CalcNode::parse_angle(context, i));
|
||||
},
|
||||
_ => Err(()),
|
||||
}
|
||||
|
|
|
@ -218,10 +218,7 @@ impl Display {
|
|||
// Special handling for contents and list-item on the root
|
||||
// element for Gecko.
|
||||
#[cfg(feature = "gecko")]
|
||||
Display::Contents | Display::ListItem if _is_root_element =>
|
||||
{
|
||||
Display::Block
|
||||
},
|
||||
Display::Contents | Display::ListItem if _is_root_element => Display::Block,
|
||||
|
||||
// These are not changed by blockification.
|
||||
Display::None | Display::Block | Display::Flex | Display::ListItem | Display::Table => {
|
||||
|
@ -747,7 +744,9 @@ impl Parse for Contain {
|
|||
let flag = match flag {
|
||||
Some(flag) if !result.contains(flag) => flag,
|
||||
_ => {
|
||||
return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name)))
|
||||
return Err(
|
||||
input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name))
|
||||
);
|
||||
},
|
||||
};
|
||||
result.insert(flag);
|
||||
|
@ -826,7 +825,7 @@ impl Parse for TransitionProperty {
|
|||
location,
|
||||
ident,
|
||||
&["none"],
|
||||
)?))
|
||||
)?));
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1309,7 +1308,7 @@ impl BreakBetween {
|
|||
Ok(v) => v,
|
||||
Err(()) => {
|
||||
return Err(location
|
||||
.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone())))
|
||||
.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone())));
|
||||
},
|
||||
};
|
||||
match break_value {
|
||||
|
|
|
@ -180,7 +180,7 @@ impl CalcNode {
|
|||
) => {
|
||||
return NoCalcLength::parse_dimension(context, value, unit)
|
||||
.map(CalcNode::Length)
|
||||
.map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
.map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
},
|
||||
(
|
||||
&Token::Dimension {
|
||||
|
@ -204,7 +204,7 @@ impl CalcNode {
|
|||
},
|
||||
(&Token::Percentage { unit_value, .. }, CalcUnit::LengthOrPercentage) |
|
||||
(&Token::Percentage { unit_value, .. }, CalcUnit::Percentage) => {
|
||||
return Ok(CalcNode::Percentage(unit_value))
|
||||
return Ok(CalcNode::Percentage(unit_value));
|
||||
},
|
||||
(&Token::ParenthesisBlock, _) => {},
|
||||
(&Token::Function(ref name), _) if name.eq_ignore_ascii_case("calc") => {},
|
||||
|
|
|
@ -181,7 +181,7 @@ impl Parse for Content {
|
|||
None => {
|
||||
return Err(input.new_custom_error(
|
||||
StyleParseErrorKind::UnexpectedFunction(name.clone()),
|
||||
))
|
||||
));
|
||||
},
|
||||
}
|
||||
},
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
//! Specified values for font properties
|
||||
|
||||
use app_units::Au;
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
#[cfg(feature = "gecko")]
|
||||
use crate::gecko_bindings::bindings;
|
||||
use crate::parser::{Parse, ParserContext};
|
||||
|
@ -22,6 +20,8 @@ use crate::values::specified::{AllowQuirks, Angle, Integer, LengthOrPercentage};
|
|||
use crate::values::specified::{NoCalcLength, Number, Percentage};
|
||||
use crate::values::CustomIdent;
|
||||
use crate::Atom;
|
||||
use app_units::Au;
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
use cssparser::{Parser, Token};
|
||||
#[cfg(feature = "gecko")]
|
||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
|
|
|
@ -22,11 +22,7 @@ pub fn parse_flex<'i, 't>(input: &mut Parser<'i, 't>) -> Result<CSSFloat, ParseE
|
|||
match *input.next()? {
|
||||
Token::Dimension {
|
||||
value, ref unit, ..
|
||||
}
|
||||
if unit.eq_ignore_ascii_case("fr") && value.is_sign_positive() =>
|
||||
{
|
||||
Ok(value)
|
||||
},
|
||||
} if unit.eq_ignore_ascii_case("fr") && value.is_sign_positive() => Ok(value),
|
||||
ref t => Err(location.new_unexpected_token_error(t.clone())),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ impl Parse for Gradient {
|
|||
let (shape, repeating, mut compat_mode) = match result {
|
||||
Some(result) => result,
|
||||
None => {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnexpectedFunction(func)))
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnexpectedFunction(func)));
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -792,7 +792,7 @@ impl LineDirection {
|
|||
CompatMode::WebKit if to_ident.is_ok() => {
|
||||
return Err(
|
||||
i.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("to".into()))
|
||||
)
|
||||
);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
//! [length]: https://drafts.csswg.org/css-values/#lengths
|
||||
|
||||
use super::{AllowQuirks, Number, Percentage, ToComputedValue};
|
||||
use app_units::Au;
|
||||
use crate::font_metrics::FontMetricsQueryResult;
|
||||
use crate::parser::{Parse, ParserContext};
|
||||
use crate::values::computed::{self, CSSPixelLength, Context, ExtremumLength};
|
||||
|
@ -17,6 +16,7 @@ use crate::values::generics::transform::IsZeroLength;
|
|||
use crate::values::generics::NonNegative;
|
||||
use crate::values::specified::calc::CalcNode;
|
||||
use crate::values::{Auto, CSSFloat, Either, IsAuto, Normal};
|
||||
use app_units::Au;
|
||||
use cssparser::{Parser, Token};
|
||||
use euclid::Size2D;
|
||||
use std::cmp;
|
||||
|
@ -601,12 +601,10 @@ impl Length {
|
|||
match *token {
|
||||
Token::Dimension {
|
||||
value, ref unit, ..
|
||||
}
|
||||
if num_context.is_ok(context.parsing_mode, value) =>
|
||||
{
|
||||
} if num_context.is_ok(context.parsing_mode, value) => {
|
||||
return NoCalcLength::parse_dimension(context, value, unit)
|
||||
.map(Length::NoCalc)
|
||||
.map_err(|()| location.new_unexpected_token_error(token.clone()))
|
||||
.map_err(|()| location.new_unexpected_token_error(token.clone()));
|
||||
},
|
||||
Token::Number { value, .. } if num_context.is_ok(context.parsing_mode, value) => {
|
||||
if value != 0. &&
|
||||
|
@ -790,20 +788,18 @@ impl LengthOrPercentage {
|
|||
match *token {
|
||||
Token::Dimension {
|
||||
value, ref unit, ..
|
||||
}
|
||||
if num_context.is_ok(context.parsing_mode, value) =>
|
||||
{
|
||||
} if num_context.is_ok(context.parsing_mode, value) => {
|
||||
return NoCalcLength::parse_dimension(context, value, unit)
|
||||
.map(LengthOrPercentage::Length)
|
||||
.map_err(|()| location.new_unexpected_token_error(token.clone()))
|
||||
.map_err(|()| location.new_unexpected_token_error(token.clone()));
|
||||
},
|
||||
Token::Percentage { unit_value, .. }
|
||||
if num_context.is_ok(context.parsing_mode, unit_value) =>
|
||||
{
|
||||
return Ok(LengthOrPercentage::Percentage(computed::Percentage(
|
||||
unit_value,
|
||||
)))
|
||||
},
|
||||
)));
|
||||
}
|
||||
Token::Number { value, .. } if num_context.is_ok(context.parsing_mode, value) => {
|
||||
if value != 0. &&
|
||||
!context.parsing_mode.allows_unitless_lengths() &&
|
||||
|
@ -922,20 +918,18 @@ impl LengthOrPercentageOrAuto {
|
|||
match *token {
|
||||
Token::Dimension {
|
||||
value, ref unit, ..
|
||||
}
|
||||
if num_context.is_ok(context.parsing_mode, value) =>
|
||||
{
|
||||
} if num_context.is_ok(context.parsing_mode, value) => {
|
||||
return NoCalcLength::parse_dimension(context, value, unit)
|
||||
.map(LengthOrPercentageOrAuto::Length)
|
||||
.map_err(|()| location.new_unexpected_token_error(token.clone()))
|
||||
.map_err(|()| location.new_unexpected_token_error(token.clone()));
|
||||
},
|
||||
Token::Percentage { unit_value, .. }
|
||||
if num_context.is_ok(context.parsing_mode, unit_value) =>
|
||||
{
|
||||
return Ok(LengthOrPercentageOrAuto::Percentage(computed::Percentage(
|
||||
unit_value,
|
||||
)))
|
||||
},
|
||||
)));
|
||||
}
|
||||
Token::Number { value, .. } if num_context.is_ok(context.parsing_mode, value) => {
|
||||
if value != 0. &&
|
||||
!context.parsing_mode.allows_unitless_lengths() &&
|
||||
|
@ -948,7 +942,7 @@ impl LengthOrPercentageOrAuto {
|
|||
)));
|
||||
},
|
||||
Token::Ident(ref value) if value.eq_ignore_ascii_case("auto") => {
|
||||
return Ok(LengthOrPercentageOrAuto::Auto)
|
||||
return Ok(LengthOrPercentageOrAuto::Auto);
|
||||
},
|
||||
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {},
|
||||
_ => return Err(location.new_unexpected_token_error(token.clone())),
|
||||
|
@ -1088,20 +1082,18 @@ impl LengthOrPercentageOrNone {
|
|||
match *token {
|
||||
Token::Dimension {
|
||||
value, ref unit, ..
|
||||
}
|
||||
if num_context.is_ok(context.parsing_mode, value) =>
|
||||
{
|
||||
} if num_context.is_ok(context.parsing_mode, value) => {
|
||||
return NoCalcLength::parse_dimension(context, value, unit)
|
||||
.map(LengthOrPercentageOrNone::Length)
|
||||
.map_err(|()| location.new_unexpected_token_error(token.clone()))
|
||||
.map_err(|()| location.new_unexpected_token_error(token.clone()));
|
||||
},
|
||||
Token::Percentage { unit_value, .. }
|
||||
if num_context.is_ok(context.parsing_mode, unit_value) =>
|
||||
{
|
||||
return Ok(LengthOrPercentageOrNone::Percentage(computed::Percentage(
|
||||
unit_value,
|
||||
)))
|
||||
},
|
||||
)));
|
||||
}
|
||||
Token::Number { value, .. } if num_context.is_ok(context.parsing_mode, value) => {
|
||||
if value != 0. &&
|
||||
!context.parsing_mode.allows_unitless_lengths() &&
|
||||
|
@ -1115,7 +1107,7 @@ impl LengthOrPercentageOrNone {
|
|||
},
|
||||
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {},
|
||||
Token::Ident(ref value) if value.eq_ignore_ascii_case("none") => {
|
||||
return Ok(LengthOrPercentageOrNone::None)
|
||||
return Ok(LengthOrPercentageOrNone::None);
|
||||
},
|
||||
_ => return Err(location.new_unexpected_token_error(token.clone())),
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ fn parse_number_with_clamping_mode<'i, 't>(
|
|||
return Ok(Number {
|
||||
value: value.min(f32::MAX).max(f32::MIN),
|
||||
calc_clamping_mode: None,
|
||||
})
|
||||
});
|
||||
},
|
||||
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {},
|
||||
ref t => return Err(location.new_unexpected_token_error(t.clone())),
|
||||
|
@ -808,7 +808,7 @@ impl Attr {
|
|||
Some(ns) => ns,
|
||||
None => {
|
||||
return Err(location
|
||||
.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
},
|
||||
};
|
||||
Some((prefix, ns))
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
//! https://html.spec.whatwg.org/multipage/#source-size-list
|
||||
|
||||
use app_units::Au;
|
||||
#[cfg(feature = "gecko")]
|
||||
use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||
use crate::media_queries::{Device, MediaCondition};
|
||||
use crate::parser::{Parse, ParserContext};
|
||||
use crate::values::computed::{self, ToComputedValue};
|
||||
use crate::values::specified::{Length, NoCalcLength, ViewportPercentageLength};
|
||||
use app_units::Au;
|
||||
use cssparser::{Delimiter, Parser, Token};
|
||||
use selectors::context::QuirksMode;
|
||||
use style_traits::ParseError;
|
||||
|
@ -118,7 +118,7 @@ impl SourceSizeList {
|
|||
return Self {
|
||||
source_sizes,
|
||||
value: Some(value),
|
||||
}
|
||||
};
|
||||
},
|
||||
Ok(SourceSizeOrLength::SourceSize(source_size)) => {
|
||||
source_sizes.push(source_size);
|
||||
|
|
|
@ -91,8 +91,7 @@ impl Parse for LineHeight {
|
|||
match ident {
|
||||
ref ident if ident.eq_ignore_ascii_case("normal") => Ok(GenericLineHeight::Normal),
|
||||
#[cfg(feature = "gecko")]
|
||||
ref ident if ident.eq_ignore_ascii_case("-moz-block-height") =>
|
||||
{
|
||||
ref ident if ident.eq_ignore_ascii_case("-moz-block-height") => {
|
||||
Ok(GenericLineHeight::MozBlockHeight)
|
||||
},
|
||||
ident => {
|
||||
|
|
|
@ -92,12 +92,10 @@ impl Time {
|
|||
// ParsingMode::DEFAULT directly.
|
||||
Ok(&Token::Dimension {
|
||||
value, ref unit, ..
|
||||
})
|
||||
if clamping_mode.is_ok(ParsingMode::DEFAULT, value) =>
|
||||
{
|
||||
}) 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));
|
||||
}
|
||||
},
|
||||
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()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue