Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 883a577fd38143b914f72c971f0f45e6fc9813e6
https://github.com/WebKit/WebKit/commit/883a577fd38143b914f72c971f0f45e6fc9813e6
Author: Lily Spiniolas <[email protected]>
Date: 2026-02-04 (Wed, 04 Feb 2026)
Changed paths:
A
LayoutTests/editing/mac/context-menu/text-transformations-menu-actions-expected.txt
A
LayoutTests/editing/mac/context-menu/text-transformations-menu-actions.html
A
LayoutTests/editing/mac/context-menu/text-transformations-menu-items-expected.txt
A LayoutTests/editing/mac/context-menu/text-transformations-menu-items.html
M Source/WebCore/editing/Editor.cpp
M Source/WebCore/editing/Editor.h
M Source/WebCore/en.lproj/Localizable.strings
M Source/WebCore/loader/EmptyClients.cpp
M Source/WebCore/page/ContextMenuController.cpp
M Source/WebCore/page/ContextMenuController.h
M Source/WebCore/page/EditorClient.h
M Source/WebCore/platform/ContextMenuItem.cpp
M Source/WebCore/platform/ContextMenuItem.h
M Source/WebCore/platform/LocalizedStrings.h
M Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm
M Source/WebKit/Platform/mac/MenuUtilities.mm
M Source/WebKit/Shared/API/c/WKContextMenuItemTypes.h
M Source/WebKit/Shared/API/c/WKSharedAPICast.h
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/UIProcess/WebPageProxy.h
M Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm
M Source/WebKit/UIProcess/mac/WebViewImpl.h
M Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h
M Source/WebKit/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
M Source/WebKit/WebProcess/WebPage/WebPage.cpp
M Source/WebKit/WebProcess/WebPage/WebPage.h
M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
M Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h
M Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm
Log Message:
-----------
Add "Convert to Simplified Chinese" and "Convert to Traditional Chinese" text
transformations
https://bugs.webkit.org/show_bug.cgi?id=306845
rdar://156354464
Reviewed by Abrar Rahman Protyasha and Aditya Keerthi.
When editing text in a NSTextView, "Convert to Simplified Chinese" and
"Convert to Traditional Chinese" appears under the transformations submenu
if the items are relevant to the selected text. These items are now available
in WebKit.
Add the two context menu items and use the same heuristic AppKit uses to
determine
which transformations should actually be listed in the menu. Analyze the first
200
characters in the selection to see if Simplified Chinese characters, Traditional
Chinese characters, or latin characters are present. If the selection exceeds
200
characters, also include case-related transformations as a fallback.
Conversions are performed in the same way AppKit performs them. The selection is
converted to an NSString, and we then set the selection equal to
`stringByApplyingTransform` with a transform of either "Hans-hant" when
converting
to Traditional Chinese, or "Hant-hans" when converting to Simplified Chinese.
Tests: editing/mac/context-menu/text-transformations-menu-actions.html
editing/mac/context-menu/text-transformations-menu-items.html
*
LayoutTests/editing/mac/context-menu/text-transformations-menu-actions-expected.txt:
Added.
* LayoutTests/editing/mac/context-menu/text-transformations-menu-actions.html:
Added.
*
LayoutTests/editing/mac/context-menu/text-transformations-menu-items-expected.txt:
Added.
* LayoutTests/editing/mac/context-menu/text-transformations-menu-items.html:
Added.
* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::canApplyCaseTransformations):
(WebCore::Editor::canConvertToSimplifiedChinese):
(WebCore::Editor::canConvertToTraditionalChinese):
(WebCore::Editor::convertToTraditionalChinese):
(WebCore::Editor::convertToSimplifiedChinese):
* Source/WebCore/editing/Editor.h:
* Source/WebCore/en.lproj/Localizable.strings:
* Source/WebCore/loader/EmptyClients.cpp:
* Source/WebCore/page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected):
(WebCore::ContextMenuController::createAndAppendTransformationsSubMenu):
(WebCore::ContextMenuController::populate):
(WebCore::ContextMenuController::checkOrEnableIfNeeded const):
* Source/WebCore/page/ContextMenuController.h:
* Source/WebCore/page/EditorClient.h:
* Source/WebCore/platform/ContextMenuItem.cpp:
(WebCore::isValidContextMenuAction):
* Source/WebCore/platform/ContextMenuItem.h:
* Source/WebCore/platform/LocalizedStrings.h:
* Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm:
(WebCore::contextMenuItemTagConvertToTraditionalChinese):
(WebCore::contextMenuItemTagConvertToSimplifiedChinese):
* Source/WebKit/Platform/mac/MenuUtilities.mm:
(WebKit::symbolNameWithTypeForAction):
* Source/WebKit/Shared/API/c/WKContextMenuItemTypes.h:
* Source/WebKit/Shared/API/c/WKSharedAPICast.h:
(WebKit::toAPI):
(WebKit::toImpl):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::convertToTraditionalChinese):
(WebKit::WebPageProxy::convertToSimplifiedChinese):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::WebContextMenuProxyMac::getContextMenuItem):
* Source/WebKit/UIProcess/mac/WebViewImpl.h:
* Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h:
* Source/WebKit/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
(WebKit::applyTextTransformation):
(WebKit::WebEditorClient::uppercaseWord):
(WebKit::WebEditorClient::lowercaseWord):
(WebKit::WebEditorClient::capitalizeWord):
(WebKit::WebEditorClient::canApplyCaseTransformations):
(WebKit::WebEditorClient::canConvertToTraditionalChinese):
(WebKit::WebEditorClient::canConvertToSimplifiedChinese):
(WebKit::WebEditorClient::convertToTraditionalChinese):
(WebKit::WebEditorClient::convertToSimplifiedChinese):
(WebKit::changeWordCase): Deleted.
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::convertToTraditionalChinese):
(WebKit::WebPage::convertToSimplifiedChinese):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h:
* Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::canApplyCaseTransformations):
(WebEditorClient::canConvertToTraditionalChinese):
(WebEditorClient::canConvertToSimplifiedChinese):
(WebEditorClient::convertToTraditionalChinese):
(WebEditorClient::convertToSimplifiedChinese):
Canonical link: https://commits.webkit.org/306761@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications