Add a spec-incompliant load event.

This commit is contained in:
Josh Matthews 2013-11-11 16:50:58 +09:00
parent 651b2f072b
commit 3b3f891455
4 changed files with 54 additions and 3 deletions

View file

@ -12,6 +12,8 @@ use dom::bindings::utils::{Reflectable, GlobalStaticData};
use dom::document::AbstractDocument;
use dom::element::Element;
use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseUpEvent};
use dom::event::{Event, HTMLEventTypeId};
use dom::eventtarget::AbstractEventTarget;
use dom::htmldocument::HTMLDocument;
use dom::window::Window;
use layout_interface::{AddStylesheetMsg, DocumentDamage};
@ -765,6 +767,15 @@ impl ScriptTask {
file.url.to_str(),
1);
}
// We have no concept of a document loader right now, so just dispatch the
// "load" event as soon as we've finished executing all scripts parsed during
// the initial load.
let event = Event::new(window, HTMLEventTypeId);
event.mut_event().InitEvent(&Some(~"load"), false, false);
let doctarget = AbstractEventTarget::from_document(document);
let wintarget = AbstractEventTarget::from_window(window);
window.eventtarget.dispatch_event_with_target(wintarget, Some(doctarget), event);
}
/// This is the main entry point for receiving and dispatching DOM events.