Add function which convert from URLValueData to SpecifiedUrl.

We will need to convert from URLValueData to SpecifiedUrl when cloning the
stylo's data from gecko's data. Because the filter structure on gecko has url as
URLValue type. We will use this convert function when interpolating as
discrete also(Bug 1368610).
This commit is contained in:
Mantaroh Yoshinaga 2017-06-13 10:42:14 +09:00
parent ccf08bcead
commit 0ca9a01be4

View file

@ -5,6 +5,7 @@
//! Common handling for the specified value CSS url() values. //! Common handling for the specified value CSS url() values.
use gecko_bindings::structs::{ServoBundledURI, URLExtraData}; use gecko_bindings::structs::{ServoBundledURI, URLExtraData};
use gecko_bindings::structs::mozilla::css::URLValueData;
use gecko_bindings::structs::root::mozilla::css::ImageValue; use gecko_bindings::structs::root::mozilla::css::ImageValue;
use gecko_bindings::sugar::refptr::RefPtr; use gecko_bindings::sugar::refptr::RefPtr;
use parser::ParserContext; use parser::ParserContext;
@ -51,6 +52,16 @@ impl SpecifiedUrl {
false false
} }
/// Convert from URLValueData to SpecifiedUrl.
pub unsafe fn from_url_value_data(url: &URLValueData)
-> Result<SpecifiedUrl, ()> {
Ok(SpecifiedUrl {
serialization: Arc::new(url.mString.to_string()),
extra_data: url.mExtraData.to_safe(),
image_value: None,
})
}
/// Returns true if this URL looks like a fragment. /// Returns true if this URL looks like a fragment.
/// See https://drafts.csswg.org/css-values/#local-urls /// See https://drafts.csswg.org/css-values/#local-urls
pub fn is_fragment(&self) -> bool { pub fn is_fragment(&self) -> bool {