[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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133763 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8d5b5c32
2012-11-07 Allan Sandfeld Jensen <allan.jensen@digia.com>
[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 <aandrey@chromium.org>
Web Inspector: [Canvas] closure compiler fixes
......@@ -368,6 +368,9 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
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 @@ void ContextMenuController::checkOrEnableIfNeeded(ContextMenuItem& item) const
#endif
case ContextMenuItemTagNoAction:
case ContextMenuItemTagOpenLinkInNewWindow:
case ContextMenuItemTagOpenLinkInThisWindow:
case ContextMenuItemTagDownloadLinkToDisk:
case ContextMenuItemTagCopyLinkToClipboard:
case ContextMenuItemTagOpenImageInNewWindow:
......
......@@ -164,6 +164,7 @@ namespace WebCore {
ContextMenuItemTagMediaPlayPause,
ContextMenuItemTagMediaMute,
ContextMenuItemTagDictationAlternative,
ContextMenuItemTagOpenLinkInThisWindow,
ContextMenuItemBaseCustomTag = 5000,
ContextMenuItemCustomTagNoAction = 5998,
ContextMenuItemLastCustomTag = 5999,
......
......@@ -49,6 +49,9 @@ namespace WebCore {
#if ENABLE(CONTEXT_MENUS)
String contextMenuItemTagOpenLinkInNewWindow();
#if PLATFORM(QT)
String contextMenuItemTagOpenLinkInThisWindow();
#endif
String contextMenuItemTagDownloadLinkToDisk();
String contextMenuItemTagCopyLinkToClipboard();
String contextMenuItemTagOpenImageInNewWindow();
......
......@@ -88,6 +88,11 @@ String contextMenuItemTagOpenLinkInNewWindow()
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");
......
......@@ -171,6 +171,7 @@ static const char* editorCommandWebActions[] =
0, // OpenLink,
0, // OpenLinkInNewWindow,
0, // OpenLinkInThisWindow,
0, // OpenFrameInNewWindow,
0, // DownloadLinkToDisk,
......@@ -436,6 +437,7 @@ static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAct
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 @@ IntPoint QWebPagePrivate::TouchAdjuster::findCandidatePointForTouch(const IntPoi
\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 @@ void QWebPage::triggerAction(WebAction action, bool)
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 = frame->loader()->documentLoader()->unreachableURL();
if (url.isEmpty())
......@@ -2788,6 +2795,9 @@ QAction *QWebPage::action(WebAction action) const
case OpenFrameInNewWindow:
text = contextMenuItemTagOpenFrameInNewWindow();
break;
case OpenLinkInThisWindow:
text = contextMenuItemTagOpenLinkInThisWindow();
break;
case DownloadLinkToDisk:
text = contextMenuItemTagDownloadLinkToDisk();
......
......@@ -180,6 +180,8 @@ public:
CopyImageUrlToClipboard,
OpenLinkInThisWindow,
WebActionCount
};
......
2012-11-07 Allan Sandfeld Jensen <allan.jensen@digia.com>
[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 <senorblanco@chromium.org>
Unreviewed, rolling out r133143.
......
2012-11-07 Allan Sandfeld Jensen <allan.jensen@digia.com>
[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 <mikhail.pozdnyakov@intel.com>
[EFL][WK2] Add ewk_settings_preferred_minimum_contents_width_get/set API
......
......@@ -251,10 +251,14 @@ static QMenu* createContextMenu(QWebPage* page, QPoint position)
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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment