Implemented opening links in new windows
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:30:28 +0000 (14:30 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2007 14:30:28 +0000 (14:30 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27545 268f45cc-cd09-0410-ab3c-d52691b4dbfc

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

index e61bc1e3f09cc343635110181b87a4dd828235cc..657221da5a57fa15ff692ab07b9daa620298088f 100644 (file)
@@ -414,18 +414,32 @@ QObject *QWebPage::createPlugin(const QString &classid, const QUrl &url, const Q
     return 0;
 }
 
+static WebCore::FrameLoadRequest frameLoadRequest(const QUrl &url, WebCore::Frame *frame)
+{
+    WebCore::ResourceRequest rr(WebCore::KURL(url.toString()),
+                                frame->loader()->outgoingReferrer());
+    return WebCore::FrameLoadRequest(rr);
+}
+
+static void openNewWindow(const QUrl& url, WebCore::Frame* frame)
+{
+    if (Page* oldPage = frame->page())
+        if (Page* newPage = oldPage->chrome()->createWindow(frame,
+                frameLoadRequest(url, frame)))
+            newPage->chrome()->show();
+}
+
 void QWebPage::webActionTriggered(WebAction action, bool checked)
 {
-    WebCore::Editor *editor = d->page->focusController()->focusedOrMainFrame()->editor();
+    WebCore::Frame *frame = d->page->focusController()->focusedOrMainFrame();
+    WebCore::Editor *editor = frame->editor();
     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),
+                targetFrame->d->frame->loader()->load(frameLoadRequest(d->currentContext.linkUrl(), wcFrame.get()),
                                                       /*lockHistory*/ false,
                                                       /*userGesture*/ true,
                                                       /*event*/ 0,
@@ -437,6 +451,7 @@ void QWebPage::webActionTriggered(WebAction action, bool checked)
             }
             // fall through
         case OpenLinkInNewWindow:
+            openNewWindow(d->currentContext.linkUrl(), frame);
             break;
         case OpenFrameInNewWindow:
             break;
@@ -445,6 +460,7 @@ void QWebPage::webActionTriggered(WebAction action, bool checked)
             editor->copyURL(WebCore::KURL(d->currentContext.linkUrl().toString()), d->currentContext.text());
             break;
         case OpenImageInNewWindow:
+            openNewWindow(d->currentContext.imageUrl(), frame);
             break;
         case DownloadImageToDisk:
         case CopyImageToClipboard:
index d347ae94c52447337ec6b71527babdbb756c419b..54f8d6599299b2627e36b90efaca0d6395ac7b46 100644 (file)
@@ -1,3 +1,14 @@
+2007-11-07  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars.
+
+        Implemented opening links in new windows
+
+        * Api/qwebpage.cpp:
+        (frameLoadRequest):
+        (openNewWindow):
+        (QWebPage::webActionTriggered):
+
 2007-11-07  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Lars.