From 8bd76da7e125f26bb6c81fe38142c82abc4e1428 Mon Sep 17 00:00:00 2001 From: Neil Deakin Date: Fri, 14 Oct 2011 09:06:41 -0400 Subject: [PATCH] Bug 694225, nsWebShellWindow::GetNamedDOMDoc can be removed and simplified, r-bsmedberg --- xpfe/appshell/src/nsWebShellWindow.cpp | 41 +++++--------------------- xpfe/appshell/src/nsWebShellWindow.h | 2 -- 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index a68312cfa42a..fea3afa99bd0 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -581,9 +581,13 @@ nsWebShellWindow::OnStateChange(nsIWebProgress *aProgress, /////////////////////////////// // Find the Menubar DOM and Load the menus, hooking them up to the loaded commands /////////////////////////////// - nsCOMPtr menubarDOMDoc(GetNamedDOMDoc(NS_LITERAL_STRING("this"))); // XXX "this" is a small kludge for code reused - if (menubarDOMDoc) - LoadNativeMenus(menubarDOMDoc, mWindow); + nsCOMPtr cv; + mDocShell->GetContentViewer(getter_AddRefs(cv)); + if (cv) { + nsCOMPtr menubarDOMDoc(do_QueryInterface(cv->GetDocument())); + if (menubarDOMDoc) + LoadNativeMenus(menubarDOMDoc, mWindow); + } #endif // USE_NATIVE_MENUS OnChromeLoaded(); @@ -621,37 +625,6 @@ nsWebShellWindow::OnSecurityChange(nsIWebProgress *aWebProgress, } -//---------------------------------------- -nsCOMPtr nsWebShellWindow::GetNamedDOMDoc(const nsAString & aDocShellName) -{ - nsCOMPtr domDoc; // result == nsnull; - - // first get the toolbar child docShell - nsCOMPtr childDocShell; - if (aDocShellName.EqualsLiteral("this")) { // XXX small kludge for code reused - childDocShell = mDocShell; - } else { - nsCOMPtr docShellAsItem; - nsCOMPtr docShellAsNode(do_QueryInterface(mDocShell)); - docShellAsNode->FindChildWithName(PromiseFlatString(aDocShellName).get(), - PR_TRUE, PR_FALSE, nsnull, nsnull, getter_AddRefs(docShellAsItem)); - childDocShell = do_QueryInterface(docShellAsItem); - if (!childDocShell) - return domDoc; - } - - nsCOMPtr cv; - childDocShell->GetContentViewer(getter_AddRefs(cv)); - if (!cv) - return domDoc; - - nsIDocument* doc = cv->GetDocument(); - if (doc) - return nsCOMPtr(do_QueryInterface(doc)); - - return domDoc; -} // nsWebShellWindow::GetNamedDOMDoc - //---------------------------------------- // if the main document URL specified URLs for any content areas, start them loading diff --git a/xpfe/appshell/src/nsWebShellWindow.h b/xpfe/appshell/src/nsWebShellWindow.h index b3d65478fe5e..4d68f3b11d26 100644 --- a/xpfe/appshell/src/nsWebShellWindow.h +++ b/xpfe/appshell/src/nsWebShellWindow.h @@ -80,8 +80,6 @@ protected: virtual ~nsWebShellWindow(); - nsCOMPtr GetNamedDOMDoc(const nsAString & aWebShellName); - void LoadContentAreas(); bool ExecuteCloseHandler(); void ConstrainToOpenerScreen(PRInt32* aX, PRInt32* aY);