diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs index d679a3aeab0..50bd41358e2 100644 --- a/src/components/script/dom/element.rs +++ b/src/components/script/dom/element.rs @@ -166,10 +166,18 @@ impl<'self> Element { //XXXjdm We really need something like a vtable so we can call AfterSetAttr. // This hardcoding is awful. - if abstract_self.is_iframe_element() { - do abstract_self.with_mut_iframe_element |iframe| { - iframe.AfterSetAttr(raw_name, raw_value); + match abstract_self.type_id() { + ElementNodeTypeId(HTMLImageElementTypeId) => { + do abstract_self.with_mut_image_element |image| { + image.AfterSetAttr(raw_name, raw_value); + } } + ElementNodeTypeId(HTMLIframeElementTypeId) => { + do abstract_self.with_mut_iframe_element |iframe| { + iframe.AfterSetAttr(raw_name, raw_value); + } + } + _ => () } match self.parent.owner_doc { diff --git a/src/components/script/dom/htmlimageelement.rs b/src/components/script/dom/htmlimageelement.rs index 4af8a36def2..1ab87a62368 100644 --- a/src/components/script/dom/htmlimageelement.rs +++ b/src/components/script/dom/htmlimageelement.rs @@ -9,6 +9,7 @@ use extra::url::Url; use gfx::geometry::to_px; use layout_interface::{ContentBoxQuery, ContentBoxResponse}; use servo_net::image_cache_task; +use servo_net::image_cache_task::ImageCacheTask; use servo_util::url::make_url; pub struct HTMLImageElement { @@ -19,36 +20,37 @@ pub struct HTMLImageElement { impl HTMLImageElement { /// Makes the local `image` member match the status of the `src` attribute and starts /// prefetching the image. This method must be called after `src` is changed. - pub fn update_image(&mut self) { + pub fn update_image(&mut self, image_cache: ImageCacheTask, url: Option) { let elem = &mut self.parent.parent; let src_opt = elem.get_attr("src").map(|x| x.to_str()); - let node = &mut elem.parent; - match node.owner_doc { - Some(doc) => { - match doc.with_base(|doc| doc.window) { - Some(window) => { - match src_opt { - None => {} - Some(src) => { - let page = window.page; - let img_url = make_url(src, - (*page).url - .map(|&(ref url, _)| url.clone())); - self.image = Some(img_url.clone()); + match src_opt { + None => {} + Some(src) => { + let img_url = make_url(src, url); + self.image = Some(img_url.clone()); - // inform the image cache to load this, but don't store a - // handle. - // - // TODO (Issue #84): don't prefetch if we are within a - //