mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Add support for selecting which frame is requesting a navigation.
This allows iframes to navigate their own history.
This commit is contained in:
parent
1092ca1019
commit
3fb3e66ada
3 changed files with 16 additions and 11 deletions
|
@ -946,7 +946,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
windowing::WindowNavigateMsg::Back => NavigationDirection::Back,
|
windowing::WindowNavigateMsg::Back => NavigationDirection::Back,
|
||||||
};
|
};
|
||||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||||
chan.send(ConstellationMsg::Navigate(direction)).unwrap()
|
chan.send(ConstellationMsg::Navigate(None, direction)).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_key_event(&self, key: Key, state: KeyState, modifiers: KeyModifiers) {
|
fn on_key_event(&self, key: Key, state: KeyState, modifiers: KeyModifiers) {
|
||||||
|
|
|
@ -111,6 +111,9 @@ impl Frame {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load(&mut self, pipeline_id: PipelineId) -> Vec<PipelineId> {
|
fn load(&mut self, pipeline_id: PipelineId) -> Vec<PipelineId> {
|
||||||
|
// TODO(gw): To also allow navigations within subframes
|
||||||
|
// to affect the parent navigation history, this should bubble
|
||||||
|
// up the navigation change to each parent.
|
||||||
self.prev.push(self.current);
|
self.prev.push(self.current);
|
||||||
self.current = pipeline_id;
|
self.current = pipeline_id;
|
||||||
replace(&mut self.next, vec!())
|
replace(&mut self.next, vec!())
|
||||||
|
@ -339,9 +342,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
self.compositor_proxy.send(CompositorMsg::LoadComplete);
|
self.compositor_proxy.send(CompositorMsg::LoadComplete);
|
||||||
}
|
}
|
||||||
// Handle a forward or back request
|
// Handle a forward or back request
|
||||||
ConstellationMsg::Navigate(direction) => {
|
ConstellationMsg::Navigate(pipeline_info, direction) => {
|
||||||
debug!("constellation got navigation message");
|
debug!("constellation got navigation message");
|
||||||
self.handle_navigate_msg(direction);
|
self.handle_navigate_msg(pipeline_info, direction);
|
||||||
}
|
}
|
||||||
// Notification that painting has finished and is requesting permission to paint.
|
// Notification that painting has finished and is requesting permission to paint.
|
||||||
ConstellationMsg::PainterReady(pipeline_id) => {
|
ConstellationMsg::PainterReady(pipeline_id) => {
|
||||||
|
@ -530,15 +533,17 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_navigate_msg(&mut self, direction: constellation_msg::NavigationDirection) {
|
fn handle_navigate_msg(&mut self,
|
||||||
|
pipeline_info: Option<(PipelineId, SubpageId)>,
|
||||||
|
direction: constellation_msg::NavigationDirection) {
|
||||||
debug!("received message to navigate {:?}", direction);
|
debug!("received message to navigate {:?}", direction);
|
||||||
|
|
||||||
// TODO(gw): Extend handle_navigate_msg to allow passing the frame
|
// Get the frame id associated with the pipeline that sent
|
||||||
// id that this navigation should apply to, instead of always referencing
|
// the navigate message, or use root frame id by default.
|
||||||
// the frame history in the root frame. To also allow navigations within
|
let frame_id = pipeline_info.map_or(self.root_frame_id, |(containing_pipeline_id, subpage_id)| {
|
||||||
// subframes to affect the parent navigation history, this should bubble
|
let pipeline_id = self.find_subpage(containing_pipeline_id, subpage_id).id;
|
||||||
// up the navigation items to each parent.
|
self.pipeline_to_frame_map.get(&pipeline_id).map(|id| *id)
|
||||||
let frame_id = self.root_frame_id.unwrap();
|
}).unwrap();
|
||||||
|
|
||||||
// Get the ids for the previous and next pipelines.
|
// Get the ids for the previous and next pipelines.
|
||||||
let (prev_pipeline_id, next_pipeline_id) = {
|
let (prev_pipeline_id, next_pipeline_id) = {
|
||||||
|
|
|
@ -203,7 +203,7 @@ pub enum Msg {
|
||||||
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),
|
||||||
Navigate(NavigationDirection),
|
Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
|
||||||
PainterReady(PipelineId),
|
PainterReady(PipelineId),
|
||||||
ResizedWindow(WindowSizeData),
|
ResizedWindow(WindowSizeData),
|
||||||
KeyEvent(Key, KeyState, KeyModifiers),
|
KeyEvent(Key, KeyState, KeyModifiers),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue