Changeset 107250 in webkit


Ignore:
Timestamp:
Feb 9, 2012 8:51:04 AM (12 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Add WebKitWebView::mouse-target-changed signal to WebKit2 GTK+ API
https://bugs.webkit.org/show_bug.cgi?id=78097

Reviewed by Martin Robinson.

.:

  • Source/autotools/symbols.filter: Add freeOwnedGPtr<_GdkEvent>

symbol to be able to use GOwnPtr<GdkEvent> in WebKit2 GTK+ unit
tests.

Source/WebKit2:

  • GNUmakefile.am: Add new files to compilation.
  • UIProcess/API/gtk/WebKitHitTestResult.cpp: Added.

(webkitHitTestResultFinalize):
(webkitHitTestResultGetProperty):
(webkitHitTestResultSetProperty):
(webkit_hit_test_result_init):
(webkit_hit_test_result_class_init):
(webkitHitTestResultCreate): Create a new WebKitHitTestResult for
the given WKHitTestResult.
(stringIsEqualToCString): Helper function to compare String and
CString considering String::isEmpty() == CString.isNull().
(webkitHitTestResultCompare): Helper function to check whether a
WebKitHitTestResult contains the same information than the given
WKHitTestResult.
(webkit_hit_test_result_get_context):
(webkit_hit_test_result_context_is_link):
(webkit_hit_test_result_context_is_image):
(webkit_hit_test_result_context_is_media):
(webkit_hit_test_result_get_link_uri):
(webkit_hit_test_result_get_link_title):
(webkit_hit_test_result_get_link_label):
(webkit_hit_test_result_get_image_uri):
(webkit_hit_test_result_get_media_uri):

  • UIProcess/API/gtk/WebKitHitTestResult.h: Added.
  • UIProcess/API/gtk/WebKitHitTestResultPrivate.h:
  • UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp:

(webkitNavigationPolicyDecisionCreate): Use
wkEventModifiersToGdkModifiers.

  • UIProcess/API/gtk/WebKitPrivate.cpp:

(wkEventModifiersToGdkModifiers): Moved from
WebKitNavigationPolicyDecision and renamed to wkEventModifiersToGdkModifiers.

  • UIProcess/API/gtk/WebKitPrivate.h:
  • UIProcess/API/gtk/WebKitUIClient.cpp:

(mouseDidMoveOverElement): UI client callback that calls
webkitWebViewMouseTargetChanged().
(attachUIClientToView): Add implementation for callback
mouseDidMoveOverElement.

  • UIProcess/API/gtk/WebKitWebView.cpp:

(webkit_web_view_class_init): Add
WebKitWebView::mouse-target-changed signal.
(webkitWebViewMouseTargetChanged): Emit
WebKitWebView::mouse-target-changed signal.

  • UIProcess/API/gtk/WebKitWebView.h:
  • UIProcess/API/gtk/WebKitWebViewPrivate.h:
  • UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new section for

WebKitHitTestResult.

  • UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
  • UIProcess/API/gtk/tests/TestWebKitWebView.cpp:

(testWebViewMouseTarget):
(beforeAll):

  • UIProcess/API/gtk/tests/WebViewTest.cpp:

(WebViewTest::WebViewTest):
(WebViewTest::~WebViewTest):
(parentWindowMapped):
(WebViewTest::showInWindowAndWaitUntilMapped): Method to add the
view into a popup window and show it running the main loop until
the window is mapped.
(WebViewTest::mouseMoveTo): Method to synthesize a
GDK_MOTION_EVENT on the given coordinates and using the given
modifiers.

  • UIProcess/API/gtk/tests/WebViewTest.h:
  • UIProcess/API/gtk/webkit2.h: Include WebKitHitTestResult.h.
  • UIProcess/API/gtk/webkit2marshal.list:
Location:
trunk
Files:
2 added
17 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r107196 r107250  
     12012-02-09  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Add WebKitWebView::mouse-target-changed signal to WebKit2 GTK+ API
     4        https://bugs.webkit.org/show_bug.cgi?id=78097
     5
     6        Reviewed by Martin Robinson.
     7
     8        * Source/autotools/symbols.filter: Add freeOwnedGPtr<_GdkEvent>
     9        symbol to be able to use GOwnPtr<GdkEvent> in WebKit2 GTK+ unit
     10        tests.
     11
    1122012-02-09  Kent Tamura  <tkent@chromium.org>
    213
  • trunk/Source/WebKit2/ChangeLog

    r107237 r107250  
     12012-02-09  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Add WebKitWebView::mouse-target-changed signal to WebKit2 GTK+ API
     4        https://bugs.webkit.org/show_bug.cgi?id=78097
     5
     6        Reviewed by Martin Robinson.
     7
     8        * GNUmakefile.am: Add new files to compilation.
     9        * UIProcess/API/gtk/WebKitHitTestResult.cpp: Added.
     10        (webkitHitTestResultFinalize):
     11        (webkitHitTestResultGetProperty):
     12        (webkitHitTestResultSetProperty):
     13        (webkit_hit_test_result_init):
     14        (webkit_hit_test_result_class_init):
     15        (webkitHitTestResultCreate): Create a new WebKitHitTestResult for
     16        the given WKHitTestResult.
     17        (stringIsEqualToCString): Helper function to compare String and
     18        CString considering String::isEmpty() == CString.isNull().
     19        (webkitHitTestResultCompare): Helper function to check whether a
     20        WebKitHitTestResult contains the same information than the given
     21        WKHitTestResult.
     22        (webkit_hit_test_result_get_context):
     23        (webkit_hit_test_result_context_is_link):
     24        (webkit_hit_test_result_context_is_image):
     25        (webkit_hit_test_result_context_is_media):
     26        (webkit_hit_test_result_get_link_uri):
     27        (webkit_hit_test_result_get_link_title):
     28        (webkit_hit_test_result_get_link_label):
     29        (webkit_hit_test_result_get_image_uri):
     30        (webkit_hit_test_result_get_media_uri):
     31        * UIProcess/API/gtk/WebKitHitTestResult.h: Added.
     32        * UIProcess/API/gtk/WebKitHitTestResultPrivate.h:
     33        * UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp:
     34        (webkitNavigationPolicyDecisionCreate): Use
     35        wkEventModifiersToGdkModifiers.
     36        * UIProcess/API/gtk/WebKitPrivate.cpp:
     37        (wkEventModifiersToGdkModifiers): Moved from
     38        WebKitNavigationPolicyDecision and renamed to wkEventModifiersToGdkModifiers.
     39        * UIProcess/API/gtk/WebKitPrivate.h:
     40        * UIProcess/API/gtk/WebKitUIClient.cpp:
     41        (mouseDidMoveOverElement): UI client callback that calls
     42        webkitWebViewMouseTargetChanged().
     43        (attachUIClientToView): Add implementation for callback
     44        mouseDidMoveOverElement.
     45        * UIProcess/API/gtk/WebKitWebView.cpp:
     46        (webkit_web_view_class_init): Add
     47        WebKitWebView::mouse-target-changed signal.
     48        (webkitWebViewMouseTargetChanged): Emit
     49        WebKitWebView::mouse-target-changed signal.
     50        * UIProcess/API/gtk/WebKitWebView.h:
     51        * UIProcess/API/gtk/WebKitWebViewPrivate.h:
     52        * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new section for
     53        WebKitHitTestResult.
     54        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
     55        * UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
     56        (testWebViewMouseTarget):
     57        (beforeAll):
     58        * UIProcess/API/gtk/tests/WebViewTest.cpp:
     59        (WebViewTest::WebViewTest):
     60        (WebViewTest::~WebViewTest):
     61        (parentWindowMapped):
     62        (WebViewTest::showInWindowAndWaitUntilMapped): Method to add the
     63        view into a popup window and show it running the main loop until
     64        the window is mapped.
     65        (WebViewTest::mouseMoveTo): Method to synthesize a
     66        GDK_MOTION_EVENT on the given coordinates and using the given
     67        modifiers.
     68        * UIProcess/API/gtk/tests/WebViewTest.h:
     69        * UIProcess/API/gtk/webkit2.h: Include WebKitHitTestResult.h.
     70        * UIProcess/API/gtk/webkit2marshal.list:
     71
    1722012-02-07  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
    273
  • trunk/Source/WebKit2/GNUmakefile.am

    r107043 r107250  
    8989        $(WebKit2)/UIProcess/API/gtk/WebKitEditingCommands.h \
    9090        $(WebKit2)/UIProcess/API/gtk/WebKitError.h \
     91        $(WebKit2)/UIProcess/API/gtk/WebKitHitTestResult.h \
    9192        $(WebKit2)/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h \
    9293        $(WebKit2)/UIProcess/API/gtk/WebKitPolicyDecision.h \
     
    540541        Source/WebKit2/UIProcess/API/gtk/WebKitError.h \
    541542        Source/WebKit2/UIProcess/API/gtk/WebKitError.cpp \
     543        Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp \
     544        Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h \
     545        Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResultPrivate.h \
    542546        Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.h \
    543547        Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp \
     
    551555        Source/WebKit2/UIProcess/API/gtk/WebKitPolicyClient.h \
    552556        Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h \
     557        Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp \
    553558        Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.cpp \
    554559        Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.h \
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResultPrivate.h

    r107249 r107250  
    11/*
    2  * Copyright (C) 2011 Igalia S.L.
    3  * Portions Copyright (c) 2011 Motorola Mobility, Inc.  All rights reserved.
     2 * Copyright (C) 2012 Igalia S.L.
    43 *
    54 * This library is free software; you can redistribute it and/or
     
    1918 */
    2019
    21 #ifndef __WEBKIT2_H__
    22 #define __WEBKIT2_H__
     20#ifndef WebKitHitTestResultPrivate_h
     21#define WebKitHitTestResultPrivate_h
    2322
    24 #define __WEBKIT2_H_INSIDE__
     23#include "WebKitHitTestResult.h"
     24#include "WebKitPrivate.h"
    2525
    26 #include <webkit2/WebKitBackForwardList.h>
    27 #include <webkit2/WebKitBackForwardListItem.h>
    28 #include <webkit2/WebKitDefines.h>
    29 #include <webkit2/WebKitDownload.h>
    30 #include <webkit2/WebKitEditingCommands.h>
    31 #include <webkit2/WebKitEnumTypes.h>
    32 #include <webkit2/WebKitError.h>
    33 #include <webkit2/WebKitSettings.h>
    34 #include <webkit2/WebKitURIRequest.h>
    35 #include <webkit2/WebKitURIResponse.h>
    36 #include <webkit2/WebKitWebContext.h>
    37 #include <webkit2/WebKitWebViewBase.h>
    38 #include <webkit2/WebKitWebView.h>
    39 #include <webkit2/WebKitWindowProperties.h>
     26WebKitHitTestResult* webkitHitTestResultCreate(WKHitTestResultRef);
     27bool webkitHitTestResultCompare(WebKitHitTestResult*, WKHitTestResultRef);
    4028
    41 #undef __WEBKIT2_H_INSIDE__
    42 
    43 #endif /* __WEBKIT2_H__ */
     29#endif // WebKitHitTestResultPrivate_h
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp

    r106142 r107250  
    2626#include "WebKitURIRequestPrivate.h"
    2727#include "WebURLRequest.h"
    28 #include <gdk/gdk.h>
    2928#include <glib/gi18n-lib.h>
    3029#include <wtf/gobject/GRefPtr.h>
     
    281280}
    282281
    283 unsigned wkEventModifiersToUnsigned(WKEventModifiers wkModifiers)
    284 {
    285     unsigned modifiers = 0;
    286     if (wkModifiers & kWKEventModifiersShiftKey)
    287         modifiers |= GDK_SHIFT_MASK;
    288     if (wkModifiers & kWKEventModifiersControlKey)
    289         modifiers |= GDK_CONTROL_MASK;
    290     if (wkModifiers & kWKEventModifiersAltKey)
    291         modifiers |= GDK_MOD1_MASK;
    292     if (wkModifiers & kWKEventModifiersMetaKey)
    293         modifiers |= GDK_META_MASK;
    294     return modifiers;
    295 }
    296 
    297282WebKitNavigationPolicyDecision* webkitNavigationPolicyDecisionCreate(WKFrameNavigationType navigationType, WKEventMouseButton mouseButton, WKEventModifiers modifiers, WKURLRequestRef request, const char* frameName, WKFramePolicyListenerRef listener)
    298283{
     
    300285    decision->priv->navigationType = static_cast<WebKitNavigationType>(navigationType);
    301286    decision->priv->mouseButton = wkEventMouseButtonToWebKitMouseButton(mouseButton);
    302     decision->priv->modifiers = wkEventModifiersToUnsigned(modifiers);
     287    decision->priv->modifiers = wkEventModifiersToGdkModifiers(modifiers);
    303288    decision->priv->request = adoptGRef(webkitURIRequestCreateForResourceRequest(toImpl(request)->resourceRequest()));
    304289    decision->priv->frameName = frameName;
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp

    r107249 r107250  
    11/*
    2  * Copyright (C) 2011 Igalia S.L.
    3  * Portions Copyright (c) 2011 Motorola Mobility, Inc.  All rights reserved.
     2 * Copyright (C) 2012 Igalia S.L.
    43 *
    54 * This library is free software; you can redistribute it and/or
     
    1918 */
    2019
    21 #ifndef __WEBKIT2_H__
    22 #define __WEBKIT2_H__
     20#include "config.h"
     21#include "WebKitPrivate.h"
    2322
    24 #define __WEBKIT2_H_INSIDE__
     23#include <gdk/gdk.h>
    2524
    26 #include <webkit2/WebKitBackForwardList.h>
    27 #include <webkit2/WebKitBackForwardListItem.h>
    28 #include <webkit2/WebKitDefines.h>
    29 #include <webkit2/WebKitDownload.h>
    30 #include <webkit2/WebKitEditingCommands.h>
    31 #include <webkit2/WebKitEnumTypes.h>
    32 #include <webkit2/WebKitError.h>
    33 #include <webkit2/WebKitSettings.h>
    34 #include <webkit2/WebKitURIRequest.h>
    35 #include <webkit2/WebKitURIResponse.h>
    36 #include <webkit2/WebKitWebContext.h>
    37 #include <webkit2/WebKitWebViewBase.h>
    38 #include <webkit2/WebKitWebView.h>
    39 #include <webkit2/WebKitWindowProperties.h>
    40 
    41 #undef __WEBKIT2_H_INSIDE__
    42 
    43 #endif /* __WEBKIT2_H__ */
     25unsigned wkEventModifiersToGdkModifiers(WKEventModifiers wkModifiers)
     26{
     27    unsigned modifiers = 0;
     28    if (wkModifiers & kWKEventModifiersShiftKey)
     29        modifiers |= GDK_SHIFT_MASK;
     30    if (wkModifiers & kWKEventModifiersControlKey)
     31        modifiers |= GDK_CONTROL_MASK;
     32    if (wkModifiers & kWKEventModifiersAltKey)
     33        modifiers |= GDK_MOD1_MASK;
     34    if (wkModifiers & kWKEventModifiersMetaKey)
     35        modifiers |= GDK_META_MASK;
     36    return modifiers;
     37}
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h

    r106838 r107250  
    4141        COMPILE_ASSERT(int(webkitName) == int(webcoreName), mismatchingEnums)
    4242
     43unsigned wkEventModifiersToGdkModifiers(WKEventModifiers);
     44
    4345#endif // WebKitPrivate_h
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp

    r106559 r107250  
    127127}
    128128
     129static void mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void* clientInfo)
     130{
     131    webkitWebViewMouseTargetChanged(WEBKIT_WEB_VIEW(clientInfo), hitTestResult, wkEventModifiersToGdkModifiers(modifiers));
     132}
     133
    129134void attachUIClientToView(WebKitWebView* webView)
    130135{
     
    172177        0, // shouldInterruptJavaScript
    173178        createNewPage,
    174         0, // mouseDidMoveOverElement
     179        mouseDidMoveOverElement,
    175180        0, // decidePolicyForNotificationPermissionRequest
    176181    };
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp

    r107092 r107250  
    2525#include "WebKitEnumTypes.h"
    2626#include "WebKitError.h"
     27#include "WebKitHitTestResultPrivate.h"
    2728#include "WebKitLoaderClient.h"
    2829#include "WebKitMarshal.h"
     
    6061    DECIDE_POLICY,
    6162
     63    MOUSE_TARGET_CHANGED,
     64
    6265    LAST_SIGNAL
    6366};
     
    8487    GRefPtr<WebKitSettings> settings;
    8588    GRefPtr<WebKitWindowProperties> windowProperties;
     89
     90    GRefPtr<WebKitHitTestResult> mouseTargetHitTestResult;
     91    unsigned mouseTargetModifiers;
    8692};
    8793
     
    616622                     WEBKIT_TYPE_POLICY_DECISION,
    617623                     WEBKIT_TYPE_POLICY_DECISION_TYPE);
     624
     625    /**
     626     * WebKitWebView::mouse-target-changed:
     627     * @web_view: the #WebKitWebView on which the signal is emitted
     628     * @hit_test_result: a #WebKitHitTestResult
     629     * @modifiers: a bitmask of #GdkModifierType
     630     *
     631     * This signal is emitted when the mouse cursor moves over an
     632     * element such as a link, image or a media element. To determine
     633     * what type of element the mouse cursor is over, a Hit Test is performed
     634     * on the current mouse coordinates and the result is passed in the
     635     * @hit_test_result argument. The @modifiers argument is a bitmask of
     636     * #GdkModifierType flags indicating the state of modifier keys.
     637     * The signal is emitted again when the mouse is moved out of the
     638     * current element with a new @hit_test_result.
     639     */
     640     signals[MOUSE_TARGET_CHANGED] =
     641         g_signal_new("mouse-target-changed",
     642                      G_TYPE_FROM_CLASS(webViewClass),
     643                      G_SIGNAL_RUN_LAST,
     644                      G_STRUCT_OFFSET(WebKitWebViewClass, mouse_target_changed),
     645                      0, 0,
     646                      webkit_marshal_VOID__OBJECT_UINT,
     647                      G_TYPE_NONE, 2,
     648                      WEBKIT_TYPE_HIT_TEST_RESULT,
     649                      G_TYPE_UINT);
    618650}
    619651
     
    725757    gboolean returnValue;
    726758    g_signal_emit(webView, signals[DECIDE_POLICY], 0, decision, type, &returnValue);
     759}
     760
     761void webkitWebViewMouseTargetChanged(WebKitWebView* webView, WKHitTestResultRef wkHitTestResult, unsigned modifiers)
     762{
     763    WebKitWebViewPrivate* priv = webView->priv;
     764    if (priv->mouseTargetHitTestResult
     765        && priv->mouseTargetModifiers == modifiers
     766        && webkitHitTestResultCompare(priv->mouseTargetHitTestResult.get(), wkHitTestResult))
     767        return;
     768
     769    priv->mouseTargetModifiers = modifiers;
     770    priv->mouseTargetHitTestResult = adoptGRef(webkitHitTestResultCreate(wkHitTestResult));
     771    g_signal_emit(webView, signals[MOUSE_TARGET_CHANGED], 0, priv->mouseTargetHitTestResult.get(), modifiers);
    727772}
    728773
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h

    r106961 r107250  
    3131#include <webkit2/WebKitBackForwardList.h>
    3232#include <webkit2/WebKitDefines.h>
     33#include <webkit2/WebKitHitTestResult.h>
    3334#include <webkit2/WebKitWebContext.h>
    3435#include <webkit2/WebKitSettings.h>
     
    117118    WebKitWebViewBaseClass parent;
    118119
    119     void       (* load_changed)   (WebKitWebView             *web_view,
    120                                    WebKitLoadEvent            load_event);
    121     gboolean   (* load_failed)    (WebKitWebView             *web_view,
    122                                    WebKitLoadEvent            load_event,
    123                                    const gchar               *failing_uri,
    124                                    GError                    *error);
    125 
    126     GtkWidget *(* create)         (WebKitWebView             *web_view);
    127     void       (* ready_to_show)  (WebKitWebView             *web_view);
    128     void       (* close)          (WebKitWebView             *web_view);
    129 
    130     gboolean   (* script_alert)   (WebKitWebView             *web_view,
    131                                    const gchar               *message);
    132     gboolean   (* script_confirm) (WebKitWebView             *web_view,
    133                                    const gchar               *message,
    134                                    gboolean                  *confirmed);
    135     gboolean   (* script_prompt)  (WebKitWebView             *web_view,
    136                                    const gchar               *message,
    137                                    const gchar               *default_text,
    138                                    gchar                    **text);
    139     gboolean   (* decide_policy)  (WebKitWebView             *web_view,
    140                                    WebKitPolicyDecision      *decision,
    141                                    WebKitPolicyDecisionType  type);
     120    void       (* load_changed)         (WebKitWebView             *web_view,
     121                                         WebKitLoadEvent            load_event);
     122    gboolean   (* load_failed)          (WebKitWebView             *web_view,
     123                                         WebKitLoadEvent            load_event,
     124                                         const gchar               *failing_uri,
     125                                         GError                    *error);
     126
     127    GtkWidget *(* create)               (WebKitWebView             *web_view);
     128    void       (* ready_to_show)        (WebKitWebView             *web_view);
     129    void       (* close)                (WebKitWebView             *web_view);
     130
     131    gboolean   (* script_alert)         (WebKitWebView             *web_view,
     132                                         const gchar               *message);
     133    gboolean   (* script_confirm)       (WebKitWebView             *web_view,
     134                                         const gchar               *message,
     135                                         gboolean                  *confirmed);
     136    gboolean   (* script_prompt)        (WebKitWebView             *web_view,
     137                                         const gchar               *message,
     138                                         const gchar               *default_text,
     139                                         gchar                    **text);
     140    gboolean   (* decide_policy)        (WebKitWebView             *web_view,
     141                                         WebKitPolicyDecision      *decision,
     142                                         WebKitPolicyDecisionType  type);
     143    void       (* mouse_target_changed) (WebKitWebView            *web_view,
     144                                         WebKitHitTestResult      *hit_test_result,
     145                                         guint                     modifiers);
    142146
    143147    /* Padding for future expansion */
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h

    r106142 r107250  
    4444WKStringRef webkitWebViewRunJavaScriptPrompt(WebKitWebView*, const CString& message, const CString& defaultText);
    4545void webkitWebViewMakePolicyDecision(WebKitWebView*, WebKitPolicyDecisionType, WebKitPolicyDecision*);
     46void webkitWebViewMouseTargetChanged(WebKitWebView*, WKHitTestResultRef, unsigned modifiers);
    4647
    4748#endif // WebKitWebViewPrivate_h
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml

    r107043 r107250  
    2525    <xi:include href="xml/WebKitNavigationPolicyDecision.xml"/>
    2626    <xi:include href="xml/WebKitResponsePolicyDecision.xml"/>
     27    <xi:include href="xml/WebKitHitTestResult.xml"/>
    2728    <xi:include href="xml/WebKitError.xml"/>
    2829  </chapter>
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt

    r107044 r107250  
    391391
    392392<SECTION>
     393<FILE>WebKitHitTestResult</FILE>
     394WebKitHitTestResult
     395WebKitHitTestResultContext
     396webkit_hit_test_result_get_context
     397webkit_hit_test_result_context_is_link
     398webkit_hit_test_result_context_is_image
     399webkit_hit_test_result_context_is_media
     400webkit_hit_test_result_get_link_uri
     401webkit_hit_test_result_get_link_title
     402webkit_hit_test_result_get_link_label
     403webkit_hit_test_result_get_image_uri
     404webkit_hit_test_result_get_media_uri
     405
     406<SUBSECTION Standard>
     407WebKitHitTestResultClass
     408WEBKIT_TYPE_HIT_TEST_RESULT
     409WEBKIT_HIT_TEST_RESULT
     410WEBKIT_IS_HIT_TEST_RESULT
     411WEBKIT_HIT_TEST_RESULT_CLASS
     412WEBKIT_IS_HIT_TEST_RESULT_CLASS
     413WEBKIT_HIT_TEST_RESULT_GET_CLASS
     414
     415<SUBSECTION Private>
     416WebKitHitTestResultPrivate
     417webkit_hit_test_result_get_type
     418</SECTION>
     419
     420<SECTION>
    393421<FILE>WebKitError</FILE>
    394422WEBKIT_NETWORK_ERROR
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp

    r107092 r107250  
    268268    }
    269269
     270    static void mouseTargetChanged(WebKitWebView*, WebKitHitTestResult* hitTestResult, guint modifiers, UIClientTest* test)
     271    {
     272        g_assert(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));
     273        test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(hitTestResult));
     274
     275        test->m_mouseTargetHitTestResult = hitTestResult;
     276        test->m_mouseTargetModifiers = modifiers;
     277        g_main_loop_quit(test->m_mainLoop);
     278    }
     279
    270280    UIClientTest()
    271281        : m_scriptType(Alert)
    272282        , m_scriptDialogConfirmed(true)
     283        , m_mouseTargetModifiers(0)
    273284    {
    274285        webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(m_webView), TRUE);
     
    277288        g_signal_connect(m_webView, "script-confirm", G_CALLBACK(scriptConfirm), this);
    278289        g_signal_connect(m_webView, "script-prompt", G_CALLBACK(scriptPrompt), this);
     290        g_signal_connect(m_webView, "mouse-target-changed", G_CALLBACK(mouseTargetChanged), this);
    279291    }
    280292
     
    292304    {
    293305        m_windowProperties = windowProperties;
     306    }
     307
     308    WebKitHitTestResult* moveMouseAndWaitUntilMouseTargetChanged(int x, int y, unsigned int mouseModifiers = 0)
     309    {
     310        mouseMoveTo(x, y, mouseModifiers);
     311        g_main_loop_run(m_mainLoop);
     312        return m_mouseTargetHitTestResult.get();
    294313    }
    295314
     
    299318    WindowProperties m_windowProperties;
    300319    HashSet<WTF::String> m_windowPropertiesChanged;
     320    GRefPtr<WebKitHitTestResult> m_mouseTargetHitTestResult;
     321    unsigned int m_mouseTargetModifiers;
    301322};
    302323
     
    360381    g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
    361382    g_assert_cmpint(events[2], ==, UIClientTest::Close);
     383}
     384
     385static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
     386{
     387    test->showInWindowAndWaitUntilMapped();
     388
     389    const char* linksHoveredHTML =
     390        "<html><body>"
     391        " <a style='position:absolute; left:1; top:1' href='http://www.webkitgtk.org' title='WebKitGTK+ Title'>WebKitGTK+ Website</a>"
     392        " <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>"
     393        " <a style='position:absolute; left:1; top:20' href='http://www.webkitgtk.org/logo' title='WebKitGTK+ Logo'><img src='0xdeadbeef' width=5 height=5></img></a>"
     394        " <video style='position:absolute; left:1; top:30' width=10 height=10 controls='controls'><source src='movie.ogg' type='video/ogg' /></video>"
     395        "</body></html>";
     396
     397    test->loadHtml(linksHoveredHTML, "file:///");
     398    test->waitUntilLoadFinished();
     399
     400    // Move over link.
     401    WebKitHitTestResult* hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 1);
     402    g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
     403    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
     404    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
     405    g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/");
     406    g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Title");
     407    g_assert_cmpstr(webkit_hit_test_result_get_link_label(hitTestResult), ==, "WebKitGTK+ Website");
     408    g_assert(!test->m_mouseTargetModifiers);
     409
     410    // Move out of the link.
     411    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(0, 0);
     412    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
     413    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
     414    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
     415    g_assert(!test->m_mouseTargetModifiers);
     416
     417    // Move over image with GDK_CONTROL_MASK.
     418    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 10, GDK_CONTROL_MASK);
     419    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
     420    g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
     421    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
     422    g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
     423    g_assert(test->m_mouseTargetModifiers & GDK_CONTROL_MASK);
     424
     425    // Move over image link.
     426    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 20);
     427    g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
     428    g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
     429    g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
     430    g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/logo");
     431    g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
     432    g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Logo");
     433    g_assert(!webkit_hit_test_result_get_link_label(hitTestResult));
     434    g_assert(!test->m_mouseTargetModifiers);
     435
     436    // Move over media.
     437    hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 30);
     438    g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
     439    g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
     440    g_assert(webkit_hit_test_result_context_is_media(hitTestResult));
     441    g_assert_cmpstr(webkit_hit_test_result_get_media_uri(hitTestResult), ==, "file:///movie.ogg");
     442    g_assert(!test->m_mouseTargetModifiers);
    362443}
    363444
     
    378459    UIClientTest::add("WebKitWebView", "javascript-dialogs", testWebViewJavaScriptDialogs);
    379460    UIClientTest::add("WebKitWebView", "window-properties", testWebViewWindowProperties);
     461    UIClientTest::add("WebKitWebView", "mouse-target", testWebViewMouseTarget);
    380462    WebViewTest::add("WebKitWebView", "zoom-level", testWebViewZoomLevel);
    381463}
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp

    r106961 r107250  
    2222#include "WebViewTest.h"
    2323
     24#include <WebCore/GOwnPtrGtk.h>
     25
    2426WebViewTest::WebViewTest()
    2527    : m_webView(WEBKIT_WEB_VIEW(g_object_ref_sink(webkit_web_view_new())))
    2628    , m_mainLoop(g_main_loop_new(0, TRUE))
     29    , m_parentWindow(0)
    2730{
    2831    assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_webView));
     
    3134WebViewTest::~WebViewTest()
    3235{
     36    if (m_parentWindow)
     37        gtk_widget_destroy(m_parentWindow);
    3338    g_object_unref(m_webView);
    3439    g_main_loop_unref(m_mainLoop);
     
    131136    g_main_loop_run(m_mainLoop);
    132137}
     138
     139static gboolean parentWindowMapped(GtkWidget* widget, GdkEvent*, WebViewTest* test)
     140{
     141    g_signal_handlers_disconnect_by_func(widget, reinterpret_cast<void*>(parentWindowMapped), test);
     142    g_main_loop_quit(test->m_mainLoop);
     143
     144    return FALSE;
     145}
     146
     147void WebViewTest::showInWindowAndWaitUntilMapped()
     148{
     149    g_assert(!m_parentWindow);
     150    m_parentWindow = gtk_window_new(GTK_WINDOW_POPUP);
     151    gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView));
     152    gtk_widget_show(GTK_WIDGET(m_webView));
     153
     154    g_signal_connect(m_parentWindow, "map-event", G_CALLBACK(parentWindowMapped), this);
     155    gtk_widget_show(m_parentWindow);
     156    g_main_loop_run(m_mainLoop);
     157}
     158
     159void WebViewTest::mouseMoveTo(int x, int y, unsigned int mouseModifiers)
     160{
     161    g_assert(m_parentWindow);
     162    GtkWidget* viewWidget = GTK_WIDGET(m_webView);
     163    g_assert(gtk_widget_get_realized(viewWidget));
     164
     165    GOwnPtr<GdkEvent> event(gdk_event_new(GDK_MOTION_NOTIFY));
     166    event->motion.x = x;
     167    event->motion.y = y;
     168
     169    event->motion.time = GDK_CURRENT_TIME;
     170    event->motion.window = gtk_widget_get_window(viewWidget);
     171    g_object_ref(event->motion.window);
     172    event->button.device = gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gtk_widget_get_display(viewWidget)));
     173    event->motion.state = mouseModifiers;
     174    event->motion.axes = 0;
     175
     176    int xRoot, yRoot;
     177    gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot);
     178    event->motion.x_root = xRoot;
     179    event->motion.y_root = yRoot;
     180    gtk_main_do_event(event.get());
     181}
     182
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h

    r106961 r107250  
    4343    void wait(double seconds);
    4444    void waitUntilLoadFinished();
     45    void showInWindowAndWaitUntilMapped();
     46
     47    void mouseMoveTo(int x, int y, unsigned int mouseModifiers = 0);
    4548
    4649    WebKitWebView* m_webView;
    4750    GMainLoop* m_mainLoop;
    4851    CString m_activeURI;
     52    GtkWidget* m_parentWindow;
    4953};
    5054
  • trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h

    r106961 r107250  
    3131#include <webkit2/WebKitEnumTypes.h>
    3232#include <webkit2/WebKitError.h>
     33#include <webkit2/WebKitHitTestResult.h>
    3334#include <webkit2/WebKitSettings.h>
    3435#include <webkit2/WebKitURIRequest.h>
  • trunk/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list

    r106142 r107250  
    1111OBJECT:VOID
    1212VOID:ENUM
     13VOID:OBJECT,UINT
    1314VOID:OBJECT,POINTER
    1415
  • trunk/Source/autotools/symbols.filter

    r107176 r107250  
    1010_ZN3WTF8fastFreeEPv;
    1111_ZN3WTF13freeOwnedGPtrI7_GErrorEEvPT_;
     12_ZN3WTF13freeOwnedGPtrI9_GdkEventEEvPT_;
    1213_ZN3WTF8Internal21fastMallocMatchFailedEPv;
    1314_ZN3WTF3MD58addBytes*;
Note: See TracChangeset for help on using the changeset viewer.