mirror of
https://github.com/servo/servo.git
synced 2025-06-20 15:18:58 +01:00
Fetch the image cache inside the update_image function.
This commit is contained in:
parent
2639e36c78
commit
e834e532c5
1 changed files with 6 additions and 6 deletions
|
@ -16,7 +16,6 @@ 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::parse_url;
|
||||
use servo_util::namespace::Null;
|
||||
use servo_util::str::DOMString;
|
||||
|
@ -66,8 +65,11 @@ impl 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.
|
||||
fn update_image(&mut self, image_cache: ImageCacheTask, url: Option<Url>) {
|
||||
fn update_image(&mut self, url: Option<Url>) {
|
||||
let elem = &mut self.htmlelement.element;
|
||||
let document = elem.node.owner_doc();
|
||||
let window = document.get().window.get();
|
||||
let image_cache = &window.image_cache_task;
|
||||
let src_opt = elem.get_attribute(Null, "src").map(|x| x.get().Value());
|
||||
match src_opt {
|
||||
None => {}
|
||||
|
@ -90,7 +92,7 @@ impl HTMLImageElement {
|
|||
let document = self.htmlelement.element.node.owner_doc();
|
||||
let window = document.get().window.get();
|
||||
let url = window.page.url.as_ref().map(|&(ref url, _)| url.clone());
|
||||
self.update_image(window.image_cache_task.clone(), url);
|
||||
self.update_image(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,9 +101,7 @@ impl HTMLImageElement {
|
|||
// This might not handle remove src attribute actually since
|
||||
// `self.update_image()` will see the missing src attribute and return early.
|
||||
if "src" == name {
|
||||
let document = self.htmlelement.element.node.owner_doc();
|
||||
let window = document.get().window.get();
|
||||
self.update_image(window.image_cache_task.clone(), None);
|
||||
self.update_image(None);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue