mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Use task! to fire a progress event when updating the image data
This commit is contained in:
parent
30a1d3f617
commit
fba54c7735
1 changed files with 21 additions and 24 deletions
|
@ -386,28 +386,6 @@ impl HTMLImageElement {
|
||||||
let _ = task_source.queue(task, window.upcast());
|
let _ = task_source.queue(task, window.upcast());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Step 10 of html.spec.whatwg.org/multipage/#update-the-image-data
|
|
||||||
fn dispatch_loadstart_progress_event(&self) {
|
|
||||||
struct FireprogressEventTask {
|
|
||||||
img: Trusted<HTMLImageElement>,
|
|
||||||
}
|
|
||||||
impl Task for FireprogressEventTask {
|
|
||||||
fn run(self: Box<Self>) {
|
|
||||||
let progressevent = ProgressEvent::new(&self.img.root().global(),
|
|
||||||
atom!("loadstart"), EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
|
|
||||||
false, 0, 0);
|
|
||||||
progressevent.upcast::<Event>().fire(self.img.root().upcast());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let task = box FireprogressEventTask {
|
|
||||||
img: Trusted::new(self),
|
|
||||||
};
|
|
||||||
let document = document_from_node(self);
|
|
||||||
let window = document.window();
|
|
||||||
let task_source = window.dom_manipulation_task_source();
|
|
||||||
let _ = task_source.queue(task, window.upcast());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#update-the-source-set
|
/// https://html.spec.whatwg.org/multipage/#update-the-source-set
|
||||||
fn update_source_set(&self) -> Vec<DOMString> {
|
fn update_source_set(&self) -> Vec<DOMString> {
|
||||||
let elem = self.upcast::<Element>();
|
let elem = self.upcast::<Element>();
|
||||||
|
@ -550,8 +528,27 @@ impl HTMLImageElement {
|
||||||
// TODO: take pixel density into account
|
// TODO: take pixel density into account
|
||||||
match self.select_image_source() {
|
match self.select_image_source() {
|
||||||
Some(src) => {
|
Some(src) => {
|
||||||
// Step 10
|
// Step 10.
|
||||||
self.dispatch_loadstart_progress_event();
|
let window = document.window();
|
||||||
|
let this = Trusted::new(self);
|
||||||
|
// FIXME(nox): Why are errors silenced here?
|
||||||
|
let _ = window.dom_manipulation_task_source().queue(
|
||||||
|
box task!(fire_progress_event: move || {
|
||||||
|
let this = this.root();
|
||||||
|
|
||||||
|
let event = ProgressEvent::new(
|
||||||
|
&this.global(),
|
||||||
|
atom!("loadstart"),
|
||||||
|
EventBubbles::DoesNotBubble,
|
||||||
|
EventCancelable::NotCancelable,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
event.upcast::<Event>().fire(this.upcast());
|
||||||
|
}),
|
||||||
|
window.upcast(),
|
||||||
|
);
|
||||||
// Step 11
|
// Step 11
|
||||||
let base_url = document.base_url();
|
let base_url = document.base_url();
|
||||||
let parsed_url = base_url.join(&src);
|
let parsed_url = base_url.join(&src);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue