[GTK] Need WebKitContextMenuItemType to open emoji picker
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2019 12:39:30 +0000 (12:39 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2019 12:39:30 +0000 (12:39 +0000)
commit5418cda7a8eb720e6fb8123aef2b49321b4508a2
tree493a02f91a94a5969a849db112fda11841b7fb51
parentc42a02c419cb19fb09851f233bd2f9f515a1f3b0
[GTK] Need WebKitContextMenuItemType to open emoji picker
https://bugs.webkit.org/show_bug.cgi?id=176760

Reviewed by Michael Catanzaro.

Source/WebCore:

Add a new context menu item to insert an emoji.

* loader/EmptyClients.cpp: Empty implementation of ContextMenuClient::insertEmoji().
* page/ContextMenuClient.h: Add insertEmoji for GTK port.
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected): Handle insert emoji action.
(WebCore::ContextMenuController::populate): Add insert emoji item after select all.
(WebCore::ContextMenuController::checkOrEnableIfNeeded const): Handle insert emoji action.
* platform/ContextMenuItem.h: Add insert emoji action.
* platform/LocalizedStrings.h:
* platform/gtk/LocalizedStringsGtk.cpp:
(WebCore::contextMenuItemTagInsertEmoji):

Source/WebCore/platform/gtk/po:

* POTFILES.in: Add WebKitEmojiChooser.cpp.

Source/WebKit:

Add a default implementation to show the emoji chooser when requested by the application, either using the
context menu or keyboard shortcuts. GtkEmojiChooser is private in GTK, so we include our own copy, adapted to
the WebKit coding style. The emoji chooser is always shown by default when using GTK >= 3.24 for any editable
content. I'm going to add public API in a follow up patch to be able to use your own chooser, or even prevent
the default chooser from being shown, similar to what we do for other UI elements like file chooser, color
chooser, print dialog, etc.

* Shared/API/glib/WebKitContextMenuActions.cpp:
(webkitContextMenuActionGetActionTag): Handle insert emoji action.
(webkitContextMenuActionGetForContextMenuItem): Ditto.
(webkitContextMenuActionGetLabel): Ditto.
* SourcesGTK.txt:
* UIProcess/API/gtk/WebKitContextMenuActions.h:
* UIProcess/API/gtk/WebKitEmojiChooser.cpp: Added.
(webkitEmojiChooserAddEmoji):
(webkitEmojiChooserAddRecentItem):
(emojiActivated):
(emojiDataHasVariations):
(webkitEmojiChooserShowVariations):
(emojiLongPressed):
(emojiPressed):
(emojiPopupMenu):
(verticalAdjustmentChanged):
(webkitEmojiChooserSetupSectionBox):
(scrollToSection):
(webkitEmojiChooserSetupSectionButton):
(webkitEmojiChooserSetupRecent):
(webkitEmojiChooserEnsureEmptyResult):
(webkitEmojiChooserSearchChanged):
(webkitEmojiChooserSetupFilters):
(webkitEmojiChooserInitializeEmojiMaxWidth):
(webkitEmojiChooserConstructed):
(webkitEmojiChooserShow):
(webkit_emoji_chooser_class_init):
(webkitEmojiChooserNew):
* UIProcess/API/gtk/WebKitEmojiChooser.h: Added.
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(_WebKitWebViewBasePrivate::_WebKitWebViewBasePrivate): Add a timer to release the emoji chooser if not used
after 2 minutes.
(_WebKitWebViewBasePrivate::releaseEmojiChooserTimerFired): Destroy the emoji chooser.
(emojiChooserEmojiPicked): Complete the operation using the given emoji text.
(emojiChooserClosed): Complete the operation if needed using an empty string.
(webkitWebViewBaseShowEmojiChooser): Create the emoji chooser if needed and show it.
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/WebPageProxy.h: Add showEmojiPicker().
* UIProcess/WebPageProxy.messages.in: Add ShowEmojiPicker message.
* UIProcess/gtk/KeyBindingTranslator.cpp:
(WebKit::insertEmojiCallback): Add GtkInsertEmoji command.
(WebKit::KeyBindingTranslator::KeyBindingTranslator): Connect to insert-emoji signal.
* UIProcess/gtk/WebPageProxyGtk.cpp:
(WebKit::WebPageProxy::showEmojiPicker): Call webkitWebViewBaseShowEmojiChooser().
* WebProcess/WebCoreSupport/WebContextMenuClient.h: Override insertEmoji() for GTK port.
* WebProcess/WebCoreSupport/WebEditorClient.h: Add insertEmoji() for GTK port.
* WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp:
(WebKit::WebContextMenuClient::insertEmoji): Call WebPage::showEmojiPicker().
* WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
(WebKit::WebEditorClient::handleGtkEditorCommand): Call WebPage::showEmojiPicker() if command is GtkInsertEmoji.
(WebKit::WebEditorClient::executePendingEditorCommands): Handle Gtk specific commands.
(WebKit::WebEditorClient::handleKeyboardEvent): Use a reference instead of a pointer for Frame.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
(WebKit::WebPage::showEmojiPicker): Send ShowEmojiPicker message to the UI process.

Tools:

Update context menu test to check insert emoji action is included in default context menu for editable content.

* TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245460 268f45cc-cd09-0410-ab3c-d52691b4dbfc
29 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/page/ContextMenuClient.h
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/platform/ContextMenuItem.h
Source/WebCore/platform/LocalizedStrings.h
Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp
Source/WebCore/platform/gtk/po/ChangeLog
Source/WebCore/platform/gtk/po/POTFILES.in
Source/WebKit/ChangeLog
Source/WebKit/Shared/API/glib/WebKitContextMenuActions.cpp
Source/WebKit/SourcesGTK.txt
Source/WebKit/UIProcess/API/gtk/WebKitContextMenuActions.h
Source/WebKit/UIProcess/API/gtk/WebKitEmojiChooser.cpp [new file with mode: 0644]
Source/WebKit/UIProcess/API/gtk/WebKitEmojiChooser.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/UIProcess/gtk/KeyBindingTranslator.cpp
Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.h
Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h
Source/WebKit/WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp
Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp