stylo: Use ServoBundledURI everywhere else, fix from_ffi to handle the error case

MozReview-Commit-ID: DHNKLm3y5Gv
This commit is contained in:
Manish Goregaokar 2017-03-12 21:08:29 -07:00 committed by Manish Goregaokar
parent 808ffffd1e
commit 77d7490d59
4 changed files with 41 additions and 62 deletions

View file

@ -150,6 +150,11 @@ impl SpecifiedUrl {
}
}
/// Check if it has a resolved URI
pub fn has_resolved(&self) -> bool {
self.resolved.is_some()
}
/// Creates an already specified url value from an already resolved URL
/// for insertion in the cascade.
pub fn for_cascade(url: ServoUrl, extra_data: UrlExtraData) -> Self {
@ -173,19 +178,20 @@ impl SpecifiedUrl {
/// Create a bundled URI suitable for sending to Gecko
/// to be constructed into a css::URLValue
#[cfg(feature = "gecko")]
pub fn for_ffi(&self) -> Option<ServoBundledURI> {
pub fn for_ffi(&self) -> ServoBundledURI {
let extra_data = self.extra_data();
let (ptr, len) = match self.as_slice_components() {
Ok(value) => value,
Err(_) => return None,
// we're okay with passing down the unresolved relative URI
Err(value) => value,
};
Some(ServoBundledURI {
ServoBundledURI {
mURLString: ptr,
mURLStringLength: len as u32,
mBaseURI: extra_data.base.get(),
mReferrer: extra_data.referrer.get(),
mPrincipal: extra_data.principal.get(),
})
}
}
}