Open and embed correctly a printpreview presentation. r=kmcclusk. Viewer only.

This commit is contained in:
dcone%netscape.com 2001-03-20 14:40:59 +00:00
Родитель f8fd717aad
Коммит bf0edb0501
1 изменённых файлов: 31 добавлений и 23 удалений

Просмотреть файл

@ -1488,40 +1488,44 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
mAppShell = aAppShell; mAppShell = aAppShell;
NS_IF_ADDREF(mAppShell); NS_IF_ADDREF(mAppShell);
mAllowPlugins = aAllowPlugins; mAllowPlugins = aAllowPlugins;
// Create top level window // Create top level window
nsresult rv = nsComponentManager::CreateInstance(kWindowCID, nsnull, nsresult rv = nsComponentManager::CreateInstance(kWindowCID,
kIWidgetIID, nsnull,
getter_AddRefs(mWindow));
kIWidgetIID,
getter_AddRefs(mWindow));
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
} }
nsWidgetInitData initData;
initData.mWindowType = eWindowType_toplevel;
initData.mBorderStyle = eBorderStyle_default;
nsRect r(0, 0, aBounds.width, aBounds.height); nsRect r(0, 0, aBounds.width, aBounds.height);
mWindow->Create((nsIWidget*)NULL, r, HandleBrowserEvent, mWindow->Create((nsIWidget*)NULL, r, HandleBrowserEvent,
nsnull, aAppShell);
nsnull, aAppShell, nsnull, &initData);
mWindow->GetClientBounds(r); mWindow->GetClientBounds(r);
// Create web shell // Create web shell
rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
NS_GET_IID(nsIDocShell), NS_ENSURE_TRUE(mWebBrowser, NS_ERROR_FAILURE);
getter_AddRefs(mDocShell));
if (NS_OK != rv) {
return rv;
}
nsCOMPtr<nsIDocumentLoader> docLoader;
r.x = r.y = 0; r.x = r.y = 0;
//nsRect ws = r;
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
mDocShell->SetAllowPlugins(aAllowPlugins);
nsCOMPtr<nsIBaseWindow> webBrowserWin(do_QueryInterface(mWebBrowser)); nsCOMPtr<nsIBaseWindow> webBrowserWin(do_QueryInterface(mWebBrowser));
rv = webBrowserWin->InitWindow(mWindow->GetNativeData(NS_NATIVE_WIDGET), nsnull, r.x, r.y, r.width, r.height); rv = webBrowserWin->InitWindow(mWindow->GetNativeData(NS_NATIVE_WIDGET),
nsnull, r.x, r.y, r.width, r.height);
NS_ENSURE_SUCCESS(EnsureWebBrowserChrome(), NS_ERROR_FAILURE);
mWebBrowser->SetContainerWindow(mWebBrowserChrome);
webBrowserWin->Create(); webBrowserWin->Create();
mDocShell = do_GetInterface(mWebBrowser);
mDocShell->SetAllowPlugins(aAllowPlugins);
nsCOMPtr<nsIDocumentLoader> docLoader;
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
webShell->SetContainer((nsIWebShellContainer*) this); webShell->SetContainer((nsIWebShellContainer*) this);
webShell->GetDocumentLoader(*getter_AddRefs(docLoader)); webShell->GetDocumentLoader(*getter_AddRefs(docLoader));
if (docLoader) { if (docLoader) {
docLoader->AddObserver(this); docLoader->AddObserver(this);
} }
webBrowserWin->SetVisibility(PR_TRUE);
if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) { if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) {
rv = CreateMenuBar(r.width); rv = CreateMenuBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
@ -1530,31 +1534,35 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
mWindow->GetClientBounds(r); mWindow->GetClientBounds(r);
r.x = r.y = 0; r.x = r.y = 0;
} }
if (nsIWebBrowserChrome::CHROME_TOOLBAR & aChromeMask) { if (nsIWebBrowserChrome::CHROME_TOOLBAR & aChromeMask) {
rv = CreateToolBar(r.width); rv = CreateToolBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
} }
} }
if (nsIWebBrowserChrome::CHROME_STATUSBAR & aChromeMask)
if (nsIWebBrowserChrome::CHROME_STATUSBAR & aChromeMask) { {
rv = CreateStatusBar(r.width); rv = CreateStatusBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
} }
} }
// Give the embedding app a chance to do platforms-specific window setup // Give the embedding app a chance to do platforms-specific window setup
InitNativeWindow(); InitNativeWindow();
// Now lay it all out // Now lay it all out
Layout(r.width, r.height); Layout(r.width, r.height);
// Create a document viewer and bind it to the webshell // Create a document viewer and bind it to the webshell
nsIDocumentViewer* docv; nsIDocumentViewer* docv;
aDocumentViewer->CreateDocumentViewerUsing(aPresContext, docv); aDocumentViewer->CreateDocumentViewerUsing(aPresContext, docv);
docv->SetContainer(mWebBrowser);
webShell->Embed(docv, "duh", nsnull); webShell->Embed(docv, "duh", nsnull);
webBrowserWin->SetVisibility(PR_TRUE); webBrowserWin->SetVisibility(PR_TRUE);
NS_RELEASE(docv); NS_RELEASE(docv);