Changeset 88802 in webkit
- Timestamp:
- Jun 14, 2011 7:58:30 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r88800 r88802 1 2011-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 1 21 2011-06-14 Carlos Garcia Campos <cgarcia@igalia.com> 2 22 -
trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp
r85987 r88802 20 20 #include "GtkUtilities.h" 21 21 22 #include "Int Rect.h"22 #include "IntPoint.h" 23 23 #include <gtk/gtk.h> 24 24 25 25 namespace WebCore { 26 26 27 Int Rect convertWidgetRectToScreenRect(GtkWidget* widget, const IntRect& rect)27 IntPoint convertWidgetPointToScreenPoint(GtkWidget* widget, const IntPoint& point) 28 28 { 29 29 // FIXME: This is actually a very tricky operation and the results of this function should … … 33 33 GtkWidget* toplevelWidget = gtk_widget_get_toplevel(widget); 34 34 if (!toplevelWidget || !gtk_widget_is_toplevel(toplevelWidget) || !GTK_IS_WINDOW(toplevelWidget)) 35 return rect;35 return point; 36 36 37 37 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); 39 39 int windowOriginX, windowOriginY; 40 40 gdk_window_get_origin(gtk_widget_get_window(toplevelWidget), &windowOriginX, &windowOriginY); 41 41 42 IntRect rectInScreenCoordinates(rect); 43 rectInScreenCoordinates.move(windowOriginX + xInWindow, windowOriginY + yInWindow); 44 return rectInScreenCoordinates; 42 return IntPoint(windowOriginX + xInWindow, windowOriginY + yInWindow); 45 43 } 46 44 -
trunk/Source/WebCore/platform/gtk/GtkUtilities.h
r85987 r88802 22 22 namespace WebCore { 23 23 24 class Int Rect;24 class IntPoint; 25 25 26 Int Rect convertWidgetRectToScreenRect(GtkWidget*, const IntRect&);26 IntPoint convertWidgetPointToScreenPoint(GtkWidget*, const IntPoint&); 27 27 28 28 } // namespace WebCore -
trunk/Source/WebCore/platform/gtk/PopupMenuGtk.cpp
r87930 r88802 30 30 #include "FrameView.h" 31 31 #include "GOwnPtr.h" 32 #include "GtkUtilities.h" 32 33 #include "HostWindow.h" 33 34 #include <gtk/gtk.h> … … 83 84 } 84 85 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()); 92 88 93 89 m_popup->popUp(rect.size(), menuPosition, size, index, gtk_get_current_event()); -
trunk/Source/WebKit/gtk/ChangeLog
r88800 r88802 1 2011-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 1 21 2011-06-14 Carlos Garcia Campos <cgarcia@igalia.com> 2 22 -
trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
r88754 r88802 465 465 IntRect ChromeClient::windowToScreen(const IntRect& rect) const 466 466 { 467 return convertWidgetRectToScreenRect(GTK_WIDGET(m_webView), rect);467 return IntRect(convertWidgetPointToScreenPoint(GTK_WIDGET(m_webView), rect.location()), rect.size()); 468 468 } 469 469 470 470 IntPoint ChromeClient::screenToWindow(const IntPoint& point) const 471 471 { 472 IntPoint widgetPositionOnScreen = convertWidgetRectToScreenRect(GTK_WIDGET(m_webView), 473 IntRect(IntPoint(), IntSize())).location(); 472 IntPoint widgetPositionOnScreen = convertWidgetPointToScreenPoint(GTK_WIDGET(m_webView), IntPoint()); 474 473 IntPoint result(point); 475 474 result.move(-widgetPositionOnScreen.x(), -widgetPositionOnScreen.y()); -
trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp
r88734 r88802 58 58 #include "GOwnPtrGtk.h" 59 59 #include "GraphicsContext.h" 60 #include "GtkUtilities.h" 60 61 #include "GtkVersioning.h" 61 62 #include "HTMLNames.h" … … 145 146 146 147 static const double defaultDPI = 96.0; 147 static IntPoint globalPointForClientPoint(GdkWindow* window, const IntPoint& clientPoint);148 148 149 149 enum { … … 416 416 location.shrunkTo(IntPoint(view->width() - gContextMenuMargin, view->height() - gContextMenuMargin)); 417 417 418 IntPoint globalPoint( globalPointForClientPoint(gtk_widget_get_window(widget), location));418 IntPoint globalPoint(convertWidgetPointToScreenPoint(widget, location)); 419 419 PlatformMouseEvent event(location, globalPoint, RightButton, MouseEventPressed, 0, false, false, false, false, gtk_get_current_event_time()); 420 420 return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event); … … 1442 1442 } 1443 1443 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 1452 1444 static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context) 1453 1445 { … … 1520 1512 if (!context->dropHappened) { 1521 1513 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); 1523 1515 core(webView)->dragController()->dragExited(&dragData); 1524 1516 } … … 1576 1568 return TRUE; 1577 1569 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))); 1579 1571 DragOperation operation = core(webView)->dragController()->dragUpdated(&dragData); 1580 1572 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); … … 1603 1595 1604 1596 // 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))); 1606 1598 DragOperation operation = core(webView)->dragController()->dragEntered(&dragData); 1607 1599 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); … … 1620 1612 1621 1613 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))); 1623 1615 core(webView)->dragController()->performDrag(&dragData); 1624 1616 -
trunk/Source/WebKit2/ChangeLog
r88800 r88802 1 2011-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 1 17 2011-06-14 Carlos Garcia Campos <cgarcia@igalia.com> 2 18 -
trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
r88669 r88802 188 188 IntPoint PageClientImpl::screenToWindow(const IntPoint& point) 189 189 { 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; 192 194 } 193 195 194 196 IntRect PageClientImpl::windowToScreen(const IntRect& rect) 195 197 { 196 return convertWidgetRectToScreenRect(m_viewWidget, rect);198 return IntRect(convertWidgetPointToScreenPoint(m_viewWidget, rect.location()), rect.size()); 197 199 } 198 200 -
trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp
r87930 r88802 29 29 #include "NativeWebMouseEvent.h" 30 30 #include "WebPopupItem.h" 31 #include <WebCore/GtkUtilities.h> 31 32 #include <gtk/gtk.h> 32 33 #include <wtf/gobject/GOwnPtr.h> … … 81 82 } 82 83 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()); 88 86 89 87 gulong unmapHandler = g_signal_connect(m_popup->platformMenu(), "unmap", G_CALLBACK(menuUnmapped), this);
Note: See TracChangeset
for help on using the changeset viewer.