aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlbodyelement.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-10-15 10:59:01 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2017-10-15 11:03:20 +0200
commitc7b1d3054f9e87cf7ae7b10df5fbf5a97f6448f4 (patch)
tree08886f4fabb29cac0b0ba7cb341477ab8f28a757 /components/script/dom/htmlbodyelement.rs
parent8b366a7441a7a4febcb5e2047807f9ad447c7adb (diff)
downloadservo-c7b1d3054f9e87cf7ae7b10df5fbf5a97f6448f4.tar.gz
servo-c7b1d3054f9e87cf7ae7b10df5fbf5a97f6448f4.zip
Change AttrValue::Url to AttrValue::ResolvedUrl
There is actually only one attribute that can use that, the one for <body background>.
Diffstat (limited to 'components/script/dom/htmlbodyelement.rs')
-rw-r--r--components/script/dom/htmlbodyelement.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs
index 580dc0a8808..69d56b31b95 100644
--- a/components/script/dom/htmlbodyelement.rs
+++ b/components/script/dom/htmlbodyelement.rs
@@ -4,7 +4,6 @@
use cssparser::RGBA;
use dom::attr::Attr;
-use dom::bindings::codegen::Bindings::AttrBinding::AttrBinding::AttrMethods;
use dom::bindings::codegen::Bindings::HTMLBodyElementBinding::{self, HTMLBodyElementMethods};
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::inheritance::Castable;
@@ -74,15 +73,16 @@ impl HTMLBodyElementMethods for HTMLBodyElement {
make_legacy_color_setter!(SetText, "text");
// https://html.spec.whatwg.org/multipage/#dom-body-background
- fn Background(&self) -> DOMString {
- self.upcast::<Element>()
- .get_attribute(&ns!(), &local_name!("background"))
- .map(|attr| attr.Value())
- .unwrap_or_default()
- }
+ make_getter!(Background, "background");
// https://html.spec.whatwg.org/multipage/#dom-body-background
- make_url_setter!(SetBackground, "background");
+ fn SetBackground(&self, input: DOMString) {
+ let value = AttrValue::from_resolved_url(
+ &document_from_node(self).base_url(),
+ input.into(),
+ );
+ self.upcast::<Element>().set_attribute(&local_name!("background"), value);
+ }
// https://html.spec.whatwg.org/multipage/#windoweventhandlers
window_event_handlers!(ForwardToWindow);
@@ -120,7 +120,7 @@ impl HTMLBodyElementLayoutHelpers for LayoutDom<HTMLBodyElement> {
unsafe {
(*self.upcast::<Element>().unsafe_get())
.get_attr_for_layout(&ns!(), &local_name!("background"))
- .and_then(AttrValue::as_url)
+ .and_then(AttrValue::as_resolved_url)
.cloned()
}
}
@@ -160,7 +160,10 @@ impl VirtualMethods for HTMLBodyElement {
local_name!("bgcolor") |
local_name!("text") => AttrValue::from_legacy_color(value.into()),
local_name!("background") => {
- AttrValue::from_url(document_from_node(self).base_url(), value.into())
+ AttrValue::from_resolved_url(
+ &document_from_node(self).base_url(),
+ value.into(),
+ )
},
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}