mirror of
https://github.com/servo/servo.git
synced 2025-08-08 15:05:35 +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
|
@ -39,7 +39,7 @@ pub mod transform;
|
|||
pub mod ui;
|
||||
pub mod url;
|
||||
|
||||
// https://drafts.csswg.org/css-counter-styles/#typedef-symbols-type
|
||||
/// https://drafts.csswg.org/css-counter-styles/#typedef-symbols-type
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(
|
||||
|
@ -55,6 +55,7 @@ pub mod url;
|
|||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(u8)]
|
||||
pub enum SymbolsType {
|
||||
Cyclic,
|
||||
Numeric,
|
||||
|
@ -63,39 +64,12 @@ pub enum SymbolsType {
|
|||
Fixed,
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl SymbolsType {
|
||||
/// Convert symbols type to their corresponding Gecko values.
|
||||
pub fn to_gecko_keyword(self) -> u8 {
|
||||
use crate::gecko_bindings::structs;
|
||||
match self {
|
||||
SymbolsType::Cyclic => structs::NS_STYLE_COUNTER_SYSTEM_CYCLIC as u8,
|
||||
SymbolsType::Numeric => structs::NS_STYLE_COUNTER_SYSTEM_NUMERIC as u8,
|
||||
SymbolsType::Alphabetic => structs::NS_STYLE_COUNTER_SYSTEM_ALPHABETIC as u8,
|
||||
SymbolsType::Symbolic => structs::NS_STYLE_COUNTER_SYSTEM_SYMBOLIC as u8,
|
||||
SymbolsType::Fixed => structs::NS_STYLE_COUNTER_SYSTEM_FIXED as u8,
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert Gecko value to symbol type.
|
||||
pub fn from_gecko_keyword(gecko_value: u32) -> SymbolsType {
|
||||
use crate::gecko_bindings::structs;
|
||||
match gecko_value {
|
||||
structs::NS_STYLE_COUNTER_SYSTEM_CYCLIC => SymbolsType::Cyclic,
|
||||
structs::NS_STYLE_COUNTER_SYSTEM_NUMERIC => SymbolsType::Numeric,
|
||||
structs::NS_STYLE_COUNTER_SYSTEM_ALPHABETIC => SymbolsType::Alphabetic,
|
||||
structs::NS_STYLE_COUNTER_SYSTEM_SYMBOLIC => SymbolsType::Symbolic,
|
||||
structs::NS_STYLE_COUNTER_SYSTEM_FIXED => SymbolsType::Fixed,
|
||||
x => panic!("Unexpected value for symbol type {}", x),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://drafts.csswg.org/css-counter-styles/#typedef-counter-style>
|
||||
///
|
||||
/// Note that 'none' is not a valid name.
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)]
|
||||
#[repr(u8)]
|
||||
pub enum CounterStyle {
|
||||
/// `<counter-style-name>`
|
||||
Name(CustomIdent),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue