-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add a feature flag to allow or disallow writing RTF to the pasteboard when copying/dragging #20880
Conversation
EWS run on previous version of this PR (hash 062a4da) |
webContent.dataInRTFDFormat = [string containsAttachments] ? dataInRTFDFormat(string.get()) : nullptr; | ||
webContent.dataInRTFFormat = dataInRTFFormat(string.get()); | ||
webContent.dataInAttributedStringFormat = archivedDataForAttributedString(string.get()); | ||
if (document->settings().writeRichTextDataWhenCopyingOrDragging()) { |
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.
this could probably be refactored into a generic function since itβs the same few lines as above, but thatβs probably overkill.
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.
It's not too unwieldy, though I'd need to pull the static dataInRTFDFormat
/ dataInRTFFormat
helpers out into the public
section so that I can use them here:
template<typename PasteboardContent>
void populateRichTextDataIfNeeded(PasteboardContent& content, const Document& document)
{
if (!document.settings().writeRichTextDataWhenCopyingOrDragging())
return;
auto string = selectionAsAttributedString(document);
content.dataInRTFDFormat = [string containsAttachments] ? Editor::dataInRTFDFormat(string.get()) : nullptr;
content.dataInRTFFormat = Editor::dataInRTFFormat(string.get());
content.dataInAttributedStringFormat = archivedDataForAttributedString(string.get());
}
Thanks for the review!
EWS run on current version of this PR (hash 984fef7) |
β¦ when copying/dragging https://bugs.webkit.org/show_bug.cgi?id=265323 rdar://118419812 Reviewed by Richard Robinson. On some Cocoa OS versions, the pasteboard will (if necessary) automatically convert HTML and web archive data written to the pasteboard to RTF, RTFD, or archived `NSAttributedString` data when pasting in an app that only consumes these native rich text formats. When this behavior is available (guarded by `HAVE(PASTEBOARD_CONVERSION_FROM_HTML_TO_RTF)`), WebKit no longer needs to eagerly write RTF, RTFD or attributed string representations of the selected text to the pasteboard when copying or dragging text, since we can defer to system support for performing this conversion on paste/drop. Make some minor adjustments to pasteboard writing logic, to make the attributed string writing part conditional on this new setting. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/editing/Editor.h: * Source/WebCore/editing/cocoa/EditorCocoa.mm: (WebCore::populateRichTextDataIfNeeded): (WebCore::Editor::writeSelectionToPasteboard): (WebCore::Editor::writeSelection): Canonical link: https://commits.webkit.org/271106@main
984fef7
to
ccdf275
Compare
Committed 271106@main (ccdf275): https://commits.webkit.org/271106@main Reviewed commits have been landed. Closing PR #20880 and removing active labels. |
ccdf275
984fef7