Changeset 196265 in webkit


Ignore:
Timestamp:
Feb 8, 2016 11:42:42 AM (8 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] WebKitWebView should send crossing events to the WebProcess
https://bugs.webkit.org/show_bug.cgi?id=153740

Reviewed by Michael Catanzaro.

Source/WebCore:

Update the target element under the mouse also when only updating
scrollbars, so that if the mouse enters the page when the window
is not active, the scroll animator is notified that the mouse
entered the scrollable area.

  • page/EventHandler.cpp:

(WebCore::EventHandler::handleMouseMoveEvent): Call
updateMouseEventTargetNode() before early returning in case of
only updating scrollbars.

Source/WebKit2:

We don't currently handle crossing events in the web view
(enter/leave). That's why if you hover a scrollbar and leave the
window, the scrollbar is still rendered as hovered.

  • Shared/gtk/WebEventFactory.cpp:

(WebKit::buttonForEvent): Handle the case of GDK_ENTER_NOTIFY and
GDK_LEAVE_NOTIFY events.
(WebKit::WebEventFactory::createWebMouseEvent): Ditto.

  • UIProcess/API/gtk/WebKitWebViewBase.cpp:

(webkitWebViewBaseRealize): Add GDK_ENTER_NOTIFY_MASK and
GDK_LEAVE_NOTIFY_MASK flags to the web view event mask.
(webkitWebViewBaseCrossingNotifyEvent): Handle enter/leave notify
events by generating a mouse move event, ensuring the double to
int conversion will not cause any problem.
(webkit_web_view_base_class_init): Add an implementation for
enter_notify_event and leave_notify_event.

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r196263 r196265  
     12016-02-08  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] WebKitWebView should send crossing events to the WebProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=153740
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Update the target element under the mouse also when only updating
     9        scrollbars, so that if the mouse enters the page when the window
     10        is not active, the scroll animator is notified that the mouse
     11        entered the scrollable area.
     12
     13        * page/EventHandler.cpp:
     14        (WebCore::EventHandler::handleMouseMoveEvent): Call
     15        updateMouseEventTargetNode() before early returning in case of
     16        only updating scrollbars.
     17
    1182016-02-08  Jeremy Jones  <jeremyj@apple.com>
    219
  • trunk/Source/WebCore/page/EventHandler.cpp

    r196256 r196265  
    18831883            scrollbar->mouseMoved(platformMouseEvent); // Handle hover effects on platforms that support visual feedback on scrollbar hovering.
    18841884#endif
    1885         if (onlyUpdateScrollbars)
     1885        if (onlyUpdateScrollbars) {
     1886            updateMouseEventTargetNode(mouseEvent.targetNode(), platformMouseEvent, true);
    18861887            return true;
     1888        }
    18871889    }
    18881890
  • trunk/Source/WebKit2/ChangeLog

    r196264 r196265  
     12016-02-08  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] WebKitWebView should send crossing events to the WebProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=153740
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        We don't currently handle crossing events in the web view
     9        (enter/leave). That's why if you hover a scrollbar and leave the
     10        window, the scrollbar is still rendered as hovered.
     11
     12        * Shared/gtk/WebEventFactory.cpp:
     13        (WebKit::buttonForEvent): Handle the case of GDK_ENTER_NOTIFY and
     14        GDK_LEAVE_NOTIFY events.
     15        (WebKit::WebEventFactory::createWebMouseEvent): Ditto.
     16        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     17        (webkitWebViewBaseRealize): Add GDK_ENTER_NOTIFY_MASK and
     18        GDK_LEAVE_NOTIFY_MASK flags to the web view event mask.
     19        (webkitWebViewBaseCrossingNotifyEvent): Handle enter/leave notify
     20        events by generating a mouse move event, ensuring the double to
     21        int conversion will not cause any problem.
     22        (webkit_web_view_base_class_init): Add an implementation for
     23        enter_notify_event and leave_notify_event.
     24
    1252016-02-08  Carlos Garcia Campos  <cgarcia@igalia.com>
    226
  • trunk/Source/WebKit2/Shared/gtk/WebEventFactory.cpp

    r196256 r196265  
    7373
    7474    switch (event->type) {
    75     case GDK_MOTION_NOTIFY:
     75    case GDK_ENTER_NOTIFY:
     76    case GDK_LEAVE_NOTIFY:
     77    case GDK_MOTION_NOTIFY: {
    7678        button = WebMouseEvent::NoButton;
    77         if (event->motion.state & GDK_BUTTON1_MASK)
     79        GdkModifierType state;
     80        gdk_event_get_state(event, &state);
     81        if (state & GDK_BUTTON1_MASK)
    7882            button = WebMouseEvent::LeftButton;
    79         else if (event->motion.state & GDK_BUTTON2_MASK)
     83        else if (state & GDK_BUTTON2_MASK)
    8084            button = WebMouseEvent::MiddleButton;
    81         else if (event->motion.state & GDK_BUTTON3_MASK)
     85        else if (state & GDK_BUTTON3_MASK)
    8286            button = WebMouseEvent::RightButton;
    8387        break;
     88    }
    8489    case GDK_BUTTON_PRESS:
    8590    case GDK_2BUTTON_PRESS:
     
    109114    switch (event->type) {
    110115    case GDK_MOTION_NOTIFY:
     116    case GDK_ENTER_NOTIFY:
     117    case GDK_LEAVE_NOTIFY:
    111118        type = WebEvent::MouseMove;
    112119        break;
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r196257 r196265  
    360360        | GDK_SMOOTH_SCROLL_MASK
    361361        | GDK_POINTER_MOTION_MASK
     362        | GDK_ENTER_NOTIFY_MASK
     363        | GDK_LEAVE_NOTIFY_MASK
    362364        | GDK_KEY_PRESS_MASK
    363365        | GDK_KEY_RELEASE_MASK
     
    832834
    833835    priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(reinterpret_cast<GdkEvent*>(event), 0 /* currentClickCount */));
     836
     837    return FALSE;
     838}
     839
     840static gboolean webkitWebViewBaseCrossingNotifyEvent(GtkWidget* widget, GdkEventCrossing* crosssingEvent)
     841{
     842    WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
     843    WebKitWebViewBasePrivate* priv = webViewBase->priv;
     844
     845    if (priv->authenticationDialog)
     846        return FALSE;
     847
     848    // In the case of crossing events, it's very important the actual coordinates the WebProcess receives, because once the mouse leaves
     849    // the web view, the WebProcess won't receive more events until the mouse enters again in the web view. So, if the coordinates of the leave
     850    // event are not accurate, the WebProcess might not know the mouse left the view. This can happen because of double to integer conversion,
     851    // if the coordinates of the leave event are for example (25.2, -0.9), the WebProcess will receive (25, 0) and any hit test will succeed
     852    // because those coordinates are inside the web view.
     853    GtkAllocation allocation;
     854    gtk_widget_get_allocation(widget, &allocation);
     855    double width = allocation.width;
     856    double height = allocation.height;
     857    double x = crosssingEvent->x;
     858    double y = crosssingEvent->y;
     859    if (x < 0 && x > -1)
     860        x = -1;
     861    else if (x >= width && x < width + 1)
     862        x = width + 1;
     863    if (y < 0 && y > -1)
     864        y = -1;
     865    else if (y >= height && y < height + 1)
     866        y = height + 1;
     867
     868    GdkEvent* event = reinterpret_cast<GdkEvent*>(crosssingEvent);
     869    GUniquePtr<GdkEvent> copiedEvent;
     870    if (x != crosssingEvent->x || y != crosssingEvent->y) {
     871        copiedEvent.reset(gdk_event_copy(event));
     872        copiedEvent->crossing.x = x;
     873        copiedEvent->crossing.y = y;
     874    }
     875
     876    priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(copiedEvent ? copiedEvent.get() : event, 0 /* currentClickCount */));
    834877
    835878    return FALSE;
     
    10801123    widgetClass->scroll_event = webkitWebViewBaseScrollEvent;
    10811124    widgetClass->motion_notify_event = webkitWebViewBaseMotionNotifyEvent;
     1125    widgetClass->enter_notify_event = webkitWebViewBaseCrossingNotifyEvent;
     1126    widgetClass->leave_notify_event = webkitWebViewBaseCrossingNotifyEvent;
    10821127#if ENABLE(TOUCH_EVENTS)
    10831128    widgetClass->touch_event = webkitWebViewBaseTouchEvent;
Note: See TracChangeset for help on using the changeset viewer.