b=109672, site icon for iframe content is shown as proxy icon, patch from bugzilla.mozilla.org@chsc.dk, r=vladimir,a=asa
git-svn-id: svn://10.0.0.236/trunk@174546 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
85e071b7cb
commit
2bf094d205
@ -126,20 +126,15 @@ function loadEventHandlers(event)
|
||||
|
||||
// some event handlers want to be told what the original browser/listener is
|
||||
var targetBrowser = null;
|
||||
var targetListener = null;
|
||||
if (gBrowser.mTabbedMode) {
|
||||
var targetBrowserIndex = gBrowser.getBrowserIndexForDocument(event.originalTarget);
|
||||
if (targetBrowserIndex == -1)
|
||||
return;
|
||||
targetBrowser = gBrowser.getBrowserAtIndex(targetBrowserIndex);
|
||||
targetListener = gBrowser.mTabListeners[targetBrowserIndex];
|
||||
} else {
|
||||
targetBrowser = gBrowser.mCurrentBrowser;
|
||||
targetListener = null; // no listener for non-tabbed-mode
|
||||
}
|
||||
|
||||
updatePageFavIcon(targetBrowser, targetListener);
|
||||
|
||||
// update the last visited date
|
||||
if (targetBrowser.currentURI.spec)
|
||||
BMSVC.updateLastVisitedDate(targetBrowser.currentURI.spec,
|
||||
@ -2110,24 +2105,12 @@ function SetPageProxyState(aState)
|
||||
gProxyButton.setAttribute("pageproxystate", aState);
|
||||
|
||||
// the page proxy state is set to valid via OnLocationChange, which
|
||||
// gets called when we switch tabs. We'll let updatePageFavIcon
|
||||
// take care of updating the mFavIconURL because it knows exactly
|
||||
// for which tab to update things, instead of confusing the issue
|
||||
// here.
|
||||
// gets called when we switch tabs.
|
||||
if (aState == "valid") {
|
||||
gLastValidURLStr = gURLBar.value;
|
||||
gURLBar.addEventListener("input", UpdatePageProxyState, false);
|
||||
|
||||
if (gBrowser.mCurrentBrowser.mFavIconURL != null) {
|
||||
if (gBrowser.isFavIconKnownMissing(gBrowser.mCurrentBrowser.mFavIconURL)) {
|
||||
gBrowser.mFavIconURL = null;
|
||||
PageProxyClearIcon();
|
||||
} else {
|
||||
PageProxySetIcon(gBrowser.mCurrentBrowser.mFavIconURL);
|
||||
}
|
||||
} else {
|
||||
PageProxyClearIcon();
|
||||
}
|
||||
PageProxySetIcon(gBrowser.mCurrentBrowser.mIconURL);
|
||||
} else if (aState == "invalid") {
|
||||
gURLBar.removeEventListener("input", UpdatePageProxyState, false);
|
||||
PageProxyClearIcon();
|
||||
@ -2139,7 +2122,9 @@ function PageProxySetIcon (aURL)
|
||||
if (!gProxyFavIcon)
|
||||
return;
|
||||
|
||||
if (gProxyFavIcon.getAttribute("src") != aURL)
|
||||
if (!aURL)
|
||||
PageProxyClearIcon();
|
||||
else if (gProxyFavIcon.getAttribute("src") != aURL)
|
||||
gProxyFavIcon.setAttribute("src", aURL);
|
||||
else if (gProxyDeck.selectedIndex != 1)
|
||||
gProxyDeck.selectedIndex = 1;
|
||||
@ -3177,16 +3162,14 @@ nsBrowserStatusHandler.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
onLinkIconAvailable : function(aBrowser, aHref)
|
||||
onLinkIconAvailable : function(aBrowser)
|
||||
{
|
||||
if (gProxyFavIcon &&
|
||||
gBrowser.mCurrentBrowser == aBrowser &&
|
||||
gBrowser.userTypedValue === null)
|
||||
{
|
||||
PageProxySetIcon(aHref);
|
||||
PageProxySetIcon(aBrowser.mIconURL);
|
||||
}
|
||||
|
||||
aBrowser.mFavIconURL = aHref;
|
||||
},
|
||||
|
||||
onProgressChange : function (aWebProgress, aRequest,
|
||||
@ -3211,15 +3194,6 @@ nsBrowserStatusHandler.prototype =
|
||||
// stray request (the first request outside of the document load),
|
||||
// initialize the throbber and his friends.
|
||||
|
||||
// always reset the favicon
|
||||
if (gBrowser.mTabbedMode) {
|
||||
var browserIndex = gBrowser.getBrowserIndexForDocument(aWebProgress.DOMWindow);
|
||||
if (browserIndex != -1)
|
||||
gBrowser.getBrowserAtIndex(browserIndex).mFavIconURL = null;
|
||||
}
|
||||
else
|
||||
gBrowser.mCurrentBrowser.mFavIconURL = null;
|
||||
|
||||
// Call start document load listeners (only if this is a network load)
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK &&
|
||||
aRequest && aWebProgress.DOMWindow == content)
|
||||
@ -3244,9 +3218,14 @@ nsBrowserStatusHandler.prototype =
|
||||
}
|
||||
else if (aStateFlags & nsIWebProgressListener.STATE_STOP) {
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
if (aRequest) {
|
||||
if (aWebProgress.DOMWindow == content)
|
||||
if (aWebProgress.DOMWindow == content) {
|
||||
if (aRequest)
|
||||
this.endDocumentLoad(aRequest, aStatus);
|
||||
var browser = gBrowser.mCurrentBrowser;
|
||||
if (!gBrowser.mTabbedMode && !browser.mIconURL)
|
||||
gBrowser.useDefaultIcon(gBrowser.mCurrentTab);
|
||||
if (browser.mIconURL)
|
||||
BookmarksUtils.loadFavIcon(browser.currentURI.spec, browser.mIconURL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3357,6 +3336,9 @@ nsBrowserStatusHandler.prototype =
|
||||
if (browser.userTypedClear)
|
||||
browser.userTypedValue = null;
|
||||
|
||||
if (!gBrowser.mTabbedMode)
|
||||
gBrowser.setIcon(gBrowser.mCurrentTab, null);
|
||||
|
||||
if (findField)
|
||||
setTimeout(function() { findField.value = browser.findString; }, 0, findField, browser);
|
||||
|
||||
@ -5749,31 +5731,6 @@ function livemarkAddMark(wincontent, data) {
|
||||
BookmarksUtils.addLivemark(wincontent.document.baseURI, data, title, description);
|
||||
}
|
||||
|
||||
function updatePageFavIcon(aBrowser, aListener) {
|
||||
var uri = aBrowser.currentURI;
|
||||
|
||||
if (!gBrowser.shouldLoadFavIcon(uri))
|
||||
return;
|
||||
|
||||
// if we made it here with this null, then no <link> was found for
|
||||
// the page load. We try to fetch a generic favicon.ico.
|
||||
if (aBrowser.mFavIconURL == null) {
|
||||
aBrowser.mFavIconURL = gBrowser.buildFavIconString(uri);
|
||||
// give it to the listener as well
|
||||
// XXX - there is no listener for non-tabbed-mode: this is why
|
||||
// the urlbar has no favicon when you switch from tabbed mode to
|
||||
// non-tabbed-mode.
|
||||
if (aListener)
|
||||
aListener.mIcon = aBrowser.mFavIconURL;
|
||||
}
|
||||
|
||||
if (aBrowser == gBrowser.mCurrentBrowser)
|
||||
PageProxySetIcon(aBrowser.mFavIconURL);
|
||||
|
||||
if (aBrowser.mFavIconURL != null)
|
||||
BookmarksUtils.loadFavIcon(uri.spec, aBrowser.mFavIconURL);
|
||||
}
|
||||
|
||||
function GetFrameDocumentsFromWindow(aWindow){
|
||||
if (aWindow.getComputedStyle(aWindow.document.body, "").direction == "ltr")
|
||||
aWindow.document.dir = "rtl";
|
||||
|
||||
@ -165,7 +165,7 @@
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
this.mFavIconURL = null;
|
||||
this.mIconURL = null;
|
||||
this.webNavigation.loadURI(aURI, aFlags, aReferrerURI, aPostData, null);
|
||||
]]>
|
||||
</body>
|
||||
@ -535,7 +535,7 @@
|
||||
false
|
||||
</field>
|
||||
|
||||
<field name="mFavIconURL">null</field>
|
||||
<field name="mIconURL">null</field>
|
||||
|
||||
<field name="mDestroyed">false</field>
|
||||
|
||||
|
||||
@ -280,7 +280,6 @@
|
||||
mTab: aTab,
|
||||
mBrowser: aBrowser,
|
||||
mBlank: aStartsBlank,
|
||||
mIcon: null,
|
||||
mLastURI: null,
|
||||
|
||||
onProgressChange : function (aWebProgress, aRequest,
|
||||
@ -308,9 +307,6 @@
|
||||
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
||||
const nsIChannel = Components.interfaces.nsIChannel;
|
||||
|
||||
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
|
||||
@ -323,9 +319,8 @@
|
||||
|
||||
if (!this.mBlank) {
|
||||
this.mTab.setAttribute("busy", "true");
|
||||
this.mTabBrowser.updateIcon(this.mTab);
|
||||
this.mTab.label = this.mTabBrowser.mStringBundle.getString("tabs.loading");
|
||||
this.mTab.removeAttribute("image");
|
||||
this.mIcon = null;
|
||||
|
||||
if (this.mTabBrowser.mCurrentTab == this.mTab)
|
||||
this.mTabBrowser.mIsBusy = true;
|
||||
@ -333,15 +328,20 @@
|
||||
}
|
||||
else if (aStateFlags & nsIWebProgressListener.STATE_STOP &&
|
||||
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
// The document is done loading, it's okay to clear
|
||||
// the value again.
|
||||
if (aWebProgress.DOMWindow == this.mBrowser.contentWindow)
|
||||
if (aWebProgress.DOMWindow == this.mBrowser.contentWindow) {
|
||||
// The document is done loading, it's okay to clear
|
||||
// the value again.
|
||||
this.mBrowser.userTypedClear = false;
|
||||
|
||||
if (!this.mBrowser.mIconURL)
|
||||
this.mTabBrowser.useDefaultIcon(this.mTab);
|
||||
}
|
||||
|
||||
if (this.mBlank)
|
||||
this.mBlank = false;
|
||||
|
||||
this.mTab.removeAttribute("busy");
|
||||
this.mTabBrowser.updateIcon(this.mTab);
|
||||
|
||||
var location = aRequest.QueryInterface(nsIChannel).URI;
|
||||
|
||||
@ -349,13 +349,6 @@
|
||||
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);
|
||||
}
|
||||
|
||||
if (this.mTab.label == this.mTabBrowser.mStringBundle.getString("tabs.loading"))
|
||||
this.mTabBrowser.setTabTitle(this.mTab);
|
||||
|
||||
@ -378,6 +371,9 @@
|
||||
if (this.mBrowser.userTypedClear)
|
||||
this.mBrowser.userTypedValue = null;
|
||||
|
||||
if (aWebProgress.DOMWindow == this.mBrowser.contentWindow)
|
||||
this.mTabBrowser.setIcon(this.mTab, null);
|
||||
|
||||
if (!this.mBlank && this.mTabBrowser.mCurrentTab == this.mTab) {
|
||||
for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) {
|
||||
var p = this.mTabBrowser.mProgressListeners[i];
|
||||
@ -412,13 +408,6 @@
|
||||
}
|
||||
},
|
||||
|
||||
setIcon : function(aURI)
|
||||
{
|
||||
this.mIcon = aURI;
|
||||
if (!this.mTab.hasAttribute("busy"))
|
||||
this.mTab.setAttribute("image", aURI);
|
||||
},
|
||||
|
||||
QueryInterface : function(aIID)
|
||||
{
|
||||
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
|
||||
@ -432,12 +421,34 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="buildFavIconString">
|
||||
<method name="setIcon">
|
||||
<parameter name="aTab"/>
|
||||
<parameter name="aURI"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var end = (aURI.port == -1) ? "/favicon.ico" : (":" + aURI.port + "/favicon.ico");
|
||||
return aURI.scheme + "://" + aURI.host + end;
|
||||
var browser = this.getBrowserForTab(aTab);
|
||||
browser.mIconURL = aURI;
|
||||
|
||||
this.updateIcon(aTab);
|
||||
|
||||
for (var i = 0; i < this.mProgressListeners.length; i++) {
|
||||
var p = this.mProgressListeners[i];
|
||||
if ('onLinkIconAvailable' in p)
|
||||
p.onLinkIconAvailable(browser);
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="updateIcon">
|
||||
<parameter name="aTab"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var browser = this.getBrowserForTab(aTab);
|
||||
if (!aTab.hasAttribute("busy") && browser.mIconURL)
|
||||
aTab.setAttribute("image", browser.mIconURL);
|
||||
else
|
||||
aTab.removeAttribute("image");
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
@ -453,19 +464,20 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="loadFavIcon">
|
||||
<parameter name="aURI"/>
|
||||
<parameter name="aAttr"/>
|
||||
<parameter name="aElt"/>
|
||||
<method name="useDefaultIcon">
|
||||
<parameter name="aTab"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var iconURL;
|
||||
if (this.contentDocument instanceof ImageDocument)
|
||||
iconURL = this.currentURI.spec;
|
||||
else
|
||||
iconURL = this.buildFavIconString(aURI);
|
||||
if (!this.isFavIconKnownMissing(iconURL))
|
||||
aElt.setAttribute(aAttr, iconURL);
|
||||
var browser = this.getBrowserForTab(aTab);
|
||||
if (browser.contentDocument instanceof ImageDocument) {
|
||||
if (this.mPrefs.getBoolPref("browser.chrome.site_icons"))
|
||||
this.setIcon(aTab, browser.currentURI.spec);
|
||||
}
|
||||
else if (this.shouldLoadFavIcon(browser.currentURI)) {
|
||||
var url = browser.currentURI.prePath + "/favicon.ico";
|
||||
if (!this.isIconKnownMissing(url))
|
||||
this.setIcon(aTab, url);
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
@ -508,7 +520,7 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="isFavIconKnownMissing">
|
||||
<method name="isIconKnownMissing">
|
||||
<parameter name="key"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
@ -638,13 +650,6 @@
|
||||
p.onLocationChange(webProgress, null, loc);
|
||||
if (securityUI)
|
||||
p.onSecurityChange(webProgress, null, securityUI.state);
|
||||
var listener = this.mTabListeners[this.mTabContainer.selectedIndex];
|
||||
if (listener.mIcon) {
|
||||
if (this.isFavIconKnownMissing(listener.mIcon))
|
||||
listener.mIcon = null;
|
||||
else if ('onLinkIconAvailable' in p)
|
||||
p.onLinkIconAvailable(newBrowser, listener.mIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mCurrentBrowser.userTypedClear = userTypedClear;
|
||||
@ -797,27 +802,9 @@
|
||||
// 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.setIcon(href);
|
||||
|
||||
if (tabBrowser.mProgressListeners) {
|
||||
var targetBrowser = tabBrowser.getBrowserAtIndex(browserIndex);
|
||||
for (i = 0; i < tabBrowser.mProgressListeners.length; i++) {
|
||||
var p = tabBrowser.mProgressListeners[i];
|
||||
if (p && 'onLinkIconAvailable' in p)
|
||||
p.onLinkIconAvailable(targetBrowser, href);
|
||||
}
|
||||
}
|
||||
|
||||
var tab = tabBrowser.mTabContainer.childNodes[browserIndex];
|
||||
tabBrowser.setIcon(tab, href);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
@ -923,11 +910,7 @@
|
||||
this.mCurrentBrowser.addEventListener("DOMTitleChanged", this.onTitleChanged, false);
|
||||
|
||||
this.setTabTitle(this.mCurrentTab);
|
||||
|
||||
// Hook up our favicon.
|
||||
var uri = this.mCurrentBrowser.currentURI;
|
||||
if (this.shouldLoadFavIcon(uri))
|
||||
this.loadFavIcon(uri, "image", this.mCurrentTab);
|
||||
this.setIcon(this.mCurrentTab, this.mCurrentBrowser.mIconURL);
|
||||
|
||||
var filter;
|
||||
if (this.mTabFilters.length > 0) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user