aboutsummaryrefslogtreecommitdiffstats
path: root/components/compositing
diff options
context:
space:
mode:
Diffstat (limited to 'components/compositing')
-rw-r--r--components/compositing/constellation.rs41
-rw-r--r--components/compositing/pipeline.rs15
2 files changed, 48 insertions, 8 deletions
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs
index 228211e3ef8..45dd597b413 100644
--- a/components/compositing/constellation.rs
+++ b/components/compositing/constellation.rs
@@ -606,6 +606,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
script_chan.send(ConstellationControlMsg::UpdateSubpageId(parent_pipeline_id,
subpage_id,
new_subpage_id)).unwrap();
+
+ // If this is an iframe, send a mozbrowser location change event.
+ // This is the result of a back/forward navigation.
+ self.trigger_mozbrowserlocationchange(next_pipeline_id);
}
}
@@ -637,7 +641,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
fn handle_mozbrowser_event_msg(&mut self,
- pipeline_id: PipelineId,
+ containing_pipeline_id: PipelineId,
subpage_id: SubpageId,
event_name: String,
event_detail: Option<String>) {
@@ -645,13 +649,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// Find the script channel for the given parent pipeline,
// and pass the event to that script task.
- let pipeline = self.pipeline(pipeline_id);
- let ScriptControlChan(ref script_channel) = pipeline.script_chan;
- let event = ConstellationControlMsg::MozBrowserEvent(pipeline_id,
- subpage_id,
- event_name,
- event_detail);
- script_channel.send(event).unwrap();
+ let pipeline = self.pipeline(containing_pipeline_id);
+ pipeline.trigger_mozbrowser_event(subpage_id, event_name, event_detail);
}
fn add_or_replace_pipeline_in_frame_tree(&mut self, frame_change: FrameChange) {
@@ -692,6 +691,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// Build frame tree and send permission
self.send_frame_tree_and_grant_paint_permission();
+ // If this is an iframe, send a mozbrowser location change event.
+ // This is the result of a link being clicked and a navigation completing.
+ self.trigger_mozbrowserlocationchange(frame_change.new_pipeline_id);
+
// Remove any evicted frames
if let Some(evicted_frames) = evicted_frames {
for pipeline_id in &evicted_frames {
@@ -862,6 +865,28 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
}
+ // https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserlocationchange
+ fn trigger_mozbrowserlocationchange(&self, pipeline_id: PipelineId) {
+ if opts::experimental_enabled() {
+ // Work around borrow checker
+ let event_info = {
+ let pipeline = self.pipeline(pipeline_id);
+
+ pipeline.parent_info.map(|(containing_pipeline_id, subpage_id)| {
+ (containing_pipeline_id, subpage_id, pipeline.url.serialize())
+ })
+ };
+
+ // If this is an iframe, then send the event with new url
+ if let Some((containing_pipeline_id, subpage_id, url)) = event_info {
+ let parent_pipeline = self.pipeline(containing_pipeline_id);
+ parent_pipeline.trigger_mozbrowser_event(subpage_id,
+ "mozbrowserlocationchange".to_owned(),
+ Some(url));
+ }
+ }
+ }
+
fn pipeline_is_in_current_frame(&self, pipeline_id: PipelineId) -> bool {
self.current_frame_tree_iter(self.root_frame_id)
.any(|current_frame| current_frame.current == pipeline_id)
diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs
index 0d8e6261d25..b5fcebb578a 100644
--- a/components/compositing/pipeline.rs
+++ b/components/compositing/pipeline.rs
@@ -24,6 +24,7 @@ use profile::time::TimeProfilerChan;
use std::sync::mpsc::{Receiver, channel};
use url::Url;
use util::geometry::{PagePx, ViewportPx};
+use util::opts;
/// A uniquely-identifiable pipeline of script task, layout task, and paint task.
pub struct Pipeline {
@@ -244,4 +245,18 @@ impl Pipeline {
pub fn add_child(&mut self, frame_id: FrameId) {
self.children.push(frame_id);
}
+
+ pub fn trigger_mozbrowser_event(&self,
+ subpage_id: SubpageId,
+ event_name: String,
+ event_detail: Option<String>) {
+ assert!(opts::experimental_enabled());
+
+ let ScriptControlChan(ref script_channel) = self.script_chan;
+ let event = ConstellationControlMsg::MozBrowserEvent(self.id,
+ subpage_id,
+ event_name,
+ event_detail);
+ script_channel.send(event).unwrap();
+ }
}