diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 97f457382f08..94891595c4a1 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -3036,31 +3036,34 @@ nsLayoutUtils::HasNonZeroCornerOnSide(const nsStyleCorners& aCorners, } /* static */ nsTransparencyMode -nsLayoutUtils::GetFrameTransparency(nsIFrame* aFrame) { - if (aFrame->GetStyleContext()->GetStyleDisplay()->mOpacity < 1.0f) +nsLayoutUtils::GetFrameTransparency(nsIFrame* aBackgroundFrame, + nsIFrame* aCSSRootFrame) { + if (aCSSRootFrame->GetStyleContext()->GetStyleDisplay()->mOpacity < 1.0f) return eTransparencyTransparent; - if (HasNonZeroCorner(aFrame->GetStyleContext()->GetStyleBorder()->mBorderRadius)) + if (HasNonZeroCorner(aCSSRootFrame->GetStyleContext()->GetStyleBorder()->mBorderRadius)) return eTransparencyTransparent; nsTransparencyMode transparency; - if (aFrame->IsThemed(&transparency)) + if (aCSSRootFrame->IsThemed(&transparency)) return transparency; - if (aFrame->GetStyleDisplay()->mAppearance == NS_THEME_WIN_GLASS) + if (aCSSRootFrame->GetStyleDisplay()->mAppearance == NS_THEME_WIN_GLASS) return eTransparencyGlass; // We need an uninitialized window to be treated as opaque because // doing otherwise breaks window display effects on some platforms, // specifically Vista. (bug 450322) - if (aFrame->GetType() == nsGkAtoms::viewportFrame && - !aFrame->GetFirstChild(nsnull)) { + if (aBackgroundFrame->GetType() == nsGkAtoms::viewportFrame && + !aBackgroundFrame->GetFirstChild(nsnull)) { return eTransparencyOpaque; } const nsStyleBackground* bg; - if (!nsCSSRendering::FindBackground(aFrame->PresContext(), aFrame, &bg)) + if (!nsCSSRendering::FindBackground(aBackgroundFrame->PresContext(), + aBackgroundFrame, &bg)) { return eTransparencyTransparent; + } if (NS_GET_A(bg->mBackgroundColor) < 255 || // bottom layer's clip is used for the color bg->BottomLayer().mClip != NS_STYLE_BG_CLIP_BORDER) diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index b270c80adb56..736a1cfe3b06 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -961,10 +961,16 @@ public: /** * Determine if a widget is likely to require transparency or translucency. - * @param aFrame the frame of a , or element. + * @param aBackgroundFrame The frame that the background is set on. For + * s, this will be the canvas frame. + * @param aCSSRootFrame The frame that holds CSS properties affecting + * the widget's transparency. For menupopups, + * aBackgroundFrame and aCSSRootFrame will be the + * same. * @return a value suitable for passing to SetWindowTranslucency */ - static nsTransparencyMode GetFrameTransparency(nsIFrame* aFrame); + static nsTransparencyMode GetFrameTransparency(nsIFrame* aBackgroundFrame, + nsIFrame* aCSSRootFrame); /** * Get textrun construction flags determined by a given style; in particular diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index e281b52bd31e..4d9ba2e8c151 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -539,14 +539,7 @@ nsContainerFrame::SyncWindowProperties(nsPresContext* aPresContext, if (!rootFrame) return; - nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(aFrame); - // The issue here is that the CSS 'background' propagates from the root - // element's frame (rootFrame) to the real root frame (nsViewportFrame), - // so we need to call GetFrameTransparency on that. But -moz-appearance - // does not propagate so we need to check that directly on rootFrame. - if (NS_THEME_WIN_GLASS == rootFrame->GetStyleDisplay()->mAppearance) { - mode = eTransparencyGlass; - } + nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(aFrame, rootFrame); nsIWidget* viewWidget = aView->GetWidget(); viewWidget->SetTransparencyMode(mode); windowWidget->SetWindowShadowStyle(rootFrame->GetStyleUIReset()->mWindowShadow); diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index 8853c97a6761..f94496598d8d 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -251,7 +251,7 @@ nsMenuPopupFrame::CreateWidgetForView(nsIView* aView) widgetData.clipSiblings = PR_TRUE; widgetData.mPopupHint = mPopupType; - nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(this); + nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(this, this); PRBool viewHasTransparentContent = !mInContentShell && (eTransparencyTransparent == mode);