Changeset 53256 in webkit


Ignore:
Timestamp:
Jan 14, 2010 3:56:58 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-01-14 Alejandro G. Castro <alex@igalia.com>

Reviewed by Xan Lopez.

Review the tooltip implementation
https://bugs.webkit.org/show_bug.cgi?id=32819

Change the GTK tooltip implementation to avoid the workaround that
we are currently using. Now we use a new private API to set the
text and all the tooltip handling is done in the webview widget.

  • WebCoreSupport/ChromeClientGtk.cpp:
  • webkit/webkitprivate.h:
  • webkit/webkitwebview.cpp: (webkit_web_view_set_tooltip_text): Added, new private API. (webkit_web_view_query_tooltip): Added
Location:
trunk/WebKit/gtk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/gtk/ChangeLog

    r53138 r53256  
     12010-01-14  Alejandro G. Castro  <alex@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        Review the tooltip implementation
     6        https://bugs.webkit.org/show_bug.cgi?id=32819
     7
     8        Change the GTK tooltip implementation to avoid the workaround that
     9        we are currently using. Now we use a new private API to set the
     10        text and all the tooltip handling is done in the webview widget.
     11
     12        * WebCoreSupport/ChromeClientGtk.cpp:
     13        * webkit/webkitprivate.h:
     14        * webkit/webkitwebview.cpp:
     15        (webkit_web_view_set_tooltip_text): Added, new private API.
     16        (webkit_web_view_query_tooltip): Added
     17
    1182010-01-12  Gustavo Noronha Silva  <gns@gnome.org>
    219
  • trunk/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp

    r52066 r53256  
    443443void ChromeClient::mouseDidMoveOverElement(const HitTestResult& hit, unsigned modifierFlags)
    444444{
    445 #if GTK_CHECK_VERSION(2,12,0)
    446     // If a tooltip must be displayed it will be, afterwards, when
    447     // setToolTip is called; this is just a work-around to make sure
    448     // it updates its location correctly; see
    449     // https://bugs.webkit.org/show_bug.cgi?id=15793.
    450     g_object_set(m_webView, "has-tooltip", FALSE, NULL);
    451 
    452     GdkDisplay* gdkDisplay;
    453     GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView));
    454     if (GTK_WIDGET_TOPLEVEL(window))
    455         gdkDisplay = gtk_widget_get_display(window);
    456     else
    457         gdkDisplay = gdk_display_get_default();
    458     gtk_tooltip_trigger_tooltip_query(gdkDisplay);
    459 #endif
    460 
    461445    // check if the element is a link...
    462446    bool isLink = hit.isLiveLink();
     
    478462void ChromeClient::setToolTip(const String& toolTip, TextDirection)
    479463{
    480 #if GTK_CHECK_VERSION(2,12,0)
    481     if (toolTip.isEmpty())
    482         g_object_set(m_webView, "has-tooltip", FALSE, NULL);
    483     else
    484         gtk_widget_set_tooltip_text(GTK_WIDGET(m_webView), toolTip.utf8().data());
    485 #else
    486     // TODO: Support older GTK+ versions
    487     // See http://bugs.webkit.org/show_bug.cgi?id=15793
    488     notImplemented();
    489 #endif
     464    webkit_web_view_set_tooltip_text(m_webView, toolTip.utf8().data());
    490465}
    491466
  • trunk/WebKit/gtk/webkit/webkitprivate.h

    r51948 r53256  
    153153        char* mainResourceIdentifier;
    154154        GHashTable* subResources;
     155        char* tooltipText;
    155156    };
    156157
     
    255256    webkit_web_view_get_subresources(WebKitWebView*);
    256257
     258    void
     259    webkit_web_view_set_tooltip_text(WebKitWebView*, const char*);
     260
    257261    WebKitDownload*
    258262    webkit_download_new_with_handle(WebKitNetworkRequest* request, WebCore::ResourceHandle* handle, const WebCore::ResourceResponse& response);
  • trunk/WebKit/gtk/webkit/webkitwebview.cpp

    r52418 r53256  
    10541054    WebKitWebViewPrivate* priv = webView->priv;
    10551055
     1056    g_free(priv->tooltipText);
    10561057    g_free(priv->mainResourceIdentifier);
    10571058    g_free(priv->encoding);
     
    12771278}
    12781279
     1280#if GTK_CHECK_VERSION(2, 12, 0)
     1281static gboolean webkit_web_view_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip)
     1282{
     1283    WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(widget);
     1284
     1285    if (priv->tooltipText) {
     1286        gtk_tooltip_set_text(tooltip, priv->tooltipText);
     1287        return TRUE;
     1288    }
     1289
     1290    return FALSE;
     1291}
     1292#endif
     1293
    12791294static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
    12801295{
     
    21462161    widgetClass->drag_end = webkit_web_view_drag_end;
    21472162    widgetClass->drag_data_get = webkit_web_view_drag_data_get;
     2163#if GTK_CHECK_VERSION(2, 12, 0)
     2164    widgetClass->query_tooltip = webkit_web_view_query_tooltip;
     2165#endif
    21482166
    21492167    GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass);
     
    26682686
    26692687    priv->subResources = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
     2688
     2689    priv->tooltipText = 0;
    26702690}
    26712691
     
    40204040    // Historically the code would just crash; this is clearly no worse than that.
    40214041    return view ? view->windowToContents(windowPoint) : windowPoint;
     4042}
     4043
     4044void webkit_web_view_set_tooltip_text(WebKitWebView* webView, const char* tooltip)
     4045{
     4046#if GTK_CHECK_VERSION(2, 12, 0)
     4047    WebKitWebViewPrivate* priv = webView->priv;
     4048    g_free(priv->tooltipText);
     4049    if (tooltip && *tooltip != '\0') {
     4050        priv->tooltipText = g_strdup(tooltip);
     4051        gtk_widget_set_has_tooltip(GTK_WIDGET(webView), TRUE);
     4052    } else {
     4053        priv->tooltipText = 0;
     4054        gtk_widget_set_has_tooltip(GTK_WIDGET(webView), FALSE);
     4055    }
     4056
     4057    gtk_widget_trigger_tooltip_query(GTK_WIDGET(webView));
     4058#else
     4059    // TODO: Support older GTK+ versions
     4060    // See http://bugs.webkit.org/show_bug.cgi?id=15793
     4061    notImplemented();
     4062#endif
    40224063}
    40234064
Note: See TracChangeset for help on using the changeset viewer.