Changeset 213278 in webkit
- Timestamp:
- Mar 2, 2017 6:20:47 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r213277 r213278 1 2017-03-02 Tomas Popela <tpopela@redhat.com> 2 3 [WK2] Keyboard menu key should show context menu 4 https://bugs.webkit.org/show_bug.cgi?id=72099 5 6 Reviewed by Carlos Garcia Campos. 7 8 Skip the fast/events/context-activated-by-key-event.html on Mac as it 9 does not have a key to activate the context menu and on iOS as well. 10 11 * platform/ios-simulator-wk2/TestExpectations: 12 * platform/mac-wk2/TestExpectations: 13 * platform/mac/TestExpectations: 14 1 15 2017-03-02 Javier Fernandez <jfernandez@igalia.com> 2 16 -
trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations
r213253 r213278 1917 1917 1918 1918 imported/w3c/web-platform-tests/webrtc [ Skip ] 1919 1920 # Skipped because there is no key to show the context menu 1921 fast/events/context-activated-by-key-event.html [ Skip ] -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r213156 r213278 639 639 webkit.org/b/168391 [ ElCapitan Debug ] storage/indexeddb/modern/idbcursor-continue-primary-key-1.html [ Pass Timeout ] 640 640 641 641 642 webkit.org/b/168380 [ ElCapitan Debug ] imported/w3c/web-platform-tests/IndexedDB/idb-binary-key-roundtrip.htm [ Pass Failure ] 643 644 # Skipped because Mac doesn't have a key to show the context menu 645 fast/events/context-activated-by-key-event.html [ Skip ] -
trunk/LayoutTests/platform/mac/TestExpectations
r213254 r213278 1551 1551 1552 1552 webkit.org/b/168927 fast/dom/timer-throttling-hidden-page.html [ Pass Failure ] 1553 1554 # Skipped because Mac doesn't have a key to show the context menu 1555 fast/events/context-activated-by-key-event.html [ Skip ] -
trunk/Source/WebCore/ChangeLog
r213276 r213278 1 2017-03-02 Tomas Popela <tpopela@redhat.com> 2 3 [WK2] Keyboard menu key should show context menu 4 https://bugs.webkit.org/show_bug.cgi?id=72099 5 6 Reviewed by Carlos Garcia Campos. 7 8 Show the context menu when the GtkWidget::popup-menu signal is 9 emitted. This signal is triggered by pressing a key (usually 10 the Menu key or the Shift + F10 shortcut) or it could be emitted on 11 WebKitWebView. 12 13 Test: fast/events/context-activated-by-key-event.html 14 15 Also could be tested by: 16 17 ManualTests/keyboard-menukey-event.html 18 ManualTests/win/contextmenu-key.html 19 ManualTests/win/contextmenu-key2.html 20 21 * page/EventHandler.cpp: 22 (WebCore::EventHandler::sendContextMenuEventForKey): 23 Correctly send the mouse event that used for showing the context menu. 24 Previously the event was immediately dispatched as it is, but this was 25 only the right way if some element was focused on the page. If there 26 was no focused element or non-empty text range then the event lacked 27 the right node, where it was supposed to be shown. The correct node 28 is determined and added to the event in the sendContextMenuEvent() so 29 we have to use this function to send the event. 30 31 Also use absoluteBoundingBoxRect() instead of 32 pixelSnappedAbsoluteClippedOverflowRect() when determining 33 a coordinate where to show the context menu for the currently focus 34 element. The latter is not returning a right box (it is bigger) which 35 could lead to the situation that no menu will be displayed at all, 36 because the HitTest won't contain the right element as the 37 determined coordinates could be outside of the element. 38 * page/EventHandler.h: 39 1 40 2017-03-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 41 -
trunk/Source/WebCore/page/EventHandler.cpp
r212484 r213278 2900 2900 if (!box) 2901 2901 return false; 2902 IntRect clippedRect = box->pixelSnappedAbsoluteClippedOverflowRect(); 2903 location = IntPoint(clippedRect.x(), clippedRect.maxY() - 1); 2902 2903 IntRect boundingBoxRect = box->absoluteBoundingBoxRect(true); 2904 location = IntPoint(boundingBoxRect.x(), boundingBoxRect.maxY() - 1); 2904 2905 } else { 2905 2906 location = IntPoint( … … 2933 2934 PlatformMouseEvent platformMouseEvent(position, globalPosition, RightButton, eventType, 1, false, false, false, false, WTF::currentTime(), ForceAtClick, NoTap); 2934 2935 2935 return !dispatchMouseEvent(eventNames().contextmenuEvent, targetNode, true, 0, platformMouseEvent, false);2936 return sendContextMenuEvent(platformMouseEvent); 2936 2937 } 2937 2938 #endif // ENABLE(CONTEXT_MENUS) -
trunk/Source/WebCore/page/EventHandler.h
r212476 r213278 235 235 #if ENABLE(CONTEXT_MENUS) 236 236 WEBCORE_EXPORT bool sendContextMenuEvent(const PlatformMouseEvent&); 237 bool sendContextMenuEventForKey();237 WEBCORE_EXPORT bool sendContextMenuEventForKey(); 238 238 #endif 239 239 -
trunk/Source/WebKit2/ChangeLog
r213272 r213278 1 2017-03-02 Tomas Popela <tpopela@redhat.com> 2 3 [WK2] Keyboard menu key should show context menu 4 https://bugs.webkit.org/show_bug.cgi?id=72099 5 6 Reviewed by Carlos Garcia Campos. 7 8 Show the context menu when the GtkWidget::popup-menu signal is 9 emitted. This signal is triggered by pressing a key (usually 10 the Menu key or the Shift + F10 shortcut) or it could be emitted on 11 WebKitWebView. 12 13 * UIProcess/API/gtk/WebKitWebView.cpp: 14 (webkit_web_view_class_init): 15 (webkit_web_view_class_init): Update the documentation for the 16 context-menu signal 17 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 18 (webkitWebViewBasePopupMenu): Connect to the popup-menu signal and 19 save the event that was used to trigger the signal. If there is no 20 such event create a new GdkEvent with GDK_NOTHING type. 21 (webkitWebViewBasePopupMenu): 22 (webkit_web_view_base_class_init): 23 * UIProcess/WebPageProxy.cpp: 24 (WebKit::WebPageProxy::handleContextMenuKeyEvent): 25 * UIProcess/WebPageProxy.h: 26 * WebProcess/WebPage/WebPage.cpp: 27 (WebKit::WebPage::contextMenuForKeyEvent): 28 * WebProcess/WebPage/WebPage.h: 29 * WebProcess/WebPage/WebPage.messages.in: 30 1 31 2017-03-01 Wenson Hsieh <wenson_hsieh@apple.com> 2 32 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r212345 r213278 1617 1617 * </itemizedlist> 1618 1618 * 1619 * The @event is expected to be one of the following types: 1620 * <itemizedlist> 1621 * <listitem><para> 1622 * a #GdkEventButton of type %GDK_BUTTON_PRESS when the context menu 1623 * was triggered with mouse. 1624 * <listitem><para> 1625 * a #GdkEventKey of type %GDK_KEY_PRESS if the keyboard was used to show 1626 * the menu. 1627 * </para></listitem> 1628 * <listitem><para> 1629 * a generic #GdkEvent of type %GDK_NOTHING when the #GtkWidget:popup-menu 1630 * signal was used to show the context menu. 1631 * </para></listitem> 1632 * </itemizedlist> 1633 * 1619 1634 * If the signal handler returns %FALSE the context menu represented by @context_menu 1620 1635 * will be shown, if it return %TRUE the context menu will not be shown. -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
r211669 r213278 808 808 } 809 809 810 static gboolean webkitWebViewBasePopupMenu(GtkWidget* widget) 811 { 812 WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); 813 WebKitWebViewBasePrivate* priv = webViewBase->priv; 814 815 GdkEvent* currentEvent = gtk_get_current_event(); 816 if (!currentEvent) 817 currentEvent = gdk_event_new(GDK_NOTHING); 818 priv->contextMenuEvent.reset(currentEvent); 819 priv->pageProxy->handleContextMenuKeyEvent(); 820 821 return TRUE; 822 } 823 810 824 static gboolean webkitWebViewBaseMotionNotifyEvent(GtkWidget* widget, GdkEventMotion* event) 811 825 { … … 1122 1136 widgetClass->button_release_event = webkitWebViewBaseButtonReleaseEvent; 1123 1137 widgetClass->scroll_event = webkitWebViewBaseScrollEvent; 1138 widgetClass->popup_menu = webkitWebViewBasePopupMenu; 1124 1139 widgetClass->motion_notify_event = webkitWebViewBaseMotionNotifyEvent; 1125 1140 widgetClass->enter_notify_event = webkitWebViewBaseCrossingNotifyEvent; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r213168 r213278 4655 4655 m_process->send(Messages::WebPage::DidSelectItemFromActiveContextMenu(item), m_pageID); 4656 4656 } 4657 4658 void WebPageProxy::handleContextMenuKeyEvent() 4659 { 4660 m_process->send(Messages::WebPage::ContextMenuForKeyEvent(), m_pageID); 4661 } 4657 4662 #endif // ENABLE(CONTEXT_MENUS) 4658 4663 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r213036 r213278 898 898 // Called by the WebContextMenuProxy. 899 899 void contextMenuItemSelected(const WebContextMenuItemData&); 900 void handleContextMenuKeyEvent(); 900 901 #endif 901 902 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r212776 r213278 2202 2202 return handled; 2203 2203 } 2204 2205 void WebPage::contextMenuForKeyEvent() 2206 { 2207 corePage()->contextMenuController().clearContextMenu(); 2208 2209 Frame& frame = m_page->focusController().focusedOrMainFrame(); 2210 bool handled = frame.eventHandler().sendContextMenuEventForKey(); 2211 if (handled) 2212 contextMenu()->show(); 2213 } 2204 2214 #endif 2205 2215 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r212745 r213278 1061 1061 #if ENABLE(CONTEXT_MENUS) 1062 1062 void contextMenuHidden() { m_isShowingContextMenu = false; } 1063 void contextMenuForKeyEvent(); 1063 1064 #endif 1064 1065 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r212745 r213278 122 122 #if ENABLE(CONTEXT_MENUS) 123 123 ContextMenuHidden() 124 ContextMenuForKeyEvent() 124 125 #endif 125 126 -
trunk/Tools/ChangeLog
r213272 r213278 1 2017-03-02 Tomas Popela <tpopela@redhat.com> 2 3 [WK2] Keyboard menu key should show context menu 4 https://bugs.webkit.org/show_bug.cgi?id=72099 5 6 Show the context menu when the GtkWidget::popup-menu signal is 7 emitted. This signal is triggered by pressing a key (usually 8 the Menu key or the Shift + F10 shortcut) or it could be emitted on 9 WebKitWebView. 10 11 Reviewed by Carlos Garcia Campos. 12 13 * TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp: 14 (testContextMenuDefaultMenu): 15 * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp: 16 (WebViewTest::emitPopupMenuSignal): 17 * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h: 18 1 19 2017-03-01 Wenson Hsieh <wenson_hsieh@apple.com> 2 20 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp
r212630 r213278 34 34 { 35 35 g_assert(event); 36 g_assert_cmpint(event->type, ==, GDK_BUTTON_PRESS); 37 g_assert_cmpint(event->button.button, ==, 3); 38 g_assert_cmpint(event->button.x, ==, m_menuPositionX); 39 g_assert_cmpint(event->button.y, ==, m_menuPositionY); 36 g_assert_cmpint(event->type, ==, m_expectedEventType); 37 38 switch (m_expectedEventType) { 39 case GDK_BUTTON_PRESS: 40 g_assert_cmpint(event->button.button, ==, 3); 41 g_assert_cmpint(event->button.x, ==, m_menuPositionX); 42 g_assert_cmpint(event->button.y, ==, m_menuPositionY); 43 break; 44 case GDK_KEY_PRESS: 45 g_assert_cmpint(event->key.keyval, ==, GDK_KEY_Menu); 46 break; 47 case GDK_NOTHING: 48 // GDK_NOTHING means that the context menu was triggered by the 49 // popup-menu signal. We don't have anything to check here. 50 break; 51 default: 52 g_assert_not_reached(); 53 } 40 54 } 41 55 … … 59 73 : m_menuPositionX(0) 60 74 , m_menuPositionY(0) 75 , m_expectedEventType(GDK_BUTTON_PRESS) 61 76 { 62 77 g_signal_connect(m_webView, "context-menu", G_CALLBACK(contextMenuCallback), this); … … 200 215 void showContextMenuAndWaitUntilFinished() 201 216 { 217 m_expectedEventType = GDK_BUTTON_PRESS; 202 218 showContextMenuAtPositionAndWaitUntilFinished(0, 0); 203 219 } … … 215 231 } 216 232 233 static gboolean emitPopupMenuSignalIdleCallback(ContextMenuTest* test) 234 { 235 test->emitPopupMenuSignal(); 236 return FALSE; 237 } 238 239 void showContextMenuTriggeredByPopupEventAndWaitUntilFinished() 240 { 241 m_expectedEventType = GDK_NOTHING; 242 g_idle_add(reinterpret_cast<GSourceFunc>(emitPopupMenuSignalIdleCallback), this); 243 g_main_loop_run(m_mainLoop); 244 } 245 246 static gboolean simulateMenuKeyIdleCallback(ContextMenuTest* test) 247 { 248 test->keyStroke(GDK_KEY_Menu); 249 return FALSE; 250 } 251 252 void showContextMenuTriggeredByContextMenuKeyAndWaitUntilFinished() 253 { 254 m_expectedEventType = GDK_KEY_PRESS; 255 g_idle_add(reinterpret_cast<GSourceFunc>(simulateMenuKeyIdleCallback), this); 256 g_main_loop_run(m_mainLoop); 257 } 258 217 259 double m_menuPositionX; 218 260 double m_menuPositionY; 261 GdkEventType m_expectedEventType; 219 262 }; 220 263 … … 366 409 }; 367 410 368 static void testContextMenuDefaultMenu(ContextMenuDefaultTest* test, gconstpointer) 369 { 370 test->showInWindowAndWaitUntilMapped(); 371 411 static void prepareContextMenuTestView(ContextMenuDefaultTest* test) 412 { 372 413 GUniquePtr<char> baseDir(g_strdup_printf("file://%s/", Test::getResourcesDir().data())); 373 414 const char* linksHTML = … … 389 430 test->loadHtml(linksHTML, baseDir.get()); 390 431 test->waitUntilLoadFinished(); 432 } 433 434 static void testContextMenuDefaultMenu(ContextMenuDefaultTest* test, gconstpointer) 435 { 436 test->showInWindowAndWaitUntilMapped(); 437 438 prepareContextMenuTestView(test); 391 439 392 440 // Context menu for selection. … … 426 474 test->m_expectedMenuType = ContextMenuDefaultTest::Editable; 427 475 test->showContextMenuAtPositionAndWaitUntilFinished(5, 35); 476 } 477 478 static void testPopupEventSignal(ContextMenuDefaultTest* test, gconstpointer) 479 { 480 test->showInWindowAndWaitUntilMapped(); 481 482 prepareContextMenuTestView(test); 483 484 test->m_expectedMenuType = ContextMenuDefaultTest::Selection; 485 test->showContextMenuTriggeredByPopupEventAndWaitUntilFinished(); 486 } 487 488 static void testContextMenuKey(ContextMenuDefaultTest* test, gconstpointer) 489 { 490 test->showInWindowAndWaitUntilMapped(); 491 492 prepareContextMenuTestView(test); 493 494 test->m_expectedMenuType = ContextMenuDefaultTest::Selection; 495 test->showContextMenuTriggeredByContextMenuKeyAndWaitUntilFinished(); 428 496 } 429 497 … … 918 986 { 919 987 ContextMenuDefaultTest::add("WebKitWebView", "default-menu", testContextMenuDefaultMenu); 988 ContextMenuDefaultTest::add("WebKitWebView", "context-menu-key", testContextMenuKey); 989 ContextMenuDefaultTest::add("WebKitWebView", "popup-event-signal", testPopupEventSignal); 920 990 ContextMenuCustomTest::add("WebKitWebView", "populate-menu", testContextMenuPopulateMenu); 921 991 ContextMenuCustomFullTest::add("WebKitWebView", "custom-menu", testContextMenuCustomMenu); -
trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp
r210574 r213278 334 334 } 335 335 336 void WebViewTest::emitPopupMenuSignal() 337 { 338 GtkWidget* viewWidget = GTK_WIDGET(m_webView); 339 g_assert(gtk_widget_get_realized(viewWidget)); 340 341 gboolean handled; 342 g_signal_emit_by_name(viewWidget, "popup-menu", &handled); 343 } 344 336 345 void WebViewTest::keyStroke(unsigned keyVal, unsigned keyModifiers) 337 346 { -
trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h
r210574 r213278 64 64 void keyStroke(unsigned keyVal, unsigned keyModifiers = 0); 65 65 66 void emitPopupMenuSignal(); 67 66 68 WebKitJavascriptResult* runJavaScriptAndWaitUntilFinished(const char* javascript, GError**); 67 69 WebKitJavascriptResult* runJavaScriptFromGResourceAndWaitUntilFinished(const char* resource, GError**);
Note: See TracChangeset
for help on using the changeset viewer.