mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +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
|
@ -39,14 +39,8 @@ pub type Image = generic::Image<Gradient, MozImageRect, SpecifiedImageUrl>;
|
|||
/// Specified values for a CSS gradient.
|
||||
/// <https://drafts.csswg.org/css-images/#gradients>
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
pub type Gradient = generic::Gradient<
|
||||
LineDirection,
|
||||
Length,
|
||||
LengthOrPercentage,
|
||||
Position,
|
||||
RGBAColor,
|
||||
Angle,
|
||||
>;
|
||||
pub type Gradient =
|
||||
generic::Gradient<LineDirection, Length, LengthOrPercentage, Position, RGBAColor, Angle>;
|
||||
|
||||
/// Specified values for a CSS gradient.
|
||||
/// <https://drafts.csswg.org/css-images/#gradients>
|
||||
|
@ -62,23 +56,13 @@ pub type Gradient = generic::Gradient<
|
|||
|
||||
/// A specified gradient kind.
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
pub type GradientKind = generic::GradientKind<
|
||||
LineDirection,
|
||||
Length,
|
||||
LengthOrPercentage,
|
||||
Position,
|
||||
Angle,
|
||||
>;
|
||||
pub type GradientKind =
|
||||
generic::GradientKind<LineDirection, Length, LengthOrPercentage, Position, Angle>;
|
||||
|
||||
/// A specified gradient kind.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub type GradientKind = generic::GradientKind<
|
||||
LineDirection,
|
||||
Length,
|
||||
LengthOrPercentage,
|
||||
GradientPosition,
|
||||
Angle,
|
||||
>;
|
||||
pub type GradientKind =
|
||||
generic::GradientKind<LineDirection, Length, LengthOrPercentage, GradientPosition, Angle>;
|
||||
|
||||
/// A specified gradient line direction.
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
|
||||
|
@ -123,7 +107,10 @@ pub type ColorStop = generic::ColorStop<RGBAColor, LengthOrPercentage>;
|
|||
pub type MozImageRect = generic::MozImageRect<NumberOrPercentage, SpecifiedImageUrl>;
|
||||
|
||||
impl Parse for Image {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Image, ParseError<'i>> {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Image, ParseError<'i>> {
|
||||
if let Ok(url) = input.try(|input| SpecifiedImageUrl::parse(context, input)) {
|
||||
return Ok(generic::Image::Url(url));
|
||||
}
|
||||
|
@ -156,17 +143,18 @@ impl Image {
|
|||
fn parse_element<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Atom, ParseError<'i>> {
|
||||
input.try(|i| i.expect_function_matching("-moz-element"))?;
|
||||
let location = input.current_source_location();
|
||||
input.parse_nested_block(|i| {
|
||||
match *i.next()? {
|
||||
Token::IDHash(ref id) => Ok(Atom::from(id.as_ref())),
|
||||
ref t => Err(location.new_unexpected_token_error(t.clone())),
|
||||
}
|
||||
input.parse_nested_block(|i| match *i.next()? {
|
||||
Token::IDHash(ref id) => Ok(Atom::from(id.as_ref())),
|
||||
ref t => Err(location.new_unexpected_token_error(t.clone())),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for Gradient {
|
||||
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>> {
|
||||
enum Shape {
|
||||
Linear,
|
||||
Radial,
|
||||
|
@ -225,18 +213,18 @@ 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))),
|
||||
None => {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnexpectedFunction(func)))
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
use gecko_bindings::structs;
|
||||
if compat_mode == CompatMode::Moz &&
|
||||
!unsafe { structs::StaticPrefs_sVarCache_layout_css_prefixes_gradients }
|
||||
{
|
||||
return Err(input.new_custom_error(
|
||||
StyleParseErrorKind::UnexpectedFunction(func)
|
||||
));
|
||||
if compat_mode == CompatMode::Moz && !unsafe {
|
||||
structs::StaticPrefs_sVarCache_layout_css_prefixes_gradients
|
||||
} {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnexpectedFunction(func)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,28 +273,17 @@ impl Gradient {
|
|||
_ => return LineDirection::Vertical(Y::Bottom),
|
||||
};
|
||||
match (h, v) {
|
||||
(Ordering::Less, Ordering::Less) => {
|
||||
LineDirection::Corner(X::Right, Y::Bottom)
|
||||
},
|
||||
(Ordering::Less, Ordering::Equal) => {
|
||||
LineDirection::Horizontal(X::Right)
|
||||
},
|
||||
(Ordering::Less, Ordering::Greater) => {
|
||||
LineDirection::Corner(X::Right, Y::Top)
|
||||
},
|
||||
(Ordering::Equal, Ordering::Greater) => {
|
||||
LineDirection::Vertical(Y::Top)
|
||||
},
|
||||
(Ordering::Equal, Ordering::Equal) |
|
||||
(Ordering::Equal, Ordering::Less) => {
|
||||
(Ordering::Less, Ordering::Less) => LineDirection::Corner(X::Right, Y::Bottom),
|
||||
(Ordering::Less, Ordering::Equal) => LineDirection::Horizontal(X::Right),
|
||||
(Ordering::Less, Ordering::Greater) => LineDirection::Corner(X::Right, Y::Top),
|
||||
(Ordering::Equal, Ordering::Greater) => LineDirection::Vertical(Y::Top),
|
||||
(Ordering::Equal, Ordering::Equal) | (Ordering::Equal, Ordering::Less) => {
|
||||
LineDirection::Vertical(Y::Bottom)
|
||||
},
|
||||
(Ordering::Greater, Ordering::Less) => {
|
||||
LineDirection::Corner(X::Left, Y::Bottom)
|
||||
},
|
||||
(Ordering::Greater, Ordering::Equal) => {
|
||||
LineDirection::Horizontal(X::Left)
|
||||
},
|
||||
(Ordering::Greater, Ordering::Equal) => LineDirection::Horizontal(X::Left),
|
||||
(Ordering::Greater, Ordering::Greater) => {
|
||||
LineDirection::Corner(X::Left, Y::Top)
|
||||
},
|
||||
|
@ -321,8 +298,10 @@ impl Gradient {
|
|||
}
|
||||
|
||||
impl Parse for Point {
|
||||
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>> {
|
||||
input.try(|i| {
|
||||
let x = Component::parse(context, i)?;
|
||||
let y = Component::parse(context, i)?;
|
||||
|
@ -338,7 +317,11 @@ impl Gradient {
|
|||
Component::Center => NumberOrPercentage::Percentage(Percentage::new(0.5)),
|
||||
Component::Number(number) => number,
|
||||
Component::Side(side) => {
|
||||
let p = if side.is_start() { Percentage::zero() } else { Percentage::hundred() };
|
||||
let p = if side.is_start() {
|
||||
Percentage::zero()
|
||||
} else {
|
||||
Percentage::hundred()
|
||||
};
|
||||
NumberOrPercentage::Percentage(p)
|
||||
},
|
||||
}
|
||||
|
@ -348,41 +331,40 @@ impl Gradient {
|
|||
impl<S: Side> From<Component<S>> for PositionComponent<S> {
|
||||
fn from(component: Component<S>) -> Self {
|
||||
match component {
|
||||
Component::Center => {
|
||||
PositionComponent::Center
|
||||
},
|
||||
Component::Center => PositionComponent::Center,
|
||||
Component::Number(NumberOrPercentage::Number(number)) => {
|
||||
PositionComponent::Length(Length::from_px(number.value).into())
|
||||
},
|
||||
Component::Number(NumberOrPercentage::Percentage(p)) => {
|
||||
PositionComponent::Length(p.into())
|
||||
},
|
||||
Component::Side(side) => {
|
||||
PositionComponent::Side(side, None)
|
||||
},
|
||||
Component::Side(side) => PositionComponent::Side(side, None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Copy + Side> Component<S> {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
match (NumberOrPercentage::from(*self), NumberOrPercentage::from(*other)) {
|
||||
match (
|
||||
NumberOrPercentage::from(*self),
|
||||
NumberOrPercentage::from(*other),
|
||||
) {
|
||||
(NumberOrPercentage::Percentage(a), NumberOrPercentage::Percentage(b)) => {
|
||||
a.get().partial_cmp(&b.get())
|
||||
},
|
||||
(NumberOrPercentage::Number(a), NumberOrPercentage::Number(b)) => {
|
||||
a.value.partial_cmp(&b.value)
|
||||
},
|
||||
(_, _) => {
|
||||
None
|
||||
}
|
||||
(_, _) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Parse> Parse for Component<S> {
|
||||
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>> {
|
||||
if let Ok(side) = input.try(|i| S::parse(context, i)) {
|
||||
return Ok(Component::Side(side));
|
||||
}
|
||||
|
@ -446,43 +428,45 @@ impl Gradient {
|
|||
},
|
||||
};
|
||||
|
||||
let mut items = input.try(|i| {
|
||||
i.expect_comma()?;
|
||||
i.parse_comma_separated(|i| {
|
||||
let function = i.expect_function()?.clone();
|
||||
let (color, mut p) = i.parse_nested_block(|i| {
|
||||
let p = match_ignore_ascii_case! { &function,
|
||||
"color-stop" => {
|
||||
let p = match NumberOrPercentage::parse(context, i)? {
|
||||
NumberOrPercentage::Number(number) => Percentage::new(number.value),
|
||||
NumberOrPercentage::Percentage(p) => p,
|
||||
};
|
||||
i.expect_comma()?;
|
||||
p
|
||||
},
|
||||
"from" => Percentage::zero(),
|
||||
"to" => Percentage::hundred(),
|
||||
_ => {
|
||||
return Err(i.new_custom_error(
|
||||
StyleParseErrorKind::UnexpectedFunction(function.clone())
|
||||
))
|
||||
},
|
||||
};
|
||||
let color = Color::parse(context, i)?;
|
||||
if color == Color::CurrentColor {
|
||||
return Err(i.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
let mut items = input
|
||||
.try(|i| {
|
||||
i.expect_comma()?;
|
||||
i.parse_comma_separated(|i| {
|
||||
let function = i.expect_function()?.clone();
|
||||
let (color, mut p) = i.parse_nested_block(|i| {
|
||||
let p = match_ignore_ascii_case! { &function,
|
||||
"color-stop" => {
|
||||
let p = match NumberOrPercentage::parse(context, i)? {
|
||||
NumberOrPercentage::Number(number) => Percentage::new(number.value),
|
||||
NumberOrPercentage::Percentage(p) => p,
|
||||
};
|
||||
i.expect_comma()?;
|
||||
p
|
||||
},
|
||||
"from" => Percentage::zero(),
|
||||
"to" => Percentage::hundred(),
|
||||
_ => {
|
||||
return Err(i.new_custom_error(
|
||||
StyleParseErrorKind::UnexpectedFunction(function.clone())
|
||||
))
|
||||
},
|
||||
};
|
||||
let color = Color::parse(context, i)?;
|
||||
if color == Color::CurrentColor {
|
||||
return Err(i.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
Ok((color.into(), p))
|
||||
})?;
|
||||
if reverse_stops {
|
||||
p.reverse();
|
||||
}
|
||||
Ok((color.into(), p))
|
||||
})?;
|
||||
if reverse_stops {
|
||||
p.reverse();
|
||||
}
|
||||
Ok(generic::GradientItem::ColorStop(generic::ColorStop {
|
||||
color: color,
|
||||
position: Some(p.into()),
|
||||
}))
|
||||
Ok(generic::GradientItem::ColorStop(generic::ColorStop {
|
||||
color: color,
|
||||
position: Some(p.into()),
|
||||
}))
|
||||
})
|
||||
})
|
||||
}).unwrap_or(vec![]);
|
||||
.unwrap_or(vec![]);
|
||||
|
||||
if items.is_empty() {
|
||||
items = vec![
|
||||
|
@ -501,13 +485,17 @@ impl Gradient {
|
|||
} else {
|
||||
items.sort_by(|a, b| {
|
||||
match (a, b) {
|
||||
(&generic::GradientItem::ColorStop(ref a), &generic::GradientItem::ColorStop(ref b)) => {
|
||||
match (&a.position, &b.position) {
|
||||
(&Some(LengthOrPercentage::Percentage(a)), &Some(LengthOrPercentage::Percentage(b))) => {
|
||||
return a.0.partial_cmp(&b.0).unwrap_or(Ordering::Equal);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
(
|
||||
&generic::GradientItem::ColorStop(ref a),
|
||||
&generic::GradientItem::ColorStop(ref b),
|
||||
) => match (&a.position, &b.position) {
|
||||
(
|
||||
&Some(LengthOrPercentage::Percentage(a)),
|
||||
&Some(LengthOrPercentage::Percentage(b)),
|
||||
) => {
|
||||
return a.0.partial_cmp(&b.0).unwrap_or(Ordering::Equal);
|
||||
},
|
||||
_ => {},
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
@ -536,7 +524,8 @@ impl GradientKind {
|
|||
input: &mut Parser<'i, 't>,
|
||||
compat_mode: &mut CompatMode,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
let direction = if let Ok(d) = input.try(|i| LineDirection::parse(context, i, compat_mode)) {
|
||||
let direction = if let Ok(d) = input.try(|i| LineDirection::parse(context, i, compat_mode))
|
||||
{
|
||||
input.expect_comma()?;
|
||||
d
|
||||
} else {
|
||||
|
@ -597,7 +586,7 @@ impl GradientKind {
|
|||
});
|
||||
|
||||
(shape, None, angle, position.ok())
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
if shape.is_ok() || position.is_some() || angle.is_some() || moz_position.is_some() {
|
||||
|
@ -616,14 +605,22 @@ impl GradientKind {
|
|||
*compat_mode = CompatMode::Modern;
|
||||
}
|
||||
let position = moz_position.unwrap_or(LegacyPosition::center());
|
||||
return Ok(generic::GradientKind::Radial(shape, GradientPosition::Legacy(position), angle));
|
||||
return Ok(generic::GradientKind::Radial(
|
||||
shape,
|
||||
GradientPosition::Legacy(position),
|
||||
angle,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
let position = position.unwrap_or(Position::center());
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
return Ok(generic::GradientKind::Radial(shape, GradientPosition::Modern(position), angle));
|
||||
return Ok(generic::GradientKind::Radial(
|
||||
shape,
|
||||
GradientPosition::Modern(position),
|
||||
angle,
|
||||
));
|
||||
}
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
{
|
||||
|
@ -636,15 +633,16 @@ impl generic::LineDirection for LineDirection {
|
|||
fn points_downwards(&self, compat_mode: CompatMode) -> bool {
|
||||
match *self {
|
||||
LineDirection::Angle(ref angle) => angle.radians() == PI,
|
||||
LineDirection::Vertical(Y::Bottom)
|
||||
if compat_mode == CompatMode::Modern => true,
|
||||
LineDirection::Vertical(Y::Top)
|
||||
if compat_mode != CompatMode::Modern => true,
|
||||
LineDirection::Vertical(Y::Bottom) if compat_mode == CompatMode::Modern => true,
|
||||
LineDirection::Vertical(Y::Top) if compat_mode != CompatMode::Modern => true,
|
||||
#[cfg(feature = "gecko")]
|
||||
LineDirection::MozPosition(Some(LegacyPosition {
|
||||
horizontal: ref x,
|
||||
vertical: ref y,
|
||||
}), None) => {
|
||||
LineDirection::MozPosition(
|
||||
Some(LegacyPosition {
|
||||
horizontal: ref x,
|
||||
vertical: ref y,
|
||||
}),
|
||||
None,
|
||||
) => {
|
||||
use values::computed::Percentage as ComputedPercentage;
|
||||
use values::specified::transform::OriginComponent;
|
||||
|
||||
|
@ -652,16 +650,16 @@ impl generic::LineDirection for LineDirection {
|
|||
// These percentage values can also be keywords.
|
||||
let x = match *x {
|
||||
OriginComponent::Center => true,
|
||||
OriginComponent::Length(LengthOrPercentage::Percentage(ComputedPercentage(val))) => {
|
||||
val == 0.5
|
||||
},
|
||||
OriginComponent::Length(LengthOrPercentage::Percentage(
|
||||
ComputedPercentage(val),
|
||||
)) => val == 0.5,
|
||||
_ => false,
|
||||
};
|
||||
let y = match *y {
|
||||
OriginComponent::Side(Y::Top) => true,
|
||||
OriginComponent::Length(LengthOrPercentage::Percentage(ComputedPercentage(val))) => {
|
||||
val == 0.0
|
||||
},
|
||||
OriginComponent::Length(LengthOrPercentage::Percentage(
|
||||
ComputedPercentage(val),
|
||||
)) => val == 0.0,
|
||||
_ => false,
|
||||
};
|
||||
x && y
|
||||
|
@ -670,18 +668,12 @@ impl generic::LineDirection for LineDirection {
|
|||
}
|
||||
}
|
||||
|
||||
fn to_css<W>(
|
||||
&self,
|
||||
dest: &mut CssWriter<W>,
|
||||
compat_mode: CompatMode,
|
||||
) -> fmt::Result
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>, compat_mode: CompatMode) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
match *self {
|
||||
LineDirection::Angle(angle) => {
|
||||
angle.to_css(dest)
|
||||
},
|
||||
LineDirection::Angle(angle) => angle.to_css(dest),
|
||||
LineDirection::Horizontal(x) => {
|
||||
if compat_mode == CompatMode::Modern {
|
||||
dest.write_str("to ")?;
|
||||
|
@ -750,7 +742,9 @@ impl LineDirection {
|
|||
// There is no `to` keyword in webkit prefixed syntax. If it's consumed,
|
||||
// parsing should throw an error.
|
||||
CompatMode::WebKit if to_ident.is_ok() => {
|
||||
return Err(i.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("to".into())))
|
||||
return Err(i.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(
|
||||
"to".into(),
|
||||
)))
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
@ -824,7 +818,9 @@ impl EndingShape {
|
|||
return Ok(generic::EndingShape::Circle(Circle::Radius(length)));
|
||||
}
|
||||
}
|
||||
return Ok(generic::EndingShape::Circle(Circle::Extent(ShapeExtent::FarthestCorner)));
|
||||
return Ok(generic::EndingShape::Circle(Circle::Extent(
|
||||
ShapeExtent::FarthestCorner,
|
||||
)));
|
||||
}
|
||||
if input.try(|i| i.expect_ident_matching("ellipse")).is_ok() {
|
||||
if let Ok(extent) = input.try(|i| ShapeExtent::parse_with_compat_mode(i, compat_mode)) {
|
||||
|
@ -840,7 +836,9 @@ impl EndingShape {
|
|||
return Ok(generic::EndingShape::Ellipse(Ellipse::Radii(x, y)));
|
||||
}
|
||||
}
|
||||
return Ok(generic::EndingShape::Ellipse(Ellipse::Extent(ShapeExtent::FarthestCorner)));
|
||||
return Ok(generic::EndingShape::Ellipse(Ellipse::Extent(
|
||||
ShapeExtent::FarthestCorner,
|
||||
)));
|
||||
}
|
||||
// -moz- prefixed radial gradient doesn't allow EndingShape's Length or LengthOrPercentage
|
||||
// to come before shape keyword. Otherwise it conflicts with <position>.
|
||||
|
@ -850,7 +848,10 @@ impl EndingShape {
|
|||
if compat_mode == CompatMode::Modern {
|
||||
let _ = input.try(|i| i.expect_ident_matching("ellipse"));
|
||||
}
|
||||
return Ok(generic::EndingShape::Ellipse(Ellipse::Radii(length.into(), y)));
|
||||
return Ok(generic::EndingShape::Ellipse(Ellipse::Radii(
|
||||
length.into(),
|
||||
y,
|
||||
)));
|
||||
}
|
||||
if compat_mode == CompatMode::Modern {
|
||||
let y = input.try(|i| {
|
||||
|
@ -858,7 +859,10 @@ impl EndingShape {
|
|||
LengthOrPercentage::parse(context, i)
|
||||
});
|
||||
if let Ok(y) = y {
|
||||
return Ok(generic::EndingShape::Ellipse(Ellipse::Radii(length.into(), y)));
|
||||
return Ok(generic::EndingShape::Ellipse(Ellipse::Radii(
|
||||
length.into(),
|
||||
y,
|
||||
)));
|
||||
}
|
||||
let _ = input.try(|i| i.expect_ident_matching("circle"));
|
||||
}
|
||||
|
@ -924,8 +928,10 @@ impl GradientItem {
|
|||
}
|
||||
|
||||
impl Parse for ColorStop {
|
||||
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>> {
|
||||
Ok(ColorStop {
|
||||
color: RGBAColor::parse(context, input)?,
|
||||
position: input.try(|i| LengthOrPercentage::parse(context, i)).ok(),
|
||||
|
@ -941,17 +947,22 @@ impl Parse for PaintWorklet {
|
|||
input.expect_function_matching("paint")?;
|
||||
input.parse_nested_block(|input| {
|
||||
let name = Atom::from(&**input.expect_ident()?);
|
||||
let arguments = input.try(|input| {
|
||||
input.expect_comma()?;
|
||||
input.parse_comma_separated(|input| SpecifiedValue::parse(input))
|
||||
}).unwrap_or(vec![]);
|
||||
let arguments = input
|
||||
.try(|input| {
|
||||
input.expect_comma()?;
|
||||
input.parse_comma_separated(|input| SpecifiedValue::parse(input))
|
||||
})
|
||||
.unwrap_or(vec![]);
|
||||
Ok(PaintWorklet { name, arguments })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for MozImageRect {
|
||||
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>> {
|
||||
input.try(|i| i.expect_function_matching("-moz-image-rect"))?;
|
||||
input.parse_nested_block(|i| {
|
||||
let string = i.expect_url_or_string()?;
|
||||
|
@ -964,7 +975,13 @@ impl Parse for MozImageRect {
|
|||
let bottom = NumberOrPercentage::parse_non_negative(context, i)?;
|
||||
i.expect_comma()?;
|
||||
let left = NumberOrPercentage::parse_non_negative(context, i)?;
|
||||
Ok(MozImageRect { url, top, right, bottom, left })
|
||||
Ok(MozImageRect {
|
||||
url,
|
||||
top,
|
||||
right,
|
||||
bottom,
|
||||
left,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue