mirror of
https://github.com/servo/servo.git
synced 2025-06-24 09:04:33 +01:00
Bug 1304792: Use borrowed types for ServoImportRule. r=Manishearth r=heycam
MozReview-Commit-ID: HKjsOaE2qAp Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
a5f5e48c68
commit
df9da705f5
3 changed files with 9 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -109,6 +109,12 @@ pub unsafe trait HasArcFFI : HasFFI {
|
|||
}
|
||||
}
|
||||
|
||||
fn arc_as_borrowed<'a>(arc: &'a Arc<Self>) -> &'a &Self::FFIType {
|
||||
unsafe {
|
||||
transmute::<&Arc<Self>, &&Self::FFIType>(arc)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn arc_from_borrowed<'a>(ptr: &'a Option<&Self::FFIType>) -> Option<&'a Arc<Self>> {
|
||||
unsafe {
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue