mirror of
https://github.com/servo/servo.git
synced 2025-07-16 03:43:38 +01:00
Auto merge of #17530 - servo:derive-all-the-things, r=emilio
Improve sequence values in style <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17530) <!-- Reviewable:end -->
This commit is contained in:
commit
de0ee6cebf
21 changed files with 211 additions and 241 deletions
|
@ -4,18 +4,9 @@
|
|||
|
||||
//! Generic types for CSS values related to effects.
|
||||
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
/// A generic value for the `filter` property.
|
||||
///
|
||||
/// Keyword `none` is represented by an empty slice.
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToComputedValue)]
|
||||
pub struct FilterList<Filter>(pub Box<[Filter]>);
|
||||
|
||||
/// A generic value for a single `filter`.
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)]
|
||||
|
@ -71,39 +62,3 @@ pub struct SimpleShadow<Color, SizeLength, ShapeLength> {
|
|||
/// Blur radius.
|
||||
pub blur: ShapeLength,
|
||||
}
|
||||
|
||||
impl<F> FilterList<F> {
|
||||
/// Returns `none`.
|
||||
#[inline]
|
||||
pub fn none() -> Self {
|
||||
FilterList(vec![].into_boxed_slice())
|
||||
}
|
||||
}
|
||||
|
||||
impl<F> From<Vec<F>> for FilterList<F> {
|
||||
#[inline]
|
||||
fn from(vec: Vec<F>) -> Self {
|
||||
FilterList(vec.into_boxed_slice())
|
||||
}
|
||||
}
|
||||
|
||||
impl<F> ToCss for FilterList<F>
|
||||
where
|
||||
F: ToCss,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where
|
||||
W: fmt::Write
|
||||
{
|
||||
if let Some((first, rest)) = self.0.split_first() {
|
||||
first.to_css(dest)?;
|
||||
for filter in rest {
|
||||
dest.write_str(" ")?;
|
||||
filter.to_css(dest)?;
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
dest.write_str("none")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use counter_style::{Symbols, parse_counter_style_name};
|
|||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use std::fmt;
|
||||
use style_traits::{OneOrMoreSeparated, CommaSeparator, ToCss, ParseError, StyleParseError};
|
||||
use style_traits::{Comma, OneOrMoreSeparated, ParseError, StyleParseError, ToCss};
|
||||
use super::CustomIdent;
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
|
@ -125,7 +125,7 @@ pub struct FontSettingTag<T> {
|
|||
}
|
||||
|
||||
impl<T> OneOrMoreSeparated for FontSettingTag<T> {
|
||||
type S = CommaSeparator;
|
||||
type S = Comma;
|
||||
}
|
||||
|
||||
impl<T: ToCss> ToCss for FontSettingTag<T> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue