Convert between {Accumulate, Interpolate}Matrix and the related gecko type.

We convert ComputedOperation::{Accumulate, Interpolate}Matrix into gecko type
not on the main thread, so we cannot use nsCSSValueList_heap (which is not
thread safe so we cannot create it and destroy it on different threads).
Therefore, we use nsCSSValueSharedList to represent the cloned
from_list/to_list. In this patch, we also implement the reversing way,
i.e. Convert eCSSKeyword_{accumulate, interpolate}matrix into
{Accumulate, Interpolate}Matrix.
This commit is contained in:
Boris Chiou 2017-06-07 11:19:59 +08:00
parent 8a69132de0
commit 1a3845b719
3 changed files with 90 additions and 20 deletions

View file

@ -259,6 +259,21 @@ impl nsCSSValue {
}
debug_assert!(values.next().is_none(), "Values should have been exhausted");
}
/// Set a shared list
pub fn set_shared_list<I>(&mut self, values: I) where I: ExactSizeIterator<Item=nsCSSValue> {
debug_assert!(values.len() > 0, "Empty list is not supported");
unsafe { bindings::Gecko_CSSValue_InitSharedList(self, values.len() as u32) };
debug_assert_eq!(self.mUnit, nsCSSUnit::eCSSUnit_SharedList);
let list = unsafe {
self.mValue.mSharedList.as_ref()
.as_mut().expect("List pointer should be non-null").mHead.as_mut()
};
debug_assert!(list.is_some(), "New created shared list shouldn't be null");
for (item, new_value) in list.unwrap().into_iter().zip(values) {
*item = new_value;
}
}
}
impl Drop for nsCSSValue {