mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #18516 - jdm:stringshare, r=heycam
Share specified URLs with Gecko This makes use of our Arc offset machinery to allow Gecko to store Arc<String> values and ensure there are used appropriately. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix [bug 1397971](https://bugzilla.mozilla.org/show_bug.cgi?id=1397971). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18516) <!-- Reviewable:end -->
This commit is contained in:
commit
70a6b2fa91
5 changed files with 173 additions and 38 deletions
|
@ -19,6 +19,7 @@ use gecko_bindings::structs::mozilla::MallocSizeOf;
|
|||
use gecko_bindings::structs::mozilla::OriginFlags;
|
||||
use gecko_bindings::structs::mozilla::Side;
|
||||
use gecko_bindings::structs::mozilla::UniquePtr;
|
||||
use gecko_bindings::structs::ServoRawOffsetArc;
|
||||
use gecko_bindings::structs::nsIContent;
|
||||
use gecko_bindings::structs::nsIDocument;
|
||||
use gecko_bindings::structs::nsIDocument_DocumentTheme;
|
||||
|
@ -46,6 +47,7 @@ use gecko_bindings::structs::RawGeckoServoStyleRuleList;
|
|||
use gecko_bindings::structs::RawGeckoURLExtraData;
|
||||
use gecko_bindings::structs::RawGeckoXBLBinding;
|
||||
use gecko_bindings::structs::RefPtr;
|
||||
use gecko_bindings::structs::RustString;
|
||||
use gecko_bindings::structs::CSSPseudoClassType;
|
||||
use gecko_bindings::structs::CSSPseudoElementType;
|
||||
use gecko_bindings::structs::ServoTraversalFlags;
|
||||
|
@ -998,7 +1000,9 @@ extern "C" {
|
|||
pub fn Gecko_ReleaseImageValueArbitraryThread(aPtr: *mut ImageValue);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ImageValue_Create(aURI: ServoBundledURI) -> *mut ImageValue;
|
||||
pub fn Gecko_ImageValue_Create(aURI: ServoBundledURI,
|
||||
aURIString: ServoRawOffsetArc<RustString>)
|
||||
-> *mut ImageValue;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ImageValue_SizeOfIncludingThis(aImageValue: *mut ImageValue)
|
||||
|
|
|
@ -1727,17 +1727,52 @@ pub mod root {
|
|||
pub vtable_: *const URLValueData__bindgen_vtable,
|
||||
pub mRefCnt: root::mozilla::ThreadSafeAutoRefCnt,
|
||||
pub mURI: root::nsMainThreadPtrHandle<root::nsIURI>,
|
||||
pub mString: ::nsstring::nsStringRepr,
|
||||
pub mExtraData: root::RefPtr<root::mozilla::URLExtraData>,
|
||||
pub mURIResolved: bool,
|
||||
pub mIsLocalRef: [u8; 2usize],
|
||||
pub mMightHaveRef: [u8; 2usize],
|
||||
pub mStrings: root::mozilla::css::URLValueData_RustOrGeckoString,
|
||||
pub mUsingRustString: bool,
|
||||
}
|
||||
pub type URLValueData_HasThreadSafeRefCnt =
|
||||
root::mozilla::TrueType;
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct URLValueData_RustOrGeckoString {
|
||||
pub mString: root::__BindgenUnionField<::nsstring::nsStringRepr>,
|
||||
pub mRustString: root::__BindgenUnionField<::gecko_bindings::structs::ServoRawOffsetArc<root::RustString>>,
|
||||
pub bindgen_union_field: [u64; 2usize],
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_URLValueData_RustOrGeckoString() {
|
||||
assert_eq!(::std::mem::size_of::<URLValueData_RustOrGeckoString>()
|
||||
, 16usize , concat ! (
|
||||
"Size of: " , stringify ! (
|
||||
URLValueData_RustOrGeckoString ) ));
|
||||
assert_eq! (::std::mem::align_of::<URLValueData_RustOrGeckoString>()
|
||||
, 8usize , concat ! (
|
||||
"Alignment of " , stringify ! (
|
||||
URLValueData_RustOrGeckoString ) ));
|
||||
assert_eq! (unsafe {
|
||||
& (
|
||||
* ( 0 as * const URLValueData_RustOrGeckoString )
|
||||
) . mString as * const _ as usize } , 0usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData_RustOrGeckoString ) , "::" ,
|
||||
stringify ! ( mString ) ));
|
||||
assert_eq! (unsafe {
|
||||
& (
|
||||
* ( 0 as * const URLValueData_RustOrGeckoString )
|
||||
) . mRustString as * const _ as usize } , 0usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData_RustOrGeckoString ) , "::" ,
|
||||
stringify ! ( mRustString ) ));
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_URLValueData() {
|
||||
assert_eq!(::std::mem::size_of::<URLValueData>() , 56usize ,
|
||||
assert_eq!(::std::mem::size_of::<URLValueData>() , 64usize ,
|
||||
concat ! (
|
||||
"Size of: " , stringify ! ( URLValueData ) ));
|
||||
assert_eq! (::std::mem::align_of::<URLValueData>() , 8usize ,
|
||||
|
@ -1754,39 +1789,46 @@ pub mod root {
|
|||
const _ as usize } , 16usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! ( mURI ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) . mString as
|
||||
* const _ as usize } , 24usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! ( mString )
|
||||
));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) . mExtraData
|
||||
as * const _ as usize } , 40usize , concat ! (
|
||||
as * const _ as usize } , 24usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! ( mExtraData )
|
||||
));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) .
|
||||
mURIResolved as * const _ as usize } , 48usize ,
|
||||
mURIResolved as * const _ as usize } , 32usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! ( mURIResolved
|
||||
) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) .
|
||||
mIsLocalRef as * const _ as usize } , 49usize ,
|
||||
mIsLocalRef as * const _ as usize } , 33usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! ( mIsLocalRef
|
||||
) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) .
|
||||
mMightHaveRef as * const _ as usize } , 51usize ,
|
||||
mMightHaveRef as * const _ as usize } , 35usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! (
|
||||
mMightHaveRef ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) . mStrings
|
||||
as * const _ as usize } , 40usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! ( mStrings )
|
||||
));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) .
|
||||
mUsingRustString as * const _ as usize } , 56usize
|
||||
, concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! (
|
||||
mUsingRustString ) ));
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
|
@ -1795,7 +1837,7 @@ pub mod root {
|
|||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_URLValue() {
|
||||
assert_eq!(::std::mem::size_of::<URLValue>() , 56usize ,
|
||||
assert_eq!(::std::mem::size_of::<URLValue>() , 64usize ,
|
||||
concat ! ( "Size of: " , stringify ! ( URLValue )
|
||||
));
|
||||
assert_eq! (::std::mem::align_of::<URLValue>() , 8usize ,
|
||||
|
@ -1811,7 +1853,7 @@ pub mod root {
|
|||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_ImageValue() {
|
||||
assert_eq!(::std::mem::size_of::<ImageValue>() , 112usize ,
|
||||
assert_eq!(::std::mem::size_of::<ImageValue>() , 120usize ,
|
||||
concat ! ( "Size of: " , stringify ! ( ImageValue )
|
||||
));
|
||||
assert_eq! (::std::mem::align_of::<ImageValue>() , 8usize ,
|
||||
|
@ -1819,12 +1861,12 @@ pub mod root {
|
|||
"Alignment of " , stringify ! ( ImageValue ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ImageValue ) ) . mRequests as
|
||||
* const _ as usize } , 56usize , concat ! (
|
||||
* const _ as usize } , 64usize , concat ! (
|
||||
"Alignment of field: " , stringify ! ( ImageValue
|
||||
) , "::" , stringify ! ( mRequests ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ImageValue ) ) . mLoadedImage
|
||||
as * const _ as usize } , 104usize , concat ! (
|
||||
as * const _ as usize } , 112usize , concat ! (
|
||||
"Alignment of field: " , stringify ! ( ImageValue
|
||||
) , "::" , stringify ! ( mLoadedImage ) ));
|
||||
}
|
||||
|
@ -28801,6 +28843,11 @@ pub mod root {
|
|||
} | ((mHadDispatch as u8 as u8) << 6usize) & (64u64 as u8))
|
||||
}
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct RustString {
|
||||
_unused: [u8; 0],
|
||||
}
|
||||
#[repr(u32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum nsCSSUnit {
|
||||
|
|
|
@ -1691,17 +1691,52 @@ pub mod root {
|
|||
pub vtable_: *const URLValueData__bindgen_vtable,
|
||||
pub mRefCnt: root::mozilla::ThreadSafeAutoRefCnt,
|
||||
pub mURI: root::nsMainThreadPtrHandle<root::nsIURI>,
|
||||
pub mString: ::nsstring::nsStringRepr,
|
||||
pub mExtraData: root::RefPtr<root::mozilla::URLExtraData>,
|
||||
pub mURIResolved: bool,
|
||||
pub mIsLocalRef: [u8; 2usize],
|
||||
pub mMightHaveRef: [u8; 2usize],
|
||||
pub mStrings: root::mozilla::css::URLValueData_RustOrGeckoString,
|
||||
pub mUsingRustString: bool,
|
||||
}
|
||||
pub type URLValueData_HasThreadSafeRefCnt =
|
||||
root::mozilla::TrueType;
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct URLValueData_RustOrGeckoString {
|
||||
pub mString: root::__BindgenUnionField<::nsstring::nsStringRepr>,
|
||||
pub mRustString: root::__BindgenUnionField<::gecko_bindings::structs::ServoRawOffsetArc<root::RustString>>,
|
||||
pub bindgen_union_field: [u64; 2usize],
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_URLValueData_RustOrGeckoString() {
|
||||
assert_eq!(::std::mem::size_of::<URLValueData_RustOrGeckoString>()
|
||||
, 16usize , concat ! (
|
||||
"Size of: " , stringify ! (
|
||||
URLValueData_RustOrGeckoString ) ));
|
||||
assert_eq! (::std::mem::align_of::<URLValueData_RustOrGeckoString>()
|
||||
, 8usize , concat ! (
|
||||
"Alignment of " , stringify ! (
|
||||
URLValueData_RustOrGeckoString ) ));
|
||||
assert_eq! (unsafe {
|
||||
& (
|
||||
* ( 0 as * const URLValueData_RustOrGeckoString )
|
||||
) . mString as * const _ as usize } , 0usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData_RustOrGeckoString ) , "::" ,
|
||||
stringify ! ( mString ) ));
|
||||
assert_eq! (unsafe {
|
||||
& (
|
||||
* ( 0 as * const URLValueData_RustOrGeckoString )
|
||||
) . mRustString as * const _ as usize } , 0usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData_RustOrGeckoString ) , "::" ,
|
||||
stringify ! ( mRustString ) ));
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_URLValueData() {
|
||||
assert_eq!(::std::mem::size_of::<URLValueData>() , 56usize ,
|
||||
assert_eq!(::std::mem::size_of::<URLValueData>() , 64usize ,
|
||||
concat ! (
|
||||
"Size of: " , stringify ! ( URLValueData ) ));
|
||||
assert_eq! (::std::mem::align_of::<URLValueData>() , 8usize ,
|
||||
|
@ -1718,39 +1753,46 @@ pub mod root {
|
|||
const _ as usize } , 16usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! ( mURI ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) . mString as
|
||||
* const _ as usize } , 24usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! ( mString )
|
||||
));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) . mExtraData
|
||||
as * const _ as usize } , 40usize , concat ! (
|
||||
as * const _ as usize } , 24usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! ( mExtraData )
|
||||
));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) .
|
||||
mURIResolved as * const _ as usize } , 48usize ,
|
||||
mURIResolved as * const _ as usize } , 32usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! ( mURIResolved
|
||||
) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) .
|
||||
mIsLocalRef as * const _ as usize } , 49usize ,
|
||||
mIsLocalRef as * const _ as usize } , 33usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! ( mIsLocalRef
|
||||
) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) .
|
||||
mMightHaveRef as * const _ as usize } , 51usize ,
|
||||
mMightHaveRef as * const _ as usize } , 35usize ,
|
||||
concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! (
|
||||
mMightHaveRef ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) . mStrings
|
||||
as * const _ as usize } , 40usize , concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! ( mStrings )
|
||||
));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const URLValueData ) ) .
|
||||
mUsingRustString as * const _ as usize } , 56usize
|
||||
, concat ! (
|
||||
"Alignment of field: " , stringify ! (
|
||||
URLValueData ) , "::" , stringify ! (
|
||||
mUsingRustString ) ));
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
|
@ -1759,7 +1801,7 @@ pub mod root {
|
|||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_URLValue() {
|
||||
assert_eq!(::std::mem::size_of::<URLValue>() , 56usize ,
|
||||
assert_eq!(::std::mem::size_of::<URLValue>() , 64usize ,
|
||||
concat ! ( "Size of: " , stringify ! ( URLValue )
|
||||
));
|
||||
assert_eq! (::std::mem::align_of::<URLValue>() , 8usize ,
|
||||
|
@ -1775,7 +1817,7 @@ pub mod root {
|
|||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_ImageValue() {
|
||||
assert_eq!(::std::mem::size_of::<ImageValue>() , 104usize ,
|
||||
assert_eq!(::std::mem::size_of::<ImageValue>() , 112usize ,
|
||||
concat ! ( "Size of: " , stringify ! ( ImageValue )
|
||||
));
|
||||
assert_eq! (::std::mem::align_of::<ImageValue>() , 8usize ,
|
||||
|
@ -1783,12 +1825,12 @@ pub mod root {
|
|||
"Alignment of " , stringify ! ( ImageValue ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ImageValue ) ) . mRequests as
|
||||
* const _ as usize } , 56usize , concat ! (
|
||||
* const _ as usize } , 64usize , concat ! (
|
||||
"Alignment of field: " , stringify ! ( ImageValue
|
||||
) , "::" , stringify ! ( mRequests ) ));
|
||||
assert_eq! (unsafe {
|
||||
& ( * ( 0 as * const ImageValue ) ) . mLoadedImage
|
||||
as * const _ as usize } , 96usize , concat ! (
|
||||
as * const _ as usize } , 104usize , concat ! (
|
||||
"Alignment of field: " , stringify ! ( ImageValue
|
||||
) , "::" , stringify ! ( mLoadedImage ) ));
|
||||
}
|
||||
|
@ -28446,6 +28488,11 @@ pub mod root {
|
|||
} | ((mHadDispatch as u8 as u8) << 6usize) & (64u64 as u8))
|
||||
}
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct RustString {
|
||||
_unused: [u8; 0],
|
||||
}
|
||||
#[repr(u32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum nsCSSUnit {
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
|
||||
use gecko_bindings::structs::{ServoBundledURI, URLExtraData};
|
||||
use gecko_bindings::structs::mozilla::css::URLValueData;
|
||||
use gecko_bindings::structs::root::{nsStyleImageRequest, RustString};
|
||||
use gecko_bindings::structs::root::mozilla::css::ImageValue;
|
||||
use gecko_bindings::structs::root::nsStyleImageRequest;
|
||||
use gecko_bindings::sugar::refptr::RefPtr;
|
||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
use parser::ParserContext;
|
||||
use servo_arc::Arc;
|
||||
use servo_arc::{Arc, RawOffsetArc};
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use style_traits::{ToCss, ParseError};
|
||||
|
||||
/// A specified url() value for gecko. Gecko does not eagerly resolve SpecifiedUrls.
|
||||
|
@ -59,7 +60,14 @@ impl SpecifiedUrl {
|
|||
pub unsafe fn from_url_value_data(url: &URLValueData)
|
||||
-> Result<SpecifiedUrl, ()> {
|
||||
Ok(SpecifiedUrl {
|
||||
serialization: Arc::new(url.mString.to_string()),
|
||||
serialization: if url.mUsingRustString {
|
||||
let arc_type = url.mStrings.mRustString.as_ref()
|
||||
as *const _ as
|
||||
*const RawOffsetArc<String>;
|
||||
Arc::from_raw_offset((*arc_type).clone())
|
||||
} else {
|
||||
Arc::new(url.mStrings.mString.as_ref().to_string())
|
||||
},
|
||||
extra_data: url.mExtraData.to_safe(),
|
||||
image_value: None,
|
||||
})
|
||||
|
@ -115,7 +123,10 @@ impl SpecifiedUrl {
|
|||
debug_assert_eq!(self.image_value, None);
|
||||
self.image_value = {
|
||||
unsafe {
|
||||
let ptr = Gecko_ImageValue_Create(self.for_ffi());
|
||||
let arc_offset = Arc::into_raw_offset(self.serialization.clone());
|
||||
let ptr = Gecko_ImageValue_Create(
|
||||
self.for_ffi(),
|
||||
mem::transmute::<_, RawOffsetArc<RustString>>(arc_offset));
|
||||
// We do not expect Gecko_ImageValue_Create returns null.
|
||||
debug_assert!(!ptr.is_null());
|
||||
Some(RefPtr::from_addrefed(ptr))
|
||||
|
|
|
@ -13,6 +13,7 @@ use std::cell::RefCell;
|
|||
use std::env;
|
||||
use std::fmt::Write;
|
||||
use std::iter;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use style::applicable_declarations::ApplicableDeclarationBlock;
|
||||
use style::context::{CascadeInputs, QuirksMode, SharedStyleContext, StyleContext};
|
||||
|
@ -77,7 +78,7 @@ use style::gecko_bindings::bindings::nsTimingFunctionBorrowedMut;
|
|||
use style::gecko_bindings::structs;
|
||||
use style::gecko_bindings::structs::{CSSPseudoElementType, CompositeOperation};
|
||||
use style::gecko_bindings::structs::{Loader, LoaderReusableStyleSheets};
|
||||
use style::gecko_bindings::structs::{RawServoStyleRule, ServoStyleContextStrong};
|
||||
use style::gecko_bindings::structs::{RawServoStyleRule, ServoStyleContextStrong, RustString};
|
||||
use style::gecko_bindings::structs::{ServoStyleSheet, SheetParsingMode, nsIAtom, nsCSSPropertyID};
|
||||
use style::gecko_bindings::structs::{nsCSSFontFaceRule, nsCSSCounterStyleRule};
|
||||
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair};
|
||||
|
@ -3834,6 +3835,31 @@ pub extern "C" fn Servo_GetCustomPropertyNameAt(computed_values: ServoStyleConte
|
|||
true
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_ReleaseArcStringData(string: *const RawOffsetArc<RustString>) {
|
||||
let string = string as *const RawOffsetArc<String>;
|
||||
// Cause RawOffsetArc::drop to run, releasing the strong reference to the string data.
|
||||
let _ = ptr::read(string);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_CloneArcStringData(string: *const RawOffsetArc<RustString>)
|
||||
-> RawOffsetArc<RustString> {
|
||||
let string = string as *const RawOffsetArc<String>;
|
||||
let cloned = (*string).clone();
|
||||
mem::transmute::<_, RawOffsetArc<RustString>>(cloned)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_GetArcStringData(string: *const RustString,
|
||||
utf8_chars: *mut *const u8,
|
||||
utf8_len: *mut u32)
|
||||
{
|
||||
let string = &*(string as *const String);
|
||||
*utf8_len = string.len() as u32;
|
||||
*utf8_chars = string.as_ptr();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ProcessInvalidations(set: RawServoStyleSetBorrowed,
|
||||
element: RawGeckoElementBorrowed,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue