Changed ContextMenu::setPlatformDescription for the Qt port to not show the qmenu...
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:29:11 +0000 (14:29 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:29:11 +0000 (14:29 +0000)
but instead just behave as a normal setter that takes ownership of the platform menu description (the qmenu).
Instead now QWebPage::contextMenuEvent() retrieves the QMenu after calling sendContextMenuEvent and calls exec()
on it.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27532 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/qt/ContextMenuQt.cpp
WebKit/qt/Api/qwebpage.cpp
WebKit/qt/ChangeLog
WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp

index 024cc9f50a818ee644b007050e577c62b05e175e..a6ed67a00bce41011ac69dc6e60051693ef4c6f6 100644 (file)
@@ -1,3 +1,16 @@
+2007-11-07  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars.
+
+        Changed ContextMenu::setPlatformDescription for the Qt port to not show the qmenu right away
+        but instead just behave as a normal setter that takes ownership of the platform menu description (the qmenu).
+        Instead now QWebPage::contextMenuEvent() retrieves the QMenu after calling sendContextMenuEvent and calls exec()
+        on it.
+
+        WARNING: NO TEST CASES ADDED OR CHANGED
+
+        * platform/qt/ContextMenuQt.cpp:
+
 2007-11-07  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Lars.
index 08a0b90f5ac4eaf66992a790af0ec0a13e9b0d37..39784ca587a898cc7c380fbf6e2dd64d5d04a9a0 100644 (file)
@@ -119,11 +119,6 @@ void ContextMenu::insertItem(unsigned position, ContextMenuItem& item)
 void ContextMenu::setPlatformDescription(PlatformMenuDescription menu)
 {
 #ifndef QT_NO_MENU
-    //qDebug("Switch menu(%p) %p to %p", this, (QMenu*)m_menu, menu);
-    if (menu == 0) {
-        FrameView *v = m_hitTestResult.innerNode()->document()->frame()->view();
-        m_menu->exec(v->containingWindow()->mapToGlobal(v->contentsToWindow(m_hitTestResult.point())));
-    }
     if (menu != m_menu) {
         delete m_menu;
         m_menu = menu;
index 8ed3e1dbb7e9499d5e74b4091db97ca5db7c8319..602f0cb5a2bb98645989908e3020dc0d9c25127e 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "Frame.h"
 #include "ChromeClientQt.h"
+#include "ContextMenu.h"
 #include "ContextMenuClientQt.h"
 #include "DragClientQt.h"
 #include "DragController.h"
@@ -468,8 +469,16 @@ void QWebPage::mouseReleaseEvent(QMouseEvent *ev)
 void QWebPage::contextMenuEvent(QContextMenuEvent *ev)
 {
     QWebFramePrivate *frame = d->currentFrame(ev->pos())->d;
-    if (frame->eventHandler)
-        frame->eventHandler->sendContextMenuEvent(PlatformMouseEvent(ev, 1));
+    if (!frame->eventHandler)
+        return;
+    d->page->contextMenuController()->clearContextMenu();
+    frame->eventHandler->sendContextMenuEvent(PlatformMouseEvent(ev, 1));
+    ContextMenu *menu = d->page->contextMenuController()->contextMenu();
+    QMenu *qmenu = menu->releasePlatformDescription();
+    if (qmenu) {
+        qmenu->exec(ev->globalPos());
+        delete qmenu;
+    }
 }
 
 void QWebPage::wheelEvent(QWheelEvent *ev)
index 45e2cd97092d2cebf0685d826c9ce0afc1eee839..f5facb737e54a40eb18311c8548a142d146675c3 100644 (file)
@@ -1,3 +1,17 @@
+2007-11-07  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars.
+
+        Changed ContextMenu::setPlatformDescription for the Qt port to not show the qmenu right away
+        but instead just behave as a normal setter that takes ownership of the platform menu description (the qmenu).
+        Instead now QWebPage::contextMenuEvent() retrieves the QMenu after calling sendContextMenuEvent and calls exec()
+        on it.
+
+        * Api/qwebpage.cpp:
+        (QWebPage::contextMenuEvent):
+        * WebCoreSupport/ContextMenuClientQt.cpp:
+        (WebCore::ContextMenuClientQt::getCustomMenuFromDefaultItems):
+
 2007-11-07  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Lars.
index 144c57c2b6d34b2d93b3ca19a525827c65760112..e65c495f2b3c4eb7bc4fb49c0b30e998a5f81049 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "ContextMenuClientQt.h"
 
+#include "ContextMenu.h"
 #include "HitTestResult.h"
 #include "KURL.h"
 #include "Shared.h"
@@ -40,10 +41,10 @@ void ContextMenuClientQt::contextMenuDestroyed()
     notImplemented();
 }
 
-PlatformMenuDescription ContextMenuClientQt::getCustomMenuFromDefaultItems(ContextMenu*)
+PlatformMenuDescription ContextMenuClientQt::getCustomMenuFromDefaultItems(ContextMenu* menu)
 {
-    notImplemented();
-    return PlatformMenuDescription();
+    // warning: this transfers the ownership to the caller
+    return menu->releasePlatformDescription();
 }
 
 void ContextMenuClientQt::contextMenuItemSelected(ContextMenuItem*, const ContextMenu*)