diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 389df0e845f..77a2fb2712d 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -330,7 +330,7 @@ extern "C" { extern "C" { pub fn Gecko_LoadStyleSheet(loader: *mut Loader, parent: *mut ServoStyleSheet, - import_rule: RawServoImportRuleStrong, + import_rule: RawServoImportRuleBorrowed, url_bytes: *const u8, url_length: u32, media_bytes: *const u8, media_length: u32); } diff --git a/components/style/gecko_bindings/sugar/ownership.rs b/components/style/gecko_bindings/sugar/ownership.rs index 13562011fbb..edd8394f31c 100644 --- a/components/style/gecko_bindings/sugar/ownership.rs +++ b/components/style/gecko_bindings/sugar/ownership.rs @@ -109,6 +109,12 @@ pub unsafe trait HasArcFFI : HasFFI { } } + fn arc_as_borrowed<'a>(arc: &'a Arc) -> &'a &Self::FFIType { + unsafe { + transmute::<&Arc, &&Self::FFIType>(arc) + } + } + #[inline] fn arc_from_borrowed<'a>(ptr: &'a Option<&Self::FFIType>) -> Option<&'a Arc> { unsafe { diff --git a/ports/geckolib/stylesheet_loader.rs b/ports/geckolib/stylesheet_loader.rs index a48559d6857..3e6fb421c86 100644 --- a/ports/geckolib/stylesheet_loader.rs +++ b/ports/geckolib/stylesheet_loader.rs @@ -3,10 +3,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use parking_lot::RwLock; -use std::mem; use std::sync::Arc; use style::gecko_bindings::bindings::Gecko_LoadStyleSheet; use style::gecko_bindings::structs::{Loader, ServoStyleSheet}; +use style::gecko_bindings::sugar::ownership::HasArcFFI; use style::stylesheets::{ImportRule, StylesheetLoader as StyleStylesheetLoader}; use style_traits::ToCss; @@ -37,7 +37,7 @@ impl StyleStylesheetLoader for StylesheetLoader { unsafe { Gecko_LoadStyleSheet(self.0, self.1, - mem::transmute(import_rule.clone()), + HasArcFFI::arc_as_borrowed(import_rule), spec_bytes, spec_len as u32, media.as_bytes().as_ptr(),