Bug 70798 Ability to have transparent background on <popup>s r+sr=roc

git-svn-id: svn://10.0.0.236/trunk@209326 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
neil%parkwaycc.co.uk
2006-09-07 08:50:43 +00:00
parent f86c7a523f
commit 74cd7ccc2b
3 changed files with 28 additions and 17 deletions

View File

@@ -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;
}
}
}

View File

@@ -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;
}

View File

@@ -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
}