From a4b1ba5f370765061a999ac661260d630d5143b1 Mon Sep 17 00:00:00 2001 From: Chinedu Francis Nwafili Date: Tue, 13 Dec 2022 07:49:24 -0500 Subject: [PATCH 1/4] Put all of serde behind feature flag This commit makes the "serde" dependency completely optional. Related: https://github.com/parcel-bundler/lightningcss/issues/357 --- Cargo.lock | 1 - Cargo.toml | 4 ++-- selectors/parser.rs | 2 +- src/bundler.rs | 6 +++--- src/css_modules.rs | 11 +++++++---- src/dependencies.rs | 21 ++++++++++++-------- src/error.rs | 47 ++++++++++++++++++++++++-------------------- src/rules/mod.rs | 5 +++-- src/targets.rs | 4 +++- src/values/string.rs | 2 ++ 10 files changed, 60 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5842d278..0a637f33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -685,7 +685,6 @@ dependencies = [ "pathdiff", "predicates", "rayon", - "serde", "serde_json", "smallvec", ] diff --git a/Cargo.toml b/Cargo.toml index 1e0a9f9d..bd2153e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,10 +32,10 @@ browserslist = ["browserslist-rs"] bundler = ["dashmap", "rayon"] cli = ["clap", "serde_json", "browserslist", "jemallocator"] grid = [] -serde = ["smallvec/serde", "cssparser/serde"] +with-serde = ["serde", "smallvec/serde", "cssparser/serde"] [dependencies] -serde = { version = "1.0.123", features = ["derive"] } +serde = { version = "1.0.123", features = ["derive"], optional = true } cssparser = "0.29.1" parcel_selectors = { version = "0.24.9", path = "./selectors" } itertools = "0.10.1" diff --git a/selectors/parser.rs b/selectors/parser.rs index be30a248..f3ef2e84 100644 --- a/selectors/parser.rs +++ b/selectors/parser.rs @@ -2709,7 +2709,7 @@ pub mod tests { use super::*; use crate::builder::SelectorFlags; use crate::parser; - use cssparser::{serialize_identifier, Parser as CssParser, ParserInput, ToCss, serialize_string}; + use cssparser::{serialize_identifier, serialize_string, Parser as CssParser, ParserInput, ToCss}; use std::collections::HashMap; use std::fmt; diff --git a/src/bundler.rs b/src/bundler.rs index 4d1470bf..d239c836 100644 --- a/src/bundler.rs +++ b/src/bundler.rs @@ -52,7 +52,6 @@ use cssparser::AtRuleParser; use dashmap::DashMap; use parcel_sourcemap::SourceMap; use rayon::prelude::*; -use serde::Serialize; use std::{ collections::HashSet, fs, @@ -144,7 +143,8 @@ impl Drop for FileProvider { } /// An error that could occur during bundling. -#[derive(Debug, Serialize)] +#[derive(Debug)] +#[cfg_attr(feature = "serde", serde::Serialize)] pub enum BundleErrorKind<'i, T: std::error::Error> { /// A parser error occurred. ParserError(ParserError<'i>), @@ -155,7 +155,7 @@ pub enum BundleErrorKind<'i, T: std::error::Error> { /// Unsupported media query boolean logic was encountered. UnsupportedMediaBooleanLogic, /// A custom resolver error. - ResolverError(#[serde(skip)] T), + ResolverError(#[cfg_attr(feature = "serde", serde(skip))] T), } impl<'i, T: std::error::Error> From>> for Error> { diff --git a/src/css_modules.rs b/src/css_modules.rs index 073babf0..1940d0d1 100644 --- a/src/css_modules.rs +++ b/src/css_modules.rs @@ -14,6 +14,7 @@ use crate::selector::SelectorList; use data_encoding::{Encoding, Specification}; use lazy_static::lazy_static; use pathdiff::diff_paths; +#[cfg(feature = "serde")] use serde::Serialize; use smallvec::{smallvec, SmallVec}; use std::borrow::Cow; @@ -164,8 +165,9 @@ pub enum Segment<'i> { /// A referenced name within a CSS module, e.g. via the `composes` property. /// /// See [CssModuleExport](CssModuleExport). -#[derive(PartialEq, Debug, Clone, Serialize)] -#[serde(tag = "type", rename_all = "lowercase")] +#[derive(PartialEq, Debug, Clone)] +#[cfg_attr(feature = "serde", derive(Serialize))] +#[cfg_attr(feature = "serde", serde(tag = "type", rename_all = "lowercase"))] pub enum CssModuleReference { /// A local reference. Local { @@ -187,8 +189,9 @@ pub enum CssModuleReference { } /// An exported value from a CSS module. -#[derive(PartialEq, Debug, Clone, Serialize)] -#[serde(rename_all = "camelCase")] +#[derive(PartialEq, Debug, Clone)] +#[cfg_attr(feature = "serde", derive(Serialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct CssModuleExport { /// The local (compiled) name for this export. pub name: String, diff --git a/src/dependencies.rs b/src/dependencies.rs index af32687d..dbb541d1 100644 --- a/src/dependencies.rs +++ b/src/dependencies.rs @@ -15,6 +15,7 @@ use crate::traits::ToCss; use crate::values::url::Url; use crate::visitor::Visit; use cssparser::SourceLocation; +#[cfg(feature = "serde")] use serde::Serialize; /// Options for `analyze_dependencies` in `PrinterOptions`. @@ -25,8 +26,9 @@ pub struct DependencyOptions { } /// A dependency. -#[derive(Serialize, Debug)] -#[serde(tag = "type", rename_all = "lowercase")] +#[derive(Debug)] +#[cfg_attr(feature = "serde", derive(Serialize))] +#[cfg_attr(feature = "serde", serde(tag = "type", rename_all = "lowercase"))] pub enum Dependency { /// An `@import` dependency. Import(ImportDependency), @@ -35,7 +37,8 @@ pub enum Dependency { } /// An `@import` dependency. -#[derive(Serialize, Debug)] +#[derive(Debug)] +#[cfg_attr(feature = "serde", derive(Serialize))] pub struct ImportDependency { /// The url to import. pub url: String, @@ -87,7 +90,8 @@ impl ImportDependency { } /// A `url()` dependency. -#[derive(Serialize, Debug)] +#[derive(Debug)] +#[cfg_attr(feature = "serde", derive(Serialize))] pub struct UrlDependency { /// The url of the dependency. pub url: String, @@ -110,8 +114,9 @@ impl UrlDependency { } /// Represents the range of source code where a dependency was found. -#[derive(Serialize, Debug)] -#[serde(rename_all = "camelCase")] +#[derive(Debug)] +#[cfg_attr(feature = "serde", derive(Serialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] pub struct SourceRange { /// The filename in which the dependency was found. pub file_path: String, @@ -122,8 +127,8 @@ pub struct SourceRange { } /// A line and column position within a source file. -#[derive(Serialize, Debug, Clone, Copy, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[derive(Debug, Clone, Copy, PartialEq, Visit)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Location { /// The line number, starting from 1. pub line: u32, diff --git a/src/error.rs b/src/error.rs index ecd9c9fd..824980fa 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,12 +5,13 @@ use crate::rules::Location; use crate::values::string::CowArcStr; use cssparser::{BasicParseErrorKind, ParseError, ParseErrorKind}; use parcel_selectors::parser::SelectorParseErrorKind; +#[cfg(feature = "serde")] use serde::Serialize; use std::fmt; /// An error with a source location. -#[derive(Debug, PartialEq, Clone, Serialize)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[derive(Debug, PartialEq, Clone)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Error { /// The type of error that occurred. pub kind: T, @@ -31,8 +32,8 @@ impl fmt::Display for Error { impl std::error::Error for Error {} /// A line and column location within a source file. -#[derive(Debug, PartialEq, Clone, Serialize)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[derive(Debug, PartialEq, Clone)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ErrorLocation { /// The filename in which the error occurred. pub filename: String, @@ -60,8 +61,9 @@ impl fmt::Display for ErrorLocation { } /// A parser error. -#[derive(Debug, PartialEq, Serialize, Clone)] -#[serde(tag = "type", content = "value")] +#[derive(Debug, PartialEq, Clone)] +#[cfg_attr(feature = "serde", derive(Serialize))] +#[cfg_attr(feature = "serde", serde(tag = "type", content = "value"))] pub enum ParserError<'i> { /// An at rule body was invalid. AtRuleBodyInvalid, @@ -90,7 +92,7 @@ pub enum ParserError<'i> { /// A `@namespace` rule was encountered after any rules besides `@charset`, `@import`, or `@layer`. UnexpectedNamespaceRule, /// An unexpected token was encountered. - UnexpectedToken(#[serde(skip)] Token<'i>), + UnexpectedToken(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), /// Maximum nesting depth was reached. MaximumNestingDepth, } @@ -164,23 +166,24 @@ impl<'i> ParserError<'i> { } /// A selector parsing error. -#[derive(Debug, PartialEq, Serialize, Clone)] -#[serde(tag = "type", content = "value")] +#[derive(Debug, PartialEq, Clone)] +#[cfg_attr(feature = "serde", derive(Serialize))] +#[cfg_attr(feature = "serde", serde(tag = "type", content = "value"))] pub enum SelectorError<'i> { /// An unexpected token was found in an attribute selector. - BadValueInAttr(#[serde(skip)] Token<'i>), + BadValueInAttr(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), /// An unexpected token was found in a class selector. - ClassNeedsIdent(#[serde(skip)] Token<'i>), + ClassNeedsIdent(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), /// A dangling combinator was found. DanglingCombinator, /// An empty selector. EmptySelector, /// A `|` was expected in an attribute selector. - ExpectedBarInAttr(#[serde(skip)] Token<'i>), + ExpectedBarInAttr(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), /// A namespace was expected. ExpectedNamespace(CowArcStr<'i>), /// An unexpected token was encountered in a namespace. - ExplicitNamespaceUnexpectedToken(#[serde(skip)] Token<'i>), + ExplicitNamespaceUnexpectedToken(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), /// An invalid pseudo class was encountered after a pseudo element. InvalidPseudoClassAfterPseudoElement, /// An invalid pseudo class was encountered after a `-webkit-scrollbar` pseudo element. @@ -188,7 +191,7 @@ pub enum SelectorError<'i> { /// A `-webkit-scrollbar` state was encountered before a `-webkit-scrollbar` pseudo element. InvalidPseudoClassBeforeWebKitScrollbar, /// Invalid qualified name in attribute selector. - InvalidQualNameInAttr(#[serde(skip)] Token<'i>), + InvalidQualNameInAttr(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), /// The current token is not allowed in this state. InvalidState, /// The selector is required to have the `&` nesting selector at the start. @@ -196,13 +199,13 @@ pub enum SelectorError<'i> { /// The selector is missing a `&` nesting selector. MissingNestingSelector, /// No qualified name in attribute selector. - NoQualifiedNameInAttributeSelector(#[serde(skip)] Token<'i>), + NoQualifiedNameInAttributeSelector(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), /// An Invalid token was encountered in a pseudo element. - PseudoElementExpectedIdent(#[serde(skip)] Token<'i>), + PseudoElementExpectedIdent(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), /// An unexpected identifier was encountered. UnexpectedIdent(CowArcStr<'i>), /// An unexpected token was encountered inside an attribute selector. - UnexpectedTokenInAttributeSelector(#[serde(skip)] Token<'i>), + UnexpectedTokenInAttributeSelector(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), /// An unsupported pseudo class or pseudo element was encountered. UnsupportedPseudoClassOrElement(CowArcStr<'i>), } @@ -291,8 +294,9 @@ impl std::error::Error for ErrorWithLocation {} pub(crate) type MinifyError = ErrorWithLocation; /// A transformation error. -#[derive(Debug, PartialEq, Serialize)] -#[serde(tag = "type")] +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "serde", derive(Serialize))] +#[cfg_attr(feature = "serde", serde(tag = "type"))] pub enum MinifyErrorKind { /// A circular `@custom-media` rule was detected. CircularCustomMedia { @@ -337,8 +341,9 @@ impl MinifyErrorKind { pub type PrinterError = Error; /// A printer error type. -#[derive(Debug, PartialEq, Serialize)] -#[serde(tag = "type")] +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "serde", Serialize)] +#[cfg_attr(feature = "serde", serde(tag = "type"))] pub enum PrinterErrorKind { /// An ambiguous relative `url()` was encountered in a custom property declaration. AmbiguousUrlInCustomProperty { diff --git a/src/rules/mod.rs b/src/rules/mod.rs index 85e16dde..98d39796 100644 --- a/src/rules/mod.rs +++ b/src/rules/mod.rs @@ -85,6 +85,7 @@ use media::MediaRule; use namespace::NamespaceRule; use nesting::NestingRule; use page::PageRule; +#[cfg(feature = "serde")] use serde::Serialize; use std::collections::{HashMap, HashSet}; use style::StyleRule; @@ -108,8 +109,8 @@ pub(crate) struct StyleContext<'a, 'i, T> { } /// A source location. -#[derive(PartialEq, Eq, Debug, Clone, Copy, Serialize)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[derive(PartialEq, Eq, Debug, Clone, Copy)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Location { /// The index of the source file within the source map. pub source_index: u32, diff --git a/src/targets.rs b/src/targets.rs index c87c92e1..56c6f576 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -1,6 +1,7 @@ //! Browser target options. // This file is autogenerated by build-prefixes.js. DO NOT EDIT! +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// Browser versions to compile CSS for. @@ -20,7 +21,8 @@ use serde::{Deserialize, Serialize}; /// ..Browsers::default() /// }; /// ``` -#[derive(Serialize, Debug, Deserialize, Clone, Copy, Default)] +#[derive(Debug, Clone, Copy, Default)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[allow(missing_docs)] pub struct Browsers { pub android: Option, diff --git a/src/values/string.rs b/src/values/string.rs index d97dde70..d66d448d 100644 --- a/src/values/string.rs +++ b/src/values/string.rs @@ -5,6 +5,7 @@ use crate::visitor::{Visit, VisitTypes, Visitor}; use cssparser::{serialize_string, CowRcStr}; #[cfg(feature = "serde")] use serde::{Deserialize, Deserializer}; +#[cfg(feature = "serde")] use serde::{Serialize, Serializer}; use std::borrow::Borrow; use std::cmp; @@ -219,6 +220,7 @@ impl<'a> fmt::Debug for CowArcStr<'a> { } } +#[cfg(feature = "serde")] impl<'a> Serialize for CowArcStr<'a> { fn serialize(&self, serializer: S) -> Result { self.as_ref().serialize(serializer) From c128787c1de338f5ddba094e49bdb0ccdf1f93ca Mon Sep 17 00:00:00 2001 From: Chinedu Francis Nwafili Date: Thu, 15 Dec 2022 19:58:27 -0500 Subject: [PATCH 2/4] Fix serde --- src/error.rs | 2 +- src/rules/mod.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/error.rs b/src/error.rs index 824980fa..37971e35 100644 --- a/src/error.rs +++ b/src/error.rs @@ -342,7 +342,7 @@ pub type PrinterError = Error; /// A printer error type. #[derive(Debug, PartialEq)] -#[cfg_attr(feature = "serde", Serialize)] +#[cfg_attr(feature = "serde", derive(Serialize))] #[cfg_attr(feature = "serde", serde(tag = "type"))] pub enum PrinterErrorKind { /// An ambiguous relative `url()` was encountered in a custom property declaration. diff --git a/src/rules/mod.rs b/src/rules/mod.rs index 98d39796..e8288d28 100644 --- a/src/rules/mod.rs +++ b/src/rules/mod.rs @@ -85,8 +85,6 @@ use media::MediaRule; use namespace::NamespaceRule; use nesting::NestingRule; use page::PageRule; -#[cfg(feature = "serde")] -use serde::Serialize; use std::collections::{HashMap, HashSet}; use style::StyleRule; use supports::SupportsRule; From 48ee25fa9b653aeac6b5855995a18cfab2fe482c Mon Sep 17 00:00:00 2001 From: Chinedu Francis Nwafili Date: Thu, 15 Dec 2022 20:34:24 -0500 Subject: [PATCH 3/4] Add "nodejs" flag --- Cargo.lock | 2 ++ Cargo.toml | 3 ++- node/Cargo.toml | 2 +- src/bundler.rs | 4 +-- src/css_modules.rs | 10 +++---- src/declaration.rs | 4 +-- src/dependencies.rs | 17 ++++++------ src/error.rs | 42 +++++++++++++++-------------- src/macros.rs | 10 +++---- src/media_query.rs | 26 +++++++++--------- src/parser.rs | 2 +- src/properties/align.rs | 18 ++++++------- src/properties/animation.rs | 10 +++---- src/properties/background.rs | 8 +++--- src/properties/border.rs | 4 +-- src/properties/border_image.rs | 8 +++--- src/properties/box_shadow.rs | 2 +- src/properties/contain.rs | 8 +++--- src/properties/css_modules.rs | 8 +++--- src/properties/custom.rs | 34 +++++++++++------------ src/properties/display.rs | 6 ++--- src/properties/effects.rs | 10 +++---- src/properties/font.rs | 20 +++++++------- src/properties/grid.rs | 46 ++++++++++++++++---------------- src/properties/list.rs | 14 +++++----- src/properties/masking.rs | 10 +++---- src/properties/mod.rs | 18 ++++++------- src/properties/outline.rs | 2 +- src/properties/position.rs | 4 +-- src/properties/size.rs | 4 +-- src/properties/svg.rs | 12 ++++----- src/properties/text.rs | 22 +++++++-------- src/properties/transform.rs | 16 +++++------ src/properties/transition.rs | 2 +- src/properties/ui.rs | 14 +++++----- src/rules/container.rs | 8 +++--- src/rules/counter_style.rs | 4 +-- src/rules/custom_media.rs | 4 +-- src/rules/document.rs | 4 +-- src/rules/font_face.rs | 22 +++++++-------- src/rules/font_palette_values.rs | 12 ++++----- src/rules/import.rs | 4 +-- src/rules/keyframes.rs | 16 +++++------ src/rules/layer.rs | 12 ++++----- src/rules/media.rs | 4 +-- src/rules/mod.rs | 11 ++++---- src/rules/namespace.rs | 6 ++--- src/rules/nesting.rs | 4 +-- src/rules/page.rs | 12 ++++----- src/rules/property.rs | 4 +-- src/rules/style.rs | 8 +++--- src/rules/supports.rs | 8 +++--- src/rules/unknown.rs | 4 +-- src/rules/viewport.rs | 4 +-- src/selector.rs | 4 +-- src/stylesheet.rs | 6 ++--- src/targets.rs | 6 ++--- src/values/alpha.rs | 2 +- src/values/angle.rs | 2 +- src/values/calc.rs | 4 +-- src/values/color.rs | 26 +++++++++--------- src/values/easing.rs | 4 +-- src/values/gradient.rs | 28 +++++++++---------- src/values/ident.rs | 16 +++++------ src/values/image.rs | 12 ++++----- src/values/length.rs | 8 +++--- src/values/percentage.rs | 6 ++--- src/values/position.rs | 4 +-- src/values/ratio.rs | 2 +- src/values/rect.rs | 2 +- src/values/resolution.rs | 2 +- src/values/shape.rs | 14 +++++----- src/values/size.rs | 2 +- src/values/string.rs | 16 +++++------ src/values/syntax.rs | 12 ++++----- src/values/time.rs | 2 +- src/values/url.rs | 4 +-- src/vendor_prefix.rs | 4 +-- 78 files changed, 384 insertions(+), 377 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a637f33..25e7d918 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -685,6 +685,7 @@ dependencies = [ "pathdiff", "predicates", "rayon", + "serde", "serde_json", "smallvec", ] @@ -695,6 +696,7 @@ version = "1.0.0-alpha.35" dependencies = [ "proc-macro2", "quote", + "syn", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index bd2153e4..e3d6d357 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,11 +27,12 @@ path = "src/lib.rs" crate-type = ["rlib"] [features] -default = ["bundler", "grid"] +default = ["bundler", "grid", "nodejs"] browserslist = ["browserslist-rs"] bundler = ["dashmap", "rayon"] cli = ["clap", "serde_json", "browserslist", "jemallocator"] grid = [] +nodejs = ["serde"] with-serde = ["serde", "smallvec/serde", "cssparser/serde"] [dependencies] diff --git a/node/Cargo.toml b/node/Cargo.toml index 33efefe9..534dc350 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -12,7 +12,7 @@ crate-type = ["cdylib"] serde = { version = "1.0.123", features = ["derive"] } serde_bytes = "0.11.5" cssparser = "0.29.1" -lightningcss = { path = "../" } +lightningcss = { path = "../", features = ["nodejs"] } parcel_sourcemap = { version = "2.1.1", features = ["json"] } [target.'cfg(target_os = "macos")'.dependencies] diff --git a/src/bundler.rs b/src/bundler.rs index d239c836..505c8f09 100644 --- a/src/bundler.rs +++ b/src/bundler.rs @@ -144,7 +144,7 @@ impl Drop for FileProvider { /// An error that could occur during bundling. #[derive(Debug)] -#[cfg_attr(feature = "serde", serde::Serialize)] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(serde::Serialize))] pub enum BundleErrorKind<'i, T: std::error::Error> { /// A parser error occurred. ParserError(ParserError<'i>), @@ -155,7 +155,7 @@ pub enum BundleErrorKind<'i, T: std::error::Error> { /// Unsupported media query boolean logic was encountered. UnsupportedMediaBooleanLogic, /// A custom resolver error. - ResolverError(#[cfg_attr(feature = "serde", serde(skip))] T), + ResolverError(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] T), } impl<'i, T: std::error::Error> From>> for Error> { diff --git a/src/css_modules.rs b/src/css_modules.rs index 1940d0d1..4ad65992 100644 --- a/src/css_modules.rs +++ b/src/css_modules.rs @@ -14,7 +14,7 @@ use crate::selector::SelectorList; use data_encoding::{Encoding, Specification}; use lazy_static::lazy_static; use pathdiff::diff_paths; -#[cfg(feature = "serde")] +#[cfg(any(feature = "with-serde", feature = "nodejs"))] use serde::Serialize; use smallvec::{smallvec, SmallVec}; use std::borrow::Cow; @@ -166,8 +166,8 @@ pub enum Segment<'i> { /// /// See [CssModuleExport](CssModuleExport). #[derive(PartialEq, Debug, Clone)] -#[cfg_attr(feature = "serde", derive(Serialize))] -#[cfg_attr(feature = "serde", serde(tag = "type", rename_all = "lowercase"))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(tag = "type", rename_all = "lowercase"))] pub enum CssModuleReference { /// A local reference. Local { @@ -190,8 +190,8 @@ pub enum CssModuleReference { /// An exported value from a CSS module. #[derive(PartialEq, Debug, Clone)] -#[cfg_attr(feature = "serde", derive(Serialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(rename_all = "camelCase"))] pub struct CssModuleExport { /// The local (compiled) name for this export. pub name: String, diff --git a/src/declaration.rs b/src/declaration.rs index 89a0e63b..9f33d95d 100644 --- a/src/declaration.rs +++ b/src/declaration.rs @@ -43,10 +43,10 @@ use cssparser::*; /// and a list of normal declarations. This reduces memory usage compared /// with storing a boolean along with each property. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct DeclarationBlock<'i> { /// A list of `!important` declarations in the block. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub important_declarations: Vec>, /// A list of normal declarations in the block. pub declarations: Vec>, diff --git a/src/dependencies.rs b/src/dependencies.rs index dbb541d1..1c957682 100644 --- a/src/dependencies.rs +++ b/src/dependencies.rs @@ -15,7 +15,7 @@ use crate::traits::ToCss; use crate::values::url::Url; use crate::visitor::Visit; use cssparser::SourceLocation; -#[cfg(feature = "serde")] +#[cfg(any(feature = "with-serde", feature = "nodejs"))] use serde::Serialize; /// Options for `analyze_dependencies` in `PrinterOptions`. @@ -27,8 +27,8 @@ pub struct DependencyOptions { /// A dependency. #[derive(Debug)] -#[cfg_attr(feature = "serde", derive(Serialize))] -#[cfg_attr(feature = "serde", serde(tag = "type", rename_all = "lowercase"))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(tag = "type", rename_all = "lowercase"))] pub enum Dependency { /// An `@import` dependency. Import(ImportDependency), @@ -38,7 +38,7 @@ pub enum Dependency { /// An `@import` dependency. #[derive(Debug)] -#[cfg_attr(feature = "serde", derive(Serialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] pub struct ImportDependency { /// The url to import. pub url: String, @@ -91,7 +91,7 @@ impl ImportDependency { /// A `url()` dependency. #[derive(Debug)] -#[cfg_attr(feature = "serde", derive(Serialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] pub struct UrlDependency { /// The url of the dependency. pub url: String, @@ -115,8 +115,8 @@ impl UrlDependency { /// Represents the range of source code where a dependency was found. #[derive(Debug)] -#[cfg_attr(feature = "serde", derive(Serialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(rename_all = "camelCase"))] pub struct SourceRange { /// The filename in which the dependency was found. pub file_path: String, @@ -128,7 +128,8 @@ pub struct SourceRange { /// A line and column position within a source file. #[derive(Debug, Clone, Copy, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(serde::Serialize))] +#[cfg_attr(any(feature = "with-serde"), derive(serde::Deserialize))] pub struct Location { /// The line number, starting from 1. pub line: u32, diff --git a/src/error.rs b/src/error.rs index 37971e35..ec8a99c1 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,13 +5,14 @@ use crate::rules::Location; use crate::values::string::CowArcStr; use cssparser::{BasicParseErrorKind, ParseError, ParseErrorKind}; use parcel_selectors::parser::SelectorParseErrorKind; -#[cfg(feature = "serde")] +#[cfg(any(feature = "with-serde", feature = "nodejs"))] use serde::Serialize; use std::fmt; /// An error with a source location. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(serde::Serialize))] +#[cfg_attr(any(feature = "with-serde"), derive(serde::Deserialize))] pub struct Error { /// The type of error that occurred. pub kind: T, @@ -33,7 +34,8 @@ impl std::error::Error for Error {} /// A line and column location within a source file. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(serde::Serialize))] +#[cfg_attr(any(feature = "with-serde"), derive(serde::Deserialize))] pub struct ErrorLocation { /// The filename in which the error occurred. pub filename: String, @@ -62,8 +64,8 @@ impl fmt::Display for ErrorLocation { /// A parser error. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(feature = "serde", derive(Serialize))] -#[cfg_attr(feature = "serde", serde(tag = "type", content = "value"))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(tag = "type", content = "value"))] pub enum ParserError<'i> { /// An at rule body was invalid. AtRuleBodyInvalid, @@ -92,7 +94,7 @@ pub enum ParserError<'i> { /// A `@namespace` rule was encountered after any rules besides `@charset`, `@import`, or `@layer`. UnexpectedNamespaceRule, /// An unexpected token was encountered. - UnexpectedToken(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), + UnexpectedToken(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), /// Maximum nesting depth was reached. MaximumNestingDepth, } @@ -167,23 +169,23 @@ impl<'i> ParserError<'i> { /// A selector parsing error. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(feature = "serde", derive(Serialize))] -#[cfg_attr(feature = "serde", serde(tag = "type", content = "value"))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(tag = "type", content = "value"))] pub enum SelectorError<'i> { /// An unexpected token was found in an attribute selector. - BadValueInAttr(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), + BadValueInAttr(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), /// An unexpected token was found in a class selector. - ClassNeedsIdent(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), + ClassNeedsIdent(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), /// A dangling combinator was found. DanglingCombinator, /// An empty selector. EmptySelector, /// A `|` was expected in an attribute selector. - ExpectedBarInAttr(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), + ExpectedBarInAttr(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), /// A namespace was expected. ExpectedNamespace(CowArcStr<'i>), /// An unexpected token was encountered in a namespace. - ExplicitNamespaceUnexpectedToken(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), + ExplicitNamespaceUnexpectedToken(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), /// An invalid pseudo class was encountered after a pseudo element. InvalidPseudoClassAfterPseudoElement, /// An invalid pseudo class was encountered after a `-webkit-scrollbar` pseudo element. @@ -191,7 +193,7 @@ pub enum SelectorError<'i> { /// A `-webkit-scrollbar` state was encountered before a `-webkit-scrollbar` pseudo element. InvalidPseudoClassBeforeWebKitScrollbar, /// Invalid qualified name in attribute selector. - InvalidQualNameInAttr(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), + InvalidQualNameInAttr(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), /// The current token is not allowed in this state. InvalidState, /// The selector is required to have the `&` nesting selector at the start. @@ -199,13 +201,13 @@ pub enum SelectorError<'i> { /// The selector is missing a `&` nesting selector. MissingNestingSelector, /// No qualified name in attribute selector. - NoQualifiedNameInAttributeSelector(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), + NoQualifiedNameInAttributeSelector(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), /// An Invalid token was encountered in a pseudo element. - PseudoElementExpectedIdent(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), + PseudoElementExpectedIdent(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), /// An unexpected identifier was encountered. UnexpectedIdent(CowArcStr<'i>), /// An unexpected token was encountered inside an attribute selector. - UnexpectedTokenInAttributeSelector(#[cfg_attr(feature = "serde", serde(skip))] Token<'i>), + UnexpectedTokenInAttributeSelector(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), /// An unsupported pseudo class or pseudo element was encountered. UnsupportedPseudoClassOrElement(CowArcStr<'i>), } @@ -295,8 +297,8 @@ pub(crate) type MinifyError = ErrorWithLocation; /// A transformation error. #[derive(Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize))] -#[cfg_attr(feature = "serde", serde(tag = "type"))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(tag = "type"))] pub enum MinifyErrorKind { /// A circular `@custom-media` rule was detected. CircularCustomMedia { @@ -342,8 +344,8 @@ pub type PrinterError = Error; /// A printer error type. #[derive(Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize))] -#[cfg_attr(feature = "serde", serde(tag = "type"))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(tag = "type"))] pub enum PrinterErrorKind { /// An ambiguous relative `url()` was encountered in a custom property declaration. AmbiguousUrlInCustomProperty { diff --git a/src/macros.rs b/src/macros.rs index 142ba01f..b40ea387 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -10,7 +10,7 @@ macro_rules! enum_property { ) => { $(#[$outer])* #[derive(Debug, Clone, Copy, PartialEq, Visit)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "lowercase"))] + #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "lowercase"))] $vis enum $name { $( $(#[$meta])* @@ -67,11 +67,11 @@ macro_rules! enum_property { ) => { $(#[$outer])* #[derive(Debug, Clone, Copy, PartialEq, Visit)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] $vis enum $name { $( $(#[$meta])* - #[cfg_attr(feature = "serde", serde(rename = $str))] + #[cfg_attr(feature = "with-serde", serde(rename = $str))] $id, )+ } @@ -340,7 +340,7 @@ macro_rules! define_shorthand { ) => { $(#[$outer])* #[derive(Debug, Clone, PartialEq, Visit)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct $name$(<$l>)? { $( $(#[$meta])* @@ -554,7 +554,7 @@ macro_rules! define_list_shorthand { ) => { $(#[$outer])* #[derive(Debug, Clone, PartialEq, Visit)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct $name$(<$l>)? { $( $(#[$meta])* diff --git a/src/media_query.rs b/src/media_query.rs index 34f60cc7..11dd5b6b 100644 --- a/src/media_query.rs +++ b/src/media_query.rs @@ -18,10 +18,10 @@ use std::collections::{HashMap, HashSet}; /// A [media query list](https://drafts.csswg.org/mediaqueries/#mq-list). #[derive(Clone, Debug, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct MediaList<'i> { /// The list of media queries. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub media_queries: Vec>, } @@ -146,7 +146,7 @@ enum_property! { /// A [media type](https://drafts.csswg.org/mediaqueries/#media-types) within a media query. #[derive(Clone, Debug, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -159,7 +159,7 @@ pub enum MediaType<'i> { /// Matches all devices that aren’t matched by print. Screen, /// An unknown media type. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Custom(CowArcStr<'i>), } @@ -178,12 +178,12 @@ impl<'i> Parse<'i> for MediaType<'i> { /// A [media query](https://drafts.csswg.org/mediaqueries/#media). #[derive(Clone, Debug, PartialEq, Visit)] #[visit(visit_media_query, MEDIA_QUERIES)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct MediaQuery<'i> { /// The qualifier for this query. pub qualifier: Option, /// The media type for this query, that can be known, unknown, or "all". - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub media_type: MediaType<'i>, /// The condition that this media query contains. This cannot have `or` /// in the first level. @@ -362,13 +362,13 @@ enum_property! { /// Represents a media condition. #[derive(Clone, Debug, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum MediaCondition<'i> { /// A media feature, implicitly parenthesized. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Feature(MediaFeature<'i>), /// A negation of a condition. #[skip_type] @@ -497,7 +497,7 @@ impl<'i> ToCss for MediaCondition<'i> { /// A [comparator](https://drafts.csswg.org/mediaqueries/#typedef-mf-comparison) within a media query. #[derive(Clone, Copy, Debug, Eq, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -553,7 +553,7 @@ impl MediaFeatureComparison { /// A [media feature](https://drafts.csswg.org/mediaqueries/#typedef-media-feature) #[derive(Clone, Debug, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -561,7 +561,7 @@ pub enum MediaFeature<'i> { /// A plain media feature, e.g. `(min-width: 240px)`. Plain { /// The name of the feature. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] name: Ident<'i>, /// The feature value. value: MediaFeatureValue<'i>, @@ -755,7 +755,7 @@ where /// See [MediaFeature](MediaFeature). #[derive(Clone, Debug, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -769,7 +769,7 @@ pub enum MediaFeatureValue<'i> { /// A ratio. Ratio(Ratio), /// An indentifier. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Ident(Ident<'i>), } diff --git a/src/parser.rs b/src/parser.rs index 87e4b733..1fe92607 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -99,7 +99,7 @@ impl<'i> AtRuleParser<'i> for DefaultAtRuleParser { } #[derive(PartialEq, Clone, Debug)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct DefaultAtRule; impl crate::traits::ToCss for DefaultAtRule { fn to_css(&self, _: &mut Printer) -> Result<(), PrinterError> { diff --git a/src/properties/align.rs b/src/properties/align.rs index ef015549..b04abf08 100644 --- a/src/properties/align.rs +++ b/src/properties/align.rs @@ -20,7 +20,7 @@ use cssparser::*; /// as used in the alignment properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -109,7 +109,7 @@ enum_property! { /// A value for the [align-content](https://www.w3.org/TR/css-align-3/#propdef-align-content) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -168,7 +168,7 @@ impl ToCss for AlignContent { /// A value for the [justify-content](https://www.w3.org/TR/css-align-3/#propdef-justify-content) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -329,7 +329,7 @@ enum_property! { /// A value for the [align-self](https://www.w3.org/TR/css-align-3/#align-self-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -395,7 +395,7 @@ impl ToCss for AlignSelf { /// A value for the [justify-self](https://www.w3.org/TR/css-align-3/#justify-self-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -551,7 +551,7 @@ impl ToCss for PlaceSelf { /// A value for the [align-items](https://www.w3.org/TR/css-align-3/#align-items-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -610,7 +610,7 @@ impl ToCss for AlignItems { /// A legacy justification keyword, as used in the `justify-items` property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -676,7 +676,7 @@ impl ToCss for LegacyJustify { /// A value for the [justify-items](https://www.w3.org/TR/css-align-3/#justify-items-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -831,7 +831,7 @@ impl ToCss for PlaceItems { /// `column-gap` and `row-gap` properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/properties/animation.rs b/src/properties/animation.rs index b4aad1ee..28ada03e 100644 --- a/src/properties/animation.rs +++ b/src/properties/animation.rs @@ -20,7 +20,7 @@ use smallvec::SmallVec; /// A value for the [animation-name](https://drafts.csswg.org/css-animations/#animation-name) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -28,10 +28,10 @@ pub enum AnimationName<'i> { /// The `none` keyword. None, /// An identifier of a `@keyframes` rule. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Ident(CustomIdent<'i>), /// A `` name of a `@keyframes` rule. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] String(CowArcStr<'i>), } @@ -89,7 +89,7 @@ pub type AnimationNameList<'i> = SmallVec<[AnimationName<'i>; 1]>; /// A value for the [animation-iteration-count](https://drafts.csswg.org/css-animations/#animation-iteration-count) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -189,7 +189,7 @@ define_list_shorthand! { /// A value for the [animation](https://drafts.csswg.org/css-animations/#animation) shorthand property. pub struct Animation<'i>(VendorPrefix) { /// The animation name. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] name: AnimationName(AnimationName<'i>, VendorPrefix), /// The animation duration. duration: AnimationDuration(Time, VendorPrefix), diff --git a/src/properties/background.rs b/src/properties/background.rs index 2000b03b..e700a110 100644 --- a/src/properties/background.rs +++ b/src/properties/background.rs @@ -20,7 +20,7 @@ use smallvec::SmallVec; /// A value for the [background-size](https://www.w3.org/TR/css-backgrounds-3/#background-size) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -110,7 +110,7 @@ enum_property! { /// A value for the [background-repeat](https://www.w3.org/TR/css-backgrounds-3/#background-repeat) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct BackgroundRepeat { /// A repeat style for the x direction. pub x: BackgroundRepeatKeyword, @@ -300,10 +300,10 @@ impl ToCss for BackgroundPosition { /// A value for the [background](https://www.w3.org/TR/css-backgrounds-3/#background) shorthand property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Background<'i> { /// The background image. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub image: Image<'i>, /// The background color. pub color: CssColor, diff --git a/src/properties/border.rs b/src/properties/border.rs index e1e30fa2..a8eba5c6 100644 --- a/src/properties/border.rs +++ b/src/properties/border.rs @@ -23,7 +23,7 @@ use cssparser::*; /// A value for the [border-width](https://www.w3.org/TR/css-backgrounds-3/#border-width) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -109,7 +109,7 @@ impl Default for LineStyle { /// A generic type that represents the `border` and `outline` shorthand properties. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct GenericBorder { /// The width of the border. pub width: BorderSideWidth, diff --git a/src/properties/border_image.rs b/src/properties/border_image.rs index d32ab2dd..1f971bd2 100644 --- a/src/properties/border_image.rs +++ b/src/properties/border_image.rs @@ -38,7 +38,7 @@ enum_property! { /// A value for the [border-image-repeat](https://www.w3.org/TR/css-backgrounds-3/#border-image-repeat) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct BorderImageRepeat { /// The horizontal repeat value. pub horizontal: BorderImageRepeatKeyword, @@ -83,7 +83,7 @@ impl ToCss for BorderImageRepeat { /// A value for the [border-image-width](https://www.w3.org/TR/css-backgrounds-3/#border-image-width) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -136,7 +136,7 @@ impl ToCss for BorderImageSideWidth { /// A value for the [border-image-slice](https://www.w3.org/TR/css-backgrounds-3/#border-image-slice) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct BorderImageSlice { /// The offsets from the edges of the image. pub offsets: Rect, @@ -182,7 +182,7 @@ define_shorthand! { #[derive(Default)] pub struct BorderImage<'i>(VendorPrefix) { /// The border image. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] source: BorderImageSource(Image<'i>), /// The offsets that define where the image is sliced. slice: BorderImageSlice(BorderImageSlice), diff --git a/src/properties/box_shadow.rs b/src/properties/box_shadow.rs index c972b2fb..b07379d1 100644 --- a/src/properties/box_shadow.rs +++ b/src/properties/box_shadow.rs @@ -18,7 +18,7 @@ use smallvec::SmallVec; /// A value for the [box-shadow](https://drafts.csswg.org/css-backgrounds/#box-shadow) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct BoxShadow { /// The color of the box shadow. pub color: CssColor, diff --git a/src/properties/contain.rs b/src/properties/contain.rs index 5d8816a6..9ca9a154 100644 --- a/src/properties/contain.rs +++ b/src/properties/contain.rs @@ -25,7 +25,7 @@ bitflags! { /// /// `normal` is mutually exclusive, but other combinations of flags are allowed. #[derive(Visit)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct ContainerType: u8 { /// The element is not a query container for any container size queries, /// but remains a query container for container style queries. @@ -90,7 +90,7 @@ impl ToCss for ContainerType { /// A value for the [container-name](https://drafts.csswg.org/css-contain-3/#container-name) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -98,7 +98,7 @@ pub enum ContainerNameList<'i> { /// The `none` keyword. None, /// A list of container names. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Names(SmallVec<[ContainerIdent<'i>; 1]>), } @@ -154,7 +154,7 @@ define_shorthand! { /// A value for the [container](https://drafts.csswg.org/css-contain-3/#container-shorthand) shorthand property. pub struct Container<'i> { /// The container name. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] name: ContainerName(ContainerNameList<'i>), /// The container type. container_type: ContainerType(ContainerType), diff --git a/src/properties/css_modules.rs b/src/properties/css_modules.rs index 25d3a446..33cbc5f5 100644 --- a/src/properties/css_modules.rs +++ b/src/properties/css_modules.rs @@ -12,10 +12,10 @@ use smallvec::SmallVec; /// A value for the [composes](https://github.com/css-modules/css-modules/#dependencies) property from CSS modules. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Composes<'i> { /// A list of class names to compose. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub names: CustomIdentList<'i>, /// Where the class names are composed from. pub from: Option>, @@ -28,7 +28,7 @@ pub struct Composes<'i> { /// See [Composes](Composes). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -36,7 +36,7 @@ pub enum Specifier<'i> { /// The referenced name is global. Global, /// The referenced name comes from the specified file. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] File(CowArcStr<'i>), /// The referenced name comes from a source index (used during bundling). SourceIndex(u32), diff --git a/src/properties/custom.rs b/src/properties/custom.rs index 94c2d115..ff813dda 100644 --- a/src/properties/custom.rs +++ b/src/properties/custom.rs @@ -26,10 +26,10 @@ use cssparser::*; /// A CSS custom property, representing any unknown property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct CustomProperty<'i> { /// The name of the property. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub name: CowArcStr<'i>, /// The property value, stored as a raw token list. pub value: TokenList<'i>, @@ -55,12 +55,12 @@ impl<'i> CustomProperty<'i> { /// be parsed, e.g. in the case css `var()` references are encountered. /// In this case, the raw tokens are stored instead. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct UnparsedProperty<'i> { /// The id of the property. pub property_id: PropertyId<'i>, /// The property value, stored as a raw token list. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub value: TokenList<'i>, } @@ -98,20 +98,20 @@ impl<'i> UnparsedProperty<'i> { /// A raw list of CSS tokens, with embedded parsed values. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenList<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub Vec>); +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +pub struct TokenList<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub Vec>); /// A raw CSS token, or a parsed value. #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_token, TOKENS)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum TokenOrValue<'i> { /// A token. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Token(Token<'i>), /// A parsed CSS color. Color(CssColor), @@ -441,13 +441,13 @@ impl<'i> TokenList<'i> { // Copied from cssparser to change CowRcStr to CowArcStr #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum Token<'a> { /// A [``](https://drafts.csswg.org/css-syntax/#ident-token-diagram) - Ident(#[cfg_attr(feature = "serde", serde(borrow))] CowArcStr<'a>), + Ident(#[cfg_attr(feature = "with-serde", serde(borrow))] CowArcStr<'a>), /// A [``](https://drafts.csswg.org/css-syntax/#at-keyword-token-diagram) /// @@ -824,10 +824,10 @@ impl<'i> TokenList<'i> { /// A CSS variable reference. #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_variable, VARIABLES)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Variable<'i> { /// The variable name. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub name: DashedIdentReference<'i>, /// A fallback value in case the variable is not defined. #[skip_type] @@ -875,10 +875,10 @@ impl<'i> Variable<'i> { /// A custom CSS function. #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_function, FUNCTIONS)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Function<'i> { /// The function name. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub name: Ident<'i>, /// The function arguments. #[skip_type] @@ -910,7 +910,7 @@ impl<'i> Function<'i> { /// since variables can resolve to multiple tokens. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "lowercase") )] @@ -924,7 +924,7 @@ pub enum UnresolvedColor<'i> { /// The blue component. b: f32, /// The unresolved alpha component. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] #[skip_type] alpha: TokenList<'i>, }, @@ -937,7 +937,7 @@ pub enum UnresolvedColor<'i> { /// The lightness component. l: f32, /// The unresolved alpha component. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] #[skip_type] alpha: TokenList<'i>, }, diff --git a/src/properties/display.rs b/src/properties/display.rs index 40039d66..dc7eda79 100644 --- a/src/properties/display.rs +++ b/src/properties/display.rs @@ -27,7 +27,7 @@ enum_property! { /// A [``](https://drafts.csswg.org/css-display-3/#typedef-display-inside) value. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "kebab-case") )] @@ -107,7 +107,7 @@ impl DisplayInside { /// /// See [Display](Display). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct DisplayPair { /// The outside display value. pub outside: DisplayOutside, @@ -321,7 +321,7 @@ enum_property! { /// A value for the [display](https://drafts.csswg.org/css-display-3/#the-display-properties) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/properties/effects.rs b/src/properties/effects.rs index e867f9a4..d50fbd5f 100644 --- a/src/properties/effects.rs +++ b/src/properties/effects.rs @@ -13,7 +13,7 @@ use smallvec::SmallVec; /// A [filter](https://drafts.fxtf.org/filter-effects-1/#filter-functions) function. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -39,7 +39,7 @@ pub enum Filter<'i> { /// A `drop-shadow()` filter. DropShadow(DropShadow), /// A `url()` reference to an SVG filter. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Url(Url<'i>), } @@ -207,7 +207,7 @@ impl<'i> Filter<'i> { /// A [`drop-shadow()`](https://drafts.fxtf.org/filter-effects-1/#funcdef-filter-drop-shadow) filter function. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct DropShadow { /// The color of the drop shadow. pub color: CssColor, @@ -295,7 +295,7 @@ impl DropShadow { /// [backdrop-filter](https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty) properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -303,7 +303,7 @@ pub enum FilterList<'i> { /// The `none` keyword. None, /// A list of filter functions. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Filters(SmallVec<[Filter<'i>; 1]>), } diff --git a/src/properties/font.rs b/src/properties/font.rs index bfca1ab9..2432365f 100644 --- a/src/properties/font.rs +++ b/src/properties/font.rs @@ -19,7 +19,7 @@ use cssparser::*; /// A value for the [font-weight](https://www.w3.org/TR/css-fonts-4/#font-weight-prop) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -76,7 +76,7 @@ impl ToCss for FontWeight { /// See [FontWeight](FontWeight). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -159,7 +159,7 @@ enum_property! { /// A value for the [font-size](https://www.w3.org/TR/css-fonts-4/#font-size-prop) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -255,7 +255,7 @@ impl Into for &FontStretchKeyword { /// A value for the [font-stretch](https://www.w3.org/TR/css-fonts-4/#font-stretch-prop) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -351,13 +351,13 @@ enum_property! { /// A value for the [font-family](https://www.w3.org/TR/css-fonts-4/#font-family-prop) property. #[derive(Debug, Clone, PartialEq, Eq, Hash, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum FontFamily<'i> { /// A custom family name. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] FamilyName(CowArcStr<'i>), /// A generic family name. Generic(GenericFontFamily), @@ -432,7 +432,7 @@ impl<'i> ToCss for FontFamily<'i> { /// A value for the [font-style](https://www.w3.org/TR/css-fonts-4/#font-style-prop) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -532,7 +532,7 @@ impl FontVariantCaps { /// A value for the [line-height](https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-line-height) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -604,7 +604,7 @@ enum_property! { // TODO: there is a more extensive spec in CSS3 but it doesn't seem any browser implements it? https://www.w3.org/TR/css-inline-3/#transverse-alignment #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -642,7 +642,7 @@ define_shorthand! { /// A value for the [font](https://www.w3.org/TR/css-fonts-4/#font-prop) shorthand property. pub struct Font<'i> { /// The font family. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] family: FontFamily(Vec>), /// The font size. size: FontSize(FontSize), diff --git a/src/properties/grid.rs b/src/properties/grid.rs index 7c7b91ba..7b23705b 100644 --- a/src/properties/grid.rs +++ b/src/properties/grid.rs @@ -22,7 +22,7 @@ use smallvec::SmallVec; /// for the `grid-template-rows` and `grid-template-columns` properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -30,7 +30,7 @@ pub enum TrackSizing<'i> { /// No explicit grid tracks. None, /// A list of grid tracks. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] TrackList(TrackList<'i>), } @@ -39,10 +39,10 @@ pub enum TrackSizing<'i> { /// /// See [TrackSizing](TrackSizing). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct TrackList<'i> { /// A list of line names. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub line_names: Vec>, /// A list of grid track items. pub items: Vec>, @@ -53,7 +53,7 @@ pub struct TrackList<'i> { /// See [TrackList](TrackList). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -61,7 +61,7 @@ pub enum TrackListItem<'i> { /// A track size. TrackSize(TrackSize), /// A `repeat()` function. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] TrackRepeat(TrackRepeat<'i>), } @@ -71,7 +71,7 @@ pub enum TrackListItem<'i> { /// See [TrackListItem](TrackListItem). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -93,7 +93,7 @@ impl Default for TrackSize { /// A [track size list](https://drafts.csswg.org/css-grid-2/#auto-tracks), as used /// in the `grid-auto-rows` and `grid-auto-columns` properties. #[derive(Debug, Clone, PartialEq, Default, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct TrackSizeList(pub SmallVec<[TrackSize; 1]>); /// A [``](https://drafts.csswg.org/css-grid-2/#typedef-track-breadth) value. @@ -101,7 +101,7 @@ pub struct TrackSizeList(pub SmallVec<[TrackSize; 1]>); /// See [TrackSize](TrackSize). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -123,12 +123,12 @@ pub enum TrackBreadth { /// /// See [TrackListItem](TrackListItem). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct TrackRepeat<'i> { /// The repeat count. count: RepeatCount, /// The line names to repeat. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] line_names: Vec>, /// The track sizes to repeat. track_sizes: Vec, @@ -140,7 +140,7 @@ pub struct TrackRepeat<'i> { /// See [TrackRepeat](TrackRepeat). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -540,7 +540,7 @@ impl ToCss for TrackSizeList { /// A value for the [grid-template-areas](https://drafts.csswg.org/css-grid-2/#grid-template-areas-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -708,10 +708,10 @@ impl GridTemplateAreas { /// /// If `areas` is not `None`, then `rows` must also not be `None`. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct GridTemplate<'i> { /// The grid template rows. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub rows: TrackSizing<'i>, /// The grid template columns. pub columns: TrackSizing<'i>, @@ -937,7 +937,7 @@ bitflags! { /// The `Row` or `Column` flags may be combined with the `Dense` flag, but the `Row` and `Column` flags may /// not be combined. #[derive(Visit)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct GridAutoFlow: u8 { /// The auto-placement algorithm places items by filling each row, adding new rows as necessary. const Row = 0b00; @@ -1037,10 +1037,10 @@ impl ToCss for GridAutoFlow { /// /// Explicit and implicit values may not be combined. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Grid<'i> { /// Explicit grid template rows. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub rows: TrackSizing<'i>, /// Explicit grid template columns. pub columns: TrackSizing<'i>, @@ -1220,7 +1220,7 @@ impl_shorthand! { /// used in the `grid-row-start`, `grid-row-end`, `grid-column-start`, and `grid-column-end` properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -1232,7 +1232,7 @@ pub enum GridLine<'i> { /// The Nth grid line, optionally filtered by line name. Negative numbers count backwards from the end. Line( CSSInteger, - #[cfg_attr(feature = "serde", serde(borrow))] Option>, + #[cfg_attr(feature = "with-serde", serde(borrow))] Option>, ), /// A grid span based on the Nth grid line from the opposite edge, optionally filtered by line name. Span(CSSInteger, Option>), @@ -1373,7 +1373,7 @@ define_shorthand! { /// A value for the [grid-row](https://drafts.csswg.org/css-grid-2/#propdef-grid-row) shorthand property. pub struct GridRow<'i> { /// The starting line. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] start: GridRowStart(GridLine<'i>), /// The ending line. end: GridRowEnd(GridLine<'i>), @@ -1384,7 +1384,7 @@ define_shorthand! { /// A value for the [grid-row](https://drafts.csswg.org/css-grid-2/#propdef-grid-column) shorthand property. pub struct GridColumn<'i> { /// The starting line. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] start: GridColumnStart(GridLine<'i>), /// The ending line. end: GridColumnEnd(GridLine<'i>), @@ -1398,7 +1398,7 @@ define_shorthand! { /// A value for the [grid-area](https://drafts.csswg.org/css-grid-2/#propdef-grid-area) shorthand property. pub struct GridArea<'i> { /// The grid row start placement. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] row_start: GridRowStart(GridLine<'i>), /// The grid column start placement. column_start: GridColumnStart(GridLine<'i>), diff --git a/src/properties/list.rs b/src/properties/list.rs index 54ec3fbd..a0acc5e3 100644 --- a/src/properties/list.rs +++ b/src/properties/list.rs @@ -16,7 +16,7 @@ use cssparser::*; /// A value for the [list-style-type](https://www.w3.org/TR/2020/WD-css-lists-3-20201117/#text-markers) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -24,7 +24,7 @@ pub enum ListStyleType<'i> { /// No marker. None, /// An explicit marker string. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] String(CSSString<'i>), /// A named counter style. CounterStyle(CounterStyle<'i>), @@ -67,7 +67,7 @@ impl ToCss for ListStyleType<'_> { /// A [counter-style](https://www.w3.org/TR/css-counter-styles-3/#typedef-counter-style) name. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -79,7 +79,7 @@ pub enum CounterStyle<'i> { /// An inline [`symbols()`](https://www.w3.org/TR/css-counter-styles-3/#symbols-function) definition. Symbols( SymbolsType, - #[cfg_attr(feature = "serde", serde(borrow))] Vec>, + #[cfg_attr(feature = "with-serde", serde(borrow))] Vec>, ), } @@ -232,13 +232,13 @@ enum_property! { /// See [CounterStyle](CounterStyle). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum Symbol<'i> { /// A string. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] String(CSSString<'i>), /// An image. Image(Image<'i>), @@ -296,7 +296,7 @@ shorthand_property! { /// A value for the [list-style](https://www.w3.org/TR/2020/WD-css-lists-3-20201117/#list-style-property) shorthand property. pub struct ListStyle<'i> { /// The list style type. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] list_style_type: ListStyleType(ListStyleType<'i>), /// The list marker image. image: ListStyleImage(Image<'i>), diff --git a/src/properties/masking.rs b/src/properties/masking.rs index 9583ba80..73a49f83 100644 --- a/src/properties/masking.rs +++ b/src/properties/masking.rs @@ -105,7 +105,7 @@ impl Default for GeometryBox { /// A value for the [mask-clip](https://www.w3.org/TR/css-masking-1/#the-mask-clip) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -205,7 +205,7 @@ define_list_shorthand! { /// A value for the [mask](https://www.w3.org/TR/css-masking-1/#the-mask) shorthand property. pub struct Mask<'i>(VendorPrefix) { /// The mask image. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] image: MaskImage(Image<'i>, VendorPrefix), /// The position of the mask. position: MaskPosition(Position, VendorPrefix), @@ -375,7 +375,7 @@ impl<'i> ImageFallback<'i> for Mask<'i> { /// A value for the [clip-path](https://www.w3.org/TR/css-masking-1/#the-clip-path) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -383,7 +383,7 @@ pub enum ClipPath<'i> { /// No clip path. None, /// A url reference to an SVG path element. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Url(Url<'i>), /// A basic shape, positioned according to the reference box. Shape(Box, GeometryBox), @@ -456,7 +456,7 @@ define_shorthand! { #[derive(Default)] pub struct MaskBorder<'i> { /// The mask image. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] source: MaskBorderSource(Image<'i>), /// The offsets that define where the image is sliced. slice: MaskBorderSlice(BorderImageSlice), diff --git a/src/properties/mod.rs b/src/properties/mod.rs index 267a7f2b..173e0a16 100644 --- a/src/properties/mod.rs +++ b/src/properties/mod.rs @@ -176,19 +176,19 @@ macro_rules! define_properties { ) => { /// A CSS property id. #[derive(Debug, Clone, PartialEq, Visit)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub enum PropertyId<'i> { $( #[doc=concat!("The `", $name, "` property.")] $(#[$meta])* - #[cfg_attr(feature = "serde", serde(rename = $name))] + #[cfg_attr(feature = "with-serde", serde(rename = $name))] $property$(($vp))?, )+ /// The `all` property. - #[cfg_attr(feature = "serde", serde(rename = "all"))] + #[cfg_attr(feature = "with-serde", serde(rename = "all"))] All, /// An unknown or custom property name. - #[cfg_attr(feature = "serde", serde(borrow, rename = "custom"))] + #[cfg_attr(feature = "with-serde", serde(borrow, rename = "custom"))] Custom(CowArcStr<'i>) } @@ -495,20 +495,20 @@ macro_rules! define_properties { /// A CSS property. #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_property, PROPERTIES)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] - #[cfg_attr(feature = "serde", serde(tag = "property", content = "value"))] + #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "with-serde", serde(tag = "property", content = "value"))] pub enum Property<'i> { $( #[doc=concat!("The `", $name, "` property.")] $(#[$meta])* - #[cfg_attr(feature = "serde", serde(rename = $name))] + #[cfg_attr(feature = "with-serde", serde(rename = $name))] $property($type, $($vp)?), )+ /// An unparsed property. - #[cfg_attr(feature = "serde", serde(borrow, rename = "unparsed"))] + #[cfg_attr(feature = "with-serde", serde(borrow, rename = "unparsed"))] Unparsed(UnparsedProperty<'i>), /// A custom or unknown property. - #[cfg_attr(feature = "serde", serde(borrow, rename = "custom"))] + #[cfg_attr(feature = "with-serde", serde(borrow, rename = "custom"))] Custom(CustomProperty<'i>), } diff --git a/src/properties/outline.rs b/src/properties/outline.rs index a84cfd80..f175e72d 100644 --- a/src/properties/outline.rs +++ b/src/properties/outline.rs @@ -16,7 +16,7 @@ use cssparser::*; /// A value for the [outline-style](https://drafts.csswg.org/css-ui/#outline-style) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/properties/position.rs b/src/properties/position.rs index 7f568f3b..573cc960 100644 --- a/src/properties/position.rs +++ b/src/properties/position.rs @@ -16,7 +16,7 @@ use cssparser::*; /// A value for the [position](https://www.w3.org/TR/css-position-3/#position-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -72,7 +72,7 @@ impl ToCss for Position { /// A value for the [z-index](https://drafts.csswg.org/css2/#z-index) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/properties/size.rs b/src/properties/size.rs index 537fd2b2..1b2a4e3a 100644 --- a/src/properties/size.rs +++ b/src/properties/size.rs @@ -20,7 +20,7 @@ use cssparser::*; /// i.e. `width` and `height. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -121,7 +121,7 @@ impl ToCss for Size { /// e.g. `min-width` and `max-height`. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/properties/svg.rs b/src/properties/svg.rs index 395c85fc..e801d24e 100644 --- a/src/properties/svg.rs +++ b/src/properties/svg.rs @@ -14,7 +14,7 @@ use cssparser::*; /// used in the `fill` and `stroke` properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -24,7 +24,7 @@ pub enum SVGPaint<'i> { /// A URL reference to a paint server element, e.g. `linearGradient`, `radialGradient`, and `pattern`. /// The fallback is used in case the paint server cannot be resolved. Url( - #[cfg_attr(feature = "serde", serde(borrow))] Url<'i>, + #[cfg_attr(feature = "with-serde", serde(borrow))] Url<'i>, Option, ), /// A solid color paint. @@ -40,7 +40,7 @@ pub enum SVGPaint<'i> { /// See [SVGPaint](SVGPaint). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -168,7 +168,7 @@ enum_property! { /// A value for the [stroke-dasharray](https://www.w3.org/TR/SVG2/painting.html#StrokeDashing) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -230,7 +230,7 @@ impl ToCss for StrokeDasharray { /// A value for the [marker](https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties) properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -238,7 +238,7 @@ pub enum Marker<'i> { /// No marker. None, /// A url reference to a `` element. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Url(Url<'i>), } diff --git a/src/properties/text.rs b/src/properties/text.rs index ee91d70d..bbc68b9a 100644 --- a/src/properties/text.rs +++ b/src/properties/text.rs @@ -49,7 +49,7 @@ bitflags! { /// /// All combinations of flags is supported. #[derive(Visit)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct TextTransformOther: u8 { /// Puts all typographic character units in full-width form. const FullWidth = 0b00000001; @@ -96,7 +96,7 @@ impl ToCss for TextTransformOther { /// A value for the [text-transform](https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#text-transform-property) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct TextTransform { /// How case should be transformed. pub case: TextTransformCase, @@ -291,7 +291,7 @@ enum_property! { /// and [letter-spacing](https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#letter-spacing-property) properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -327,7 +327,7 @@ impl ToCss for Spacing { /// A value for the [text-indent](https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#text-indent-property) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct TextIndent { /// The amount to indent. pub value: LengthPercentage, @@ -401,7 +401,7 @@ bitflags! { /// /// Multiple lines may be specified by combining the flags. #[derive(Visit)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct TextDecorationLine: u8 { /// Each line of text is underlined. const Underline = 0b00000001; @@ -527,7 +527,7 @@ impl Default for TextDecorationStyle { /// A value for the [text-decoration-thickness](https://www.w3.org/TR/2020/WD-css-text-decor-4-20200506/#text-decoration-width-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -715,7 +715,7 @@ enum_property! { /// A value for the [text-emphasis-style](https://www.w3.org/TR/2020/WD-css-text-decor-4-20200506/#text-emphasis-style-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -730,7 +730,7 @@ pub enum TextEmphasisStyle<'i> { shape: Option, }, /// Display the given string as marks. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] String(CSSString<'i>), } @@ -796,7 +796,7 @@ define_shorthand! { /// A value for the [text-emphasis](https://www.w3.org/TR/2020/WD-css-text-decor-4-20200506/#text-emphasis-property) shorthand property. pub struct TextEmphasis<'i>(VendorPrefix) { /// The text emphasis style. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] style: TextEmphasisStyle(TextEmphasisStyle<'i>, VendorPrefix), /// The text emphasis color. color: TextEmphasisColor(CssColor, VendorPrefix), @@ -886,7 +886,7 @@ enum_property! { /// A value for the [text-emphasis-position](https://www.w3.org/TR/2020/WD-css-text-decor-4-20200506/#text-emphasis-position-property) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct TextEmphasisPosition { /// The vertical position. pub vertical: TextEmphasisPositionVertical, @@ -1235,7 +1235,7 @@ impl<'i> PropertyHandler<'i> for TextDecorationHandler<'i> { /// A value for the [text-shadow](https://www.w3.org/TR/2020/WD-css-text-decor-4-20200506/#text-shadow-property) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct TextShadow { /// The color of the text shadow. pub color: CssColor, diff --git a/src/properties/transform.rs b/src/properties/transform.rs index a62f1232..02292c94 100644 --- a/src/properties/transform.rs +++ b/src/properties/transform.rs @@ -22,7 +22,7 @@ use std::f32::consts::PI; /// A value for the [transform](https://www.w3.org/TR/2019/CR-css-transforms-1-20190214/#propdef-transform) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct TransformList(pub Vec); impl<'i> Parse<'i> for TransformList { @@ -145,7 +145,7 @@ impl TransformList { /// An individual [transform function](https://www.w3.org/TR/2019/CR-css-transforms-1-20190214/#two-d-transform-functions). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -196,7 +196,7 @@ pub enum Transform { /// A 2D matrix. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] #[allow(missing_docs)] pub struct Matrix { pub a: T, @@ -233,7 +233,7 @@ impl Matrix { /// A 3D matrix. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] #[allow(missing_docs)] pub struct Matrix3d { pub m11: T, @@ -1388,7 +1388,7 @@ enum_property! { /// A value for the [perspective](https://drafts.csswg.org/css-transforms-2/#perspective-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -1423,7 +1423,7 @@ impl ToCss for Perspective { /// A value for the [translate](https://drafts.csswg.org/css-transforms-2/#propdef-translate) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Translate { /// The x translation. pub x: LengthPercentage, @@ -1486,7 +1486,7 @@ impl Translate { /// A value for the [rotate](https://drafts.csswg.org/css-transforms-2/#propdef-rotate) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Rotate { /// Rotation around the x axis. pub x: f32, @@ -1570,7 +1570,7 @@ impl Rotate { /// A value for the [scale](https://drafts.csswg.org/css-transforms-2/#propdef-scale) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Scale { /// Scale on the x axis. pub x: NumberOrPercentage, diff --git a/src/properties/transition.rs b/src/properties/transition.rs index 2520da6c..5eb3df59 100644 --- a/src/properties/transition.rs +++ b/src/properties/transition.rs @@ -22,7 +22,7 @@ define_list_shorthand! { /// A value for the [transition](https://www.w3.org/TR/2018/WD-css-transitions-1-20181011/#transition-shorthand-property) property. pub struct Transition<'i>(VendorPrefix) { /// The property to transition. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] property: TransitionProperty(PropertyId<'i>, VendorPrefix), /// The duration of the transition. duration: TransitionDuration(Time, VendorPrefix), diff --git a/src/properties/ui.rs b/src/properties/ui.rs index e122cd3d..3594163a 100644 --- a/src/properties/ui.rs +++ b/src/properties/ui.rs @@ -37,10 +37,10 @@ enum_property! { /// /// See [Cursor](Cursor). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct CursorImage<'i> { /// A url to the cursor image. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub url: Url<'i>, /// The location in the image where the mouse pointer appears. pub hotspot: Option<(CSSNumber, CSSNumber)>, @@ -125,10 +125,10 @@ enum_property! { /// A value for the [cursor](https://www.w3.org/TR/2021/WD-css-ui-4-20210316/#cursor) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Cursor<'i> { /// A list of cursor images. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub images: SmallVec<[CursorImage<'i>; 1]>, /// A pre-defined cursor. pub keyword: CursorKeyword, @@ -168,7 +168,7 @@ impl<'i> ToCss for Cursor<'i> { /// A value for the [caret-color](https://www.w3.org/TR/2021/WD-css-ui-4-20210316/#caret-color) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -284,7 +284,7 @@ enum_property! { /// A value for the [appearance](https://www.w3.org/TR/2021/WD-css-ui-4-20210316/#appearance-switching) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "kebab-case") )] @@ -306,7 +306,7 @@ pub enum Appearance<'i> { SliderHorizontal, SquareButton, Textarea, - NonStandard(#[cfg_attr(feature = "serde", serde(borrow))] CowArcStr<'i>), + NonStandard(#[cfg_attr(feature = "with-serde", serde(borrow))] CowArcStr<'i>), } impl<'i> Parse<'i> for Appearance<'i> { diff --git a/src/rules/container.rs b/src/rules/container.rs index e67d46ee..5ea8cf49 100644 --- a/src/rules/container.rs +++ b/src/rules/container.rs @@ -15,10 +15,10 @@ use crate::visitor::Visit; /// A [@container](https://drafts.csswg.org/css-contain-3/#container-rule) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct ContainerRule<'i, R = DefaultAtRule> { /// The name of the container. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub name: Option>, /// The container condition. pub condition: MediaCondition<'i>, @@ -31,8 +31,8 @@ pub struct ContainerRule<'i, R = DefaultAtRule> { /// A [``](https://drafts.csswg.org/css-contain-3/#typedef-container-name) in a `@container` rule. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ContainerName<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub CustomIdent<'i>); +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +pub struct ContainerName<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub CustomIdent<'i>); impl<'i> Parse<'i> for ContainerName<'i> { fn parse<'t>(input: &mut Parser<'i, 't>) -> Result>> { diff --git a/src/rules/counter_style.rs b/src/rules/counter_style.rs index c253be65..cced4a3e 100644 --- a/src/rules/counter_style.rs +++ b/src/rules/counter_style.rs @@ -10,10 +10,10 @@ use crate::visitor::Visit; /// A [@counter-style](https://drafts.csswg.org/css-counter-styles/#the-counter-style-rule) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct CounterStyleRule<'i> { /// The name of the counter style to declare. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub name: CustomIdent<'i>, // TODO: eventually parse these properties /// Declarations in the `@counter-style` rule. diff --git a/src/rules/custom_media.rs b/src/rules/custom_media.rs index e4a0b73f..3e0948a1 100644 --- a/src/rules/custom_media.rs +++ b/src/rules/custom_media.rs @@ -10,10 +10,10 @@ use crate::visitor::Visit; /// A [@custom-media](https://drafts.csswg.org/mediaqueries-5/#custom-mq) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct CustomMediaRule<'i> { /// The name of the declared media query. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub name: DashedIdent<'i>, /// The media query to declare. pub query: MediaList<'i>, diff --git a/src/rules/document.rs b/src/rules/document.rs index 3b98c16e..87d0f618 100644 --- a/src/rules/document.rs +++ b/src/rules/document.rs @@ -13,10 +13,10 @@ use crate::visitor::Visit; /// Note that only the `url-prefix()` function with no arguments is supported, and only the `-moz` prefix /// is allowed since Firefox was the only browser that ever implemented this rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct MozDocumentRule<'i, R = DefaultAtRule> { /// Nested rules within the `@-moz-document` rule. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub rules: CssRuleList<'i, R>, /// The location of the rule in the source file. #[skip_visit] diff --git a/src/rules/font_face.rs b/src/rules/font_face.rs index 14cdfd9b..ff201593 100644 --- a/src/rules/font_face.rs +++ b/src/rules/font_face.rs @@ -17,10 +17,10 @@ use std::fmt::Write; /// A [@font-face](https://drafts.csswg.org/css-fonts/#font-face-rule) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct FontFaceRule<'i> { /// Declarations in the `@font-face` rule. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub properties: Vec>, /// The location of the rule in the source file. #[skip_visit] @@ -32,13 +32,13 @@ pub struct FontFaceRule<'i> { /// See [FontFaceRule](FontFaceRule). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum FontFaceProperty<'i> { /// The `src` property. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Source(Vec>), /// The `font-family` property. FontFamily(FontFamily<'i>), @@ -58,7 +58,7 @@ pub enum FontFaceProperty<'i> { /// property in an `@font-face` rule. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -66,7 +66,7 @@ pub enum Source<'i> { /// A `url()` with optional format metadata. Url(UrlSource<'i>), /// The `local()` function. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Local(FontFamily<'i>), } @@ -108,12 +108,12 @@ impl<'i> ToCss for Source<'i> { /// A `url()` value for the [src](https://drafts.csswg.org/css-fonts/#src-desc) /// property in an `@font-face` rule. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct UrlSource<'i> { /// The URL. pub url: Url<'i>, /// Optional `format()` function. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub format: Option>, /// Optional `tech()` function. pub tech: Vec, @@ -167,7 +167,7 @@ impl<'i> ToCss for UrlSource<'i> { /// property of an `@font-face` rule. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -188,7 +188,7 @@ pub enum FontFormat<'i> { /// An SVG font. SVG, /// An unknown format. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] String(CowArcStr<'i>), } @@ -279,7 +279,7 @@ enum_property! { /// /// Cannot be empty. Can represent a single code point when start == end. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct UnicodeRange { /// Inclusive start of the range. In [0, end]. pub start: u32, diff --git a/src/rules/font_palette_values.rs b/src/rules/font_palette_values.rs index 800c002f..c2ab7e12 100644 --- a/src/rules/font_palette_values.rs +++ b/src/rules/font_palette_values.rs @@ -17,12 +17,12 @@ use cssparser::*; /// A [@font-palette-values](https://drafts.csswg.org/css-fonts-4/#font-palette-values) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct FontPaletteValuesRule<'i> { /// The name of the font palette. pub name: DashedIdent<'i>, /// Declarations in the `@font-palette-values` rule. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub properties: Vec>, /// The location of the rule in the source file. #[skip_visit] @@ -34,13 +34,13 @@ pub struct FontPaletteValuesRule<'i> { /// See [FontPaletteValuesRule](FontPaletteValuesRule). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum FontPaletteValuesProperty<'i> { /// The `font-family` property. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] FontFamily(FontFamily<'i>), /// The `base-palette` property. BasePalette(BasePalette), @@ -54,7 +54,7 @@ pub enum FontPaletteValuesProperty<'i> { /// property in an `@font-palette-values` rule. #[derive(Debug, PartialEq, Clone, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -70,7 +70,7 @@ pub enum BasePalette { /// A value for the [override-colors](https://drafts.csswg.org/css-fonts-4/#override-color) /// property in an `@font-palette-values` rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct OverrideColors { /// The index of the color within the palette to override. index: u16, diff --git a/src/rules/import.rs b/src/rules/import.rs index e4114823..40dd487c 100644 --- a/src/rules/import.rs +++ b/src/rules/import.rs @@ -14,10 +14,10 @@ use cssparser::*; /// A [@import](https://drafts.csswg.org/css-cascade/#at-import) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct ImportRule<'i> { /// The url to import. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] #[skip_visit] pub url: CowArcStr<'i>, /// An optional cascade layer name, or `None` for an anonymous layer. diff --git a/src/rules/keyframes.rs b/src/rules/keyframes.rs index fd49bd44..d84cb40a 100644 --- a/src/rules/keyframes.rs +++ b/src/rules/keyframes.rs @@ -22,11 +22,11 @@ use cssparser::*; /// A [@keyframes](https://drafts.csswg.org/css-animations/#keyframes) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct KeyframesRule<'i> { /// The animation name. /// = | - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub name: KeyframesName<'i>, /// A list of keyframes in the animation. pub keyframes: Vec>, @@ -40,14 +40,14 @@ pub struct KeyframesRule<'i> { /// KeyframesName #[derive(Debug, Clone, PartialEq, Eq, Hash, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub enum KeyframesName<'i> { /// `` of a `@keyframes` name. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Ident(CustomIdent<'i>), /// `` of a `@keyframes` name. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Custom(CowArcStr<'i>), } @@ -250,7 +250,7 @@ impl<'i> ToCss for KeyframesRule<'i> { /// within an `@keyframes` rule. #[derive(Debug, PartialEq, Clone, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -310,12 +310,12 @@ impl ToCss for KeyframeSelector { /// /// See [KeyframesRule](KeyframesRule). #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Keyframe<'i> { /// A list of keyframe selectors to associate with the declarations in this keyframe. pub selectors: Vec, /// The declarations for this keyframe. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub declarations: DeclarationBlock<'i>, } diff --git a/src/rules/layer.rs b/src/rules/layer.rs index 7d4d2926..004416a5 100644 --- a/src/rules/layer.rs +++ b/src/rules/layer.rs @@ -15,8 +15,8 @@ use smallvec::SmallVec; /// /// Nested layers are represented using a list of identifiers. In CSS syntax, these are dot-separated. #[derive(Debug, Clone, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LayerName<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub SmallVec<[CowArcStr<'i>; 1]>); +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +pub struct LayerName<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub SmallVec<[CowArcStr<'i>; 1]>); macro_rules! expect_non_whitespace { ($parser: ident, $($branches: tt)+) => {{ @@ -81,10 +81,10 @@ impl<'i> ToCss for LayerName<'i> { /// /// See also [LayerBlockRule](LayerBlockRule). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct LayerStatementRule<'i> { /// The layer names to declare. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] #[skip_visit] pub names: Vec>, /// The location of the rule in the source file. @@ -106,10 +106,10 @@ impl<'i> ToCss for LayerStatementRule<'i> { /// A [@layer block](https://drafts.csswg.org/css-cascade-5/#layer-block) rule. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct LayerBlockRule<'i, R = DefaultAtRule> { /// The name of the layer to declare, or `None` to declare an anonymous layer. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] #[skip_visit] pub name: Option>, /// The rules within the `@layer` rule. diff --git a/src/rules/media.rs b/src/rules/media.rs index 054187f5..41edb857 100644 --- a/src/rules/media.rs +++ b/src/rules/media.rs @@ -12,10 +12,10 @@ use crate::visitor::Visit; /// A [@media](https://drafts.csswg.org/css-conditional-3/#at-media) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct MediaRule<'i, R = DefaultAtRule> { /// The media query list. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub query: MediaList<'i>, /// The rules within the `@media` rule. pub rules: CssRuleList<'i, R>, diff --git a/src/rules/mod.rs b/src/rules/mod.rs index e8288d28..b8c2ce46 100644 --- a/src/rules/mod.rs +++ b/src/rules/mod.rs @@ -108,7 +108,8 @@ pub(crate) struct StyleContext<'a, 'i, T> { /// A source location. #[derive(PartialEq, Eq, Debug, Clone, Copy)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(serde::Serialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Deserialize))] pub struct Location { /// The index of the source file within the source map. pub source_index: u32, @@ -123,13 +124,13 @@ pub struct Location { #[derive(Debug, PartialEq, Clone, Visit)] #[visit(visit_rule, RULES)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum CssRule<'i, R = DefaultAtRule> { /// A `@media` rule. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Media(MediaRule<'i, R>), /// An `@import` rule. Import(ImportRule<'i>), @@ -243,9 +244,9 @@ impl<'i, T: ToCss> ToCss for CssRule<'i, T> { /// A list of CSS rules. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct CssRuleList<'i, R = DefaultAtRule>( - #[cfg_attr(feature = "serde", serde(borrow))] pub Vec>, + #[cfg_attr(feature = "with-serde", serde(borrow))] pub Vec>, ); // Manually implemented to avoid circular child types. diff --git a/src/rules/namespace.rs b/src/rules/namespace.rs index 93f4a28b..c2d9b058 100644 --- a/src/rules/namespace.rs +++ b/src/rules/namespace.rs @@ -10,14 +10,14 @@ use crate::visitor::Visit; /// A [@namespace](https://drafts.csswg.org/css-namespaces/#declaration) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct NamespaceRule<'i> { /// An optional namespace prefix to declare, or `None` to declare the default namespace. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] #[skip_visit] pub prefix: Option>, /// The url of the namespace. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] #[skip_visit] pub url: CSSString<'i>, /// The location of the rule in the source file. diff --git a/src/rules/nesting.rs b/src/rules/nesting.rs index fa45618d..07064827 100644 --- a/src/rules/nesting.rs +++ b/src/rules/nesting.rs @@ -11,10 +11,10 @@ use crate::traits::ToCss; use crate::visitor::Visit; /// A [@nest](https://www.w3.org/TR/css-nesting-1/#at-nest) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct NestingRule<'i, R = DefaultAtRule> { /// The style rule that defines the selector and declarations for the `@nest` rule. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub style: StyleRule<'i, R>, /// The location of the rule in the source file. #[skip_visit] diff --git a/src/rules/page.rs b/src/rules/page.rs index 127b7b74..87e3a1f5 100644 --- a/src/rules/page.rs +++ b/src/rules/page.rs @@ -16,10 +16,10 @@ use cssparser::*; /// /// Either a name or at least one pseudo class is required. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct PageSelector<'i> { /// An optional named page type. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub name: Option>, /// A list of page pseudo classes. pub pseudo_classes: Vec, @@ -114,12 +114,12 @@ enum_property! { /// A [page margin rule](https://www.w3.org/TR/css-page-3/#margin-at-rules) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct PageMarginRule<'i> { /// The margin box identifier for this rule. pub margin_box: PageMarginBox, /// The declarations within the rule. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub declarations: DeclarationBlock<'i>, /// The location of the rule in the source file. #[skip_visit] @@ -140,10 +140,10 @@ impl<'i> ToCss for PageMarginRule<'i> { /// A [@page](https://www.w3.org/TR/css-page-3/#at-page-rule) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct PageRule<'i> { /// A list of page selectors. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] #[skip_visit] pub selectors: Vec>, /// The declarations within the `@page` rule. diff --git a/src/rules/property.rs b/src/rules/property.rs index bff1dc08..653ce26a 100644 --- a/src/rules/property.rs +++ b/src/rules/property.rs @@ -15,10 +15,10 @@ use cssparser::*; /// A [@property](https://drafts.css-houdini.org/css-properties-values-api/#at-property-rule) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct PropertyRule<'i> { /// The name of the custom property to declare. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub name: DashedIdent<'i>, /// A syntax string to specify the grammar for the custom property. #[skip_visit] diff --git a/src/rules/style.rs b/src/rules/style.rs index 148cf9ac..f6e593ec 100644 --- a/src/rules/style.rs +++ b/src/rules/style.rs @@ -19,16 +19,16 @@ use crate::vendor_prefix::VendorPrefix; use crate::visitor::Visit; use cssparser::*; -#[cfg(feature = "serde")] +#[cfg(feature = "with-serde")] use crate::selector::{deserialize_selectors, serialize_selectors}; /// A CSS [style rule](https://drafts.csswg.org/css-syntax/#style-rules). #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct StyleRule<'i, R = DefaultAtRule> { /// The selectors for the style rule. #[cfg_attr( - feature = "serde", + feature = "with-serde", serde( serialize_with = "serialize_selectors", deserialize_with = "deserialize_selectors", @@ -37,7 +37,7 @@ pub struct StyleRule<'i, R = DefaultAtRule> { )] pub selectors: SelectorList<'i>, /// A vendor prefix override, used during selector printing. - #[cfg_attr(feature = "serde", serde(skip, default = "VendorPrefix::empty"))] + #[cfg_attr(feature = "with-serde", serde(skip, default = "VendorPrefix::empty"))] #[skip_visit] pub vendor_prefix: VendorPrefix, /// The declarations within the style rule. diff --git a/src/rules/supports.rs b/src/rules/supports.rs index e222d07e..dec0a398 100644 --- a/src/rules/supports.rs +++ b/src/rules/supports.rs @@ -16,10 +16,10 @@ use cssparser::*; /// A [@supports](https://drafts.csswg.org/css-conditional-3/#at-supports) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct SupportsRule<'i, R = DefaultAtRule> { /// The supports condition. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub condition: SupportsCondition<'i>, /// The rules within the `@supports` rule. pub rules: CssRuleList<'i, R>, @@ -70,7 +70,7 @@ impl<'a, 'i, T: ToCss> ToCssWithContext<'a, 'i, T> for SupportsRule<'i, T> { #[derive(Debug, PartialEq, Clone, Visit)] #[visit(visit_supports_condition, SUPPORTS_CONDITIONS)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -87,7 +87,7 @@ pub enum SupportsCondition<'i> { /// A declaration to evaluate. Declaration { /// The property id for the declaration. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] property_id: PropertyId<'i>, /// The raw value of the declaration. value: CowArcStr<'i>, diff --git a/src/rules/unknown.rs b/src/rules/unknown.rs index 1c831c7c..1b1a7b33 100644 --- a/src/rules/unknown.rs +++ b/src/rules/unknown.rs @@ -10,10 +10,10 @@ use crate::visitor::Visit; /// An unknown at-rule, stored as raw tokens. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct UnknownAtRule<'i> { /// The name of the at-rule (without the @). - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] #[skip_visit] pub name: CowArcStr<'i>, /// The prelude of the rule. diff --git a/src/rules/viewport.rs b/src/rules/viewport.rs index ca437780..ebc6adb8 100644 --- a/src/rules/viewport.rs +++ b/src/rules/viewport.rs @@ -10,13 +10,13 @@ use crate::visitor::Visit; /// A [@viewport](https://drafts.csswg.org/css-device-adapt/#atviewport-rule) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct ViewportRule<'i> { /// The vendor prefix for this rule, e.g. `@-ms-viewport`. #[skip_visit] pub vendor_prefix: VendorPrefix, /// The declarations within the `@viewport` rule. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub declarations: DeclarationBlock<'i>, /// The location of the rule in the source file. #[skip_visit] diff --git a/src/selector.rs b/src/selector.rs index af1e3917..08cb8900 100644 --- a/src/selector.rs +++ b/src/selector.rs @@ -1736,7 +1736,7 @@ pub(crate) fn is_unused( }) } -#[cfg(feature = "serde")] +#[cfg(feature = "with-serde")] pub(crate) fn serialize_selectors(selectors: &SelectorList, s: S) -> Result where S: serde::Serializer, @@ -1755,7 +1755,7 @@ where .serialize(s) } -#[cfg(feature = "serde")] +#[cfg(feature = "with-serde")] pub(crate) fn deserialize_selectors<'i, 'de: 'i, D>(deserializer: D) -> Result, D::Error> where D: serde::Deserializer<'de>, diff --git a/src/stylesheet.rs b/src/stylesheet.rs index 0a32f3a9..42817105 100644 --- a/src/stylesheet.rs +++ b/src/stylesheet.rs @@ -58,11 +58,11 @@ pub use crate::printer::PseudoClasses; /// assert_eq!(res.code, ".foo, .bar {\n color: red;\n}\n"); /// ``` #[derive(Debug)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct StyleSheet<'i, 'o, T: AtRuleParser<'i> = DefaultAtRuleParser> { /// A list of top-level rules within the style sheet. #[cfg_attr( - feature = "serde", + feature = "with-serde", serde( borrow, bound( @@ -77,7 +77,7 @@ pub struct StyleSheet<'i, 'o, T: AtRuleParser<'i> = DefaultAtRuleParser> { pub sources: Vec, /// The source map URL extracted from the original style sheet. pub(crate) source_map_urls: Vec>, - #[cfg_attr(feature = "serde", serde(skip))] + #[cfg_attr(feature = "with-serde", serde(skip))] /// The options the style sheet was originally parsed with. options: ParserOptions<'o, 'i, T>, } diff --git a/src/targets.rs b/src/targets.rs index 56c6f576..ed0ea557 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -1,8 +1,8 @@ //! Browser target options. // This file is autogenerated by build-prefixes.js. DO NOT EDIT! -#[cfg(feature = "serde")] -use serde::{Deserialize, Serialize}; +#[cfg(any(feature = "with-serde", feature = "nodejs"))] +use serde::{Serialize, Deserialize}; /// Browser versions to compile CSS for. /// @@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize}; /// }; /// ``` #[derive(Debug, Clone, Copy, Default)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize, Deserialize))] #[allow(missing_docs)] pub struct Browsers { pub android: Option, diff --git a/src/values/alpha.rs b/src/values/alpha.rs index 77554d2f..4593d0cf 100644 --- a/src/values/alpha.rs +++ b/src/values/alpha.rs @@ -12,7 +12,7 @@ use cssparser::*; /// /// Parses either a `` or ``, but is always stored and serialized as a number. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct AlphaValue(pub f32); impl<'i> Parse<'i> for AlphaValue { diff --git a/src/values/angle.rs b/src/values/angle.rs index bf89ee93..fefd9b75 100644 --- a/src/values/angle.rs +++ b/src/values/angle.rs @@ -22,7 +22,7 @@ use std::f32::consts::PI; #[derive(Debug, Clone, Visit)] #[visit(visit_angle, ANGLES)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/calc.rs b/src/values/calc.rs index 784fdf93..4659a0e3 100644 --- a/src/values/calc.rs +++ b/src/values/calc.rs @@ -21,7 +21,7 @@ use super::time::Time; /// values, including lengths, percentages, angles, times, etc. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -202,7 +202,7 @@ impl + TrySign + Clone + std::fmt::Deb /// [Time](super::time::Time), and [Angle](super::angle::Angle) support `calc()` expressions. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/color.rs b/src/values/color.rs index 21b0d549..6b99d37b 100644 --- a/src/values/color.rs +++ b/src/values/color.rs @@ -33,7 +33,7 @@ use std::fmt::Write; #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_color, COLORS)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "lowercase") )] @@ -53,7 +53,7 @@ pub enum CssColor { /// A color in a LAB color space, including the `lab()`, `lch()`, `oklab()`, and `oklch()` functions. #[derive(Debug, Clone, Copy, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "lowercase") )] @@ -71,34 +71,34 @@ pub enum LABColor { /// A color in a predefined color space, e.g. `display-p3`. #[derive(Debug, Clone, Copy, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value") )] pub enum PredefinedColor { /// A color in the `srgb` color space. - #[cfg_attr(feature = "serde", serde(rename = "srgb"))] + #[cfg_attr(feature = "with-serde", serde(rename = "srgb"))] SRGB(SRGB), /// A color in the `srgb-linear` color space. - #[cfg_attr(feature = "serde", serde(rename = "srgb-linear"))] + #[cfg_attr(feature = "with-serde", serde(rename = "srgb-linear"))] SRGBLinear(SRGBLinear), /// A color in the `display-p3` color space. - #[cfg_attr(feature = "serde", serde(rename = "display-p3"))] + #[cfg_attr(feature = "with-serde", serde(rename = "display-p3"))] DisplayP3(P3), /// A color in the `a98-rgb` color space. - #[cfg_attr(feature = "serde", serde(rename = "a98-rgb"))] + #[cfg_attr(feature = "with-serde", serde(rename = "a98-rgb"))] A98(A98), /// A color in the `prophoto-rgb` color space. - #[cfg_attr(feature = "serde", serde(rename = "prophoto-rgb"))] + #[cfg_attr(feature = "with-serde", serde(rename = "prophoto-rgb"))] ProPhoto(ProPhoto), /// A color in the `rec2020` color space. - #[cfg_attr(feature = "serde", serde(rename = "rec2020"))] + #[cfg_attr(feature = "with-serde", serde(rename = "rec2020"))] Rec2020(Rec2020), /// A color in the `xyz-d50` color space. - #[cfg_attr(feature = "serde", serde(rename = "xyz-d50"))] + #[cfg_attr(feature = "with-serde", serde(rename = "xyz-d50"))] XYZd50(XYZd50), /// A color in the `xyz-d65` color space. - #[cfg_attr(feature = "serde", serde(rename = "xyz-d65"))] + #[cfg_attr(feature = "with-serde", serde(rename = "xyz-d65"))] XYZd65(XYZd65), } @@ -107,7 +107,7 @@ pub enum PredefinedColor { /// are any `none` components, which are represented as NaN. #[derive(Debug, Clone, Copy, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "lowercase") )] @@ -1168,7 +1168,7 @@ macro_rules! define_colorspace { ) => { $(#[$outer])* #[derive(Debug, Clone, Copy, PartialEq, Visit)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct $name { $(#[$a_meta])* pub $a: f32, diff --git a/src/values/easing.rs b/src/values/easing.rs index 54203999..ceaf5492 100644 --- a/src/values/easing.rs +++ b/src/values/easing.rs @@ -11,7 +11,7 @@ use std::fmt::Write; /// A CSS [easing function](https://www.w3.org/TR/css-easing-1/#easing-functions). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -133,7 +133,7 @@ impl EasingFunction { /// A [step position](https://www.w3.org/TR/css-easing-1/#step-position), used within the `steps()` function. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/gradient.rs b/src/values/gradient.rs index fa61f60b..efd9d574 100644 --- a/src/values/gradient.rs +++ b/src/values/gradient.rs @@ -21,7 +21,7 @@ use cssparser::*; /// A CSS [``](https://www.w3.org/TR/css-images-3/#gradients) value. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -200,7 +200,7 @@ impl ToCss for Gradient { /// A CSS [`linear-gradient()`](https://www.w3.org/TR/css-images-3/#linear-gradients) or `repeating-linear-gradient()`. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct LinearGradient { /// The direction of the gradient. pub direction: LineDirection, @@ -297,7 +297,7 @@ impl LinearGradient { /// A CSS [`radial-gradient()`](https://www.w3.org/TR/css-images-3/#radial-gradients) or `repeating-radial-gradient()`. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct RadialGradient { /// The shape of the gradient. pub shape: EndingShape, @@ -369,7 +369,7 @@ impl RadialGradient { /// See [LinearGradient](LinearGradient). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -462,7 +462,7 @@ impl LineDirection { /// See [RadialGradient](RadialGradient). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -511,7 +511,7 @@ impl ToCss for EndingShape { /// See [RadialGradient](RadialGradient). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -578,7 +578,7 @@ impl ToCss for Circle { /// See [RadialGradient](RadialGradient). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -661,7 +661,7 @@ enum_property! { /// A CSS [`conic-gradient()`](https://www.w3.org/TR/css-images-4/#conic-gradients) or `repeating-conic-gradient()`. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct ConicGradient { /// The angle of the gradient. pub angle: Angle, @@ -739,7 +739,7 @@ impl ConicGradient { /// This type is generic, and may be either a [LengthPercentage](super::length::LengthPercentage) /// or [Angle](super::angle::Angle) depending on what type of gradient it is within. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct ColorStop { /// The color of the color stop. pub color: CssColor, @@ -775,7 +775,7 @@ impl ToCss for ColorStop { /// or [Angle](super::angle::Angle) depending on what type of gradient it is within. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -919,7 +919,7 @@ where /// A legacy `-webkit-gradient()`. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -1062,7 +1062,7 @@ impl WebKitGradient { /// A color stop within a legacy `-webkit-gradient()`. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct WebKitColorStop { /// The color of the color stop. pub color: CssColor, @@ -1123,7 +1123,7 @@ impl WebKitColorStop { /// An x/y position within a legacy `-webkit-gradient()`. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct WebKitGradientPoint { /// The x-position. pub x: WebKitGradientPointComponent, @@ -1153,7 +1153,7 @@ impl ToCss for WebKitGradientPoint { /// A keyword or number within a [WebKitGradientPoint](WebKitGradientPoint). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/ident.rs b/src/values/ident.rs index 68f7c37a..fdd2ce81 100644 --- a/src/values/ident.rs +++ b/src/values/ident.rs @@ -20,8 +20,8 @@ use super::string::impl_string_type; /// They may be renamed to include a hash when compiled as part of a CSS module. #[derive(Debug, Clone, Eq, Hash, Visit)] #[visit(visit_custom_ident, CUSTOM_IDENTS)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CustomIdent<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub CowArcStr<'i>); +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +pub struct CustomIdent<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub CowArcStr<'i>); impl<'i> Parse<'i> for CustomIdent<'i> { fn parse<'t>(input: &mut Parser<'i, 't>) -> Result>> { @@ -58,8 +58,8 @@ pub type CustomIdentList<'i> = SmallVec<[CustomIdent<'i>; 1]>; /// Author defined idents must start with two dash characters ("--") or parsing will fail. #[derive(Debug, Clone, Eq, Hash, Visit)] #[visit(visit_dashed_ident, DASHED_IDENTS)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DashedIdent<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub CowArcStr<'i>); +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +pub struct DashedIdent<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub CowArcStr<'i>); impl<'i> Parse<'i> for DashedIdent<'i> { fn parse<'t>(input: &mut Parser<'i, 't>) -> Result>> { @@ -90,10 +90,10 @@ impl<'i> ToCss for DashedIdent<'i> { /// In CSS modules, when the `dashed_idents` option is enabled, the identifier may be followed by the /// `from` keyword and an argument indicating where the referenced identifier is declared (e.g. a filename). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct DashedIdentReference<'i> { /// The referenced identifier. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub ident: DashedIdent<'i>, /// CSS modules extension: the filename where the variable is defined. /// Only enabled when the CSS modules `dashed_idents` option is turned on. @@ -144,8 +144,8 @@ impl<'i> ToCss for DashedIdentReference<'i> { /// A CSS [``](https://www.w3.org/TR/css-values-4/#css-css-identifier). #[derive(Debug, Clone, Eq, Hash, Default, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Ident<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub CowArcStr<'i>); +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Ident<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub CowArcStr<'i>); impl<'i> Parse<'i> for Ident<'i> { fn parse<'t>(input: &mut Parser<'i, 't>) -> Result>> { diff --git a/src/values/image.rs b/src/values/image.rs index 67df7ca9..5451bb56 100644 --- a/src/values/image.rs +++ b/src/values/image.rs @@ -21,7 +21,7 @@ use smallvec::SmallVec; #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_image, IMAGES)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -29,7 +29,7 @@ pub enum Image<'i> { /// The `none` keyword. None, /// A `url()`. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Url(Url<'i>), /// A gradient. Gradient(Box), @@ -342,10 +342,10 @@ impl<'i> ToCss for Image<'i> { /// `image-set()` allows the user agent to choose between multiple versions of an image to /// display the most appropriate resolution or file type that it supports. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct ImageSet<'i> { /// The image options to choose from. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub options: Vec>, /// The vendor prefix for the `image-set()` function. pub vendor_prefix: VendorPrefix, @@ -414,7 +414,7 @@ impl<'i> ToCss for ImageSet<'i> { /// An image option within the `image-set()` function. See [ImageSet](ImageSet). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct ImageSetOption<'i> { /// The image for this option. #[skip_type] @@ -422,7 +422,7 @@ pub struct ImageSetOption<'i> { /// The resolution of the image. pub resolution: Resolution, /// The mime type of the image. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub file_type: Option>, } diff --git a/src/values/length.rs b/src/values/length.rs index 3fa78e58..20ff07e9 100644 --- a/src/values/length.rs +++ b/src/values/length.rs @@ -39,7 +39,7 @@ impl LengthPercentage { /// Either a [``](https://www.w3.org/TR/css-values-4/#typedef-length-percentage), or the `auto` keyword. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -95,7 +95,7 @@ macro_rules! define_length_units { /// without support for `calc()`. See also: [Length](Length). #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_length, LENGTHS)] - #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "unit", content = "value", rename_all = "kebab-case"))] + #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "unit", content = "value", rename_all = "kebab-case"))] pub enum LengthValue { $( $(#[$meta])* @@ -476,7 +476,7 @@ impl LengthValue { /// A CSS [``](https://www.w3.org/TR/css-values-4/#lengths) value, with support for `calc()`. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -738,7 +738,7 @@ impl_try_from_angle!(Length); /// Either a [``](https://www.w3.org/TR/css-values-4/#lengths) or a [``](https://www.w3.org/TR/css-values-4/#numbers). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/percentage.rs b/src/values/percentage.rs index e6c81edc..60771a0c 100644 --- a/src/values/percentage.rs +++ b/src/values/percentage.rs @@ -15,7 +15,7 @@ use cssparser::*; /// Percentages may be explicit or computed by `calc()`, but are always stored and serialized /// as their computed value. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Percentage(pub CSSNumber); impl<'i> Parse<'i> for Percentage { @@ -142,7 +142,7 @@ impl_try_from_angle!(Percentage); /// Either a `` or ``. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -194,7 +194,7 @@ impl std::convert::Into for &NumberOrPercentage { /// #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/position.rs b/src/values/position.rs index 9c6b2932..a390af70 100644 --- a/src/values/position.rs +++ b/src/values/position.rs @@ -12,7 +12,7 @@ use cssparser::*; /// A CSS [``](https://www.w3.org/TR/css3-values/#position) value, /// as used in the `background-position` property, gradients, masks, etc. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Position { /// The x-position. pub x: HorizontalPosition, @@ -239,7 +239,7 @@ impl ToCss for Position { /// This type is generic over side keywords. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/ratio.rs b/src/values/ratio.rs index 4cb7f3c3..1add44d9 100644 --- a/src/values/ratio.rs +++ b/src/values/ratio.rs @@ -11,7 +11,7 @@ use cssparser::*; /// representing the ratio of two numeric values. #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_ratio, RATIOS)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Ratio(pub CSSNumber, pub CSSNumber); impl<'i> Parse<'i> for Ratio { diff --git a/src/values/rect.rs b/src/values/rect.rs index 76cd418a..b4cf30bb 100644 --- a/src/values/rect.rs +++ b/src/values/rect.rs @@ -12,7 +12,7 @@ use cssparser::*; /// When serialized, as few components as possible are written when /// there are duplicate values. #[derive(Clone, Debug, PartialEq, Eq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Rect( /// The top component. pub T, diff --git a/src/values/resolution.rs b/src/values/resolution.rs index f2b571cb..78acd75f 100644 --- a/src/values/resolution.rs +++ b/src/values/resolution.rs @@ -13,7 +13,7 @@ use cssparser::*; #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_resolution, RESOLUTIONS)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/shape.rs b/src/values/shape.rs index 6ea552dd..84ee94b1 100644 --- a/src/values/shape.rs +++ b/src/values/shape.rs @@ -14,7 +14,7 @@ use cssparser::*; /// A CSS [``](https://www.w3.org/TR/css-shapes-1/#basic-shape-functions) value. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -31,7 +31,7 @@ pub enum BasicShape { /// An [`inset()`](https://www.w3.org/TR/css-shapes-1/#funcdef-inset) rectangle shape. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct InsetRect { /// The rectangle. pub rect: Rect, @@ -41,7 +41,7 @@ pub struct InsetRect { /// A [`circle()`](https://www.w3.org/TR/css-shapes-1/#funcdef-circle) shape. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Circle { /// The radius of the circle. pub radius: ShapeRadius, @@ -53,7 +53,7 @@ pub struct Circle { /// that defines the radius of a `circle()` or `ellipse()` shape. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -68,7 +68,7 @@ pub enum ShapeRadius { /// An [`ellipse()`](https://www.w3.org/TR/css-shapes-1/#funcdef-ellipse) shape. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Ellipse { /// The x-radius of the ellipse. pub radius_x: ShapeRadius, @@ -80,7 +80,7 @@ pub struct Ellipse { /// A [`polygon()`](https://www.w3.org/TR/css-shapes-1/#funcdef-polygon) shape. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Polygon { /// The fill rule used to determine the interior of the polygon. pub fill_rule: FillRule, @@ -92,7 +92,7 @@ pub struct Polygon { /// /// See [Polygon](Polygon). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Point { /// The x position of the point. x: LengthPercentage, diff --git a/src/values/size.rs b/src/values/size.rs index e89a3f74..c4fc4438 100644 --- a/src/values/size.rs +++ b/src/values/size.rs @@ -10,7 +10,7 @@ use cssparser::*; /// /// When serialized, only a single component will be written if both are equal. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Size2D(pub T, pub T); impl<'i, T> Parse<'i> for Size2D diff --git a/src/values/string.rs b/src/values/string.rs index d66d448d..c2f9228b 100644 --- a/src/values/string.rs +++ b/src/values/string.rs @@ -3,9 +3,9 @@ use crate::traits::{Parse, ToCss}; use crate::visitor::{Visit, VisitTypes, Visitor}; use cssparser::{serialize_string, CowRcStr}; -#[cfg(feature = "serde")] +#[cfg(feature = "with-serde")] use serde::{Deserialize, Deserializer}; -#[cfg(feature = "serde")] +#[cfg(any(feature = "with-serde", feature = "nodejs"))] use serde::{Serialize, Serializer}; use std::borrow::Borrow; use std::cmp; @@ -220,14 +220,14 @@ impl<'a> fmt::Debug for CowArcStr<'a> { } } -#[cfg(feature = "serde")] +#[cfg(any(feature = "nodejs", feature = "with-serde"))] impl<'a> Serialize for CowArcStr<'a> { fn serialize(&self, serializer: S) -> Result { self.as_ref().serialize(serializer) } } -#[cfg(feature = "serde")] +#[cfg(feature = "with-serde")] impl<'a, 'de: 'a> Deserialize<'de> for CowArcStr<'a> { fn deserialize(deserializer: D) -> Result where @@ -237,10 +237,10 @@ impl<'a, 'de: 'a> Deserialize<'de> for CowArcStr<'a> { } } -#[cfg(feature = "serde")] +#[cfg(feature = "with-serde")] struct CowArcStrVisitor; -#[cfg(feature = "serde")] +#[cfg(feature = "with-serde")] impl<'de> serde::de::Visitor<'de> for CowArcStrVisitor { type Value = CowArcStr<'de>; @@ -277,8 +277,8 @@ impl<'i, V: Visitor<'i, T>, T: Visit<'i, T, V>> Visit<'i, T, V> for CowArcStr<'i /// A quoted CSS string. #[derive(Clone, Eq, Ord, Hash, Debug, Visit)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CSSString<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub CowArcStr<'i>); +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +pub struct CSSString<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub CowArcStr<'i>); impl<'i> Parse<'i> for CSSString<'i> { fn parse<'t>( diff --git a/src/values/syntax.rs b/src/values/syntax.rs index 03842c84..4fa33655 100644 --- a/src/values/syntax.rs +++ b/src/values/syntax.rs @@ -12,7 +12,7 @@ use cssparser::*; /// used to define the grammar for a registered custom property. #[derive(Debug, PartialEq, Clone)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -29,7 +29,7 @@ pub enum SyntaxString { /// A syntax component consists of a component kind an a multiplier, which indicates how the component /// may repeat during parsing. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct SyntaxComponent { /// The kind of component. pub kind: SyntaxComponentKind, @@ -40,7 +40,7 @@ pub struct SyntaxComponent { /// A [syntax component component name](https://drafts.css-houdini.org/css-properties-values-api/#supported-names). #[derive(Debug, PartialEq, Clone)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -81,7 +81,7 @@ pub enum SyntaxComponentKind { /// [SyntaxComponent](SyntaxComponent). Indicates whether and how the component may be repeated. #[derive(Debug, PartialEq, Clone)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -97,7 +97,7 @@ pub enum Multiplier { /// A parsed value for a [SyntaxComponent](SyntaxComponent). #[derive(Debug, PartialEq, Clone)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -113,7 +113,7 @@ pub enum ParsedComponent<'i> { /// A `` value. Color(values::color::CssColor), /// An `` value. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] Image(values::image::Image<'i>), /// A `` value. Url(values::url::Url<'i>), diff --git a/src/values/time.rs b/src/values/time.rs index 7250c05f..184c1753 100644 --- a/src/values/time.rs +++ b/src/values/time.rs @@ -18,7 +18,7 @@ use cssparser::*; #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_time, TIMES)] #[cfg_attr( - feature = "serde", + feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/url.rs b/src/values/url.rs index 3f21414b..7d554787 100644 --- a/src/values/url.rs +++ b/src/values/url.rs @@ -11,10 +11,10 @@ use cssparser::*; /// A CSS [url()](https://www.w3.org/TR/css-values-4/#urls) value and its source location. #[derive(Debug, Clone, Visit)] #[visit(visit_url, URLS)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] pub struct Url<'i> { /// The url string. - #[cfg_attr(feature = "serde", serde(borrow))] + #[cfg_attr(feature = "with-serde", serde(borrow))] pub url: CowArcStr<'i>, /// The location where the `url()` was seen in the CSS source file. pub loc: Location, diff --git a/src/vendor_prefix.rs b/src/vendor_prefix.rs index d0155c40..e72baa4b 100644 --- a/src/vendor_prefix.rs +++ b/src/vendor_prefix.rs @@ -127,7 +127,7 @@ impl cssparser::ToCss for VendorPrefix { } } -#[cfg(feature = "serde")] +#[cfg(feature = "with-serde")] impl serde::Serialize for VendorPrefix { fn serialize(&self, serializer: S) -> Result where @@ -155,7 +155,7 @@ impl serde::Serialize for VendorPrefix { } } -#[cfg(feature = "serde")] +#[cfg(feature = "with-serde")] impl<'de> serde::Deserialize<'de> for VendorPrefix { fn deserialize(deserializer: D) -> Result where From fc2d411546ff0c0a8738d842efce7307079d77a0 Mon Sep 17 00:00:00 2001 From: Devon Govett Date: Tue, 20 Dec 2022 22:38:39 -0500 Subject: [PATCH 4/4] Rename feature back to serde --- Cargo.toml | 4 +-- src/bundler.rs | 4 +-- src/css_modules.rs | 10 +++---- src/declaration.rs | 4 +-- src/dependencies.rs | 18 ++++++------- src/error.rs | 44 +++++++++++++++--------------- src/macros.rs | 10 +++---- src/media_query.rs | 26 +++++++++--------- src/parser.rs | 2 +- src/properties/align.rs | 18 ++++++------- src/properties/animation.rs | 10 +++---- src/properties/background.rs | 8 +++--- src/properties/border.rs | 4 +-- src/properties/border_image.rs | 8 +++--- src/properties/box_shadow.rs | 2 +- src/properties/contain.rs | 8 +++--- src/properties/css_modules.rs | 8 +++--- src/properties/custom.rs | 34 +++++++++++------------ src/properties/display.rs | 6 ++--- src/properties/effects.rs | 10 +++---- src/properties/font.rs | 20 +++++++------- src/properties/grid.rs | 46 ++++++++++++++++---------------- src/properties/list.rs | 14 +++++----- src/properties/masking.rs | 10 +++---- src/properties/mod.rs | 18 ++++++------- src/properties/outline.rs | 2 +- src/properties/position.rs | 4 +-- src/properties/size.rs | 4 +-- src/properties/svg.rs | 12 ++++----- src/properties/text.rs | 22 +++++++-------- src/properties/transform.rs | 16 +++++------ src/properties/transition.rs | 2 +- src/properties/ui.rs | 14 +++++----- src/rules/container.rs | 8 +++--- src/rules/counter_style.rs | 4 +-- src/rules/custom_media.rs | 4 +-- src/rules/document.rs | 4 +-- src/rules/font_face.rs | 22 +++++++-------- src/rules/font_palette_values.rs | 12 ++++----- src/rules/import.rs | 4 +-- src/rules/keyframes.rs | 16 +++++------ src/rules/layer.rs | 12 ++++----- src/rules/media.rs | 4 +-- src/rules/mod.rs | 12 ++++----- src/rules/namespace.rs | 6 ++--- src/rules/nesting.rs | 4 +-- src/rules/page.rs | 12 ++++----- src/rules/property.rs | 4 +-- src/rules/style.rs | 8 +++--- src/rules/supports.rs | 8 +++--- src/rules/unknown.rs | 4 +-- src/rules/viewport.rs | 4 +-- src/selector.rs | 4 +-- src/stylesheet.rs | 6 ++--- src/targets.rs | 4 +-- src/values/alpha.rs | 2 +- src/values/angle.rs | 2 +- src/values/calc.rs | 4 +-- src/values/color.rs | 26 +++++++++--------- src/values/easing.rs | 4 +-- src/values/gradient.rs | 28 +++++++++---------- src/values/ident.rs | 16 +++++------ src/values/image.rs | 12 ++++----- src/values/length.rs | 8 +++--- src/values/percentage.rs | 6 ++--- src/values/position.rs | 4 +-- src/values/ratio.rs | 2 +- src/values/rect.rs | 2 +- src/values/resolution.rs | 2 +- src/values/shape.rs | 14 +++++----- src/values/size.rs | 2 +- src/values/string.rs | 16 +++++------ src/values/syntax.rs | 12 ++++----- src/values/time.rs | 2 +- src/values/url.rs | 4 +-- src/vendor_prefix.rs | 4 +-- 76 files changed, 380 insertions(+), 380 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e3d6d357..3f379d28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,8 +32,8 @@ browserslist = ["browserslist-rs"] bundler = ["dashmap", "rayon"] cli = ["clap", "serde_json", "browserslist", "jemallocator"] grid = [] -nodejs = ["serde"] -with-serde = ["serde", "smallvec/serde", "cssparser/serde"] +nodejs = ["dep:serde"] +serde = ["dep:serde", "smallvec/serde", "cssparser/serde"] [dependencies] serde = { version = "1.0.123", features = ["derive"], optional = true } diff --git a/src/bundler.rs b/src/bundler.rs index 505c8f09..4be9841a 100644 --- a/src/bundler.rs +++ b/src/bundler.rs @@ -144,7 +144,7 @@ impl Drop for FileProvider { /// An error that could occur during bundling. #[derive(Debug)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(serde::Serialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(serde::Serialize))] pub enum BundleErrorKind<'i, T: std::error::Error> { /// A parser error occurred. ParserError(ParserError<'i>), @@ -155,7 +155,7 @@ pub enum BundleErrorKind<'i, T: std::error::Error> { /// Unsupported media query boolean logic was encountered. UnsupportedMediaBooleanLogic, /// A custom resolver error. - ResolverError(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] T), + ResolverError(#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(skip))] T), } impl<'i, T: std::error::Error> From>> for Error> { diff --git a/src/css_modules.rs b/src/css_modules.rs index 4ad65992..f93d0b9b 100644 --- a/src/css_modules.rs +++ b/src/css_modules.rs @@ -14,7 +14,7 @@ use crate::selector::SelectorList; use data_encoding::{Encoding, Specification}; use lazy_static::lazy_static; use pathdiff::diff_paths; -#[cfg(any(feature = "with-serde", feature = "nodejs"))] +#[cfg(any(feature = "serde", feature = "nodejs"))] use serde::Serialize; use smallvec::{smallvec, SmallVec}; use std::borrow::Cow; @@ -166,8 +166,8 @@ pub enum Segment<'i> { /// /// See [CssModuleExport](CssModuleExport). #[derive(PartialEq, Debug, Clone)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(tag = "type", rename_all = "lowercase"))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(tag = "type", rename_all = "lowercase"))] pub enum CssModuleReference { /// A local reference. Local { @@ -190,8 +190,8 @@ pub enum CssModuleReference { /// An exported value from a CSS module. #[derive(PartialEq, Debug, Clone)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(rename_all = "camelCase"))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(rename_all = "camelCase"))] pub struct CssModuleExport { /// The local (compiled) name for this export. pub name: String, diff --git a/src/declaration.rs b/src/declaration.rs index 9f33d95d..89a0e63b 100644 --- a/src/declaration.rs +++ b/src/declaration.rs @@ -43,10 +43,10 @@ use cssparser::*; /// and a list of normal declarations. This reduces memory usage compared /// with storing a boolean along with each property. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DeclarationBlock<'i> { /// A list of `!important` declarations in the block. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub important_declarations: Vec>, /// A list of normal declarations in the block. pub declarations: Vec>, diff --git a/src/dependencies.rs b/src/dependencies.rs index 1c957682..b131415e 100644 --- a/src/dependencies.rs +++ b/src/dependencies.rs @@ -15,7 +15,7 @@ use crate::traits::ToCss; use crate::values::url::Url; use crate::visitor::Visit; use cssparser::SourceLocation; -#[cfg(any(feature = "with-serde", feature = "nodejs"))] +#[cfg(any(feature = "serde", feature = "nodejs"))] use serde::Serialize; /// Options for `analyze_dependencies` in `PrinterOptions`. @@ -27,8 +27,8 @@ pub struct DependencyOptions { /// A dependency. #[derive(Debug)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(tag = "type", rename_all = "lowercase"))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(tag = "type", rename_all = "lowercase"))] pub enum Dependency { /// An `@import` dependency. Import(ImportDependency), @@ -38,7 +38,7 @@ pub enum Dependency { /// An `@import` dependency. #[derive(Debug)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(Serialize))] pub struct ImportDependency { /// The url to import. pub url: String, @@ -91,7 +91,7 @@ impl ImportDependency { /// A `url()` dependency. #[derive(Debug)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(Serialize))] pub struct UrlDependency { /// The url of the dependency. pub url: String, @@ -115,8 +115,8 @@ impl UrlDependency { /// Represents the range of source code where a dependency was found. #[derive(Debug)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(rename_all = "camelCase"))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(rename_all = "camelCase"))] pub struct SourceRange { /// The filename in which the dependency was found. pub file_path: String, @@ -128,8 +128,8 @@ pub struct SourceRange { /// A line and column position within a source file. #[derive(Debug, Clone, Copy, PartialEq, Visit)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(serde::Serialize))] -#[cfg_attr(any(feature = "with-serde"), derive(serde::Deserialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(serde::Serialize))] +#[cfg_attr(any(feature = "serde"), derive(serde::Deserialize))] pub struct Location { /// The line number, starting from 1. pub line: u32, diff --git a/src/error.rs b/src/error.rs index ec8a99c1..52c184e6 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,14 +5,14 @@ use crate::rules::Location; use crate::values::string::CowArcStr; use cssparser::{BasicParseErrorKind, ParseError, ParseErrorKind}; use parcel_selectors::parser::SelectorParseErrorKind; -#[cfg(any(feature = "with-serde", feature = "nodejs"))] +#[cfg(any(feature = "serde", feature = "nodejs"))] use serde::Serialize; use std::fmt; /// An error with a source location. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(serde::Serialize))] -#[cfg_attr(any(feature = "with-serde"), derive(serde::Deserialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(serde::Serialize))] +#[cfg_attr(any(feature = "serde"), derive(serde::Deserialize))] pub struct Error { /// The type of error that occurred. pub kind: T, @@ -34,8 +34,8 @@ impl std::error::Error for Error {} /// A line and column location within a source file. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(serde::Serialize))] -#[cfg_attr(any(feature = "with-serde"), derive(serde::Deserialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(serde::Serialize))] +#[cfg_attr(any(feature = "serde"), derive(serde::Deserialize))] pub struct ErrorLocation { /// The filename in which the error occurred. pub filename: String, @@ -64,8 +64,8 @@ impl fmt::Display for ErrorLocation { /// A parser error. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(tag = "type", content = "value"))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(tag = "type", content = "value"))] pub enum ParserError<'i> { /// An at rule body was invalid. AtRuleBodyInvalid, @@ -94,7 +94,7 @@ pub enum ParserError<'i> { /// A `@namespace` rule was encountered after any rules besides `@charset`, `@import`, or `@layer`. UnexpectedNamespaceRule, /// An unexpected token was encountered. - UnexpectedToken(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), + UnexpectedToken(#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(skip))] Token<'i>), /// Maximum nesting depth was reached. MaximumNestingDepth, } @@ -169,23 +169,23 @@ impl<'i> ParserError<'i> { /// A selector parsing error. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(tag = "type", content = "value"))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(tag = "type", content = "value"))] pub enum SelectorError<'i> { /// An unexpected token was found in an attribute selector. - BadValueInAttr(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), + BadValueInAttr(#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(skip))] Token<'i>), /// An unexpected token was found in a class selector. - ClassNeedsIdent(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), + ClassNeedsIdent(#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(skip))] Token<'i>), /// A dangling combinator was found. DanglingCombinator, /// An empty selector. EmptySelector, /// A `|` was expected in an attribute selector. - ExpectedBarInAttr(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), + ExpectedBarInAttr(#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(skip))] Token<'i>), /// A namespace was expected. ExpectedNamespace(CowArcStr<'i>), /// An unexpected token was encountered in a namespace. - ExplicitNamespaceUnexpectedToken(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), + ExplicitNamespaceUnexpectedToken(#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(skip))] Token<'i>), /// An invalid pseudo class was encountered after a pseudo element. InvalidPseudoClassAfterPseudoElement, /// An invalid pseudo class was encountered after a `-webkit-scrollbar` pseudo element. @@ -193,7 +193,7 @@ pub enum SelectorError<'i> { /// A `-webkit-scrollbar` state was encountered before a `-webkit-scrollbar` pseudo element. InvalidPseudoClassBeforeWebKitScrollbar, /// Invalid qualified name in attribute selector. - InvalidQualNameInAttr(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), + InvalidQualNameInAttr(#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(skip))] Token<'i>), /// The current token is not allowed in this state. InvalidState, /// The selector is required to have the `&` nesting selector at the start. @@ -201,13 +201,13 @@ pub enum SelectorError<'i> { /// The selector is missing a `&` nesting selector. MissingNestingSelector, /// No qualified name in attribute selector. - NoQualifiedNameInAttributeSelector(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), + NoQualifiedNameInAttributeSelector(#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(skip))] Token<'i>), /// An Invalid token was encountered in a pseudo element. - PseudoElementExpectedIdent(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), + PseudoElementExpectedIdent(#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(skip))] Token<'i>), /// An unexpected identifier was encountered. UnexpectedIdent(CowArcStr<'i>), /// An unexpected token was encountered inside an attribute selector. - UnexpectedTokenInAttributeSelector(#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(skip))] Token<'i>), + UnexpectedTokenInAttributeSelector(#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(skip))] Token<'i>), /// An unsupported pseudo class or pseudo element was encountered. UnsupportedPseudoClassOrElement(CowArcStr<'i>), } @@ -297,8 +297,8 @@ pub(crate) type MinifyError = ErrorWithLocation; /// A transformation error. #[derive(Debug, PartialEq)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(tag = "type"))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(tag = "type"))] pub enum MinifyErrorKind { /// A circular `@custom-media` rule was detected. CircularCustomMedia { @@ -344,8 +344,8 @@ pub type PrinterError = Error; /// A printer error type. #[derive(Debug, PartialEq)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize))] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), serde(tag = "type"))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(Serialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(tag = "type"))] pub enum PrinterErrorKind { /// An ambiguous relative `url()` was encountered in a custom property declaration. AmbiguousUrlInCustomProperty { diff --git a/src/macros.rs b/src/macros.rs index b40ea387..142ba01f 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -10,7 +10,7 @@ macro_rules! enum_property { ) => { $(#[$outer])* #[derive(Debug, Clone, Copy, PartialEq, Visit)] - #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "lowercase"))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "lowercase"))] $vis enum $name { $( $(#[$meta])* @@ -67,11 +67,11 @@ macro_rules! enum_property { ) => { $(#[$outer])* #[derive(Debug, Clone, Copy, PartialEq, Visit)] - #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] $vis enum $name { $( $(#[$meta])* - #[cfg_attr(feature = "with-serde", serde(rename = $str))] + #[cfg_attr(feature = "serde", serde(rename = $str))] $id, )+ } @@ -340,7 +340,7 @@ macro_rules! define_shorthand { ) => { $(#[$outer])* #[derive(Debug, Clone, PartialEq, Visit)] - #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct $name$(<$l>)? { $( $(#[$meta])* @@ -554,7 +554,7 @@ macro_rules! define_list_shorthand { ) => { $(#[$outer])* #[derive(Debug, Clone, PartialEq, Visit)] - #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct $name$(<$l>)? { $( $(#[$meta])* diff --git a/src/media_query.rs b/src/media_query.rs index 11dd5b6b..34f60cc7 100644 --- a/src/media_query.rs +++ b/src/media_query.rs @@ -18,10 +18,10 @@ use std::collections::{HashMap, HashSet}; /// A [media query list](https://drafts.csswg.org/mediaqueries/#mq-list). #[derive(Clone, Debug, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MediaList<'i> { /// The list of media queries. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub media_queries: Vec>, } @@ -146,7 +146,7 @@ enum_property! { /// A [media type](https://drafts.csswg.org/mediaqueries/#media-types) within a media query. #[derive(Clone, Debug, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -159,7 +159,7 @@ pub enum MediaType<'i> { /// Matches all devices that aren’t matched by print. Screen, /// An unknown media type. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Custom(CowArcStr<'i>), } @@ -178,12 +178,12 @@ impl<'i> Parse<'i> for MediaType<'i> { /// A [media query](https://drafts.csswg.org/mediaqueries/#media). #[derive(Clone, Debug, PartialEq, Visit)] #[visit(visit_media_query, MEDIA_QUERIES)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MediaQuery<'i> { /// The qualifier for this query. pub qualifier: Option, /// The media type for this query, that can be known, unknown, or "all". - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub media_type: MediaType<'i>, /// The condition that this media query contains. This cannot have `or` /// in the first level. @@ -362,13 +362,13 @@ enum_property! { /// Represents a media condition. #[derive(Clone, Debug, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum MediaCondition<'i> { /// A media feature, implicitly parenthesized. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Feature(MediaFeature<'i>), /// A negation of a condition. #[skip_type] @@ -497,7 +497,7 @@ impl<'i> ToCss for MediaCondition<'i> { /// A [comparator](https://drafts.csswg.org/mediaqueries/#typedef-mf-comparison) within a media query. #[derive(Clone, Copy, Debug, Eq, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -553,7 +553,7 @@ impl MediaFeatureComparison { /// A [media feature](https://drafts.csswg.org/mediaqueries/#typedef-media-feature) #[derive(Clone, Debug, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -561,7 +561,7 @@ pub enum MediaFeature<'i> { /// A plain media feature, e.g. `(min-width: 240px)`. Plain { /// The name of the feature. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] name: Ident<'i>, /// The feature value. value: MediaFeatureValue<'i>, @@ -755,7 +755,7 @@ where /// See [MediaFeature](MediaFeature). #[derive(Clone, Debug, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -769,7 +769,7 @@ pub enum MediaFeatureValue<'i> { /// A ratio. Ratio(Ratio), /// An indentifier. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Ident(Ident<'i>), } diff --git a/src/parser.rs b/src/parser.rs index 1fe92607..87e4b733 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -99,7 +99,7 @@ impl<'i> AtRuleParser<'i> for DefaultAtRuleParser { } #[derive(PartialEq, Clone, Debug)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DefaultAtRule; impl crate::traits::ToCss for DefaultAtRule { fn to_css(&self, _: &mut Printer) -> Result<(), PrinterError> { diff --git a/src/properties/align.rs b/src/properties/align.rs index b04abf08..ef015549 100644 --- a/src/properties/align.rs +++ b/src/properties/align.rs @@ -20,7 +20,7 @@ use cssparser::*; /// as used in the alignment properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -109,7 +109,7 @@ enum_property! { /// A value for the [align-content](https://www.w3.org/TR/css-align-3/#propdef-align-content) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -168,7 +168,7 @@ impl ToCss for AlignContent { /// A value for the [justify-content](https://www.w3.org/TR/css-align-3/#propdef-justify-content) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -329,7 +329,7 @@ enum_property! { /// A value for the [align-self](https://www.w3.org/TR/css-align-3/#align-self-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -395,7 +395,7 @@ impl ToCss for AlignSelf { /// A value for the [justify-self](https://www.w3.org/TR/css-align-3/#justify-self-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -551,7 +551,7 @@ impl ToCss for PlaceSelf { /// A value for the [align-items](https://www.w3.org/TR/css-align-3/#align-items-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -610,7 +610,7 @@ impl ToCss for AlignItems { /// A legacy justification keyword, as used in the `justify-items` property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -676,7 +676,7 @@ impl ToCss for LegacyJustify { /// A value for the [justify-items](https://www.w3.org/TR/css-align-3/#justify-items-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -831,7 +831,7 @@ impl ToCss for PlaceItems { /// `column-gap` and `row-gap` properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/properties/animation.rs b/src/properties/animation.rs index 28ada03e..b4aad1ee 100644 --- a/src/properties/animation.rs +++ b/src/properties/animation.rs @@ -20,7 +20,7 @@ use smallvec::SmallVec; /// A value for the [animation-name](https://drafts.csswg.org/css-animations/#animation-name) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -28,10 +28,10 @@ pub enum AnimationName<'i> { /// The `none` keyword. None, /// An identifier of a `@keyframes` rule. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Ident(CustomIdent<'i>), /// A `` name of a `@keyframes` rule. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] String(CowArcStr<'i>), } @@ -89,7 +89,7 @@ pub type AnimationNameList<'i> = SmallVec<[AnimationName<'i>; 1]>; /// A value for the [animation-iteration-count](https://drafts.csswg.org/css-animations/#animation-iteration-count) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -189,7 +189,7 @@ define_list_shorthand! { /// A value for the [animation](https://drafts.csswg.org/css-animations/#animation) shorthand property. pub struct Animation<'i>(VendorPrefix) { /// The animation name. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] name: AnimationName(AnimationName<'i>, VendorPrefix), /// The animation duration. duration: AnimationDuration(Time, VendorPrefix), diff --git a/src/properties/background.rs b/src/properties/background.rs index e700a110..2000b03b 100644 --- a/src/properties/background.rs +++ b/src/properties/background.rs @@ -20,7 +20,7 @@ use smallvec::SmallVec; /// A value for the [background-size](https://www.w3.org/TR/css-backgrounds-3/#background-size) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -110,7 +110,7 @@ enum_property! { /// A value for the [background-repeat](https://www.w3.org/TR/css-backgrounds-3/#background-repeat) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BackgroundRepeat { /// A repeat style for the x direction. pub x: BackgroundRepeatKeyword, @@ -300,10 +300,10 @@ impl ToCss for BackgroundPosition { /// A value for the [background](https://www.w3.org/TR/css-backgrounds-3/#background) shorthand property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Background<'i> { /// The background image. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub image: Image<'i>, /// The background color. pub color: CssColor, diff --git a/src/properties/border.rs b/src/properties/border.rs index a8eba5c6..e1e30fa2 100644 --- a/src/properties/border.rs +++ b/src/properties/border.rs @@ -23,7 +23,7 @@ use cssparser::*; /// A value for the [border-width](https://www.w3.org/TR/css-backgrounds-3/#border-width) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -109,7 +109,7 @@ impl Default for LineStyle { /// A generic type that represents the `border` and `outline` shorthand properties. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GenericBorder { /// The width of the border. pub width: BorderSideWidth, diff --git a/src/properties/border_image.rs b/src/properties/border_image.rs index 1f971bd2..d32ab2dd 100644 --- a/src/properties/border_image.rs +++ b/src/properties/border_image.rs @@ -38,7 +38,7 @@ enum_property! { /// A value for the [border-image-repeat](https://www.w3.org/TR/css-backgrounds-3/#border-image-repeat) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BorderImageRepeat { /// The horizontal repeat value. pub horizontal: BorderImageRepeatKeyword, @@ -83,7 +83,7 @@ impl ToCss for BorderImageRepeat { /// A value for the [border-image-width](https://www.w3.org/TR/css-backgrounds-3/#border-image-width) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -136,7 +136,7 @@ impl ToCss for BorderImageSideWidth { /// A value for the [border-image-slice](https://www.w3.org/TR/css-backgrounds-3/#border-image-slice) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BorderImageSlice { /// The offsets from the edges of the image. pub offsets: Rect, @@ -182,7 +182,7 @@ define_shorthand! { #[derive(Default)] pub struct BorderImage<'i>(VendorPrefix) { /// The border image. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] source: BorderImageSource(Image<'i>), /// The offsets that define where the image is sliced. slice: BorderImageSlice(BorderImageSlice), diff --git a/src/properties/box_shadow.rs b/src/properties/box_shadow.rs index b07379d1..c972b2fb 100644 --- a/src/properties/box_shadow.rs +++ b/src/properties/box_shadow.rs @@ -18,7 +18,7 @@ use smallvec::SmallVec; /// A value for the [box-shadow](https://drafts.csswg.org/css-backgrounds/#box-shadow) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BoxShadow { /// The color of the box shadow. pub color: CssColor, diff --git a/src/properties/contain.rs b/src/properties/contain.rs index 9ca9a154..5d8816a6 100644 --- a/src/properties/contain.rs +++ b/src/properties/contain.rs @@ -25,7 +25,7 @@ bitflags! { /// /// `normal` is mutually exclusive, but other combinations of flags are allowed. #[derive(Visit)] - #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ContainerType: u8 { /// The element is not a query container for any container size queries, /// but remains a query container for container style queries. @@ -90,7 +90,7 @@ impl ToCss for ContainerType { /// A value for the [container-name](https://drafts.csswg.org/css-contain-3/#container-name) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -98,7 +98,7 @@ pub enum ContainerNameList<'i> { /// The `none` keyword. None, /// A list of container names. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Names(SmallVec<[ContainerIdent<'i>; 1]>), } @@ -154,7 +154,7 @@ define_shorthand! { /// A value for the [container](https://drafts.csswg.org/css-contain-3/#container-shorthand) shorthand property. pub struct Container<'i> { /// The container name. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] name: ContainerName(ContainerNameList<'i>), /// The container type. container_type: ContainerType(ContainerType), diff --git a/src/properties/css_modules.rs b/src/properties/css_modules.rs index 33cbc5f5..25d3a446 100644 --- a/src/properties/css_modules.rs +++ b/src/properties/css_modules.rs @@ -12,10 +12,10 @@ use smallvec::SmallVec; /// A value for the [composes](https://github.com/css-modules/css-modules/#dependencies) property from CSS modules. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Composes<'i> { /// A list of class names to compose. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub names: CustomIdentList<'i>, /// Where the class names are composed from. pub from: Option>, @@ -28,7 +28,7 @@ pub struct Composes<'i> { /// See [Composes](Composes). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -36,7 +36,7 @@ pub enum Specifier<'i> { /// The referenced name is global. Global, /// The referenced name comes from the specified file. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] File(CowArcStr<'i>), /// The referenced name comes from a source index (used during bundling). SourceIndex(u32), diff --git a/src/properties/custom.rs b/src/properties/custom.rs index ff813dda..94c2d115 100644 --- a/src/properties/custom.rs +++ b/src/properties/custom.rs @@ -26,10 +26,10 @@ use cssparser::*; /// A CSS custom property, representing any unknown property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CustomProperty<'i> { /// The name of the property. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub name: CowArcStr<'i>, /// The property value, stored as a raw token list. pub value: TokenList<'i>, @@ -55,12 +55,12 @@ impl<'i> CustomProperty<'i> { /// be parsed, e.g. in the case css `var()` references are encountered. /// In this case, the raw tokens are stored instead. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UnparsedProperty<'i> { /// The id of the property. pub property_id: PropertyId<'i>, /// The property value, stored as a raw token list. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub value: TokenList<'i>, } @@ -98,20 +98,20 @@ impl<'i> UnparsedProperty<'i> { /// A raw list of CSS tokens, with embedded parsed values. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TokenList<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub Vec>); +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct TokenList<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub Vec>); /// A raw CSS token, or a parsed value. #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_token, TOKENS)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum TokenOrValue<'i> { /// A token. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Token(Token<'i>), /// A parsed CSS color. Color(CssColor), @@ -441,13 +441,13 @@ impl<'i> TokenList<'i> { // Copied from cssparser to change CowRcStr to CowArcStr #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum Token<'a> { /// A [``](https://drafts.csswg.org/css-syntax/#ident-token-diagram) - Ident(#[cfg_attr(feature = "with-serde", serde(borrow))] CowArcStr<'a>), + Ident(#[cfg_attr(feature = "serde", serde(borrow))] CowArcStr<'a>), /// A [``](https://drafts.csswg.org/css-syntax/#at-keyword-token-diagram) /// @@ -824,10 +824,10 @@ impl<'i> TokenList<'i> { /// A CSS variable reference. #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_variable, VARIABLES)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Variable<'i> { /// The variable name. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub name: DashedIdentReference<'i>, /// A fallback value in case the variable is not defined. #[skip_type] @@ -875,10 +875,10 @@ impl<'i> Variable<'i> { /// A custom CSS function. #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_function, FUNCTIONS)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Function<'i> { /// The function name. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub name: Ident<'i>, /// The function arguments. #[skip_type] @@ -910,7 +910,7 @@ impl<'i> Function<'i> { /// since variables can resolve to multiple tokens. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "lowercase") )] @@ -924,7 +924,7 @@ pub enum UnresolvedColor<'i> { /// The blue component. b: f32, /// The unresolved alpha component. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] #[skip_type] alpha: TokenList<'i>, }, @@ -937,7 +937,7 @@ pub enum UnresolvedColor<'i> { /// The lightness component. l: f32, /// The unresolved alpha component. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] #[skip_type] alpha: TokenList<'i>, }, diff --git a/src/properties/display.rs b/src/properties/display.rs index dc7eda79..40039d66 100644 --- a/src/properties/display.rs +++ b/src/properties/display.rs @@ -27,7 +27,7 @@ enum_property! { /// A [``](https://drafts.csswg.org/css-display-3/#typedef-display-inside) value. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "kebab-case") )] @@ -107,7 +107,7 @@ impl DisplayInside { /// /// See [Display](Display). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DisplayPair { /// The outside display value. pub outside: DisplayOutside, @@ -321,7 +321,7 @@ enum_property! { /// A value for the [display](https://drafts.csswg.org/css-display-3/#the-display-properties) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/properties/effects.rs b/src/properties/effects.rs index d50fbd5f..e867f9a4 100644 --- a/src/properties/effects.rs +++ b/src/properties/effects.rs @@ -13,7 +13,7 @@ use smallvec::SmallVec; /// A [filter](https://drafts.fxtf.org/filter-effects-1/#filter-functions) function. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -39,7 +39,7 @@ pub enum Filter<'i> { /// A `drop-shadow()` filter. DropShadow(DropShadow), /// A `url()` reference to an SVG filter. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Url(Url<'i>), } @@ -207,7 +207,7 @@ impl<'i> Filter<'i> { /// A [`drop-shadow()`](https://drafts.fxtf.org/filter-effects-1/#funcdef-filter-drop-shadow) filter function. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DropShadow { /// The color of the drop shadow. pub color: CssColor, @@ -295,7 +295,7 @@ impl DropShadow { /// [backdrop-filter](https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty) properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -303,7 +303,7 @@ pub enum FilterList<'i> { /// The `none` keyword. None, /// A list of filter functions. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Filters(SmallVec<[Filter<'i>; 1]>), } diff --git a/src/properties/font.rs b/src/properties/font.rs index 2432365f..bfca1ab9 100644 --- a/src/properties/font.rs +++ b/src/properties/font.rs @@ -19,7 +19,7 @@ use cssparser::*; /// A value for the [font-weight](https://www.w3.org/TR/css-fonts-4/#font-weight-prop) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -76,7 +76,7 @@ impl ToCss for FontWeight { /// See [FontWeight](FontWeight). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -159,7 +159,7 @@ enum_property! { /// A value for the [font-size](https://www.w3.org/TR/css-fonts-4/#font-size-prop) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -255,7 +255,7 @@ impl Into for &FontStretchKeyword { /// A value for the [font-stretch](https://www.w3.org/TR/css-fonts-4/#font-stretch-prop) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -351,13 +351,13 @@ enum_property! { /// A value for the [font-family](https://www.w3.org/TR/css-fonts-4/#font-family-prop) property. #[derive(Debug, Clone, PartialEq, Eq, Hash, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum FontFamily<'i> { /// A custom family name. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] FamilyName(CowArcStr<'i>), /// A generic family name. Generic(GenericFontFamily), @@ -432,7 +432,7 @@ impl<'i> ToCss for FontFamily<'i> { /// A value for the [font-style](https://www.w3.org/TR/css-fonts-4/#font-style-prop) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -532,7 +532,7 @@ impl FontVariantCaps { /// A value for the [line-height](https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-line-height) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -604,7 +604,7 @@ enum_property! { // TODO: there is a more extensive spec in CSS3 but it doesn't seem any browser implements it? https://www.w3.org/TR/css-inline-3/#transverse-alignment #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -642,7 +642,7 @@ define_shorthand! { /// A value for the [font](https://www.w3.org/TR/css-fonts-4/#font-prop) shorthand property. pub struct Font<'i> { /// The font family. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] family: FontFamily(Vec>), /// The font size. size: FontSize(FontSize), diff --git a/src/properties/grid.rs b/src/properties/grid.rs index 7b23705b..7c7b91ba 100644 --- a/src/properties/grid.rs +++ b/src/properties/grid.rs @@ -22,7 +22,7 @@ use smallvec::SmallVec; /// for the `grid-template-rows` and `grid-template-columns` properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -30,7 +30,7 @@ pub enum TrackSizing<'i> { /// No explicit grid tracks. None, /// A list of grid tracks. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] TrackList(TrackList<'i>), } @@ -39,10 +39,10 @@ pub enum TrackSizing<'i> { /// /// See [TrackSizing](TrackSizing). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TrackList<'i> { /// A list of line names. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub line_names: Vec>, /// A list of grid track items. pub items: Vec>, @@ -53,7 +53,7 @@ pub struct TrackList<'i> { /// See [TrackList](TrackList). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -61,7 +61,7 @@ pub enum TrackListItem<'i> { /// A track size. TrackSize(TrackSize), /// A `repeat()` function. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] TrackRepeat(TrackRepeat<'i>), } @@ -71,7 +71,7 @@ pub enum TrackListItem<'i> { /// See [TrackListItem](TrackListItem). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -93,7 +93,7 @@ impl Default for TrackSize { /// A [track size list](https://drafts.csswg.org/css-grid-2/#auto-tracks), as used /// in the `grid-auto-rows` and `grid-auto-columns` properties. #[derive(Debug, Clone, PartialEq, Default, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TrackSizeList(pub SmallVec<[TrackSize; 1]>); /// A [``](https://drafts.csswg.org/css-grid-2/#typedef-track-breadth) value. @@ -101,7 +101,7 @@ pub struct TrackSizeList(pub SmallVec<[TrackSize; 1]>); /// See [TrackSize](TrackSize). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -123,12 +123,12 @@ pub enum TrackBreadth { /// /// See [TrackListItem](TrackListItem). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TrackRepeat<'i> { /// The repeat count. count: RepeatCount, /// The line names to repeat. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] line_names: Vec>, /// The track sizes to repeat. track_sizes: Vec, @@ -140,7 +140,7 @@ pub struct TrackRepeat<'i> { /// See [TrackRepeat](TrackRepeat). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -540,7 +540,7 @@ impl ToCss for TrackSizeList { /// A value for the [grid-template-areas](https://drafts.csswg.org/css-grid-2/#grid-template-areas-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -708,10 +708,10 @@ impl GridTemplateAreas { /// /// If `areas` is not `None`, then `rows` must also not be `None`. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GridTemplate<'i> { /// The grid template rows. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub rows: TrackSizing<'i>, /// The grid template columns. pub columns: TrackSizing<'i>, @@ -937,7 +937,7 @@ bitflags! { /// The `Row` or `Column` flags may be combined with the `Dense` flag, but the `Row` and `Column` flags may /// not be combined. #[derive(Visit)] - #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GridAutoFlow: u8 { /// The auto-placement algorithm places items by filling each row, adding new rows as necessary. const Row = 0b00; @@ -1037,10 +1037,10 @@ impl ToCss for GridAutoFlow { /// /// Explicit and implicit values may not be combined. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Grid<'i> { /// Explicit grid template rows. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub rows: TrackSizing<'i>, /// Explicit grid template columns. pub columns: TrackSizing<'i>, @@ -1220,7 +1220,7 @@ impl_shorthand! { /// used in the `grid-row-start`, `grid-row-end`, `grid-column-start`, and `grid-column-end` properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -1232,7 +1232,7 @@ pub enum GridLine<'i> { /// The Nth grid line, optionally filtered by line name. Negative numbers count backwards from the end. Line( CSSInteger, - #[cfg_attr(feature = "with-serde", serde(borrow))] Option>, + #[cfg_attr(feature = "serde", serde(borrow))] Option>, ), /// A grid span based on the Nth grid line from the opposite edge, optionally filtered by line name. Span(CSSInteger, Option>), @@ -1373,7 +1373,7 @@ define_shorthand! { /// A value for the [grid-row](https://drafts.csswg.org/css-grid-2/#propdef-grid-row) shorthand property. pub struct GridRow<'i> { /// The starting line. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] start: GridRowStart(GridLine<'i>), /// The ending line. end: GridRowEnd(GridLine<'i>), @@ -1384,7 +1384,7 @@ define_shorthand! { /// A value for the [grid-row](https://drafts.csswg.org/css-grid-2/#propdef-grid-column) shorthand property. pub struct GridColumn<'i> { /// The starting line. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] start: GridColumnStart(GridLine<'i>), /// The ending line. end: GridColumnEnd(GridLine<'i>), @@ -1398,7 +1398,7 @@ define_shorthand! { /// A value for the [grid-area](https://drafts.csswg.org/css-grid-2/#propdef-grid-area) shorthand property. pub struct GridArea<'i> { /// The grid row start placement. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] row_start: GridRowStart(GridLine<'i>), /// The grid column start placement. column_start: GridColumnStart(GridLine<'i>), diff --git a/src/properties/list.rs b/src/properties/list.rs index a0acc5e3..54ec3fbd 100644 --- a/src/properties/list.rs +++ b/src/properties/list.rs @@ -16,7 +16,7 @@ use cssparser::*; /// A value for the [list-style-type](https://www.w3.org/TR/2020/WD-css-lists-3-20201117/#text-markers) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -24,7 +24,7 @@ pub enum ListStyleType<'i> { /// No marker. None, /// An explicit marker string. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] String(CSSString<'i>), /// A named counter style. CounterStyle(CounterStyle<'i>), @@ -67,7 +67,7 @@ impl ToCss for ListStyleType<'_> { /// A [counter-style](https://www.w3.org/TR/css-counter-styles-3/#typedef-counter-style) name. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -79,7 +79,7 @@ pub enum CounterStyle<'i> { /// An inline [`symbols()`](https://www.w3.org/TR/css-counter-styles-3/#symbols-function) definition. Symbols( SymbolsType, - #[cfg_attr(feature = "with-serde", serde(borrow))] Vec>, + #[cfg_attr(feature = "serde", serde(borrow))] Vec>, ), } @@ -232,13 +232,13 @@ enum_property! { /// See [CounterStyle](CounterStyle). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum Symbol<'i> { /// A string. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] String(CSSString<'i>), /// An image. Image(Image<'i>), @@ -296,7 +296,7 @@ shorthand_property! { /// A value for the [list-style](https://www.w3.org/TR/2020/WD-css-lists-3-20201117/#list-style-property) shorthand property. pub struct ListStyle<'i> { /// The list style type. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] list_style_type: ListStyleType(ListStyleType<'i>), /// The list marker image. image: ListStyleImage(Image<'i>), diff --git a/src/properties/masking.rs b/src/properties/masking.rs index 73a49f83..9583ba80 100644 --- a/src/properties/masking.rs +++ b/src/properties/masking.rs @@ -105,7 +105,7 @@ impl Default for GeometryBox { /// A value for the [mask-clip](https://www.w3.org/TR/css-masking-1/#the-mask-clip) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -205,7 +205,7 @@ define_list_shorthand! { /// A value for the [mask](https://www.w3.org/TR/css-masking-1/#the-mask) shorthand property. pub struct Mask<'i>(VendorPrefix) { /// The mask image. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] image: MaskImage(Image<'i>, VendorPrefix), /// The position of the mask. position: MaskPosition(Position, VendorPrefix), @@ -375,7 +375,7 @@ impl<'i> ImageFallback<'i> for Mask<'i> { /// A value for the [clip-path](https://www.w3.org/TR/css-masking-1/#the-clip-path) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -383,7 +383,7 @@ pub enum ClipPath<'i> { /// No clip path. None, /// A url reference to an SVG path element. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Url(Url<'i>), /// A basic shape, positioned according to the reference box. Shape(Box, GeometryBox), @@ -456,7 +456,7 @@ define_shorthand! { #[derive(Default)] pub struct MaskBorder<'i> { /// The mask image. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] source: MaskBorderSource(Image<'i>), /// The offsets that define where the image is sliced. slice: MaskBorderSlice(BorderImageSlice), diff --git a/src/properties/mod.rs b/src/properties/mod.rs index 173e0a16..267a7f2b 100644 --- a/src/properties/mod.rs +++ b/src/properties/mod.rs @@ -176,19 +176,19 @@ macro_rules! define_properties { ) => { /// A CSS property id. #[derive(Debug, Clone, PartialEq, Visit)] - #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum PropertyId<'i> { $( #[doc=concat!("The `", $name, "` property.")] $(#[$meta])* - #[cfg_attr(feature = "with-serde", serde(rename = $name))] + #[cfg_attr(feature = "serde", serde(rename = $name))] $property$(($vp))?, )+ /// The `all` property. - #[cfg_attr(feature = "with-serde", serde(rename = "all"))] + #[cfg_attr(feature = "serde", serde(rename = "all"))] All, /// An unknown or custom property name. - #[cfg_attr(feature = "with-serde", serde(borrow, rename = "custom"))] + #[cfg_attr(feature = "serde", serde(borrow, rename = "custom"))] Custom(CowArcStr<'i>) } @@ -495,20 +495,20 @@ macro_rules! define_properties { /// A CSS property. #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_property, PROPERTIES)] - #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] - #[cfg_attr(feature = "with-serde", serde(tag = "property", content = "value"))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", serde(tag = "property", content = "value"))] pub enum Property<'i> { $( #[doc=concat!("The `", $name, "` property.")] $(#[$meta])* - #[cfg_attr(feature = "with-serde", serde(rename = $name))] + #[cfg_attr(feature = "serde", serde(rename = $name))] $property($type, $($vp)?), )+ /// An unparsed property. - #[cfg_attr(feature = "with-serde", serde(borrow, rename = "unparsed"))] + #[cfg_attr(feature = "serde", serde(borrow, rename = "unparsed"))] Unparsed(UnparsedProperty<'i>), /// A custom or unknown property. - #[cfg_attr(feature = "with-serde", serde(borrow, rename = "custom"))] + #[cfg_attr(feature = "serde", serde(borrow, rename = "custom"))] Custom(CustomProperty<'i>), } diff --git a/src/properties/outline.rs b/src/properties/outline.rs index f175e72d..a84cfd80 100644 --- a/src/properties/outline.rs +++ b/src/properties/outline.rs @@ -16,7 +16,7 @@ use cssparser::*; /// A value for the [outline-style](https://drafts.csswg.org/css-ui/#outline-style) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/properties/position.rs b/src/properties/position.rs index 573cc960..7f568f3b 100644 --- a/src/properties/position.rs +++ b/src/properties/position.rs @@ -16,7 +16,7 @@ use cssparser::*; /// A value for the [position](https://www.w3.org/TR/css-position-3/#position-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -72,7 +72,7 @@ impl ToCss for Position { /// A value for the [z-index](https://drafts.csswg.org/css2/#z-index) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/properties/size.rs b/src/properties/size.rs index 1b2a4e3a..537fd2b2 100644 --- a/src/properties/size.rs +++ b/src/properties/size.rs @@ -20,7 +20,7 @@ use cssparser::*; /// i.e. `width` and `height. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -121,7 +121,7 @@ impl ToCss for Size { /// e.g. `min-width` and `max-height`. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/properties/svg.rs b/src/properties/svg.rs index e801d24e..395c85fc 100644 --- a/src/properties/svg.rs +++ b/src/properties/svg.rs @@ -14,7 +14,7 @@ use cssparser::*; /// used in the `fill` and `stroke` properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -24,7 +24,7 @@ pub enum SVGPaint<'i> { /// A URL reference to a paint server element, e.g. `linearGradient`, `radialGradient`, and `pattern`. /// The fallback is used in case the paint server cannot be resolved. Url( - #[cfg_attr(feature = "with-serde", serde(borrow))] Url<'i>, + #[cfg_attr(feature = "serde", serde(borrow))] Url<'i>, Option, ), /// A solid color paint. @@ -40,7 +40,7 @@ pub enum SVGPaint<'i> { /// See [SVGPaint](SVGPaint). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -168,7 +168,7 @@ enum_property! { /// A value for the [stroke-dasharray](https://www.w3.org/TR/SVG2/painting.html#StrokeDashing) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -230,7 +230,7 @@ impl ToCss for StrokeDasharray { /// A value for the [marker](https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties) properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -238,7 +238,7 @@ pub enum Marker<'i> { /// No marker. None, /// A url reference to a `` element. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Url(Url<'i>), } diff --git a/src/properties/text.rs b/src/properties/text.rs index bbc68b9a..ee91d70d 100644 --- a/src/properties/text.rs +++ b/src/properties/text.rs @@ -49,7 +49,7 @@ bitflags! { /// /// All combinations of flags is supported. #[derive(Visit)] - #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TextTransformOther: u8 { /// Puts all typographic character units in full-width form. const FullWidth = 0b00000001; @@ -96,7 +96,7 @@ impl ToCss for TextTransformOther { /// A value for the [text-transform](https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#text-transform-property) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TextTransform { /// How case should be transformed. pub case: TextTransformCase, @@ -291,7 +291,7 @@ enum_property! { /// and [letter-spacing](https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#letter-spacing-property) properties. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -327,7 +327,7 @@ impl ToCss for Spacing { /// A value for the [text-indent](https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#text-indent-property) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TextIndent { /// The amount to indent. pub value: LengthPercentage, @@ -401,7 +401,7 @@ bitflags! { /// /// Multiple lines may be specified by combining the flags. #[derive(Visit)] - #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TextDecorationLine: u8 { /// Each line of text is underlined. const Underline = 0b00000001; @@ -527,7 +527,7 @@ impl Default for TextDecorationStyle { /// A value for the [text-decoration-thickness](https://www.w3.org/TR/2020/WD-css-text-decor-4-20200506/#text-decoration-width-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -715,7 +715,7 @@ enum_property! { /// A value for the [text-emphasis-style](https://www.w3.org/TR/2020/WD-css-text-decor-4-20200506/#text-emphasis-style-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -730,7 +730,7 @@ pub enum TextEmphasisStyle<'i> { shape: Option, }, /// Display the given string as marks. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] String(CSSString<'i>), } @@ -796,7 +796,7 @@ define_shorthand! { /// A value for the [text-emphasis](https://www.w3.org/TR/2020/WD-css-text-decor-4-20200506/#text-emphasis-property) shorthand property. pub struct TextEmphasis<'i>(VendorPrefix) { /// The text emphasis style. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] style: TextEmphasisStyle(TextEmphasisStyle<'i>, VendorPrefix), /// The text emphasis color. color: TextEmphasisColor(CssColor, VendorPrefix), @@ -886,7 +886,7 @@ enum_property! { /// A value for the [text-emphasis-position](https://www.w3.org/TR/2020/WD-css-text-decor-4-20200506/#text-emphasis-position-property) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TextEmphasisPosition { /// The vertical position. pub vertical: TextEmphasisPositionVertical, @@ -1235,7 +1235,7 @@ impl<'i> PropertyHandler<'i> for TextDecorationHandler<'i> { /// A value for the [text-shadow](https://www.w3.org/TR/2020/WD-css-text-decor-4-20200506/#text-shadow-property) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TextShadow { /// The color of the text shadow. pub color: CssColor, diff --git a/src/properties/transform.rs b/src/properties/transform.rs index 02292c94..a62f1232 100644 --- a/src/properties/transform.rs +++ b/src/properties/transform.rs @@ -22,7 +22,7 @@ use std::f32::consts::PI; /// A value for the [transform](https://www.w3.org/TR/2019/CR-css-transforms-1-20190214/#propdef-transform) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TransformList(pub Vec); impl<'i> Parse<'i> for TransformList { @@ -145,7 +145,7 @@ impl TransformList { /// An individual [transform function](https://www.w3.org/TR/2019/CR-css-transforms-1-20190214/#two-d-transform-functions). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -196,7 +196,7 @@ pub enum Transform { /// A 2D matrix. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[allow(missing_docs)] pub struct Matrix { pub a: T, @@ -233,7 +233,7 @@ impl Matrix { /// A 3D matrix. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[allow(missing_docs)] pub struct Matrix3d { pub m11: T, @@ -1388,7 +1388,7 @@ enum_property! { /// A value for the [perspective](https://drafts.csswg.org/css-transforms-2/#perspective-property) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -1423,7 +1423,7 @@ impl ToCss for Perspective { /// A value for the [translate](https://drafts.csswg.org/css-transforms-2/#propdef-translate) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Translate { /// The x translation. pub x: LengthPercentage, @@ -1486,7 +1486,7 @@ impl Translate { /// A value for the [rotate](https://drafts.csswg.org/css-transforms-2/#propdef-rotate) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Rotate { /// Rotation around the x axis. pub x: f32, @@ -1570,7 +1570,7 @@ impl Rotate { /// A value for the [scale](https://drafts.csswg.org/css-transforms-2/#propdef-scale) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Scale { /// Scale on the x axis. pub x: NumberOrPercentage, diff --git a/src/properties/transition.rs b/src/properties/transition.rs index 5eb3df59..2520da6c 100644 --- a/src/properties/transition.rs +++ b/src/properties/transition.rs @@ -22,7 +22,7 @@ define_list_shorthand! { /// A value for the [transition](https://www.w3.org/TR/2018/WD-css-transitions-1-20181011/#transition-shorthand-property) property. pub struct Transition<'i>(VendorPrefix) { /// The property to transition. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] property: TransitionProperty(PropertyId<'i>, VendorPrefix), /// The duration of the transition. duration: TransitionDuration(Time, VendorPrefix), diff --git a/src/properties/ui.rs b/src/properties/ui.rs index 3594163a..e122cd3d 100644 --- a/src/properties/ui.rs +++ b/src/properties/ui.rs @@ -37,10 +37,10 @@ enum_property! { /// /// See [Cursor](Cursor). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CursorImage<'i> { /// A url to the cursor image. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub url: Url<'i>, /// The location in the image where the mouse pointer appears. pub hotspot: Option<(CSSNumber, CSSNumber)>, @@ -125,10 +125,10 @@ enum_property! { /// A value for the [cursor](https://www.w3.org/TR/2021/WD-css-ui-4-20210316/#cursor) property. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Cursor<'i> { /// A list of cursor images. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub images: SmallVec<[CursorImage<'i>; 1]>, /// A pre-defined cursor. pub keyword: CursorKeyword, @@ -168,7 +168,7 @@ impl<'i> ToCss for Cursor<'i> { /// A value for the [caret-color](https://www.w3.org/TR/2021/WD-css-ui-4-20210316/#caret-color) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -284,7 +284,7 @@ enum_property! { /// A value for the [appearance](https://www.w3.org/TR/2021/WD-css-ui-4-20210316/#appearance-switching) property. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(rename_all = "kebab-case") )] @@ -306,7 +306,7 @@ pub enum Appearance<'i> { SliderHorizontal, SquareButton, Textarea, - NonStandard(#[cfg_attr(feature = "with-serde", serde(borrow))] CowArcStr<'i>), + NonStandard(#[cfg_attr(feature = "serde", serde(borrow))] CowArcStr<'i>), } impl<'i> Parse<'i> for Appearance<'i> { diff --git a/src/rules/container.rs b/src/rules/container.rs index 5ea8cf49..e67d46ee 100644 --- a/src/rules/container.rs +++ b/src/rules/container.rs @@ -15,10 +15,10 @@ use crate::visitor::Visit; /// A [@container](https://drafts.csswg.org/css-contain-3/#container-rule) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ContainerRule<'i, R = DefaultAtRule> { /// The name of the container. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub name: Option>, /// The container condition. pub condition: MediaCondition<'i>, @@ -31,8 +31,8 @@ pub struct ContainerRule<'i, R = DefaultAtRule> { /// A [``](https://drafts.csswg.org/css-contain-3/#typedef-container-name) in a `@container` rule. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ContainerName<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub CustomIdent<'i>); +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct ContainerName<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub CustomIdent<'i>); impl<'i> Parse<'i> for ContainerName<'i> { fn parse<'t>(input: &mut Parser<'i, 't>) -> Result>> { diff --git a/src/rules/counter_style.rs b/src/rules/counter_style.rs index cced4a3e..c253be65 100644 --- a/src/rules/counter_style.rs +++ b/src/rules/counter_style.rs @@ -10,10 +10,10 @@ use crate::visitor::Visit; /// A [@counter-style](https://drafts.csswg.org/css-counter-styles/#the-counter-style-rule) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CounterStyleRule<'i> { /// The name of the counter style to declare. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub name: CustomIdent<'i>, // TODO: eventually parse these properties /// Declarations in the `@counter-style` rule. diff --git a/src/rules/custom_media.rs b/src/rules/custom_media.rs index 3e0948a1..e4a0b73f 100644 --- a/src/rules/custom_media.rs +++ b/src/rules/custom_media.rs @@ -10,10 +10,10 @@ use crate::visitor::Visit; /// A [@custom-media](https://drafts.csswg.org/mediaqueries-5/#custom-mq) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CustomMediaRule<'i> { /// The name of the declared media query. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub name: DashedIdent<'i>, /// The media query to declare. pub query: MediaList<'i>, diff --git a/src/rules/document.rs b/src/rules/document.rs index 87d0f618..3b98c16e 100644 --- a/src/rules/document.rs +++ b/src/rules/document.rs @@ -13,10 +13,10 @@ use crate::visitor::Visit; /// Note that only the `url-prefix()` function with no arguments is supported, and only the `-moz` prefix /// is allowed since Firefox was the only browser that ever implemented this rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MozDocumentRule<'i, R = DefaultAtRule> { /// Nested rules within the `@-moz-document` rule. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub rules: CssRuleList<'i, R>, /// The location of the rule in the source file. #[skip_visit] diff --git a/src/rules/font_face.rs b/src/rules/font_face.rs index ff201593..14cdfd9b 100644 --- a/src/rules/font_face.rs +++ b/src/rules/font_face.rs @@ -17,10 +17,10 @@ use std::fmt::Write; /// A [@font-face](https://drafts.csswg.org/css-fonts/#font-face-rule) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct FontFaceRule<'i> { /// Declarations in the `@font-face` rule. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub properties: Vec>, /// The location of the rule in the source file. #[skip_visit] @@ -32,13 +32,13 @@ pub struct FontFaceRule<'i> { /// See [FontFaceRule](FontFaceRule). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum FontFaceProperty<'i> { /// The `src` property. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Source(Vec>), /// The `font-family` property. FontFamily(FontFamily<'i>), @@ -58,7 +58,7 @@ pub enum FontFaceProperty<'i> { /// property in an `@font-face` rule. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -66,7 +66,7 @@ pub enum Source<'i> { /// A `url()` with optional format metadata. Url(UrlSource<'i>), /// The `local()` function. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Local(FontFamily<'i>), } @@ -108,12 +108,12 @@ impl<'i> ToCss for Source<'i> { /// A `url()` value for the [src](https://drafts.csswg.org/css-fonts/#src-desc) /// property in an `@font-face` rule. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UrlSource<'i> { /// The URL. pub url: Url<'i>, /// Optional `format()` function. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub format: Option>, /// Optional `tech()` function. pub tech: Vec, @@ -167,7 +167,7 @@ impl<'i> ToCss for UrlSource<'i> { /// property of an `@font-face` rule. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -188,7 +188,7 @@ pub enum FontFormat<'i> { /// An SVG font. SVG, /// An unknown format. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] String(CowArcStr<'i>), } @@ -279,7 +279,7 @@ enum_property! { /// /// Cannot be empty. Can represent a single code point when start == end. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UnicodeRange { /// Inclusive start of the range. In [0, end]. pub start: u32, diff --git a/src/rules/font_palette_values.rs b/src/rules/font_palette_values.rs index c2ab7e12..800c002f 100644 --- a/src/rules/font_palette_values.rs +++ b/src/rules/font_palette_values.rs @@ -17,12 +17,12 @@ use cssparser::*; /// A [@font-palette-values](https://drafts.csswg.org/css-fonts-4/#font-palette-values) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct FontPaletteValuesRule<'i> { /// The name of the font palette. pub name: DashedIdent<'i>, /// Declarations in the `@font-palette-values` rule. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub properties: Vec>, /// The location of the rule in the source file. #[skip_visit] @@ -34,13 +34,13 @@ pub struct FontPaletteValuesRule<'i> { /// See [FontPaletteValuesRule](FontPaletteValuesRule). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum FontPaletteValuesProperty<'i> { /// The `font-family` property. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] FontFamily(FontFamily<'i>), /// The `base-palette` property. BasePalette(BasePalette), @@ -54,7 +54,7 @@ pub enum FontPaletteValuesProperty<'i> { /// property in an `@font-palette-values` rule. #[derive(Debug, PartialEq, Clone, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -70,7 +70,7 @@ pub enum BasePalette { /// A value for the [override-colors](https://drafts.csswg.org/css-fonts-4/#override-color) /// property in an `@font-palette-values` rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct OverrideColors { /// The index of the color within the palette to override. index: u16, diff --git a/src/rules/import.rs b/src/rules/import.rs index 40dd487c..e4114823 100644 --- a/src/rules/import.rs +++ b/src/rules/import.rs @@ -14,10 +14,10 @@ use cssparser::*; /// A [@import](https://drafts.csswg.org/css-cascade/#at-import) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ImportRule<'i> { /// The url to import. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] #[skip_visit] pub url: CowArcStr<'i>, /// An optional cascade layer name, or `None` for an anonymous layer. diff --git a/src/rules/keyframes.rs b/src/rules/keyframes.rs index d84cb40a..fd49bd44 100644 --- a/src/rules/keyframes.rs +++ b/src/rules/keyframes.rs @@ -22,11 +22,11 @@ use cssparser::*; /// A [@keyframes](https://drafts.csswg.org/css-animations/#keyframes) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct KeyframesRule<'i> { /// The animation name. /// = | - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub name: KeyframesName<'i>, /// A list of keyframes in the animation. pub keyframes: Vec>, @@ -40,14 +40,14 @@ pub struct KeyframesRule<'i> { /// KeyframesName #[derive(Debug, Clone, PartialEq, Eq, Hash, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum KeyframesName<'i> { /// `` of a `@keyframes` name. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Ident(CustomIdent<'i>), /// `` of a `@keyframes` name. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Custom(CowArcStr<'i>), } @@ -250,7 +250,7 @@ impl<'i> ToCss for KeyframesRule<'i> { /// within an `@keyframes` rule. #[derive(Debug, PartialEq, Clone, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -310,12 +310,12 @@ impl ToCss for KeyframeSelector { /// /// See [KeyframesRule](KeyframesRule). #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Keyframe<'i> { /// A list of keyframe selectors to associate with the declarations in this keyframe. pub selectors: Vec, /// The declarations for this keyframe. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub declarations: DeclarationBlock<'i>, } diff --git a/src/rules/layer.rs b/src/rules/layer.rs index 004416a5..7d4d2926 100644 --- a/src/rules/layer.rs +++ b/src/rules/layer.rs @@ -15,8 +15,8 @@ use smallvec::SmallVec; /// /// Nested layers are represented using a list of identifiers. In CSS syntax, these are dot-separated. #[derive(Debug, Clone, PartialEq)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] -pub struct LayerName<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub SmallVec<[CowArcStr<'i>; 1]>); +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct LayerName<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub SmallVec<[CowArcStr<'i>; 1]>); macro_rules! expect_non_whitespace { ($parser: ident, $($branches: tt)+) => {{ @@ -81,10 +81,10 @@ impl<'i> ToCss for LayerName<'i> { /// /// See also [LayerBlockRule](LayerBlockRule). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct LayerStatementRule<'i> { /// The layer names to declare. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] #[skip_visit] pub names: Vec>, /// The location of the rule in the source file. @@ -106,10 +106,10 @@ impl<'i> ToCss for LayerStatementRule<'i> { /// A [@layer block](https://drafts.csswg.org/css-cascade-5/#layer-block) rule. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct LayerBlockRule<'i, R = DefaultAtRule> { /// The name of the layer to declare, or `None` to declare an anonymous layer. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] #[skip_visit] pub name: Option>, /// The rules within the `@layer` rule. diff --git a/src/rules/media.rs b/src/rules/media.rs index 41edb857..054187f5 100644 --- a/src/rules/media.rs +++ b/src/rules/media.rs @@ -12,10 +12,10 @@ use crate::visitor::Visit; /// A [@media](https://drafts.csswg.org/css-conditional-3/#at-media) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MediaRule<'i, R = DefaultAtRule> { /// The media query list. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub query: MediaList<'i>, /// The rules within the `@media` rule. pub rules: CssRuleList<'i, R>, diff --git a/src/rules/mod.rs b/src/rules/mod.rs index b8c2ce46..01298f6b 100644 --- a/src/rules/mod.rs +++ b/src/rules/mod.rs @@ -108,8 +108,8 @@ pub(crate) struct StyleContext<'a, 'i, T> { /// A source location. #[derive(PartialEq, Eq, Debug, Clone, Copy)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(serde::Serialize))] -#[cfg_attr(feature = "with-serde", derive(serde::Deserialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] pub struct Location { /// The index of the source file within the source map. pub source_index: u32, @@ -124,13 +124,13 @@ pub struct Location { #[derive(Debug, PartialEq, Clone, Visit)] #[visit(visit_rule, RULES)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] pub enum CssRule<'i, R = DefaultAtRule> { /// A `@media` rule. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Media(MediaRule<'i, R>), /// An `@import` rule. Import(ImportRule<'i>), @@ -244,9 +244,9 @@ impl<'i, T: ToCss> ToCss for CssRule<'i, T> { /// A list of CSS rules. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CssRuleList<'i, R = DefaultAtRule>( - #[cfg_attr(feature = "with-serde", serde(borrow))] pub Vec>, + #[cfg_attr(feature = "serde", serde(borrow))] pub Vec>, ); // Manually implemented to avoid circular child types. diff --git a/src/rules/namespace.rs b/src/rules/namespace.rs index c2d9b058..93f4a28b 100644 --- a/src/rules/namespace.rs +++ b/src/rules/namespace.rs @@ -10,14 +10,14 @@ use crate::visitor::Visit; /// A [@namespace](https://drafts.csswg.org/css-namespaces/#declaration) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct NamespaceRule<'i> { /// An optional namespace prefix to declare, or `None` to declare the default namespace. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] #[skip_visit] pub prefix: Option>, /// The url of the namespace. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] #[skip_visit] pub url: CSSString<'i>, /// The location of the rule in the source file. diff --git a/src/rules/nesting.rs b/src/rules/nesting.rs index 07064827..fa45618d 100644 --- a/src/rules/nesting.rs +++ b/src/rules/nesting.rs @@ -11,10 +11,10 @@ use crate::traits::ToCss; use crate::visitor::Visit; /// A [@nest](https://www.w3.org/TR/css-nesting-1/#at-nest) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct NestingRule<'i, R = DefaultAtRule> { /// The style rule that defines the selector and declarations for the `@nest` rule. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub style: StyleRule<'i, R>, /// The location of the rule in the source file. #[skip_visit] diff --git a/src/rules/page.rs b/src/rules/page.rs index 87e3a1f5..127b7b74 100644 --- a/src/rules/page.rs +++ b/src/rules/page.rs @@ -16,10 +16,10 @@ use cssparser::*; /// /// Either a name or at least one pseudo class is required. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct PageSelector<'i> { /// An optional named page type. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub name: Option>, /// A list of page pseudo classes. pub pseudo_classes: Vec, @@ -114,12 +114,12 @@ enum_property! { /// A [page margin rule](https://www.w3.org/TR/css-page-3/#margin-at-rules) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct PageMarginRule<'i> { /// The margin box identifier for this rule. pub margin_box: PageMarginBox, /// The declarations within the rule. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub declarations: DeclarationBlock<'i>, /// The location of the rule in the source file. #[skip_visit] @@ -140,10 +140,10 @@ impl<'i> ToCss for PageMarginRule<'i> { /// A [@page](https://www.w3.org/TR/css-page-3/#at-page-rule) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct PageRule<'i> { /// A list of page selectors. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] #[skip_visit] pub selectors: Vec>, /// The declarations within the `@page` rule. diff --git a/src/rules/property.rs b/src/rules/property.rs index 653ce26a..bff1dc08 100644 --- a/src/rules/property.rs +++ b/src/rules/property.rs @@ -15,10 +15,10 @@ use cssparser::*; /// A [@property](https://drafts.css-houdini.org/css-properties-values-api/#at-property-rule) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct PropertyRule<'i> { /// The name of the custom property to declare. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub name: DashedIdent<'i>, /// A syntax string to specify the grammar for the custom property. #[skip_visit] diff --git a/src/rules/style.rs b/src/rules/style.rs index f6e593ec..148cf9ac 100644 --- a/src/rules/style.rs +++ b/src/rules/style.rs @@ -19,16 +19,16 @@ use crate::vendor_prefix::VendorPrefix; use crate::visitor::Visit; use cssparser::*; -#[cfg(feature = "with-serde")] +#[cfg(feature = "serde")] use crate::selector::{deserialize_selectors, serialize_selectors}; /// A CSS [style rule](https://drafts.csswg.org/css-syntax/#style-rules). #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct StyleRule<'i, R = DefaultAtRule> { /// The selectors for the style rule. #[cfg_attr( - feature = "with-serde", + feature = "serde", serde( serialize_with = "serialize_selectors", deserialize_with = "deserialize_selectors", @@ -37,7 +37,7 @@ pub struct StyleRule<'i, R = DefaultAtRule> { )] pub selectors: SelectorList<'i>, /// A vendor prefix override, used during selector printing. - #[cfg_attr(feature = "with-serde", serde(skip, default = "VendorPrefix::empty"))] + #[cfg_attr(feature = "serde", serde(skip, default = "VendorPrefix::empty"))] #[skip_visit] pub vendor_prefix: VendorPrefix, /// The declarations within the style rule. diff --git a/src/rules/supports.rs b/src/rules/supports.rs index dec0a398..e222d07e 100644 --- a/src/rules/supports.rs +++ b/src/rules/supports.rs @@ -16,10 +16,10 @@ use cssparser::*; /// A [@supports](https://drafts.csswg.org/css-conditional-3/#at-supports) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SupportsRule<'i, R = DefaultAtRule> { /// The supports condition. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub condition: SupportsCondition<'i>, /// The rules within the `@supports` rule. pub rules: CssRuleList<'i, R>, @@ -70,7 +70,7 @@ impl<'a, 'i, T: ToCss> ToCssWithContext<'a, 'i, T> for SupportsRule<'i, T> { #[derive(Debug, PartialEq, Clone, Visit)] #[visit(visit_supports_condition, SUPPORTS_CONDITIONS)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -87,7 +87,7 @@ pub enum SupportsCondition<'i> { /// A declaration to evaluate. Declaration { /// The property id for the declaration. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] property_id: PropertyId<'i>, /// The raw value of the declaration. value: CowArcStr<'i>, diff --git a/src/rules/unknown.rs b/src/rules/unknown.rs index 1b1a7b33..1c831c7c 100644 --- a/src/rules/unknown.rs +++ b/src/rules/unknown.rs @@ -10,10 +10,10 @@ use crate::visitor::Visit; /// An unknown at-rule, stored as raw tokens. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UnknownAtRule<'i> { /// The name of the at-rule (without the @). - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] #[skip_visit] pub name: CowArcStr<'i>, /// The prelude of the rule. diff --git a/src/rules/viewport.rs b/src/rules/viewport.rs index ebc6adb8..ca437780 100644 --- a/src/rules/viewport.rs +++ b/src/rules/viewport.rs @@ -10,13 +10,13 @@ use crate::visitor::Visit; /// A [@viewport](https://drafts.csswg.org/css-device-adapt/#atviewport-rule) rule. #[derive(Debug, PartialEq, Clone, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ViewportRule<'i> { /// The vendor prefix for this rule, e.g. `@-ms-viewport`. #[skip_visit] pub vendor_prefix: VendorPrefix, /// The declarations within the `@viewport` rule. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub declarations: DeclarationBlock<'i>, /// The location of the rule in the source file. #[skip_visit] diff --git a/src/selector.rs b/src/selector.rs index 08cb8900..af1e3917 100644 --- a/src/selector.rs +++ b/src/selector.rs @@ -1736,7 +1736,7 @@ pub(crate) fn is_unused( }) } -#[cfg(feature = "with-serde")] +#[cfg(feature = "serde")] pub(crate) fn serialize_selectors(selectors: &SelectorList, s: S) -> Result where S: serde::Serializer, @@ -1755,7 +1755,7 @@ where .serialize(s) } -#[cfg(feature = "with-serde")] +#[cfg(feature = "serde")] pub(crate) fn deserialize_selectors<'i, 'de: 'i, D>(deserializer: D) -> Result, D::Error> where D: serde::Deserializer<'de>, diff --git a/src/stylesheet.rs b/src/stylesheet.rs index 42817105..0a32f3a9 100644 --- a/src/stylesheet.rs +++ b/src/stylesheet.rs @@ -58,11 +58,11 @@ pub use crate::printer::PseudoClasses; /// assert_eq!(res.code, ".foo, .bar {\n color: red;\n}\n"); /// ``` #[derive(Debug)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct StyleSheet<'i, 'o, T: AtRuleParser<'i> = DefaultAtRuleParser> { /// A list of top-level rules within the style sheet. #[cfg_attr( - feature = "with-serde", + feature = "serde", serde( borrow, bound( @@ -77,7 +77,7 @@ pub struct StyleSheet<'i, 'o, T: AtRuleParser<'i> = DefaultAtRuleParser> { pub sources: Vec, /// The source map URL extracted from the original style sheet. pub(crate) source_map_urls: Vec>, - #[cfg_attr(feature = "with-serde", serde(skip))] + #[cfg_attr(feature = "serde", serde(skip))] /// The options the style sheet was originally parsed with. options: ParserOptions<'o, 'i, T>, } diff --git a/src/targets.rs b/src/targets.rs index ed0ea557..9ca4507d 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -1,7 +1,7 @@ //! Browser target options. // This file is autogenerated by build-prefixes.js. DO NOT EDIT! -#[cfg(any(feature = "with-serde", feature = "nodejs"))] +#[cfg(any(feature = "serde", feature = "nodejs"))] use serde::{Serialize, Deserialize}; /// Browser versions to compile CSS for. @@ -22,7 +22,7 @@ use serde::{Serialize, Deserialize}; /// }; /// ``` #[derive(Debug, Clone, Copy, Default)] -#[cfg_attr(any(feature = "with-serde", feature = "nodejs"), derive(Serialize, Deserialize))] +#[cfg_attr(any(feature = "serde", feature = "nodejs"), derive(Serialize, Deserialize))] #[allow(missing_docs)] pub struct Browsers { pub android: Option, diff --git a/src/values/alpha.rs b/src/values/alpha.rs index 4593d0cf..77554d2f 100644 --- a/src/values/alpha.rs +++ b/src/values/alpha.rs @@ -12,7 +12,7 @@ use cssparser::*; /// /// Parses either a `` or ``, but is always stored and serialized as a number. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AlphaValue(pub f32); impl<'i> Parse<'i> for AlphaValue { diff --git a/src/values/angle.rs b/src/values/angle.rs index fefd9b75..bf89ee93 100644 --- a/src/values/angle.rs +++ b/src/values/angle.rs @@ -22,7 +22,7 @@ use std::f32::consts::PI; #[derive(Debug, Clone, Visit)] #[visit(visit_angle, ANGLES)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/calc.rs b/src/values/calc.rs index 4659a0e3..784fdf93 100644 --- a/src/values/calc.rs +++ b/src/values/calc.rs @@ -21,7 +21,7 @@ use super::time::Time; /// values, including lengths, percentages, angles, times, etc. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -202,7 +202,7 @@ impl + TrySign + Clone + std::fmt::Deb /// [Time](super::time::Time), and [Angle](super::angle::Angle) support `calc()` expressions. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/color.rs b/src/values/color.rs index 6b99d37b..21b0d549 100644 --- a/src/values/color.rs +++ b/src/values/color.rs @@ -33,7 +33,7 @@ use std::fmt::Write; #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_color, COLORS)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "lowercase") )] @@ -53,7 +53,7 @@ pub enum CssColor { /// A color in a LAB color space, including the `lab()`, `lch()`, `oklab()`, and `oklch()` functions. #[derive(Debug, Clone, Copy, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "lowercase") )] @@ -71,34 +71,34 @@ pub enum LABColor { /// A color in a predefined color space, e.g. `display-p3`. #[derive(Debug, Clone, Copy, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value") )] pub enum PredefinedColor { /// A color in the `srgb` color space. - #[cfg_attr(feature = "with-serde", serde(rename = "srgb"))] + #[cfg_attr(feature = "serde", serde(rename = "srgb"))] SRGB(SRGB), /// A color in the `srgb-linear` color space. - #[cfg_attr(feature = "with-serde", serde(rename = "srgb-linear"))] + #[cfg_attr(feature = "serde", serde(rename = "srgb-linear"))] SRGBLinear(SRGBLinear), /// A color in the `display-p3` color space. - #[cfg_attr(feature = "with-serde", serde(rename = "display-p3"))] + #[cfg_attr(feature = "serde", serde(rename = "display-p3"))] DisplayP3(P3), /// A color in the `a98-rgb` color space. - #[cfg_attr(feature = "with-serde", serde(rename = "a98-rgb"))] + #[cfg_attr(feature = "serde", serde(rename = "a98-rgb"))] A98(A98), /// A color in the `prophoto-rgb` color space. - #[cfg_attr(feature = "with-serde", serde(rename = "prophoto-rgb"))] + #[cfg_attr(feature = "serde", serde(rename = "prophoto-rgb"))] ProPhoto(ProPhoto), /// A color in the `rec2020` color space. - #[cfg_attr(feature = "with-serde", serde(rename = "rec2020"))] + #[cfg_attr(feature = "serde", serde(rename = "rec2020"))] Rec2020(Rec2020), /// A color in the `xyz-d50` color space. - #[cfg_attr(feature = "with-serde", serde(rename = "xyz-d50"))] + #[cfg_attr(feature = "serde", serde(rename = "xyz-d50"))] XYZd50(XYZd50), /// A color in the `xyz-d65` color space. - #[cfg_attr(feature = "with-serde", serde(rename = "xyz-d65"))] + #[cfg_attr(feature = "serde", serde(rename = "xyz-d65"))] XYZd65(XYZd65), } @@ -107,7 +107,7 @@ pub enum PredefinedColor { /// are any `none` components, which are represented as NaN. #[derive(Debug, Clone, Copy, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "lowercase") )] @@ -1168,7 +1168,7 @@ macro_rules! define_colorspace { ) => { $(#[$outer])* #[derive(Debug, Clone, Copy, PartialEq, Visit)] - #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct $name { $(#[$a_meta])* pub $a: f32, diff --git a/src/values/easing.rs b/src/values/easing.rs index ceaf5492..54203999 100644 --- a/src/values/easing.rs +++ b/src/values/easing.rs @@ -11,7 +11,7 @@ use std::fmt::Write; /// A CSS [easing function](https://www.w3.org/TR/css-easing-1/#easing-functions). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -133,7 +133,7 @@ impl EasingFunction { /// A [step position](https://www.w3.org/TR/css-easing-1/#step-position), used within the `steps()` function. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/gradient.rs b/src/values/gradient.rs index efd9d574..fa61f60b 100644 --- a/src/values/gradient.rs +++ b/src/values/gradient.rs @@ -21,7 +21,7 @@ use cssparser::*; /// A CSS [``](https://www.w3.org/TR/css-images-3/#gradients) value. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -200,7 +200,7 @@ impl ToCss for Gradient { /// A CSS [`linear-gradient()`](https://www.w3.org/TR/css-images-3/#linear-gradients) or `repeating-linear-gradient()`. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct LinearGradient { /// The direction of the gradient. pub direction: LineDirection, @@ -297,7 +297,7 @@ impl LinearGradient { /// A CSS [`radial-gradient()`](https://www.w3.org/TR/css-images-3/#radial-gradients) or `repeating-radial-gradient()`. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct RadialGradient { /// The shape of the gradient. pub shape: EndingShape, @@ -369,7 +369,7 @@ impl RadialGradient { /// See [LinearGradient](LinearGradient). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -462,7 +462,7 @@ impl LineDirection { /// See [RadialGradient](RadialGradient). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -511,7 +511,7 @@ impl ToCss for EndingShape { /// See [RadialGradient](RadialGradient). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -578,7 +578,7 @@ impl ToCss for Circle { /// See [RadialGradient](RadialGradient). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -661,7 +661,7 @@ enum_property! { /// A CSS [`conic-gradient()`](https://www.w3.org/TR/css-images-4/#conic-gradients) or `repeating-conic-gradient()`. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ConicGradient { /// The angle of the gradient. pub angle: Angle, @@ -739,7 +739,7 @@ impl ConicGradient { /// This type is generic, and may be either a [LengthPercentage](super::length::LengthPercentage) /// or [Angle](super::angle::Angle) depending on what type of gradient it is within. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ColorStop { /// The color of the color stop. pub color: CssColor, @@ -775,7 +775,7 @@ impl ToCss for ColorStop { /// or [Angle](super::angle::Angle) depending on what type of gradient it is within. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -919,7 +919,7 @@ where /// A legacy `-webkit-gradient()`. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -1062,7 +1062,7 @@ impl WebKitGradient { /// A color stop within a legacy `-webkit-gradient()`. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WebKitColorStop { /// The color of the color stop. pub color: CssColor, @@ -1123,7 +1123,7 @@ impl WebKitColorStop { /// An x/y position within a legacy `-webkit-gradient()`. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WebKitGradientPoint { /// The x-position. pub x: WebKitGradientPointComponent, @@ -1153,7 +1153,7 @@ impl ToCss for WebKitGradientPoint { /// A keyword or number within a [WebKitGradientPoint](WebKitGradientPoint). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/ident.rs b/src/values/ident.rs index fdd2ce81..68f7c37a 100644 --- a/src/values/ident.rs +++ b/src/values/ident.rs @@ -20,8 +20,8 @@ use super::string::impl_string_type; /// They may be renamed to include a hash when compiled as part of a CSS module. #[derive(Debug, Clone, Eq, Hash, Visit)] #[visit(visit_custom_ident, CUSTOM_IDENTS)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CustomIdent<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub CowArcStr<'i>); +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct CustomIdent<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub CowArcStr<'i>); impl<'i> Parse<'i> for CustomIdent<'i> { fn parse<'t>(input: &mut Parser<'i, 't>) -> Result>> { @@ -58,8 +58,8 @@ pub type CustomIdentList<'i> = SmallVec<[CustomIdent<'i>; 1]>; /// Author defined idents must start with two dash characters ("--") or parsing will fail. #[derive(Debug, Clone, Eq, Hash, Visit)] #[visit(visit_dashed_ident, DASHED_IDENTS)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] -pub struct DashedIdent<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub CowArcStr<'i>); +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct DashedIdent<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub CowArcStr<'i>); impl<'i> Parse<'i> for DashedIdent<'i> { fn parse<'t>(input: &mut Parser<'i, 't>) -> Result>> { @@ -90,10 +90,10 @@ impl<'i> ToCss for DashedIdent<'i> { /// In CSS modules, when the `dashed_idents` option is enabled, the identifier may be followed by the /// `from` keyword and an argument indicating where the referenced identifier is declared (e.g. a filename). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DashedIdentReference<'i> { /// The referenced identifier. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub ident: DashedIdent<'i>, /// CSS modules extension: the filename where the variable is defined. /// Only enabled when the CSS modules `dashed_idents` option is turned on. @@ -144,8 +144,8 @@ impl<'i> ToCss for DashedIdentReference<'i> { /// A CSS [``](https://www.w3.org/TR/css-values-4/#css-css-identifier). #[derive(Debug, Clone, Eq, Hash, Default, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Ident<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub CowArcStr<'i>); +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Ident<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub CowArcStr<'i>); impl<'i> Parse<'i> for Ident<'i> { fn parse<'t>(input: &mut Parser<'i, 't>) -> Result>> { diff --git a/src/values/image.rs b/src/values/image.rs index 5451bb56..67df7ca9 100644 --- a/src/values/image.rs +++ b/src/values/image.rs @@ -21,7 +21,7 @@ use smallvec::SmallVec; #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_image, IMAGES)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -29,7 +29,7 @@ pub enum Image<'i> { /// The `none` keyword. None, /// A `url()`. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Url(Url<'i>), /// A gradient. Gradient(Box), @@ -342,10 +342,10 @@ impl<'i> ToCss for Image<'i> { /// `image-set()` allows the user agent to choose between multiple versions of an image to /// display the most appropriate resolution or file type that it supports. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ImageSet<'i> { /// The image options to choose from. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub options: Vec>, /// The vendor prefix for the `image-set()` function. pub vendor_prefix: VendorPrefix, @@ -414,7 +414,7 @@ impl<'i> ToCss for ImageSet<'i> { /// An image option within the `image-set()` function. See [ImageSet](ImageSet). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ImageSetOption<'i> { /// The image for this option. #[skip_type] @@ -422,7 +422,7 @@ pub struct ImageSetOption<'i> { /// The resolution of the image. pub resolution: Resolution, /// The mime type of the image. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub file_type: Option>, } diff --git a/src/values/length.rs b/src/values/length.rs index 20ff07e9..3fa78e58 100644 --- a/src/values/length.rs +++ b/src/values/length.rs @@ -39,7 +39,7 @@ impl LengthPercentage { /// Either a [``](https://www.w3.org/TR/css-values-4/#typedef-length-percentage), or the `auto` keyword. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -95,7 +95,7 @@ macro_rules! define_length_units { /// without support for `calc()`. See also: [Length](Length). #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_length, LENGTHS)] - #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "unit", content = "value", rename_all = "kebab-case"))] + #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "unit", content = "value", rename_all = "kebab-case"))] pub enum LengthValue { $( $(#[$meta])* @@ -476,7 +476,7 @@ impl LengthValue { /// A CSS [``](https://www.w3.org/TR/css-values-4/#lengths) value, with support for `calc()`. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -738,7 +738,7 @@ impl_try_from_angle!(Length); /// Either a [``](https://www.w3.org/TR/css-values-4/#lengths) or a [``](https://www.w3.org/TR/css-values-4/#numbers). #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/percentage.rs b/src/values/percentage.rs index 60771a0c..e6c81edc 100644 --- a/src/values/percentage.rs +++ b/src/values/percentage.rs @@ -15,7 +15,7 @@ use cssparser::*; /// Percentages may be explicit or computed by `calc()`, but are always stored and serialized /// as their computed value. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Percentage(pub CSSNumber); impl<'i> Parse<'i> for Percentage { @@ -142,7 +142,7 @@ impl_try_from_angle!(Percentage); /// Either a `` or ``. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -194,7 +194,7 @@ impl std::convert::Into for &NumberOrPercentage { /// #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/position.rs b/src/values/position.rs index a390af70..9c6b2932 100644 --- a/src/values/position.rs +++ b/src/values/position.rs @@ -12,7 +12,7 @@ use cssparser::*; /// A CSS [``](https://www.w3.org/TR/css3-values/#position) value, /// as used in the `background-position` property, gradients, masks, etc. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Position { /// The x-position. pub x: HorizontalPosition, @@ -239,7 +239,7 @@ impl ToCss for Position { /// This type is generic over side keywords. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/ratio.rs b/src/values/ratio.rs index 1add44d9..4cb7f3c3 100644 --- a/src/values/ratio.rs +++ b/src/values/ratio.rs @@ -11,7 +11,7 @@ use cssparser::*; /// representing the ratio of two numeric values. #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_ratio, RATIOS)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Ratio(pub CSSNumber, pub CSSNumber); impl<'i> Parse<'i> for Ratio { diff --git a/src/values/rect.rs b/src/values/rect.rs index b4cf30bb..76cd418a 100644 --- a/src/values/rect.rs +++ b/src/values/rect.rs @@ -12,7 +12,7 @@ use cssparser::*; /// When serialized, as few components as possible are written when /// there are duplicate values. #[derive(Clone, Debug, PartialEq, Eq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Rect( /// The top component. pub T, diff --git a/src/values/resolution.rs b/src/values/resolution.rs index 78acd75f..f2b571cb 100644 --- a/src/values/resolution.rs +++ b/src/values/resolution.rs @@ -13,7 +13,7 @@ use cssparser::*; #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_resolution, RESOLUTIONS)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/shape.rs b/src/values/shape.rs index 84ee94b1..6ea552dd 100644 --- a/src/values/shape.rs +++ b/src/values/shape.rs @@ -14,7 +14,7 @@ use cssparser::*; /// A CSS [``](https://www.w3.org/TR/css-shapes-1/#basic-shape-functions) value. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -31,7 +31,7 @@ pub enum BasicShape { /// An [`inset()`](https://www.w3.org/TR/css-shapes-1/#funcdef-inset) rectangle shape. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InsetRect { /// The rectangle. pub rect: Rect, @@ -41,7 +41,7 @@ pub struct InsetRect { /// A [`circle()`](https://www.w3.org/TR/css-shapes-1/#funcdef-circle) shape. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Circle { /// The radius of the circle. pub radius: ShapeRadius, @@ -53,7 +53,7 @@ pub struct Circle { /// that defines the radius of a `circle()` or `ellipse()` shape. #[derive(Debug, Clone, PartialEq, Visit)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -68,7 +68,7 @@ pub enum ShapeRadius { /// An [`ellipse()`](https://www.w3.org/TR/css-shapes-1/#funcdef-ellipse) shape. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Ellipse { /// The x-radius of the ellipse. pub radius_x: ShapeRadius, @@ -80,7 +80,7 @@ pub struct Ellipse { /// A [`polygon()`](https://www.w3.org/TR/css-shapes-1/#funcdef-polygon) shape. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Polygon { /// The fill rule used to determine the interior of the polygon. pub fill_rule: FillRule, @@ -92,7 +92,7 @@ pub struct Polygon { /// /// See [Polygon](Polygon). #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Point { /// The x position of the point. x: LengthPercentage, diff --git a/src/values/size.rs b/src/values/size.rs index c4fc4438..e89a3f74 100644 --- a/src/values/size.rs +++ b/src/values/size.rs @@ -10,7 +10,7 @@ use cssparser::*; /// /// When serialized, only a single component will be written if both are equal. #[derive(Debug, Clone, PartialEq, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Size2D(pub T, pub T); impl<'i, T> Parse<'i> for Size2D diff --git a/src/values/string.rs b/src/values/string.rs index c2f9228b..104c544a 100644 --- a/src/values/string.rs +++ b/src/values/string.rs @@ -3,9 +3,9 @@ use crate::traits::{Parse, ToCss}; use crate::visitor::{Visit, VisitTypes, Visitor}; use cssparser::{serialize_string, CowRcStr}; -#[cfg(feature = "with-serde")] +#[cfg(feature = "serde")] use serde::{Deserialize, Deserializer}; -#[cfg(any(feature = "with-serde", feature = "nodejs"))] +#[cfg(any(feature = "serde", feature = "nodejs"))] use serde::{Serialize, Serializer}; use std::borrow::Borrow; use std::cmp; @@ -220,14 +220,14 @@ impl<'a> fmt::Debug for CowArcStr<'a> { } } -#[cfg(any(feature = "nodejs", feature = "with-serde"))] +#[cfg(any(feature = "nodejs", feature = "serde"))] impl<'a> Serialize for CowArcStr<'a> { fn serialize(&self, serializer: S) -> Result { self.as_ref().serialize(serializer) } } -#[cfg(feature = "with-serde")] +#[cfg(feature = "serde")] impl<'a, 'de: 'a> Deserialize<'de> for CowArcStr<'a> { fn deserialize(deserializer: D) -> Result where @@ -237,10 +237,10 @@ impl<'a, 'de: 'a> Deserialize<'de> for CowArcStr<'a> { } } -#[cfg(feature = "with-serde")] +#[cfg(feature = "serde")] struct CowArcStrVisitor; -#[cfg(feature = "with-serde")] +#[cfg(feature = "serde")] impl<'de> serde::de::Visitor<'de> for CowArcStrVisitor { type Value = CowArcStr<'de>; @@ -277,8 +277,8 @@ impl<'i, V: Visitor<'i, T>, T: Visit<'i, T, V>> Visit<'i, T, V> for CowArcStr<'i /// A quoted CSS string. #[derive(Clone, Eq, Ord, Hash, Debug, Visit)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CSSString<'i>(#[cfg_attr(feature = "with-serde", serde(borrow))] pub CowArcStr<'i>); +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct CSSString<'i>(#[cfg_attr(feature = "serde", serde(borrow))] pub CowArcStr<'i>); impl<'i> Parse<'i> for CSSString<'i> { fn parse<'t>( diff --git a/src/values/syntax.rs b/src/values/syntax.rs index 4fa33655..03842c84 100644 --- a/src/values/syntax.rs +++ b/src/values/syntax.rs @@ -12,7 +12,7 @@ use cssparser::*; /// used to define the grammar for a registered custom property. #[derive(Debug, PartialEq, Clone)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -29,7 +29,7 @@ pub enum SyntaxString { /// A syntax component consists of a component kind an a multiplier, which indicates how the component /// may repeat during parsing. #[derive(Debug, PartialEq, Clone)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SyntaxComponent { /// The kind of component. pub kind: SyntaxComponentKind, @@ -40,7 +40,7 @@ pub struct SyntaxComponent { /// A [syntax component component name](https://drafts.css-houdini.org/css-properties-values-api/#supported-names). #[derive(Debug, PartialEq, Clone)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -81,7 +81,7 @@ pub enum SyntaxComponentKind { /// [SyntaxComponent](SyntaxComponent). Indicates whether and how the component may be repeated. #[derive(Debug, PartialEq, Clone)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -97,7 +97,7 @@ pub enum Multiplier { /// A parsed value for a [SyntaxComponent](SyntaxComponent). #[derive(Debug, PartialEq, Clone)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] @@ -113,7 +113,7 @@ pub enum ParsedComponent<'i> { /// A `` value. Color(values::color::CssColor), /// An `` value. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] Image(values::image::Image<'i>), /// A `` value. Url(values::url::Url<'i>), diff --git a/src/values/time.rs b/src/values/time.rs index 184c1753..7250c05f 100644 --- a/src/values/time.rs +++ b/src/values/time.rs @@ -18,7 +18,7 @@ use cssparser::*; #[derive(Debug, Clone, PartialEq, Visit)] #[visit(visit_time, TIMES)] #[cfg_attr( - feature = "with-serde", + feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] diff --git a/src/values/url.rs b/src/values/url.rs index 7d554787..3f21414b 100644 --- a/src/values/url.rs +++ b/src/values/url.rs @@ -11,10 +11,10 @@ use cssparser::*; /// A CSS [url()](https://www.w3.org/TR/css-values-4/#urls) value and its source location. #[derive(Debug, Clone, Visit)] #[visit(visit_url, URLS)] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Url<'i> { /// The url string. - #[cfg_attr(feature = "with-serde", serde(borrow))] + #[cfg_attr(feature = "serde", serde(borrow))] pub url: CowArcStr<'i>, /// The location where the `url()` was seen in the CSS source file. pub loc: Location, diff --git a/src/vendor_prefix.rs b/src/vendor_prefix.rs index e72baa4b..d0155c40 100644 --- a/src/vendor_prefix.rs +++ b/src/vendor_prefix.rs @@ -127,7 +127,7 @@ impl cssparser::ToCss for VendorPrefix { } } -#[cfg(feature = "with-serde")] +#[cfg(feature = "serde")] impl serde::Serialize for VendorPrefix { fn serialize(&self, serializer: S) -> Result where @@ -155,7 +155,7 @@ impl serde::Serialize for VendorPrefix { } } -#[cfg(feature = "with-serde")] +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for VendorPrefix { fn deserialize(deserializer: D) -> Result where