Bug 1401955 - Prevent favicon flickering on about:home and about:newtab. r=florian
This sets the hardcoded favicon paths before painting the tab or window
to ensure they're painted right away.
MozReview-Commit-ID: 5V3gQP7XkNP
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1347,16 +1347,24 @@ var gBrowserInit = {
gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, tabToOpen);
} catch (e) {
Cu.reportError(e);
}
}
this._setInitialFocus();
+ // Hack to ensure that the about:home favicon is loaded
+ // instantaneously, to avoid flickering and improve perceived performance.
+ this._uriToLoadPromise.then(uriToLoad => {
+ if (uriToLoad == "about:home") {
+ gBrowser.setIcon(gBrowser.selectedTab, "chrome://branding/content/icon32.png");
+ }
+ });
+
// Wait until chrome is painted before executing code not critical to making the window visible
this._boundDelayedStartup = this._delayedStartup.bind(this);
window.addEventListener("MozAfterPaint", this._boundDelayedStartup);
this._loadHandled = true;
},
_cancelDelayedStartup() {
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -832,17 +832,18 @@
let inLoadURI = this.mBrowser.inLoadURI;
if (this.mTab.selected && gURLBar && !inLoadURI) {
URLBarSetURI();
}
} else if (isSuccessful) {
this.mBrowser.urlbarChangeTracker.finishedLoad();
}
- if (!this.mBrowser.mIconURL) {
+ // Ignore initial about:blank to prevent flickering.
+ if (!this.mBrowser.mIconURL && !ignoreBlank) {
this.mTabBrowser.useDefaultIcon(this.mTab);
}
}
// For keyword URIs clear the user typed value since they will be changed into real URIs
if (location.scheme == "keyword")
this.mBrowser.userTypedValue = null;
@@ -2842,16 +2843,22 @@
this._tabFilters.delete(t);
this._tabListeners.delete(t);
let notificationbox = this.getNotificationBox(t.linkedBrowser);
notificationbox.remove();
}
throw e;
}
+ // Hack to ensure that the about:newtab favicon is loaded
+ // instantaneously, to avoid flickering and improve perceived performance.
+ if (aURI == BROWSER_NEW_TAB_URL) {
+ this.setIcon(t, "chrome://branding/content/icon32.png");
+ }
+
// Dispatch a new tab notification. We do this once we're
// entirely done, so that things are in a consistent state
// even if the event listener opens or closes tabs.
var detail = aEventDetail || {};
var evt = new CustomEvent("TabOpen", { bubbles: true, detail });
t.dispatchEvent(evt);
if (!usingPreloadedContent && aOriginPrincipal && aURI) {