diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index 345b5c827da..2398089874b 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -930,28 +930,29 @@ nsCOMPtr nsWebShellWindow::GetNamedDOMDoc(const nsString & aWebS PRInt32 nsWebShellWindow::GetDocHeight(nsIDocument * aDoc) { nsIPresShell * presShell = aDoc->GetShellAt(0); - if (presShell) { - nsCOMPtr presContext; - presShell->GetPresContext(getter_AddRefs(presContext)); - if (presContext) { - nsRect rect; - presContext->GetVisibleArea(rect); - nsIFrame * rootFrame; - nsSize size; - presShell->GetRootFrame(&rootFrame); - if (rootFrame) { - rootFrame->GetSize(size); - float t2p; - presContext->GetTwipsToPixels(&t2p); - printf("Doc size %d,%d\n", PRInt32((float)size.width*t2p), - PRInt32((float)size.height*t2p)); - //return rect.height; - return PRInt32((float)rect.height*t2p); - //return PRInt32((float)size.height*presContext->GetTwipsToPixels()); - } + if (!presShell) + return 0; + + nsCOMPtr presContext; + presShell->GetPresContext(getter_AddRefs(presContext)); + if (presContext) { + nsRect rect; + presContext->GetVisibleArea(rect); + nsIFrame * rootFrame; + nsSize size; + presShell->GetRootFrame(&rootFrame); + if (rootFrame) { + rootFrame->GetSize(size); + float t2p; + presContext->GetTwipsToPixels(&t2p); + printf("Doc size %d,%d\n", PRInt32((float)size.width*t2p), + PRInt32((float)size.height*t2p)); + //return rect.height; + return PRInt32((float)rect.height*t2p); + //return PRInt32((float)size.height*presContext->GetTwipsToPixels()); } - NS_RELEASE(presShell); } + NS_RELEASE(presShell); return 0; } @@ -989,14 +990,15 @@ NS_IMETHODIMP nsWebShellWindow::OnConnectionsComplete() if (menubarDOMDoc) LoadMenus(menubarDOMDoc, mWindow); + SetSizeFromXUL(); + SetTitleFromXUL(); - // Calculate size of windows #if 0 nsCOMPtr toolbarDOMDoc(GetNamedDOMDoc(nsAutoString("browser.toolbar"))); nsCOMPtr contentDOMDoc(GetNamedDOMDoc(nsAutoString("browser.webwindow"))); - nsCOMPtr contentDoc(contentDOMDoc); - nsCOMPtr statusDoc(statusDOMDoc); - nsCOMPtr toolbarDoc(toolbarDOMDoc); + nsCOMPtr contentDoc(do_QueryInterface(contentDOMDoc)); + nsCOMPtr statusDoc(do_QueryInterface(statusDOMDoc)); + nsCOMPtr toolbarDoc(do_QueryInterface(toolbarDOMDoc)); nsIWebShell* statusWebShell = nsnull; mWebShell->FindChildWithName(nsAutoString("browser.status"), statusWebShell); @@ -1109,7 +1111,7 @@ void nsWebShellWindow::ExecuteStartupCode() // Execute the string in the onLoad attribute of the webshellElement. nsString startupCode; - if (webshellElement && NS_SUCCEEDED(webshellElement->GetAttribute("onload", startupCode))) + if (webshellElement && NS_SUCCEEDED(webshellElement->GetAttribute("onload", startupCode))) ExecuteJavaScriptString(startupCode); if (mCallbacks) @@ -1118,6 +1120,25 @@ void nsWebShellWindow::ExecuteStartupCode() } +void nsWebShellWindow::SetSizeFromXUL() +{ +} // SetSizeFromXUL + + +void nsWebShellWindow::SetTitleFromXUL() +{ + nsCOMPtr webshellNode = GetDOMNodeFromWebShell(mWebShell); + nsIWidget *windowWidget = GetWidget(); + nsCOMPtr webshellElement; + nsString windowTitle; + + if (webshellNode) + webshellElement = do_QueryInterface(webshellNode); + if (webshellElement && windowWidget && + NS_SUCCEEDED(webshellElement->GetAttribute("title", windowTitle))) + windowWidget->SetTitle(windowTitle); +} // SetTitleFromXUL + //---------------------------------------------------------------- //-- nsIDocumentObserver diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.h b/mozilla/xpfe/appshell/src/nsWebShellWindow.h index 8613d520a27..1969b42e014 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.h +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.h @@ -181,6 +181,8 @@ protected: nsCOMPtr GetDOMNodeFromWebShell(nsIWebShell *aShell); void ExecuteStartupCode(); + void SetSizeFromXUL(); + void SetTitleFromXUL(); virtual ~nsWebShellWindow();