Bug 1106101 - Let people open searches in new tabs with ctrl/cmd+click or middle mouse button. ui-r=phlsa, r=florian

This commit is contained in:
Blake Winton 2014-12-17 15:23:44 -05:00
Родитель 81a9946ddf
Коммит 596118b5c6
2 изменённых файлов: 34 добавлений и 5 удалений

Просмотреть файл

@ -939,12 +939,24 @@
this.closePopup();
controller.handleEscape();
// Fill in the search bar's value
searchBar.value = search;
// open the search results according to the clicking subtlety
var where = whereToOpenLink(aEvent, false, true);
// But open ctrl/cmd clicks on autocomplete items in a new background tab.
if (where == "tab" && (aEvent instanceof MouseEvent) &&
(aEvent.button == 1 ||
#ifdef XP_MACOSX
aEvent.metaKey))
#else
aEvent.ctrlKey))
#endif
where = "tab-background";
searchBar.doSearch(search, where);
if (where == "tab-background")
searchBar.focus();
else
searchBar.value = search;
}
]]></body>
</method>

Просмотреть файл

@ -472,6 +472,8 @@
var textValue = textBox.value;
var where = "current";
// Open ctrl/cmd clicks on one-off buttons in a new background tab.
if (aEvent && aEvent.originalTarget.getAttribute("anonid") == "search-go-button") {
if (aEvent.button == 2)
return;
@ -479,11 +481,20 @@
}
else {
var newTabPref = textBox._prefBranch.getBoolPref("browser.search.openintab");
if ((aEvent && aEvent.altKey) ^ newTabPref)
if (((aEvent instanceof KeyboardEvent) && aEvent.altKey) ^ newTabPref)
where = "tab";
if ((aEvent instanceof MouseEvent) && (aEvent.button == 1 ||
#ifdef XP_MACOSX
aEvent.metaKey))
#else
aEvent.ctrlKey))
#endif
where = "tab-background";
}
this.doSearch(textValue, where, aEngine);
if (where == "tab-background")
this.focus();
]]></body>
</method>
@ -509,7 +520,13 @@
var submission = engine.getSubmission(aData, null, "searchbar");
BrowserSearch.recordSearchInHealthReport(engine, "searchbar");
// null parameter below specifies HTML response for search
openUILinkIn(submission.uri.spec, aWhere, null, submission.postData);
let params = {
postData: submission.postData,
inBackground: aWhere == "tab-background"
};
openUILinkIn(submission.uri.spec,
aWhere == "tab-background" ? "tab" : aWhere,
params);
]]></body>
</method>
</implementation>