/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::utils::{DOMString, ErrorResult, null_str_as_empty}; use dom::htmlelement::HTMLElement; use dom::node::{ScriptView, AbstractNode}; use extra::url::Url; use servo_util::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; use servo_util::tree::ElementLike; pub struct HTMLImageElement { htmlelement: HTMLElement, image: Option, } 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, image_cache: ImageCacheTask, url: Option) { let elem = &mut self.htmlelement.element; let src_opt = elem.get_attr("src").map(|x| x.to_str()); 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 //