mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Fix for bug 57636. r=rpotts, sr=jst, a=asa. Onload handlers now fire on document.written content.
This commit is contained in:
parent
220e686401
commit
73edd4ea66
@ -365,9 +365,9 @@ public:
|
||||
NS_IMETHOD Init(nsIWidget* aParentWidget,
|
||||
nsIDeviceContext* aDeviceContext,
|
||||
const nsRect& aBounds);
|
||||
NS_IMETHOD BindToDocument(nsISupports* aDoc, const char* aCommand);
|
||||
NS_IMETHOD SetContainer(nsISupports* aContainer);
|
||||
NS_IMETHOD GetContainer(nsISupports** aContainerResult);
|
||||
NS_IMETHOD LoadStart(nsISupports* aDoc);
|
||||
NS_IMETHOD LoadComplete(nsresult aStatus);
|
||||
NS_IMETHOD Destroy(void);
|
||||
NS_IMETHOD Stop(void);
|
||||
@ -506,6 +506,8 @@ private:
|
||||
PRUint32 aDelay);
|
||||
void StopPagePrintTimer();
|
||||
|
||||
void PrepareToStartLoad(void);
|
||||
|
||||
protected:
|
||||
// IMPORTANT: The ownership implicit in the following member
|
||||
// variables has been explicitly checked and set using nsCOMPtr
|
||||
@ -801,12 +803,15 @@ NS_NewDocumentViewer(nsIDocumentViewer** aResult)
|
||||
DocumentViewerImpl::DocumentViewerImpl()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
PrepareToStartLoad();
|
||||
}
|
||||
|
||||
void DocumentViewerImpl::PrepareToStartLoad() {
|
||||
mEnableRendering = PR_TRUE;
|
||||
mStopped = PR_FALSE;
|
||||
mLoaded = PR_FALSE;
|
||||
mPrt = nsnull;
|
||||
mIsPrinting = PR_FALSE;
|
||||
|
||||
}
|
||||
|
||||
DocumentViewerImpl::DocumentViewerImpl(nsIPresContext* aPresContext)
|
||||
@ -815,9 +820,7 @@ DocumentViewerImpl::DocumentViewerImpl(nsIPresContext* aPresContext)
|
||||
NS_INIT_ISUPPORTS();
|
||||
mHintCharsetSource = kCharsetUninitialized;
|
||||
mAllowPlugins = PR_TRUE;
|
||||
mEnableRendering = PR_TRUE;
|
||||
mPrt = nsnull;
|
||||
mIsPrinting = PR_FALSE;
|
||||
PrepareToStartLoad();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS5(DocumentViewerImpl,
|
||||
@ -864,18 +867,27 @@ DocumentViewerImpl::~DocumentViewerImpl()
|
||||
* This method is called by the Document Loader once a document has
|
||||
* been created for a particular data stream... The content viewer
|
||||
* must cache this document for later use when Init(...) is called.
|
||||
*
|
||||
* This method is also called when an out of band document.write() happens.
|
||||
* In that case, the document passed in is the same as the previous document.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
DocumentViewerImpl::BindToDocument(nsISupports *aDoc, const char *aCommand)
|
||||
DocumentViewerImpl::LoadStart(nsISupports *aDoc)
|
||||
{
|
||||
NS_PRECONDITION(!mDocument, "Viewer is already bound to a document!");
|
||||
|
||||
#ifdef NOISY_VIEWER
|
||||
printf("DocumentViewerImpl::BindToDocument\n");
|
||||
printf("DocumentViewerImpl::LoadStart\n");
|
||||
#endif
|
||||
|
||||
nsresult rv;
|
||||
mDocument = do_QueryInterface(aDoc,&rv);
|
||||
if (!mDocument) {
|
||||
mDocument = do_QueryInterface(aDoc,&rv);
|
||||
}
|
||||
else if (mDocument == aDoc) {
|
||||
// Reset the document viewer's state back to what it was
|
||||
// when the document load started.
|
||||
PrepareToStartLoad();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -3839,8 +3851,8 @@ DocumentViewerImpl::CreateDocumentViewerUsing(nsIPresContext* aPresContext,
|
||||
viewer->SetUAStyleSheet(mUAStyleSheet);
|
||||
|
||||
// Bind the new viewer to the old document
|
||||
nsresult rv = viewer->BindToDocument(mDocument, "create");/* XXX verb? */
|
||||
|
||||
nsresult rv = viewer->LoadStart(mDocument);
|
||||
|
||||
aResult = viewer;
|
||||
|
||||
return rv;
|
||||
|
@ -323,7 +323,7 @@ nsContentDLF::CreateInstanceForDocument(nsISupports* aContainer,
|
||||
docv->SetUAStyleSheet(nsContentDLF::GetUAStyleSheet());
|
||||
|
||||
// Bind the document to the Content Viewer
|
||||
rv = docv->BindToDocument(aDocument, aCommand);
|
||||
rv = docv->LoadStart(aDocument);
|
||||
*aDocViewerResult = docv;
|
||||
NS_IF_ADDREF(*aDocViewerResult);
|
||||
} while (PR_FALSE);
|
||||
@ -379,7 +379,7 @@ nsContentDLF::CreateDocument(const char* aCommand,
|
||||
break;
|
||||
|
||||
// Bind the document to the Content Viewer
|
||||
rv = docv->BindToDocument(doc, aCommand);
|
||||
rv = docv->LoadStart(doc);
|
||||
*aDocViewer = docv;
|
||||
NS_IF_ADDREF(*aDocViewer);
|
||||
} while (PR_FALSE);
|
||||
@ -470,7 +470,7 @@ nsContentDLF::CreateRDFDocument(const char* aCommand,
|
||||
/*
|
||||
* Bind the document to the Content Viewer...
|
||||
*/
|
||||
rv = docv->BindToDocument(doc, aCommand);
|
||||
rv = docv->LoadStart(doc);
|
||||
*aDocViewer = docv;
|
||||
NS_IF_ADDREF(*aDocViewer);
|
||||
}
|
||||
@ -495,7 +495,7 @@ nsContentDLF::CreateXULDocumentFromStream(nsIInputStream& aXULStream,
|
||||
if ( NS_FAILED(status = CreateRDFDocument(aExtraInfo, address_of(doc), address_of(docv))) )
|
||||
break;
|
||||
|
||||
if ( NS_FAILED(status = docv->BindToDocument(doc, aCommand)) )
|
||||
if ( NS_FAILED(status = docv->LoadStart(doc)) )
|
||||
break;
|
||||
|
||||
*aDocViewer = docv;
|
||||
|
@ -111,6 +111,7 @@
|
||||
#include "nsHTMLParts.h" //for createelementNS
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDocumentViewer.h"
|
||||
|
||||
#include "nsContentCID.h"
|
||||
#include "nsIPrompt.h"
|
||||
@ -211,6 +212,7 @@ nsHTMLDocument::nsHTMLDocument()
|
||||
mParser = nsnull;
|
||||
mDTDMode = eDTDMode_quirks;
|
||||
mCSSLoader = nsnull;
|
||||
mDocWriteDummyRequest = nsnull;
|
||||
|
||||
mBodyContent = nsnull;
|
||||
mForms = nsnull;
|
||||
@ -376,6 +378,9 @@ nsHTMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(mDocWriteDummyRequest == nsnull, "nsHTMLDocument::Reset() - dummy doc write request still exists!");
|
||||
mDocWriteDummyRequest = nsnull;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2054,13 +2059,14 @@ nsHTMLDocument::GetSourceDocumentURL(JSContext* cx,
|
||||
nsresult
|
||||
nsHTMLDocument::OpenCommon(nsIURI* aSourceURL)
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docshell;
|
||||
|
||||
// If we already have a parser we ignore the document.open call.
|
||||
if (mParser)
|
||||
return NS_OK;
|
||||
|
||||
// Stop current loads targetted at the window this document is in.
|
||||
if (mScriptGlobalObject) {
|
||||
nsCOMPtr<nsIDocShell> docshell;
|
||||
mScriptGlobalObject->GetDocShell(getter_AddRefs(docshell));
|
||||
|
||||
if (docshell) {
|
||||
@ -2076,6 +2082,7 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURL)
|
||||
nsCOMPtr<nsILoadGroup> group = do_QueryReferent(mDocumentLoadGroup);
|
||||
|
||||
result = NS_OpenURI(getter_AddRefs(channel), aSourceURL, nsnull, group);
|
||||
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
||||
//Before we reset the doc notify the globalwindow of the change.
|
||||
@ -2189,6 +2196,21 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURL)
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare the docshell and the document viewer for the impending out of band document.write()
|
||||
if (docshell) {
|
||||
docshell->PrepareForNewContentModel();
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
docshell->GetContentViewer(getter_AddRefs(cv));
|
||||
nsCOMPtr<nsIDocumentViewer> docViewer = do_QueryInterface(cv);
|
||||
if (docViewer) {
|
||||
docViewer->LoadStart(NS_STATIC_CAST(nsIHTMLDocument *, this));
|
||||
}
|
||||
}
|
||||
|
||||
// Add a doc write dummy request into the document load group
|
||||
NS_ASSERTION(mDocWriteDummyRequest == nsnull, "nsHTMLDocument::OpenCommon(): doc write dummy request exists!");
|
||||
AddDocWriteDummyRequest();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2260,6 +2282,27 @@ nsHTMLDocument::Close()
|
||||
mWriteLevel--;
|
||||
mIsWriting = 0;
|
||||
NS_IF_RELEASE(mParser);
|
||||
|
||||
// XXX Make sure that all the document.written content is reflowed.
|
||||
// We should remove this call once we change nsHTMLDocument::OpenCommon() so that it
|
||||
// completely destroys the earlier document's content and frame hierarchy. Right now,
|
||||
// it re-uses the earlier document's root content object and corresponding frame objects.
|
||||
// These re-used frame objects think that they have already been reflowed, so they drop
|
||||
// initial reflows. For certain cases of document.written content, like a frameset document,
|
||||
// the dropping of the initial reflow means that we end up in document.close() without
|
||||
// appended any reflow commands to the reflow queue and, consequently, without adding the
|
||||
// dummy layout request to the load group. Since the dummy layout request is not added to
|
||||
// the load group, the onload handler of the frameset fires before the frames get reflowed
|
||||
// and loaded. That is the long explanation for why we need this one line of code here!
|
||||
FlushPendingNotifications();
|
||||
|
||||
// Remove the doc write dummy request from the document load group
|
||||
// that we added in OpenCommon(). If all other requests between
|
||||
// document.open() and document.close() have completed, then this
|
||||
// method should cause the firing of an onload event.
|
||||
NS_ASSERTION(mDocWriteDummyRequest, "nsHTMLDocument::Close(): Trying to remove non-existent doc write dummy request!");
|
||||
RemoveDocWriteDummyRequest();
|
||||
NS_ASSERTION(mDocWriteDummyRequest == nsnull, "nsHTMLDocument::Close(): Doc write dummy request could not be removed!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -3507,3 +3550,159 @@ nsHTMLDocument::GetForms(nsIDOMHTMLCollection** aForms)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// DocWriteDummyRequest
|
||||
//
|
||||
// This is a dummy request implementation that is used to make sure that
|
||||
// the onload event fires for document.writes that occur after the document
|
||||
// has finished loading. Since such document.writes() blow away the old document
|
||||
// we need some way to generate document load notifications for the content that
|
||||
// is document.written. The addition and removal of the dummy request generates
|
||||
// the appropriate load notifications which bubble up through a chain of observers
|
||||
// till the document viewer's LoadComplete() method which fires the onLoad event.
|
||||
//
|
||||
|
||||
class DocWriteDummyRequest : public nsIChannel
|
||||
{
|
||||
protected:
|
||||
DocWriteDummyRequest();
|
||||
virtual ~DocWriteDummyRequest();
|
||||
|
||||
static PRInt32 gRefCnt;
|
||||
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsLoadFlags mLoadFlags;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
|
||||
public:
|
||||
static nsresult
|
||||
Create(nsIRequest** aResult);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRequest
|
||||
NS_IMETHOD GetName(PRUnichar* *result) {
|
||||
*result = ToNewUnicode(NS_LITERAL_STRING("about:dummy-doc-write-request"));
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD IsPending(PRBool *_retval) { *_retval = PR_TRUE; return NS_OK; }
|
||||
NS_IMETHOD GetStatus(nsresult *status) { *status = NS_OK; return NS_OK; }
|
||||
NS_IMETHOD Cancel(nsresult status);
|
||||
NS_IMETHOD Suspend(void) { return NS_OK; }
|
||||
NS_IMETHOD Resume(void) { return NS_OK; }
|
||||
|
||||
// nsIChannel
|
||||
NS_IMETHOD GetOriginalURI(nsIURI* *aOriginalURI) { *aOriginalURI = mURI; NS_ADDREF(*aOriginalURI); return NS_OK; }
|
||||
NS_IMETHOD SetOriginalURI(nsIURI* aOriginalURI) { mURI = aOriginalURI; return NS_OK; }
|
||||
NS_IMETHOD GetURI(nsIURI* *aURI) { *aURI = mURI; NS_ADDREF(*aURI); return NS_OK; }
|
||||
NS_IMETHOD Open(nsIInputStream **_retval) { *_retval = nsnull; return NS_OK; }
|
||||
NS_IMETHOD AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt) { return NS_OK; }
|
||||
NS_IMETHOD GetLoadFlags(nsLoadFlags *aLoadFlags) { *aLoadFlags = mLoadFlags; return NS_OK; }
|
||||
NS_IMETHOD SetLoadFlags(nsLoadFlags aLoadFlags) { mLoadFlags = aLoadFlags; return NS_OK; }
|
||||
NS_IMETHOD GetOwner(nsISupports * *aOwner) { *aOwner = nsnull; return NS_OK; }
|
||||
NS_IMETHOD SetOwner(nsISupports * aOwner) { return NS_OK; }
|
||||
NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup) { *aLoadGroup = mLoadGroup; NS_IF_ADDREF(*aLoadGroup); return NS_OK; }
|
||||
NS_IMETHOD SetLoadGroup(nsILoadGroup * aLoadGroup) { mLoadGroup = aLoadGroup; return NS_OK; }
|
||||
NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks) { *aNotificationCallbacks = nsnull; return NS_OK; }
|
||||
NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks) { return NS_OK; }
|
||||
NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo) { *aSecurityInfo = nsnull; return NS_OK; }
|
||||
NS_IMETHOD GetContentType(char * *aContentType) { *aContentType = nsnull; return NS_OK; }
|
||||
NS_IMETHOD SetContentType(const char * aContentType) { return NS_OK; }
|
||||
NS_IMETHOD GetContentLength(PRInt32 *aContentLength) { return NS_OK; }
|
||||
NS_IMETHOD SetContentLength(PRInt32 aContentLength) { return NS_OK; }
|
||||
|
||||
};
|
||||
|
||||
PRInt32 DocWriteDummyRequest::gRefCnt;
|
||||
|
||||
NS_IMPL_ADDREF(DocWriteDummyRequest);
|
||||
NS_IMPL_RELEASE(DocWriteDummyRequest);
|
||||
NS_IMPL_QUERY_INTERFACE2(DocWriteDummyRequest, nsIRequest, nsIChannel);
|
||||
|
||||
nsresult
|
||||
DocWriteDummyRequest::Create(nsIRequest** aResult)
|
||||
{
|
||||
DocWriteDummyRequest* request = new DocWriteDummyRequest();
|
||||
if (!request)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return request->QueryInterface(NS_GET_IID(nsIRequest), (void**) aResult);
|
||||
}
|
||||
|
||||
|
||||
DocWriteDummyRequest::DocWriteDummyRequest()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
gRefCnt++;
|
||||
mLoadGroup = nsnull;
|
||||
mLoadFlags = 0;
|
||||
mURI = nsnull;
|
||||
}
|
||||
|
||||
|
||||
DocWriteDummyRequest::~DocWriteDummyRequest()
|
||||
{
|
||||
gRefCnt--;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocWriteDummyRequest::Cancel(nsresult status)
|
||||
{
|
||||
// XXX To be implemented?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
nsresult
|
||||
nsHTMLDocument::AddDocWriteDummyRequest(void)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
rv = DocWriteDummyRequest::Create(getter_AddRefs(mDocWriteDummyRequest));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
|
||||
rv = GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (loadGroup) {
|
||||
nsCOMPtr<nsIChannel> channel(do_QueryInterface(mDocWriteDummyRequest));
|
||||
rv = channel->SetLoadGroup(loadGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsLoadFlags loadFlags = 0;
|
||||
channel->GetLoadFlags(&loadFlags);
|
||||
loadFlags |= nsIChannel::LOAD_DOCUMENT_URI;
|
||||
channel->SetLoadFlags(loadFlags);
|
||||
|
||||
channel->SetOriginalURI(mDocumentURL);
|
||||
|
||||
rv = loadGroup->AddRequest(mDocWriteDummyRequest, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLDocument::RemoveDocWriteDummyRequest(void)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
rv = GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (loadGroup && mDocWriteDummyRequest) {
|
||||
rv = loadGroup->RemoveRequest(mDocWriteDummyRequest, nsnull, NS_OK);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mDocWriteDummyRequest = nsnull;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -36,6 +36,12 @@
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIRDFService.h"
|
||||
|
||||
// Doc write dummy request
|
||||
#include "nsIChannel.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
|
||||
class nsBaseContentList;
|
||||
class nsContentList;
|
||||
class nsIHTMLStyleSheet;
|
||||
@ -187,6 +193,9 @@ protected:
|
||||
nsresult ScriptWriteCommon(PRBool aNewlineTerminate);
|
||||
nsresult OpenCommon(nsIURI* aUrl);
|
||||
|
||||
nsresult AddDocWriteDummyRequest(void);
|
||||
nsresult RemoveDocWriteDummyRequest(void);
|
||||
|
||||
nsIHTMLStyleSheet* mAttrStyleSheet;
|
||||
nsIHTMLCSSStyleSheet* mStyleAttrStyleSheet;
|
||||
nsIURI* mBaseURL;
|
||||
@ -226,6 +235,7 @@ protected:
|
||||
|
||||
nsHashtable mNameHashTable;
|
||||
nsHashtable mIdHashTable;
|
||||
nsCOMPtr<nsIRequest> mDocWriteDummyRequest;
|
||||
};
|
||||
|
||||
#endif /* nsHTMLDocument_h___ */
|
||||
|
@ -178,7 +178,6 @@ nsDocShell::nsDocShell():
|
||||
mItemType(typeContent),
|
||||
mCurrentScrollbarPref(-1, -1),
|
||||
mDefaultScrollbarPref(-1, -1),
|
||||
mInitialPageLoad(PR_TRUE),
|
||||
mAllowPlugins(PR_TRUE),
|
||||
mAllowJavascript(PR_TRUE),
|
||||
mAllowMetaRedirects(PR_TRUE),
|
||||
@ -685,6 +684,17 @@ nsDocShell::StopLoad()
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Reset state to a new content model within the current document and the document
|
||||
* viewer. Called by the document before initiating an out of band document.write().
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::PrepareForNewContentModel()
|
||||
{
|
||||
mEODForCurrentDocument = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// Bug 13871: Prevent frameset spoofing
|
||||
// Check if origin document uri is the equivalent to target's principal.
|
||||
@ -2359,6 +2369,7 @@ nsDocShell::Destroy()
|
||||
|
||||
if (mScriptGlobal) {
|
||||
mScriptGlobal->SetDocShell(nsnull);
|
||||
mScriptGlobal->SetGlobalObjectOwner(nsnull);
|
||||
mScriptGlobal = nsnull;
|
||||
}
|
||||
if (mScriptContext) {
|
||||
@ -3737,7 +3748,8 @@ nsDocShell::CreateContentViewer(const char *aContentType,
|
||||
NS_ENSURE_SUCCESS(Embed(viewer, "", (nsISupports *) nsnull),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
mEODForCurrentDocument = PR_FALSE; // clear the current flag
|
||||
mEODForCurrentDocument = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -4851,7 +4863,6 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel,
|
||||
// will set it up for us.
|
||||
SetupRefreshURI(aChannel);
|
||||
|
||||
mInitialPageLoad = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,6 @@ protected:
|
||||
nsPoint mCurrentScrollbarPref; // this document only
|
||||
nsPoint mDefaultScrollbarPref; // persistent across doc loads
|
||||
PRUint32 mLoadType;
|
||||
PRBool mInitialPageLoad;
|
||||
PRBool mAllowPlugins;
|
||||
PRBool mAllowJavascript;
|
||||
PRBool mAllowMetaRedirects;
|
||||
|
@ -22,11 +22,11 @@ interface nsIContentViewer : nsISupports
|
||||
in nsIDeviceContextPtr aDeviceContext,
|
||||
[const] in nsRectRef aBounds);
|
||||
|
||||
void bindToDocument(in nsISupports aDoc, in string aCommand);
|
||||
|
||||
attribute nsISupports container;
|
||||
|
||||
void loadStart(in nsISupports aDoc);
|
||||
void loadComplete(in unsigned long aStatus);
|
||||
|
||||
void destroy();
|
||||
void stop();
|
||||
|
||||
|
@ -135,6 +135,12 @@ interface nsIDocShell : nsISupports
|
||||
*/
|
||||
void stopLoad();
|
||||
|
||||
/**
|
||||
* Reset state to a new content model within the current document and the document
|
||||
* viewer. Called by the document before initiating an out of band document.write().
|
||||
*/
|
||||
void prepareForNewContentModel();
|
||||
|
||||
/**
|
||||
* Presentation context for the currently loaded document. This may be null.
|
||||
*/
|
||||
|
@ -365,9 +365,9 @@ public:
|
||||
NS_IMETHOD Init(nsIWidget* aParentWidget,
|
||||
nsIDeviceContext* aDeviceContext,
|
||||
const nsRect& aBounds);
|
||||
NS_IMETHOD BindToDocument(nsISupports* aDoc, const char* aCommand);
|
||||
NS_IMETHOD SetContainer(nsISupports* aContainer);
|
||||
NS_IMETHOD GetContainer(nsISupports** aContainerResult);
|
||||
NS_IMETHOD LoadStart(nsISupports* aDoc);
|
||||
NS_IMETHOD LoadComplete(nsresult aStatus);
|
||||
NS_IMETHOD Destroy(void);
|
||||
NS_IMETHOD Stop(void);
|
||||
@ -506,6 +506,8 @@ private:
|
||||
PRUint32 aDelay);
|
||||
void StopPagePrintTimer();
|
||||
|
||||
void PrepareToStartLoad(void);
|
||||
|
||||
protected:
|
||||
// IMPORTANT: The ownership implicit in the following member
|
||||
// variables has been explicitly checked and set using nsCOMPtr
|
||||
@ -801,12 +803,15 @@ NS_NewDocumentViewer(nsIDocumentViewer** aResult)
|
||||
DocumentViewerImpl::DocumentViewerImpl()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
PrepareToStartLoad();
|
||||
}
|
||||
|
||||
void DocumentViewerImpl::PrepareToStartLoad() {
|
||||
mEnableRendering = PR_TRUE;
|
||||
mStopped = PR_FALSE;
|
||||
mLoaded = PR_FALSE;
|
||||
mPrt = nsnull;
|
||||
mIsPrinting = PR_FALSE;
|
||||
|
||||
}
|
||||
|
||||
DocumentViewerImpl::DocumentViewerImpl(nsIPresContext* aPresContext)
|
||||
@ -815,9 +820,7 @@ DocumentViewerImpl::DocumentViewerImpl(nsIPresContext* aPresContext)
|
||||
NS_INIT_ISUPPORTS();
|
||||
mHintCharsetSource = kCharsetUninitialized;
|
||||
mAllowPlugins = PR_TRUE;
|
||||
mEnableRendering = PR_TRUE;
|
||||
mPrt = nsnull;
|
||||
mIsPrinting = PR_FALSE;
|
||||
PrepareToStartLoad();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS5(DocumentViewerImpl,
|
||||
@ -864,18 +867,27 @@ DocumentViewerImpl::~DocumentViewerImpl()
|
||||
* This method is called by the Document Loader once a document has
|
||||
* been created for a particular data stream... The content viewer
|
||||
* must cache this document for later use when Init(...) is called.
|
||||
*
|
||||
* This method is also called when an out of band document.write() happens.
|
||||
* In that case, the document passed in is the same as the previous document.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
DocumentViewerImpl::BindToDocument(nsISupports *aDoc, const char *aCommand)
|
||||
DocumentViewerImpl::LoadStart(nsISupports *aDoc)
|
||||
{
|
||||
NS_PRECONDITION(!mDocument, "Viewer is already bound to a document!");
|
||||
|
||||
#ifdef NOISY_VIEWER
|
||||
printf("DocumentViewerImpl::BindToDocument\n");
|
||||
printf("DocumentViewerImpl::LoadStart\n");
|
||||
#endif
|
||||
|
||||
nsresult rv;
|
||||
mDocument = do_QueryInterface(aDoc,&rv);
|
||||
if (!mDocument) {
|
||||
mDocument = do_QueryInterface(aDoc,&rv);
|
||||
}
|
||||
else if (mDocument == aDoc) {
|
||||
// Reset the document viewer's state back to what it was
|
||||
// when the document load started.
|
||||
PrepareToStartLoad();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -3839,8 +3851,8 @@ DocumentViewerImpl::CreateDocumentViewerUsing(nsIPresContext* aPresContext,
|
||||
viewer->SetUAStyleSheet(mUAStyleSheet);
|
||||
|
||||
// Bind the new viewer to the old document
|
||||
nsresult rv = viewer->BindToDocument(mDocument, "create");/* XXX verb? */
|
||||
|
||||
nsresult rv = viewer->LoadStart(mDocument);
|
||||
|
||||
aResult = viewer;
|
||||
|
||||
return rv;
|
||||
|
@ -323,7 +323,7 @@ nsContentDLF::CreateInstanceForDocument(nsISupports* aContainer,
|
||||
docv->SetUAStyleSheet(nsContentDLF::GetUAStyleSheet());
|
||||
|
||||
// Bind the document to the Content Viewer
|
||||
rv = docv->BindToDocument(aDocument, aCommand);
|
||||
rv = docv->LoadStart(aDocument);
|
||||
*aDocViewerResult = docv;
|
||||
NS_IF_ADDREF(*aDocViewerResult);
|
||||
} while (PR_FALSE);
|
||||
@ -379,7 +379,7 @@ nsContentDLF::CreateDocument(const char* aCommand,
|
||||
break;
|
||||
|
||||
// Bind the document to the Content Viewer
|
||||
rv = docv->BindToDocument(doc, aCommand);
|
||||
rv = docv->LoadStart(doc);
|
||||
*aDocViewer = docv;
|
||||
NS_IF_ADDREF(*aDocViewer);
|
||||
} while (PR_FALSE);
|
||||
@ -470,7 +470,7 @@ nsContentDLF::CreateRDFDocument(const char* aCommand,
|
||||
/*
|
||||
* Bind the document to the Content Viewer...
|
||||
*/
|
||||
rv = docv->BindToDocument(doc, aCommand);
|
||||
rv = docv->LoadStart(doc);
|
||||
*aDocViewer = docv;
|
||||
NS_IF_ADDREF(*aDocViewer);
|
||||
}
|
||||
@ -495,7 +495,7 @@ nsContentDLF::CreateXULDocumentFromStream(nsIInputStream& aXULStream,
|
||||
if ( NS_FAILED(status = CreateRDFDocument(aExtraInfo, address_of(doc), address_of(docv))) )
|
||||
break;
|
||||
|
||||
if ( NS_FAILED(status = docv->BindToDocument(doc, aCommand)) )
|
||||
if ( NS_FAILED(status = docv->LoadStart(doc)) )
|
||||
break;
|
||||
|
||||
*aDocViewer = docv;
|
||||
|
@ -337,7 +337,7 @@ nsLayoutDLF::CreateInstanceForDocument(nsISupports* aContainer,
|
||||
docv->SetUAStyleSheet(nsLayoutDLF::GetUAStyleSheet());
|
||||
|
||||
// Bind the document to the Content Viewer
|
||||
rv = docv->BindToDocument(aDocument, aCommand);
|
||||
rv = docv->LoadStart(aDocument);
|
||||
*aDocViewerResult = docv;
|
||||
NS_IF_ADDREF(*aDocViewerResult);
|
||||
} while (PR_FALSE);
|
||||
@ -393,7 +393,7 @@ nsLayoutDLF::CreateDocument(const char* aCommand,
|
||||
break;
|
||||
|
||||
// Bind the document to the Content Viewer
|
||||
rv = docv->BindToDocument(doc, aCommand);
|
||||
rv = docv->LoadStart(doc);
|
||||
*aDocViewer = docv;
|
||||
NS_IF_ADDREF(*aDocViewer);
|
||||
} while (PR_FALSE);
|
||||
@ -484,7 +484,7 @@ nsLayoutDLF::CreateRDFDocument(const char* aCommand,
|
||||
/*
|
||||
* Bind the document to the Content Viewer...
|
||||
*/
|
||||
rv = docv->BindToDocument(doc, aCommand);
|
||||
rv = docv->LoadStart(doc);
|
||||
*aDocViewer = docv;
|
||||
NS_IF_ADDREF(*aDocViewer);
|
||||
}
|
||||
@ -509,7 +509,7 @@ nsLayoutDLF::CreateXULDocumentFromStream(nsIInputStream& aXULStream,
|
||||
if ( NS_FAILED(status = CreateRDFDocument(aExtraInfo, address_of(doc), address_of(docv))) )
|
||||
break;
|
||||
|
||||
if ( NS_FAILED(status = docv->BindToDocument(doc, aCommand)) )
|
||||
if ( NS_FAILED(status = docv->LoadStart(doc)) )
|
||||
break;
|
||||
|
||||
*aDocViewer = docv;
|
||||
|
@ -158,9 +158,9 @@ public:
|
||||
NS_IMETHOD Init(nsIWidget* aParentWidget,
|
||||
nsIDeviceContext* aDeviceContext,
|
||||
const nsRect& aBounds);
|
||||
NS_IMETHOD BindToDocument(nsISupports* aDoc, const char* aCommand);
|
||||
NS_IMETHOD SetContainer(nsISupports* aContainer);
|
||||
NS_IMETHOD GetContainer(nsISupports** aContainerResult);
|
||||
NS_IMETHOD LoadStart(nsISupports* aDoc);
|
||||
NS_IMETHOD LoadComplete(nsresult aStatus);
|
||||
NS_IMETHOD Destroy(void);
|
||||
NS_IMETHOD Stop(void);
|
||||
@ -288,21 +288,6 @@ PluginViewerImpl::~PluginViewerImpl()
|
||||
NS_IF_RELEASE(mChannel);
|
||||
}
|
||||
|
||||
/*
|
||||
* This method is called by the Document Loader once a document has
|
||||
* been created for a particular data stream... The content viewer
|
||||
* must cache this document for later use when Init(...) is called.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
PluginViewerImpl::BindToDocument(nsISupports *aDoc, const char *aCommand)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
printf("PluginViewerImpl::BindToDocument\n");
|
||||
#endif
|
||||
return aDoc->QueryInterface(kIDocumentIID, (void**)&mDocument);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PluginViewerImpl::SetContainer(nsISupports* aContainer)
|
||||
{
|
||||
@ -427,6 +412,21 @@ PluginViewerImpl::Stop(void)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This method is called by the Document Loader once a document has
|
||||
* been created for a particular data stream... The content viewer
|
||||
* must cache this document for later use when Init(...) is called.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
PluginViewerImpl::LoadStart(nsISupports *aDoc)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
printf("PluginViewerImpl::LoadStart\n");
|
||||
#endif
|
||||
return aDoc->QueryInterface(kIDocumentIID, (void**)&mDocument);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
PluginViewerImpl::LoadComplete(nsresult aStatus)
|
||||
{
|
||||
|
@ -158,9 +158,9 @@ public:
|
||||
NS_IMETHOD Init(nsIWidget* aParentWidget,
|
||||
nsIDeviceContext* aDeviceContext,
|
||||
const nsRect& aBounds);
|
||||
NS_IMETHOD BindToDocument(nsISupports* aDoc, const char* aCommand);
|
||||
NS_IMETHOD SetContainer(nsISupports* aContainer);
|
||||
NS_IMETHOD GetContainer(nsISupports** aContainerResult);
|
||||
NS_IMETHOD LoadStart(nsISupports* aDoc);
|
||||
NS_IMETHOD LoadComplete(nsresult aStatus);
|
||||
NS_IMETHOD Destroy(void);
|
||||
NS_IMETHOD Stop(void);
|
||||
@ -288,21 +288,6 @@ PluginViewerImpl::~PluginViewerImpl()
|
||||
NS_IF_RELEASE(mChannel);
|
||||
}
|
||||
|
||||
/*
|
||||
* This method is called by the Document Loader once a document has
|
||||
* been created for a particular data stream... The content viewer
|
||||
* must cache this document for later use when Init(...) is called.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
PluginViewerImpl::BindToDocument(nsISupports *aDoc, const char *aCommand)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
printf("PluginViewerImpl::BindToDocument\n");
|
||||
#endif
|
||||
return aDoc->QueryInterface(kIDocumentIID, (void**)&mDocument);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PluginViewerImpl::SetContainer(nsISupports* aContainer)
|
||||
{
|
||||
@ -427,6 +412,21 @@ PluginViewerImpl::Stop(void)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This method is called by the Document Loader once a document has
|
||||
* been created for a particular data stream... The content viewer
|
||||
* must cache this document for later use when Init(...) is called.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
PluginViewerImpl::LoadStart(nsISupports *aDoc)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
printf("PluginViewerImpl::LoadStart\n");
|
||||
#endif
|
||||
return aDoc->QueryInterface(kIDocumentIID, (void**)&mDocument);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
PluginViewerImpl::LoadComplete(nsresult aStatus)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user