Moved clipboard integration from textinput to constellation, to facilitate sandboxing.

This commit is contained in:
Avi Weinstock 2015-04-02 16:26:20 -04:00
parent ba4c455438
commit 503cc9e6d6
10 changed files with 46 additions and 19 deletions

View file

@ -58,6 +58,9 @@ git = "https://github.com/servo/rust-core-text"
[dependencies.gleam]
git = "https://github.com/servo/gleam"
[dependencies.clipboard]
git = "https://github.com/aweinstock314/rust-x11-clipboard"
[dependencies]
url = "0.2.16"
time = "0.1.17"

View file

@ -38,6 +38,7 @@ use util::cursor::Cursor;
use util::geometry::PagePx;
use util::opts;
use util::task::spawn_named;
use clipboard::ClipboardContext;
/// Maintains the pipelines and navigation context and grants permission to composite.
pub struct Constellation<LTF, STF> {
@ -102,6 +103,9 @@ pub struct Constellation<LTF, STF> {
phantom: PhantomData<(LTF, STF)>,
pub window_size: WindowSizeData,
/// Means of accessing the clipboard
clipboard_ctx: ClipboardContext,
}
/// Stores the navigation context for a single frame in the frame tree.
@ -212,6 +216,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
device_pixel_ratio: ScaleFactor::new(1.0),
},
phantom: PhantomData,
clipboard_ctx: ClipboardContext::new().unwrap(),
};
constellation.run();
});
@ -395,6 +400,16 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
debug!("constellation got focus message");
self.handle_focus_msg(pipeline_id);
}
ConstellationMsg::GetClipboardContents(sender) => {
let result = match self.clipboard_ctx.get_contents() {
Ok(s) => s,
Err(e) => {
debug!("Error getting clipboard contents ({}), defaulting to empty string", e);
"".to_string()
},
};
sender.send(result).unwrap();
}
}
true
}

View file

@ -28,6 +28,7 @@ extern crate net_traits;
extern crate util;
extern crate gleam;
extern crate webdriver_server;
extern crate clipboard;
extern crate libc;
extern crate time;