mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Distinguish between specified and computed URLs.
This is needed to serialize computed URLs correctly from getComputedStyle. Bug: 1461288 Reviewed-by: xidorn MozReview-Commit-ID: 9wakhqNrszb
This commit is contained in:
parent
a6328ba3ce
commit
1314f47da5
11 changed files with 375 additions and 295 deletions
|
@ -4,8 +4,14 @@
|
|||
|
||||
//! Generic types for counters-related CSS values.
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
use computed_values::list_style_type::T as ListStyleType;
|
||||
use std::ops::Deref;
|
||||
use values::CustomIdent;
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::generics::CounterStyleOrNone;
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::specified::Attr;
|
||||
|
||||
/// A name / value pair for counters.
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo,
|
||||
|
@ -74,3 +80,78 @@ impl<I> Default for Counters<I> {
|
|||
Counters(vec![].into_boxed_slice())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
type CounterStyleType = ListStyleType;
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
type CounterStyleType = CounterStyleOrNone;
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
#[inline]
|
||||
fn is_decimal(counter_type: &CounterStyleType) -> bool {
|
||||
*counter_type == ListStyleType::Decimal
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
#[inline]
|
||||
fn is_decimal(counter_type: &CounterStyleType) -> bool {
|
||||
*counter_type == CounterStyleOrNone::decimal()
|
||||
}
|
||||
|
||||
/// The specified value for the `content` property.
|
||||
///
|
||||
/// https://drafts.csswg.org/css-content/#propdef-content
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo,
|
||||
ToComputedValue, ToCss)]
|
||||
pub enum Content<ImageUrl> {
|
||||
/// `normal` reserved keyword.
|
||||
Normal,
|
||||
/// `none` reserved keyword.
|
||||
None,
|
||||
/// `-moz-alt-content`.
|
||||
#[cfg(feature = "gecko")]
|
||||
MozAltContent,
|
||||
/// Content items.
|
||||
Items(#[css(iterable)] Box<[ContentItem<ImageUrl>]>),
|
||||
}
|
||||
|
||||
impl<ImageUrl> Content<ImageUrl> {
|
||||
/// Set `content` property to `normal`.
|
||||
#[inline]
|
||||
pub fn normal() -> Self {
|
||||
Content::Normal
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Items for the `content` property.
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo,
|
||||
ToComputedValue, ToCss)]
|
||||
pub enum ContentItem<ImageUrl> {
|
||||
/// Literal string content.
|
||||
String(Box<str>),
|
||||
/// `counter(name, style)`.
|
||||
#[css(comma, function)]
|
||||
Counter(CustomIdent, #[css(skip_if = "is_decimal")] CounterStyleType),
|
||||
/// `counters(name, separator, style)`.
|
||||
#[css(comma, function)]
|
||||
Counters(
|
||||
CustomIdent,
|
||||
Box<str>,
|
||||
#[css(skip_if = "is_decimal")] CounterStyleType,
|
||||
),
|
||||
/// `open-quote`.
|
||||
OpenQuote,
|
||||
/// `close-quote`.
|
||||
CloseQuote,
|
||||
/// `no-open-quote`.
|
||||
NoOpenQuote,
|
||||
/// `no-close-quote`.
|
||||
NoCloseQuote,
|
||||
/// `attr([namespace? `|`]? ident)`
|
||||
#[cfg(feature = "gecko")]
|
||||
Attr(Attr),
|
||||
/// `url(url)`
|
||||
Url(ImageUrl),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue