mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
stylo: Add ServoBundledURI abstraction for use when setting css::URLValues
MozReview-Commit-ID: 4QKKzJ1DVYP
This commit is contained in:
parent
47ebeaa95c
commit
e965b4e345
6 changed files with 63 additions and 29 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
use cssparser::{CssStringWriter, Parser};
|
||||
#[cfg(feature = "gecko")]
|
||||
use gecko_bindings::structs::ServoBundledURI;
|
||||
#[cfg(feature = "gecko")]
|
||||
use gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||
use parser::{Parse, ParserContext};
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -167,6 +169,25 @@ impl SpecifiedUrl {
|
|||
extra_data: UrlExtraData {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a bundled URI suitable for sending to Gecko
|
||||
/// to be constructed into a css::URLValue
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn for_ffi(&self) -> ServoBundledURI {
|
||||
use std::ptr;
|
||||
let extra_data = self.extra_data();
|
||||
let (ptr, len) = match self.as_slice_components() {
|
||||
Ok(value) => value,
|
||||
Err(_) => (ptr::null(), 0),
|
||||
};
|
||||
ServoBundledURI {
|
||||
mURLString: ptr,
|
||||
mURLStringLength: len as u32,
|
||||
mBaseURI: extra_data.base.get(),
|
||||
mReferrer: extra_data.referrer.get(),
|
||||
mPrincipal: extra_data.principal.get(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for SpecifiedUrl {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue