style: Copy less URLs on stylo.

Bug: 1442246
Reviewed-by: jdm
MozReview-Commit-ID: NmHue1mGDq
This commit is contained in:
Emilio Cobos Álvarez 2018-03-01 15:37:23 +01:00
parent 0c9be9f776
commit da94feb11a
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -81,7 +81,7 @@ impl SpecifiedUrl {
let image_value = image_request.mImageValue.mRawPtr.as_ref().unwrap(); let image_value = image_request.mImageValue.mRawPtr.as_ref().unwrap();
let ref url_value_data = image_value._base; let ref url_value_data = image_value._base;
let mut result = try!(Self::from_url_value_data(url_value_data)); let mut result = Self::from_url_value_data(url_value_data)?;
result.build_image_value(); result.build_image_value();
Ok(result) Ok(result)
} }
@ -108,10 +108,11 @@ impl SpecifiedUrl {
/// Create a bundled URI suitable for sending to Gecko /// Create a bundled URI suitable for sending to Gecko
/// to be constructed into a css::URLValue /// to be constructed into a css::URLValue
pub fn for_ffi(&self) -> ServoBundledURI { pub fn for_ffi(&self) -> ServoBundledURI {
let (ptr, len) = self.as_slice_components(); let arc_offset = Arc::into_raw_offset(self.serialization.clone());
ServoBundledURI { ServoBundledURI {
mURLString: ptr, mURLString: unsafe {
mURLStringLength: len as u32, mem::transmute::<_, RawOffsetArc<RustString>>(arc_offset)
},
mExtraData: self.extra_data.get(), mExtraData: self.extra_data.get(),
} }
} }
@ -123,10 +124,7 @@ impl SpecifiedUrl {
debug_assert_eq!(self.image_value, None); debug_assert_eq!(self.image_value, None);
self.image_value = { self.image_value = {
unsafe { unsafe {
let arc_offset = Arc::into_raw_offset(self.serialization.clone()); let ptr = Gecko_ImageValue_Create(self.for_ffi());
let ptr = Gecko_ImageValue_Create(
self.for_ffi(),
mem::transmute::<_, RawOffsetArc<RustString>>(arc_offset));
// We do not expect Gecko_ImageValue_Create returns null. // We do not expect Gecko_ImageValue_Create returns null.
debug_assert!(!ptr.is_null()); debug_assert!(!ptr.is_null());
Some(RefPtr::from_addrefed(ptr)) Some(RefPtr::from_addrefed(ptr))