diff --git a/components/style/gecko/arc_types.rs b/components/style/gecko/arc_types.rs index fc712422536..c72047183f2 100644 --- a/components/style/gecko/arc_types.rs +++ b/components/style/gecko/arc_types.rs @@ -17,7 +17,7 @@ use crate::gecko_bindings::structs::{ RawServoMozDocumentRule, RawServoNamespaceRule, RawServoPageRule, RawServoStyleRule, RawServoStyleSheetContents, RawServoSupportsRule, ServoCssRules, }; -use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong}; +use crate::gecko_bindings::sugar::ownership::{HasArcFFI, Strong}; use crate::media_queries::MediaList; use crate::properties::animated_properties::AnimationValue; use crate::properties::{ComputedValues, PropertyDeclarationBlock}; @@ -33,10 +33,9 @@ use std::{mem, ptr}; macro_rules! impl_arc_ffi { ($servo_type:ty => $gecko_type:ty[$addref:ident, $release:ident]) => { - unsafe impl HasFFI for $servo_type { + unsafe impl HasArcFFI for $servo_type { type FFIType = $gecko_type; } - unsafe impl HasArcFFI for $servo_type {} #[no_mangle] pub unsafe extern "C" fn $addref(obj: &$gecko_type) { diff --git a/components/style/gecko_bindings/sugar/ownership.rs b/components/style/gecko_bindings/sugar/ownership.rs index 2d0e9819b8c..bb9d2c87e6d 100644 --- a/components/style/gecko_bindings/sugar/ownership.rs +++ b/components/style/gecko_bindings/sugar/ownership.rs @@ -11,21 +11,18 @@ use std::mem::{forget, transmute}; use std::ops::{Deref, DerefMut}; use std::ptr; -/// Indicates that a given Servo type has a corresponding Gecko FFI type. -pub unsafe trait HasFFI: Sized + 'static { - /// The corresponding Gecko type that this rust type represents. - /// - /// See the examples in `components/style/gecko/conversions.rs`. - type FFIType: Sized; -} - /// Helper trait for conversions between FFI Strong/Borrowed types and Arcs /// /// Should be implemented by types which are passed over FFI as Arcs via Strong /// and Borrowed. /// /// In this case, the FFIType is the rough equivalent of ArcInner. -pub unsafe trait HasArcFFI: HasFFI { +pub unsafe trait HasArcFFI: Sized + 'static { + /// The corresponding Gecko type that this rust type represents. + /// + /// See the examples in `components/style/gecko/conversions.rs`. + type FFIType: Sized; + // these methods can't be on Borrowed because it leads to an unspecified // impl parameter /// Artificially increments the refcount of a (possibly null) borrowed Arc @@ -163,26 +160,21 @@ impl Strong { /// A few helpers implemented on top of Arc to make it more /// comfortable to use and write safe code with. -pub unsafe trait FFIArcHelpers { - /// The Rust FFI type that we're implementing methods for. - type Inner: HasArcFFI; - +pub unsafe trait FFIArcHelpers { /// Converts an Arc into a strong FFI reference. /// /// Arc -> Strong - fn into_strong(self) -> Strong<::FFIType>; + fn into_strong(self) -> Strong; /// Produces a borrowed FFI reference by borrowing an Arc. /// /// &Arc -> &GeckoType /// /// Then the `arc_as_borrowed` method can go away. - fn as_borrowed(&self) -> &::FFIType; + fn as_borrowed(&self) -> &T::FFIType; } -unsafe impl FFIArcHelpers for RawOffsetArc { - type Inner = T; - +unsafe impl FFIArcHelpers for RawOffsetArc { #[inline] fn into_strong(self) -> Strong { unsafe { transmute(self) } @@ -194,9 +186,7 @@ unsafe impl FFIArcHelpers for RawOffsetArc { } } -unsafe impl FFIArcHelpers for Arc { - type Inner = T; - +unsafe impl FFIArcHelpers for Arc { #[inline] fn into_strong(self) -> Strong { Arc::into_raw_offset(self).into_strong()