summaryrefslogtreecommitdiffstats
path: root/servo/components/style/gecko
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--servo/components/style/gecko/arc_types.rs9
-rw-r--r--servo/components/style/gecko/wrapper.rs12
-rw-r--r--servo/components/style/gecko_bindings/sugar/mod.rs1
-rw-r--r--servo/components/style/gecko_bindings/sugar/ns_t_array.rs144
4 files changed, 13 insertions, 153 deletions
diff --git a/servo/components/style/gecko/arc_types.rs b/servo/components/style/gecko/arc_types.rs
index 420b86d332..259d9f1570 100644
--- a/servo/components/style/gecko/arc_types.rs
+++ b/servo/components/style/gecko/arc_types.rs
@@ -16,8 +16,8 @@ use crate::stylesheets::keyframes_rule::Keyframe;
use crate::stylesheets::{
ContainerRule, CounterStyleRule, CssRules, DocumentRule, FontFaceRule, FontFeatureValuesRule,
FontPaletteValuesRule, ImportRule, KeyframesRule, LayerBlockRule, LayerStatementRule,
- MediaRule, NamespaceRule, PageRule, PropertyRule, ScopeRule, StartingStyleRule, StyleRule,
- StylesheetContents, SupportsRule,
+ MarginRule, MediaRule, NamespaceRule, PageRule, PropertyRule, ScopeRule, StartingStyleRule,
+ StyleRule, StylesheetContents, SupportsRule,
};
use servo_arc::Arc;
@@ -101,6 +101,11 @@ impl_simple_arc_ffi!(
Servo_NamespaceRule_AddRef,
Servo_NamespaceRule_Release
);
+impl_simple_arc_ffi!(
+ MarginRule,
+ Servo_MarginRule_AddRef,
+ Servo_MarginRule_Release
+);
impl_locked_arc_ffi!(
PageRule,
LockedPageRule,
diff --git a/servo/components/style/gecko/wrapper.rs b/servo/components/style/gecko/wrapper.rs
index eab968149c..5e2d893b15 100644
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -577,14 +577,14 @@ pub enum GeckoChildrenIterator<'a> {
/// replaces it with the next sibling when requested.
Current(Option<GeckoNode<'a>>),
/// A Gecko-implemented iterator we need to drop appropriately.
- GeckoIterator(structs::StyleChildrenIterator),
+ GeckoIterator(std::mem::ManuallyDrop<structs::StyleChildrenIterator>),
}
impl<'a> Drop for GeckoChildrenIterator<'a> {
fn drop(&mut self) {
if let GeckoChildrenIterator::GeckoIterator(ref mut it) = *self {
unsafe {
- bindings::Gecko_DestroyStyleChildrenIterator(it);
+ bindings::Gecko_DestroyStyleChildrenIterator(&mut **it);
}
}
}
@@ -605,7 +605,7 @@ impl<'a> Iterator for GeckoChildrenIterator<'a> {
// however we can't express this easily with bindgen, and it would
// introduce functions with two input lifetimes into bindgen,
// which would be out of scope for elision.
- bindings::Gecko_GetNextStyleChild(&mut *(it as *mut _))
+ bindings::Gecko_GetNextStyleChild(&mut **it)
.as_ref()
.map(GeckoNode)
},
@@ -1015,9 +1015,9 @@ impl<'le> TElement for GeckoElement<'le> {
self.may_have_anonymous_children()
{
unsafe {
- let mut iter: structs::StyleChildrenIterator = ::std::mem::zeroed();
- bindings::Gecko_ConstructStyleChildrenIterator(self.0, &mut iter);
- return LayoutIterator(GeckoChildrenIterator::GeckoIterator(iter));
+ let mut iter = std::mem::MaybeUninit::<structs::StyleChildrenIterator>::uninit();
+ bindings::Gecko_ConstructStyleChildrenIterator(self.0, iter.as_mut_ptr());
+ return LayoutIterator(GeckoChildrenIterator::GeckoIterator(std::mem::ManuallyDrop::new(iter.assume_init())));
}
}
diff --git a/servo/components/style/gecko_bindings/sugar/mod.rs b/servo/components/style/gecko_bindings/sugar/mod.rs
index 00faf63ba6..e639abeda0 100644
--- a/servo/components/style/gecko_bindings/sugar/mod.rs
+++ b/servo/components/style/gecko_bindings/sugar/mod.rs
@@ -7,7 +7,6 @@
mod ns_com_ptr;
mod ns_compatibility;
mod ns_style_auto_array;
-mod ns_t_array;
pub mod origin_flags;
pub mod ownership;
pub mod refptr;
diff --git a/servo/components/style/gecko_bindings/sugar/ns_t_array.rs b/servo/components/style/gecko_bindings/sugar/ns_t_array.rs
deleted file mode 100644
index d10ed420dd..0000000000
--- a/servo/components/style/gecko_bindings/sugar/ns_t_array.rs
+++ /dev/null
@@ -1,144 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-
-//! Rust helpers for Gecko's nsTArray.
-
-use crate::gecko_bindings::bindings;
-use crate::gecko_bindings::structs::{nsTArray, nsTArrayHeader, CopyableTArray};
-use std::mem;
-use std::ops::{Deref, DerefMut};
-use std::slice;
-
-impl<T> Deref for nsTArray<T> {
- type Target = [T];
-
- #[inline]
- fn deref<'a>(&'a self) -> &'a [T] {
- unsafe { slice::from_raw_parts(self.slice_begin(), self.header().mLength as usize) }
- }
-}
-
-impl<T> DerefMut for nsTArray<T> {
- fn deref_mut<'a>(&'a mut self) -> &'a mut [T] {
- unsafe { slice::from_raw_parts_mut(self.slice_begin(), self.header().mLength as usize) }
- }
-}
-
-impl<T> nsTArray<T> {
- #[inline]
- fn header<'a>(&'a self) -> &'a nsTArrayHeader {
- debug_assert!(!self.mBuffer.is_null());
- unsafe { mem::transmute(self.mBuffer) }
- }
-
- // unsafe, since header may be in shared static or something
- unsafe fn header_mut<'a>(&'a mut self) -> &'a mut nsTArrayHeader {
- debug_assert!(!self.mBuffer.is_null());
-
- mem::transmute(self.mBuffer)
- }
-
- #[inline]
- unsafe fn slice_begin(&self) -> *mut T {
- debug_assert!(!self.mBuffer.is_null());
- (self.mBuffer as *const nsTArrayHeader).offset(1) as *mut _
- }
-
- /// Ensures the array has enough capacity at least to hold `cap` elements.
- ///
- /// NOTE: This doesn't call the constructor on the values!
- pub fn ensure_capacity(&mut self, cap: usize) {
- if cap >= self.len() {
- unsafe {
- bindings::Gecko_EnsureTArrayCapacity(
- self as *mut nsTArray<T> as *mut _,
- cap,
- mem::size_of::<T>(),
- )
- }
- }
- }
-
- /// Clears the array storage without calling the destructor on the values.
- #[inline]
- pub unsafe fn clear(&mut self) {
- if self.len() != 0 {
- bindings::Gecko_ClearPODTArray(
- self as *mut nsTArray<T> as *mut _,
- mem::size_of::<T>(),
- mem::align_of::<T>(),
- );
- }
- }
-
- /// Clears a POD array. This is safe since copy types are memcopyable.
- #[inline]
- pub fn clear_pod(&mut self)
- where
- T: Copy,
- {
- unsafe { self.clear() }
- }
-
- /// Resize and set the length of the array to `len`.
- ///
- /// unsafe because this may leave the array with uninitialized elements.
- ///
- /// This will not call constructors. If you need that, either manually add
- /// bindings or run the typed `EnsureCapacity` call on the gecko side.
- pub unsafe fn set_len(&mut self, len: u32) {
- // this can leak
- debug_assert!(len >= self.len() as u32);
- if self.len() == len as usize {
- return;
- }
- self.ensure_capacity(len as usize);
- self.header_mut().mLength = len;
- }
-
- /// Resizes an array containing only POD elements
- ///
- /// unsafe because this may leave the array with uninitialized elements.
- ///
- /// This will not leak since it only works on POD types (and thus doesn't assert)
- pub unsafe fn set_len_pod(&mut self, len: u32)
- where
- T: Copy,
- {
- if self.len() == len as usize {
- return;
- }
- self.ensure_capacity(len as usize);
- let header = self.header_mut();
- header.mLength = len;
- }
-
- /// Collects the given iterator into this array.
- ///
- /// Not unsafe because we won't leave uninitialized elements in the array.
- pub fn assign_from_iter_pod<I>(&mut self, iter: I)
- where
- T: Copy,
- I: ExactSizeIterator + Iterator<Item = T>,
- {
- debug_assert!(iter.len() <= 0xFFFFFFFF);
- unsafe {
- self.set_len_pod(iter.len() as u32);
- }
- self.iter_mut().zip(iter).for_each(|(r, v)| *r = v);
- }
-}
-
-impl<T> Deref for CopyableTArray<T> {
- type Target = nsTArray<T>;
- fn deref(&self) -> &Self::Target {
- &self._base
- }
-}
-
-impl<T> DerefMut for CopyableTArray<T> {
- fn deref_mut(&mut self) -> &mut nsTArray<T> {
- &mut self._base
- }
-}