mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #20211 - servo:derive-all-the-things, r=emilio
Improve #[derive(ToCss)] <!-- 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/20211) <!-- Reviewable:end -->
This commit is contained in:
commit
785b7c7775
10 changed files with 146 additions and 111 deletions
|
@ -547,9 +547,8 @@ impl Parse for Fallback {
|
|||
|
||||
/// <https://drafts.csswg.org/css-counter-styles/#descdef-counter-style-symbols>
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[css(iterable)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, ToComputedValue, ToCss)]
|
||||
pub struct Symbols(pub Vec<Symbol>);
|
||||
pub struct Symbols(#[css(iterable)] pub Vec<Symbol>);
|
||||
|
||||
impl Parse for Symbols {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
|
|
|
@ -25,10 +25,11 @@ pub use gecko::media_queries::{Device, Expression};
|
|||
|
||||
/// A type that encapsulates a media query list.
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
#[css(comma, iterable)]
|
||||
#[css(comma)]
|
||||
#[derive(Clone, Debug, ToCss)]
|
||||
pub struct MediaList {
|
||||
/// The list of media queries.
|
||||
#[css(iterable)]
|
||||
pub media_queries: Vec<MediaQuery>,
|
||||
}
|
||||
|
||||
|
|
|
@ -126,9 +126,7 @@
|
|||
% endif
|
||||
% if not allow_empty:
|
||||
% if separator == "Comma":
|
||||
#[css(comma, iterable)]
|
||||
% else:
|
||||
#[css(iterable)]
|
||||
#[css(comma)]
|
||||
% endif
|
||||
#[derive(ToCss)]
|
||||
% endif
|
||||
|
@ -136,6 +134,9 @@
|
|||
% if allow_empty and allow_empty != "NotInitial":
|
||||
pub Vec<single_value::T>,
|
||||
% else:
|
||||
% if not allow_empty:
|
||||
#[css(iterable)]
|
||||
% endif
|
||||
pub SmallVec<[single_value::T; 1]>,
|
||||
% endif
|
||||
);
|
||||
|
@ -189,13 +190,16 @@
|
|||
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
|
||||
% if not allow_empty:
|
||||
% if separator == "Comma":
|
||||
#[css(comma, iterable)]
|
||||
% else:
|
||||
#[css(iterable)]
|
||||
#[css(comma)]
|
||||
% endif
|
||||
#[derive(ToCss)]
|
||||
% endif
|
||||
pub struct SpecifiedValue(pub Vec<single_value::SpecifiedValue>);
|
||||
pub struct SpecifiedValue(
|
||||
% if not allow_empty:
|
||||
#[css(iterable)]
|
||||
% endif
|
||||
pub Vec<single_value::SpecifiedValue>,
|
||||
);
|
||||
|
||||
% if allow_empty:
|
||||
impl ToCss for SpecifiedValue {
|
||||
|
|
|
@ -176,9 +176,9 @@ impl UrlMatchingFunction {
|
|||
/// The `@document` rule's condition is written as a comma-separated list of
|
||||
/// URL matching functions, and the condition evaluates to true whenever any
|
||||
/// one of those functions evaluates to true.
|
||||
#[css(comma, iterable)]
|
||||
#[css(comma)]
|
||||
#[derive(Clone, Debug, ToCss)]
|
||||
pub struct DocumentCondition(Vec<UrlMatchingFunction>);
|
||||
pub struct DocumentCondition(#[css(iterable)] Vec<UrlMatchingFunction>);
|
||||
|
||||
impl DocumentCondition {
|
||||
/// Parse a document condition.
|
||||
|
|
|
@ -118,9 +118,8 @@ impl ToGeckoFontFeatureValues for PairValues {
|
|||
}
|
||||
|
||||
/// A @font-feature-values block declaration value that keeps a list of values.
|
||||
#[css(iterable)]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
pub struct VectorValues(pub Vec<u32>);
|
||||
pub struct VectorValues(#[css(iterable)] pub Vec<u32>);
|
||||
|
||||
impl Parse for VectorValues {
|
||||
fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
|
|
|
@ -145,9 +145,9 @@ impl KeyframePercentage {
|
|||
|
||||
/// A keyframes selector is a list of percentages or from/to symbols, which are
|
||||
/// converted at parse time to percentages.
|
||||
#[css(comma, iterable)]
|
||||
#[css(comma)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, ToCss)]
|
||||
pub struct KeyframeSelector(Vec<KeyframePercentage>);
|
||||
pub struct KeyframeSelector(#[css(iterable)] Vec<KeyframePercentage>);
|
||||
|
||||
impl KeyframeSelector {
|
||||
/// Return the list of percentages this selector contains.
|
||||
|
|
|
@ -369,9 +369,9 @@ pub enum OverflowClipBox {
|
|||
pub enum WillChange {
|
||||
/// Expresses no particular intent
|
||||
Auto,
|
||||
#[css(comma, iterable)]
|
||||
/// <custom-ident>
|
||||
AnimateableFeatures(Box<[CustomIdent]>),
|
||||
#[css(comma)]
|
||||
AnimateableFeatures(#[css(iterable)] Box<[CustomIdent]>),
|
||||
}
|
||||
|
||||
impl WillChange {
|
||||
|
|
|
@ -92,8 +92,7 @@ pub enum Content {
|
|||
#[cfg(feature = "gecko")]
|
||||
MozAltContent,
|
||||
/// Content items.
|
||||
#[css(iterable)]
|
||||
Items(Box<[ContentItem]>),
|
||||
Items(#[css(iterable)] Box<[ContentItem]>),
|
||||
}
|
||||
|
||||
/// Items for the `content` property.
|
||||
|
|
|
@ -152,8 +152,8 @@ impl From<LengthOrPercentage> for FontSize {
|
|||
#[derive(Clone, Debug, Eq, Hash, PartialEq, ToCss)]
|
||||
pub enum FontFamily {
|
||||
/// List of `font-family`
|
||||
#[css(iterable, comma)]
|
||||
Values(FontFamilyList),
|
||||
#[css(comma)]
|
||||
Values(#[css(iterable)] FontFamilyList),
|
||||
/// System font
|
||||
System(SystemFont),
|
||||
}
|
||||
|
@ -718,11 +718,11 @@ pub enum VariantAlternates {
|
|||
#[css(function)]
|
||||
Stylistic(CustomIdent),
|
||||
/// Enables display with stylistic sets
|
||||
#[css(comma, function, iterable)]
|
||||
Styleset(Box<[CustomIdent]>),
|
||||
#[css(comma, function)]
|
||||
Styleset(#[css(iterable)] Box<[CustomIdent]>),
|
||||
/// Enables display of specific character variants
|
||||
#[css(comma, function, iterable)]
|
||||
CharacterVariant(Box<[CustomIdent]>),
|
||||
#[css(comma, function)]
|
||||
CharacterVariant(#[css(iterable)] Box<[CustomIdent]>),
|
||||
/// Enables display of swash glyphs
|
||||
#[css(function)]
|
||||
Swash(CustomIdent),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue