Bug 1348606 - Use a threadsafe array for counters. r=xidorn

MozReview-Commit-ID: KgTgcD5mGqr
This commit is contained in:
Bobby Holley 2017-03-22 15:01:52 -07:00
parent 9d0b481789
commit e485365288
3 changed files with 356 additions and 108 deletions

View file

@ -6,7 +6,8 @@
use app_units::Au;
use gecko_bindings::bindings;
use gecko_bindings::structs::{nsCSSValue, nsCSSUnit, nsCSSValue_Array, nscolor};
use gecko_bindings::structs::{nsCSSValue, nsCSSUnit};
use gecko_bindings::structs::{nsCSSValue_Array, nsCSSValue_ThreadSafeArray, nscolor};
use std::mem;
use std::ops::{Index, IndexMut};
use std::slice;
@ -126,7 +127,9 @@ impl Drop for nsCSSValue {
}
}
impl nsCSSValue_Array {
macro_rules! decl_cssarray_sugar {
($name:ident) => {
impl $name {
/// Return the length of this `nsCSSValue::Array`
#[inline]
pub fn len(&self) -> usize {
@ -151,7 +154,7 @@ impl nsCSSValue_Array {
}
}
impl Index<usize> for nsCSSValue_Array {
impl Index<usize> for $name {
type Output = nsCSSValue;
#[inline]
fn index(&self, i: usize) -> &nsCSSValue {
@ -159,10 +162,14 @@ impl Index<usize> for nsCSSValue_Array {
}
}
impl IndexMut<usize> for nsCSSValue_Array {
impl IndexMut<usize> for $name {
#[inline]
fn index_mut(&mut self, i: usize) -> &mut nsCSSValue {
&mut self.as_mut_slice()[i]
}
}
}
}
decl_cssarray_sugar!(nsCSSValue_Array);
decl_cssarray_sugar!(nsCSSValue_ThreadSafeArray);