mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Forward to embedder message for setting/getting clipboard contents from clipboard provider.
Create clipboard context in browser.rs and handle new messages.
This commit is contained in:
parent
1e5103e675
commit
f4d972adb2
5 changed files with 47 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use embedder_traits::EmbedderMsg;
|
||||
use ipc_channel::ipc::channel;
|
||||
use script_traits::{ScriptMsg, ScriptToConstellationChan};
|
||||
use std::borrow::ToOwned;
|
||||
|
@ -16,11 +17,17 @@ pub trait ClipboardProvider {
|
|||
impl ClipboardProvider for ScriptToConstellationChan {
|
||||
fn clipboard_contents(&mut self) -> String {
|
||||
let (tx, rx) = channel().unwrap();
|
||||
self.send(ScriptMsg::GetClipboardContents(tx)).unwrap();
|
||||
self.send(ScriptMsg::ForwardToEmbedder(
|
||||
EmbedderMsg::GetClipboardContents(tx),
|
||||
))
|
||||
.unwrap();
|
||||
rx.recv().unwrap()
|
||||
}
|
||||
fn set_clipboard_contents(&mut self, s: String) {
|
||||
self.send(ScriptMsg::SetClipboardContents(s)).unwrap();
|
||||
self.send(ScriptMsg::ForwardToEmbedder(
|
||||
EmbedderMsg::SetClipboardContents(s),
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue