Bug 478784: fix transparent-widget check in PresShell::Paint; r+sr=roc
authorZack Weinberg <zweinberg@mozilla.com>
Wed, 25 Feb 2009 09:35:31 -0800
changeset 23442 191401e9d02ab97943225a532ac2b21fcfba49f2
parent 23441 a6844aa97aceeddc9a81b434d6e68a132412c5e0
child 23443 8be6f1f1bb3cded4518acd0677aa600d780c9657
push id778
push userrocallahan@mozilla.com
push dateThu, 26 Feb 2009 09:56:42 +0000
bugs478784
milestone1.9.1b3pre
Bug 478784: fix transparent-widget check in PresShell::Paint; r+sr=roc
layout/base/nsPresShell.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5389,21 +5389,22 @@ PresShell::Paint(nsIView*             aV
   NS_ASSERTION(aView, "null view");
 
   // Compute the backstop color for the view.  This color must be
   // totally transparent if the view is within a glass or transparent
   // widget; otherwise it must be totally opaque.  The user's default
   // background color as recorded in the prescontext is guaranteed to
   // be opaque.
 
+  PRBool needTransparency = PR_FALSE;
   nscolor backgroundColor = mPresContext->DefaultBackgroundColor();
   for (nsIView *view = aView; view; view = view->GetParent()) {
     if (view->HasWidget() &&
         view->GetWidget()->GetTransparencyMode() != eTransparencyOpaque) {
-      backgroundColor = NS_RGBA(0,0,0,0);
+      needTransparency = PR_TRUE;
       break;
     }
   }
 
   // Check whether the view manager knows the background color of the
   // canvas.  We set this below, and the docshell propagates it across
   // page loads; using it in preference to the user's default color
   // avoids screen flashing in between pages that use the same
@@ -5414,19 +5415,21 @@ PresShell::Paint(nsIView*             aV
   nscolor viewDefaultColor = NS_RGBA(0,0,0,0);
   if (mViewManager)
     mViewManager->GetDefaultBackgroundColor(&viewDefaultColor);
 
   // If we don't have a frame tree yet, all we can do is paint the
   // backstop colors.
   nsIFrame* frame = static_cast<nsIFrame*>(aView->GetClientData());
   if (!frame) {
-    backgroundColor = NS_ComposeColors(backgroundColor, viewDefaultColor);
-    aRenderingContext->SetColor(backgroundColor);
-    aRenderingContext->FillRect(aDirtyRegion.GetBounds());
+    if (!needTransparency) {
+      backgroundColor = NS_ComposeColors(backgroundColor, viewDefaultColor);
+      aRenderingContext->SetColor(backgroundColor);
+      aRenderingContext->FillRect(aDirtyRegion.GetBounds());
+    }
     return NS_OK;
   }
 
   // If we do have a frame tree, check whether it specifies a canvas
   // background color yet.  If it does, use that instead of whatever
   // color the view manager reported, and update the view manager
   // accordingly.
   nsIFrame* rootFrame = FrameConstructor()->GetRootElementStyleFrame();
@@ -5440,17 +5443,18 @@ PresShell::Paint(nsIView*             aV
     backgroundColor = NS_ComposeColors(backgroundColor,
                                        bgStyle->mBackgroundColor);
     mViewManager->SetDefaultBackgroundColor(backgroundColor);
   } else {
     backgroundColor = NS_ComposeColors(backgroundColor, viewDefaultColor);
   }
 
   nsLayoutUtils::PaintFrame(aRenderingContext, frame, aDirtyRegion,
-                            backgroundColor);
+                            needTransparency ? NS_RGBA(0,0,0,0)
+                            : backgroundColor);
   return NS_OK;
 }
 
 nsIFrame*
 PresShell::GetCurrentEventFrame()
 {
   if (NS_UNLIKELY(mIsDestroying)) {
     return nsnull;