Added and implemented the "OpenLink" action.
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:30:22 +0000 (14:30 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:30:22 +0000 (14:30 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27544 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/qt/Api/qwebpage.cpp
WebKit/qt/Api/qwebpage.h
WebKit/qt/ChangeLog

index 9d5995b4a742277928d2ba906d8143fed0f12e32..e61bc1e3f09cc343635110181b87a4dd828235cc 100644 (file)
@@ -42,6 +42,7 @@
 #include "Settings.h"
 #include "Page.h"
 #include "FrameLoader.h"
+#include "FrameLoadRequest.h"
 #include "KURL.h"
 #include "Image.h"
 #include "IconDatabase.h"
@@ -52,6 +53,8 @@
 #include "PlatformKeyboardEvent.h"
 #include "PlatformWheelEvent.h"
 #include "ProgressTracker.h"
+#include "RefPtr.h"
+#include "HashMap.h"
 #include "HitTestResult.h"
 #include "LocalizedStrings.h"
 
@@ -129,6 +132,7 @@ void QWebPagePrivate::createMainFrame()
 static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAction action)
 {
     switch (action) {
+        case WebCore::ContextMenuItemTagOpenLink: return QWebPage::OpenLink;
         case WebCore::ContextMenuItemTagOpenLinkInNewWindow: return QWebPage::OpenLinkInNewWindow;
         case WebCore::ContextMenuItemTagDownloadLinkToDisk: return QWebPage::DownloadLinkToDisk;
         case WebCore::ContextMenuItemTagCopyLinkToClipboard: return QWebPage::CopyLinkToClipboard;
@@ -416,14 +420,32 @@ void QWebPage::webActionTriggered(WebAction action, bool checked)
     const char *command = 0;
 
     switch (action) {
+        case OpenLink:
+            if (QWebFrame *targetFrame = d->currentContext.targetFrame()) {
+                WTF::RefPtr<WebCore::Frame> wcFrame = targetFrame->d->frame;
+                WebCore::ResourceRequest rr(WebCore::KURL(d->currentContext.linkUrl().toString()),
+                                            wcFrame->loader()->outgoingReferrer());
+                targetFrame->d->frame->loader()->load(WebCore::FrameLoadRequest(rr),
+                                                      /*lockHistory*/ false,
+                                                      /*userGesture*/ true,
+                                                      /*event*/ 0,
+                                                      /*HTMLFormElement*/ 0,
+                                                      /*formValues*/
+                                                      WTF::HashMap<String, String>());
+                break;
+            } else {
+            }
+            // fall through
         case OpenLinkInNewWindow:
             break;
         case OpenFrameInNewWindow:
+            break;
         case DownloadLinkToDisk:
         case CopyLinkToClipboard:
             editor->copyURL(WebCore::KURL(d->currentContext.linkUrl().toString()), d->currentContext.text());
             break;
         case OpenImageInNewWindow:
+            break;
         case DownloadImageToDisk:
         case CopyImageToClipboard:
             break;
@@ -592,6 +614,9 @@ QAction *QWebPage::webAction(WebAction action) const
     QString text;
 
     switch (action) {
+        case OpenLink:
+            text = contextMenuItemTagOpenLink();
+            break;
         case OpenLinkInNewWindow:
             text = contextMenuItemTagOpenLinkInNewWindow();
             break;
index 29691d263247a83a043f253154621d96211e8f54..59cefc5f9bbda342207b991e304f8d72ab4580fe 100644 (file)
@@ -71,6 +71,8 @@ public:
     enum WebAction {
         NoWebAction = - 1,
 
+        OpenLink,
+
         OpenLinkInNewWindow,
         OpenFrameInNewWindow,
 
index 33c98999e2fb146d65f2adce0660109c180e858a..d347ae94c52447337ec6b71527babdbb756c419b 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-07  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars.
+
+        Added and implemented the "OpenLink" action.
+
+        * Api/qwebpage.cpp:
+        (webActionForContextMenuAction):
+        (QWebPage::webActionTriggered):
+        (QWebPage::webAction):
+        * Api/qwebpage.h:
+
 2007-11-07  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Lars.