Bug 1432716 - Group the "Show search suggestions ahead of browsing history in address bar results" checkbox with other search suggestion checkboxes. ui=shorlander r=adw

MozReview-Commit-ID: 6Xt8MixhV3x

--HG--
extra : rebase_source : ce562d395dad27ebf48c78b221310ae55c3cae4d
This commit is contained in:
Dão Gottwald 2018-01-24 08:48:27 +01:00
Родитель 0844d2267b
Коммит e52b4084af
4 изменённых файлов: 33 добавлений и 19 удалений

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

@ -60,29 +60,31 @@ var gSearchPane = {
this._initAutocomplete();
let suggestsPref = Preferences.get("browser.search.suggest.enabled");
suggestsPref.on("change", this.updateSuggestsCheckbox.bind(this));
this.updateSuggestsCheckbox();
let urlbarSuggestsPref = Preferences.get("browser.urlbar.suggest.searches");
let updateSuggestionCheckboxes = this._updateSuggestionCheckboxes.bind(this);
suggestsPref.on("change", updateSuggestionCheckboxes);
urlbarSuggestsPref.on("change", updateSuggestionCheckboxes);
this._initShowSearchSuggestionsFirst();
this._updateSuggestionCheckboxes();
},
_initShowSearchSuggestionsFirst() {
let pref = Preferences.get("browser.urlbar.matchBuckets");
this._urlbarSuggestionsPosPref = Preferences.get("browser.urlbar.matchBuckets");
let checkbox =
document.getElementById("showSearchSuggestionsFirstCheckbox");
pref.on("change", () => {
this._syncFromShowSearchSuggestionsFirstPref(checkbox, pref);
this._urlbarSuggestionsPosPref.on("change", () => {
this._syncFromShowSearchSuggestionsFirstPref(checkbox);
});
this._syncFromShowSearchSuggestionsFirstPref(checkbox, pref);
this._syncFromShowSearchSuggestionsFirstPref(checkbox);
checkbox.addEventListener("command", () => {
this._syncToShowSearchSuggestionsFirstPref(checkbox.checked, pref);
this._syncToShowSearchSuggestionsFirstPref(checkbox.checked);
});
},
_syncFromShowSearchSuggestionsFirstPref(checkbox, pref) {
if (!pref.value) {
_syncFromShowSearchSuggestionsFirstPref(checkbox) {
if (!this._urlbarSuggestionsPosPref.value) {
// The pref is cleared, meaning search suggestions are shown first.
checkbox.checked = true;
return;
@ -93,22 +95,25 @@ var gSearchPane = {
checkbox.checked = buckets[0] && buckets[0][0] == "suggestion";
},
_syncToShowSearchSuggestionsFirstPref(checked, pref) {
_syncToShowSearchSuggestionsFirstPref(checked) {
if (checked) {
// Show search suggestions first, so clear the pref since that's the
// default.
pref.reset();
this._urlbarSuggestionsPosPref.reset();
return;
}
// Show history first.
pref.value = "general:5,suggestion:Infinity";
this._urlbarSuggestionsPosPref.value = "general:5,suggestion:Infinity";
},
updateSuggestsCheckbox() {
_updateSuggestionCheckboxes() {
let suggestsPref = Preferences.get("browser.search.suggest.enabled");
let permanentPB =
Services.prefs.getBoolPref("browser.privatebrowsing.autostart");
let urlbarSuggests = document.getElementById("urlBarSuggestion");
let positionCheckbox =
document.getElementById("showSearchSuggestionsFirstCheckbox");
urlbarSuggests.disabled = !suggestsPref.value || permanentPB;
let urlbarSuggestsPref = Preferences.get("browser.urlbar.suggest.searches");
@ -117,6 +122,14 @@ var gSearchPane = {
urlbarSuggests.checked = false;
}
if (urlbarSuggests.checked) {
positionCheckbox.disabled = false;
this._syncFromShowSearchSuggestionsFirstPref(positionCheckbox);
} else {
positionCheckbox.disabled = true;
positionCheckbox.checked = false;
}
let permanentPBLabel =
document.getElementById("urlBarSuggestionPermanentPBLabel");
permanentPBLabel.hidden = urlbarSuggests.hidden || !permanentPB;

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

@ -18,8 +18,6 @@
<radio id="searchBarShownRadio" value="true" label="&searchBar.shown.label;"/>
<image class="searchBarImage searchBarShownImage" role="presentation"/>
</radiogroup>
<checkbox id="showSearchSuggestionsFirstCheckbox"
label="&showSearchSuggestionsAboveHistory.label;"/>
</groupbox>
<!-- Default Search Engine -->
@ -48,6 +46,8 @@
<checkbox id="urlBarSuggestion" label="&showURLBarSuggestions2.label;"
accesskey="&showURLBarSuggestions2.accesskey;"
preference="browser.urlbar.suggest.searches"/>
<checkbox id="showSearchSuggestionsFirstCheckbox"
label="&showSearchSuggestionsAboveHistory.label;"/>
<hbox id="urlBarSuggestionPermanentPBLabel"
align="center" class="indent">
<label flex="1">&urlBarSuggestionsPermanentPB.label;</label>

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

@ -7,6 +7,8 @@ const CHECKBOX_ID = "showSearchSuggestionsFirstCheckbox";
// Open preferences with search suggestions shown first (the default).
add_task(async function openWithSearchSuggestionsShownFirst() {
await SpecialPowers.pushPrefEnv({set: [["browser.urlbar.suggest.searches", true]]});
// The pref should be cleared initially so that search suggestions are shown
// first (the default).
Assert.equal(Services.prefs.getCharPref(PREF_NAME, ""), "",

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

@ -12,9 +12,8 @@
list-style-image: url("chrome://browser/skin/preferences/in-content/no-search-bar.svg");
}
#searchBarShownRadio,
#showSearchSuggestionsFirstCheckbox {
/* A little space to separate these from the elements above them. */
#searchBarShownRadio {
/* Allow a little visual space to separate the radio from the image above it. */
margin-top: 10px;
}