[webkit-changes] [WebKit/WebKit] 8ab68c: [Mail Compose] Unable to "Copy Font" when the sele...
Wenson Hsieh
noreply at github.com
Fri Sep 23 15:54:04 PDT 2022
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8ab68c1708b90fe4e69e0f7dc1a81daaa9475f8c
https://github.com/WebKit/WebKit/commit/8ab68c1708b90fe4e69e0f7dc1a81daaa9475f8c
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2022-09-23 (Fri, 23 Sep 2022)
Changed paths:
M Source/WebCore/editing/Editor.cpp
M Source/WebCore/editing/Editor.h
M Source/WebCore/editing/EditorCommand.cpp
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEditActions.mm
Log Message:
-----------
[Mail Compose] Unable to "Copy Font" when the selection is collapsed
https://bugs.webkit.org/show_bug.cgi?id=245577
rdar://95564944
Reviewed by Devin Rousso.
Extend support for `-copyFont:` to the case where the selection is a caret in editable content. See
below for more details.
Test: WKWebViewEditActions.CopyFontAtCaretSelection
* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::copyFont):
(WebCore::Editor::canCopyFont const):
"Copy Font" (⌘⌥C on macOS) for collapsed selections in Mail compose is currently broken, due to the
fact that `Editor::copyFont` is only enabled if `Editor::canCopy` returns `true`; in turn, this is
only the case if the selection is a range.
However, unlike the other "Copy" comands, "Copy Font" is special in that it still works even if the
selection is collapsed. To fix this bug, we add a new helper, `canCopyFont()`, that returns true if
the selection is either an editable caret, or a selection range, and then make "CopyFont" command
enablement consult this helper.
* Source/WebCore/editing/Editor.h:
* Source/WebCore/editing/EditorCommand.cpp:
(WebCore::enabledCopy):
(WebCore::enabledCopyFont):
(WebCore::createCommandMap):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEditActions.mm:
Add a new API test to verify this change, by using "Copy Font" and "Paste Font" to apply a font
color to otherwise unstyled text.
Canonical link: https://commits.webkit.org/254809@main
More information about the webkit-changes
mailing list