mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-22 12:04:38 +00:00
Bug 691610 - e10s support for useDefaultIcon. r=felipe sr=smaug
This commit is contained in:
parent
59393898c7
commit
2a7f05152e
@ -586,10 +586,8 @@
|
||||
if (this._shouldShowProgress(aRequest)) {
|
||||
if (!(aStateFlags & nsIWebProgressListener.STATE_RESTORING)) {
|
||||
this.mTab.setAttribute("busy", "true");
|
||||
if (!gMultiProcessBrowser) {
|
||||
if (!(this.mBrowser.docShell.loadType & Ci.nsIDocShell.LOAD_CMD_RELOAD))
|
||||
this.mTabBrowser.setTabTitleLoading(this.mTab);
|
||||
}
|
||||
if (!(aWebProgress.loadType & Ci.nsIDocShell.LOAD_CMD_RELOAD))
|
||||
this.mTabBrowser.setTabTitleLoading(this.mTab);
|
||||
}
|
||||
|
||||
if (this.mTab.selected)
|
||||
@ -701,10 +699,9 @@
|
||||
|
||||
// Don't clear the favicon if this onLocationChange was
|
||||
// triggered by a pushState or a replaceState. See bug 550565.
|
||||
if (!gMultiProcessBrowser) {
|
||||
if (aWebProgress.isLoadingDocument &&
|
||||
!(this.mBrowser.docShell.loadType & Ci.nsIDocShell.LOAD_CMD_PUSHSTATE))
|
||||
this.mBrowser.mIconURL = null;
|
||||
if (aWebProgress.isLoadingDocument &&
|
||||
!(aWebProgress.loadType & Ci.nsIDocShell.LOAD_CMD_PUSHSTATE)) {
|
||||
this.mBrowser.mIconURL = null;
|
||||
}
|
||||
|
||||
let autocomplete = this.mTabBrowser._placesAutocomplete;
|
||||
@ -830,30 +827,23 @@
|
||||
<parameter name="aTab"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
// Bug 691610 - e10s support for useDefaultIcon
|
||||
if (gMultiProcessBrowser)
|
||||
return;
|
||||
|
||||
var browser = this.getBrowserForTab(aTab);
|
||||
var docURIObject = browser.contentDocument.documentURIObject;
|
||||
var documentURI = browser.documentURI;
|
||||
var icon = null;
|
||||
if (browser.contentDocument instanceof ImageDocument) {
|
||||
|
||||
if (browser.imageDocument) {
|
||||
if (Services.prefs.getBoolPref("browser.chrome.site_icons")) {
|
||||
let sz = Services.prefs.getIntPref("browser.chrome.image_icons.max_size");
|
||||
try {
|
||||
let req = browser.contentDocument.imageRequest;
|
||||
if (req &&
|
||||
req.image &&
|
||||
req.image.width <= sz &&
|
||||
req.image.height <= sz)
|
||||
icon = browser.currentURI;
|
||||
} catch (e) { }
|
||||
if (browser.imageDocument.width <= sz &&
|
||||
browser.imageDocument.height <= sz) {
|
||||
icon = browser.currentURI;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Use documentURIObject in the check for shouldLoadFavIcon so that we
|
||||
// do the right thing with about:-style error pages. Bug 453442
|
||||
else if (this.shouldLoadFavIcon(docURIObject)) {
|
||||
let url = docURIObject.prePath + "/favicon.ico";
|
||||
else if (this.shouldLoadFavIcon(documentURI)) {
|
||||
let url = documentURI.prePath + "/favicon.ico";
|
||||
if (!this.isFailedIcon(url))
|
||||
icon = url;
|
||||
}
|
||||
|
@ -54,11 +54,10 @@ namespace dom {
|
||||
class ImageListener : public MediaDocumentStreamListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
ImageListener(ImageDocument* aDocument);
|
||||
virtual ~ImageListener();
|
||||
|
||||
/* nsIRequestObserver */
|
||||
NS_IMETHOD OnStartRequest(nsIRequest* request, nsISupports *ctxt);
|
||||
};
|
||||
|
||||
ImageListener::ImageListener(ImageDocument* aDocument)
|
||||
@ -96,7 +95,7 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
|
||||
if (secMan) {
|
||||
secMan->GetChannelPrincipal(channel, getter_AddRefs(channelPrincipal));
|
||||
}
|
||||
|
||||
|
||||
int16_t decision = nsIContentPolicy::ACCEPT;
|
||||
nsresult rv = NS_CheckContentProcessPolicy(nsIContentPolicy::TYPE_IMAGE,
|
||||
channelURI,
|
||||
@ -107,7 +106,7 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
|
||||
&decision,
|
||||
nsContentUtils::GetContentPolicy(),
|
||||
secMan);
|
||||
|
||||
|
||||
if (NS_FAILED(rv) || NS_CP_REJECTED(decision)) {
|
||||
request->Cancel(NS_ERROR_CONTENT_BLOCKED);
|
||||
return NS_OK;
|
||||
@ -123,6 +122,16 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
|
||||
return MediaDocumentStreamListener::OnStartRequest(request, ctxt);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageListener::OnStopRequest(nsIRequest* aRequest, nsISupports* aCtxt, nsresult aStatus)
|
||||
{
|
||||
ImageDocument* imgDoc = static_cast<ImageDocument*>(mDocument.get());
|
||||
nsContentUtils::DispatchChromeEvent(imgDoc, static_cast<nsIDocument*>(imgDoc),
|
||||
NS_LITERAL_STRING("ImageContentLoaded"),
|
||||
true, true);
|
||||
return MediaDocumentStreamListener::OnStopRequest(aRequest, aCtxt, aStatus);
|
||||
}
|
||||
|
||||
ImageDocument::ImageDocument()
|
||||
: MediaDocument(),
|
||||
mOriginalZoomLevel(1.0)
|
||||
|
@ -69,6 +69,7 @@ MOCHITEST_FILES = imgutils.js \
|
||||
test_drawDiscardedImage.html \
|
||||
short_header.gif \
|
||||
test_short_gif_header.html \
|
||||
test_ImageContentLoaded.html \
|
||||
$(NULL)
|
||||
|
||||
# Tests disabled due to intermittent orange
|
||||
|
28
image/test/mochitest/test_ImageContentLoaded.html
Normal file
28
image/test/mochitest/test_ImageContentLoaded.html
Normal file
@ -0,0 +1,28 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=691610
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 691610</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish()
|
||||
|
||||
SpecialPowers.addChromeEventListener("ImageContentLoaded", function () {
|
||||
ok(true, "chrome listener was invoked");
|
||||
SimpleTest.finish();
|
||||
}, true);
|
||||
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.src = "damon.jpg"
|
||||
document.body.appendChild(iframe);
|
||||
iframe.contentDocument.defaultView.addEventListener("ImageContentLoaded", function () {
|
||||
ok(false, "should not invoke event");
|
||||
}, true);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -97,6 +97,13 @@ nsBrowserStatusFilter::GetIsLoadingDocument(bool *aIsLoadingDocument)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserStatusFilter::GetLoadType(uint32_t *aLoadType)
|
||||
{
|
||||
*aLoadType = 0;
|
||||
NS_NOTREACHED("nsBrowserStatusFilter::GetLoadType");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsBrowserStatusFilter::nsIWebProgressListener
|
||||
|
@ -25,7 +25,9 @@ let WebProgressListener = {
|
||||
_setupJSON: function setupJSON(aWebProgress, aRequest) {
|
||||
return {
|
||||
isTopLevel: aWebProgress.isTopLevel,
|
||||
requestURI: this._requestSpec(aRequest)
|
||||
isLoadingDocument: aWebProgress.isLoadingDocument,
|
||||
requestURI: this._requestSpec(aRequest),
|
||||
loadType: aWebProgress.loadType
|
||||
};
|
||||
},
|
||||
|
||||
@ -195,3 +197,13 @@ addEventListener("DOMTitleChanged", function (aEvent) {
|
||||
break;
|
||||
}
|
||||
}, false);
|
||||
|
||||
addEventListener("ImageContentLoaded", function (aEvent) {
|
||||
if (content.document instanceof Ci.nsIImageDocument) {
|
||||
let req = content.document.imageRequest;
|
||||
if (!req.image)
|
||||
return;
|
||||
sendAsyncMessage("ImageDocumentLoaded", { width: req.image.width,
|
||||
height: req.image.height });
|
||||
}
|
||||
}, false)
|
@ -214,6 +214,10 @@
|
||||
onget="return this.webNavigation.currentURI;"
|
||||
readonly="true"/>
|
||||
|
||||
<property name="documentURI"
|
||||
onget="return this.contentDocument.documentURIObject;"
|
||||
readonly="true"/>
|
||||
|
||||
<property name="preferences"
|
||||
onget="return this.mPrefs.QueryInterface(Components.interfaces.nsIPrefService);"
|
||||
readonly="true"/>
|
||||
@ -239,6 +243,22 @@
|
||||
</setter>
|
||||
</property>
|
||||
|
||||
<property name="imageDocument"
|
||||
readonly="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
var document = this.contentDocument;
|
||||
if (!document || !(document instanceof Ci.nsIImageDocument))
|
||||
return null;
|
||||
|
||||
try {
|
||||
return {width: document.imageRequest.image.width, height: document.imageRequest.image.height };
|
||||
} catch (e) {}
|
||||
return null;
|
||||
]]>
|
||||
</getter>
|
||||
</property>
|
||||
|
||||
<property name="isRemoteBrowser"
|
||||
onget="return (this.getAttribute('remote') == 'true');"
|
||||
readonly="true"/>
|
||||
|
@ -50,6 +50,12 @@
|
||||
</getter>
|
||||
</property>
|
||||
|
||||
<field name="_documentURI">null</field>
|
||||
|
||||
<property name="documentURI"
|
||||
onget="return this._documentURI;"
|
||||
readonly="true"/>
|
||||
|
||||
<field name="_contentTitle">""</field>
|
||||
|
||||
<property name="contentTitle"
|
||||
@ -72,9 +78,16 @@
|
||||
onget="return this.contentWindow ? this.contentWindow.document : null"
|
||||
readonly="true"/>
|
||||
|
||||
<field name="_imageDocument">null</field>
|
||||
|
||||
<property name="imageDocument"
|
||||
onget="return this._imageDocument"
|
||||
readonly="true"/>
|
||||
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this.messageManager.addMessageListener("DOMTitleChanged", this);
|
||||
this.messageManager.addMessageListener("ImageDocumentLoaded", this);
|
||||
this.messageManager.loadFrameScript("chrome://global/content/browser-child.js", true);
|
||||
this.webProgress._init();
|
||||
]]>
|
||||
@ -94,6 +107,12 @@
|
||||
case "DOMTitleChanged":
|
||||
this._contentTitle = json.title;
|
||||
break;
|
||||
case "ImageDocumentLoaded":
|
||||
this._imageDocument = {
|
||||
width: json.width,
|
||||
height: json.height
|
||||
};
|
||||
break;
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
@ -11,6 +11,12 @@ const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
function newURI(spec)
|
||||
{
|
||||
return Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService)
|
||||
.newURI(spec, null, null);
|
||||
}
|
||||
|
||||
function RemoteWebProgressRequest(spec)
|
||||
{
|
||||
this.uri = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService)
|
||||
@ -26,9 +32,10 @@ RemoteWebProgressRequest.prototype = {
|
||||
function RemoteWebProgress(browser)
|
||||
{
|
||||
this._browser = browser;
|
||||
this._isDocumentLoading = false;
|
||||
this._isLoadingDocument = false;
|
||||
this._DOMWindow = null;
|
||||
this._isTopLevel = null;
|
||||
this._loadType = 0;
|
||||
this._progressListeners = [];
|
||||
}
|
||||
|
||||
@ -56,7 +63,7 @@ RemoteWebProgress.prototype = {
|
||||
this._browser = null;
|
||||
},
|
||||
|
||||
get isLoadingDocument() { return this._isDocumentLoading },
|
||||
get isLoadingDocument() { return this._isLoadingDocument },
|
||||
get DOMWindow() { return this._DOMWindow; },
|
||||
get DOMWindowID() { return 0; },
|
||||
get isTopLevel() {
|
||||
@ -68,6 +75,7 @@ RemoteWebProgress.prototype = {
|
||||
// may not be a toplevel frame.
|
||||
return this._isTopLevel === null ? true : this._isTopLevel;
|
||||
},
|
||||
get loadType() { return this._loadType; },
|
||||
|
||||
addProgressListener: function WP_AddProgressListener (aListener) {
|
||||
let listener = aListener.QueryInterface(Ci.nsIWebProgressListener);
|
||||
@ -86,8 +94,11 @@ RemoteWebProgress.prototype = {
|
||||
},
|
||||
|
||||
receiveMessage: function WP_ReceiveMessage(aMessage) {
|
||||
this._isLoadingDocument = aMessage.json.isLoadingDocument;
|
||||
this._DOMWindow = aMessage.objects.DOMWindow;
|
||||
this._isTopLevel = aMessage.json.isTopLevel;
|
||||
this._loadType = aMessage.json.loadType;
|
||||
|
||||
this._browser._contentWindow = aMessage.objects.contentWindow;
|
||||
|
||||
let req = this._uriSpec(aMessage.json.requestURI);
|
||||
@ -99,13 +110,14 @@ RemoteWebProgress.prototype = {
|
||||
break;
|
||||
|
||||
case "Content:LocationChange":
|
||||
let loc = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService)
|
||||
.newURI(aMessage.json.location, null, null);
|
||||
let loc = newURI(aMessage.json.location);
|
||||
|
||||
this._browser.webNavigation._currentURI = loc;
|
||||
this._browser.webNavigation.canGoBack = aMessage.json.canGoBack;
|
||||
this._browser.webNavigation.canGoForward = aMessage.json.canGoForward;
|
||||
this._browser._characterSet = aMessage.json.charset;
|
||||
this._browser._documentURI = newURI(aMessage.json.documentURI);
|
||||
this._browser._imageDocument = null;
|
||||
|
||||
for each (let p in this._progressListeners) {
|
||||
p.onLocationChange(this, req, loc);
|
||||
|
@ -975,6 +975,14 @@ nsDocLoader::GetIsLoadingDocument(bool *aIsLoadingDocument)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocLoader::GetLoadType(uint32_t *aLoadType)
|
||||
{
|
||||
*aLoadType = 0;
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
int64_t nsDocLoader::GetMaxTotalProgress()
|
||||
{
|
||||
int64_t newMaxTotal = 0;
|
||||
|
@ -26,14 +26,14 @@ interface nsIWebProgressListener;
|
||||
* notifications from any nsIWebProgress instances that are children of that
|
||||
* nsIWebProgress instance.
|
||||
*/
|
||||
[scriptable, uuid(1c3437b0-9e2c-11e2-9e96-0800200c9a66)]
|
||||
[scriptable, uuid(bd0efb3b-1c81-4fb0-b16d-576a2be48a95)]
|
||||
interface nsIWebProgress : nsISupports
|
||||
{
|
||||
/**
|
||||
* The following flags may be combined to form the aNotifyMask parameter for
|
||||
* the addProgressListener method. They limit the set of events that are
|
||||
* delivered to an nsIWebProgressListener instance.
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* These flags indicate the state transistions to observe, corresponding to
|
||||
@ -42,7 +42,7 @@ interface nsIWebProgress : nsISupports
|
||||
* NOTIFY_STATE_REQUEST
|
||||
* Only receive the onStateChange event if the aStateFlags parameter
|
||||
* includes nsIWebProgressListener::STATE_IS_REQUEST.
|
||||
*
|
||||
*
|
||||
* NOTIFY_STATE_DOCUMENT
|
||||
* Only receive the onStateChange event if the aStateFlags parameter
|
||||
* includes nsIWebProgressListener::STATE_IS_DOCUMENT.
|
||||
@ -138,10 +138,16 @@ interface nsIWebProgress : nsISupports
|
||||
* Indicates whether DOMWindow.top == DOMWindow.
|
||||
*/
|
||||
readonly attribute boolean isTopLevel;
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether or not a document is currently being loaded
|
||||
* in the context of this nsIWebProgress instance.
|
||||
*/
|
||||
readonly attribute boolean isLoadingDocument;
|
||||
|
||||
/**
|
||||
* Contains a load type as specified by the load* constants in
|
||||
* nsIDocShellLoadInfo.idl.
|
||||
*/
|
||||
readonly attribute unsigned long loadType;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user