mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Run rustfmt on selectors, servo_arc, and style.
This was generated with: ./mach cargo fmt --package selectors && ./mach cargo fmt --package servo_arc && ./mach cargo fmt --package style Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
This commit is contained in:
parent
f7ae1a37e3
commit
c99bcdd4b8
181 changed files with 9981 additions and 7933 deletions
|
@ -5,15 +5,15 @@
|
|||
//! Generic types for CSS values related to backgrounds.
|
||||
|
||||
/// A generic value for the `background-size` property.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)]
|
||||
#[derive(MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToComputedValue, ToCss)]
|
||||
pub enum BackgroundSize<LengthOrPercentageOrAuto> {
|
||||
/// `<width> <height>`
|
||||
Explicit {
|
||||
/// Explicit width.
|
||||
width: LengthOrPercentageOrAuto,
|
||||
/// Explicit height.
|
||||
height: LengthOrPercentageOrAuto
|
||||
height: LengthOrPercentageOrAuto,
|
||||
},
|
||||
/// `cover`
|
||||
#[animation(error)]
|
||||
|
|
|
@ -32,8 +32,7 @@ pub type FloatAreaShape<BasicShape, Image> = ShapeSource<BasicShape, ShapeBox, I
|
|||
/// https://drafts.csswg.org/css-shapes-1/#typedef-shape-box
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Animate, Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq)]
|
||||
#[derive(ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum ShapeBox {
|
||||
MarginBox,
|
||||
BorderBox,
|
||||
|
@ -48,10 +47,7 @@ pub enum ShapeBox {
|
|||
pub enum ShapeSource<BasicShape, ReferenceBox, ImageOrUrl> {
|
||||
#[animation(error)]
|
||||
ImageOrUrl(ImageOrUrl),
|
||||
Shape(
|
||||
BasicShape,
|
||||
Option<ReferenceBox>,
|
||||
),
|
||||
Shape(BasicShape, Option<ReferenceBox>),
|
||||
#[animation(error)]
|
||||
Box(ReferenceBox),
|
||||
#[animation(error)]
|
||||
|
@ -59,8 +55,8 @@ pub enum ShapeSource<BasicShape, ReferenceBox, ImageOrUrl> {
|
|||
}
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToComputedValue,
|
||||
ToCss)]
|
||||
pub enum BasicShape<H, V, LengthOrPercentage> {
|
||||
Inset(#[css(field_bound)] InsetRect<LengthOrPercentage>),
|
||||
Circle(#[css(field_bound)] Circle<H, V, LengthOrPercentage>),
|
||||
|
@ -78,7 +74,8 @@ pub struct InsetRect<LengthOrPercentage> {
|
|||
|
||||
/// <https://drafts.csswg.org/css-shapes/#funcdef-circle>
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToComputedValue)]
|
||||
pub struct Circle<H, V, LengthOrPercentage> {
|
||||
pub position: Position<H, V>,
|
||||
pub radius: ShapeRadius<LengthOrPercentage>,
|
||||
|
@ -86,7 +83,8 @@ pub struct Circle<H, V, LengthOrPercentage> {
|
|||
|
||||
/// <https://drafts.csswg.org/css-shapes/#funcdef-ellipse>
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToComputedValue)]
|
||||
pub struct Ellipse<H, V, LengthOrPercentage> {
|
||||
pub position: Position<H, V>,
|
||||
pub semiaxis_x: ShapeRadius<LengthOrPercentage>,
|
||||
|
@ -95,8 +93,8 @@ pub struct Ellipse<H, V, LengthOrPercentage> {
|
|||
|
||||
/// <https://drafts.csswg.org/css-shapes/#typedef-shape-radius>
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToComputedValue, ToCss)]
|
||||
pub enum ShapeRadius<LengthOrPercentage> {
|
||||
Length(LengthOrPercentage),
|
||||
#[animation(error)]
|
||||
|
@ -122,8 +120,7 @@ pub struct Polygon<LengthOrPercentage> {
|
|||
// says that it can also be `inherit`
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq)]
|
||||
#[derive(ToComputedValue, ToCss)]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum FillRule {
|
||||
Nonzero,
|
||||
Evenodd,
|
||||
|
@ -141,7 +138,8 @@ where
|
|||
(
|
||||
&ShapeSource::Shape(ref this, ref this_box),
|
||||
&ShapeSource::Shape(ref other, ref other_box),
|
||||
) if this_box == other_box => {
|
||||
) if this_box == other_box =>
|
||||
{
|
||||
this.compute_squared_distance(other)
|
||||
},
|
||||
_ => Err(()),
|
||||
|
@ -156,7 +154,8 @@ impl<B, T, U> ToAnimatedZero for ShapeSource<B, T, U> {
|
|||
}
|
||||
|
||||
impl<L> ToCss for InsetRect<L>
|
||||
where L: ToCss + PartialEq
|
||||
where
|
||||
L: ToCss + PartialEq,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
|
@ -174,7 +173,9 @@ impl<L> ToCss for InsetRect<L>
|
|||
|
||||
impl<L> Default for ShapeRadius<L> {
|
||||
#[inline]
|
||||
fn default() -> Self { ShapeRadius::ClosestSide }
|
||||
fn default() -> Self {
|
||||
ShapeRadius::ClosestSide
|
||||
}
|
||||
}
|
||||
|
||||
impl<L> Animate for Polygon<L>
|
||||
|
@ -188,13 +189,20 @@ where
|
|||
if self.coordinates.len() != other.coordinates.len() {
|
||||
return Err(());
|
||||
}
|
||||
let coordinates = self.coordinates.iter().zip(other.coordinates.iter()).map(|(this, other)| {
|
||||
Ok((
|
||||
this.0.animate(&other.0, procedure)?,
|
||||
this.1.animate(&other.1, procedure)?,
|
||||
))
|
||||
}).collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(Polygon { fill: self.fill, coordinates })
|
||||
let coordinates = self.coordinates
|
||||
.iter()
|
||||
.zip(other.coordinates.iter())
|
||||
.map(|(this, other)| {
|
||||
Ok((
|
||||
this.0.animate(&other.0, procedure)?,
|
||||
this.1.animate(&other.1, procedure)?,
|
||||
))
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(Polygon {
|
||||
fill: self.fill,
|
||||
coordinates,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,11 +217,15 @@ where
|
|||
if self.coordinates.len() != other.coordinates.len() {
|
||||
return Err(());
|
||||
}
|
||||
self.coordinates.iter().zip(other.coordinates.iter()).map(|(this, other)| {
|
||||
let d1 = this.0.compute_squared_distance(&other.0)?;
|
||||
let d2 = this.1.compute_squared_distance(&other.1)?;
|
||||
Ok(d1 + d2)
|
||||
}).sum()
|
||||
self.coordinates
|
||||
.iter()
|
||||
.zip(other.coordinates.iter())
|
||||
.map(|(this, other)| {
|
||||
let d1 = this.0.compute_squared_distance(&other.0)?;
|
||||
let d2 = this.1.compute_squared_distance(&other.1)?;
|
||||
Ok(d1 + d2)
|
||||
})
|
||||
.sum()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,5 +256,7 @@ impl<L: ToCss> ToCss for Polygon<L> {
|
|||
|
||||
impl Default for FillRule {
|
||||
#[inline]
|
||||
fn default() -> Self { FillRule::Nonzero }
|
||||
fn default() -> Self {
|
||||
FillRule::Nonzero
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ pub struct BorderImageSlice<NumberOrPercentage> {
|
|||
}
|
||||
|
||||
/// A generic value for the `border-*-radius` longhand properties.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)]
|
||||
#[derive(MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToComputedValue, ToCss)]
|
||||
pub struct BorderCornerRadius<L>(#[css(field_bound)] pub Size<L>);
|
||||
|
||||
impl<L> BorderCornerRadius<L> {
|
||||
|
@ -42,8 +42,8 @@ impl<L> BorderCornerRadius<L> {
|
|||
}
|
||||
|
||||
/// A generic value for the `border-spacing` property.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub struct BorderSpacing<L>(#[css(field_bound)] pub Size<L>);
|
||||
|
||||
impl<L> BorderSpacing<L> {
|
||||
|
@ -56,8 +56,8 @@ impl<L> BorderSpacing<L> {
|
|||
/// A generic value for `border-radius`, `outline-radius` and `inset()`.
|
||||
///
|
||||
/// <https://drafts.csswg.org/css-backgrounds-3/#border-radius>
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)]
|
||||
#[derive(MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToComputedValue)]
|
||||
pub struct BorderRadius<LengthOrPercentage> {
|
||||
/// The top left radius.
|
||||
pub top_left: BorderCornerRadius<LengthOrPercentage>,
|
||||
|
@ -70,7 +70,8 @@ pub struct BorderRadius<LengthOrPercentage> {
|
|||
}
|
||||
|
||||
impl<N> From<N> for BorderImageSlice<N>
|
||||
where N: Clone,
|
||||
where
|
||||
N: Clone,
|
||||
{
|
||||
#[inline]
|
||||
fn from(value: N) -> Self {
|
||||
|
@ -82,7 +83,8 @@ impl<N> From<N> for BorderImageSlice<N>
|
|||
}
|
||||
|
||||
impl<N> ToCss for BorderImageSlice<N>
|
||||
where N: PartialEq + ToCss,
|
||||
where
|
||||
N: PartialEq + ToCss,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
|
@ -103,7 +105,7 @@ impl<L> BorderRadius<L> {
|
|||
tl: BorderCornerRadius<L>,
|
||||
tr: BorderCornerRadius<L>,
|
||||
br: BorderCornerRadius<L>,
|
||||
bl: BorderCornerRadius<L>
|
||||
bl: BorderCornerRadius<L>,
|
||||
) -> Self {
|
||||
BorderRadius {
|
||||
top_left: tl,
|
||||
|
@ -115,7 +117,8 @@ impl<L> BorderRadius<L> {
|
|||
}
|
||||
|
||||
impl<L> BorderRadius<L>
|
||||
where L: PartialEq + ToCss
|
||||
where
|
||||
L: PartialEq + ToCss,
|
||||
{
|
||||
/// Serialises two given rects following the syntax of the `border-radius``
|
||||
/// property.
|
||||
|
@ -128,7 +131,9 @@ impl<L> BorderRadius<L>
|
|||
W: Write,
|
||||
{
|
||||
widths.to_css(dest)?;
|
||||
if widths.0 != heights.0 || widths.1 != heights.1 || widths.2 != heights.2 || widths.3 != heights.3 {
|
||||
if widths.0 != heights.0 || widths.1 != heights.1 || widths.2 != heights.2 ||
|
||||
widths.3 != heights.3
|
||||
{
|
||||
dest.write_str(" / ")?;
|
||||
heights.to_css(dest)?;
|
||||
}
|
||||
|
@ -137,7 +142,8 @@ impl<L> BorderRadius<L>
|
|||
}
|
||||
|
||||
impl<L> ToCss for BorderRadius<L>
|
||||
where L: PartialEq + ToCss
|
||||
where
|
||||
L: PartialEq + ToCss,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
use values::animated::ToAnimatedZero;
|
||||
|
||||
/// A generic value for the `vertical-align` property.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToComputedValue, ToCss)]
|
||||
pub enum VerticalAlign<LengthOrPercentage> {
|
||||
/// `baseline`
|
||||
Baseline,
|
||||
|
@ -57,8 +57,8 @@ pub enum AnimationIterationCount<Number> {
|
|||
}
|
||||
|
||||
/// A generic value for the `perspective` property.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub enum Perspective<NonNegativeLength> {
|
||||
/// A non-negative length.
|
||||
Length(NonNegativeLength),
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
//! Generic types for the column properties.
|
||||
|
||||
/// A generic type for `column-count` values.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub enum ColumnCount<PositiveInteger> {
|
||||
/// A positive integer.
|
||||
Integer(PositiveInteger),
|
||||
|
|
|
@ -75,7 +75,7 @@ where
|
|||
W: fmt::Write,
|
||||
{
|
||||
if self.0.is_empty() {
|
||||
return dest.write_str("none")
|
||||
return dest.write_str("none");
|
||||
}
|
||||
|
||||
let mut first = true;
|
||||
|
|
|
@ -10,8 +10,7 @@ use style_traits::values::{CssWriter, SequenceWriter, ToCss};
|
|||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
/// A generic value for a single `box-shadow`.
|
||||
#[derive(Animate, Clone, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToAnimatedValue, ToAnimatedZero)]
|
||||
#[derive(Animate, Clone, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, ToAnimatedZero)]
|
||||
pub struct BoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength> {
|
||||
/// The base shadow.
|
||||
pub base: SimpleShadow<Color, SizeLength, BlurShapeLength>,
|
||||
|
@ -24,8 +23,8 @@ pub struct BoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength> {
|
|||
|
||||
/// A generic value for a single `filter`.
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToAnimatedValue, ToComputedValue, ToCss)]
|
||||
#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedValue,
|
||||
ToComputedValue, ToCss)]
|
||||
pub enum Filter<Angle, Factor, Length, DropShadow> {
|
||||
/// `blur(<length>)`
|
||||
#[css(function)]
|
||||
|
@ -67,8 +66,8 @@ pub enum Filter<Angle, Factor, Length, DropShadow> {
|
|||
///
|
||||
/// Contrary to the canonical order from the spec, the color is serialised
|
||||
/// first, like in Gecko and Webkit.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug)]
|
||||
#[derive(MallocSizeOf, PartialEq, ToAnimatedValue, ToAnimatedZero, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedValue,
|
||||
ToAnimatedZero, ToCss)]
|
||||
pub struct SimpleShadow<Color, SizeLength, ShapeLength> {
|
||||
/// Color.
|
||||
pub color: Color,
|
||||
|
@ -80,10 +79,8 @@ pub struct SimpleShadow<Color, SizeLength, ShapeLength> {
|
|||
pub blur: ShapeLength,
|
||||
}
|
||||
|
||||
impl<Color, SizeLength, BlurShapeLength, ShapeLength> ToCss for BoxShadow<Color,
|
||||
SizeLength,
|
||||
BlurShapeLength,
|
||||
ShapeLength>
|
||||
impl<Color, SizeLength, BlurShapeLength, ShapeLength> ToCss
|
||||
for BoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength>
|
||||
where
|
||||
Color: ToCss,
|
||||
SizeLength: ToCss,
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
/// A generic value for the `flex-basis` property.
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq)]
|
||||
#[derive(ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq, ToAnimatedValue,
|
||||
ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub enum FlexBasis<Width> {
|
||||
/// `content`
|
||||
Content,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! Generic types for font stuff.
|
||||
|
||||
use app_units::Au;
|
||||
use byteorder::{ReadBytesExt, BigEndian};
|
||||
use byteorder::{BigEndian, ReadBytesExt};
|
||||
use cssparser::Parser;
|
||||
use num_traits::One;
|
||||
use parser::{Parse, ParserContext};
|
||||
|
@ -92,7 +92,9 @@ impl<T: Parse> Parse for FontSettings<T> {
|
|||
}
|
||||
|
||||
Ok(FontSettings(
|
||||
input.parse_comma_separated(|i| T::parse(context, i))?.into_boxed_slice()
|
||||
input
|
||||
.parse_comma_separated(|i| T::parse(context, i))?
|
||||
.into_boxed_slice(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +132,7 @@ impl Parse for FontTag {
|
|||
|
||||
// allowed strings of length 4 containing chars: <U+20, U+7E>
|
||||
if tag.len() != 4 || tag.as_bytes().iter().any(|c| *c < b' ' || *c > b'~') {
|
||||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
let mut raw = Cursor::new(tag.as_bytes());
|
||||
|
@ -138,8 +140,8 @@ impl Parse for FontTag {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedValue, ToAnimatedZero, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedValue, ToAnimatedZero, ToCss)]
|
||||
/// Additional information for keyword-derived font sizes.
|
||||
pub struct KeywordInfo<Length> {
|
||||
/// The keyword used
|
||||
|
@ -176,8 +178,8 @@ where
|
|||
}
|
||||
|
||||
/// CSS font keywords
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedValue, ToAnimatedZero)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedValue, ToAnimatedZero)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum KeywordSize {
|
||||
XXSmall,
|
||||
|
|
|
@ -13,7 +13,7 @@ pub enum ScrollSnapPoint<LengthOrPercentage> {
|
|||
None,
|
||||
/// `repeat(<length-or-percentage>)`
|
||||
#[css(function)]
|
||||
Repeat(LengthOrPercentage)
|
||||
Repeat(LengthOrPercentage),
|
||||
}
|
||||
|
||||
impl<L> ScrollSnapPoint<L> {
|
||||
|
|
|
@ -55,7 +55,7 @@ where
|
|||
W: Write,
|
||||
{
|
||||
if self.is_auto() {
|
||||
return dest.write_str("auto")
|
||||
return dest.write_str("auto");
|
||||
}
|
||||
|
||||
if self.is_span {
|
||||
|
@ -81,10 +81,13 @@ where
|
|||
}
|
||||
|
||||
impl Parse for GridLine<specified::Integer> {
|
||||
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>> {
|
||||
let mut grid_line = Self::auto();
|
||||
if input.try(|i| i.expect_ident_matching("auto")).is_ok() {
|
||||
return Ok(grid_line)
|
||||
return Ok(grid_line);
|
||||
}
|
||||
|
||||
// <custom-ident> | [ <integer> && <custom-ident>? ] | [ span && [ <integer> || <custom-ident> ] ]
|
||||
|
@ -93,11 +96,12 @@ impl Parse for GridLine<specified::Integer> {
|
|||
// And, for some magical reason, "span" should be the first or last value and not in-between.
|
||||
let mut val_before_span = false;
|
||||
|
||||
for _ in 0..3 { // Maximum possible entities for <grid-line>
|
||||
for _ in 0..3 {
|
||||
// Maximum possible entities for <grid-line>
|
||||
let location = input.current_source_location();
|
||||
if input.try(|i| i.expect_ident_matching("span")).is_ok() {
|
||||
if grid_line.is_span {
|
||||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
if grid_line.line_num.is_some() || grid_line.ident.is_some() {
|
||||
|
@ -108,7 +112,7 @@ impl Parse for GridLine<specified::Integer> {
|
|||
} else if let Ok(i) = input.try(|i| specified::Integer::parse(context, i)) {
|
||||
// FIXME(emilio): Probably shouldn't reject if it's calc()...
|
||||
if i.value() == 0 || val_before_span || grid_line.line_num.is_some() {
|
||||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
grid_line.line_num = Some(i);
|
||||
|
@ -118,21 +122,23 @@ impl Parse for GridLine<specified::Integer> {
|
|||
}
|
||||
grid_line.ident = Some(CustomIdent::from_ident(location, &name, &[])?);
|
||||
} else {
|
||||
break
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if grid_line.is_auto() {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
if grid_line.is_span {
|
||||
if let Some(i) = grid_line.line_num {
|
||||
if i.value() <= 0 { // disallow negative integers for grid spans
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
if i.value() <= 0 {
|
||||
// disallow negative integers for grid spans
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
} else if grid_line.ident.is_none() { // integer could be omitted
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
} else if grid_line.ident.is_none() {
|
||||
// integer could be omitted
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,8 +148,7 @@ impl Parse for GridLine<specified::Integer> {
|
|||
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq)]
|
||||
#[derive(ToComputedValue, ToCss)]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum TrackKeyword {
|
||||
Auto,
|
||||
MaxContent,
|
||||
|
@ -210,11 +215,11 @@ impl<L> TrackSize<L> {
|
|||
// need to make sure that they're fixed. So, we don't have to modify the parsing function.
|
||||
TrackSize::Minmax(ref breadth_1, ref breadth_2) => {
|
||||
if breadth_1.is_fixed() {
|
||||
return true // the second value is always a <track-breadth>
|
||||
return true; // the second value is always a <track-breadth>
|
||||
}
|
||||
|
||||
match *breadth_1 {
|
||||
TrackBreadth::Fr(_) => false, // should be <inflexible-breadth> at this point
|
||||
TrackBreadth::Fr(_) => false, // should be <inflexible-breadth> at this point
|
||||
_ => breadth_2.is_fixed(),
|
||||
}
|
||||
},
|
||||
|
@ -284,18 +289,11 @@ impl<L: ToComputedValue> ToComputedValue for TrackSize<L> {
|
|||
TrackBreadth::Fr(f.to_computed_value(context)),
|
||||
)
|
||||
},
|
||||
TrackSize::Breadth(ref b) => {
|
||||
TrackSize::Breadth(b.to_computed_value(context))
|
||||
},
|
||||
TrackSize::Breadth(ref b) => TrackSize::Breadth(b.to_computed_value(context)),
|
||||
TrackSize::Minmax(ref b1, ref b2) => {
|
||||
TrackSize::Minmax(
|
||||
b1.to_computed_value(context),
|
||||
b2.to_computed_value(context),
|
||||
)
|
||||
}
|
||||
TrackSize::FitContent(ref lop) => {
|
||||
TrackSize::FitContent(lop.to_computed_value(context))
|
||||
TrackSize::Minmax(b1.to_computed_value(context), b2.to_computed_value(context))
|
||||
},
|
||||
TrackSize::FitContent(ref lop) => TrackSize::FitContent(lop.to_computed_value(context)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,12 +303,10 @@ impl<L: ToComputedValue> ToComputedValue for TrackSize<L> {
|
|||
TrackSize::Breadth(ref b) => {
|
||||
TrackSize::Breadth(ToComputedValue::from_computed_value(b))
|
||||
},
|
||||
TrackSize::Minmax(ref b1, ref b2) => {
|
||||
TrackSize::Minmax(
|
||||
ToComputedValue::from_computed_value(b1),
|
||||
ToComputedValue::from_computed_value(b2),
|
||||
)
|
||||
},
|
||||
TrackSize::Minmax(ref b1, ref b2) => TrackSize::Minmax(
|
||||
ToComputedValue::from_computed_value(b1),
|
||||
ToComputedValue::from_computed_value(b2),
|
||||
),
|
||||
TrackSize::FitContent(ref lop) => {
|
||||
TrackSize::FitContent(ToComputedValue::from_computed_value(lop))
|
||||
},
|
||||
|
@ -358,7 +354,10 @@ pub enum RepeatCount<Integer> {
|
|||
}
|
||||
|
||||
impl Parse for RepeatCount<specified::Integer> {
|
||||
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>> {
|
||||
// Maximum number of repeat is 10000. The greater numbers should be clamped.
|
||||
const MAX_LINE: i32 = 10000;
|
||||
if let Ok(mut i) = input.try(|i| specified::Integer::parse_positive(context, i)) {
|
||||
|
@ -403,8 +402,11 @@ impl<L: ToCss, I: ToCss> ToCss for TrackRepeat<L, I> {
|
|||
dest.write_str(", ")?;
|
||||
|
||||
let mut line_names_iter = self.line_names.iter();
|
||||
for (i, (ref size, ref names)) in self.track_sizes.iter()
|
||||
.zip(&mut line_names_iter).enumerate() {
|
||||
for (i, (ref size, ref names)) in self.track_sizes
|
||||
.iter()
|
||||
.zip(&mut line_names_iter)
|
||||
.enumerate()
|
||||
{
|
||||
if i > 0 {
|
||||
dest.write_str(" ")?;
|
||||
}
|
||||
|
@ -450,8 +452,8 @@ impl<L: Clone> TrackRepeat<L, specified::Integer> {
|
|||
track_sizes: track_sizes,
|
||||
line_names: line_names.into_boxed_slice(),
|
||||
}
|
||||
|
||||
} else { // if it's auto-fit/auto-fill, then it's left to the layout.
|
||||
} else {
|
||||
// if it's auto-fit/auto-fill, then it's left to the layout.
|
||||
TrackRepeat {
|
||||
count: self.count,
|
||||
track_sizes: self.track_sizes.clone(),
|
||||
|
@ -528,7 +530,7 @@ impl<L: ToCss, I: ToCss> ToCss for TrackList<L, I> {
|
|||
let mut line_names_iter = self.line_names.iter().peekable();
|
||||
|
||||
for idx in 0.. {
|
||||
let names = line_names_iter.next().unwrap(); // This should exist!
|
||||
let names = line_names_iter.next().unwrap(); // This should exist!
|
||||
concat_serialize_idents("[", "]", names, " ", dest)?;
|
||||
|
||||
match self.auto_repeat {
|
||||
|
@ -551,8 +553,10 @@ impl<L: ToCss, I: ToCss> ToCss for TrackList<L, I> {
|
|||
},
|
||||
}
|
||||
|
||||
if values_iter.peek().is_some() || line_names_iter.peek().map_or(false, |v| !v.is_empty()) ||
|
||||
(idx + 1 == auto_idx) {
|
||||
if values_iter.peek().is_some() ||
|
||||
line_names_iter.peek().map_or(false, |v| !v.is_empty()) ||
|
||||
(idx + 1 == auto_idx)
|
||||
{
|
||||
dest.write_str(" ")?;
|
||||
}
|
||||
}
|
||||
|
@ -574,7 +578,10 @@ pub struct LineNameList {
|
|||
}
|
||||
|
||||
impl Parse for LineNameList {
|
||||
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.expect_ident_matching("subgrid")?;
|
||||
let mut line_names = vec![];
|
||||
let mut fill_idx = None;
|
||||
|
@ -586,7 +593,7 @@ impl Parse for LineNameList {
|
|||
let count = RepeatCount::parse(context, input)?;
|
||||
input.expect_comma()?;
|
||||
let mut names_list = vec![];
|
||||
names_list.push(parse_line_names(input)?); // there should be at least one
|
||||
names_list.push(parse_line_names(input)?); // there should be at least one
|
||||
while let Ok(names) = input.try(parse_line_names) {
|
||||
names_list.push(names);
|
||||
}
|
||||
|
@ -597,9 +604,13 @@ impl Parse for LineNameList {
|
|||
|
||||
if let Ok((mut names_list, count)) = repeat_parse_result {
|
||||
match count {
|
||||
RepeatCount::Number(num) =>
|
||||
line_names.extend(names_list.iter().cloned().cycle()
|
||||
.take(num.value() as usize * names_list.len())),
|
||||
RepeatCount::Number(num) => line_names.extend(
|
||||
names_list
|
||||
.iter()
|
||||
.cloned()
|
||||
.cycle()
|
||||
.take(num.value() as usize * names_list.len()),
|
||||
),
|
||||
RepeatCount::AutoFill if fill_idx.is_none() => {
|
||||
// `repeat(autof-fill, ..)` should have just one line name.
|
||||
if names_list.len() != 1 {
|
||||
|
@ -615,7 +626,7 @@ impl Parse for LineNameList {
|
|||
} else if let Ok(names) = input.try(parse_line_names) {
|
||||
line_names.push(names);
|
||||
} else {
|
||||
break
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,11 @@ pub enum GradientKind<LineDirection, Length, LengthOrPercentage, Position, Angle
|
|||
/// A linear gradient.
|
||||
Linear(LineDirection),
|
||||
/// A radial gradient.
|
||||
Radial(EndingShape<Length, LengthOrPercentage>, Position, Option<Angle>),
|
||||
Radial(
|
||||
EndingShape<Length, LengthOrPercentage>,
|
||||
Position,
|
||||
Option<Angle>,
|
||||
),
|
||||
}
|
||||
|
||||
/// A radial gradient's ending shape.
|
||||
|
@ -97,8 +101,7 @@ pub enum Ellipse<LengthOrPercentage> {
|
|||
/// <https://drafts.csswg.org/css-images/#typedef-extent-keyword>
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq)]
|
||||
#[derive(ToComputedValue, ToCss)]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum ShapeExtent {
|
||||
ClosestSide,
|
||||
FarthestSide,
|
||||
|
@ -182,7 +185,10 @@ where
|
|||
}
|
||||
|
||||
impl<G, R, U> ToCss for Image<G, R, U>
|
||||
where G: ToCss, R: ToCss, U: ToCss
|
||||
where
|
||||
G: ToCss,
|
||||
R: ToCss,
|
||||
U: ToCss,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
|
@ -204,7 +210,13 @@ impl<G, R, U> ToCss for Image<G, R, U>
|
|||
}
|
||||
|
||||
impl<D, L, LoP, P, C, A> ToCss for Gradient<D, L, LoP, P, C, A>
|
||||
where D: LineDirection, L: ToCss, LoP: ToCss, P: ToCss, C: ToCss, A: ToCss
|
||||
where
|
||||
D: LineDirection,
|
||||
L: ToCss,
|
||||
LoP: ToCss,
|
||||
P: ToCss,
|
||||
C: ToCss,
|
||||
A: ToCss,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
|
@ -222,8 +234,9 @@ impl<D, L, LoP, P, C, A> ToCss for Gradient<D, L, LoP, P, C, A>
|
|||
dest.write_str(self.kind.label())?;
|
||||
dest.write_str("-gradient(")?;
|
||||
let mut skip_comma = match self.kind {
|
||||
GradientKind::Linear(ref direction)
|
||||
if direction.points_downwards(self.compat_mode) => true,
|
||||
GradientKind::Linear(ref direction) if direction.points_downwards(self.compat_mode) => {
|
||||
true
|
||||
},
|
||||
GradientKind::Linear(ref direction) => {
|
||||
direction.to_css(dest, self.compat_mode)?;
|
||||
false
|
||||
|
@ -231,9 +244,7 @@ impl<D, L, LoP, P, C, A> ToCss for Gradient<D, L, LoP, P, C, A>
|
|||
GradientKind::Radial(ref shape, ref position, ref angle) => {
|
||||
let omit_shape = match *shape {
|
||||
EndingShape::Ellipse(Ellipse::Extent(ShapeExtent::Cover)) |
|
||||
EndingShape::Ellipse(Ellipse::Extent(ShapeExtent::FarthestCorner)) => {
|
||||
true
|
||||
},
|
||||
EndingShape::Ellipse(Ellipse::Extent(ShapeExtent::FarthestCorner)) => true,
|
||||
_ => false,
|
||||
};
|
||||
if self.compat_mode == CompatMode::Modern {
|
||||
|
@ -284,7 +295,8 @@ pub trait LineDirection {
|
|||
|
||||
/// Serialises this direction according to the compatibility mode.
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>, compat_mode: CompatMode) -> fmt::Result
|
||||
where W: Write;
|
||||
where
|
||||
W: Write;
|
||||
}
|
||||
|
||||
impl<L> ToCss for Circle<L>
|
||||
|
@ -296,17 +308,14 @@ where
|
|||
W: Write,
|
||||
{
|
||||
match *self {
|
||||
Circle::Extent(ShapeExtent::FarthestCorner) |
|
||||
Circle::Extent(ShapeExtent::Cover) => {
|
||||
Circle::Extent(ShapeExtent::FarthestCorner) | Circle::Extent(ShapeExtent::Cover) => {
|
||||
dest.write_str("circle")
|
||||
},
|
||||
Circle::Extent(keyword) => {
|
||||
dest.write_str("circle ")?;
|
||||
keyword.to_css(dest)
|
||||
},
|
||||
Circle::Radius(ref length) => {
|
||||
length.to_css(dest)
|
||||
},
|
||||
Circle::Radius(ref length) => length.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! Generic types that share their serialization implementations
|
||||
//! for both specified and computed values.
|
||||
|
||||
use counter_style::{Symbols, parse_counter_style_name};
|
||||
use counter_style::{parse_counter_style_name, Symbols};
|
||||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use style_traits::{ParseError, StyleParseErrorKind};
|
||||
|
@ -37,8 +37,7 @@ pub mod url;
|
|||
// https://drafts.csswg.org/css-counter-styles/#typedef-symbols-type
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq)]
|
||||
#[derive(ToComputedValue, ToCss)]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum SymbolsType {
|
||||
Cyclic,
|
||||
Numeric,
|
||||
|
@ -70,7 +69,7 @@ impl SymbolsType {
|
|||
structs::NS_STYLE_COUNTER_SYSTEM_ALPHABETIC => SymbolsType::Alphabetic,
|
||||
structs::NS_STYLE_COUNTER_SYSTEM_SYMBOLIC => SymbolsType::Symbolic,
|
||||
structs::NS_STYLE_COUNTER_SYSTEM_FIXED => SymbolsType::Fixed,
|
||||
x => panic!("Unexpected value for symbol type {}", x)
|
||||
x => panic!("Unexpected value for symbol type {}", x),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,9 +102,11 @@ impl CounterStyleOrNone {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
impl Parse for CounterStyleOrNone {
|
||||
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(name) = input.try(|i| parse_counter_style_name(i)) {
|
||||
return Ok(CounterStyleOrNone::Name(name));
|
||||
}
|
||||
|
@ -114,13 +115,15 @@ impl Parse for CounterStyleOrNone {
|
|||
}
|
||||
if input.try(|i| i.expect_function_matching("symbols")).is_ok() {
|
||||
return input.parse_nested_block(|input| {
|
||||
let symbols_type = input.try(|i| SymbolsType::parse(i))
|
||||
let symbols_type = input
|
||||
.try(|i| SymbolsType::parse(i))
|
||||
.unwrap_or(SymbolsType::Symbolic);
|
||||
let symbols = Symbols::parse(context, input)?;
|
||||
// There must be at least two symbols for alphabetic or
|
||||
// numeric system.
|
||||
if (symbols_type == SymbolsType::Alphabetic ||
|
||||
symbols_type == SymbolsType::Numeric) && symbols.0.len() < 2 {
|
||||
symbols_type == SymbolsType::Numeric) && symbols.0.len() < 2
|
||||
{
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
// Identifier is not allowed in symbols() function.
|
||||
|
@ -136,12 +139,12 @@ impl Parse for CounterStyleOrNone {
|
|||
|
||||
/// A wrapper of Non-negative values.
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, PartialOrd, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
PartialOrd, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub struct NonNegative<T>(pub T);
|
||||
|
||||
/// A wrapper of greater-than-or-equal-to-one values.
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, PartialOrd, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
PartialOrd, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub struct GreaterThanOrEqualToOne<T>(pub T);
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
//! Generic values for pointing properties.
|
||||
|
||||
/// A generic value for the `caret-color` property.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub enum CaretColor<Color> {
|
||||
/// An explicit color.
|
||||
Color(Color),
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
//! [`position`](https://drafts.csswg.org/css-backgrounds-3/#position)
|
||||
|
||||
/// A generic type for representing a CSS [position](https://drafts.csswg.org/css-values/#position).
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)]
|
||||
#[derive(MallocSizeOf, PartialEq, ToAnimatedZero, ToComputedValue)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedZero, ToComputedValue)]
|
||||
pub struct Position<H, V> {
|
||||
/// The horizontal component of position.
|
||||
pub horizontal: H,
|
||||
|
@ -26,8 +26,8 @@ impl<H, V> Position<H, V> {
|
|||
}
|
||||
|
||||
/// A generic value for the `z-index` property.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)]
|
||||
#[derive(MallocSizeOf, PartialEq, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub enum ZIndex<Integer> {
|
||||
/// An integer value.
|
||||
Integer(Integer),
|
||||
|
|
|
@ -11,8 +11,8 @@ use style_traits::{CssWriter, ParseError, ToCss};
|
|||
|
||||
/// A CSS value made of four components, where its `ToCss` impl will try to
|
||||
/// serialize as few components as possible, like for example in `border-width`.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)]
|
||||
#[derive(MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToComputedValue)]
|
||||
pub struct Rect<T>(pub T, pub T, pub T, pub T);
|
||||
|
||||
impl<T> Rect<T> {
|
||||
|
@ -23,7 +23,8 @@ impl<T> Rect<T> {
|
|||
}
|
||||
|
||||
impl<T> Rect<T>
|
||||
where T: Clone
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
/// Returns a rect with all the values equal to `v`.
|
||||
pub fn all(v: T) -> Self {
|
||||
|
@ -34,20 +35,32 @@ impl<T> Rect<T>
|
|||
pub fn parse_with<'i, 't, Parse>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
parse: Parse)
|
||||
-> Result<Self, ParseError<'i>>
|
||||
where Parse: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<T, ParseError<'i>>
|
||||
parse: Parse,
|
||||
) -> Result<Self, ParseError<'i>>
|
||||
where
|
||||
Parse: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<T, ParseError<'i>>,
|
||||
{
|
||||
let first = parse(context, input)?;
|
||||
let second = if let Ok(second) = input.try(|i| parse(context, i)) { second } else {
|
||||
let second = if let Ok(second) = input.try(|i| parse(context, i)) {
|
||||
second
|
||||
} else {
|
||||
// <first>
|
||||
return Ok(Self::new(first.clone(), first.clone(), first.clone(), first));
|
||||
return Ok(Self::new(
|
||||
first.clone(),
|
||||
first.clone(),
|
||||
first.clone(),
|
||||
first,
|
||||
));
|
||||
};
|
||||
let third = if let Ok(third) = input.try(|i| parse(context, i)) { third } else {
|
||||
let third = if let Ok(third) = input.try(|i| parse(context, i)) {
|
||||
third
|
||||
} else {
|
||||
// <first> <second>
|
||||
return Ok(Self::new(first.clone(), second.clone(), first, second));
|
||||
};
|
||||
let fourth = if let Ok(fourth) = input.try(|i| parse(context, i)) { fourth } else {
|
||||
let fourth = if let Ok(fourth) = input.try(|i| parse(context, i)) {
|
||||
fourth
|
||||
} else {
|
||||
// <first> <second> <third>
|
||||
return Ok(Self::new(first, second.clone(), third, second));
|
||||
};
|
||||
|
@ -57,16 +70,21 @@ impl<T> Rect<T>
|
|||
}
|
||||
|
||||
impl<T> Parse for Rect<T>
|
||||
where T: Clone + Parse
|
||||
where
|
||||
T: Clone + Parse,
|
||||
{
|
||||
#[inline]
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Self::parse_with(context, input, T::parse)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ToCss for Rect<T>
|
||||
where T: PartialEq + ToCss
|
||||
where
|
||||
T: PartialEq + ToCss,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
|
|
|
@ -13,8 +13,8 @@ use values::animated::ToAnimatedValue;
|
|||
|
||||
/// A generic size, for `border-*-radius` longhand properties, or
|
||||
/// `border-spacing`.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)]
|
||||
#[derive(MallocSizeOf, PartialEq, ToAnimatedZero, ToComputedValue)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedZero, ToComputedValue)]
|
||||
pub struct Size<L>(pub Size2D<L>);
|
||||
|
||||
impl<L> Size<L> {
|
||||
|
@ -42,7 +42,7 @@ impl<L> Size<L> {
|
|||
) -> Result<Self, ParseError<'i>>
|
||||
where
|
||||
L: Clone,
|
||||
F: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<L, ParseError<'i>>
|
||||
F: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<L, ParseError<'i>>,
|
||||
{
|
||||
let first = parse_one(context, input)?;
|
||||
let second = input
|
||||
|
@ -53,8 +53,8 @@ impl<L> Size<L> {
|
|||
}
|
||||
|
||||
impl<L> ToCss for Size<L>
|
||||
where L:
|
||||
ToCss + PartialEq,
|
||||
where
|
||||
L: ToCss + PartialEq,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
|
@ -72,8 +72,8 @@ where L:
|
|||
}
|
||||
|
||||
impl<L> ToAnimatedValue for Size<L>
|
||||
where L:
|
||||
ToAnimatedValue,
|
||||
where
|
||||
L: ToAnimatedValue,
|
||||
{
|
||||
type AnimatedValue = Size<L::AnimatedValue>;
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ use values::distance::{ComputeSquaredDistance, SquaredDistance};
|
|||
///
|
||||
/// <https://www.w3.org/TR/SVG2/painting.html#SpecifyingPaint>
|
||||
#[animation(no_bound(UrlPaintServer))]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToAnimatedValue, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedValue,
|
||||
ToComputedValue, ToCss)]
|
||||
pub struct SVGPaint<ColorType, UrlPaintServer> {
|
||||
/// The paint source
|
||||
pub kind: SVGPaintKind<ColorType, UrlPaintServer>,
|
||||
|
@ -31,8 +31,8 @@ pub struct SVGPaint<ColorType, UrlPaintServer> {
|
|||
/// to have a fallback, Gecko lets the context
|
||||
/// properties have a fallback as well.
|
||||
#[animation(no_bound(UrlPaintServer))]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedValue,
|
||||
ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub enum SVGPaintKind<ColorType, UrlPaintServer> {
|
||||
/// `none`
|
||||
#[animation(error)]
|
||||
|
@ -62,9 +62,10 @@ impl<ColorType, UrlPaintServer> SVGPaintKind<ColorType, UrlPaintServer> {
|
|||
/// Parse SVGPaint's fallback.
|
||||
/// fallback is keyword(none), Color or empty.
|
||||
/// <https://svgwg.org/svg2-draft/painting.html#SpecifyingPaint>
|
||||
fn parse_fallback<'i, 't, ColorType: Parse>(context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>)
|
||||
-> Option<Either<ColorType, None_>> {
|
||||
fn parse_fallback<'i, 't, ColorType: Parse>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Option<Either<ColorType, None_>> {
|
||||
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
Some(Either::Second(None_))
|
||||
} else {
|
||||
|
@ -77,7 +78,10 @@ fn parse_fallback<'i, 't, ColorType: Parse>(context: &ParserContext,
|
|||
}
|
||||
|
||||
impl<ColorType: Parse, UrlPaintServer: Parse> Parse for SVGPaint<ColorType, UrlPaintServer> {
|
||||
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(url) = input.try(|i| UrlPaintServer::parse(context, i)) {
|
||||
Ok(SVGPaint {
|
||||
kind: SVGPaintKind::PaintServer(url),
|
||||
|
@ -108,8 +112,8 @@ impl<ColorType: Parse, UrlPaintServer: Parse> Parse for SVGPaint<ColorType, UrlP
|
|||
|
||||
/// A value of <length> | <percentage> | <number> for svg which allow unitless length.
|
||||
/// <https://www.w3.org/TR/SVG11/painting.html#StrokeProperties>
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedValue)]
|
||||
#[derive(ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, ToAnimatedZero,
|
||||
ToComputedValue, ToCss)]
|
||||
pub enum SvgLengthOrPercentageOrNumber<LengthOrPercentage, Number> {
|
||||
/// <length> | <percentage>
|
||||
LengthOrPercentage(LengthOrPercentage),
|
||||
|
@ -118,44 +122,38 @@ pub enum SvgLengthOrPercentageOrNumber<LengthOrPercentage, Number> {
|
|||
}
|
||||
|
||||
impl<L, N> ComputeSquaredDistance for SvgLengthOrPercentageOrNumber<L, N>
|
||||
where
|
||||
L: ComputeSquaredDistance + Copy + Into<NumberOrPercentage>,
|
||||
N: ComputeSquaredDistance + Copy + Into<NumberOrPercentage>
|
||||
where
|
||||
L: ComputeSquaredDistance + Copy + Into<NumberOrPercentage>,
|
||||
N: ComputeSquaredDistance + Copy + Into<NumberOrPercentage>,
|
||||
{
|
||||
#[inline]
|
||||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
||||
match (self, other) {
|
||||
(
|
||||
&SvgLengthOrPercentageOrNumber::LengthOrPercentage(ref from),
|
||||
&SvgLengthOrPercentageOrNumber::LengthOrPercentage(ref to)
|
||||
) => {
|
||||
from.compute_squared_distance(to)
|
||||
},
|
||||
&SvgLengthOrPercentageOrNumber::LengthOrPercentage(ref to),
|
||||
) => from.compute_squared_distance(to),
|
||||
(
|
||||
&SvgLengthOrPercentageOrNumber::Number(ref from),
|
||||
&SvgLengthOrPercentageOrNumber::Number(ref to)
|
||||
) => {
|
||||
from.compute_squared_distance(to)
|
||||
},
|
||||
&SvgLengthOrPercentageOrNumber::Number(ref to),
|
||||
) => from.compute_squared_distance(to),
|
||||
(
|
||||
&SvgLengthOrPercentageOrNumber::LengthOrPercentage(from),
|
||||
&SvgLengthOrPercentageOrNumber::Number(to)
|
||||
) => {
|
||||
from.into().compute_squared_distance(&to.into())
|
||||
},
|
||||
&SvgLengthOrPercentageOrNumber::Number(to),
|
||||
) => from.into().compute_squared_distance(&to.into()),
|
||||
(
|
||||
&SvgLengthOrPercentageOrNumber::Number(from),
|
||||
&SvgLengthOrPercentageOrNumber::LengthOrPercentage(to)
|
||||
) => {
|
||||
from.into().compute_squared_distance(&to.into())
|
||||
},
|
||||
&SvgLengthOrPercentageOrNumber::LengthOrPercentage(to),
|
||||
) => from.into().compute_squared_distance(&to.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<LengthOrPercentageType, NumberType> SvgLengthOrPercentageOrNumber<LengthOrPercentageType, NumberType>
|
||||
where LengthOrPercentage: From<LengthOrPercentageType>,
|
||||
LengthOrPercentageType: Copy
|
||||
impl<LengthOrPercentageType, NumberType>
|
||||
SvgLengthOrPercentageOrNumber<LengthOrPercentageType, NumberType>
|
||||
where
|
||||
LengthOrPercentage: From<LengthOrPercentageType>,
|
||||
LengthOrPercentageType: Copy,
|
||||
{
|
||||
/// return true if this struct has calc value.
|
||||
pub fn has_calc(&self) -> bool {
|
||||
|
@ -173,10 +171,13 @@ impl<LengthOrPercentageType, NumberType> SvgLengthOrPercentageOrNumber<LengthOrP
|
|||
|
||||
/// Parsing the SvgLengthOrPercentageOrNumber. At first, we need to parse number
|
||||
/// since prevent converting to the length.
|
||||
impl <LengthOrPercentageType: Parse, NumberType: Parse> Parse for
|
||||
SvgLengthOrPercentageOrNumber<LengthOrPercentageType, NumberType> {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
impl<LengthOrPercentageType: Parse, NumberType: Parse> Parse
|
||||
for SvgLengthOrPercentageOrNumber<LengthOrPercentageType, 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));
|
||||
}
|
||||
|
@ -189,9 +190,8 @@ impl <LengthOrPercentageType: Parse, NumberType: Parse> Parse for
|
|||
}
|
||||
|
||||
/// An SVG length value supports `context-value` in addition to length.
|
||||
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToAnimatedValue, ToAnimatedZero)]
|
||||
#[derive(ToComputedValue, ToCss)]
|
||||
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedValue,
|
||||
ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub enum SVGLength<LengthType> {
|
||||
/// `<length> | <percentage> | <number>`
|
||||
Length(LengthType),
|
||||
|
@ -200,8 +200,8 @@ pub enum SVGLength<LengthType> {
|
|||
}
|
||||
|
||||
/// Generic value for stroke-dasharray.
|
||||
#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToAnimatedValue, ToComputedValue, ToCss)]
|
||||
#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedValue,
|
||||
ToComputedValue, ToCss)]
|
||||
pub enum SVGStrokeDashArray<LengthType> {
|
||||
/// `[ <length> | <percentage> | <number> ]#`
|
||||
#[css(comma)]
|
||||
|
@ -216,8 +216,8 @@ pub enum SVGStrokeDashArray<LengthType> {
|
|||
|
||||
/// An SVG opacity value accepts `context-{fill,stroke}-opacity` in
|
||||
/// addition to opacity value.
|
||||
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedZero,
|
||||
ToComputedValue, ToCss)]
|
||||
pub enum SVGOpacity<OpacityType> {
|
||||
/// `<opacity-value>`
|
||||
Opacity(OpacityType),
|
||||
|
|
|
@ -49,9 +49,10 @@ impl<Value> Spacing<Value> {
|
|||
pub fn parse_with<'i, 't, F>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
parse: F)
|
||||
-> Result<Self, ParseError<'i>>
|
||||
where F: FnOnce(&ParserContext, &mut Parser<'i, 't>) -> Result<Value, ParseError<'i>>
|
||||
parse: F,
|
||||
) -> Result<Self, ParseError<'i>>
|
||||
where
|
||||
F: FnOnce(&ParserContext, &mut Parser<'i, 't>) -> Result<Value, ParseError<'i>>,
|
||||
{
|
||||
if input.try(|i| i.expect_ident_matching("normal")).is_ok() {
|
||||
return Ok(Spacing::Normal);
|
||||
|
@ -103,12 +104,14 @@ where
|
|||
V: From<Au>,
|
||||
{
|
||||
#[inline]
|
||||
fn to_animated_zero(&self) -> Result<Self, ()> { Err(()) }
|
||||
fn to_animated_zero(&self) -> Result<Self, ()> {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
/// A generic value for the `line-height` property.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)]
|
||||
#[derive(MallocSizeOf, PartialEq, ToAnimatedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedValue, ToCss)]
|
||||
pub enum LineHeight<Number, LengthOrPercentage> {
|
||||
/// `normal`
|
||||
Normal,
|
||||
|
@ -123,7 +126,9 @@ pub enum LineHeight<Number, LengthOrPercentage> {
|
|||
|
||||
impl<N, L> ToAnimatedZero for LineHeight<N, L> {
|
||||
#[inline]
|
||||
fn to_animated_zero(&self) -> Result<Self, ()> { Err(()) }
|
||||
fn to_animated_zero(&self) -> Result<Self, ()> {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<N, L> LineHeight<N, L> {
|
||||
|
@ -135,8 +140,8 @@ impl<N, L> LineHeight<N, L> {
|
|||
}
|
||||
|
||||
/// A generic value for the `-moz-tab-size` property.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub enum MozTabSize<Number, Length> {
|
||||
/// A number.
|
||||
Number(Number),
|
||||
|
|
|
@ -64,8 +64,8 @@ impl<T: Into<f64>> From<Matrix3D<T>> for Transform3D<f64> {
|
|||
}
|
||||
|
||||
/// A generic transform origin.
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)]
|
||||
#[derive(MallocSizeOf, PartialEq, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub struct TransformOrigin<H, V, Depth> {
|
||||
/// The horizontal origin.
|
||||
pub horizontal: H,
|
||||
|
@ -101,8 +101,7 @@ pub enum TimingFunction<Integer, Number> {
|
|||
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq)]
|
||||
#[derive(ToComputedValue, ToCss)]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum TimingKeyword {
|
||||
Linear,
|
||||
Ease,
|
||||
|
@ -113,8 +112,7 @@ pub enum TimingKeyword {
|
|||
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq)]
|
||||
#[derive(ToComputedValue, ToCss)]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum StepPosition {
|
||||
Start,
|
||||
End,
|
||||
|
@ -247,48 +245,18 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>
|
|||
#[allow(missing_docs)]
|
||||
#[css(comma, function = "interpolatematrix")]
|
||||
InterpolateMatrix {
|
||||
from_list: Transform<
|
||||
TransformOperation<
|
||||
Angle,
|
||||
Number,
|
||||
Length,
|
||||
Integer,
|
||||
LengthOrPercentage,
|
||||
>,
|
||||
>,
|
||||
to_list: Transform<
|
||||
TransformOperation<
|
||||
Angle,
|
||||
Number,
|
||||
Length,
|
||||
Integer,
|
||||
LengthOrPercentage,
|
||||
>,
|
||||
>,
|
||||
from_list:
|
||||
Transform<TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>>,
|
||||
to_list: Transform<TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>>,
|
||||
progress: computed::Percentage,
|
||||
},
|
||||
/// A intermediate type for accumulation of mismatched transform lists.
|
||||
#[allow(missing_docs)]
|
||||
#[css(comma, function = "accumulatematrix")]
|
||||
AccumulateMatrix {
|
||||
from_list: Transform<
|
||||
TransformOperation<
|
||||
Angle,
|
||||
Number,
|
||||
Length,
|
||||
Integer,
|
||||
LengthOrPercentage,
|
||||
>,
|
||||
>,
|
||||
to_list: Transform<
|
||||
TransformOperation<
|
||||
Angle,
|
||||
Number,
|
||||
Length,
|
||||
Integer,
|
||||
LengthOrPercentage,
|
||||
>,
|
||||
>,
|
||||
from_list:
|
||||
Transform<TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>>,
|
||||
to_list: Transform<TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>>,
|
||||
count: Integer,
|
||||
},
|
||||
}
|
||||
|
@ -298,12 +266,15 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>
|
|||
pub struct Transform<T>(#[css(if_empty = "none", iterable)] pub Vec<T>);
|
||||
|
||||
impl<Angle, Number, Length, Integer, LengthOrPercentage>
|
||||
TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage> {
|
||||
TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>
|
||||
{
|
||||
/// Check if it is any translate function
|
||||
pub fn is_translate(&self) -> bool {
|
||||
use self::TransformOperation::*;
|
||||
match *self {
|
||||
Translate(..) | Translate3D(..) | TranslateX(..) | TranslateY(..) | TranslateZ(..) => true,
|
||||
Translate(..) | Translate3D(..) | TranslateX(..) | TranslateY(..) | TranslateZ(..) => {
|
||||
true
|
||||
},
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -373,7 +344,7 @@ impl ToAbsoluteLength for ComputedLengthOrPercentage {
|
|||
// If we don't have reference box, we cannot resolve the used value,
|
||||
// so only retrieve the length part. This will be used for computing
|
||||
// distance without any layout info.
|
||||
None => Ok(extract_pixel_length(self))
|
||||
None => Ok(extract_pixel_length(self)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -399,9 +370,8 @@ where
|
|||
fn is_3d(&self) -> bool {
|
||||
use self::TransformOperation::*;
|
||||
match *self {
|
||||
Translate3D(..) | TranslateZ(..) |
|
||||
Rotate3D(..) | RotateX(..) | RotateY(..) | RotateZ(..) |
|
||||
Scale3D(..) | ScaleZ(..) | Perspective(..) | Matrix3D(..) => true,
|
||||
Translate3D(..) | TranslateZ(..) | Rotate3D(..) | RotateX(..) | RotateY(..) |
|
||||
RotateZ(..) | Scale3D(..) | ScaleZ(..) | Perspective(..) | Matrix3D(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -424,7 +394,10 @@ where
|
|||
let (ax, ay, az, theta) =
|
||||
get_normalized_vector_and_angle(ax.into(), ay.into(), az.into(), theta);
|
||||
Transform3D::create_rotation(
|
||||
ax as f64, ay as f64, az as f64, euclid::Angle::radians(theta)
|
||||
ax as f64,
|
||||
ay as f64,
|
||||
az as f64,
|
||||
euclid::Angle::radians(theta),
|
||||
)
|
||||
},
|
||||
RotateX(theta) => {
|
||||
|
@ -441,7 +414,8 @@ where
|
|||
},
|
||||
Perspective(ref d) => {
|
||||
let m = create_perspective_matrix(d.to_pixel_length(None)?);
|
||||
m.cast().expect("Casting from f32 to f64 should be successful")
|
||||
m.cast()
|
||||
.expect("Casting from f32 to f64 should be successful")
|
||||
},
|
||||
Scale3D(sx, sy, sz) => Transform3D::create_scale(sx.into(), sy.into(), sz.into()),
|
||||
Scale(sx, sy) => Transform3D::create_scale(sx.into(), sy.unwrap_or(sx).into(), 1.),
|
||||
|
@ -469,24 +443,18 @@ where
|
|||
TranslateZ(ref z) => {
|
||||
Transform3D::create_translation(0., 0., z.to_pixel_length(None)? as f64)
|
||||
},
|
||||
Skew(theta_x, theta_y) => {
|
||||
Transform3D::create_skew(
|
||||
euclid::Angle::radians(theta_x.as_ref().radians64()),
|
||||
euclid::Angle::radians(theta_y.map_or(0., |a| a.as_ref().radians64())),
|
||||
)
|
||||
},
|
||||
SkewX(theta) => {
|
||||
Transform3D::create_skew(
|
||||
euclid::Angle::radians(theta.as_ref().radians64()),
|
||||
euclid::Angle::radians(0.),
|
||||
)
|
||||
},
|
||||
SkewY(theta) => {
|
||||
Transform3D::create_skew(
|
||||
euclid::Angle::radians(0.),
|
||||
euclid::Angle::radians(theta.as_ref().radians64()),
|
||||
)
|
||||
},
|
||||
Skew(theta_x, theta_y) => Transform3D::create_skew(
|
||||
euclid::Angle::radians(theta_x.as_ref().radians64()),
|
||||
euclid::Angle::radians(theta_y.map_or(0., |a| a.as_ref().radians64())),
|
||||
),
|
||||
SkewX(theta) => Transform3D::create_skew(
|
||||
euclid::Angle::radians(theta.as_ref().radians64()),
|
||||
euclid::Angle::radians(0.),
|
||||
),
|
||||
SkewY(theta) => Transform3D::create_skew(
|
||||
euclid::Angle::radians(0.),
|
||||
euclid::Angle::radians(theta.as_ref().radians64()),
|
||||
),
|
||||
Matrix3D(m) => m.into(),
|
||||
Matrix(m) => m.into(),
|
||||
InterpolateMatrix { .. } | AccumulateMatrix { .. } => {
|
||||
|
@ -586,8 +554,8 @@ pub fn get_normalized_vector_and_angle<T: Zero>(
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedZero,
|
||||
ToComputedValue, ToCss)]
|
||||
/// A value of the `Rotate` property
|
||||
///
|
||||
/// <https://drafts.csswg.org/css-transforms-2/#individual-transforms>
|
||||
|
@ -600,8 +568,8 @@ pub enum Rotate<Number, Angle> {
|
|||
Rotate3D(Number, Number, Number, Angle),
|
||||
}
|
||||
|
||||
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedZero,
|
||||
ToComputedValue, ToCss)]
|
||||
/// A value of the `Scale` property
|
||||
///
|
||||
/// <https://drafts.csswg.org/css-transforms-2/#individual-transforms>
|
||||
|
@ -616,8 +584,8 @@ pub enum Scale<Number> {
|
|||
Scale3D(Number, Number, Number),
|
||||
}
|
||||
|
||||
#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedZero,
|
||||
ToComputedValue, ToCss)]
|
||||
/// A value of the `Translate` property
|
||||
///
|
||||
/// <https://drafts.csswg.org/css-transforms-2/#individual-transforms>
|
||||
|
|
|
@ -9,8 +9,8 @@ use parser::{Parse, ParserContext};
|
|||
use style_traits::ParseError;
|
||||
|
||||
/// An image url or none, used for example in list-style-image
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedValue,
|
||||
ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub enum UrlOrNone<Url> {
|
||||
/// `none`
|
||||
None,
|
||||
|
@ -25,7 +25,10 @@ impl<Url> UrlOrNone<Url> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<Url> Parse for UrlOrNone<Url> where Url: Parse {
|
||||
impl<Url> Parse for UrlOrNone<Url>
|
||||
where
|
||||
Url: Parse,
|
||||
{
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue