diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index a84773dd195..514fc50720f 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -64,7 +64,7 @@ use style;
use style::legacy::{UnsignedIntegerAttribute, from_declaration};
use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, parse_style_attribute};
use style::properties::DeclaredValue::SpecifiedValue;
-use style::properties::longhands::{self, border_spacing, height};
+use style::properties::longhands::{self, background_image, border_spacing, height};
use style::values::CSSFloat;
use style::values::specified::{self, CSSColor, CSSRGBA};
use util::geometry::Au;
@@ -280,6 +280,19 @@ impl RawLayoutElementHelpers for Element {
CSSColor { parsed: Color::RGBA(color), authored: None }))));
}
+ let background = if self.is_htmlbodyelement() {
+ let this: &HTMLBodyElement = mem::transmute(self);
+ this.get_background()
+ } else {
+ None
+ };
+
+ if let Some(url) = background {
+ hints.push(from_declaration(
+ PropertyDeclaration::BackgroundImage(SpecifiedValue(
+ background_image::SpecifiedValue(Some(specified::Image::Url(url)))))));
+ }
+
let color = if self.is_htmlfontelement() {
let this: &HTMLFontElement = mem::transmute(self);
this.get_color()
diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs
index a7a71b49233..35139a6f9ee 100644
--- a/components/script/dom/htmlbodyelement.rs
+++ b/components/script/dom/htmlbodyelement.rs
@@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::{Attr, AttrHelpers};
+use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::Bindings::HTMLBodyElementBinding::{self, HTMLBodyElementMethods};
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
@@ -14,7 +15,7 @@ use dom::document::{Document, DocumentHelpers};
use dom::element::ElementTypeId;
use dom::eventtarget::{EventTarget, EventTargetTypeId, EventTargetHelpers};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
-use dom::node::{Node, NodeTypeId, window_from_node};
+use dom::node::{Node, NodeTypeId, window_from_node, document_from_node};
use dom::virtualmethods::VirtualMethods;
use dom::window::WindowHelpers;
use msg::constellation_msg::ConstellationChan;
@@ -22,6 +23,7 @@ use msg::constellation_msg::Msg as ConstellationMsg;
use cssparser::RGBA;
use util::str::{self, DOMString};
+use url::{Url, UrlParser};
use std::borrow::ToOwned;
use std::cell::Cell;
@@ -36,6 +38,7 @@ const INITIAL_REFLOW_DELAY: u64 = 200_000_000;
pub struct HTMLBodyElement {
htmlelement: HTMLElement,
background_color: Cell