Change AttrValue::Url to AttrValue::ResolvedUrl

There is actually only one attribute that can use that, the one for
<body background>.
This commit is contained in:
Anthony Ramine 2017-10-15 10:59:01 +02:00
parent 8b366a7441
commit c7b1d3054f
9 changed files with 48 additions and 72 deletions

View file

@ -1306,26 +1306,13 @@ impl Element {
Some(attr) => attr,
None => return DOMString::new(),
};
let value = attr.value();
match *value {
AttrValue::Url(ref value, _) => {
// XXXManishearth this doesn't handle `javascript:` urls properly
let base = document_from_node(self).base_url();
let value = base.join(value)
.map(|parsed| parsed.into_string())
.unwrap_or_else(|_| value.clone());
DOMString::from(value)
},
_ => panic!("attribute value should be AttrValue::Url(..)"),
}
}
pub fn set_url_attribute(&self, local_name: &LocalName, value: DOMString) {
let value = AttrValue::from_url(
document_from_node(self).base_url(),
value.into(),
);
self.set_attribute(local_name, value);
let value = &**attr.value();
// XXXManishearth this doesn't handle `javascript:` urls properly
let base = document_from_node(self).base_url();
let value = base.join(value)
.map(|parsed| parsed.into_string())
.unwrap_or_else(|_| value.to_owned());
DOMString::from(value)
}
pub fn get_string_attribute(&self, local_name: &LocalName) -> DOMString {
@ -1334,6 +1321,7 @@ impl Element {
None => DOMString::new(),
}
}
pub fn set_string_attribute(&self, local_name: &LocalName, value: DOMString) {
assert!(*local_name == local_name.to_ascii_lowercase());
self.set_attribute(local_name, AttrValue::String(value.into()));