Bug 1594472 - do less work for same-document navigations, r=MattN,mconley

Updating tab
- mute state
- audio playing indicator state
- find bar state
- tab titles
- icons

is not necessary when the navigation is same-document. Avoid doing the work.

Differential Revision: https://phabricator.services.mozilla.com/D52109

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2019-11-07 21:02:26 +00:00
Родитель b65a40732b
Коммит 7e5577e2b2
1 изменённых файлов: 41 добавлений и 36 удалений

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

@ -5857,45 +5857,50 @@
gBrowser._tabAttrModified(this.mTab, ["busy"]);
}
// If the browser was playing audio, we should remove the playing state.
if (this.mTab.hasAttribute("soundplaying") && !isSameDocument) {
clearTimeout(this.mTab._soundPlayingAttrRemovalTimer);
this.mTab._soundPlayingAttrRemovalTimer = 0;
this.mTab.removeAttribute("soundplaying");
gBrowser._tabAttrModified(this.mTab, ["soundplaying"]);
}
// If the browser was previously muted, we should restore the muted state.
if (this.mTab.hasAttribute("muted")) {
this.mTab.linkedBrowser.mute();
}
if (gBrowser.isFindBarInitialized(this.mTab)) {
let findBar = gBrowser.getCachedFindBar(this.mTab);
// Close the Find toolbar if we're in old-style TAF mode
if (findBar.findMode != findBar.FIND_NORMAL) {
findBar.close();
if (!isSameDocument) {
// If the browser was playing audio, we should remove the playing state.
if (this.mTab.hasAttribute("soundplaying")) {
clearTimeout(this.mTab._soundPlayingAttrRemovalTimer);
this.mTab._soundPlayingAttrRemovalTimer = 0;
this.mTab.removeAttribute("soundplaying");
gBrowser._tabAttrModified(this.mTab, ["soundplaying"]);
}
}
if (!isReload) {
gBrowser.setTabTitle(this.mTab);
}
// If the browser was previously muted, we should restore the muted state.
if (this.mTab.hasAttribute("muted")) {
this.mTab.linkedBrowser.mute();
}
// Don't clear the favicon if this tab is in the pending
// state, as SessionStore will have set the icon for us even
// though we're pointed at an about:blank. Also don't clear it
// if onLocationChange was triggered by a pushState or a
// replaceState (bug 550565) or a hash change (bug 408415).
if (
!this.mTab.hasAttribute("pending") &&
aWebProgress.isLoadingDocument &&
!isSameDocument
) {
// Removing the tab's image here causes flickering, wait until the load
// is complete.
this.mBrowser.mIconURL = null;
if (gBrowser.isFindBarInitialized(this.mTab)) {
let findBar = gBrowser.getCachedFindBar(this.mTab);
// Close the Find toolbar if we're in old-style TAF mode
if (findBar.findMode != findBar.FIND_NORMAL) {
findBar.close();
}
}
// Note that we're not updating for same-document loads, despite
// the `title` argument to `history.pushState/replaceState`. For
// context, see https://bugzilla.mozilla.org/show_bug.cgi?id=585653
// and https://github.com/whatwg/html/issues/2174
if (!isReload) {
gBrowser.setTabTitle(this.mTab);
}
// Don't clear the favicon if this tab is in the pending
// state, as SessionStore will have set the icon for us even
// though we're pointed at an about:blank. Also don't clear it
// if onLocationChange was triggered by a pushState or a
// replaceState (bug 550565) or a hash change (bug 408415).
if (
!this.mTab.hasAttribute("pending") &&
aWebProgress.isLoadingDocument
) {
// Removing the tab's image here causes flickering, wait until the
// load is complete.
this.mBrowser.mIconURL = null;
}
}
let userContextId = this.mBrowser.getAttribute("usercontextid") || 0;