mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Allow Window implementations to indicate that they don't support a clipboard.
This is important for the SERVO_HEADLESS configuration, because creating a clipboard on linux creates an X context which then causes reftest instability.
This commit is contained in:
parent
ec79881471
commit
2b396b2485
6 changed files with 46 additions and 11 deletions
|
@ -122,7 +122,7 @@ pub struct Constellation<LTF, STF> {
|
||||||
pub window_size: WindowSizeData,
|
pub window_size: WindowSizeData,
|
||||||
|
|
||||||
/// Means of accessing the clipboard
|
/// Means of accessing the clipboard
|
||||||
clipboard_ctx: ClipboardContext,
|
clipboard_ctx: Option<ClipboardContext>,
|
||||||
|
|
||||||
/// Bits of state used to interact with the webdriver implementation
|
/// Bits of state used to interact with the webdriver implementation
|
||||||
webdriver: WebDriverData
|
webdriver: WebDriverData
|
||||||
|
@ -215,7 +215,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
time_profiler_chan: time::ProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
mem_profiler_chan: mem::ProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
devtools_chan: Option<DevtoolsControlChan>,
|
devtools_chan: Option<DevtoolsControlChan>,
|
||||||
storage_task: StorageTask)
|
storage_task: StorageTask,
|
||||||
|
supports_clipboard: bool)
|
||||||
-> ConstellationChan {
|
-> ConstellationChan {
|
||||||
let (constellation_port, constellation_chan) = ConstellationChan::new();
|
let (constellation_port, constellation_chan) = ConstellationChan::new();
|
||||||
let constellation_chan_clone = constellation_chan.clone();
|
let constellation_chan_clone = constellation_chan.clone();
|
||||||
|
@ -248,7 +249,11 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
device_pixel_ratio: ScaleFactor::new(1.0),
|
device_pixel_ratio: ScaleFactor::new(1.0),
|
||||||
},
|
},
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
clipboard_ctx: ClipboardContext::new().unwrap(),
|
clipboard_ctx: if supports_clipboard {
|
||||||
|
ClipboardContext::new().ok()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
webdriver: WebDriverData::new()
|
webdriver: WebDriverData::new()
|
||||||
};
|
};
|
||||||
constellation.run();
|
constellation.run();
|
||||||
|
@ -438,13 +443,13 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
self.handle_focus_msg(pipeline_id);
|
self.handle_focus_msg(pipeline_id);
|
||||||
}
|
}
|
||||||
ConstellationMsg::GetClipboardContents(sender) => {
|
ConstellationMsg::GetClipboardContents(sender) => {
|
||||||
let result = match self.clipboard_ctx.get_contents() {
|
let result = self.clipboard_ctx.as_ref().map_or(
|
||||||
Ok(s) => s,
|
"".to_string(),
|
||||||
Err(e) => {
|
|ctx| ctx.get_contents().unwrap_or_else(|e| {
|
||||||
debug!("Error getting clipboard contents ({}), defaulting to empty string", e);
|
debug!("Error getting clipboard contents ({}), defaulting to empty string", e);
|
||||||
"".to_string()
|
"".to_string()
|
||||||
},
|
})
|
||||||
};
|
);
|
||||||
sender.send(result).unwrap();
|
sender.send(result).unwrap();
|
||||||
}
|
}
|
||||||
ConstellationMsg::WebDriverCommand(command) => {
|
ConstellationMsg::WebDriverCommand(command) => {
|
||||||
|
|
|
@ -135,4 +135,7 @@ pub trait WindowMethods {
|
||||||
|
|
||||||
/// Process a key event.
|
/// Process a key event.
|
||||||
fn handle_key(&self, key: Key, mods: KeyModifiers);
|
fn handle_key(&self, key: Key, mods: KeyModifiers);
|
||||||
|
|
||||||
|
/// Does this window support a clipboard
|
||||||
|
fn supports_clipboard(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ use profile_traits::mem;
|
||||||
use profile_traits::time;
|
use profile_traits::time;
|
||||||
use util::opts;
|
use util::opts;
|
||||||
|
|
||||||
|
use std::borrow::Borrow;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
|
|
||||||
|
@ -91,6 +92,13 @@ impl Browser {
|
||||||
// to deliver the message.
|
// to deliver the message.
|
||||||
let (compositor_proxy, compositor_receiver) =
|
let (compositor_proxy, compositor_receiver) =
|
||||||
WindowMethods::create_compositor_channel(&window);
|
WindowMethods::create_compositor_channel(&window);
|
||||||
|
let supports_clipboard = match window {
|
||||||
|
Some(ref win_rc) => {
|
||||||
|
let win: &Window = win_rc.borrow();
|
||||||
|
win.supports_clipboard()
|
||||||
|
}
|
||||||
|
None => false
|
||||||
|
};
|
||||||
let time_profiler_chan = profile_time::Profiler::create(opts.time_profiler_period);
|
let time_profiler_chan = profile_time::Profiler::create(opts.time_profiler_period);
|
||||||
let mem_profiler_chan = profile_mem::Profiler::create(opts.mem_profiler_period);
|
let mem_profiler_chan = profile_mem::Profiler::create(opts.mem_profiler_period);
|
||||||
let devtools_chan = opts.devtools_port.map(|port| {
|
let devtools_chan = opts.devtools_port.map(|port| {
|
||||||
|
@ -104,7 +112,8 @@ impl Browser {
|
||||||
compositor_proxy.clone_compositor_proxy(),
|
compositor_proxy.clone_compositor_proxy(),
|
||||||
time_profiler_chan.clone(),
|
time_profiler_chan.clone(),
|
||||||
devtools_chan,
|
devtools_chan,
|
||||||
mem_profiler_chan.clone());
|
mem_profiler_chan.clone(),
|
||||||
|
supports_clipboard);
|
||||||
|
|
||||||
if let Some(port) = opts.webdriver_port {
|
if let Some(port) = opts.webdriver_port {
|
||||||
webdriver_server::start_server(port, constellation_chan.clone());
|
webdriver_server::start_server(port, constellation_chan.clone());
|
||||||
|
@ -149,7 +158,8 @@ fn create_constellation(opts: opts::Opts,
|
||||||
compositor_proxy: Box<CompositorProxy+Send>,
|
compositor_proxy: Box<CompositorProxy+Send>,
|
||||||
time_profiler_chan: time::ProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
|
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
|
||||||
mem_profiler_chan: mem::ProfilerChan) -> ConstellationChan {
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
|
supports_clipboard: bool) -> ConstellationChan {
|
||||||
let resource_task = new_resource_task(opts.user_agent.clone(), devtools_chan.clone());
|
let resource_task = new_resource_task(opts.user_agent.clone(), devtools_chan.clone());
|
||||||
|
|
||||||
let image_cache_task = new_image_cache_task(resource_task.clone());
|
let image_cache_task = new_image_cache_task(resource_task.clone());
|
||||||
|
@ -165,7 +175,8 @@ fn create_constellation(opts: opts::Opts,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
mem_profiler_chan,
|
mem_profiler_chan,
|
||||||
devtools_chan,
|
devtools_chan,
|
||||||
storage_task);
|
storage_task,
|
||||||
|
supports_clipboard);
|
||||||
|
|
||||||
// Send the URL command to the constellation.
|
// Send the URL command to the constellation.
|
||||||
match opts.url {
|
match opts.url {
|
||||||
|
|
|
@ -451,6 +451,10 @@ impl WindowMethods for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn supports_clipboard(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CefCompositorProxy {
|
struct CefCompositorProxy {
|
||||||
|
|
|
@ -614,6 +614,10 @@ impl WindowMethods for Window {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn supports_clipboard(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The type of a window.
|
/// The type of a window.
|
||||||
|
@ -718,6 +722,10 @@ impl WindowMethods for Window {
|
||||||
/// Helper function to handle keyboard events.
|
/// Helper function to handle keyboard events.
|
||||||
fn handle_key(&self, _: Key, _: constellation_msg::KeyModifiers) {
|
fn handle_key(&self, _: Key, _: constellation_msg::KeyModifiers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn supports_clipboard(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GlutinCompositorProxy {
|
struct GlutinCompositorProxy {
|
||||||
|
|
|
@ -841,6 +841,10 @@ impl WindowMethods for Window {
|
||||||
fn prepare_for_composite(&self, _width: usize, _height: usize) -> bool {
|
fn prepare_for_composite(&self, _width: usize, _height: usize) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn supports_clipboard(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GonkCompositorProxy {
|
struct GonkCompositorProxy {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue