/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Common handling for the specified value CSS param() values.
usecrate::custom_properties::VariableValue; usecrate::parser::{Parse, ParserContext}; usecrate::values::fmt; usecrate::values::CssWriter; usecrate::{derives::*, values::DashedIdent}; use cssparser::Parser; use std::fmt::Write; use style_traits::arc_slice::ArcSlice; use style_traits::owned_str::OwnedStr; use style_traits::{ParseError, ToCss};
/// A struct to hold a specific '<declaration-value>?', since an empty value (param(--a, )) serializes differently than /// a non-provided value (param(--a)) #[derive(
Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem,
)] #[repr(C, u8)] pubenum LinkParamValueOrNone { /// Handles the case when no value is provided at all: param(--a)
None, /// Handles the cases for provided, or provided but empty, e.g. param(--a, blue) and param(--a, )
Specified(OwnedStr),
}
let params = input.parse_comma_separated(|input| {
input.expect_function_matching("param")?;
input.parse_nested_block(|input| { let name = DashedIdent::parse(context, input)?; // if a comma exists then parse it and set value as specified, even if no value provided // need to handle url references properly https://bugzilla.mozilla.org/show_bug.cgi?id=2028998 let value = if input.try_parse(|i| i.expect_comma()).is_ok() { let parsed = VariableValue::parse(input, None, &context.url_data)?;
LinkParamValueOrNone::Specified(OwnedStr::from(parsed.css))
} else {
LinkParamValueOrNone::None
};
Ok(LinkParam { name, value })
})
})?;
impl ToCss for LinkParam { fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where
W: Write,
{
dest.write_str("param(")?; self.name.to_css(dest)?; iflet LinkParamValueOrNone::Specified(param) = &self.value {
dest.write_str(", ")?; if !param.is_empty() { // Don't use to_css, instead write the raw CSS value without extra quoting, else serialization will include un-de-serializable quotes
dest.write_str(¶m)?;
}
}
dest.write_char(')')
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-08-25)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.