mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1110678 - Re-implement Ctrl+up/down and Alt+up/down in the search field, r=felipe.
This commit is contained in:
parent
acd3fa8369
commit
eeaf0c7548
@ -1000,6 +1000,32 @@
|
||||
class="search-setting-button search-panel-header"
|
||||
label="&changeSearchSettings.button;"/>
|
||||
</content>
|
||||
<implementation>
|
||||
<method name="updateHeader">
|
||||
<body><![CDATA[
|
||||
let currentEngine = Services.search.currentEngine;
|
||||
let uri = currentEngine.iconURI;
|
||||
if (uri) {
|
||||
uri = uri.spec;
|
||||
this.setAttribute("src", PlacesUtils.getImageURLForResolution(window, uri));
|
||||
}
|
||||
else {
|
||||
// If the default has just been changed to a provider without icon,
|
||||
// avoid showing the icon of the previous default provider.
|
||||
this.removeAttribute("src");
|
||||
}
|
||||
|
||||
const kBundleURI = "chrome://browser/locale/search.properties";
|
||||
let bundle = Services.strings.createBundle(kBundleURI);
|
||||
let headerText = bundle.formatStringFromName("searchHeader",
|
||||
[currentEngine.name], 1);
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "searchbar-engine-name")
|
||||
.setAttribute("value", headerText);
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "searchbar-engine")
|
||||
.engine = currentEngine;
|
||||
]]></body>
|
||||
</method>
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="popupshowing"><![CDATA[
|
||||
// First handle deciding if we are showing the reduced version of the
|
||||
@ -1022,26 +1048,7 @@
|
||||
}
|
||||
|
||||
// Show the current default engine in the top header of the panel.
|
||||
let currentEngine = Services.search.currentEngine;
|
||||
let uri = currentEngine.iconURI;
|
||||
if (uri) {
|
||||
uri = uri.spec;
|
||||
this.setAttribute("src", PlacesUtils.getImageURLForResolution(window, uri));
|
||||
}
|
||||
else {
|
||||
// If the default has just been changed to a provider without icon,
|
||||
// avoid showing the icon of the previous default provider.
|
||||
this.removeAttribute("src");
|
||||
}
|
||||
|
||||
const kBundleURI = "chrome://browser/locale/search.properties";
|
||||
let bundle = Services.strings.createBundle(kBundleURI);
|
||||
let headerText = bundle.formatStringFromName("searchHeader",
|
||||
[currentEngine.name], 1);
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "searchbar-engine-name")
|
||||
.setAttribute("value", headerText);
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "searchbar-engine")
|
||||
.engine = currentEngine;
|
||||
this.updateHeader();
|
||||
|
||||
// Update the 'Search for <keywords> with:" header.
|
||||
let headerSearchText =
|
||||
@ -1074,6 +1081,8 @@
|
||||
|
||||
let addEngines = gBrowser.selectedBrowser.engines;
|
||||
if (addEngines && addEngines.length > 0) {
|
||||
const kBundleURI = "chrome://browser/locale/search.properties";
|
||||
let bundle = Services.strings.createBundle(kBundleURI);
|
||||
for (let engine of addEngines) {
|
||||
let button = document.createElementNS(kXULNS, "button");
|
||||
let label = bundle.formatStringFromName("cmd_addFoundEngine",
|
||||
@ -1109,8 +1118,9 @@
|
||||
hiddenList = [];
|
||||
}
|
||||
|
||||
let currentEngineName = Services.search.currentEngine.name;
|
||||
let engines = Services.search.getVisibleEngines()
|
||||
.filter(e => e.name != currentEngine.name &&
|
||||
.filter(e => e.name != currentEngineName &&
|
||||
hiddenList.indexOf(e.name) == -1);
|
||||
|
||||
let header = document.getAnonymousElementByAttribute(this, "anonid",
|
||||
|
@ -467,6 +467,9 @@
|
||||
|
||||
aEvent.preventDefault();
|
||||
aEvent.stopPropagation();
|
||||
|
||||
if (this.hasAttribute("oneoffui"))
|
||||
this.openSuggestionsPanel();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
@ -647,10 +650,9 @@
|
||||
|
||||
<field name="_ignoreFocus">false</field>
|
||||
|
||||
<method name="selectEngine">
|
||||
<method name="rebuildPopup">
|
||||
<body><![CDATA[
|
||||
// Override this method to avoid accidentally changing the default
|
||||
// engine using the keyboard shortcuts of the old UI.
|
||||
this._textbox.popup.updateHeader();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
@ -914,7 +916,11 @@
|
||||
<![CDATA[
|
||||
// Don't open search popup if history popup is open
|
||||
if (!this.popupOpen) {
|
||||
document.getBindingParent(this).searchButton.open = true;
|
||||
let searchBox = document.getBindingParent(this);
|
||||
if (searchBox.hasAttribute("oneoffui"))
|
||||
searchBox.openSuggestionsPanel();
|
||||
else
|
||||
searchBox.searchButton.open = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -980,8 +986,54 @@
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
// accel + up/down changes the default engine and shouldn't affect
|
||||
// the selection on the one-off buttons.
|
||||
#ifdef XP_MACOSX
|
||||
if (aEvent.metaKey)
|
||||
#else
|
||||
if (aEvent.ctrlKey)
|
||||
#endif
|
||||
return;
|
||||
|
||||
let selectedButton = this.getSelectedOneOff();
|
||||
|
||||
// Alt + up/down is very similar to (shift +) tab but differs in that
|
||||
// it loops through the list, whereas tab will move the focus out.
|
||||
if (aEvent.altKey &&
|
||||
(aEvent.keyCode == KeyEvent.DOM_VK_DOWN ||
|
||||
aEvent.keyCode == KeyEvent.DOM_VK_UP)) {
|
||||
let forward = aEvent.keyCode == KeyEvent.DOM_VK_DOWN;
|
||||
if (selectedButton) {
|
||||
// cycle though the list of one-off buttons.
|
||||
selectedButton.removeAttribute("selected");
|
||||
if (forward)
|
||||
selectedButton = selectedButton.nextSibling;
|
||||
else
|
||||
selectedButton = selectedButton.previousSibling;
|
||||
|
||||
// Avoid selecting dummy buttons.
|
||||
if (selectedButton && selectedButton.classList.contains("dummy"))
|
||||
selectedButton = null;
|
||||
}
|
||||
else {
|
||||
// If no selection, select the first or last one-off button.
|
||||
if (forward) {
|
||||
selectedButton = list.firstChild;
|
||||
}
|
||||
else {
|
||||
selectedButton = list.lastChild;
|
||||
while (selectedButton.classList.contains("dummy"))
|
||||
selectedButton = selectedButton.previousSibling;
|
||||
}
|
||||
}
|
||||
if (selectedButton)
|
||||
selectedButton.setAttribute("selected", "true");
|
||||
|
||||
aEvent.preventDefault();
|
||||
aEvent.stopPropagation();
|
||||
return;
|
||||
}
|
||||
|
||||
// If the last suggestion is selected, DOWN selects the first one-off.
|
||||
if (aEvent.keyCode == KeyEvent.DOM_VK_DOWN &&
|
||||
popup.selectedIndex + 1 == popup.view.rowCount) {
|
||||
|
Loading…
Reference in New Issue
Block a user