mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Rename LengthOrPercentage to LengthPercentage.
It does not represent `<length> | <percentage>`, but `<length-percentage>`, so `LengthOrPercentage` is not the right name. This patch is totally autogenerated using: rg 'LengthOrPercentage' servo | cut -d : -f 1 | sort | uniq > files for file in $(cat files); do sed -i "s#LengthOrPercentage#LengthPercentage#g" $file; done Differential Revision: https://phabricator.services.mozilla.com/D15812
This commit is contained in:
parent
4a31509215
commit
daf1f02feb
61 changed files with 709 additions and 702 deletions
|
@ -22,13 +22,13 @@ use style_traits::{CssWriter, ToCss};
|
|||
ToAnimatedZero,
|
||||
ToComputedValue,
|
||||
)]
|
||||
pub enum BackgroundSize<LengthOrPercentageOrAuto> {
|
||||
pub enum BackgroundSize<LengthPercentageOrAuto> {
|
||||
/// `<width> <height>`
|
||||
Explicit {
|
||||
/// Explicit width.
|
||||
width: LengthOrPercentageOrAuto,
|
||||
width: LengthPercentageOrAuto,
|
||||
/// Explicit height.
|
||||
height: LengthOrPercentageOrAuto,
|
||||
height: LengthPercentageOrAuto,
|
||||
},
|
||||
/// `cover`
|
||||
#[animation(error)]
|
||||
|
@ -38,9 +38,9 @@ pub enum BackgroundSize<LengthOrPercentageOrAuto> {
|
|||
Contain,
|
||||
}
|
||||
|
||||
impl<LengthOrPercentageOrAuto> ToCss for BackgroundSize<LengthOrPercentageOrAuto>
|
||||
impl<LengthPercentageOrAuto> ToCss for BackgroundSize<LengthPercentageOrAuto>
|
||||
where
|
||||
LengthOrPercentageOrAuto: ToCss + IsAuto,
|
||||
LengthPercentageOrAuto: ToCss + IsAuto,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
|
|
|
@ -104,11 +104,11 @@ pub enum ShapeSource<BasicShape, ReferenceBox, ImageOrUrl> {
|
|||
ToComputedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub enum BasicShape<H, V, LengthOrPercentage, NonNegativeLengthOrPercentage> {
|
||||
Inset(#[css(field_bound)] InsetRect<LengthOrPercentage, NonNegativeLengthOrPercentage>),
|
||||
Circle(#[css(field_bound)] Circle<H, V, NonNegativeLengthOrPercentage>),
|
||||
Ellipse(#[css(field_bound)] Ellipse<H, V, NonNegativeLengthOrPercentage>),
|
||||
Polygon(Polygon<LengthOrPercentage>),
|
||||
pub enum BasicShape<H, V, LengthPercentage, NonNegativeLengthPercentage> {
|
||||
Inset(#[css(field_bound)] InsetRect<LengthPercentage, NonNegativeLengthPercentage>),
|
||||
Circle(#[css(field_bound)] Circle<H, V, NonNegativeLengthPercentage>),
|
||||
Ellipse(#[css(field_bound)] Ellipse<H, V, NonNegativeLengthPercentage>),
|
||||
Polygon(Polygon<LengthPercentage>),
|
||||
}
|
||||
|
||||
/// <https://drafts.csswg.org/css-shapes/#funcdef-inset>
|
||||
|
@ -125,9 +125,9 @@ pub enum BasicShape<H, V, LengthOrPercentage, NonNegativeLengthOrPercentage> {
|
|||
ToAnimatedValue,
|
||||
ToComputedValue,
|
||||
)]
|
||||
pub struct InsetRect<LengthOrPercentage, NonNegativeLengthOrPercentage> {
|
||||
pub rect: Rect<LengthOrPercentage>,
|
||||
pub round: Option<BorderRadius<NonNegativeLengthOrPercentage>>,
|
||||
pub struct InsetRect<LengthPercentage, NonNegativeLengthPercentage> {
|
||||
pub rect: Rect<LengthPercentage>,
|
||||
pub round: Option<BorderRadius<NonNegativeLengthPercentage>>,
|
||||
}
|
||||
|
||||
/// <https://drafts.csswg.org/css-shapes/#funcdef-circle>
|
||||
|
@ -145,9 +145,9 @@ pub struct InsetRect<LengthOrPercentage, NonNegativeLengthOrPercentage> {
|
|||
ToAnimatedValue,
|
||||
ToComputedValue,
|
||||
)]
|
||||
pub struct Circle<H, V, NonNegativeLengthOrPercentage> {
|
||||
pub struct Circle<H, V, NonNegativeLengthPercentage> {
|
||||
pub position: Position<H, V>,
|
||||
pub radius: ShapeRadius<NonNegativeLengthOrPercentage>,
|
||||
pub radius: ShapeRadius<NonNegativeLengthPercentage>,
|
||||
}
|
||||
|
||||
/// <https://drafts.csswg.org/css-shapes/#funcdef-ellipse>
|
||||
|
@ -165,10 +165,10 @@ pub struct Circle<H, V, NonNegativeLengthOrPercentage> {
|
|||
ToAnimatedValue,
|
||||
ToComputedValue,
|
||||
)]
|
||||
pub struct Ellipse<H, V, NonNegativeLengthOrPercentage> {
|
||||
pub struct Ellipse<H, V, NonNegativeLengthPercentage> {
|
||||
pub position: Position<H, V>,
|
||||
pub semiaxis_x: ShapeRadius<NonNegativeLengthOrPercentage>,
|
||||
pub semiaxis_y: ShapeRadius<NonNegativeLengthOrPercentage>,
|
||||
pub semiaxis_x: ShapeRadius<NonNegativeLengthPercentage>,
|
||||
pub semiaxis_y: ShapeRadius<NonNegativeLengthPercentage>,
|
||||
}
|
||||
|
||||
/// <https://drafts.csswg.org/css-shapes/#typedef-shape-radius>
|
||||
|
@ -186,8 +186,8 @@ pub struct Ellipse<H, V, NonNegativeLengthOrPercentage> {
|
|||
ToComputedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub enum ShapeRadius<NonNegativeLengthOrPercentage> {
|
||||
Length(NonNegativeLengthOrPercentage),
|
||||
pub enum ShapeRadius<NonNegativeLengthPercentage> {
|
||||
Length(NonNegativeLengthPercentage),
|
||||
#[animation(error)]
|
||||
ClosestSide,
|
||||
#[animation(error)]
|
||||
|
@ -208,13 +208,13 @@ pub enum ShapeRadius<NonNegativeLengthOrPercentage> {
|
|||
ToComputedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub struct Polygon<LengthOrPercentage> {
|
||||
pub struct Polygon<LengthPercentage> {
|
||||
/// The filling rule for a polygon.
|
||||
#[css(skip_if = "fill_is_default")]
|
||||
pub fill: FillRule,
|
||||
/// A collection of (x, y) coordinates to draw the polygon.
|
||||
#[css(iterable)]
|
||||
pub coordinates: Vec<PolygonCoord<LengthOrPercentage>>,
|
||||
pub coordinates: Vec<PolygonCoord<LengthPercentage>>,
|
||||
}
|
||||
|
||||
/// Coordinates for Polygon.
|
||||
|
@ -228,7 +228,7 @@ pub struct Polygon<LengthOrPercentage> {
|
|||
ToComputedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub struct PolygonCoord<LengthOrPercentage>(pub LengthOrPercentage, pub LengthOrPercentage);
|
||||
pub struct PolygonCoord<LengthPercentage>(pub LengthPercentage, pub LengthPercentage);
|
||||
|
||||
// https://drafts.csswg.org/css-shapes/#typedef-fill-rule
|
||||
// NOTE: Basic shapes spec says that these are the only two values, however
|
||||
|
|
|
@ -13,9 +13,9 @@ use style_traits::{CssWriter, ToCss};
|
|||
#[derive(
|
||||
Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
|
||||
)]
|
||||
pub enum BorderImageSideWidth<LengthOrPercentage, Number> {
|
||||
pub enum BorderImageSideWidth<LengthPercentage, Number> {
|
||||
/// `<length-or-percentage>`
|
||||
Length(LengthOrPercentage),
|
||||
Length(LengthPercentage),
|
||||
/// `<number>`
|
||||
Number(Number),
|
||||
/// `auto`
|
||||
|
@ -98,15 +98,15 @@ impl<L> BorderSpacing<L> {
|
|||
ToAnimatedValue,
|
||||
ToComputedValue,
|
||||
)]
|
||||
pub struct BorderRadius<LengthOrPercentage> {
|
||||
pub struct BorderRadius<LengthPercentage> {
|
||||
/// The top left radius.
|
||||
pub top_left: BorderCornerRadius<LengthOrPercentage>,
|
||||
pub top_left: BorderCornerRadius<LengthPercentage>,
|
||||
/// The top right radius.
|
||||
pub top_right: BorderCornerRadius<LengthOrPercentage>,
|
||||
pub top_right: BorderCornerRadius<LengthPercentage>,
|
||||
/// The bottom right radius.
|
||||
pub bottom_right: BorderCornerRadius<LengthOrPercentage>,
|
||||
pub bottom_right: BorderCornerRadius<LengthPercentage>,
|
||||
/// The bottom left radius.
|
||||
pub bottom_left: BorderCornerRadius<LengthOrPercentage>,
|
||||
pub bottom_left: BorderCornerRadius<LengthPercentage>,
|
||||
}
|
||||
|
||||
impl<L> BorderRadius<L> {
|
||||
|
|
|
@ -19,7 +19,7 @@ use crate::values::animated::ToAnimatedZero;
|
|||
ToComputedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub enum VerticalAlign<LengthOrPercentage> {
|
||||
pub enum VerticalAlign<LengthPercentage> {
|
||||
/// `baseline`
|
||||
Baseline,
|
||||
/// `sub`
|
||||
|
@ -40,7 +40,7 @@ pub enum VerticalAlign<LengthOrPercentage> {
|
|||
#[cfg(feature = "gecko")]
|
||||
MozMiddleWithBaseline,
|
||||
/// `<length-percentage>`
|
||||
Length(LengthOrPercentage),
|
||||
Length(LengthPercentage),
|
||||
}
|
||||
|
||||
impl<L> VerticalAlign<L> {
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
/// A generic value for scroll snap points.
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
|
||||
pub enum ScrollSnapPoint<LengthOrPercentage> {
|
||||
pub enum ScrollSnapPoint<LengthPercentage> {
|
||||
/// `none`
|
||||
None,
|
||||
/// `repeat(<length-or-percentage>)`
|
||||
#[css(function)]
|
||||
Repeat(LengthOrPercentage),
|
||||
Repeat(LengthPercentage),
|
||||
}
|
||||
|
||||
impl<L> ScrollSnapPoint<L> {
|
||||
|
|
|
@ -482,11 +482,11 @@ impl<L: Clone> TrackRepeat<L, specified::Integer> {
|
|||
|
||||
/// Track list values. Can be <track-size> or <track-repeat>
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
|
||||
pub enum TrackListValue<LengthOrPercentage, Integer> {
|
||||
pub enum TrackListValue<LengthPercentage, Integer> {
|
||||
/// A <track-size> value.
|
||||
TrackSize(TrackSize<LengthOrPercentage>),
|
||||
TrackSize(TrackSize<LengthPercentage>),
|
||||
/// A <track-repeat> value.
|
||||
TrackRepeat(TrackRepeat<LengthOrPercentage, Integer>),
|
||||
TrackRepeat(TrackRepeat<LengthPercentage, Integer>),
|
||||
}
|
||||
|
||||
/// The type of a `<track-list>` as determined during parsing.
|
||||
|
@ -515,7 +515,7 @@ pub enum TrackListType {
|
|||
///
|
||||
/// <https://drafts.csswg.org/css-grid/#typedef-track-list>
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo)]
|
||||
pub struct TrackList<LengthOrPercentage, Integer> {
|
||||
pub struct TrackList<LengthPercentage, Integer> {
|
||||
/// The type of this `<track-list>` (auto, explicit or general).
|
||||
///
|
||||
/// In order to avoid parsing the same value multiple times, this does a single traversal
|
||||
|
@ -523,7 +523,7 @@ pub struct TrackList<LengthOrPercentage, Integer> {
|
|||
#[css(skip)]
|
||||
pub list_type: TrackListType,
|
||||
/// A vector of `<track-size> | <track-repeat>` values.
|
||||
pub values: Vec<TrackListValue<LengthOrPercentage, Integer>>,
|
||||
pub values: Vec<TrackListValue<LengthPercentage, Integer>>,
|
||||
/// `<line-names>` accompanying `<track-size> | <track-repeat>` values.
|
||||
///
|
||||
/// If there's no `<line-names>`, then it's represented by an empty vector.
|
||||
|
@ -531,7 +531,7 @@ pub struct TrackList<LengthOrPercentage, Integer> {
|
|||
/// length is always one value more than that of the `<track-size>`.
|
||||
pub line_names: Box<[Box<[CustomIdent]>]>,
|
||||
/// `<auto-repeat>` value. There can only be one `<auto-repeat>` in a TrackList.
|
||||
pub auto_repeat: Option<TrackRepeat<LengthOrPercentage, Integer>>,
|
||||
pub auto_repeat: Option<TrackRepeat<LengthPercentage, Integer>>,
|
||||
}
|
||||
|
||||
impl<L: ToCss, I: ToCss> ToCss for TrackList<L, I> {
|
||||
|
|
|
@ -37,11 +37,11 @@ pub enum Image<Gradient, MozImageRect, ImageUrl> {
|
|||
/// A CSS gradient.
|
||||
/// <https://drafts.csswg.org/css-images/#gradients>
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
pub struct Gradient<LineDirection, Length, LengthOrPercentage, Position, Color, Angle> {
|
||||
pub struct Gradient<LineDirection, Length, LengthPercentage, Position, Color, Angle> {
|
||||
/// Gradients can be linear or radial.
|
||||
pub kind: GradientKind<LineDirection, Length, LengthOrPercentage, Position, Angle>,
|
||||
pub kind: GradientKind<LineDirection, Length, LengthPercentage, Position, Angle>,
|
||||
/// The color stops and interpolation hints.
|
||||
pub items: Vec<GradientItem<Color, LengthOrPercentage>>,
|
||||
pub items: Vec<GradientItem<Color, LengthPercentage>>,
|
||||
/// True if this is a repeating gradient.
|
||||
pub repeating: bool,
|
||||
/// Compatibility mode.
|
||||
|
@ -61,12 +61,12 @@ pub enum CompatMode {
|
|||
|
||||
/// A gradient kind.
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
pub enum GradientKind<LineDirection, Length, LengthOrPercentage, Position, Angle> {
|
||||
pub enum GradientKind<LineDirection, Length, LengthPercentage, Position, Angle> {
|
||||
/// A linear gradient.
|
||||
Linear(LineDirection),
|
||||
/// A radial gradient.
|
||||
Radial(
|
||||
EndingShape<Length, LengthOrPercentage>,
|
||||
EndingShape<Length, LengthPercentage>,
|
||||
Position,
|
||||
Option<Angle>,
|
||||
),
|
||||
|
@ -74,11 +74,11 @@ pub enum GradientKind<LineDirection, Length, LengthOrPercentage, Position, Angle
|
|||
|
||||
/// A radial gradient's ending shape.
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum EndingShape<Length, LengthOrPercentage> {
|
||||
pub enum EndingShape<Length, LengthPercentage> {
|
||||
/// A circular gradient.
|
||||
Circle(Circle<Length>),
|
||||
/// An elliptic gradient.
|
||||
Ellipse(Ellipse<LengthOrPercentage>),
|
||||
Ellipse(Ellipse<LengthPercentage>),
|
||||
}
|
||||
|
||||
/// A circle shape.
|
||||
|
@ -92,9 +92,9 @@ pub enum Circle<Length> {
|
|||
|
||||
/// An ellipse shape.
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum Ellipse<LengthOrPercentage> {
|
||||
pub enum Ellipse<LengthPercentage> {
|
||||
/// An ellipse pair of radii.
|
||||
Radii(LengthOrPercentage, LengthOrPercentage),
|
||||
Radii(LengthPercentage, LengthPercentage),
|
||||
/// An ellipse extent.
|
||||
Extent(ShapeExtent),
|
||||
}
|
||||
|
@ -115,21 +115,21 @@ pub enum ShapeExtent {
|
|||
/// A gradient item.
|
||||
/// <https://drafts.csswg.org/css-images-4/#color-stop-syntax>
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum GradientItem<Color, LengthOrPercentage> {
|
||||
pub enum GradientItem<Color, LengthPercentage> {
|
||||
/// A color stop.
|
||||
ColorStop(ColorStop<Color, LengthOrPercentage>),
|
||||
ColorStop(ColorStop<Color, LengthPercentage>),
|
||||
/// An interpolation hint.
|
||||
InterpolationHint(LengthOrPercentage),
|
||||
InterpolationHint(LengthPercentage),
|
||||
}
|
||||
|
||||
/// A color stop.
|
||||
/// <https://drafts.csswg.org/css-images/#typedef-color-stop-list>
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
pub struct ColorStop<Color, LengthOrPercentage> {
|
||||
pub struct ColorStop<Color, LengthPercentage> {
|
||||
/// The color of this stop.
|
||||
pub color: Color,
|
||||
/// The position of this stop.
|
||||
pub position: Option<LengthOrPercentage>,
|
||||
pub position: Option<LengthPercentage>,
|
||||
}
|
||||
|
||||
/// Specified values for a paint worklet.
|
||||
|
|
|
@ -26,8 +26,8 @@ use crate::values::computed::ExtremumLength;
|
|||
ToComputedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub enum MozLength<LengthOrPercentageOrAuto> {
|
||||
LengthOrPercentageOrAuto(LengthOrPercentageOrAuto),
|
||||
pub enum MozLength<LengthPercentageOrAuto> {
|
||||
LengthPercentageOrAuto(LengthPercentageOrAuto),
|
||||
#[animation(error)]
|
||||
ExtremumLength(ExtremumLength),
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ pub enum MozLength<LengthOrPercentageOrAuto> {
|
|||
ToComputedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub enum MaxLength<LengthOrPercentageOrNone> {
|
||||
LengthOrPercentageOrNone(LengthOrPercentageOrNone),
|
||||
pub enum MaxLength<LengthPercentageOrNone> {
|
||||
LengthPercentageOrNone(LengthPercentageOrNone),
|
||||
#[animation(error)]
|
||||
ExtremumLength(ExtremumLength),
|
||||
}
|
||||
|
|
|
@ -142,28 +142,28 @@ impl<ColorType: Parse, UrlPaintServer: Parse> Parse for SVGPaint<ColorType, UrlP
|
|||
ToComputedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub enum SvgLengthOrPercentageOrNumber<LengthOrPercentage, Number> {
|
||||
pub enum SvgLengthPercentageOrNumber<LengthPercentage, Number> {
|
||||
/// <length> | <percentage>
|
||||
LengthOrPercentage(LengthOrPercentage),
|
||||
LengthPercentage(LengthPercentage),
|
||||
/// <number>
|
||||
Number(Number),
|
||||
}
|
||||
|
||||
/// Parsing the SvgLengthOrPercentageOrNumber. At first, we need to parse number
|
||||
/// Parsing the SvgLengthPercentageOrNumber. At first, we need to parse number
|
||||
/// since prevent converting to the length.
|
||||
impl<LengthOrPercentageType: Parse, NumberType: Parse> Parse
|
||||
for SvgLengthOrPercentageOrNumber<LengthOrPercentageType, NumberType>
|
||||
impl<LengthPercentageType: Parse, NumberType: Parse> Parse
|
||||
for SvgLengthPercentageOrNumber<LengthPercentageType, NumberType>
|
||||
{
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(num) = input.try(|i| NumberType::parse(context, i)) {
|
||||
return Ok(SvgLengthOrPercentageOrNumber::Number(num));
|
||||
return Ok(SvgLengthPercentageOrNumber::Number(num));
|
||||
}
|
||||
|
||||
let lop = LengthOrPercentageType::parse(context, input)?;
|
||||
Ok(SvgLengthOrPercentageOrNumber::LengthOrPercentage(lop))
|
||||
let lop = LengthPercentageType::parse(context, input)?;
|
||||
Ok(SvgLengthPercentageOrNumber::LengthPercentage(lop))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ impl<V> ToAnimatedZero for Spacing<V> {
|
|||
ToAnimatedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub enum LineHeight<Number, LengthOrPercentage> {
|
||||
pub enum LineHeight<Number, LengthPercentage> {
|
||||
/// `normal`
|
||||
Normal,
|
||||
/// `-moz-block-height`
|
||||
|
@ -132,7 +132,7 @@ pub enum LineHeight<Number, LengthOrPercentage> {
|
|||
/// `<number>`
|
||||
Number(Number),
|
||||
/// `<length-or-percentage>`
|
||||
Length(LengthOrPercentage),
|
||||
Length(LengthPercentage),
|
||||
}
|
||||
|
||||
impl<N, L> ToAnimatedZero for LineHeight<N, L> {
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
//! Generic types for CSS values that are related to transformations.
|
||||
|
||||
use crate::values::computed::length::Length as ComputedLength;
|
||||
use crate::values::computed::length::LengthOrPercentage as ComputedLengthOrPercentage;
|
||||
use crate::values::computed::length::LengthPercentage as ComputedLengthPercentage;
|
||||
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::specified::length::LengthPercentage as SpecifiedLengthPercentage;
|
||||
use crate::values::{computed, CSSFloat};
|
||||
use app_units::Au;
|
||||
use euclid::{self, Rect, Transform3D};
|
||||
|
@ -105,7 +105,7 @@ impl<H, V, D> TransformOrigin<H, V, D> {
|
|||
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
|
||||
/// A single operation in the list of a `transform` value
|
||||
pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage> {
|
||||
pub enum TransformOperation<Angle, Number, Length, Integer, LengthPercentage> {
|
||||
/// Represents a 2D 2x3 matrix.
|
||||
Matrix(Matrix<Number>),
|
||||
/// Represents a 3D 4x4 matrix.
|
||||
|
@ -125,19 +125,19 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>
|
|||
SkewY(Angle),
|
||||
/// translate(x, y) or translate(x)
|
||||
#[css(comma, function)]
|
||||
Translate(LengthOrPercentage, Option<LengthOrPercentage>),
|
||||
Translate(LengthPercentage, Option<LengthPercentage>),
|
||||
/// translateX(x)
|
||||
#[css(function = "translateX")]
|
||||
TranslateX(LengthOrPercentage),
|
||||
TranslateX(LengthPercentage),
|
||||
/// translateY(y)
|
||||
#[css(function = "translateY")]
|
||||
TranslateY(LengthOrPercentage),
|
||||
TranslateY(LengthPercentage),
|
||||
/// translateZ(z)
|
||||
#[css(function = "translateZ")]
|
||||
TranslateZ(Length),
|
||||
/// translate3d(x, y, z)
|
||||
#[css(comma, function = "translate3d")]
|
||||
Translate3D(LengthOrPercentage, LengthOrPercentage, Length),
|
||||
Translate3D(LengthPercentage, LengthPercentage, Length),
|
||||
/// A 2D scaling factor.
|
||||
///
|
||||
/// `scale(2)` is parsed as `Scale(Number::new(2.0), None)` and is equivalent to
|
||||
|
@ -192,8 +192,8 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>
|
|||
#[css(comma, function = "interpolatematrix")]
|
||||
InterpolateMatrix {
|
||||
from_list:
|
||||
Transform<TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>>,
|
||||
to_list: Transform<TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>>,
|
||||
Transform<TransformOperation<Angle, Number, Length, Integer, LengthPercentage>>,
|
||||
to_list: Transform<TransformOperation<Angle, Number, Length, Integer, LengthPercentage>>,
|
||||
progress: computed::Percentage,
|
||||
},
|
||||
/// A intermediate type for accumulation of mismatched transform lists.
|
||||
|
@ -201,8 +201,8 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>
|
|||
#[css(comma, function = "accumulatematrix")]
|
||||
AccumulateMatrix {
|
||||
from_list:
|
||||
Transform<TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>>,
|
||||
to_list: Transform<TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>>,
|
||||
Transform<TransformOperation<Angle, Number, Length, Integer, LengthPercentage>>,
|
||||
to_list: Transform<TransformOperation<Angle, Number, Length, Integer, LengthPercentage>>,
|
||||
count: Integer,
|
||||
},
|
||||
}
|
||||
|
@ -211,8 +211,8 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>
|
|||
/// A value of the `transform` property
|
||||
pub struct Transform<T>(#[css(if_empty = "none", iterable)] pub Vec<T>);
|
||||
|
||||
impl<Angle, Number, Length, Integer, LengthOrPercentage>
|
||||
TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>
|
||||
impl<Angle, Number, Length, Integer, LengthPercentage>
|
||||
TransformOperation<Angle, Number, Length, Integer, LengthPercentage>
|
||||
{
|
||||
/// Check if it is any rotate function.
|
||||
pub fn is_rotate(&self) -> bool {
|
||||
|
@ -263,13 +263,13 @@ impl ToAbsoluteLength for SpecifiedLength {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToAbsoluteLength for SpecifiedLengthOrPercentage {
|
||||
impl ToAbsoluteLength for SpecifiedLengthPercentage {
|
||||
// This returns Err(()) if there is any relative length or percentage. We use this when
|
||||
// parsing a transform list of DOMMatrix because we want to return a DOM Exception
|
||||
// if there is relative length.
|
||||
#[inline]
|
||||
fn to_pixel_length(&self, _containing_len: Option<Au>) -> Result<CSSFloat, ()> {
|
||||
use self::SpecifiedLengthOrPercentage::*;
|
||||
use self::SpecifiedLengthPercentage::*;
|
||||
match *self {
|
||||
Length(len) => len.to_computed_pixel_length_without_context(),
|
||||
Calc(ref calc) => calc.to_computed_pixel_length_without_context(),
|
||||
|
@ -285,7 +285,7 @@ impl ToAbsoluteLength for ComputedLength {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToAbsoluteLength for ComputedLengthOrPercentage {
|
||||
impl ToAbsoluteLength for ComputedLengthPercentage {
|
||||
#[inline]
|
||||
fn to_pixel_length(&self, containing_len: Option<Au>) -> Result<CSSFloat, ()> {
|
||||
match containing_len {
|
||||
|
@ -633,18 +633,18 @@ impl<Number: ToCss + PartialEq> ToCss for Scale<Number> {
|
|||
/// A value of the `Translate` property
|
||||
///
|
||||
/// <https://drafts.csswg.org/css-transforms-2/#individual-transforms>
|
||||
pub enum Translate<LengthOrPercentage, Length> {
|
||||
pub enum Translate<LengthPercentage, Length> {
|
||||
/// 'none'
|
||||
None,
|
||||
/// '<length-percentage>' or '<length-percentage> <length-percentage>'
|
||||
Translate(LengthOrPercentage, LengthOrPercentage),
|
||||
Translate(LengthPercentage, LengthPercentage),
|
||||
/// '<length-percentage> <length-percentage> <length>'
|
||||
Translate3D(LengthOrPercentage, LengthOrPercentage, Length),
|
||||
Translate3D(LengthPercentage, LengthPercentage, Length),
|
||||
}
|
||||
|
||||
/// A trait to check if this is a zero length.
|
||||
/// An alternative way is use num_traits::Zero. However, in order to implement num_traits::Zero,
|
||||
/// we also have to implement Add, which may be complicated for LengthOrPercentage::Calc.
|
||||
/// we also have to implement Add, which may be complicated for LengthPercentage::Calc.
|
||||
/// We could do this if other types also need it. If so, we could drop this trait.
|
||||
pub trait IsZeroLength {
|
||||
/// Returns true if this is a zero length.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue