-
Notifications
You must be signed in to change notification settings - Fork 15k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: clipboard.writeBuffer raw format access #31116
Conversation
💖 Thanks for opening this pull request! 💖 We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @henrit - thanks for this!
Given that the underlying functionality you're adding via patch is something Chromium removed with no intention of re-adding, the approach contained in the patch is something that we'd need to float forever. Generally speaking, we try to keep our patch count to a minimum as each adds nontrivial maintenance burden, and prefer only to add indefinite lifetime patches as a last resort.
I'd prefer we first try to see if we can avoid doing so before trying to move this PR forward (e.g. by subclassing ScopedClipboardWriter
to add the missing functionality to Electron's own source tree).
|
||
+void ScopedClipboardWriter::WriteUnsafeRawData(const std::u16string& format, | ||
+ mojo_base::BigBuffer data) { | ||
+ RecordWrite(ClipboardFormatMetric::kUnsafeRawData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chromium only uses this to record perf metrics - we can remove this and the added enum class value as we don't make use of them in Electron
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick feedback. That makes sense.
What would be a good folder to put the subclass?
Should it go next to the rest of the code in shell/common/api/
, or maybe one-level up in shell/common/
since it doesn't itself define apis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's just go with shell/common/
for now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I'm not seeing a path to subclass the chromium clipboard code into something useful.
ui::ScopedClipboardWriter keeps its reference to a ui::Clipboard subclass private, and ui::Clipboard itself keeps
all its clipboard writing methods protected, which ScopedClipboardWriter can only access because it's
marked as a friend class.
If I understand this correctly, this code shape limits us to either copying large chunks of clipboard code
into electron, or patch it on the chromium side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@henrit I looked into this and I agree with you on your assessment. Given that we would have to bring over a large amount of the the clipboard code, we should instead proceed with the patch instead. @henrit are you willing to continue working on this? If not, I'd be happy to take it over, but since it's your PR, I'd prefer to defer to you.
Looking at the PR, I think if it is rebased to resolve the conflict and perhaps cleanup the patch with @codebytere's suggestions, we can move this PR forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little tardy with this response, but FWIW I've looked into this wrt pickling and also agree with going the patch route first, since it looks like we'd need to copy a decent amount of code if we copied instead of patching.
Some of my review comments don't make sense in a patch context. Feel free to mark resolved at will.
I'm still happy to help via followup review and/or pairing if anyone wants it, whether it's @henrit or @jkleinsc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify my review from yesterday a bit -- @codebytere is right that it makes more sense to have this live as standalone code as possible instead of as a patch.
My review comments yesterday are for changes after the code is moved to a subclass, but I didn't make that explicit and looking at my comments again today I don't want to give the impression that I was asking for an updated file in .patches/
Congrats on merging your first pull request! 🎉🎉🎉 |
Release Notes Persisted
|
* fix: clipboard.writeBuffer raw format access * test: clipboard.writeBuffer raw format access * test: clipboard win32 test skip * fixup spec * cleanup patch Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
* fix: clipboard.writeBuffer raw format access * test: clipboard.writeBuffer raw format access * test: clipboard win32 test skip * fixup spec * cleanup patch Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
I have automatically backported this PR to "16-x-y", please check out #31719 |
I have automatically backported this PR to "15-x-y", please check out #31720 |
* fix: clipboard.writeBuffer raw format access * test: clipboard.writeBuffer raw format access * test: clipboard win32 test skip * fixup spec * cleanup patch Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: henrit <henrit@gmail.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
* fix: clipboard.writeBuffer raw format access (#31116) * fix: clipboard.writeBuffer raw format access * test: clipboard.writeBuffer raw format access * test: clipboard win32 test skip * fixup spec * cleanup patch Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> * fixup .patches file Co-authored-by: henrit <henrit@gmail.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
* fix: clipboard.writeBuffer raw format access * test: clipboard.writeBuffer raw format access * test: clipboard win32 test skip * fixup spec * cleanup patch Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Description of Change
This PR addresses #31115.
It includes a chromium patch to re-expose a mechanism to set raw data on the clipboard that was recently removed.
cc: @deepak1556 @ckerr
Checklist
npm test
passesRelease Notes
Notes: Fixed
clipboard.writeBuffer()
,clipboard.readBuffer()
andclipboard.read()
's ability to manipulate platform-specific clipboard formats.