diff --git a/components/style/binding_tools/regen.py b/components/style/binding_tools/regen.py index c037bd5cc65..3c2fbccb8b0 100755 --- a/components/style/binding_tools/regen.py +++ b/components/style/binding_tools/regen.py @@ -319,6 +319,7 @@ COMPILATION_TARGETS = { "RawGeckoNode", "RawGeckoElement", "RawGeckoDocument", + "RawServoDeclarationBlockStrong", ], "whitelist_functions": [ "Servo_.*", diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 26288268ace..5eeea5b91e6 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -21,6 +21,8 @@ pub type RawGeckoElementBorrowed<'a> = &'a RawGeckoElement; pub type RawGeckoElementBorrowedOrNull<'a> = Option<&'a RawGeckoElement>; pub type RawGeckoDocumentBorrowed<'a> = &'a RawGeckoDocument; pub type RawGeckoDocumentBorrowedOrNull<'a> = Option<&'a RawGeckoDocument>; +pub type RawServoDeclarationBlockStrongBorrowed<'a> = &'a RawServoDeclarationBlockStrong; +pub type RawServoDeclarationBlockStrongBorrowedOrNull<'a> = Option<&'a RawServoDeclarationBlockStrong>; pub type RawServoStyleSetBorrowed<'a> = &'a RawServoStyleSet; pub type RawServoStyleSetBorrowedMut<'a> = &'a mut RawServoStyleSet; pub type RawServoStyleSetOwned = ::gecko_bindings::sugar::ownership::Owned; diff --git a/components/style/gecko_bindings/sugar/ownership.rs b/components/style/gecko_bindings/sugar/ownership.rs index bd3148366bb..4b5401f3eaf 100644 --- a/components/style/gecko_bindings/sugar/ownership.rs +++ b/components/style/gecko_bindings/sugar/ownership.rs @@ -161,6 +161,20 @@ impl Strong { } } + #[inline] + /// Given a reference to a strong FFI reference, + /// converts it to a reference to a servo-side Arc + /// Returns None on null. + /// + /// Strong -> Arc + pub fn as_arc_opt(&self) -> Option<&Arc> where U: HasArcFFI { + if self.is_null() { + None + } else { + unsafe { Some(transmute(self)) } + } + } + #[inline] /// Produces a null strong FFI reference pub fn null() -> Self {