diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index 68036f26e89..52ee3dfd615 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -967,6 +967,31 @@ extern "C" { pub fn Gecko_CopyCounterStyle(dst: *mut CounterStylePtr, src: *const CounterStylePtr); } +extern "C" { + pub fn Gecko_CounterStyle_IsNone(ptr: *const CounterStylePtr) -> bool; +} +extern "C" { + pub fn Gecko_CounterStyle_IsName(ptr: *const CounterStylePtr) -> bool; +} +extern "C" { + pub fn Gecko_CounterStyle_GetName(ptr: *const CounterStylePtr, + result: *mut nsAString); +} +extern "C" { + pub fn Gecko_CounterStyle_GetSymbols(ptr: *const CounterStylePtr) + -> *const nsTArray; +} +extern "C" { + pub fn Gecko_CounterStyle_GetSystem(ptr: *const CounterStylePtr) -> u8; +} +extern "C" { + pub fn Gecko_CounterStyle_IsSingleString(ptr: *const CounterStylePtr) + -> bool; +} +extern "C" { + pub fn Gecko_CounterStyle_GetSingleString(ptr: *const CounterStylePtr, + result: *mut nsAString); +} extern "C" { pub fn Gecko_SetNullImageValue(image: *mut nsStyleImage); } @@ -1865,9 +1890,6 @@ extern "C" { extern "C" { pub fn Gecko_Destroy_nsStyleEffects(ptr: *mut nsStyleEffects); } -extern "C" { - pub fn Gecko_Construct_nsStyleVariables(ptr: *mut nsStyleVariables); -} extern "C" { pub fn Gecko_RegisterProfilerThread(name: *const ::std::os::raw::c_char); } diff --git a/components/style/gecko/values.rs b/components/style/gecko/values.rs index 9d961ee18c3..69d13c49f4c 100644 --- a/components/style/gecko/values.rs +++ b/components/style/gecko/values.rs @@ -477,4 +477,34 @@ impl CounterStyleOrNone { } } } + + /// Convert Gecko CounterStylePtr to CounterStyleOrNone. + pub fn from_gecko_value(gecko_value: &CounterStylePtr) -> Self { + use counter_style::{Symbol, Symbols}; + use gecko_bindings::bindings::Gecko_CounterStyle_GetName; + use gecko_bindings::bindings::Gecko_CounterStyle_GetSymbols; + use gecko_bindings::bindings::Gecko_CounterStyle_GetSystem; + use gecko_bindings::bindings::Gecko_CounterStyle_IsName; + use gecko_bindings::bindings::Gecko_CounterStyle_IsNone; + use values::CustomIdent; + use values::generics::SymbolsType; + + if unsafe { Gecko_CounterStyle_IsNone(gecko_value) } { + CounterStyleOrNone::None + } else if unsafe { Gecko_CounterStyle_IsName(gecko_value) } { + ns_auto_string!(name); + unsafe { Gecko_CounterStyle_GetName(gecko_value, &mut *name) }; + CounterStyleOrNone::Name(CustomIdent((&*name).into())) + } else { + let system = unsafe { Gecko_CounterStyle_GetSystem(gecko_value) }; + let symbol_type = SymbolsType::from_gecko_keyword(system as u32); + let symbols = unsafe { + let ref gecko_symbols = *Gecko_CounterStyle_GetSymbols(gecko_value); + gecko_symbols.iter().map(|gecko_symbol| { + Symbol::String(gecko_symbol.to_string()) + }).collect() + }; + CounterStyleOrNone::Symbols(symbol_type, Symbols(symbols)) + } + } } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index ce8861cc5a9..68500b3ca50 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -4149,6 +4149,23 @@ fn static_assert() { self.copy_list_style_type_from(other) } + pub fn clone_list_style_type(&self) -> longhands::list_style_type::computed_value::T { + use gecko_bindings::bindings::Gecko_CounterStyle_IsSingleString; + use gecko_bindings::bindings::Gecko_CounterStyle_GetSingleString; + use self::longhands::list_style_type::computed_value::T; + use values::generics::CounterStyleOrNone; + + if unsafe { Gecko_CounterStyle_IsSingleString(&self.gecko.mCounterStyle) } { + ns_auto_string!(single_string); + unsafe { + Gecko_CounterStyle_GetSingleString(&self.gecko.mCounterStyle, &mut *single_string) + }; + T::String(single_string.to_string()) + } else { + T::CounterStyle(CounterStyleOrNone::from_gecko_value(&self.gecko.mCounterStyle)) + } + } + pub fn set_quotes(&mut self, other: longhands::quotes::computed_value::T) { use gecko_bindings::bindings::Gecko_NewStyleQuoteValues; use gecko_bindings::sugar::refptr::UniqueRefPtr; diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index b993824ad4e..3780fa0c400 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/components/style/properties/longhand/list.mako.rs @@ -27,8 +27,7 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu arabic-indic bengali cambodian cjk-decimal devanagari gujarati gurmukhi kannada khmer lao malayalam mongolian myanmar oriya persian telugu thai tibetan cjk-earthly-branch cjk-heavenly-stem lower-greek hiragana hiragana-iroha katakana katakana-iroha""", - needs_conversion="True", - animation_value_type="none", + animation_value_type="discrete", spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type")} % else: <%helpers:longhand name="list-style-type" animation_value_type="none" boxed="True" diff --git a/components/style/values/generics/mod.rs b/components/style/values/generics/mod.rs index f87b7a88de5..075ce2c4715 100644 --- a/components/style/values/generics/mod.rs +++ b/components/style/values/generics/mod.rs @@ -50,6 +50,19 @@ impl SymbolsType { 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 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