From c3bcfd8995067b9abd18c62630d629fa137671dd Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Fri, 12 Sep 2008 08:36:53 -0700 Subject: [PATCH] Bug 453566 - HTML element with rgba(0,0,0,0) background produces garbage on screen. r+sr=roc --- layout/base/nsCSSRendering.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index bb70a984598..e301583197f 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -1299,21 +1299,24 @@ nsCSSRendering::PaintBackground(nsPresContext* aPresContext, nsIViewManager* vm = aPresContext->GetViewManager(); - if (NS_GET_A(canvasColor.mBackgroundColor) == 0) { - nsIView* rootView; - vm->GetRootView(rootView); - if (!rootView->GetParent()) { - PRBool widgetIsTransparent = PR_FALSE; + if (NS_GET_A(canvasColor.mBackgroundColor) < 255) { + // If the window is intended to be opaque, ensure that we always + // paint an opaque color for its root element, in case there's no + // background at all or a partly transparent image. + // + // The default background color from the prescontext is under user + // control, so it might not be opaque either. + nsIView* rView; + vm->GetRootView(rView); + if (!rView->GetParent() && + (!rView->HasWidget() || + rView->GetWidget()->GetTransparencyMode() == eTransparencyOpaque)) { + nscolor backColor = + NS_ComposeColors(NS_RGB(255,255,255), + aPresContext->DefaultBackgroundColor()); - if (rootView->HasWidget()) - // We don't want to draw a bg for glass windows either - widgetIsTransparent = eTransparencyOpaque != rootView->GetWidget()->GetTransparencyMode(); - - if (!widgetIsTransparent) { - // Ensure that we always paint a color for the root (in case there's - // no background at all or a partly transparent image). - canvasColor.mBackgroundColor = aPresContext->DefaultBackgroundColor(); - } + canvasColor.mBackgroundColor = + NS_ComposeColors(backColor, canvasColor.mBackgroundColor); } }