From 0e1a25372e9da3f4224e1383068c889ad798ab99 Mon Sep 17 00:00:00 2001 From: "ben@bengoodger.com" Date: Tue, 21 Aug 2007 21:59:41 -0700 Subject: [PATCH] Aviary branch landing --- browser/base/content/tabbrowser.xml | 462 ++++++++++++++++++++-------- 1 file changed, 337 insertions(+), 125 deletions(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 1955ee75641..e059b3ec2f2 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -51,7 +51,7 @@ - @@ -80,6 +80,7 @@ - + + @@ -154,6 +159,86 @@ false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -167,7 +252,8 @@ mTab: aTab, mBrowser: aBrowser, mBlank: aStartsBlank, - mIcon: "", + mIcon: null, + mLastURI: null, onProgressChange : function (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, @@ -194,7 +280,10 @@ const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; const nsIChannel = Components.interfaces.nsIChannel; - if (aStateFlags & nsIWebProgressListener.STATE_START && + if (aStateFlags & nsIWebProgressListener.STATE_START) + this.mBrowser.mFavIconURL = null; + + if (aStateFlags & nsIWebProgressListener.STATE_START && aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) { // It's okay to clear what the user typed when we start // loading a document. If the user types, this flag gets @@ -207,8 +296,8 @@ if (!this.mBlank) { this.mTab.setAttribute("busy", "true"); this.mTab.label = this.mTabBrowser.mStringBundle.getString("tabs.loading"); - this.mTab.removeAttribute("image"); - this.mIcon = ""; + this.mTab.removeAttribute("image"); + this.mIcon = null; if (this.mTabBrowser.mCurrentTab == this.mTab) this.mTabBrowser.mIsBusy = true; @@ -227,12 +316,17 @@ this.mTab.removeAttribute("busy"); var location = aRequest.QueryInterface(nsIChannel).URI; - if (this.mIcon) { - this.mTab.setAttribute("image", this.mIcon); - this.mIcon = ""; + + // For keyword URIs clear the user typed value since they will be changed into real URIs + if (location.scheme == "keyword") + this.mBrowser.userTypedValue = null; + + if (this.mTabBrowser.shouldLoadFavIcon(location)) { + if (this.mIcon) + this.mTab.setAttribute("image", this.mIcon); + else + this.mTabBrowser.loadFavIcon(location, "image", this.mTab); } - else if (this.mTabBrowser.shouldLoadFavIcon(location)) - this.mTabBrowser.loadFavIcon(location, "image", this.mTab); if (this.mTab.label == this.mTabBrowser.mStringBundle.getString("tabs.loading")) this.mTabBrowser.setTabTitle(this.mTab); @@ -248,10 +342,10 @@ p.onStateChange(aWebProgress, aRequest, aStateFlags, aStatus); } } - }, + } + , - onLocationChange : function(aWebProgress, aRequest, aLocation) - { + onLocationChange : function(aWebProgress, aRequest, aLocation) { // The document loaded correctly, clear the value if we should if (this.mBrowser.userTypedClear) this.mBrowser.userTypedValue = null; @@ -265,8 +359,7 @@ } }, - onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) - { + onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) { if (this.mBlank) return; @@ -298,11 +391,12 @@ return this; throw Components.results.NS_NOINTERFACE; } - }); + + }); ]]> - + @@ -318,7 +412,7 @@ @@ -331,13 +425,8 @@ @@ -380,6 +469,20 @@ + + + + + + + + + + + + + + @@ -409,7 +524,6 @@ @@ -614,31 +719,25 @@ null) != nsIContentPolicy.ACCEPT) return; - // var browserIndex = tabBrowser.getBrowserIndexForDocument(targetDoc); - var browserIndex = -1; - if (tabBrowser.mTabbedMode) { - for (var i = 0; i < tabBrowser.mPanelContainer.childNodes.length; i++) { - if (tabBrowser.mPanelContainer.childNodes[i].contentDocument == targetDoc) { - browserIndex = i; - break; - } - } - } else { - if (tabBrowser.mCurrentBrowser.contentDocument == targetDoc) - browserIndex = 0; - } - + var browserIndex = tabBrowser.getBrowserIndexForDocument(targetDoc); // no browser? no favicon. if (browserIndex == -1) return; var listener = tabBrowser.mTabListeners[browserIndex]; // there's no tab listener for non-tabbed mode browser 0 + + if (tabBrowser.isFavIconKnownMissing(href)) { + if (listener) + listener.mIcon = null; + return; + } + if (listener) listener.mIcon = href; if (tabBrowser.mProgressListeners) { - var targetBrowser = tabBrowser.mTabbedMode ? tabBrowser.mPanelContainer.childNodes[i] : tabBrowser.mCurrentBrowser; + var targetBrowser = tabBrowser.getBrowserAtIndex(browserIndex); for (i = 0; i < tabBrowser.mProgressListeners.length; i++) { var p = tabBrowser.mProgressListeners[i]; if (p) @@ -657,14 +756,14 @@ return; var i = 0; - for ( ; i < this.parentNode.childNodes.length; i++) { - if (this.parentNode.childNodes[i] == this) + for ( ; i < this.parentNode.parentNode.childNodes.length; i++) { + if (this.parentNode.parentNode.childNodes[i].firstChild.nextSibling == this) break; } + + var tabBrowser = this.parentNode.parentNode.parentNode.parentNode; - var tabBrowser = this.parentNode.parentNode.parentNode; var tab = tabBrowser.mTabContainer.childNodes[i]; - tabBrowser.setTabTitle(tab); if (tab == tabBrowser.mCurrentTab) @@ -760,14 +859,25 @@ } // Wire up a progress listener to our filter. - const listener = this.mTabProgressListener(this.mCurrentTab, - this.mCurrentBrowser, - false); + const listener = this.mTabProgressListener(this.mCurrentTab, this.mCurrentBrowser, false); filter.addProgressListener(listener, Components.interfaces.nsIWebProgress.NOTIFY_ALL); this.mTabListeners[0] = listener; ]]> + + + + + + + @@ -776,14 +886,16 @@ + + + + + + + = 0; --i) { - if (childNodes[i] != aTab) - this.removeTab(childNodes[i]); + var childNodes = this.mTabContainer.childNodes; + + for (var i = childNodes.length - 1; i >= 0; --i) { + if (childNodes[i] != aTab) + this.removeTab(childNodes[i]); + } + } } ]]> @@ -875,6 +1045,11 @@ var l = this.mTabContainer.childNodes.length; if (l == 1) { + if (!this.mPrefs.getBoolPref("browser.tabs.autoHide")) { + // blank the tab + this.loadURI("about:blank"); + return; + } // hide the tab bar this.mPrefs.setBoolPref("browser.tabs.forceHide", true); this.setStripVisibilityTo(false); @@ -904,7 +1079,7 @@ // Remove the tab's filter and progress listener. const filter = this.mTabFilters[index]; - var oldBrowser = this.mPanelContainer.childNodes[index]; + var oldBrowser = this.getBrowserAtIndex(index); oldBrowser.webProgress.removeProgressListener(filter); filter.removeProgressListener(this.mTabListeners[index]); this.mTabFilters.splice(index, 1); @@ -938,7 +1113,7 @@ oldBrowser.destroy(); this.mTabContainer.removeChild(oldTab); - this.mPanelContainer.removeChild(oldBrowser); + this.mPanelContainer.removeChild(this.mPanelContainer.childNodes[index]); this.selectedTab = this.mTabContainer.childNodes[newIndex]; this.mPanelContainer.selectedIndex = newIndex; @@ -955,7 +1130,7 @@ var l = this.mPanelContainer.childNodes.length; for (var i = 0; i < l; i++) { try { - this.mPanelContainer.childNodes[i].reload(); + this.getBrowserAtIndex(i).reload(); } catch (e) { // ignore failure to reload so others will be reloaded } @@ -1058,7 +1233,7 @@ for (var i = 0; i < this.mTabContainer.childNodes.length; i++) { if (this.mTabContainer.childNodes[i] == aTab) { - return this.mPanelContainer.childNodes[i]; + return this.getBrowserAtIndex(i); } } @@ -1092,7 +1267,7 @@ @@ -1265,9 +1440,8 @@ @@ -1275,9 +1449,8 @@ @@ -1291,6 +1464,25 @@ onget="return this.mCurrentBrowser.currentURI;" readonly="true"/> + null + + + + + + + + @@ -1366,6 +1558,20 @@ ]]> + + + - - - -