Add support for switching frames with the webdriver API.

This moves webdriver_traits into msg to avoid a circular dependency.
This commit is contained in:
James Graham 2015-05-11 14:47:10 +01:00
parent c724444ccb
commit 49f1b13ad9
20 changed files with 273 additions and 122 deletions

View file

@ -29,7 +29,8 @@ use msg::constellation_msg::{IFrameSandboxState, MozBrowserEvent, NavigationDire
use msg::constellation_msg::{Key, KeyState, KeyModifiers, LoadData};
use msg::constellation_msg::{SubpageId, WindowSizeData};
use msg::constellation_msg::{self, ConstellationChan, Failure};
use msg::constellation_msg::{WebDriverCommandMsg};
use msg::constellation_msg::WebDriverCommandMsg;
use msg::webdriver_msg;
use net_traits::{self, ResourceTask};
use net_traits::image_cache_task::ImageCacheTask;
use net_traits::storage_task::{StorageTask, StorageTaskMsg};
@ -50,7 +51,6 @@ use util::geometry::PagePx;
use util::opts;
use util::task::spawn_named;
use clipboard::ClipboardContext;
use webdriver_traits;
/// Maintains the pipelines and navigation context and grants permission to composite.
///
@ -190,7 +190,7 @@ pub struct SendableFrameTree {
}
struct WebDriverData {
load_channel: Option<Sender<webdriver_traits::LoadComplete>>
load_channel: Option<Sender<webdriver_msg::LoadComplete>>
}
impl WebDriverData {
@ -425,9 +425,13 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
subpage_id,
event);
}
ConstellationMsg::GetRootPipeline(resp_chan) => {
ConstellationMsg::GetPipeline(frame_id, resp_chan) => {
debug!("constellation got get root pipeline message");
self.handle_get_root_pipeline(resp_chan);
self.handle_get_pipeline(frame_id, resp_chan);
}
ConstellationMsg::GetFrame(parent_pipeline_id, subpage_id, resp_chan) => {
debug!("constellation got get root pipeline message");
self.handle_get_frame(parent_pipeline_id, subpage_id, resp_chan);
}
ConstellationMsg::Focus(pipeline_id) => {
debug!("constellation got focus message");
@ -691,7 +695,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let back = !self.mut_frame(frame_id).prev.is_empty();
self.compositor_proxy.send(CompositorMsg::LoadComplete(back, forward));
if let Some(ref reply_chan) = self.webdriver.load_channel {
reply_chan.send(webdriver_traits::LoadComplete).unwrap();
reply_chan.send(webdriver_msg::LoadComplete).unwrap();
}
self.webdriver.load_channel = None;
}
@ -815,14 +819,24 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
pipeline.trigger_mozbrowser_event(subpage_id, event);
}
fn handle_get_root_pipeline(&mut self, resp_chan: Sender<Option<PipelineId>>) {
let pipeline_id = self.root_frame_id.map(|frame_id| {
fn handle_get_pipeline(&mut self, frame_id: Option<FrameId>,
resp_chan: Sender<Option<PipelineId>>) {
let pipeline_id = frame_id.or(self.root_frame_id).map(|frame_id| {
let frame = self.frames.get(&frame_id).unwrap();
frame.current
});
resp_chan.send(pipeline_id).unwrap();
}
fn handle_get_frame(&mut self,
containing_pipeline_id: PipelineId,
subpage_id: SubpageId,
resp_chan: Sender<Option<FrameId>>) {
let frame_id = self.subpage_map.get(&(containing_pipeline_id, subpage_id)).and_then(
|x| self.pipeline_to_frame_map.get(&x)).map(|x| *x);
resp_chan.send(frame_id).unwrap();
}
fn focus_parent_pipeline(&self, pipeline_id: PipelineId) {
// Send a message to the parent of the provided pipeline (if it exists)
// telling it to mark the iframe element as focused.