DocShell cleanup. Removed the implementation of the unused nsIDocSHell::SetDocument() method and moved the implementation responsibility to the nsIContentViewer
git-svn-id: svn://10.0.0.236/trunk@72889 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -280,9 +280,6 @@ public:
|
||||
NS_IMETHOD GetPositionAndSize(PRInt32* x, PRInt32* y, PRInt32* cx,
|
||||
PRInt32* cy);
|
||||
|
||||
// nsIDocShell
|
||||
NS_IMETHOD SetDocument(nsIDOMDocument *aDOMDoc, nsIDOMElement *aRootNode);
|
||||
|
||||
// nsWebShell
|
||||
nsIEventQueue* GetEventQueue(void);
|
||||
void HandleLinkClickEvent(nsIContent *aContent,
|
||||
@@ -1617,119 +1614,6 @@ NS_IMETHODIMP nsWebShell::GetPositionAndSize(PRInt32* x, PRInt32* y,
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// nsWebShell::nsIDocShell
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc,
|
||||
nsIDOMElement *aRootNode)
|
||||
{
|
||||
// The tricky part is bypassing the normal load process and just putting a document into
|
||||
// the webshell. This is particularly nasty, since webshells don't normally even know
|
||||
// about their documents
|
||||
|
||||
// (1) Create a document viewer
|
||||
nsCOMPtr<nsIContentViewer> documentViewer;
|
||||
nsCOMPtr<nsIDocumentLoaderFactory> docFactory;
|
||||
static NS_DEFINE_CID(kLayoutDocumentLoaderFactoryCID, NS_LAYOUT_DOCUMENT_LOADER_FACTORY_CID);
|
||||
NS_ENSURE_SUCCESS(nsComponentManager::CreateInstance(kLayoutDocumentLoaderFactoryCID, nsnull,
|
||||
NS_GET_IID(nsIDocumentLoaderFactory),
|
||||
(void**)getter_AddRefs(docFactory)),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDOMDoc);
|
||||
if (!doc) { return NS_ERROR_NULL_POINTER; }
|
||||
|
||||
NS_ENSURE_SUCCESS(docFactory->CreateInstanceForDocument(NS_STATIC_CAST(nsIContentViewerContainer*, (nsIWebShell*)this),
|
||||
doc,
|
||||
"view",
|
||||
getter_AddRefs(documentViewer)),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
// (2) Feed the webshell to the content viewer
|
||||
NS_ENSURE_SUCCESS(documentViewer->SetContainer((nsIWebShell*)this), NS_ERROR_FAILURE);
|
||||
|
||||
// (3) Tell the content viewer container to embed the content viewer.
|
||||
// (This step causes everything to be set up for an initial flow.)
|
||||
NS_ENSURE_SUCCESS(SetupNewViewer(documentViewer), NS_ERROR_FAILURE);
|
||||
|
||||
// XXX: It would be great to get rid of this dummy channel!
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_ENSURE_SUCCESS(NS_NewURI(getter_AddRefs(uri), NS_ConvertASCIItoUCS2("about:blank")), NS_ERROR_FAILURE);
|
||||
if (!uri) { return NS_ERROR_OUT_OF_MEMORY; }
|
||||
|
||||
nsCOMPtr<nsIChannel> dummyChannel;
|
||||
NS_ENSURE_SUCCESS(NS_OpenURI(getter_AddRefs(dummyChannel), uri, nsnull), NS_ERROR_FAILURE);
|
||||
|
||||
// (4) fire start document load notification
|
||||
nsCOMPtr<nsIStreamListener> outStreamListener; // a valid pointer is required for the returned stream listener
|
||||
// XXX: warning: magic cookie! should get string "view delayedContentLoad"
|
||||
// from somewhere, maybe nsIHTMLDocument?
|
||||
NS_ENSURE_SUCCESS(doc->StartDocumentLoad("view delayedContentLoad",
|
||||
dummyChannel,
|
||||
nsnull,
|
||||
NS_STATIC_CAST(nsIContentViewerContainer*, (nsIWebShell*)this),
|
||||
getter_AddRefs(outStreamListener),
|
||||
PR_TRUE),
|
||||
NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(OnStartDocumentLoad(mDocLoader, uri, "load"), NS_ERROR_FAILURE);
|
||||
|
||||
// (5) hook up the document and its content
|
||||
nsCOMPtr<nsIContent> rootContent = do_QueryInterface(aRootNode);
|
||||
if (!doc) { return NS_ERROR_OUT_OF_MEMORY; }
|
||||
NS_ENSURE_SUCCESS(rootContent->SetDocument(doc, PR_FALSE, PR_TRUE), NS_ERROR_FAILURE);
|
||||
doc->SetRootContent(rootContent);
|
||||
rootContent->SetDocument(doc, PR_TRUE, PR_TRUE);
|
||||
|
||||
// (6) reflow the document
|
||||
PRInt32 i;
|
||||
PRInt32 ns = doc->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell(dont_AddRef(doc->GetShellAt(i)));
|
||||
if (shell)
|
||||
{
|
||||
// Make shell an observer for next time
|
||||
NS_ENSURE_SUCCESS(shell->BeginObservingDocument(), NS_ERROR_FAILURE);
|
||||
|
||||
// Resize-reflow this time
|
||||
nsCOMPtr<nsIDocumentViewer> docViewer = do_QueryInterface(documentViewer);
|
||||
if (!docViewer) { return NS_ERROR_OUT_OF_MEMORY; }
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
NS_ENSURE_SUCCESS(docViewer->GetPresContext(*(getter_AddRefs(presContext))), NS_ERROR_FAILURE);
|
||||
if (!presContext) { return NS_ERROR_OUT_OF_MEMORY; }
|
||||
float p2t;
|
||||
presContext->GetScaledPixelsToTwips(&p2t);
|
||||
|
||||
nsRect r;
|
||||
GetPositionAndSize(&r.x, &r.y, &r.width, &r.height);
|
||||
NS_ENSURE_SUCCESS(shell->InitialReflow(NSToCoordRound(r.width * p2t), NSToCoordRound(r.height * p2t)), NS_ERROR_FAILURE);
|
||||
|
||||
// Now trigger a refresh
|
||||
nsCOMPtr<nsIViewManager> vm;
|
||||
NS_ENSURE_SUCCESS(shell->GetViewManager(getter_AddRefs(vm)), NS_ERROR_FAILURE);
|
||||
if (vm)
|
||||
{
|
||||
PRBool enabled;
|
||||
documentViewer->GetEnableRendering(&enabled);
|
||||
if (enabled) {
|
||||
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(vm->SetWindowDimensions(NSToCoordRound(r.width * p2t),
|
||||
NSToCoordRound(r.height * p2t)),
|
||||
NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// (7) fire end document load notification
|
||||
nsresult rv = NS_OK;
|
||||
NS_ENSURE_SUCCESS(OnEndDocumentLoad(mDocLoader, dummyChannel, rv), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); // test the resulting out-param separately
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Factory code for creating nsWebShell's
|
||||
|
||||
Reference in New Issue
Block a user