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