From 74cd7ccc2b0f224f83de09e95809b9dc0bd9d2a3 Mon Sep 17 00:00:00 2001 From: "neil%parkwaycc.co.uk" Date: Thu, 7 Sep 2006 08:50:43 +0000 Subject: [PATCH] Bug 70798 Ability to have transparent background on s r+sr=roc git-svn-id: svn://10.0.0.236/trunk@209326 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsPresShell.cpp | 15 ++++++------- .../layout/xul/base/src/nsMenuPopupFrame.cpp | 9 +++++++- mozilla/view/src/nsViewManager.cpp | 21 +++++++++++-------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 62d4cd914c4..b99b9286971 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -5680,13 +5680,14 @@ PresShell::Paint(nsIView* aView, frame = NS_STATIC_CAST(nsIFrame*, aView->GetClientData()); nscolor backgroundColor; mViewManager->GetDefaultBackgroundColor(&backgroundColor); - nsIView* rootView; - mViewManager->GetRootView(rootView); - if (!rootView->GetParent() && rootView->HasWidget()) { - PRBool widgetIsTranslucent; - rootView->GetWidget()->GetWindowTranslucency(widgetIsTranslucent); - if (widgetIsTranslucent) { - backgroundColor = NS_RGBA(0,0,0,0); + for (nsIView *view = aView; view; view = view->GetParent()) { + if (view->HasWidget()) { + PRBool widgetIsTranslucent; + view->GetWidget()->GetWindowTranslucency(widgetIsTranslucent); + if (widgetIsTranslucent) { + backgroundColor = NS_RGBA(0,0,0,0); + break; + } } } diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp index 48f1b2c8a3c..60b881e3a68 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -216,11 +216,17 @@ nsMenuPopupFrame::CreateWidgetForView(nsIView* aView) widgetData.mBorderStyle = eBorderStyle_default; widgetData.clipSiblings = PR_TRUE; + PRBool isCanvas; + const nsStyleBackground* bg; + PRBool hasBG = + nsCSSRendering::FindBackground(GetPresContext(), this, &bg, &isCanvas); + PRBool viewHasTransparentContent = hasBG && (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT); + nsIContent* parentContent = GetContent()->GetParent(); nsIAtom *tag = nsnull; if (parentContent) tag = parentContent->Tag(); - widgetData.mDropShadow = !(tag && tag == nsXULAtoms::menulist); + widgetData.mDropShadow = !(viewHasTransparentContent || tag == nsXULAtoms::menulist); #if defined(XP_MACOSX) || defined(XP_BEOS) static NS_DEFINE_IID(kCPopupCID, NS_POPUP_CID); @@ -230,6 +236,7 @@ nsMenuPopupFrame::CreateWidgetForView(nsIView* aView) static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID); aView->CreateWidget(kCChildCID, &widgetData, nsnull, PR_TRUE, PR_TRUE); #endif + aView->GetWidget()->SetWindowTranslucency(viewHasTransparentContent); return NS_OK; } diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index 93a954f1027..5cf7552ced4 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -786,6 +786,7 @@ void nsViewManager::RenderViews(nsView *aView, nsIRenderingContext& aRC, const nsRegion& aRegion, nsIDrawingSurface* aRCSurface) { #ifndef MOZ_CAIRO_GFX + BlendingBuffers* buffers = nsnull; nsIWidget* widget = aView->GetWidget(); PRBool translucentWindow = PR_FALSE; if (widget) { @@ -793,15 +794,14 @@ void nsViewManager::RenderViews(nsView *aView, nsIRenderingContext& aRC, if (translucentWindow) { NS_WARNING("Transparent window enabled"); NS_ASSERTION(aRCSurface, "Cannot support transparent windows with doublebuffering disabled"); + + // Create a buffer wrapping aRC (which is usually the double-buffering offscreen buffer). + buffers = CreateBlendingBuffers(&aRC, PR_TRUE, aRCSurface, translucentWindow, aRegion.GetBounds()); + NS_ASSERTION(buffers, "Failed to create rendering buffers"); + if (!buffers) + return; } } - - // Create a buffer wrapping aRC (which is usually the double-buffering offscreen buffer). - BlendingBuffers* buffers = - CreateBlendingBuffers(&aRC, PR_TRUE, aRCSurface, translucentWindow, aRegion.GetBounds()); - NS_ASSERTION(buffers, "Failed to create rendering buffers"); - if (!buffers) - return; #endif if (mObserver) { @@ -814,6 +814,10 @@ void nsViewManager::RenderViews(nsView *aView, nsIRenderingContext& aRC, aRC.Translate(-offsetToRoot.x, -offsetToRoot.y); mObserver->Paint(displayRoot, &aRC, damageRegion); aRC.PopState(); +#ifndef MOZ_CAIRO_GFX + if (translucentWindow) + mObserver->Paint(displayRoot, buffers->mWhiteCX, aRegion); +#endif } #ifndef MOZ_CAIRO_GFX @@ -830,9 +834,8 @@ void nsViewManager::RenderViews(nsView *aView, nsIRenderingContext& aRC, widget->UpdateTranslucentWindowAlpha(r, alphas); } delete[] alphas; + delete buffers; } - - delete buffers; #endif }