diff --git a/browser/base/content/abouthome/aboutHome.js b/browser/base/content/abouthome/aboutHome.js index 603b8c2b2ffe..c526a303d097 100644 --- a/browser/base/content/abouthome/aboutHome.js +++ b/browser/base/content/abouthome/aboutHome.js @@ -256,19 +256,6 @@ function onSearchSubmit(aEvent) function setupSearchEngine() { - let searchEngineName = document.documentElement.getAttribute("searchEngineName"); - let searchEngineInfo = SEARCH_ENGINES[searchEngineName]; - if (!searchEngineInfo) { - return; - } - - // Add search engine logo. - if (searchEngineInfo.image) { - let logoElt = document.getElementById("searchEngineLogo"); - logoElt.src = searchEngineInfo.image; - logoElt.alt = searchEngineName; - } - // The "autofocus" attribute doesn't focus the form element // immediately when the element is first drawn, so the // attribute is also used for styling when the page first loads. @@ -277,6 +264,26 @@ function setupSearchEngine() searchText.removeEventListener("blur", searchText_onBlur); searchText.removeAttribute("autofocus"); }); + + let searchEngineName = document.documentElement.getAttribute("searchEngineName"); + let searchEngineInfo = SEARCH_ENGINES[searchEngineName]; + let logoElt = document.getElementById("searchEngineLogo"); + + // Add search engine logo. + if (searchEngineInfo && searchEngineInfo.image) { + logoElt.parentNode.hidden = false; + logoElt.src = searchEngineInfo.image; +#ifdef XP_MACOSX + if (searchEngineInfo.imageHD && !window.matchMedia("(max-resolution: 1dppx)").matches) + logoElt.src = searchEngineInfo.imageHD; +#endif + logoElt.alt = searchEngineName; + searchText.placeholder = ""; + } + else { + logoElt.parentNode.hidden = true; + searchText.placeholder = searchEngineName; + } } diff --git a/browser/components/search/content/engineManager.js b/browser/components/search/content/engineManager.js index ff8aa42737f5..92b6d59b7789 100644 --- a/browser/components/search/content/engineManager.js +++ b/browser/components/search/content/engineManager.js @@ -45,6 +45,7 @@ var gEngineManagerDialog = { break; case "engine-removed": case "engine-current": + case "engine-default": // Not relevant break; } diff --git a/browser/components/search/content/search.xml b/browser/components/search/content/search.xml index eeb36d718e1b..cd79d761dd1a 100644 --- a/browser/components/search/content/search.xml +++ b/browser/components/search/content/search.xml @@ -121,8 +121,12 @@ document.getAnonymousElementByAttribute(this, "anonid", "searchbar-engine-button"); - + + = 0 && newIndex < this.engines.length) + if (newIndex >= 0 && newIndex < this.engines.length) { this.currentEngine = this.engines[newIndex]; + } aEvent.preventDefault(); aEvent.stopPropagation(); diff --git a/browser/modules/AboutHomeUtils.jsm b/browser/modules/AboutHomeUtils.jsm index 3018da0d853a..09d395fee082 100644 --- a/browser/modules/AboutHomeUtils.jsm +++ b/browser/modules/AboutHomeUtils.jsm @@ -18,6 +18,23 @@ const STARTPAGE_VERSION = 4; this.AboutHomeUtils = { get snippetsVersion() STARTPAGE_VERSION, + /** + * Returns an object containing the name and searchURL of the original default + * search engine. + */ + get defaultSearchEngine() { + let defaultEngine = Services.search.defaultEngine; + let submission = defaultEngine.getSubmission("_searchTerms_", null, "homepage"); + if (submission.postData) { + throw new Error("Home page does not support POST search engines."); + } + + return Object.freeze({ + name: defaultEngine.name, + searchURL: submission.uri.spec + }); + }, + /* * showKnowYourRights - Determines if the user should be shown the * about:rights notification. The notification should *not* be shown if @@ -59,23 +76,6 @@ this.AboutHomeUtils = { } }; -/** - * Returns an object containing the name and searchURL of the original default - * search engine. - */ -XPCOMUtils.defineLazyGetter(AboutHomeUtils, "defaultSearchEngine", function() { - let defaultEngine = Services.search.defaultEngine; - let submission = defaultEngine.getSubmission("_searchTerms_", null, "homepage"); - if (submission.postData) { - throw new Error("Home page does not support POST search engines."); - } - - return Object.freeze({ - name: defaultEngine.name, - searchURL: submission.uri.spec - }); -}); - /** * Returns the URL to fetch snippets from, in the urlFormatter service format. */