Changeset 55389 in webkit


Ignore:
Timestamp:
Mar 1, 2010 5:12:16 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-01 José Millán Soto <jmillan@igalia.com>

Reviewed by Gustavo Noronha Silva.

[GTK] Right click does not activate text entry
https://bugs.webkit.org/show_bug.cgi?id=29177

Stop skipping some tests which where failing because of right click
not being correct handled.

  • platform/gtk/Skipped:

2010-03-01 José Millán Soto <jmillan@igalia.com>

Reviewed by Gustavo Noronha Silva.

[GTK] Right click does not activate text entry
https://bugs.webkit.org/show_bug.cgi?id=29177

Makes the frame handle the mouse click event before sending the
context menu event.

  • webkit/webkitwebview.cpp: (PopupMenuPositionFunc): Function created to make the popup menu appear in the correct position, especially when invoked from the keyboard. (webkit_web_view_forward_context_menu_event): Mouse click event is sent to frame before creating context menu, PopupMenuPositionFunc used to determine the position where the menu should appear. (webkit_web_view_popup_menu_handler): Improved focused node position detection. Event button set to right button.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r55386 r55389  
     12010-03-01  José Millán Soto  <jmillan@igalia.com>
     2
     3        Reviewed by Gustavo Noronha Silva.
     4
     5        [GTK] Right click does not activate text entry
     6        https://bugs.webkit.org/show_bug.cgi?id=29177
     7
     8        Stop skipping some tests which where failing because of right click
     9        not being correct handled.
     10
     11        * platform/gtk/Skipped:
     12
    1132010-03-01  Alex Milowski  <alex@milowski.com>
    214
  • trunk/LayoutTests/platform/gtk/Skipped

    r55375 r55389  
    13371337fast/events/js-keyboard-event-creation.html
    13381338fast/events/mouse-click-events.html
    1339 fast/events/mouseclick-target-and-positioning.html
    13401339fast/events/mouseup-from-button2.html
    13411340fast/events/offsetX-offsetY.html
     
    13521351fast/events/pointer-events-2.html
    13531352fast/events/popup-blocking-click-in-iframe.html
    1354 fast/events/right-click-focus.html
    13551353fast/events/scrollbar-double-click.html
    13561354fast/events/stop-load-in-unload-handler-using-document-write.html
  • trunk/WebKit/gtk/ChangeLog

    r55387 r55389  
     12010-03-01  José Millán Soto  <jmillan@igalia.com>
     2
     3        Reviewed by Gustavo Noronha Silva.
     4
     5        [GTK] Right click does not activate text entry
     6        https://bugs.webkit.org/show_bug.cgi?id=29177
     7
     8        Makes the frame handle the mouse click event before sending the
     9        context menu event.
     10
     11        * webkit/webkitwebview.cpp:
     12        (PopupMenuPositionFunc):
     13        Function created to make the popup menu appear in the correct position, especially
     14        when invoked from the keyboard.
     15        (webkit_web_view_forward_context_menu_event):
     16        Mouse click event is sent to frame before creating context menu,
     17        PopupMenuPositionFunc used to determine the position where the menu should appear.
     18        (webkit_web_view_popup_menu_handler):
     19        Improved focused node position detection. Event button set to right button.
     20
    1212010-03-01  Jakob Petsovits  <jpetsovits@rim.com>
    222
  • trunk/WebKit/gtk/webkit/webkitwebview.cpp

    r55387 r55389  
    203203}
    204204
     205static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pushIn, gpointer userData)
     206{
     207    WebKitWebView* view = WEBKIT_WEB_VIEW(userData);
     208    WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(view);
     209    GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(view));
     210    GtkRequisition menuSize;
     211
     212    gtk_widget_size_request(GTK_WIDGET(menu), &menuSize);
     213
     214    *x = priv->lastPopupXPosition;
     215    if ((*x + menuSize.width) >= gdk_screen_get_width(screen))
     216      *x -= menuSize.width;
     217
     218    *y = priv->lastPopupYPosition;
     219    if ((*y + menuSize.height) >= gdk_screen_get_height(screen))
     220      *y -= menuSize.height;
     221
     222    *pushIn = FALSE;
     223}
     224
    205225static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent& event)
    206226{
    207227    Page* page = core(webView);
    208228    page->contextMenuController()->clearContextMenu();
    209     Frame* focusedFrame = page->focusController()->focusedOrMainFrame();
    210 
    211     if (!focusedFrame->view())
     229    Frame* focusedFrame;
     230    Frame* mainFrame = page->mainFrame();
     231    gboolean mousePressEventResult = FALSE;
     232
     233    if (!mainFrame->view())
    212234        return FALSE;
    213235
    214     focusedFrame->view()->setCursor(pointerCursor());
     236    mainFrame->view()->setCursor(pointerCursor());
     237    if (page->frameCount()) {
     238        HitTestRequest request(HitTestRequest::Active);
     239        IntPoint point = mainFrame->view()->windowToContents(event.pos());
     240        MouseEventWithHitTestResults mev = mainFrame->document()->prepareMouseEvent(request, point, event);
     241
     242        Frame* targetFrame = EventHandler::subframeForTargetNode(mev.targetNode());
     243        if (!targetFrame)
     244            targetFrame = mainFrame;
     245
     246        focusedFrame = page->focusController()->focusedOrMainFrame();
     247        if (targetFrame != focusedFrame) {
     248            page->focusController()->setFocusedFrame(targetFrame);
     249            focusedFrame = targetFrame;
     250        }
     251    } else
     252        focusedFrame = mainFrame;
     253
     254    if (focusedFrame->view() && focusedFrame->eventHandler()->handleMousePressEvent(event))
     255        mousePressEventResult = TRUE;
     256
     257
    215258    bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(event);
    216259    if (!handledEvent)
     
    218261
    219262    // If coreMenu is NULL, this means WebCore decided to not create
    220     // the default context menu; this may still mean that the frame
    221     // wants to consume the event - this happens when the page is
    222     // handling the right-click for reasons other than a context menu,
    223     // so we give it to it.
     263    // the default context menu; this may happen when the page is
     264    // handling the right-click for reasons other than the context menu.
    224265    ContextMenu* coreMenu = page->contextMenuController()->contextMenu();
    225     if (!coreMenu) {
    226         Frame* frame = core(webView)->mainFrame();
    227         if (frame->view() && frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event)))
    228             return TRUE;
    229 
    230         return FALSE;
    231     }
     266    if (!coreMenu)
     267        return mousePressEventResult;
    232268
    233269    // If we reach here, it's because WebCore is going to show the
     
    263299
    264300    gtk_menu_popup(menu, NULL, NULL,
    265                    NULL,
    266                    priv, event.button() + 1, gtk_get_current_event_time());
     301                   &PopupMenuPositionFunc,
     302                   webView, event.button() + 1, gtk_get_current_event_time());
    267303    return TRUE;
    268304}
     
    274310    // The context menu event was generated from the keyboard, so show the context menu by the current selection.
    275311    Page* page = core(WEBKIT_WEB_VIEW(widget));
    276     FrameView* view = page->mainFrame()->view();
     312    Frame* frame = page->focusController()->focusedOrMainFrame();
     313    FrameView* view = frame->view();
    277314    if (!view)
    278315        return FALSE;   
    279316
    280     Position start = page->mainFrame()->selection()->selection().start();
    281     Position end = page->mainFrame()->selection()->selection().end();
     317    Position start = frame->selection()->selection().start();
     318    Position end = frame->selection()->selection().end();
    282319
    283320    int rightAligned = FALSE;
    284321    IntPoint location;
    285322
    286     if (!start.node() || !end.node())
     323    if (!start.node() || !end.node()
     324        || (frame->selection()->selection().isCaret() && !frame->selection()->selection().isContentEditable()))
    287325        location = IntPoint(rightAligned ? view->contentsWidth() - contextMenuMargin : contextMenuMargin, contextMenuMargin);
    288326    else {
     
    330368    // Ideally we'd have the position of a context menu event be separate from its target node.
    331369    location = view->contentsToWindow(location) + IntSize(0, -1);
     370    if (location.y() < 0)
     371        location.setY(contextMenuMargin);
     372    else if (location.y() > view->height())
     373        location.setY(view->height() - contextMenuMargin);
     374    if (location.x() < 0)
     375        location.setX(contextMenuMargin);
     376    else if (location.x() > view->width())
     377        location.setX(view->width() - contextMenuMargin);
    332378    IntPoint global = location + IntSize(x, y);
    333     PlatformMouseEvent event(location, global, NoButton, MouseEventPressed, 0, false, false, false, false, gtk_get_current_event_time());
     379
     380    PlatformMouseEvent event(location, global, RightButton, MouseEventPressed, 0, false, false, false, false, gtk_get_current_event_time());
    334381
    335382    return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event);
Note: See TracChangeset for help on using the changeset viewer.