Title: [133763] trunk
Revision
133763
Author
[email protected]
Date
2012-11-07 08:12:53 -0800 (Wed, 07 Nov 2012)

Log Message

[Qt] Open link in this window action
https://bugs.webkit.org/show_bug.cgi?id=101226

Reviewed by Simon Hausmann.

Source/WebCore:

Adds the action to the WebCore context-menu controller.

* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected):
(WebCore::ContextMenuController::checkOrEnableIfNeeded):
* platform/ContextMenuItem.h:
* platform/LocalizedStrings.h:
* platform/qt/LocalizedStringsQt.cpp:
(WebCore::contextMenuItemTagOpenLinkInThisWindow):

Source/WebKit/qt:

Adds the action to QtWebKit.

* Api/qwebpage.cpp:
(webActionForContextMenuAction):
(QWebPage::triggerAction):
(QWebPage::action):
* Api/qwebpage.h:

Tools:

Populates the context-menu with the new action when the default action is to open in a new window.

* QtTestBrowser/webview.cpp:
(createContextMenu):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (133762 => 133763)


--- trunk/Source/WebCore/ChangeLog	2012-11-07 16:05:27 UTC (rev 133762)
+++ trunk/Source/WebCore/ChangeLog	2012-11-07 16:12:53 UTC (rev 133763)
@@ -1,3 +1,20 @@
+2012-11-07  Allan Sandfeld Jensen  <[email protected]>
+
+        [Qt] Open link in this window action
+        https://bugs.webkit.org/show_bug.cgi?id=101226
+
+        Reviewed by Simon Hausmann.
+
+        Adds the action to the WebCore context-menu controller.
+
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::contextMenuItemSelected):
+        (WebCore::ContextMenuController::checkOrEnableIfNeeded):
+        * platform/ContextMenuItem.h:
+        * platform/LocalizedStrings.h:
+        * platform/qt/LocalizedStringsQt.cpp:
+        (WebCore::contextMenuItemTagOpenLinkInThisWindow):
+
 2012-11-07  Andrey Adaikin  <[email protected]>
 
         Web Inspector: [Canvas] closure compiler fixes

Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (133762 => 133763)


--- trunk/Source/WebCore/page/ContextMenuController.cpp	2012-11-07 16:05:27 UTC (rev 133762)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp	2012-11-07 16:12:53 UTC (rev 133763)
@@ -368,6 +368,9 @@
         else
             openNewWindow(m_hitTestResult.absoluteLinkURL(), frame);
         break;
+    case ContextMenuItemTagOpenLinkInThisWindow:
+        frame->loader()->loadFrameRequest(FrameLoadRequest(frame->document()->securityOrigin(), ResourceRequest(m_hitTestResult.absoluteLinkURL(), frame->loader()->outgoingReferrer())), false, false, 0, 0, MaybeSendReferrer);
+        break;
     case ContextMenuItemTagBold:
         frame->editor()->command("ToggleBold").execute();
         break;
@@ -1297,6 +1300,7 @@
 #endif
         case ContextMenuItemTagNoAction:
         case ContextMenuItemTagOpenLinkInNewWindow:
+        case ContextMenuItemTagOpenLinkInThisWindow:
         case ContextMenuItemTagDownloadLinkToDisk:
         case ContextMenuItemTagCopyLinkToClipboard:
         case ContextMenuItemTagOpenImageInNewWindow:

Modified: trunk/Source/WebCore/platform/ContextMenuItem.h (133762 => 133763)


--- trunk/Source/WebCore/platform/ContextMenuItem.h	2012-11-07 16:05:27 UTC (rev 133762)
+++ trunk/Source/WebCore/platform/ContextMenuItem.h	2012-11-07 16:12:53 UTC (rev 133763)
@@ -164,6 +164,7 @@
         ContextMenuItemTagMediaPlayPause,
         ContextMenuItemTagMediaMute,
         ContextMenuItemTagDictationAlternative,
+        ContextMenuItemTagOpenLinkInThisWindow,
         ContextMenuItemBaseCustomTag = 5000,
         ContextMenuItemCustomTagNoAction = 5998,
         ContextMenuItemLastCustomTag = 5999,

Modified: trunk/Source/WebCore/platform/LocalizedStrings.h (133762 => 133763)


--- trunk/Source/WebCore/platform/LocalizedStrings.h	2012-11-07 16:05:27 UTC (rev 133762)
+++ trunk/Source/WebCore/platform/LocalizedStrings.h	2012-11-07 16:12:53 UTC (rev 133763)
@@ -49,6 +49,9 @@
 
 #if ENABLE(CONTEXT_MENUS)
     String contextMenuItemTagOpenLinkInNewWindow();
+#if PLATFORM(QT)
+    String contextMenuItemTagOpenLinkInThisWindow();
+#endif
     String contextMenuItemTagDownloadLinkToDisk();
     String contextMenuItemTagCopyLinkToClipboard();
     String contextMenuItemTagOpenImageInNewWindow();

Modified: trunk/Source/WebCore/platform/qt/LocalizedStringsQt.cpp (133762 => 133763)


--- trunk/Source/WebCore/platform/qt/LocalizedStringsQt.cpp	2012-11-07 16:05:27 UTC (rev 133762)
+++ trunk/Source/WebCore/platform/qt/LocalizedStringsQt.cpp	2012-11-07 16:12:53 UTC (rev 133763)
@@ -88,6 +88,11 @@
     return QCoreApplication::translate("QWebPage", "Open in New Window", "Open in New Window context menu item");
 }
 
+String contextMenuItemTagOpenLinkInThisWindow()
+{
+    return QCoreApplication::translate("QWebPage", "Open in This Window", "Open in This Window context menu item");
+}
+
 String contextMenuItemTagDownloadLinkToDisk()
 {
     return QCoreApplication::translate("QWebPage", "Save Link...", "Download Linked File context menu item");

Modified: trunk/Source/WebKit/qt/Api/qwebpage.cpp (133762 => 133763)


--- trunk/Source/WebKit/qt/Api/qwebpage.cpp	2012-11-07 16:05:27 UTC (rev 133762)
+++ trunk/Source/WebKit/qt/Api/qwebpage.cpp	2012-11-07 16:12:53 UTC (rev 133763)
@@ -171,6 +171,7 @@
     0, // OpenLink,
 
     0, // OpenLinkInNewWindow,
+    0, // OpenLinkInThisWindow,
     0, // OpenFrameInNewWindow,
 
     0, // DownloadLinkToDisk,
@@ -436,6 +437,7 @@
     switch (action) {
         case WebCore::ContextMenuItemTagOpenLink: return QWebPage::OpenLink;
         case WebCore::ContextMenuItemTagOpenLinkInNewWindow: return QWebPage::OpenLinkInNewWindow;
+        case WebCore::ContextMenuItemTagOpenLinkInThisWindow: return QWebPage::OpenLinkInThisWindow;
         case WebCore::ContextMenuItemTagDownloadLinkToDisk: return QWebPage::DownloadLinkToDisk;
         case WebCore::ContextMenuItemTagCopyLinkToClipboard: return QWebPage::CopyLinkToClipboard;
         case WebCore::ContextMenuItemTagOpenImageInNewWindow: return QWebPage::OpenImageInNewWindow;
@@ -1693,6 +1695,7 @@
     \value NoWebAction No action is triggered.
     \value OpenLink Open the current link.
     \value OpenLinkInNewWindow Open the current link in a new window.
+    \value OpenLinkInThisWindow Open the current link without opening a new window. Used on links that would default to opening in another frame or a new window. (Added in Qt 5.0)
     \value OpenFrameInNewWindow Replicate the current frame in a new window.
     \value DownloadLinkToDisk Download the current link to the disk.
     \value CopyLinkToClipboard Copy the current link to the clipboard.
@@ -2367,6 +2370,10 @@
         case OpenLinkInNewWindow:
             openNewWindow(d->hitTestResult.linkUrl(), frame);
             break;
+        case OpenLinkInThisWindow:
+            frame->loader()->loadFrameRequest(frameLoadRequest(d->hitTestResult.linkUrl(), frame),
+                /*lockHistory*/ false, /*lockBackForwardList*/ false, /*event*/ 0, /*FormState*/ 0, MaybeSendReferrer);
+            break;
         case OpenFrameInNewWindow: {
             KURL url = ""
             if (url.isEmpty())
@@ -2788,6 +2795,9 @@
         case OpenFrameInNewWindow:
             text = contextMenuItemTagOpenFrameInNewWindow();
             break;
+        case OpenLinkInThisWindow:
+            text = contextMenuItemTagOpenLinkInThisWindow();
+            break;
 
         case DownloadLinkToDisk:
             text = contextMenuItemTagDownloadLinkToDisk();

Modified: trunk/Source/WebKit/qt/Api/qwebpage.h (133762 => 133763)


--- trunk/Source/WebKit/qt/Api/qwebpage.h	2012-11-07 16:05:27 UTC (rev 133762)
+++ trunk/Source/WebKit/qt/Api/qwebpage.h	2012-11-07 16:12:53 UTC (rev 133763)
@@ -180,6 +180,8 @@
 
         CopyImageUrlToClipboard,
 
+        OpenLinkInThisWindow,
+
         WebActionCount
     };
 

Modified: trunk/Source/WebKit/qt/ChangeLog (133762 => 133763)


--- trunk/Source/WebKit/qt/ChangeLog	2012-11-07 16:05:27 UTC (rev 133762)
+++ trunk/Source/WebKit/qt/ChangeLog	2012-11-07 16:12:53 UTC (rev 133763)
@@ -1,3 +1,18 @@
+2012-11-07  Allan Sandfeld Jensen  <[email protected]>
+
+        [Qt] Open link in this window action
+        https://bugs.webkit.org/show_bug.cgi?id=101226
+
+        Reviewed by Simon Hausmann.
+
+        Adds the action to QtWebKit.
+
+        * Api/qwebpage.cpp:
+        (webActionForContextMenuAction):
+        (QWebPage::triggerAction):
+        (QWebPage::action):
+        * Api/qwebpage.h:
+
 2012-11-01  Stephen White  <[email protected]>
 
         Unreviewed, rolling out r133143.

Modified: trunk/Tools/ChangeLog (133762 => 133763)


--- trunk/Tools/ChangeLog	2012-11-07 16:05:27 UTC (rev 133762)
+++ trunk/Tools/ChangeLog	2012-11-07 16:12:53 UTC (rev 133763)
@@ -1,3 +1,15 @@
+2012-11-07  Allan Sandfeld Jensen  <[email protected]>
+
+        [Qt] Open link in this window action
+        https://bugs.webkit.org/show_bug.cgi?id=101226
+
+        Reviewed by Simon Hausmann.
+
+        Populates the context-menu with the new action when the default action is to open in a new window.
+
+        * QtTestBrowser/webview.cpp:
+        (createContextMenu):
+
 2012-11-07  Mikhail Pozdnyakov  <[email protected]>
 
         [EFL][WK2] Add ewk_settings_preferred_minimum_contents_width_get/set API

Modified: trunk/Tools/QtTestBrowser/webview.cpp (133762 => 133763)


--- trunk/Tools/QtTestBrowser/webview.cpp	2012-11-07 16:05:27 UTC (rev 133762)
+++ trunk/Tools/QtTestBrowser/webview.cpp	2012-11-07 16:12:53 UTC (rev 133763)
@@ -251,10 +251,14 @@
     QWebHitTestResult r = page->mainFrame()->hitTestContent(position);
 
     if (!r.linkUrl().isEmpty()) {
+#ifndef QT_NO_DESKTOPSERVICES
         WebPage* webPage = qobject_cast<WebPage*>(page);
         QAction* newTabAction = menu->addAction("Open in Default &Browser", webPage, SLOT(openUrlInDefaultBrowser()));
         newTabAction->setData(r.linkUrl());
         menu->insertAction(menu->actions().at(2), newTabAction);
+#endif
+        if (r.linkTargetFrame() != r.frame())
+            menu->insertAction(menu->actions().at(0), page->action(QWebPage::OpenLinkInThisWindow));
     }
     return menu;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to