Push the mChannel member for documents up to nsDocument and expose it on

nsIDocument.  Bug 292971 preliminaries, r+sr=jst, a=chofmann
This commit is contained in:
bzbarsky%mit.edu 2005-06-01 01:15:23 +00:00
parent 0741ff04a6
commit 89f6d79b74
8 changed files with 36 additions and 23 deletions

View File

@ -90,8 +90,8 @@ class nsILayoutHistoryState;
// IID for the nsIDocument interface
#define NS_IDOCUMENT_IID \
{ 0x660e9925, 0x30e0, 0x4016, \
{ 0x8b, 0x7f, 0x0d, 0x70, 0x6e, 0xba, 0xc9, 0x8e } }
{ 0x97e4f20e, 0x73de, 0x41fd, \
{ 0x85, 0x20, 0x41, 0x45, 0xc8, 0x74, 0xf5, 0x85 } }
// The base value for the content ID counter.
// This counter is used by the document to
@ -441,6 +441,13 @@ public:
return mCSSLoader;
}
/**
* Get the channel that was passed to StartDocumentLoad for this
* document. Note that this may be null in some cases (eg if
* StartDocumentLoad was never called)
*/
virtual nsIChannel* GetChannel() const = 0;
/**
* Get this document's attribute stylesheet. May return null if
* there isn't one.

View File

@ -1030,6 +1030,8 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
RetrieveRelevantHeaders(aChannel);
mChannel = aChannel;
return NS_OK;
}

View File

@ -343,12 +343,15 @@ public:
virtual void AddCatalogStyleSheet(nsIStyleSheet* aSheet);
virtual void EnsureCatalogStyleSheet(const char *aStyleSheetURI);
virtual nsIChannel* GetChannel() const {
return mChannel;
}
/**
* Get this document's attribute stylesheet. May return null if
* there isn't one.
*/
nsHTMLStyleSheet* GetAttributeStyleSheet() const {
virtual nsHTMLStyleSheet* GetAttributeStyleSheet() const {
return mAttrStyleSheet;
}
@ -356,7 +359,7 @@ public:
* Get this document's inline style sheet. May return null if there
* isn't one
*/
nsIHTMLCSSStyleSheet* GetInlineStyleSheet() const {
virtual nsIHTMLCSSStyleSheet* GetInlineStyleSheet() const {
return mStyleAttrStyleSheet;
}
@ -631,6 +634,8 @@ protected:
nsSupportsHashtable* mBoxObjectTable;
// The channel that got passed to StartDocumentLoad(), if any
nsCOMPtr<nsIChannel> mChannel;
nsRefPtr<nsHTMLStyleSheet> mAttrStyleSheet;
nsCOMPtr<nsIHTMLCSSStyleSheet> mStyleAttrStyleSheet;
nsRefPtr<nsXMLEventsManager> mXMLEventsManager;

View File

@ -708,9 +708,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
// Store the security info for future use with wyciwyg channels.
aChannel->GetSecurityInfo(getter_AddRefs(mSecurityInfo));
// Stash away a pointer to our channel (we need this for cookies)
mChannel = aChannel;
nsCOMPtr<nsIURI> uri;
rv = aChannel->GetURI(getter_AddRefs(uri));
if (NS_FAILED(rv)) {

View File

@ -251,8 +251,6 @@ protected:
return mDefaultNamespaceID;
};
nsCOMPtr<nsIChannel> mChannel;
nsCompatibility mCompatMode;
nsCOMArray<nsIDOMHTMLMapElement> mImageMaps;

View File

@ -225,10 +225,10 @@ nsXMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
void
nsXMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup)
{
if (mPendingChannel) {
if (mChannelIsPending) {
StopDocumentLoad();
mPendingChannel->Cancel(NS_BINDING_ABORTED);
mPendingChannel = nsnull;
mChannel->Cancel(NS_BINDING_ABORTED);
mChannelIsPending = nsnull;
}
nsDocument::ResetToURI(aURI, aLoadGroup);
@ -506,12 +506,12 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn)
}
// After this point, if we error out of this method we should clear
// mPendingChannel.
// mChannelIsPending.
// Start an asynchronous read of the XML document
rv = channel->AsyncOpen(listener, nsnull);
if (NS_FAILED(rv)) {
mPendingChannel = nsnull;
mChannelIsPending = PR_FALSE;
if (modalEventQueue) {
mEventQService->PopThreadEventQueue(modalEventQueue);
}
@ -614,8 +614,9 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
rv = CallQueryInterface(mParser, aDocListener);
NS_ENSURE_SUCCESS(rv, rv);
mPendingChannel = aChannel;
NS_ASSERTION(mChannel, "How can we not have a channel here?");
mChannelIsPending = PR_TRUE;
SetDocumentCharacterSet(charset);
mParser->SetDocumentCharset(charset, charsetSource);
mParser->SetCommand(aCommand);
@ -628,7 +629,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
void
nsXMLDocument::EndLoad()
{
mPendingChannel = nsnull;
mChannelIsPending = PR_FALSE;
mLoopingForSyncLoad = PR_FALSE;
if (mLoadedAsData || mLoadedAsInteractiveData) {

View File

@ -102,12 +102,13 @@ protected:
nsCOMPtr<nsIScriptContext> mScriptContext;
// mPendingChannel is the channel that we're currently asynchronously loading
// (via document.load() or normal load). It's set when we first find out
// about the channel (at the end of StartDocumentLoad) and cleared in EndLoad
// or if ResetToURI() is called. In the latter case it's also cancelled.
nsCOMPtr<nsIChannel> mPendingChannel;
// mChannelIsPending indicates whether we're currently asynchronously loading
// data from mChannel (via document.load() or normal load). It's set to true
// when we first find out about the channel (StartDocumentLoad) and set to
// false in EndLoad or if ResetToURI() is called. In the latter case our
// mChannel is also cancelled. Note that if this member is true, mChannel
// cannot be null.
PRPackedBool mChannelIsPending;
PRPackedBool mCrossSiteAccessEnabled;
PRPackedBool mLoadedAsData;
PRPackedBool mLoadedAsInteractiveData;

View File

@ -532,6 +532,8 @@ nsXULDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
mDocumentTitle.SetIsVoid(PR_TRUE);
mChannel = aChannel;
nsresult rv = aChannel->GetOriginalURI(getter_AddRefs(mDocumentURI));
NS_ENSURE_SUCCESS(rv, rv);