Changeset 88802 in webkit


Ignore:
Timestamp:
Jun 14, 2011 7:58:30 AM (13 years ago)
Author:
Carlos Garcia Campos
Message:

2011-06-14 Carlos Garcia Campos <cgarcia@igalia.com>

Reviewed by Martin Robinson.

[GTK] Rename convertWidgetRectToScreenRect() to convertWidgetPointToScreenPoint()
https://bugs.webkit.org/show_bug.cgi?id=62626

The method actually converts coordinates, the rectangle size is
not affected, so it can be modified to return a point
instead. Fix also a bug in the implementation, it was translating
the coordinates twice returning the wrong position when the given
rectangle was not at 0,0.

  • platform/gtk/GtkUtilities.cpp: (WebCore::convertWidgetPointToScreenPoint):
  • platform/gtk/GtkUtilities.h:
  • platform/gtk/PopupMenuGtk.cpp: (WebCore::PopupMenuGtk::show): Use convertWidgetPointToScreenPoint().

2011-06-14 Carlos Garcia Campos <cgarcia@igalia.com>

Reviewed by Martin Robinson.

[GTK] Rename convertWidgetRectToScreenRect() to convertWidgetPointToScreenPoint()
https://bugs.webkit.org/show_bug.cgi?id=62626

  • WebCoreSupport/ChromeClientGtk.cpp: (WebKit::ChromeClient::windowToScreen): Update to use convertWidgetPointToScreenPoint() (WebKit::ChromeClient::screenToWindow): Ditto.
  • webkit/webkitwebview.cpp: Remove globalPointForClientPoint() since it does the same than convertWidgetPointToScreenPoint(). (webkit_web_view_popup_menu_handler): Use convertWidgetPointToScreenPoint() instead of globalPointForClientPoint(). (doDragLeaveLater): Ditto. (webkit_web_view_drag_motion): Ditto. (webkit_web_view_drag_data_received): Ditto. (webkit_web_view_drag_drop): Ditto.

2011-06-14 Carlos Garcia Campos <cgarcia@igalia.com>

Reviewed by Martin Robinson.

[GTK] Rename convertWidgetRectToScreenRect() to convertWidgetPointToScreenPoint()
https://bugs.webkit.org/show_bug.cgi?id=62626

  • UIProcess/API/gtk/PageClientImpl.cpp: (WebKit::PageClientImpl::screenToWindow): Implement this method using convertWidgetPointToScreenPoint(). (WebKit::PageClientImpl::windowToScreen): Update to use convertWidgetPointToScreenPoint().
  • UIProcess/gtk/WebPopupMenuProxyGtk.cpp: (WebKit::WebPopupMenuProxyGtk::showPopupMenu): Use convertWidgetPointToScreenPoint().
Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r88800 r88802  
     12011-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [GTK] Rename convertWidgetRectToScreenRect() to convertWidgetPointToScreenPoint()
     6        https://bugs.webkit.org/show_bug.cgi?id=62626
     7
     8        The method actually converts coordinates, the rectangle size is
     9        not affected, so it can be modified to return a point
     10        instead. Fix also a bug in the implementation, it was translating
     11        the coordinates twice returning the wrong position when the given
     12        rectangle was not at 0,0.
     13
     14        * platform/gtk/GtkUtilities.cpp:
     15        (WebCore::convertWidgetPointToScreenPoint):
     16        * platform/gtk/GtkUtilities.h:
     17        * platform/gtk/PopupMenuGtk.cpp:
     18        (WebCore::PopupMenuGtk::show): Use
     19        convertWidgetPointToScreenPoint().
     20
    1212011-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
    222
  • trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp

    r85987 r88802  
    2020#include "GtkUtilities.h"
    2121
    22 #include "IntRect.h"
     22#include "IntPoint.h"
    2323#include <gtk/gtk.h>
    2424
    2525namespace WebCore {
    2626
    27 IntRect convertWidgetRectToScreenRect(GtkWidget* widget, const IntRect& rect)
     27IntPoint convertWidgetPointToScreenPoint(GtkWidget* widget, const IntPoint& point)
    2828{
    2929    // FIXME: This is actually a very tricky operation and the results of this function should
     
    3333    GtkWidget* toplevelWidget = gtk_widget_get_toplevel(widget);
    3434    if (!toplevelWidget || !gtk_widget_is_toplevel(toplevelWidget) || !GTK_IS_WINDOW(toplevelWidget))
    35         return rect;
     35        return point;
    3636
    3737    int xInWindow, yInWindow;
    38     gtk_widget_translate_coordinates(widget, toplevelWidget, rect.x(), rect.y(), &xInWindow, &yInWindow);
     38    gtk_widget_translate_coordinates(widget, toplevelWidget, point.x(), point.y(), &xInWindow, &yInWindow);
    3939    int windowOriginX, windowOriginY;
    4040    gdk_window_get_origin(gtk_widget_get_window(toplevelWidget), &windowOriginX, &windowOriginY);
    4141
    42     IntRect rectInScreenCoordinates(rect);
    43     rectInScreenCoordinates.move(windowOriginX + xInWindow, windowOriginY + yInWindow);
    44     return rectInScreenCoordinates;
     42    return IntPoint(windowOriginX + xInWindow, windowOriginY + yInWindow);
    4543}
    4644
  • trunk/Source/WebCore/platform/gtk/GtkUtilities.h

    r85987 r88802  
    2222namespace WebCore {
    2323
    24 class IntRect;
     24class IntPoint;
    2525
    26 IntRect convertWidgetRectToScreenRect(GtkWidget*, const IntRect&);
     26IntPoint convertWidgetPointToScreenPoint(GtkWidget*, const IntPoint&);
    2727
    2828} // namespace WebCore
  • trunk/Source/WebCore/platform/gtk/PopupMenuGtk.cpp

    r87930 r88802  
    3030#include "FrameView.h"
    3131#include "GOwnPtr.h"
     32#include "GtkUtilities.h"
    3233#include "HostWindow.h"
    3334#include <gtk/gtk.h>
     
    8384    }
    8485
    85     int x = 0;
    86     int y = 0;
    87     GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(view->hostWindow()->platformPageClient()));
    88     if (window)
    89         gdk_window_get_origin(window, &x, &y);
    90     IntPoint menuPosition(view->contentsToWindow(rect.location()));
    91     menuPosition.move(x, y + rect.height());
     86    IntPoint menuPosition = convertWidgetPointToScreenPoint(GTK_WIDGET(view->hostWindow()->platformPageClient()), view->contentsToWindow(rect.location()));
     87    menuPosition.move(0, rect.height());
    9288
    9389    m_popup->popUp(rect.size(), menuPosition, size, index, gtk_get_current_event());
  • trunk/Source/WebKit/gtk/ChangeLog

    r88800 r88802  
     12011-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [GTK] Rename convertWidgetRectToScreenRect() to convertWidgetPointToScreenPoint()
     6        https://bugs.webkit.org/show_bug.cgi?id=62626
     7
     8        * WebCoreSupport/ChromeClientGtk.cpp:
     9        (WebKit::ChromeClient::windowToScreen): Update to use
     10        convertWidgetPointToScreenPoint()
     11        (WebKit::ChromeClient::screenToWindow): Ditto.
     12        * webkit/webkitwebview.cpp: Remove globalPointForClientPoint()
     13        since it does the same than convertWidgetPointToScreenPoint().
     14        (webkit_web_view_popup_menu_handler): Use
     15        convertWidgetPointToScreenPoint() instead of globalPointForClientPoint().
     16        (doDragLeaveLater): Ditto.
     17        (webkit_web_view_drag_motion): Ditto.
     18        (webkit_web_view_drag_data_received): Ditto.
     19        (webkit_web_view_drag_drop): Ditto.
     20
    1212011-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
    222
  • trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp

    r88754 r88802  
    465465IntRect ChromeClient::windowToScreen(const IntRect& rect) const
    466466{
    467     return convertWidgetRectToScreenRect(GTK_WIDGET(m_webView), rect);
     467    return IntRect(convertWidgetPointToScreenPoint(GTK_WIDGET(m_webView), rect.location()), rect.size());
    468468}
    469469
    470470IntPoint ChromeClient::screenToWindow(const IntPoint& point) const
    471471{
    472     IntPoint widgetPositionOnScreen = convertWidgetRectToScreenRect(GTK_WIDGET(m_webView),
    473                                                                     IntRect(IntPoint(), IntSize())).location();
     472    IntPoint widgetPositionOnScreen = convertWidgetPointToScreenPoint(GTK_WIDGET(m_webView), IntPoint());
    474473    IntPoint result(point);
    475474    result.move(-widgetPositionOnScreen.x(), -widgetPositionOnScreen.y());
  • trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp

    r88734 r88802  
    5858#include "GOwnPtrGtk.h"
    5959#include "GraphicsContext.h"
     60#include "GtkUtilities.h"
    6061#include "GtkVersioning.h"
    6162#include "HTMLNames.h"
     
    145146
    146147static const double defaultDPI = 96.0;
    147 static IntPoint globalPointForClientPoint(GdkWindow* window, const IntPoint& clientPoint);
    148148
    149149enum {
     
    416416    location.shrunkTo(IntPoint(view->width() - gContextMenuMargin, view->height() - gContextMenuMargin));
    417417
    418     IntPoint globalPoint(globalPointForClientPoint(gtk_widget_get_window(widget), location));
     418    IntPoint globalPoint(convertWidgetPointToScreenPoint(widget, location));
    419419    PlatformMouseEvent event(location, globalPoint, RightButton, MouseEventPressed, 0, false, false, false, false, gtk_get_current_event_time());
    420420    return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event);
     
    14421442}
    14431443
    1444 static IntPoint globalPointForClientPoint(GdkWindow* window, const IntPoint& clientPoint)
    1445 {
    1446     int x, y;
    1447     gdk_window_get_origin(window, &x, &y);
    1448     return clientPoint + IntSize(x, y);
    1449 }
    1450 
    1451 
    14521444static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context)
    14531445{
     
    15201512    if (!context->dropHappened) {
    15211513        const IntPoint& position = context->lastMotionPosition;
    1522         DragData dragData(context->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(GTK_WIDGET(webView)), position), DragOperationNone);
     1514        DragData dragData(context->dataObject.get(), position, convertWidgetPointToScreenPoint(GTK_WIDGET(webView), position), DragOperationNone);
    15231515        core(webView)->dragController()->dragExited(&dragData);
    15241516    }
     
    15761568        return TRUE;
    15771569
    1578     DragData dragData(droppingContext->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(widget), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
     1570    DragData dragData(droppingContext->dataObject.get(), position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
    15791571    DragOperation operation = core(webView)->dragController()->dragUpdated(&dragData);
    15801572    gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
     
    16031595
    16041596    // If there are no more pending requests, start sending dragging data to WebCore.
    1605     DragData dragData(droppingContext->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(widget), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
     1597    DragData dragData(droppingContext->dataObject.get(), position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
    16061598    DragOperation operation = core(webView)->dragController()->dragEntered(&dragData);
    16071599    gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
     
    16201612
    16211613    IntPoint position(x, y);
    1622     DragData dragData(droppingContext->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(widget), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
     1614    DragData dragData(droppingContext->dataObject.get(), position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
    16231615    core(webView)->dragController()->performDrag(&dragData);
    16241616
  • trunk/Source/WebKit2/ChangeLog

    r88800 r88802  
     12011-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [GTK] Rename convertWidgetRectToScreenRect() to convertWidgetPointToScreenPoint()
     6        https://bugs.webkit.org/show_bug.cgi?id=62626
     7
     8        * UIProcess/API/gtk/PageClientImpl.cpp:
     9        (WebKit::PageClientImpl::screenToWindow): Implement this method
     10        using convertWidgetPointToScreenPoint().
     11        (WebKit::PageClientImpl::windowToScreen): Update to use
     12        convertWidgetPointToScreenPoint().
     13        * UIProcess/gtk/WebPopupMenuProxyGtk.cpp:
     14        (WebKit::WebPopupMenuProxyGtk::showPopupMenu): Use
     15        convertWidgetPointToScreenPoint().
     16
    1172011-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
    218
  • trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp

    r88669 r88802  
    188188IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
    189189{
    190     notImplemented();
    191     return point;
     190    IntPoint widgetPositionOnScreen = convertWidgetPointToScreenPoint(m_viewWidget, IntPoint());
     191    IntPoint result(point);
     192    result.move(-widgetPositionOnScreen.x(), -widgetPositionOnScreen.y());
     193    return result;
    192194}
    193195
    194196IntRect PageClientImpl::windowToScreen(const IntRect& rect)
    195197{
    196     return convertWidgetRectToScreenRect(m_viewWidget, rect);
     198    return IntRect(convertWidgetPointToScreenPoint(m_viewWidget, rect.location()), rect.size());
    197199}
    198200
  • trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp

    r87930 r88802  
    2929#include "NativeWebMouseEvent.h"
    3030#include "WebPopupItem.h"
     31#include <WebCore/GtkUtilities.h>
    3132#include <gtk/gtk.h>
    3233#include <wtf/gobject/GOwnPtr.h>
     
    8182    }
    8283
    83     int x = 0;
    84     int y = 0;
    85     if (GdkWindow* window = gtk_widget_get_window(m_webView))
    86         gdk_window_get_origin(window, &x, &y);
    87     IntPoint menuPosition(rect.x() + x, rect.y() + y + rect.height());
     84    IntPoint menuPosition = convertWidgetPointToScreenPoint(m_webView, rect.location());
     85    menuPosition.move(0, rect.height());
    8886
    8987    gulong unmapHandler = g_signal_connect(m_popup->platformMenu(), "unmap", G_CALLBACK(menuUnmapped), this);
Note: See TracChangeset for help on using the changeset viewer.