Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upClipboard refactoring #23564
Clipboard refactoring #23564
Conversation
highfive
commented
Jun 13, 2019
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @emilio (or someone else) soon. |
highfive
commented
Jun 13, 2019
|
Heads up! This PR modifies the following files:
|
highfive
commented
Jun 13, 2019
|
|
Looks good! |
| @@ -2,14 +2,14 @@ | |||
| * 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/. */ | |||
|
|
|||
| extern crate clipboard; | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
If you build |
|
Sorry for the delay; last week was very busy. One last change which will allow us to provide different clipboard solutions on other platforms like android/magic leap/hololens! |
| @@ -7,6 +7,7 @@ edition = "2018" | |||
| publish = false | |||
|
|
|||
| [dependencies] | |||
| clipboard = "0.5" | |||
This comment has been minimized.
This comment has been minimized.
jdm
Jun 24, 2019
Member
Since libsimpleservo/api is a platform-agnostic embedding API, we should not add a platform-specific dependency like clipboard to it.
| @@ -516,6 +526,28 @@ impl ServoGlue { | |||
| } | |||
| self.events.push(WindowEvent::SelectBrowser(new_browser_id)); | |||
| }, | |||
| EmbedderMsg::GetClipboardContents(sender) => { | |||
| let contents = match self.clipboard_ctx { | |||
This comment has been minimized.
This comment has been minimized.
jdm
Jun 24, 2019
•
Member
Instead of directly manipulating the clipboard for the GetClipboardContents and SetClipboardContents messages, let's add new callbacks to HostTrait (get_clipboard_contents() can return an Option and set_clipboard_contents can accept a String) and call those instead. See how EmbedderMsg::HistoryChanged is handled earlier.
…and call them instead of directly handlind clipboard
|
Ok thanks for the tips @jdm :). I've removed direct handling of clipboard from I am not sure if I'm doing implementation right though?: fn get_clipboard_contents(&self) -> Option<String> {
debug!("get_clipboard_contents");
let raw_contents = (self.0.get_clipboard_contents)();
if raw_contents.is_null() {
return None;
}
let c_str = unsafe { CStr::from_ptr(raw_contents) };
let contents_str = c_str.to_str().expect("Can't create str");
Some(contents_str.to_owned())
}
fn set_clipboard_contents(&self, contents: String) {
debug!("set_clipboard_contents");
let contents = CString::new(contents).expect("Can't create string");
let contents_ptr = contents.as_ptr();
mem::forget(contents);
(self.0.set_clipboard_contents)(contents_ptr);
}I guess this two methods should call some external ( platform specific ) function for getting and setting system clipboard. This is just for |
|
For jniapi and mlservo you can leave stub implementations, unless you are familiar enough with android that you're confident about the JNI work :) |
|
@bors-servo r+ |
|
|
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 -->
|
|
|
More warnings from other platforms:
|
|
Can I build/test other platforms somehow on my Linux machine to see and fix such failures before issuing a PR? :) |
|
The jni one you could build by following https://github.com/servo/servo/wiki/Building-for-Android, but it's not necessarily worth it. You can see all of the failures from the previous build by looking at https://treeherder.allizom.org/#/jobs?repo=servo-auto . |
|
The libmlservo can only be built by people with access to the Magic Leap SDK, which is restricted to a small set of developers right now. |
|
Thanks @jdm for explanation. I've fixed the unused arguments warnings. |
|
@bors-servo r+ |
|
|
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 -->
|
|
mmiecz commentedJun 13, 2019
•
edited by jdm
This PR removes clipboard handling from the constellation. Instead, now embedder handles it.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is