diff --git a/mozilla/xpfe/appshell/src/nsContentTreeOwner.cpp b/mozilla/xpfe/appshell/src/nsContentTreeOwner.cpp index 9746a10228e..c35cb32f6b1 100644 --- a/mozilla/xpfe/appshell/src/nsContentTreeOwner.cpp +++ b/mozilla/xpfe/appshell/src/nsContentTreeOwner.cpp @@ -193,32 +193,30 @@ NS_IMETHODIMP nsContentTreeOwner::GetNewWindow(PRInt32 aChromeFlags, NS_IMETHODIMP nsContentTreeOwner::SetJSStatus(const PRUnichar* aStatus) { - nsAutoString status(aStatus); - - if(!status.Length()) - status = mDefaultStatus; - - nsAutoString statusName("status"); - NS_ENSURE_SUCCESS(mXULWindow->NotifyObservers(statusName.GetUnicode(), - status.GetUnicode()), NS_ERROR_FAILURE); - + nsCOMPtr window; + mXULWindow->GetDOMElementById("WebBrowserChrome", getter_AddRefs(window)); + if(window) + window->SetAttribute("status", aStatus); return NS_OK; } NS_IMETHODIMP nsContentTreeOwner::SetJSDefaultStatus(const PRUnichar* aStatus) { - mDefaultStatus = aStatus; - - nsAutoString statusName("defaultStatus"); - NS_ENSURE_SUCCESS(mXULWindow->NotifyObservers(statusName.GetUnicode(), - aStatus), NS_ERROR_FAILURE); - + nsCOMPtr window; + mXULWindow->GetDOMElementById("WebBrowserChrome", getter_AddRefs(window)); + if(window) + window->SetAttribute("defaultStatus", aStatus); return NS_OK; } NS_IMETHODIMP nsContentTreeOwner::SetOverLink(const PRUnichar* aLink) { - return SetJSStatus(aLink); + nsCOMPtr window; + mXULWindow->GetDOMElementById("WebBrowserChrome", getter_AddRefs(window)); + if(window) + window->SetAttribute("overLink", aLink); + + return NS_OK; } NS_IMETHODIMP nsContentTreeOwner::SetWebBrowser(nsIWebBrowser* aWebBrowser) @@ -441,7 +439,7 @@ NS_IMETHODIMP nsContentTreeOwner::ApplyChromeMask() return NS_OK; // We'll do this later when chrome is loaded nsCOMPtr window; - mXULWindow->GetDOMElementFromDocShell(mXULWindow->mDocShell, getter_AddRefs(window)); + mXULWindow->GetWindowDOMElement(getter_AddRefs(window)); NS_ENSURE_TRUE(window, NS_ERROR_FAILURE); mXULWindow->mWindow->ShowMenuBar(mChromeMask & @@ -496,8 +494,7 @@ void nsContentTreeOwner::XULWindow(nsXULWindow* aXULWindow) { // Get the window title modifiers nsCOMPtr docShellElement; - mXULWindow->GetDOMElementFromDocShell(mXULWindow->mDocShell, - getter_AddRefs(docShellElement)); + mXULWindow->GetWindowDOMElement(getter_AddRefs(docShellElement)); nsAutoString contentTitleSetting; diff --git a/mozilla/xpfe/appshell/src/nsContentTreeOwner.h b/mozilla/xpfe/appshell/src/nsContentTreeOwner.h index 4faf73409b3..2e2a37f8540 100644 --- a/mozilla/xpfe/appshell/src/nsContentTreeOwner.h +++ b/mozilla/xpfe/appshell/src/nsContentTreeOwner.h @@ -64,7 +64,6 @@ protected: PRBool mPrimary; PRBool mContentTitleSetting; PRUint32 mChromeMask; - nsString mDefaultStatus; nsString mWindowTitleModifier; nsString mTitleSeparator; nsString mTitlePreface; diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index de66faf2eaf..7a4e161f41f 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1285,8 +1285,6 @@ nsWebShellWindow::OnEndDocumentLoad(nsIDocumentLoader* loader, } #endif - ExecuteStartupCode(); - #ifdef USE_NATIVE_MENUS /////////////////////////////// // Find the Menubar DOM and Load the menus, hooking them up to the loaded commands @@ -1416,39 +1414,6 @@ nsCOMPtr nsWebShellWindow::GetNamedDOMDoc(const nsString & aWebS //---------------------------------------- -/** - * Get nsIDOMNode corresponding to a given webshell - * @param aShell the given webshell - * @return the corresponding DOM element, null if for some reason there is none - */ -nsCOMPtr -nsWebShellWindow::GetDOMNodeFromWebShell(nsIWebShell *aShell) -{ - nsCOMPtr docShell(do_QueryInterface(aShell)); - - nsCOMPtr element; - GetDOMElementFromDocShell(docShell, getter_AddRefs(element)); - - nsCOMPtr node(do_QueryInterface(element)); - - return node; -} - -/** - * XXX Hack for XUL Window callbacks. MUST GO AWAY!!!! - */ -void nsWebShellWindow::ExecuteStartupCode() -{ - nsCOMPtr webshellNode = GetDOMNodeFromWebShell(mWebShell); - nsCOMPtr webshellElement; - - if (webshellNode) - webshellElement = do_QueryInterface(webshellNode); - - // Execute the string in the onLoad attribute of the webshellElement. - nsString startupCode; -} - /* copy the window's size and position to the window tag */ void nsWebShellWindow::StoreBoundsToXUL(PRBool aPosition, PRBool aSize, PRBool aSizeMode) { diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.h b/mozilla/xpfe/appshell/src/nsWebShellWindow.h index a9f91299bfc..9414ab0263f 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.h +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.h @@ -218,9 +218,6 @@ protected: nsIDOMNode * contextMenuTest; - nsString mStatus; - nsString mDefaultStatus; - nsCOMPtr mSPTimer; PRBool mSPTimerSize, mSPTimerPosition; PRLock * mSPTimerLock; diff --git a/mozilla/xpfe/appshell/src/nsXULWindow.cpp b/mozilla/xpfe/appshell/src/nsXULWindow.cpp index 53156be224a..54bb8aa1efe 100644 --- a/mozilla/xpfe/appshell/src/nsXULWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsXULWindow.cpp @@ -38,6 +38,7 @@ #include "nsIDOMDocument.h" #include "nsIDOMElement.h" #include "nsIDOMWindow.h" +#include "nsIDOMXULDocument.h" #include "nsIInterfaceRequestor.h" #include "nsIIOService.h" #include "nsIJSContextStack.h" @@ -182,7 +183,7 @@ NS_IMETHODIMP nsXULWindow::SetPersistence(PRBool aPersistX, PRBool aPersistY, { nsCOMPtr docShellElement; - GetDOMElementFromDocShell(mDocShell, getter_AddRefs(docShellElement)); + GetWindowDOMElement(getter_AddRefs(docShellElement)); if(!docShellElement) return NS_ERROR_FAILURE; @@ -261,7 +262,7 @@ NS_IMETHODIMP nsXULWindow::GetPersistence(PRBool* aPersistX, PRBool* aPersistY, PRBool* aPersistSizeMode) { nsCOMPtr docShellElement; - GetDOMElementFromDocShell(mDocShell, getter_AddRefs(docShellElement)); + GetWindowDOMElement(getter_AddRefs(docShellElement)); if(!docShellElement) return NS_ERROR_FAILURE; @@ -695,7 +696,7 @@ NS_IMETHODIMP nsXULWindow::LoadPositionAndSizeFromXUL(PRBool aPosition, to do that. */ nsCOMPtr docShellElement; - GetDOMElementFromDocShell(mDocShell, getter_AddRefs(docShellElement)); + GetWindowDOMElement(getter_AddRefs(docShellElement)); NS_ENSURE_TRUE(docShellElement, NS_ERROR_FAILURE); PRInt32 curX = 0; @@ -766,7 +767,7 @@ NS_IMETHODIMP nsXULWindow::LoadPositionAndSizeFromXUL(PRBool aPosition, NS_IMETHODIMP nsXULWindow::LoadTitleFromXUL() { nsCOMPtr docShellElement; - GetDOMElementFromDocShell(mDocShell, getter_AddRefs(docShellElement)); + GetWindowDOMElement(getter_AddRefs(docShellElement)); NS_ENSURE_TRUE(docShellElement, NS_ERROR_FAILURE); nsAutoString windowTitle; @@ -788,7 +789,7 @@ NS_IMETHODIMP nsXULWindow::PersistPositionAndSize(PRBool aPosition, PRBool aSize return NS_ERROR_FAILURE; nsCOMPtr docShellElement; - GetDOMElementFromDocShell(mDocShell, getter_AddRefs(docShellElement)); + GetWindowDOMElement(getter_AddRefs(docShellElement)); if(!docShellElement) return NS_ERROR_FAILURE; @@ -857,17 +858,16 @@ NS_IMETHODIMP nsXULWindow::PersistPositionAndSize(PRBool aPosition, PRBool aSize return NS_OK; } -NS_IMETHODIMP nsXULWindow::GetDOMElementFromDocShell(nsIDocShell* aDocShell, - nsIDOMElement** aDOMElement) +NS_IMETHODIMP nsXULWindow::GetWindowDOMElement(nsIDOMElement** aDOMElement) { - NS_ENSURE_ARG(aDocShell); + NS_ENSURE_STATE(mDocShell); NS_ENSURE_ARG_POINTER(aDOMElement); *aDOMElement = nsnull; nsCOMPtr cv; - aDocShell->GetContentViewer(getter_AddRefs(cv)); + mDocShell->GetContentViewer(getter_AddRefs(cv)); if(!cv) return NS_ERROR_FAILURE; @@ -888,6 +888,34 @@ NS_IMETHODIMP nsXULWindow::GetDOMElementFromDocShell(nsIDocShell* aDocShell, return NS_OK; } +NS_IMETHODIMP nsXULWindow::GetDOMElementById(char* aID, nsIDOMElement** aDOMElement) +{ + NS_ENSURE_STATE(mDocShell); + NS_ENSURE_ARG_POINTER(aDOMElement); + + *aDOMElement = nsnull; + + nsCOMPtr cv; + + mDocShell->GetContentViewer(getter_AddRefs(cv)); + if(!cv) + return NS_ERROR_FAILURE; + + nsCOMPtr docv(do_QueryInterface(cv)); + if(!docv) + return NS_ERROR_FAILURE; + + nsCOMPtr doc; + docv->GetDocument(*getter_AddRefs(doc)); + nsCOMPtr domdoc(do_QueryInterface(doc)); + if(!domdoc) + return NS_ERROR_FAILURE; + + NS_ENSURE_SUCCESS(domdoc->GetElementById(aID, aDOMElement), NS_ERROR_FAILURE); + + return NS_OK; +} + NS_IMETHODIMP nsXULWindow::ContentShellAdded(nsIDocShellTreeItem* aContentShell, PRBool aPrimary, const PRUnichar* aID) { diff --git a/mozilla/xpfe/appshell/src/nsXULWindow.h b/mozilla/xpfe/appshell/src/nsXULWindow.h index d91d864c16f..821a4740c8c 100644 --- a/mozilla/xpfe/appshell/src/nsXULWindow.h +++ b/mozilla/xpfe/appshell/src/nsXULWindow.h @@ -71,8 +71,8 @@ protected: NS_IMETHOD LoadTitleFromXUL(); NS_IMETHOD PersistPositionAndSize(PRBool aPosition, PRBool aSize, PRBool aSizeMode); - NS_IMETHOD GetDOMElementFromDocShell(nsIDocShell* aDocShell, - nsIDOMElement** aDOMElement); + NS_IMETHOD GetWindowDOMElement(nsIDOMElement** aDOMElement); + NS_IMETHOD GetDOMElementById(char* aID, nsIDOMElement** aDOMElement); NS_IMETHOD ContentShellAdded(nsIDocShellTreeItem* aContentShell, PRBool aPrimary, const PRUnichar* aID); NS_IMETHOD SizeShellTo(nsIDocShellTreeItem* aShellItem, PRInt32 aCX,