mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #23564 - mmiecz:clipboard-refactoring, r=jdm
Clipboard refactoring <!-- Please describe your changes on the following line: --> This PR removes clipboard handling from the constellation. Instead, now embedder handles it. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #23440 (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because it is enough to test manually in input box, if copying and pasting still works . <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23564) <!-- Reviewable:end -->
This commit is contained in:
commit
e382266b22
12 changed files with 117 additions and 66 deletions
|
@ -2,9 +2,9 @@
|
|||
* 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;
|
||||
|
||||
pub trait ClipboardProvider {
|
||||
// blocking method to get the clipboard contents
|
||||
|
@ -16,31 +16,16 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DummyClipboardContext {
|
||||
content: String,
|
||||
}
|
||||
|
||||
impl DummyClipboardContext {
|
||||
pub fn new(s: &str) -> DummyClipboardContext {
|
||||
DummyClipboardContext {
|
||||
content: s.to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ClipboardProvider for DummyClipboardContext {
|
||||
fn clipboard_contents(&mut self) -> String {
|
||||
self.content.clone()
|
||||
}
|
||||
fn set_clipboard_contents(&mut self, s: String) {
|
||||
self.content = s;
|
||||
self.send(ScriptMsg::ForwardToEmbedder(
|
||||
EmbedderMsg::SetClipboardContents(s),
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue