Title: [88802] trunk/Source
Revision
88802
Author
[email protected]
Date
2011-06-14 07:58:30 -0700 (Tue, 14 Jun 2011)

Log Message

2011-06-14  Carlos Garcia Campos  <[email protected]>

        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  <[email protected]>

        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  <[email protected]>

        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().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (88801 => 88802)


--- trunk/Source/WebCore/ChangeLog	2011-06-14 14:38:30 UTC (rev 88801)
+++ trunk/Source/WebCore/ChangeLog	2011-06-14 14:58:30 UTC (rev 88802)
@@ -2,6 +2,26 @@
 
         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  <[email protected]>
+
+        Reviewed by Martin Robinson.
+
         [GTK] Support authentication dialogs in WebKit2
         https://bugs.webkit.org/show_bug.cgi?id=62366
 

Modified: trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp (88801 => 88802)


--- trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp	2011-06-14 14:38:30 UTC (rev 88801)
+++ trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp	2011-06-14 14:58:30 UTC (rev 88802)
@@ -19,12 +19,12 @@
 #include "config.h"
 #include "GtkUtilities.h"
 
-#include "IntRect.h"
+#include "IntPoint.h"
 #include <gtk/gtk.h>
 
 namespace WebCore {
 
-IntRect convertWidgetRectToScreenRect(GtkWidget* widget, const IntRect& rect)
+IntPoint convertWidgetPointToScreenPoint(GtkWidget* widget, const IntPoint& point)
 {
     // FIXME: This is actually a very tricky operation and the results of this function should
     // only be thought of as a guess. For instance, sometimes it may not correctly take into
@@ -32,16 +32,14 @@
 
     GtkWidget* toplevelWidget = gtk_widget_get_toplevel(widget);
     if (!toplevelWidget || !gtk_widget_is_toplevel(toplevelWidget) || !GTK_IS_WINDOW(toplevelWidget))
-        return rect;
+        return point;
 
     int xInWindow, yInWindow;
-    gtk_widget_translate_coordinates(widget, toplevelWidget, rect.x(), rect.y(), &xInWindow, &yInWindow);
+    gtk_widget_translate_coordinates(widget, toplevelWidget, point.x(), point.y(), &xInWindow, &yInWindow);
     int windowOriginX, windowOriginY;
     gdk_window_get_origin(gtk_widget_get_window(toplevelWidget), &windowOriginX, &windowOriginY);
 
-    IntRect rectInScreenCoordinates(rect);
-    rectInScreenCoordinates.move(windowOriginX + xInWindow, windowOriginY + yInWindow);
-    return rectInScreenCoordinates;
+    return IntPoint(windowOriginX + xInWindow, windowOriginY + yInWindow);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/gtk/GtkUtilities.h (88801 => 88802)


--- trunk/Source/WebCore/platform/gtk/GtkUtilities.h	2011-06-14 14:38:30 UTC (rev 88801)
+++ trunk/Source/WebCore/platform/gtk/GtkUtilities.h	2011-06-14 14:58:30 UTC (rev 88802)
@@ -21,9 +21,9 @@
 
 namespace WebCore {
 
-class IntRect;
+class IntPoint;
 
-IntRect convertWidgetRectToScreenRect(GtkWidget*, const IntRect&);
+IntPoint convertWidgetPointToScreenPoint(GtkWidget*, const IntPoint&);
 
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/platform/gtk/PopupMenuGtk.cpp (88801 => 88802)


--- trunk/Source/WebCore/platform/gtk/PopupMenuGtk.cpp	2011-06-14 14:38:30 UTC (rev 88801)
+++ trunk/Source/WebCore/platform/gtk/PopupMenuGtk.cpp	2011-06-14 14:58:30 UTC (rev 88802)
@@ -29,6 +29,7 @@
 
 #include "FrameView.h"
 #include "GOwnPtr.h"
+#include "GtkUtilities.h"
 #include "HostWindow.h"
 #include <gtk/gtk.h>
 #include <wtf/text/CString.h>
@@ -82,13 +83,8 @@
         }
     }
 
-    int x = 0;
-    int y = 0;
-    GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(view->hostWindow()->platformPageClient()));
-    if (window)
-        gdk_window_get_origin(window, &x, &y);
-    IntPoint menuPosition(view->contentsToWindow(rect.location()));
-    menuPosition.move(x, y + rect.height());
+    IntPoint menuPosition = convertWidgetPointToScreenPoint(GTK_WIDGET(view->hostWindow()->platformPageClient()), view->contentsToWindow(rect.location()));
+    menuPosition.move(0, rect.height());
 
     m_popup->popUp(rect.size(), menuPosition, size, index, gtk_get_current_event());
 }

Modified: trunk/Source/WebKit/gtk/ChangeLog (88801 => 88802)


--- trunk/Source/WebKit/gtk/ChangeLog	2011-06-14 14:38:30 UTC (rev 88801)
+++ trunk/Source/WebKit/gtk/ChangeLog	2011-06-14 14:58:30 UTC (rev 88802)
@@ -2,6 +2,26 @@
 
         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  <[email protected]>
+
+        Reviewed by Martin Robinson.
+
         [GTK] Support authentication dialogs in WebKit2
         https://bugs.webkit.org/show_bug.cgi?id=62366
 

Modified: trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp (88801 => 88802)


--- trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp	2011-06-14 14:38:30 UTC (rev 88801)
+++ trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp	2011-06-14 14:58:30 UTC (rev 88802)
@@ -464,13 +464,12 @@
 
 IntRect ChromeClient::windowToScreen(const IntRect& rect) const
 {
-    return convertWidgetRectToScreenRect(GTK_WIDGET(m_webView), rect);
+    return IntRect(convertWidgetPointToScreenPoint(GTK_WIDGET(m_webView), rect.location()), rect.size());
 }
 
 IntPoint ChromeClient::screenToWindow(const IntPoint& point) const
 {
-    IntPoint widgetPositionOnScreen = convertWidgetRectToScreenRect(GTK_WIDGET(m_webView),
-                                                                    IntRect(IntPoint(), IntSize())).location();
+    IntPoint widgetPositionOnScreen = convertWidgetPointToScreenPoint(GTK_WIDGET(m_webView), IntPoint());
     IntPoint result(point);
     result.move(-widgetPositionOnScreen.x(), -widgetPositionOnScreen.y());
     return result;

Modified: trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp (88801 => 88802)


--- trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp	2011-06-14 14:38:30 UTC (rev 88801)
+++ trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp	2011-06-14 14:58:30 UTC (rev 88802)
@@ -57,6 +57,7 @@
 #include "FrameView.h"
 #include "GOwnPtrGtk.h"
 #include "GraphicsContext.h"
+#include "GtkUtilities.h"
 #include "GtkVersioning.h"
 #include "HTMLNames.h"
 #include "HitTestRequest.h"
@@ -144,7 +145,6 @@
 using namespace WebCore;
 
 static const double defaultDPI = 96.0;
-static IntPoint globalPointForClientPoint(GdkWindow* window, const IntPoint& clientPoint);
 
 enum {
     /* normal signals */
@@ -415,7 +415,7 @@
     location.expandedTo(IntPoint(gContextMenuMargin, gContextMenuMargin));
     location.shrunkTo(IntPoint(view->width() - gContextMenuMargin, view->height() - gContextMenuMargin));
 
-    IntPoint globalPoint(globalPointForClientPoint(gtk_widget_get_window(widget), location));
+    IntPoint globalPoint(convertWidgetPointToScreenPoint(widget, location));
     PlatformMouseEvent event(location, globalPoint, RightButton, MouseEventPressed, 0, false, false, false, false, gtk_get_current_event_time());
     return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event);
 }
@@ -1441,14 +1441,6 @@
     settings->setMinimumLogicalFontSize(minimumLogicalFontSize / 72.0 * DPI);
 }
 
-static IntPoint globalPointForClientPoint(GdkWindow* window, const IntPoint& clientPoint)
-{
-    int x, y;
-    gdk_window_get_origin(window, &x, &y);
-    return clientPoint + IntSize(x, y);
-}
-
-
 static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context)
 {
     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
@@ -1519,7 +1511,7 @@
     // happens in the case of a successful drop onto the view.
     if (!context->dropHappened) {
         const IntPoint& position = context->lastMotionPosition;
-        DragData dragData(context->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(GTK_WIDGET(webView)), position), DragOperationNone);
+        DragData dragData(context->dataObject.get(), position, convertWidgetPointToScreenPoint(GTK_WIDGET(webView), position), DragOperationNone);
         core(webView)->dragController()->dragExited(&dragData);
     }
 
@@ -1575,7 +1567,7 @@
     if (droppingContext->pendingDataRequests > 0)
         return TRUE;
 
-    DragData dragData(droppingContext->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(widget), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
+    DragData dragData(droppingContext->dataObject.get(), position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
     DragOperation operation = core(webView)->dragController()->dragUpdated(&dragData);
     gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
 
@@ -1602,7 +1594,7 @@
     const IntPoint& position = droppingContext->lastMotionPosition;
 
     // If there are no more pending requests, start sending dragging data to WebCore.
-    DragData dragData(droppingContext->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(widget), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
+    DragData dragData(droppingContext->dataObject.get(), position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
     DragOperation operation = core(webView)->dragController()->dragEntered(&dragData);
     gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
 }
@@ -1619,7 +1611,7 @@
     droppingContext->dropHappened = true;
 
     IntPoint position(x, y);
-    DragData dragData(droppingContext->dataObject.get(), position, globalPointForClientPoint(gtk_widget_get_window(widget), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
+    DragData dragData(droppingContext->dataObject.get(), position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
     core(webView)->dragController()->performDrag(&dragData);
 
     gtk_drag_finish(context, TRUE, FALSE, time);

Modified: trunk/Source/WebKit2/ChangeLog (88801 => 88802)


--- trunk/Source/WebKit2/ChangeLog	2011-06-14 14:38:30 UTC (rev 88801)
+++ trunk/Source/WebKit2/ChangeLog	2011-06-14 14:58:30 UTC (rev 88802)
@@ -2,6 +2,22 @@
 
         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().
+
+2011-06-14  Carlos Garcia Campos  <[email protected]>
+
+        Reviewed by Martin Robinson.
+
         [GTK] Support authentication dialogs in WebKit2
         https://bugs.webkit.org/show_bug.cgi?id=62366
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp (88801 => 88802)


--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp	2011-06-14 14:38:30 UTC (rev 88801)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp	2011-06-14 14:58:30 UTC (rev 88802)
@@ -187,13 +187,15 @@
 
 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
 {
-    notImplemented();
-    return point;
+    IntPoint widgetPositionOnScreen = convertWidgetPointToScreenPoint(m_viewWidget, IntPoint());
+    IntPoint result(point);
+    result.move(-widgetPositionOnScreen.x(), -widgetPositionOnScreen.y());
+    return result;
 }
 
 IntRect PageClientImpl::windowToScreen(const IntRect& rect)
 {
-    return convertWidgetRectToScreenRect(m_viewWidget, rect);
+    return IntRect(convertWidgetPointToScreenPoint(m_viewWidget, rect.location()), rect.size());
 }
 
 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled)

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp (88801 => 88802)


--- trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp	2011-06-14 14:38:30 UTC (rev 88801)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp	2011-06-14 14:58:30 UTC (rev 88802)
@@ -28,6 +28,7 @@
 
 #include "NativeWebMouseEvent.h"
 #include "WebPopupItem.h"
+#include <WebCore/GtkUtilities.h>
 #include <gtk/gtk.h>
 #include <wtf/gobject/GOwnPtr.h>
 #include <wtf/text/CString.h>
@@ -80,11 +81,8 @@
         }
     }
 
-    int x = 0;
-    int y = 0;
-    if (GdkWindow* window = gtk_widget_get_window(m_webView))
-        gdk_window_get_origin(window, &x, &y);
-    IntPoint menuPosition(rect.x() + x, rect.y() + y + rect.height());
+    IntPoint menuPosition = convertWidgetPointToScreenPoint(m_webView, rect.location());
+    menuPosition.move(0, rect.height());
 
     gulong unmapHandler = g_signal_connect(m_popup->platformMenu(), "unmap", G_CALLBACK(menuUnmapped), this);
     m_popup->popUp(rect.size(), menuPosition, size, selectedIndex, m_client->currentlyProcessedMouseDownEvent() ? m_client->currentlyProcessedMouseDownEvent()->nativeEvent() : 0);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to