diff options
author | Martin Robinson <mrobinson@igalia.com> | 2023-09-06 11:15:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-06 09:15:21 +0000 |
commit | 0cf84f9f7cb75781ee7967d1faa0ca10bd6c58ff (patch) | |
tree | eef7a7ac22204e1529491d5732e839e46f77cd3a /ports/servoshell | |
parent | 8d5dc7a0bb0b4f46a5333f928e01767a22372f3f (diff) | |
download | servo-0cf84f9f7cb75781ee7967d1faa0ca10bd6c58ff.tar.gz servo-0cf84f9f7cb75781ee7967d1faa0ca10bd6c58ff.zip |
Use arboard in servoshell instead of rust-clipboard (#30274)
rust-clipboard is unmaintained, which means that it pulls in very old
dependencies (including a version xcb with 3 critical security
vulnerabilities). In addition, we already depend on arboard. This
removes four crates from our dependency graph.
Diffstat (limited to 'ports/servoshell')
-rw-r--r-- | ports/servoshell/Cargo.toml | 2 | ||||
-rw-r--r-- | ports/servoshell/browser.rs | 27 |
2 files changed, 13 insertions, 16 deletions
diff --git a/ports/servoshell/Cargo.toml b/ports/servoshell/Cargo.toml index 2d532b29c6a..53774624463 100644 --- a/ports/servoshell/Cargo.toml +++ b/ports/servoshell/Cargo.toml @@ -44,8 +44,8 @@ webgl_backtrace = ["libservo/webgl_backtrace"] xr-profile = ["libservo/xr-profile"] [target.'cfg(not(target_os = "android"))'.dependencies] +arboard = "3" backtrace = { workspace = true } -clipboard = "0.5" egui = "0.22.0" egui_glow = { version = "0.22.0", features = ["winit"] } egui-winit = { version = "0.22.0", default-features = false, features = ["clipboard", "wayland"] } diff --git a/ports/servoshell/browser.rs b/ports/servoshell/browser.rs index d1ea764af9b..2dc1447297c 100644 --- a/ports/servoshell/browser.rs +++ b/ports/servoshell/browser.rs @@ -4,7 +4,7 @@ use crate::keyutils::{CMD_OR_ALT, CMD_OR_CONTROL}; use crate::window_trait::{WindowPortsMethods, LINE_HEIGHT}; -use clipboard::{ClipboardContext, ClipboardProvider}; +use arboard::Clipboard; use euclid::{Point2D, Vector2D}; use keyboard_types::{Key, KeyboardEvent, Modifiers, ShortcutMatcher}; use servo::compositing::windowing::{WebRenderDebugOption, EmbedderEvent}; @@ -47,7 +47,7 @@ pub struct Browser<Window: WindowPortsMethods + ?Sized> { window: Rc<Window>, event_queue: Vec<EmbedderEvent>, - clipboard_ctx: Option<ClipboardContext>, + clipboard: Option<Clipboard>, shutdown_requested: bool, } @@ -63,7 +63,7 @@ where browser_id: None, browsers: Vec::new(), window, - clipboard_ctx: match ClipboardContext::new() { + clipboard: match Clipboard::new() { Ok(c) => Some(c), Err(e) => { warn!("Error creating clipboard context ({})", e); @@ -420,23 +420,20 @@ where self.handle_key_from_servo(browser_id, key_event); }, EmbedderMsg::GetClipboardContents(sender) => { - let contents = match self.clipboard_ctx { - Some(ref mut ctx) => match ctx.get_contents() { - Ok(c) => c, - Err(e) => { - warn!("Error getting clipboard contents ({}), defaulting to empty string", e); - "".to_owned() - }, - }, - None => "".to_owned(), - }; + let contents = self.clipboard + .as_mut() + .and_then(|clipboard| clipboard.get_text().ok()) + .unwrap_or_else(|| { + warn!("Error getting clipboard text. Returning empty string."); + String::new() + }); if let Err(e) = sender.send(contents) { warn!("Failed to send clipboard ({})", e); } }, EmbedderMsg::SetClipboardContents(text) => { - if let Some(ref mut ctx) = self.clipboard_ctx { - if let Err(e) = ctx.set_contents(text) { + if let Some(ref mut clipboard) = self.clipboard { + if let Err(e) = clipboard.set_text(text) { warn!("Error setting clipboard contents ({})", e); } } |