ensure_len() for nsStyleAutoArray<StyleTransition>.

This commit is contained in:
Hiroyuki Ikezoe 2017-03-03 08:15:52 +09:00
parent e5386ed7aa
commit 96dbc9849d
2 changed files with 19 additions and 2 deletions

View file

@ -678,6 +678,11 @@ extern "C" {
*mut ::std::os::raw::c_void, *mut ::std::os::raw::c_void,
len: usize); len: usize);
} }
extern "C" {
pub fn Gecko_EnsureStyleTransitionArrayLength(array:
*mut ::std::os::raw::c_void,
len: usize);
}
extern "C" { extern "C" {
pub fn Gecko_AnimationAppendKeyframe(keyframes: pub fn Gecko_AnimationAppendKeyframe(keyframes:
RawGeckoKeyframeListBorrowedMut, RawGeckoKeyframeListBorrowedMut,

View file

@ -5,6 +5,8 @@
//! Rust helpers for Gecko's `nsStyleAutoArray`. //! Rust helpers for Gecko's `nsStyleAutoArray`.
use gecko_bindings::bindings::Gecko_EnsureStyleAnimationArrayLength; use gecko_bindings::bindings::Gecko_EnsureStyleAnimationArrayLength;
use gecko_bindings::bindings::Gecko_EnsureStyleTransitionArrayLength;
use gecko_bindings::structs::{StyleAnimation, StyleTransition};
use gecko_bindings::structs::nsStyleAutoArray; use gecko_bindings::structs::nsStyleAutoArray;
use std::iter::{once, Chain, Once, IntoIterator}; use std::iter::{once, Chain, Once, IntoIterator};
use std::ops::{Index, IndexMut}; use std::ops::{Index, IndexMut};
@ -53,12 +55,22 @@ impl<T> nsStyleAutoArray<T> {
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
1 + self.mOtherElements.len() 1 + self.mOtherElements.len()
} }
}
impl nsStyleAutoArray<StyleAnimation> {
/// Ensures that the array has length at least the given length. /// Ensures that the array has length at least the given length.
pub fn ensure_len(&mut self, len: usize) { pub fn ensure_len(&mut self, len: usize) {
unsafe { unsafe {
Gecko_EnsureStyleAnimationArrayLength(self as *mut nsStyleAutoArray<T> as *mut _, Gecko_EnsureStyleAnimationArrayLength(self as *mut nsStyleAutoArray<StyleAnimation> as *mut _, len);
len); }
}
}
impl nsStyleAutoArray<StyleTransition> {
/// Ensures that the array has length at least the given length.
pub fn ensure_len(&mut self, len: usize) {
unsafe {
Gecko_EnsureStyleTransitionArrayLength(self as *mut nsStyleAutoArray<StyleTransition> as *mut _, len);
} }
} }
} }