From efff4e16935796aec22bc220ecaa764d7ea69d80 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Wed, 9 Jan 2008 22:50:29 +0000 Subject: [PATCH] Bug 322074. Check more carefully whether a transparent document is actually a top-level window. r+sr=bzbarsky git-svn-id: svn://10.0.0.236/trunk@242770 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsContainerFrame.cpp | 38 +++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/mozilla/layout/generic/nsContainerFrame.cpp b/mozilla/layout/generic/nsContainerFrame.cpp index 041e5f9dd4f..23347a084c4 100644 --- a/mozilla/layout/generic/nsContainerFrame.cpp +++ b/mozilla/layout/generic/nsContainerFrame.cpp @@ -69,6 +69,7 @@ #include "nsContentErrors.h" #include "nsIEventStateManager.h" #include "nsListControlFrame.h" +#include "nsIBaseWindow.h" #ifdef NS_DEBUG #undef NOISY @@ -448,6 +449,26 @@ IsMenuPopup(nsIFrame *aFrame) return (frameType == nsGkAtoms::menuPopupFrame); } +static PRBool +IsTopLevelWidget(nsPresContext* aPresContext) +{ + nsCOMPtr container = aPresContext->Document()->GetContainer(); + nsCOMPtr baseWindow = do_QueryInterface(container); + if (!baseWindow) + return PR_FALSE; + + nsCOMPtr mainWidget; + baseWindow->GetMainWidget(getter_AddRefs(mainWidget)); + if (!mainWidget) + return PR_FALSE; + + nsWindowType windowType; + mainWidget->GetWindowType(windowType); + return windowType == eWindowType_toplevel || + windowType == eWindowType_dialog; + // popups aren't toplevel so they're not handled here +} + static void SyncFrameViewGeometryDependentProperties(nsPresContext* aPresContext, nsIFrame* aFrame, @@ -466,20 +487,9 @@ SyncFrameViewGeometryDependentProperties(nsPresContext* aPresContext, nsIView* rootView; vm->GetRootView(rootView); - nsIDocument *doc = aPresContext->PresShell()->GetDocument(); - if (doc) { - nsIContent *rootElem = doc->GetRootContent(); - if (!doc->GetParentDocument() && - (nsCOMPtr(doc->GetContainer())) && - rootElem && rootElem->IsNodeOfType(nsINode::eXUL)) { - // we're XUL at the root of the document hierarchy. Try to make our - // window translucent. - // don't proceed unless this is the root view - // (sometimes the non-root-view is a canvas) - if (aView->HasWidget() && aView == rootView) { - aView->GetWidget()->SetHasTransparentBackground(nsLayoutUtils::FrameHasTransparency(aFrame)); - } - } + if (aView->HasWidget() && aView == rootView && + IsTopLevelWidget(aPresContext)) { + aView->GetWidget()->SetHasTransparentBackground(nsLayoutUtils::FrameHasTransparency(aFrame)); } } }