Auto merge of #17985 - dadaa:make-list-style-type-animatable, r=hiro

Make list-style-type animatable

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [X] There are tests for these changes. The test is patch 3 in https://bugzilla.mozilla.org/show_bug.cgi?id=1382137

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17985)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-08-07 19:06:43 -05:00 committed by GitHub
commit 10c3e2f3ac
5 changed files with 86 additions and 5 deletions

View file

@ -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<nsStringRepr>;
}
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);
}

View file

@ -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))
}
}
}