servo: Merge #6415 - Add DOMLoad message to constellation that is sent after the DOM Load event is dispatched (from jgraham:dom_load); r=jdm

Source-Repo: https://github.com/servo/servo
Source-Revision: 361d94d23ebf2897a240763d28fbb77b3d831b34
This commit is contained in:
James Graham 2015-08-07 11:30:33 -06:00
Родитель d54da28e96
Коммит f689852d1b
3 изменённых файлов: 28 добавлений и 2 удалений

Просмотреть файл

@ -423,6 +423,11 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
debug!("constellation got load complete message"); debug!("constellation got load complete message");
self.handle_load_complete_msg(&pipeline_id) self.handle_load_complete_msg(&pipeline_id)
} }
// The DOM load event fired on a document
ConstellationMsg::DOMLoad(pipeline_id) => {
debug!("constellation got dom load message");
self.handle_dom_load(pipeline_id)
}
// Handle a forward or back request // Handle a forward or back request
ConstellationMsg::Navigate(pipeline_info, direction) => { ConstellationMsg::Navigate(pipeline_info, direction) => {
debug!("constellation got navigation message"); debug!("constellation got navigation message");
@ -744,15 +749,22 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
fn handle_load_complete_msg(&mut self, pipeline_id: &PipelineId) { fn handle_load_complete_msg(&mut self, pipeline_id: &PipelineId) {
let frame_id = match self.pipeline_to_frame_map.get(pipeline_id) { let frame_id = match self.pipeline_to_frame_map.get(pipeline_id) {
Some(frame) => *frame, Some(frame) => *frame,
None => return None => {
debug!("frame not found for pipeline id {:?}", pipeline_id);
return
}
}; };
let forward = !self.frame(frame_id).next.is_empty(); let forward = !self.frame(frame_id).next.is_empty();
let back = !self.frame(frame_id).prev.is_empty(); let back = !self.frame(frame_id).prev.is_empty();
self.compositor_proxy.send(CompositorMsg::LoadComplete(back, forward)); self.compositor_proxy.send(CompositorMsg::LoadComplete(back, forward));
}
fn handle_dom_load(&mut self,
pipeline_id: PipelineId) {
let mut webdriver_reset = false; let mut webdriver_reset = false;
if let Some((ref expected_pipeline_id, ref reply_chan)) = self.webdriver.load_channel { if let Some((expected_pipeline_id, ref reply_chan)) = self.webdriver.load_channel {
debug!("Sending load to WebDriver");
if expected_pipeline_id == pipeline_id { if expected_pipeline_id == pipeline_id {
let _ = reply_chan.send(webdriver_msg::LoadStatus::LoadComplete); let _ = reply_chan.send(webdriver_msg::LoadStatus::LoadComplete);
webdriver_reset = true; webdriver_reset = true;

Просмотреть файл

@ -219,6 +219,8 @@ pub enum Msg {
Failure(Failure), Failure(Failure),
InitLoadUrl(Url), InitLoadUrl(Url),
LoadComplete(PipelineId), LoadComplete(PipelineId),
/// Dispatched after the DOM load event has fired on a document
DOMLoad(PipelineId),
FrameRect(PipelineId, SubpageId, Rect<f32>), FrameRect(PipelineId, SubpageId, Rect<f32>),
LoadUrl(PipelineId, LoadData), LoadUrl(PipelineId, LoadData),
ScriptLoadedURLInIFrame(Url, PipelineId, SubpageId, Option<SubpageId>, IFrameSandboxState), ScriptLoadedURLInIFrame(Url, PipelineId, SubpageId, Option<SubpageId>, IFrameSandboxState),

Просмотреть файл

@ -289,6 +289,7 @@ pub trait DocumentHelpers<'a> {
fn load_async(self, load: LoadType, listener: AsyncResponseTarget); fn load_async(self, load: LoadType, listener: AsyncResponseTarget);
fn load_sync(self, load: LoadType) -> Result<(Metadata, Vec<u8>), String>; fn load_sync(self, load: LoadType) -> Result<(Metadata, Vec<u8>), String>;
fn finish_load(self, load: LoadType); fn finish_load(self, load: LoadType);
fn notify_constellation_load(self);
fn set_current_parser(self, script: Option<&ServoHTMLParser>); fn set_current_parser(self, script: Option<&ServoHTMLParser>);
fn get_current_parser(self) -> Option<Root<ServoHTMLParser>>; fn get_current_parser(self) -> Option<Root<ServoHTMLParser>>;
fn find_iframe(self, subpage_id: SubpageId) -> Option<Root<HTMLIFrameElement>>; fn find_iframe(self, subpage_id: SubpageId) -> Option<Root<HTMLIFrameElement>>;
@ -986,6 +987,15 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
loader.finish_load(load); loader.finish_load(load);
} }
fn notify_constellation_load(self) {
let window = self.window.root();
let pipeline_id = window.r().pipeline();
let ConstellationChan(ref chan) = window.r().constellation_chan();
let event = ConstellationMsg::DOMLoad(pipeline_id);
chan.send(event).unwrap();
}
fn set_current_parser(self, script: Option<&ServoHTMLParser>) { fn set_current_parser(self, script: Option<&ServoHTMLParser>) {
self.current_parser.set(script.map(JS::from_ref)); self.current_parser.set(script.map(JS::from_ref));
} }
@ -1904,6 +1914,8 @@ impl DocumentProgressHandler {
event.r().fire(target); event.r().fire(target);
}); });
document.r().notify_constellation_load();
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadend // https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadend
document.r().trigger_mozbrowser_event(MozBrowserEvent::LoadEnd); document.r().trigger_mozbrowser_event(MozBrowserEvent::LoadEnd);