aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-08-07 11:30:33 -0600
committerbors-servo <metajack+bors@gmail.com>2015-08-07 11:30:33 -0600
commit361d94d23ebf2897a240763d28fbb77b3d831b34 (patch)
tree558181c6bef6b01b52e8830d545fc6e859890246 /components
parent9bd5291aea24f5bc2780c864d207ce1496f8525f (diff)
parent36da7e2270053b42927560469daa73c11803d859 (diff)
downloadservo-361d94d23ebf2897a240763d28fbb77b3d831b34.tar.gz
servo-361d94d23ebf2897a240763d28fbb77b3d831b34.zip
Auto merge of #6415 - jgraham:dom_load, r=jdm
Add DOMLoad message to constellation that is sent after the DOM Load event is dispatched. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6415) <!-- Reviewable:end -->
Diffstat (limited to 'components')
-rw-r--r--components/compositing/constellation.rs16
-rw-r--r--components/msg/constellation_msg.rs2
-rw-r--r--components/script/dom/document.rs12
3 files changed, 28 insertions, 2 deletions
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs
index 28aba6346ea..c3d0c247b18 100644
--- a/components/compositing/constellation.rs
+++ b/components/compositing/constellation.rs
@@ -423,6 +423,11 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
debug!("constellation got load complete message");
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
ConstellationMsg::Navigate(pipeline_info, direction) => {
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) {
let frame_id = match self.pipeline_to_frame_map.get(pipeline_id) {
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 back = !self.frame(frame_id).prev.is_empty();
self.compositor_proxy.send(CompositorMsg::LoadComplete(back, forward));
+ }
+ fn handle_dom_load(&mut self,
+ pipeline_id: PipelineId) {
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 {
let _ = reply_chan.send(webdriver_msg::LoadStatus::LoadComplete);
webdriver_reset = true;
diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs
index 286d0f71a2b..922d92465a8 100644
--- a/components/msg/constellation_msg.rs
+++ b/components/msg/constellation_msg.rs
@@ -219,6 +219,8 @@ pub enum Msg {
Failure(Failure),
InitLoadUrl(Url),
LoadComplete(PipelineId),
+ /// Dispatched after the DOM load event has fired on a document
+ DOMLoad(PipelineId),
FrameRect(PipelineId, SubpageId, Rect<f32>),
LoadUrl(PipelineId, LoadData),
ScriptLoadedURLInIFrame(Url, PipelineId, SubpageId, Option<SubpageId>, IFrameSandboxState),
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 4f4b43437e7..0057ab0bcf7 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -289,6 +289,7 @@ pub trait DocumentHelpers<'a> {
fn load_async(self, load: LoadType, listener: AsyncResponseTarget);
fn load_sync(self, load: LoadType) -> Result<(Metadata, Vec<u8>), String>;
fn finish_load(self, load: LoadType);
+ fn notify_constellation_load(self);
fn set_current_parser(self, script: Option<&ServoHTMLParser>);
fn get_current_parser(self) -> Option<Root<ServoHTMLParser>>;
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);
}
+ 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>) {
self.current_parser.set(script.map(JS::from_ref));
}
@@ -1904,6 +1914,8 @@ impl DocumentProgressHandler {
event.r().fire(target);
});
+ document.r().notify_constellation_load();
+
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadend
document.r().trigger_mozbrowser_event(MozBrowserEvent::LoadEnd);