Changeset 245460 in webkit
- Timestamp:
- May 17, 2019, 5:39:30 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 27 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/loader/EmptyClients.cpp (modified) (1 diff)
-
Source/WebCore/page/ContextMenuClient.h (modified) (1 diff)
-
Source/WebCore/page/ContextMenuController.cpp (modified) (5 diffs)
-
Source/WebCore/platform/ContextMenuItem.h (modified) (1 diff)
-
Source/WebCore/platform/LocalizedStrings.h (modified) (1 diff)
-
Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp (modified) (1 diff)
-
Source/WebCore/platform/gtk/po/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/gtk/po/POTFILES.in (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Shared/API/glib/WebKitContextMenuActions.cpp (modified) (3 diffs)
-
Source/WebKit/SourcesGTK.txt (modified) (1 diff)
-
Source/WebKit/UIProcess/API/gtk/WebKitContextMenuActions.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/gtk/WebKitEmojiChooser.cpp (added)
-
Source/WebKit/UIProcess/API/gtk/WebKitEmojiChooser.h (added)
-
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (modified) (7 diffs)
-
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.messages.in (modified) (1 diff)
-
Source/WebKit/UIProcess/gtk/KeyBindingTranslator.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.h (modified) (1 diff)
-
Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h (modified) (1 diff)
-
Source/WebKit/WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp (modified) (4 diffs)
-
Source/WebKit/WebProcess/WebPage/WebPage.h (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r245429 r245460 1 2019-05-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Need WebKitContextMenuItemType to open emoji picker 4 https://bugs.webkit.org/show_bug.cgi?id=176760 5 6 Reviewed by Michael Catanzaro. 7 8 Add a new context menu item to insert an emoji. 9 10 * loader/EmptyClients.cpp: Empty implementation of ContextMenuClient::insertEmoji(). 11 * page/ContextMenuClient.h: Add insertEmoji for GTK port. 12 * page/ContextMenuController.cpp: 13 (WebCore::ContextMenuController::contextMenuItemSelected): Handle insert emoji action. 14 (WebCore::ContextMenuController::populate): Add insert emoji item after select all. 15 (WebCore::ContextMenuController::checkOrEnableIfNeeded const): Handle insert emoji action. 16 * platform/ContextMenuItem.h: Add insert emoji action. 17 * platform/LocalizedStrings.h: 18 * platform/gtk/LocalizedStringsGtk.cpp: 19 (WebCore::contextMenuItemTagInsertEmoji): 20 1 21 2019-05-16 Greg Doolittle <gr3g@apple.com> 2 22 -
trunk/Source/WebCore/loader/EmptyClients.cpp
r244932 r245460 110 110 #endif 111 111 112 #if PLATFORM(GTK) 113 void insertEmoji(Frame&) final { } 114 #endif 115 112 116 #if USE(ACCESSIBILITY_CONTEXT_MENUS) 113 117 void showContextMenu() final { } -
trunk/Source/WebCore/page/ContextMenuClient.h
r238771 r245460 50 50 #endif 51 51 52 #if PLATFORM(GTK) 53 virtual void insertEmoji(Frame&) = 0; 54 #endif 55 52 56 #if USE(ACCESSIBILITY_CONTEXT_MENUS) 53 57 virtual void showContextMenu() = 0; -
trunk/Source/WebCore/page/ContextMenuController.cpp
r242749 r245460 358 358 insertUnicodeCharacter(zeroWidthNonJoiner, *frame); 359 359 break; 360 #endif361 #if PLATFORM(GTK)362 360 case ContextMenuItemTagSelectAll: 363 361 frame->editor().command("SelectAll").execute(); 362 break; 363 case ContextMenuItemTagInsertEmoji: 364 m_client.insertEmoji(*frame); 364 365 break; 365 366 #endif … … 812 813 #if PLATFORM(GTK) 813 814 ContextMenuItem DeleteItem(ActionType, ContextMenuItemTagDelete, contextMenuItemTagDelete()); 814 #endif815 #if PLATFORM(GTK)816 815 ContextMenuItem SelectAllItem(ActionType, ContextMenuItemTagSelectAll, contextMenuItemTagSelectAll()); 816 ContextMenuItem InsertEmojiItem(ActionType, ContextMenuItemTagInsertEmoji, contextMenuItemTagInsertEmoji()); 817 817 #endif 818 818 … … 1050 1050 appendItem(DeleteItem, m_contextMenu.get()); 1051 1051 appendItem(*separatorItem(), m_contextMenu.get()); 1052 #endif1053 #if PLATFORM(GTK)1054 1052 appendItem(SelectAllItem, m_contextMenu.get()); 1053 appendItem(InsertEmojiItem, m_contextMenu.get()); 1055 1054 #endif 1056 1055 … … 1207 1206 shouldEnable = frame->editor().canDelete(); 1208 1207 break; 1208 case ContextMenuItemTagInsertEmoji: 1209 shouldEnable = frame->editor().canEdit(); 1210 break; 1211 case ContextMenuItemTagSelectAll: 1209 1212 case ContextMenuItemTagInputMethods: 1210 1213 case ContextMenuItemTagUnicode: … … 1219 1222 case ContextMenuItemTagUnicodeInsertZWJMark: 1220 1223 case ContextMenuItemTagUnicodeInsertZWNJMark: 1221 shouldEnable = true;1222 break;1223 #endif1224 #if PLATFORM(GTK)1225 case ContextMenuItemTagSelectAll:1226 1224 shouldEnable = true; 1227 1225 break; -
trunk/Source/WebCore/platform/ContextMenuItem.h
r238771 r245460 69 69 ContextMenuItemTagUnicodeInsertZWJMark, 70 70 ContextMenuItemTagUnicodeInsertZWNJMark, 71 ContextMenuItemTagInsertEmoji, 71 72 #endif 72 73 ContextMenuItemTagSpellingGuess, -
trunk/Source/WebCore/platform/LocalizedStrings.h
r244404 r245460 84 84 String contextMenuItemTagUnicodeInsertZWJMark(); 85 85 String contextMenuItemTagUnicodeInsertZWNJMark(); 86 #endif87 #if PLATFORM(GTK)88 86 String contextMenuItemTagSelectAll(); 87 String contextMenuItemTagInsertEmoji(); 89 88 #endif 90 89 String contextMenuItemTagNoGuessesFound(); -
trunk/Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp
r238406 r245460 99 99 } 100 100 101 String contextMenuItemTagInsertEmoji() 102 { 103 return String::fromUTF8(_("Insert _Emoji")); 104 } 105 101 106 String contextMenuItemTagUnicode() 102 107 { -
trunk/Source/WebCore/platform/gtk/po/ChangeLog
r244805 r245460 1 2019-05-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Need WebKitContextMenuItemType to open emoji picker 4 https://bugs.webkit.org/show_bug.cgi?id=176760 5 6 Reviewed by Michael Catanzaro. 7 8 * POTFILES.in: Add WebKitEmojiChooser.cpp. 9 1 10 2019-04-30 Álvaro Torralba <donfrutosgomez@gmail.com> 2 11 -
trunk/Source/WebCore/platform/gtk/po/POTFILES.in
r243409 r245460 32 32 ../../../WebKit/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp 33 33 ../../../WebKit/UIProcess/API/gtk/WebKitColorChooserRequest.cpp 34 ../../../WebKit/UIProcess/API/gtk/WebKitEmojiChooser.cpp 34 35 ../../../WebKit/UIProcess/API/gtk/WebKitPrintCustomWidget.cpp 35 36 ../../../WebKit/UIProcess/API/gtk/WebKitPrintOperation.cpp -
trunk/Source/WebKit/ChangeLog
r245427 r245460 1 2019-05-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Need WebKitContextMenuItemType to open emoji picker 4 https://bugs.webkit.org/show_bug.cgi?id=176760 5 6 Reviewed by Michael Catanzaro. 7 8 Add a default implementation to show the emoji chooser when requested by the application, either using the 9 context menu or keyboard shortcuts. GtkEmojiChooser is private in GTK, so we include our own copy, adapted to 10 the WebKit coding style. The emoji chooser is always shown by default when using GTK >= 3.24 for any editable 11 content. I'm going to add public API in a follow up patch to be able to use your own chooser, or even prevent 12 the default chooser from being shown, similar to what we do for other UI elements like file chooser, color 13 chooser, print dialog, etc. 14 15 * Shared/API/glib/WebKitContextMenuActions.cpp: 16 (webkitContextMenuActionGetActionTag): Handle insert emoji action. 17 (webkitContextMenuActionGetForContextMenuItem): Ditto. 18 (webkitContextMenuActionGetLabel): Ditto. 19 * SourcesGTK.txt: 20 * UIProcess/API/gtk/WebKitContextMenuActions.h: 21 * UIProcess/API/gtk/WebKitEmojiChooser.cpp: Added. 22 (webkitEmojiChooserAddEmoji): 23 (webkitEmojiChooserAddRecentItem): 24 (emojiActivated): 25 (emojiDataHasVariations): 26 (webkitEmojiChooserShowVariations): 27 (emojiLongPressed): 28 (emojiPressed): 29 (emojiPopupMenu): 30 (verticalAdjustmentChanged): 31 (webkitEmojiChooserSetupSectionBox): 32 (scrollToSection): 33 (webkitEmojiChooserSetupSectionButton): 34 (webkitEmojiChooserSetupRecent): 35 (webkitEmojiChooserEnsureEmptyResult): 36 (webkitEmojiChooserSearchChanged): 37 (webkitEmojiChooserSetupFilters): 38 (webkitEmojiChooserInitializeEmojiMaxWidth): 39 (webkitEmojiChooserConstructed): 40 (webkitEmojiChooserShow): 41 (webkit_emoji_chooser_class_init): 42 (webkitEmojiChooserNew): 43 * UIProcess/API/gtk/WebKitEmojiChooser.h: Added. 44 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 45 (_WebKitWebViewBasePrivate::_WebKitWebViewBasePrivate): Add a timer to release the emoji chooser if not used 46 after 2 minutes. 47 (_WebKitWebViewBasePrivate::releaseEmojiChooserTimerFired): Destroy the emoji chooser. 48 (emojiChooserEmojiPicked): Complete the operation using the given emoji text. 49 (emojiChooserClosed): Complete the operation if needed using an empty string. 50 (webkitWebViewBaseShowEmojiChooser): Create the emoji chooser if needed and show it. 51 * UIProcess/API/gtk/WebKitWebViewBasePrivate.h: 52 * UIProcess/WebPageProxy.h: Add showEmojiPicker(). 53 * UIProcess/WebPageProxy.messages.in: Add ShowEmojiPicker message. 54 * UIProcess/gtk/KeyBindingTranslator.cpp: 55 (WebKit::insertEmojiCallback): Add GtkInsertEmoji command. 56 (WebKit::KeyBindingTranslator::KeyBindingTranslator): Connect to insert-emoji signal. 57 * UIProcess/gtk/WebPageProxyGtk.cpp: 58 (WebKit::WebPageProxy::showEmojiPicker): Call webkitWebViewBaseShowEmojiChooser(). 59 * WebProcess/WebCoreSupport/WebContextMenuClient.h: Override insertEmoji() for GTK port. 60 * WebProcess/WebCoreSupport/WebEditorClient.h: Add insertEmoji() for GTK port. 61 * WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp: 62 (WebKit::WebContextMenuClient::insertEmoji): Call WebPage::showEmojiPicker(). 63 * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp: 64 (WebKit::WebEditorClient::handleGtkEditorCommand): Call WebPage::showEmojiPicker() if command is GtkInsertEmoji. 65 (WebKit::WebEditorClient::executePendingEditorCommands): Handle Gtk specific commands. 66 (WebKit::WebEditorClient::handleKeyboardEvent): Use a reference instead of a pointer for Frame. 67 * WebProcess/WebPage/WebPage.h: 68 * WebProcess/WebPage/gtk/WebPageGtk.cpp: 69 (WebKit::WebPage::showEmojiPicker): Send ShowEmojiPicker message to the UI process. 70 1 71 2019-05-16 John Wilander <wilander@apple.com> 2 72 -
trunk/Source/WebKit/Shared/API/glib/WebKitContextMenuActions.cpp
r218553 r245460 84 84 case WEBKIT_CONTEXT_MENU_ACTION_SELECT_ALL: 85 85 return ContextMenuItemTagSelectAll; 86 case WEBKIT_CONTEXT_MENU_ACTION_INSERT_EMOJI: 87 return ContextMenuItemTagInsertEmoji; 86 88 case WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS: 87 89 return ContextMenuItemTagInputMethods; … … 184 186 case ContextMenuItemTagSelectAll: 185 187 return WEBKIT_CONTEXT_MENU_ACTION_SELECT_ALL; 188 case ContextMenuItemTagInsertEmoji: 189 return WEBKIT_CONTEXT_MENU_ACTION_INSERT_EMOJI; 186 190 case ContextMenuItemTagInputMethods: 187 191 return WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS; … … 282 286 case WEBKIT_CONTEXT_MENU_ACTION_SELECT_ALL: 283 287 return contextMenuItemTagSelectAll(); 288 case WEBKIT_CONTEXT_MENU_ACTION_INSERT_EMOJI: 289 return contextMenuItemTagInsertEmoji(); 284 290 case WEBKIT_CONTEXT_MENU_ACTION_INPUT_METHODS: 285 291 return contextMenuItemTagInputMethods(); -
trunk/Source/WebKit/SourcesGTK.txt
r245241 r245460 190 190 UIProcess/API/gtk/WebKitColorChooser.cpp @no-unify 191 191 UIProcess/API/gtk/WebKitColorChooserRequest.cpp @no-unify 192 UIProcess/API/gtk/WebKitEmojiChooser.cpp @no-unify 192 193 UIProcess/API/gtk/WebKitOptionMenu.cpp @no-unify 193 194 UIProcess/API/gtk/WebKitOptionMenuItem.cpp @no-unify -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitContextMenuActions.h
r213703 r245460 75 75 * @WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_VIDEO_TO_DISK: Download video to disk. Since 2.2 76 76 * @WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_AUDIO_TO_DISK: Download audio to disk. Since 2.2 77 * @WEBKIT_CONTEXT_MENU_ACTION_INSERT_EMOJI: Insert an emoji. Since 2.26 77 78 * @WEBKIT_CONTEXT_MENU_ACTION_CUSTOM: Custom action defined by applications. 78 79 * … … 126 127 WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_VIDEO_TO_DISK, 127 128 WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_AUDIO_TO_DISK, 129 WEBKIT_CONTEXT_MENU_ACTION_INSERT_EMOJI, 128 130 129 131 WEBKIT_CONTEXT_MENU_ACTION_CUSTOM = 10000 -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
r245065 r245460 43 43 #include "WebInspectorProxy.h" 44 44 #include "WebKit2Initialize.h" 45 #include "WebKitEmojiChooser.h" 45 46 #include "WebKitWebViewBaseAccessible.h" 46 47 #include "WebKitWebViewBasePrivate.h" … … 68 69 #include <wtf/HashMap.h> 69 70 #include <wtf/glib/GRefPtr.h> 71 #include <wtf/glib/RunLoopSourcePriority.h> 70 72 #include <wtf/glib/WTFGType.h> 71 73 #include <wtf/text/CString.h> … … 148 150 _WebKitWebViewBasePrivate() 149 151 : updateActivityStateTimer(RunLoop::main(), this, &_WebKitWebViewBasePrivate::updateActivityStateTimerFired) 152 #if GTK_CHECK_VERSION(3, 24, 0) 153 , releaseEmojiChooserTimer(RunLoop::main(), this, &_WebKitWebViewBasePrivate::releaseEmojiChooserTimerFired) 154 #endif 150 155 { 156 #if GTK_CHECK_VERSION(3, 24, 0) 157 releaseEmojiChooserTimer.setPriority(RunLoopSourcePriority::ReleaseUnusedResourcesTimer); 158 #endif 151 159 } 152 160 … … 158 166 activityStateFlagsToUpdate = { }; 159 167 } 168 169 #if GTK_CHECK_VERSION(3, 24, 0) 170 void releaseEmojiChooserTimerFired() 171 { 172 if (emojiChooser) { 173 gtk_widget_destroy(emojiChooser); 174 emojiChooser = nullptr; 175 } 176 } 177 #endif 160 178 161 179 WebKitWebViewChildrenMap children; … … 208 226 std::unique_ptr<ViewGestureController> viewGestureController; 209 227 bool isBackForwardNavigationGestureEnabled { false }; 228 229 #if GTK_CHECK_VERSION(3, 24, 0) 230 GtkWidget* emojiChooser; 231 CompletionHandler<void(String)> emojiChooserCompletionHandler; 232 RunLoop::Timer<WebKitWebViewBasePrivate> releaseEmojiChooserTimer; 233 #endif 210 234 }; 211 235 … … 526 550 } 527 551 552 #if GTK_CHECK_VERSION(3, 24, 0) 553 static void webkitWebViewBaseCompleteEmojiChooserRequest(WebKitWebViewBase* webView, const String& text) 554 { 555 if (auto completionHandler = std::exchange(webView->priv->emojiChooserCompletionHandler, nullptr)) 556 completionHandler(text); 557 } 558 #endif 559 528 560 static void webkitWebViewBaseDispose(GObject* gobject) 529 561 { 530 562 WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(gobject); 531 563 webkitWebViewBaseSetToplevelOnScreenWindow(webView, nullptr); 564 #if GTK_CHECK_VERSION(3, 24, 0) 565 webkitWebViewBaseCompleteEmojiChooserRequest(webView, emptyString()); 566 #endif 532 567 webView->priv->pageProxy->close(); 533 568 webView->priv->acceleratedBackingStore = nullptr; … … 1755 1790 webkitWebViewBase->priv->viewGestureController->didRestoreScrollPosition(); 1756 1791 } 1792 1793 #if GTK_CHECK_VERSION(3, 24, 0) 1794 static void emojiChooserEmojiPicked(WebKitWebViewBase* webkitWebViewBase, const char* text) 1795 { 1796 webkitWebViewBaseCompleteEmojiChooserRequest(webkitWebViewBase, String::fromUTF8(text)); 1797 } 1798 1799 static void emojiChooserClosed(WebKitWebViewBase* webkitWebViewBase) 1800 { 1801 webkitWebViewBaseCompleteEmojiChooserRequest(webkitWebViewBase, emptyString()); 1802 webkitWebViewBase->priv->releaseEmojiChooserTimer.startOneShot(2_min); 1803 } 1804 #endif 1805 1806 void webkitWebViewBaseShowEmojiChooser(WebKitWebViewBase* webkitWebViewBase, const IntRect& caretRect, CompletionHandler<void(String)>&& completionHandler) 1807 { 1808 #if GTK_CHECK_VERSION(3, 24, 0) 1809 WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv; 1810 priv->releaseEmojiChooserTimer.stop(); 1811 1812 if (!priv->emojiChooser) { 1813 priv->emojiChooser = webkitEmojiChooserNew(); 1814 g_signal_connect_swapped(priv->emojiChooser, "emoji-picked", G_CALLBACK(emojiChooserEmojiPicked), webkitWebViewBase); 1815 g_signal_connect_swapped(priv->emojiChooser, "closed", G_CALLBACK(emojiChooserClosed), webkitWebViewBase); 1816 gtk_popover_set_relative_to(GTK_POPOVER(priv->emojiChooser), GTK_WIDGET(webkitWebViewBase)); 1817 } 1818 1819 priv->emojiChooserCompletionHandler = WTFMove(completionHandler); 1820 1821 GdkRectangle gdkCaretRect = caretRect; 1822 gtk_popover_set_pointing_to(GTK_POPOVER(priv->emojiChooser), &gdkCaretRect); 1823 gtk_popover_popup(GTK_POPOVER(priv->emojiChooser)); 1824 #else 1825 UNUSED_PARAM(webkitWebViewBase); 1826 UNUSED_PARAM(caretRect); 1827 completionHandler(emptyString()); 1828 #endif 1829 } -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
r244744 r245460 94 94 void webkitWebViewBaseDidSameDocumentNavigationForMainFrame(WebKitWebViewBase*, WebKit::SameDocumentNavigationType); 95 95 void webkitWebViewBaseDidRestoreScrollPosition(WebKitWebViewBase*); 96 97 void webkitWebViewBaseShowEmojiChooser(WebKitWebViewBase*, const WebCore::IntRect&, CompletionHandler<void(String)>&&); -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r245335 r245460 1775 1775 void getEditorCommandsForKeyEvent(const AtomicString&, Vector<String>&); 1776 1776 void bindAccessibilityTree(const String&); 1777 void showEmojiPicker(const WebCore::IntRect&, CompletionHandler<void(String)>&&); 1777 1778 #endif 1778 1779 -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r244633 r245460 564 564 565 565 ConfigureLoggingChannel(String channelName, enum:uint8_t WTFLogChannelState state, enum:uint8_t WTFLogLevel level) 566 567 #if PLATFORM(GTK) 568 ShowEmojiPicker(WebCore::IntRect caretRect) -> (String result) Async 569 #endif 566 570 } -
trunk/Source/WebKit/UIProcess/gtk/KeyBindingTranslator.cpp
r194496 r245460 60 60 translator->addPendingEditorCommand("OverWrite"); 61 61 } 62 63 #if GTK_CHECK_VERSION(3, 24, 0) 64 static void insertEmojiCallback(GtkWidget* widget, KeyBindingTranslator* translator) 65 { 66 g_signal_stop_emission_by_name(widget, "insert-emoji"); 67 translator->addPendingEditorCommand("GtkInsertEmoji"); 68 } 69 #endif 62 70 63 71 // GTK+ will still send these signals to the web view. So we can safely stop signal … … 174 182 g_signal_connect(m_nativeWidget.get(), "popup-menu", G_CALLBACK(popupMenuCallback), this); 175 183 g_signal_connect(m_nativeWidget.get(), "show-help", G_CALLBACK(showHelpCallback), this); 184 #if GTK_CHECK_VERSION(3, 24, 0) 185 g_signal_connect(m_nativeWidget.get(), "insert-emoji", G_CALLBACK(insertEmojiCallback), this); 186 #endif 176 187 } 177 188 -
trunk/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp
r244897 r245460 164 164 } 165 165 166 void WebPageProxy::showEmojiPicker(const WebCore::IntRect& caretRect, CompletionHandler<void(String)>&& completionHandler) 167 { 168 webkitWebViewBaseShowEmojiChooser(WEBKIT_WEB_VIEW_BASE(viewWidget()), caretRect, WTFMove(completionHandler)); 169 } 170 166 171 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.h
r238771 r245460 56 56 #endif 57 57 58 #if PLATFORM(GTK) 59 void insertEmoji(WebCore::Frame&) override; 60 #endif 61 58 62 #if USE(ACCESSIBILITY_CONTEXT_MENUS) 59 63 void showContextMenu() override; -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h
r244932 r245460 141 141 142 142 #if PLATFORM(GTK) 143 bool executePendingEditorCommands(WebCore::Frame*, const Vector<WTF::String>&, bool); 143 bool executePendingEditorCommands(WebCore::Frame&, const Vector<WTF::String>&, bool); 144 bool handleGtkEditorCommand(WebCore::Frame&, const String& command, bool); 144 145 void getEditorCommandsForKeyEvent(const WebCore::KeyboardEvent*, Vector<WTF::String>&); 145 146 void updateGlobalSelection(WebCore::Frame*); -
trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp
r228373 r245460 30 30 #if ENABLE(CONTEXT_MENUS) 31 31 32 #include "WebPage.h" 32 33 #include <WebCore/NotImplemented.h> 33 34 … … 56 57 } 57 58 59 void WebContextMenuClient::insertEmoji(Frame& frame) 60 { 61 m_page->showEmojiPicker(frame); 62 } 63 58 64 } // namespace WebKit 59 65 #endif // ENABLE(CONTEXT_MENUS) -
trunk/Source/WebKit/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
r244932 r245460 29 29 #include <WebCore/PlatformKeyboardEvent.h> 30 30 #include <WebCore/markup.h> 31 #include <wtf/Variant.h> 31 32 #include <wtf/glib/GRefPtr.h> 32 33 … … 34 35 using namespace WebCore; 35 36 36 bool WebEditorClient:: executePendingEditorCommands(Frame* frame, const Vector<WTF::String>& pendingEditorCommands, bool allowTextInsertion)37 bool WebEditorClient::handleGtkEditorCommand(Frame& frame, const String& command, bool allowTextInsertion) 37 38 { 38 Vector<Editor::Command> commands; 39 for (auto& commandString : pendingEditorCommands) { 40 Editor::Command command = frame->editor().command(commandString); 41 if (command.isTextInsertion() && !allowTextInsertion) 39 if (command == "GtkInsertEmoji"_s) { 40 if (!allowTextInsertion) 42 41 return false; 43 44 commands.append(WTFMove(command));42 m_page->showEmojiPicker(frame); 43 return true; 45 44 } 46 45 47 for (auto& command : commands) { 48 if (!command.execute()) 49 return false; 46 return false; 47 } 48 49 bool WebEditorClient::executePendingEditorCommands(Frame& frame, const Vector<WTF::String>& pendingEditorCommands, bool allowTextInsertion) 50 { 51 Vector<Variant<Editor::Command, String>> commands; 52 for (auto& commandString : pendingEditorCommands) { 53 if (commandString.startsWith("Gtk")) 54 commands.append(commandString); 55 else { 56 Editor::Command command = frame.editor().command(commandString); 57 if (command.isTextInsertion() && !allowTextInsertion) 58 return false; 59 60 commands.append(WTFMove(command)); 61 } 62 } 63 64 for (auto& commandVariant : commands) { 65 if (WTF::holds_alternative<String>(commandVariant)) { 66 if (!handleGtkEditorCommand(frame, WTF::get<String>(commandVariant), allowTextInsertion)) 67 return false; 68 } else { 69 auto& command = WTF::get<Editor::Command>(commandVariant); 70 if (!command.execute()) 71 return false; 72 } 50 73 } 51 74 … … 74 97 // through the DOM first. 75 98 if (platformEvent->type() == PlatformEvent::RawKeyDown) { 76 if (executePendingEditorCommands( frame, pendingEditorCommands, false))99 if (executePendingEditorCommands(*frame, pendingEditorCommands, false)) 77 100 event.setDefaultHandled(); 78 101 … … 81 104 82 105 // Only allow text insertion commands if the current node is editable. 83 if (executePendingEditorCommands( frame, pendingEditorCommands, frame->editor().canEdit())) {106 if (executePendingEditorCommands(*frame, pendingEditorCommands, frame->editor().canEdit())) { 84 107 event.setDefaultHandled(); 85 108 return; -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r245366 r245460 764 764 765 765 void collapseSelectionInFrame(uint64_t frameID); 766 void showEmojiPicker(WebCore::Frame&); 766 767 #endif 767 768 -
trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp
r245072 r245460 196 196 } 197 197 198 void WebPage::showEmojiPicker(Frame& frame) 199 { 200 CompletionHandler<void(String)> completionHandler = [frame = makeRef(frame)](String result) { 201 if (!result.isEmpty()) 202 frame->editor().insertText(result, nullptr); 203 }; 204 sendWithAsyncReply(Messages::WebPageProxy::ShowEmojiPicker(frame.selection().absoluteCaretBounds()), WTFMove(completionHandler)); 205 } 206 198 207 void WebPage::effectiveAppearanceDidChange(bool useDarkAppearance, bool useInactiveAppearance) 199 208 { -
trunk/Tools/ChangeLog
r245433 r245460 1 2019-05-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Need WebKitContextMenuItemType to open emoji picker 4 https://bugs.webkit.org/show_bug.cgi?id=176760 5 6 Reviewed by Michael Catanzaro. 7 8 Update context menu test to check insert emoji action is included in default context menu for editable content. 9 10 * TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp: 11 1 12 2019-05-16 Aakash Jain <aakash_jain@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp
r239772 r245460 403 403 iter = checkCurrentItemIsSeparatorAndGetNext(iter); 404 404 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_SELECT_ALL, Visible | Enabled); 405 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_INSERT_EMOJI, Visible | Enabled); 405 406 iter = checkCurrentItemIsSeparatorAndGetNext(iter); 406 407 iter = checkCurrentItemIsStockActionAndGetNext(iter, WEBKIT_CONTEXT_MENU_ACTION_UNICODE, Visible | Enabled);
Note:
See TracChangeset
for help on using the changeset viewer.