mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #18886 - servo:urls, r=SimonSapin
Change AttrValue::Url to AttrValue::ResolvedUrl Things make more sense like this. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18886) <!-- Reviewable:end -->
This commit is contained in:
commit
7e8def9c08
9 changed files with 48 additions and 72 deletions
|
@ -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()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue