mirror of
https://github.com/servo/servo.git
synced 2025-08-09 15:35:34 +01:00
style: Use cbindgen for content property.
This cleans up and also allows us to keep the distinction between content: none and content: normal, which allows us to fix the computed style we return from getComputedStyle(). Do this last bit from the resolved value instead of StyleAdjuster, because otherwise we need to tweak every initial struct for ::before / ::after. Differential Revision: https://phabricator.services.mozilla.com/D58276
This commit is contained in:
parent
07d0eea5fb
commit
219c0f6328
13 changed files with 122 additions and 343 deletions
|
@ -153,22 +153,26 @@ fn is_decimal(counter_type: &CounterStyleType) -> bool {
|
|||
SpecifiedValueInfo,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
pub enum Content<ImageUrl> {
|
||||
#[repr(u8)]
|
||||
pub enum GenericContent<ImageUrl> {
|
||||
/// `normal` reserved keyword.
|
||||
Normal,
|
||||
/// `none` reserved keyword.
|
||||
None,
|
||||
/// `-moz-alt-content`.
|
||||
#[cfg(feature = "gecko")]
|
||||
MozAltContent,
|
||||
/// Content items.
|
||||
Items(#[css(iterable)] Box<[ContentItem<ImageUrl>]>),
|
||||
Items(#[css(iterable)] crate::OwnedSlice<GenericContentItem<ImageUrl>>),
|
||||
}
|
||||
|
||||
pub use self::GenericContent as Content;
|
||||
|
||||
impl<ImageUrl> Content<ImageUrl> {
|
||||
#[inline]
|
||||
pub(crate) fn is_items(&self) -> bool {
|
||||
matches!(*self, Self::Items(..))
|
||||
}
|
||||
|
||||
/// Set `content` property to `normal`.
|
||||
#[inline]
|
||||
pub fn normal() -> Self {
|
||||
|
@ -189,9 +193,10 @@ impl<ImageUrl> Content<ImageUrl> {
|
|||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
pub enum ContentItem<ImageUrl> {
|
||||
#[repr(u8)]
|
||||
pub enum GenericContentItem<ImageUrl> {
|
||||
/// Literal string content.
|
||||
String(Box<str>),
|
||||
String(crate::OwnedStr),
|
||||
/// `counter(name, style)`.
|
||||
#[css(comma, function)]
|
||||
Counter(CustomIdent, #[css(skip_if = "is_decimal")] CounterStyleType),
|
||||
|
@ -199,7 +204,7 @@ pub enum ContentItem<ImageUrl> {
|
|||
#[css(comma, function)]
|
||||
Counters(
|
||||
CustomIdent,
|
||||
Box<str>,
|
||||
crate::OwnedStr,
|
||||
#[css(skip_if = "is_decimal")] CounterStyleType,
|
||||
),
|
||||
/// `open-quote`.
|
||||
|
@ -210,9 +215,14 @@ pub enum ContentItem<ImageUrl> {
|
|||
NoOpenQuote,
|
||||
/// `no-close-quote`.
|
||||
NoCloseQuote,
|
||||
/// `-moz-alt-content`.
|
||||
#[cfg(feature = "gecko")]
|
||||
MozAltContent,
|
||||
/// `attr([namespace? `|`]? ident)`
|
||||
#[cfg(feature = "gecko")]
|
||||
Attr(Attr),
|
||||
/// `url(url)`
|
||||
Url(ImageUrl),
|
||||
}
|
||||
|
||||
pub use self::GenericContentItem as ContentItem;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue