mirror of
https://github.com/servo/servo.git
synced 2025-08-15 02:15:33 +01:00
Manual fixups so that the rustfmt output won't trigger tidy.
This commit is contained in:
parent
b292f78363
commit
f7ae1a37e3
40 changed files with 443 additions and 416 deletions
|
@ -13,42 +13,39 @@ use std::borrow::Cow;
|
|||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use values::computed::Percentage;
|
||||
use values::generics::basic_shape::{Circle as GenericCircle};
|
||||
use values::generics::basic_shape::{ClippingShape as GenericClippingShape, Ellipse as GenericEllipse};
|
||||
use values::generics::basic_shape::{FillRule, BasicShape as GenericBasicShape};
|
||||
use values::generics::basic_shape::{FloatAreaShape as GenericFloatAreaShape, InsetRect as GenericInsetRect};
|
||||
use values::generics::basic_shape::{GeometryBox, ShapeBox, ShapeSource};
|
||||
use values::generics::basic_shape::{Polygon as GenericPolygon, ShapeRadius as GenericShapeRadius};
|
||||
use values::generics::basic_shape as generic;
|
||||
use values::generics::basic_shape::{FillRule, GeometryBox, ShapeBox, ShapeSource};
|
||||
use values::generics::rect::Rect;
|
||||
use values::specified::LengthOrPercentage;
|
||||
use values::specified::border::BorderRadius;
|
||||
use values::specified::image::Image;
|
||||
use values::specified::position::{HorizontalPosition, Position, PositionComponent, Side, VerticalPosition};
|
||||
use values::specified::position::{HorizontalPosition, Position, PositionComponent};
|
||||
use values::specified::position::{Side, VerticalPosition};
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
/// A specified clipping shape.
|
||||
pub type ClippingShape = GenericClippingShape<BasicShape, SpecifiedUrl>;
|
||||
pub type ClippingShape = generic::ClippingShape<BasicShape, SpecifiedUrl>;
|
||||
|
||||
/// A specified float area shape.
|
||||
pub type FloatAreaShape = GenericFloatAreaShape<BasicShape, Image>;
|
||||
pub type FloatAreaShape = generic::FloatAreaShape<BasicShape, Image>;
|
||||
|
||||
/// A specified basic shape.
|
||||
pub type BasicShape = GenericBasicShape<HorizontalPosition, VerticalPosition, LengthOrPercentage>;
|
||||
pub type BasicShape = generic::BasicShape<HorizontalPosition, VerticalPosition, LengthOrPercentage>;
|
||||
|
||||
/// The specified value of `inset()`
|
||||
pub type InsetRect = GenericInsetRect<LengthOrPercentage>;
|
||||
pub type InsetRect = generic::InsetRect<LengthOrPercentage>;
|
||||
|
||||
/// A specified circle.
|
||||
pub type Circle = GenericCircle<HorizontalPosition, VerticalPosition, LengthOrPercentage>;
|
||||
pub type Circle = generic::Circle<HorizontalPosition, VerticalPosition, LengthOrPercentage>;
|
||||
|
||||
/// A specified ellipse.
|
||||
pub type Ellipse = GenericEllipse<HorizontalPosition, VerticalPosition, LengthOrPercentage>;
|
||||
pub type Ellipse = generic::Ellipse<HorizontalPosition, VerticalPosition, LengthOrPercentage>;
|
||||
|
||||
/// The specified value of `ShapeRadius`
|
||||
pub type ShapeRadius = GenericShapeRadius<LengthOrPercentage>;
|
||||
pub type ShapeRadius = generic::ShapeRadius<LengthOrPercentage>;
|
||||
|
||||
/// The specified value of `Polygon`
|
||||
pub type Polygon = GenericPolygon<LengthOrPercentage>;
|
||||
pub type Polygon = generic::Polygon<LengthOrPercentage>;
|
||||
|
||||
impl<ReferenceBox, ImageOrUrl> Parse for ShapeSource<BasicShape, ReferenceBox, ImageOrUrl>
|
||||
where
|
||||
|
@ -110,10 +107,10 @@ impl Parse for BasicShape {
|
|||
let function = input.expect_function()?.clone();
|
||||
input.parse_nested_block(move |i| {
|
||||
(match_ignore_ascii_case! { &function,
|
||||
"inset" => return InsetRect::parse_function_arguments(context, i).map(GenericBasicShape::Inset),
|
||||
"circle" => return Circle::parse_function_arguments(context, i).map(GenericBasicShape::Circle),
|
||||
"ellipse" => return Ellipse::parse_function_arguments(context, i).map(GenericBasicShape::Ellipse),
|
||||
"polygon" => return Polygon::parse_function_arguments(context, i).map(GenericBasicShape::Polygon),
|
||||
"inset" => return InsetRect::parse_function_arguments(context, i).map(generic::BasicShape::Inset),
|
||||
"circle" => return Circle::parse_function_arguments(context, i).map(generic::BasicShape::Circle),
|
||||
"ellipse" => return Ellipse::parse_function_arguments(context, i).map(generic::BasicShape::Ellipse),
|
||||
"polygon" => return Polygon::parse_function_arguments(context, i).map(generic::BasicShape::Polygon),
|
||||
_ => Err(())
|
||||
}).map_err(|()| location.new_custom_error(StyleParseErrorKind::UnexpectedFunction(function.clone())))
|
||||
})
|
||||
|
@ -139,7 +136,7 @@ impl InsetRect {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
Ok(GenericInsetRect {
|
||||
Ok(generic::InsetRect {
|
||||
rect: rect,
|
||||
round: round,
|
||||
})
|
||||
|
@ -166,7 +163,7 @@ impl Circle {
|
|||
Position::center()
|
||||
};
|
||||
|
||||
Ok(GenericCircle { radius, position })
|
||||
Ok(generic::Circle { radius, position })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,7 +173,7 @@ impl ToCss for Circle {
|
|||
W: Write,
|
||||
{
|
||||
dest.write_str("circle(")?;
|
||||
if GenericShapeRadius::ClosestSide != self.radius {
|
||||
if generic::ShapeRadius::ClosestSide != self.radius {
|
||||
self.radius.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
}
|
||||
|
@ -208,7 +205,7 @@ impl Ellipse {
|
|||
Position::center()
|
||||
};
|
||||
|
||||
Ok(GenericEllipse {
|
||||
Ok(generic::Ellipse {
|
||||
semiaxis_x: a,
|
||||
semiaxis_y: b,
|
||||
position: position,
|
||||
|
@ -239,12 +236,12 @@ impl Parse for ShapeRadius {
|
|||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
if let Ok(lop) = input.try(|i| LengthOrPercentage::parse_non_negative(context, i)) {
|
||||
return Ok(GenericShapeRadius::Length(lop))
|
||||
return Ok(generic::ShapeRadius::Length(lop))
|
||||
}
|
||||
|
||||
try_match_ident_ignore_ascii_case! { input,
|
||||
"closest-side" => Ok(GenericShapeRadius::ClosestSide),
|
||||
"farthest-side" => Ok(GenericShapeRadius::FarthestSide),
|
||||
"closest-side" => Ok(generic::ShapeRadius::ClosestSide),
|
||||
"farthest-side" => Ok(generic::ShapeRadius::FarthestSide),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,9 @@ use std::mem;
|
|||
use style_traits::{ParseError, StyleParseErrorKind};
|
||||
use values::{CSSFloat, CustomIdent};
|
||||
use values::computed::{self, Context, ToComputedValue};
|
||||
use values::generics::grid::{GridTemplateComponent, RepeatCount, TrackBreadth, TrackKeyword, TrackRepeat};
|
||||
use values::generics::grid::{LineNameList, TrackSize, TrackList, TrackListType, TrackListValue};
|
||||
use values::generics::grid::{GridTemplateComponent, RepeatCount, TrackBreadth};
|
||||
use values::generics::grid::{TrackKeyword, TrackRepeat, LineNameList, TrackSize};
|
||||
use values::generics::grid::{TrackList, TrackListType, TrackListValue};
|
||||
use values::specified::{LengthOrPercentage, Integer};
|
||||
|
||||
/// Parse a single flexible length.
|
||||
|
@ -175,7 +176,8 @@ impl Parse for TrackList<LengthOrPercentage, Integer> {
|
|||
let mut names = vec![];
|
||||
let mut values = vec![];
|
||||
|
||||
let mut list_type = TrackListType::Explicit; // assume it's the simplest case
|
||||
// assume it's the simplest case.
|
||||
let mut list_type = TrackListType::Explicit;
|
||||
// holds <auto-repeat> value. It can only be only one in a TrackList.
|
||||
let mut auto_repeat = None;
|
||||
// if there is any <auto-repeat> the list will be of type TrackListType::Auto(idx)
|
||||
|
|
|
@ -21,11 +21,7 @@ use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
|||
use values::{Either, None_};
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::computed::{Context, Position as ComputedPosition, ToComputedValue};
|
||||
use values::generics::image::{Circle, CompatMode, Ellipse, ColorStop as GenericColorStop};
|
||||
use values::generics::image::{EndingShape as GenericEndingShape, Gradient as GenericGradient};
|
||||
use values::generics::image::{GradientItem as GenericGradientItem, GradientKind as GenericGradientKind};
|
||||
use values::generics::image::{Image as GenericImage, LineDirection as GenericsLineDirection};
|
||||
use values::generics::image::{MozImageRect as GenericMozImageRect, ShapeExtent};
|
||||
use values::generics::image::{self as generic, Circle, CompatMode, Ellipse, ShapeExtent};
|
||||
use values::generics::image::PaintWorklet;
|
||||
use values::generics::position::Position as GenericPosition;
|
||||
use values::specified::{Angle, Color, Length, LengthOrPercentage};
|
||||
|
@ -38,12 +34,12 @@ pub type ImageLayer = Either<None_, Image>;
|
|||
|
||||
/// Specified values for an image according to CSS-IMAGES.
|
||||
/// <https://drafts.csswg.org/css-images/#image-values>
|
||||
pub type Image = GenericImage<Gradient, MozImageRect, SpecifiedImageUrl>;
|
||||
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 = GenericGradient<
|
||||
pub type Gradient = generic::Gradient<
|
||||
LineDirection,
|
||||
Length,
|
||||
LengthOrPercentage,
|
||||
|
@ -55,7 +51,7 @@ pub type Gradient = GenericGradient<
|
|||
/// Specified values for a CSS gradient.
|
||||
/// <https://drafts.csswg.org/css-images/#gradients>
|
||||
#[cfg(feature = "gecko")]
|
||||
pub type Gradient = GenericGradient<
|
||||
pub type Gradient = generic::Gradient<
|
||||
LineDirection,
|
||||
Length,
|
||||
LengthOrPercentage,
|
||||
|
@ -66,7 +62,7 @@ pub type Gradient = GenericGradient<
|
|||
|
||||
/// A specified gradient kind.
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
pub type GradientKind = GenericGradientKind<
|
||||
pub type GradientKind = generic::GradientKind<
|
||||
LineDirection,
|
||||
Length,
|
||||
LengthOrPercentage,
|
||||
|
@ -76,7 +72,7 @@ pub type GradientKind = GenericGradientKind<
|
|||
|
||||
/// A specified gradient kind.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub type GradientKind = GenericGradientKind<
|
||||
pub type GradientKind = generic::GradientKind<
|
||||
LineDirection,
|
||||
Length,
|
||||
LengthOrPercentage,
|
||||
|
@ -114,36 +110,36 @@ pub enum GradientPosition {
|
|||
}
|
||||
|
||||
/// A specified ending shape.
|
||||
pub type EndingShape = GenericEndingShape<Length, LengthOrPercentage>;
|
||||
pub type EndingShape = generic::EndingShape<Length, LengthOrPercentage>;
|
||||
|
||||
/// A specified gradient item.
|
||||
pub type GradientItem = GenericGradientItem<RGBAColor, LengthOrPercentage>;
|
||||
pub type GradientItem = generic::GradientItem<RGBAColor, LengthOrPercentage>;
|
||||
|
||||
/// A computed color stop.
|
||||
pub type ColorStop = GenericColorStop<RGBAColor, LengthOrPercentage>;
|
||||
pub type ColorStop = generic::ColorStop<RGBAColor, LengthOrPercentage>;
|
||||
|
||||
/// Specified values for `moz-image-rect`
|
||||
/// -moz-image-rect(<uri>, top, right, bottom, left);
|
||||
pub type MozImageRect = GenericMozImageRect<NumberOrPercentage, SpecifiedImageUrl>;
|
||||
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>> {
|
||||
if let Ok(url) = input.try(|input| SpecifiedImageUrl::parse(context, input)) {
|
||||
return Ok(GenericImage::Url(url));
|
||||
return Ok(generic::Image::Url(url));
|
||||
}
|
||||
if let Ok(gradient) = input.try(|i| Gradient::parse(context, i)) {
|
||||
return Ok(GenericImage::Gradient(Box::new(gradient)));
|
||||
return Ok(generic::Image::Gradient(Box::new(gradient)));
|
||||
}
|
||||
#[cfg(feature = "servo")]
|
||||
{
|
||||
if let Ok(paint_worklet) = input.try(|i| PaintWorklet::parse(context, i)) {
|
||||
return Ok(GenericImage::PaintWorklet(paint_worklet));
|
||||
return Ok(generic::Image::PaintWorklet(paint_worklet));
|
||||
}
|
||||
}
|
||||
if let Ok(image_rect) = input.try(|input| MozImageRect::parse(context, input)) {
|
||||
return Ok(GenericImage::Rect(Box::new(image_rect)));
|
||||
return Ok(generic::Image::Rect(Box::new(image_rect)));
|
||||
}
|
||||
Ok(GenericImage::Element(Image::parse_element(input)?))
|
||||
Ok(generic::Image::Element(Image::parse_element(input)?))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +149,7 @@ impl Image {
|
|||
#[cfg(feature = "servo")]
|
||||
pub fn for_cascade(url: ServoUrl) -> Self {
|
||||
use values::CssUrl;
|
||||
GenericImage::Url(CssUrl::for_cascade(url))
|
||||
generic::Image::Url(CssUrl::for_cascade(url))
|
||||
}
|
||||
|
||||
/// Parses a `-moz-element(# <element-id>)`.
|
||||
|
@ -220,7 +216,9 @@ impl Parse for Gradient {
|
|||
Some((Shape::Radial, true, CompatMode::Moz))
|
||||
},
|
||||
"-webkit-gradient" => {
|
||||
return input.parse_nested_block(|i| Self::parse_webkit_gradient_argument(context, i));
|
||||
return input.parse_nested_block(|i| {
|
||||
Self::parse_webkit_gradient_argument(context, i)
|
||||
});
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
|
@ -406,7 +404,7 @@ impl Gradient {
|
|||
let second = Point::parse(context, input)?;
|
||||
|
||||
let direction = LineDirection::from_points(first, second);
|
||||
let kind = GenericGradientKind::Linear(direction);
|
||||
let kind = generic::GradientKind::Linear(direction);
|
||||
|
||||
(kind, false)
|
||||
},
|
||||
|
@ -425,22 +423,27 @@ impl Gradient {
|
|||
(true, first_point, first_radius)
|
||||
};
|
||||
|
||||
let shape = GenericEndingShape::Circle(Circle::Radius(Length::from_px(radius.value)));
|
||||
let rad = Circle::Radius(Length::from_px(radius.value));
|
||||
let shape = generic::EndingShape::Circle(rad);
|
||||
let position: Position = point.into();
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
let kind = GenericGradientKind::Radial(shape, GradientPosition::Modern(position), None);
|
||||
let pos = GradientPosition::Modern(position);
|
||||
let kind = generic::GradientKind::Radial(shape, pos, None);
|
||||
(kind, reverse_stops)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
{
|
||||
let kind = GenericGradientKind::Radial(shape, position, None);
|
||||
let kind = generic::GradientKind::Radial(shape, position, None);
|
||||
(kind, reverse_stops)
|
||||
}
|
||||
},
|
||||
_ => return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone()))),
|
||||
_ => {
|
||||
let e = SelectorParseErrorKind::UnexpectedIdent(ident.clone());
|
||||
return Err(input.new_custom_error(e));
|
||||
},
|
||||
};
|
||||
|
||||
let mut items = input.try(|i| {
|
||||
|
@ -459,7 +462,11 @@ impl Gradient {
|
|||
},
|
||||
"from" => Percentage::zero(),
|
||||
"to" => Percentage::hundred(),
|
||||
_ => return Err(i.new_custom_error(StyleParseErrorKind::UnexpectedFunction(function.clone()))),
|
||||
_ => {
|
||||
return Err(i.new_custom_error(
|
||||
StyleParseErrorKind::UnexpectedFunction(function.clone())
|
||||
))
|
||||
},
|
||||
};
|
||||
let color = Color::parse(context, i)?;
|
||||
if color == Color::CurrentColor {
|
||||
|
@ -470,7 +477,7 @@ impl Gradient {
|
|||
if reverse_stops {
|
||||
p.reverse();
|
||||
}
|
||||
Ok(GenericGradientItem::ColorStop(GenericColorStop {
|
||||
Ok(generic::GradientItem::ColorStop(generic::ColorStop {
|
||||
color: color,
|
||||
position: Some(p.into()),
|
||||
}))
|
||||
|
@ -479,11 +486,11 @@ impl Gradient {
|
|||
|
||||
if items.is_empty() {
|
||||
items = vec![
|
||||
GenericGradientItem::ColorStop(GenericColorStop {
|
||||
generic::GradientItem::ColorStop(generic::ColorStop {
|
||||
color: Color::transparent().into(),
|
||||
position: Some(Percentage::zero().into()),
|
||||
}),
|
||||
GenericGradientItem::ColorStop(GenericColorStop {
|
||||
generic::GradientItem::ColorStop(generic::ColorStop {
|
||||
color: Color::transparent().into(),
|
||||
position: Some(Percentage::hundred().into()),
|
||||
}),
|
||||
|
@ -494,7 +501,7 @@ impl Gradient {
|
|||
} else {
|
||||
items.sort_by(|a, b| {
|
||||
match (a, b) {
|
||||
(&GenericGradientItem::ColorStop(ref a), &GenericGradientItem::ColorStop(ref 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);
|
||||
|
@ -512,7 +519,7 @@ impl Gradient {
|
|||
})
|
||||
}
|
||||
|
||||
Ok(GenericGradient {
|
||||
Ok(generic::Gradient {
|
||||
kind: kind,
|
||||
items: items,
|
||||
repeating: false,
|
||||
|
@ -538,7 +545,7 @@ impl GradientKind {
|
|||
_ => LineDirection::Vertical(Y::Top),
|
||||
}
|
||||
};
|
||||
Ok(GenericGradientKind::Linear(direction))
|
||||
Ok(generic::GradientKind::Linear(direction))
|
||||
}
|
||||
|
||||
fn parse_radial<'i, 't>(
|
||||
|
@ -598,7 +605,7 @@ impl GradientKind {
|
|||
}
|
||||
|
||||
let shape = shape.unwrap_or({
|
||||
GenericEndingShape::Ellipse(Ellipse::Extent(ShapeExtent::FarthestCorner))
|
||||
generic::EndingShape::Ellipse(Ellipse::Extent(ShapeExtent::FarthestCorner))
|
||||
});
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -609,23 +616,23 @@ impl GradientKind {
|
|||
*compat_mode = CompatMode::Modern;
|
||||
}
|
||||
let position = moz_position.unwrap_or(LegacyPosition::center());
|
||||
return Ok(GenericGradientKind::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(GenericGradientKind::Radial(shape, GradientPosition::Modern(position), angle));
|
||||
return Ok(generic::GradientKind::Radial(shape, GradientPosition::Modern(position), angle));
|
||||
}
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
{
|
||||
return Ok(GenericGradientKind::Radial(shape, position, angle));
|
||||
return Ok(generic::GradientKind::Radial(shape, position, angle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GenericsLineDirection for LineDirection {
|
||||
impl generic::LineDirection for LineDirection {
|
||||
fn points_downwards(&self, compat_mode: CompatMode) -> bool {
|
||||
match *self {
|
||||
LineDirection::Angle(ref angle) => angle.radians() == PI,
|
||||
|
@ -803,25 +810,25 @@ impl EndingShape {
|
|||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(extent) = input.try(|i| ShapeExtent::parse_with_compat_mode(i, compat_mode)) {
|
||||
if input.try(|i| i.expect_ident_matching("circle")).is_ok() {
|
||||
return Ok(GenericEndingShape::Circle(Circle::Extent(extent)));
|
||||
return Ok(generic::EndingShape::Circle(Circle::Extent(extent)));
|
||||
}
|
||||
let _ = input.try(|i| i.expect_ident_matching("ellipse"));
|
||||
return Ok(GenericEndingShape::Ellipse(Ellipse::Extent(extent)));
|
||||
return Ok(generic::EndingShape::Ellipse(Ellipse::Extent(extent)));
|
||||
}
|
||||
if input.try(|i| i.expect_ident_matching("circle")).is_ok() {
|
||||
if let Ok(extent) = input.try(|i| ShapeExtent::parse_with_compat_mode(i, compat_mode)) {
|
||||
return Ok(GenericEndingShape::Circle(Circle::Extent(extent)));
|
||||
return Ok(generic::EndingShape::Circle(Circle::Extent(extent)));
|
||||
}
|
||||
if compat_mode == CompatMode::Modern {
|
||||
if let Ok(length) = input.try(|i| Length::parse(context, i)) {
|
||||
return Ok(GenericEndingShape::Circle(Circle::Radius(length)));
|
||||
return Ok(generic::EndingShape::Circle(Circle::Radius(length)));
|
||||
}
|
||||
}
|
||||
return Ok(GenericEndingShape::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)) {
|
||||
return Ok(GenericEndingShape::Ellipse(Ellipse::Extent(extent)));
|
||||
return Ok(generic::EndingShape::Ellipse(Ellipse::Extent(extent)));
|
||||
}
|
||||
if compat_mode == CompatMode::Modern {
|
||||
let pair: Result<_, ParseError> = input.try(|i| {
|
||||
|
@ -830,10 +837,10 @@ impl EndingShape {
|
|||
Ok((x, y))
|
||||
});
|
||||
if let Ok((x, y)) = pair {
|
||||
return Ok(GenericEndingShape::Ellipse(Ellipse::Radii(x, y)));
|
||||
return Ok(generic::EndingShape::Ellipse(Ellipse::Radii(x, y)));
|
||||
}
|
||||
}
|
||||
return Ok(GenericEndingShape::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>.
|
||||
|
@ -843,7 +850,7 @@ impl EndingShape {
|
|||
if compat_mode == CompatMode::Modern {
|
||||
let _ = input.try(|i| i.expect_ident_matching("ellipse"));
|
||||
}
|
||||
return Ok(GenericEndingShape::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| {
|
||||
|
@ -851,12 +858,12 @@ impl EndingShape {
|
|||
LengthOrPercentage::parse(context, i)
|
||||
});
|
||||
if let Ok(y) = y {
|
||||
return Ok(GenericEndingShape::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"));
|
||||
}
|
||||
|
||||
return Ok(GenericEndingShape::Circle(Circle::Radius(length)));
|
||||
return Ok(generic::EndingShape::Circle(Circle::Radius(length)));
|
||||
}
|
||||
}
|
||||
input.try(|i| {
|
||||
|
@ -872,7 +879,7 @@ impl EndingShape {
|
|||
}
|
||||
LengthOrPercentage::parse(context, i)?
|
||||
};
|
||||
Ok(GenericEndingShape::Ellipse(Ellipse::Radii(x.into(), y)))
|
||||
Ok(generic::EndingShape::Ellipse(Ellipse::Radii(x.into(), y)))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -903,11 +910,11 @@ impl GradientItem {
|
|||
if seen_stop {
|
||||
if let Ok(hint) = input.try(|i| LengthOrPercentage::parse(context, i)) {
|
||||
seen_stop = false;
|
||||
return Ok(GenericGradientItem::InterpolationHint(hint));
|
||||
return Ok(generic::GradientItem::InterpolationHint(hint));
|
||||
}
|
||||
}
|
||||
seen_stop = true;
|
||||
ColorStop::parse(context, input).map(GenericGradientItem::ColorStop)
|
||||
ColorStop::parse(context, input).map(generic::GradientItem::ColorStop)
|
||||
})?;
|
||||
if !seen_stop || items.len() < 2 {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
|
|
|
@ -26,12 +26,13 @@ use values::specified::calc::CalcNode;
|
|||
pub use properties::animated_properties::TransitionProperty;
|
||||
pub use self::angle::Angle;
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use self::align::{AlignContent, JustifyContent, AlignItems, ContentDistribution, SelfAlignment, JustifyItems};
|
||||
pub use self::align::{AlignContent, AlignItems, AlignSelf, ContentDistribution};
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use self::align::{AlignSelf, JustifySelf};
|
||||
pub use self::align::{SelfAlignment, JustifyContent, JustifyItems, JustifySelf};
|
||||
pub use self::background::{BackgroundRepeat, BackgroundSize};
|
||||
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
||||
pub use self::border::{BorderImageRepeat, BorderImageSideWidth, BorderRadius, BorderSideWidth, BorderSpacing};
|
||||
pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
|
||||
pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing};
|
||||
pub use self::column::ColumnCount;
|
||||
pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVariantAlternates};
|
||||
pub use self::font::{FontFamily, FontLanguageOverride, FontVariationSettings, FontVariantEastAsian};
|
||||
|
|
|
@ -11,20 +11,15 @@ use style_traits::{ParseError, StyleParseErrorKind};
|
|||
use values::computed::{Context, LengthOrPercentage as ComputedLengthOrPercentage};
|
||||
use values::computed::{Percentage as ComputedPercentage, ToComputedValue};
|
||||
use values::computed::transform::TimingFunction as ComputedTimingFunction;
|
||||
use values::generics::transform::{Matrix3D, Transform as GenericTransform};
|
||||
use values::generics::transform::{StepPosition, TimingFunction as GenericTimingFunction, Matrix};
|
||||
use values::generics::transform::{TimingKeyword, TransformOrigin as GenericTransformOrigin};
|
||||
use values::generics::transform::Rotate as GenericRotate;
|
||||
use values::generics::transform::Scale as GenericScale;
|
||||
use values::generics::transform::TransformOperation as GenericTransformOperation;
|
||||
use values::generics::transform::Translate as GenericTranslate;
|
||||
use values::generics::transform as generic;
|
||||
use values::generics::transform::{Matrix, Matrix3D, StepPosition, TimingKeyword};
|
||||
use values::specified::{self, Angle, Number, Length, Integer, LengthOrPercentage};
|
||||
use values::specified::position::{Side, X, Y};
|
||||
|
||||
pub use values::generics::transform::TransformStyle;
|
||||
|
||||
/// A single operation in a specified CSS `transform`
|
||||
pub type TransformOperation = GenericTransformOperation<
|
||||
pub type TransformOperation = generic::TransformOperation<
|
||||
Angle,
|
||||
Number,
|
||||
Length,
|
||||
|
@ -33,10 +28,10 @@ pub type TransformOperation = GenericTransformOperation<
|
|||
>;
|
||||
|
||||
/// A specified CSS `transform`
|
||||
pub type Transform = GenericTransform<TransformOperation>;
|
||||
pub type Transform = generic::Transform<TransformOperation>;
|
||||
|
||||
/// The specified value of a CSS `<transform-origin>`
|
||||
pub type TransformOrigin = GenericTransformOrigin<OriginComponent<X>, OriginComponent<Y>, Length>;
|
||||
pub type TransformOrigin = generic::TransformOrigin<OriginComponent<X>, OriginComponent<Y>, Length>;
|
||||
|
||||
impl Transform {
|
||||
/// Internal parse function for deciding if we wish to accept prefixed values or not
|
||||
|
@ -53,10 +48,10 @@ impl Transform {
|
|||
.try(|input| input.expect_ident_matching("none"))
|
||||
.is_ok()
|
||||
{
|
||||
return Ok(GenericTransform(Vec::new()));
|
||||
return Ok(generic::Transform(Vec::new()));
|
||||
}
|
||||
|
||||
Ok(GenericTransform(Space::parse(input, |input| {
|
||||
Ok(generic::Transform(Space::parse(input, |input| {
|
||||
let function = input.expect_function()?.clone();
|
||||
input.parse_nested_block(|input| {
|
||||
let location = input.current_source_location();
|
||||
|
@ -75,7 +70,7 @@ impl Transform {
|
|||
let e = Number::parse(context, input)?;
|
||||
input.expect_comma()?;
|
||||
let f = Number::parse(context, input)?;
|
||||
Ok(GenericTransformOperation::Matrix(Matrix { a, b, c, d, e, f }))
|
||||
Ok(generic::TransformOperation::Matrix(Matrix { a, b, c, d, e, f }))
|
||||
},
|
||||
"matrix3d" => {
|
||||
let m11 = Number::parse(context, input)?;
|
||||
|
@ -110,7 +105,7 @@ impl Transform {
|
|||
let m43 = Number::parse(context, input)?;
|
||||
input.expect_comma()?;
|
||||
let m44 = Number::parse(context, input)?;
|
||||
Ok(GenericTransformOperation::Matrix3D(Matrix3D {
|
||||
Ok(generic::TransformOperation::Matrix3D(Matrix3D {
|
||||
m11, m12, m13, m14,
|
||||
m21, m22, m23, m24,
|
||||
m31, m32, m33, m34,
|
||||
|
@ -121,22 +116,22 @@ impl Transform {
|
|||
let sx = specified::LengthOrPercentage::parse(context, input)?;
|
||||
if input.try(|input| input.expect_comma()).is_ok() {
|
||||
let sy = specified::LengthOrPercentage::parse(context, input)?;
|
||||
Ok(GenericTransformOperation::Translate(sx, Some(sy)))
|
||||
Ok(generic::TransformOperation::Translate(sx, Some(sy)))
|
||||
} else {
|
||||
Ok(GenericTransformOperation::Translate(sx, None))
|
||||
Ok(generic::TransformOperation::Translate(sx, None))
|
||||
}
|
||||
},
|
||||
"translatex" => {
|
||||
let tx = specified::LengthOrPercentage::parse(context, input)?;
|
||||
Ok(GenericTransformOperation::TranslateX(tx))
|
||||
Ok(generic::TransformOperation::TranslateX(tx))
|
||||
},
|
||||
"translatey" => {
|
||||
let ty = specified::LengthOrPercentage::parse(context, input)?;
|
||||
Ok(GenericTransformOperation::TranslateY(ty))
|
||||
Ok(generic::TransformOperation::TranslateY(ty))
|
||||
},
|
||||
"translatez" => {
|
||||
let tz = specified::Length::parse(context, input)?;
|
||||
Ok(GenericTransformOperation::TranslateZ(tz))
|
||||
Ok(generic::TransformOperation::TranslateZ(tz))
|
||||
},
|
||||
"translate3d" => {
|
||||
let tx = specified::LengthOrPercentage::parse(context, input)?;
|
||||
|
@ -144,28 +139,28 @@ impl Transform {
|
|||
let ty = specified::LengthOrPercentage::parse(context, input)?;
|
||||
input.expect_comma()?;
|
||||
let tz = specified::Length::parse(context, input)?;
|
||||
Ok(GenericTransformOperation::Translate3D(tx, ty, tz))
|
||||
Ok(generic::TransformOperation::Translate3D(tx, ty, tz))
|
||||
},
|
||||
"scale" => {
|
||||
let sx = Number::parse(context, input)?;
|
||||
if input.try(|input| input.expect_comma()).is_ok() {
|
||||
let sy = Number::parse(context, input)?;
|
||||
Ok(GenericTransformOperation::Scale(sx, Some(sy)))
|
||||
Ok(generic::TransformOperation::Scale(sx, Some(sy)))
|
||||
} else {
|
||||
Ok(GenericTransformOperation::Scale(sx, None))
|
||||
Ok(generic::TransformOperation::Scale(sx, None))
|
||||
}
|
||||
},
|
||||
"scalex" => {
|
||||
let sx = Number::parse(context, input)?;
|
||||
Ok(GenericTransformOperation::ScaleX(sx))
|
||||
Ok(generic::TransformOperation::ScaleX(sx))
|
||||
},
|
||||
"scaley" => {
|
||||
let sy = Number::parse(context, input)?;
|
||||
Ok(GenericTransformOperation::ScaleY(sy))
|
||||
Ok(generic::TransformOperation::ScaleY(sy))
|
||||
},
|
||||
"scalez" => {
|
||||
let sz = Number::parse(context, input)?;
|
||||
Ok(GenericTransformOperation::ScaleZ(sz))
|
||||
Ok(generic::TransformOperation::ScaleZ(sz))
|
||||
},
|
||||
"scale3d" => {
|
||||
let sx = Number::parse(context, input)?;
|
||||
|
@ -173,23 +168,23 @@ impl Transform {
|
|||
let sy = Number::parse(context, input)?;
|
||||
input.expect_comma()?;
|
||||
let sz = Number::parse(context, input)?;
|
||||
Ok(GenericTransformOperation::Scale3D(sx, sy, sz))
|
||||
Ok(generic::TransformOperation::Scale3D(sx, sy, sz))
|
||||
},
|
||||
"rotate" => {
|
||||
let theta = specified::Angle::parse_with_unitless(context, input)?;
|
||||
Ok(GenericTransformOperation::Rotate(theta))
|
||||
Ok(generic::TransformOperation::Rotate(theta))
|
||||
},
|
||||
"rotatex" => {
|
||||
let theta = specified::Angle::parse_with_unitless(context, input)?;
|
||||
Ok(GenericTransformOperation::RotateX(theta))
|
||||
Ok(generic::TransformOperation::RotateX(theta))
|
||||
},
|
||||
"rotatey" => {
|
||||
let theta = specified::Angle::parse_with_unitless(context, input)?;
|
||||
Ok(GenericTransformOperation::RotateY(theta))
|
||||
Ok(generic::TransformOperation::RotateY(theta))
|
||||
},
|
||||
"rotatez" => {
|
||||
let theta = specified::Angle::parse_with_unitless(context, input)?;
|
||||
Ok(GenericTransformOperation::RotateZ(theta))
|
||||
Ok(generic::TransformOperation::RotateZ(theta))
|
||||
},
|
||||
"rotate3d" => {
|
||||
let ax = Number::parse(context, input)?;
|
||||
|
@ -200,28 +195,28 @@ impl Transform {
|
|||
input.expect_comma()?;
|
||||
let theta = specified::Angle::parse_with_unitless(context, input)?;
|
||||
// TODO(gw): Check that the axis can be normalized.
|
||||
Ok(GenericTransformOperation::Rotate3D(ax, ay, az, theta))
|
||||
Ok(generic::TransformOperation::Rotate3D(ax, ay, az, theta))
|
||||
},
|
||||
"skew" => {
|
||||
let ax = specified::Angle::parse_with_unitless(context, input)?;
|
||||
if input.try(|input| input.expect_comma()).is_ok() {
|
||||
let ay = specified::Angle::parse_with_unitless(context, input)?;
|
||||
Ok(GenericTransformOperation::Skew(ax, Some(ay)))
|
||||
Ok(generic::TransformOperation::Skew(ax, Some(ay)))
|
||||
} else {
|
||||
Ok(GenericTransformOperation::Skew(ax, None))
|
||||
Ok(generic::TransformOperation::Skew(ax, None))
|
||||
}
|
||||
},
|
||||
"skewx" => {
|
||||
let theta = specified::Angle::parse_with_unitless(context, input)?;
|
||||
Ok(GenericTransformOperation::SkewX(theta))
|
||||
Ok(generic::TransformOperation::SkewX(theta))
|
||||
},
|
||||
"skewy" => {
|
||||
let theta = specified::Angle::parse_with_unitless(context, input)?;
|
||||
Ok(GenericTransformOperation::SkewY(theta))
|
||||
Ok(generic::TransformOperation::SkewY(theta))
|
||||
},
|
||||
"perspective" => {
|
||||
let d = specified::Length::parse_non_negative(context, input)?;
|
||||
Ok(GenericTransformOperation::Perspective(d))
|
||||
Ok(generic::TransformOperation::Perspective(d))
|
||||
},
|
||||
_ => Err(()),
|
||||
};
|
||||
|
@ -253,7 +248,7 @@ pub enum OriginComponent<S> {
|
|||
}
|
||||
|
||||
/// A specified timing function.
|
||||
pub type TimingFunction = GenericTimingFunction<Integer, Number>;
|
||||
pub type TimingFunction = generic::TimingFunction<Integer, Number>;
|
||||
|
||||
impl Parse for TransformOrigin {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
|
@ -367,7 +362,7 @@ fn allow_frames_timing() -> bool {
|
|||
impl Parse for TimingFunction {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(keyword) = input.try(TimingKeyword::parse) {
|
||||
return Ok(GenericTimingFunction::Keyword(keyword));
|
||||
return Ok(generic::TimingFunction::Keyword(keyword));
|
||||
}
|
||||
if let Ok(ident) = input.try(|i| i.expect_ident_cloned()) {
|
||||
let position =
|
||||
|
@ -376,7 +371,7 @@ impl Parse for TimingFunction {
|
|||
"step-end" => StepPosition::End,
|
||||
_ => return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone()))),
|
||||
};
|
||||
return Ok(GenericTimingFunction::Steps(Integer::new(1), position));
|
||||
return Ok(generic::TimingFunction::Steps(Integer::new(1), position));
|
||||
}
|
||||
let location = input.current_source_location();
|
||||
let function = input.expect_function()?.clone();
|
||||
|
@ -395,7 +390,7 @@ impl Parse for TimingFunction {
|
|||
return Err(i.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
Ok(GenericTimingFunction::CubicBezier { x1, y1, x2, y2 })
|
||||
Ok(generic::TimingFunction::CubicBezier { x1, y1, x2, y2 })
|
||||
},
|
||||
"steps" => {
|
||||
let steps = Integer::parse_positive(context, i)?;
|
||||
|
@ -403,12 +398,12 @@ impl Parse for TimingFunction {
|
|||
i.expect_comma()?;
|
||||
StepPosition::parse(i)
|
||||
}).unwrap_or(StepPosition::End);
|
||||
Ok(GenericTimingFunction::Steps(steps, position))
|
||||
Ok(generic::TimingFunction::Steps(steps, position))
|
||||
},
|
||||
"frames" => {
|
||||
if allow_frames_timing() {
|
||||
let frames = Integer::parse_with_minimum(context, i, 2)?;
|
||||
Ok(GenericTimingFunction::Frames(frames))
|
||||
Ok(generic::TimingFunction::Frames(frames))
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
|
@ -425,25 +420,25 @@ impl ToComputedValue for TimingFunction {
|
|||
#[inline]
|
||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||
match *self {
|
||||
GenericTimingFunction::Keyword(keyword) => GenericTimingFunction::Keyword(keyword),
|
||||
GenericTimingFunction::CubicBezier {
|
||||
generic::TimingFunction::Keyword(keyword) => generic::TimingFunction::Keyword(keyword),
|
||||
generic::TimingFunction::CubicBezier {
|
||||
x1,
|
||||
y1,
|
||||
x2,
|
||||
y2,
|
||||
} => {
|
||||
GenericTimingFunction::CubicBezier {
|
||||
generic::TimingFunction::CubicBezier {
|
||||
x1: x1.to_computed_value(context),
|
||||
y1: y1.to_computed_value(context),
|
||||
x2: x2.to_computed_value(context),
|
||||
y2: y2.to_computed_value(context),
|
||||
}
|
||||
},
|
||||
GenericTimingFunction::Steps(steps, position) => {
|
||||
GenericTimingFunction::Steps(steps.to_computed_value(context) as u32, position)
|
||||
generic::TimingFunction::Steps(steps, position) => {
|
||||
generic::TimingFunction::Steps(steps.to_computed_value(context) as u32, position)
|
||||
},
|
||||
GenericTimingFunction::Frames(frames) => {
|
||||
GenericTimingFunction::Frames(frames.to_computed_value(context) as u32)
|
||||
generic::TimingFunction::Frames(frames) => {
|
||||
generic::TimingFunction::Frames(frames.to_computed_value(context) as u32)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -451,32 +446,32 @@ impl ToComputedValue for TimingFunction {
|
|||
#[inline]
|
||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||
match *computed {
|
||||
GenericTimingFunction::Keyword(keyword) => GenericTimingFunction::Keyword(keyword),
|
||||
GenericTimingFunction::CubicBezier {
|
||||
generic::TimingFunction::Keyword(keyword) => generic::TimingFunction::Keyword(keyword),
|
||||
generic::TimingFunction::CubicBezier {
|
||||
ref x1,
|
||||
ref y1,
|
||||
ref x2,
|
||||
ref y2,
|
||||
} => {
|
||||
GenericTimingFunction::CubicBezier {
|
||||
generic::TimingFunction::CubicBezier {
|
||||
x1: Number::from_computed_value(x1),
|
||||
y1: Number::from_computed_value(y1),
|
||||
x2: Number::from_computed_value(x2),
|
||||
y2: Number::from_computed_value(y2),
|
||||
}
|
||||
},
|
||||
GenericTimingFunction::Steps(steps, position) => {
|
||||
GenericTimingFunction::Steps(Integer::from_computed_value(&(steps as i32)), position)
|
||||
generic::TimingFunction::Steps(steps, position) => {
|
||||
generic::TimingFunction::Steps(Integer::from_computed_value(&(steps as i32)), position)
|
||||
},
|
||||
GenericTimingFunction::Frames(frames) => {
|
||||
GenericTimingFunction::Frames(Integer::from_computed_value(&(frames as i32)))
|
||||
generic::TimingFunction::Frames(frames) => {
|
||||
generic::TimingFunction::Frames(Integer::from_computed_value(&(frames as i32)))
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A specified CSS `rotate`
|
||||
pub type Rotate = GenericRotate<Number, Angle>;
|
||||
pub type Rotate = generic::Rotate<Number, Angle>;
|
||||
|
||||
impl Parse for Rotate {
|
||||
fn parse<'i, 't>(
|
||||
|
@ -484,7 +479,7 @@ impl Parse for Rotate {
|
|||
input: &mut Parser<'i, 't>
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(GenericRotate::None);
|
||||
return Ok(generic::Rotate::None);
|
||||
}
|
||||
|
||||
if let Ok(rx) = input.try(|i| Number::parse(context, i)) {
|
||||
|
@ -492,17 +487,17 @@ impl Parse for Rotate {
|
|||
let ry = Number::parse(context, input)?;
|
||||
let rz = Number::parse(context, input)?;
|
||||
let angle = specified::Angle::parse(context, input)?;
|
||||
return Ok(GenericRotate::Rotate3D(rx, ry, rz, angle));
|
||||
return Ok(generic::Rotate::Rotate3D(rx, ry, rz, angle));
|
||||
}
|
||||
|
||||
// 'rotate: <angle>'
|
||||
let angle = specified::Angle::parse(context, input)?;
|
||||
Ok(GenericRotate::Rotate(angle))
|
||||
Ok(generic::Rotate::Rotate(angle))
|
||||
}
|
||||
}
|
||||
|
||||
/// A specified CSS `translate`
|
||||
pub type Translate = GenericTranslate<LengthOrPercentage, Length>;
|
||||
pub type Translate = generic::Translate<LengthOrPercentage, Length>;
|
||||
|
||||
impl Parse for Translate {
|
||||
fn parse<'i, 't>(
|
||||
|
@ -510,27 +505,27 @@ impl Parse for Translate {
|
|||
input: &mut Parser<'i, 't>
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(GenericTranslate::None);
|
||||
return Ok(generic::Translate::None);
|
||||
}
|
||||
|
||||
let tx = specified::LengthOrPercentage::parse(context, input)?;
|
||||
if let Ok(ty) = input.try(|i| specified::LengthOrPercentage::parse(context, i)) {
|
||||
if let Ok(tz) = input.try(|i| specified::Length::parse(context, i)) {
|
||||
// 'translate: <length-percentage> <length-percentage> <length>'
|
||||
return Ok(GenericTranslate::Translate3D(tx, ty, tz));
|
||||
return Ok(generic::Translate::Translate3D(tx, ty, tz));
|
||||
}
|
||||
|
||||
// translate: <length-percentage> <length-percentage>'
|
||||
return Ok(GenericTranslate::Translate(tx, ty));
|
||||
return Ok(generic::Translate::Translate(tx, ty));
|
||||
}
|
||||
|
||||
// 'translate: <length-percentage> '
|
||||
Ok(GenericTranslate::TranslateX(tx))
|
||||
Ok(generic::Translate::TranslateX(tx))
|
||||
}
|
||||
}
|
||||
|
||||
/// A specified CSS `scale`
|
||||
pub type Scale = GenericScale<Number>;
|
||||
pub type Scale = generic::Scale<Number>;
|
||||
|
||||
impl Parse for Scale {
|
||||
fn parse<'i, 't>(
|
||||
|
@ -538,21 +533,21 @@ impl Parse for Scale {
|
|||
input: &mut Parser<'i, 't>
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(GenericScale::None);
|
||||
return Ok(generic::Scale::None);
|
||||
}
|
||||
|
||||
let sx = Number::parse(context, input)?;
|
||||
if let Ok(sy) = input.try(|i| Number::parse(context, i)) {
|
||||
if let Ok(sz) = input.try(|i| Number::parse(context, i)) {
|
||||
// 'scale: <number> <number> <number>'
|
||||
return Ok(GenericScale::Scale3D(sx, sy, sz));
|
||||
return Ok(generic::Scale::Scale3D(sx, sy, sz));
|
||||
}
|
||||
|
||||
// 'scale: <number> <number>'
|
||||
return Ok(GenericScale::Scale(sx, sy));
|
||||
return Ok(generic::Scale::Scale(sx, sy));
|
||||
}
|
||||
|
||||
// 'scale: <number>'
|
||||
Ok(GenericScale::ScaleX(sx))
|
||||
Ok(generic::Scale::ScaleX(sx))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue