Bug 510149 - Changes to nsLayoutUtils::GetFrameTransparency. r=roc

--HG--
extra : rebase_source : 024d18340b423827524eb725d961d0907b90338d
This commit is contained in:
Markus Stange 2009-08-14 10:08:13 +12:00
Родитель 87be8be824
Коммит f2ba84dee3
4 изменённых файлов: 21 добавлений и 19 удалений

Просмотреть файл

@ -3036,31 +3036,34 @@ nsLayoutUtils::HasNonZeroCornerOnSide(const nsStyleCorners& aCorners,
} }
/* static */ nsTransparencyMode /* static */ nsTransparencyMode
nsLayoutUtils::GetFrameTransparency(nsIFrame* aFrame) { nsLayoutUtils::GetFrameTransparency(nsIFrame* aBackgroundFrame,
if (aFrame->GetStyleContext()->GetStyleDisplay()->mOpacity < 1.0f) nsIFrame* aCSSRootFrame) {
if (aCSSRootFrame->GetStyleContext()->GetStyleDisplay()->mOpacity < 1.0f)
return eTransparencyTransparent; return eTransparencyTransparent;
if (HasNonZeroCorner(aFrame->GetStyleContext()->GetStyleBorder()->mBorderRadius)) if (HasNonZeroCorner(aCSSRootFrame->GetStyleContext()->GetStyleBorder()->mBorderRadius))
return eTransparencyTransparent; return eTransparencyTransparent;
nsTransparencyMode transparency; nsTransparencyMode transparency;
if (aFrame->IsThemed(&transparency)) if (aCSSRootFrame->IsThemed(&transparency))
return transparency; return transparency;
if (aFrame->GetStyleDisplay()->mAppearance == NS_THEME_WIN_GLASS) if (aCSSRootFrame->GetStyleDisplay()->mAppearance == NS_THEME_WIN_GLASS)
return eTransparencyGlass; return eTransparencyGlass;
// We need an uninitialized window to be treated as opaque because // We need an uninitialized window to be treated as opaque because
// doing otherwise breaks window display effects on some platforms, // doing otherwise breaks window display effects on some platforms,
// specifically Vista. (bug 450322) // specifically Vista. (bug 450322)
if (aFrame->GetType() == nsGkAtoms::viewportFrame && if (aBackgroundFrame->GetType() == nsGkAtoms::viewportFrame &&
!aFrame->GetFirstChild(nsnull)) { !aBackgroundFrame->GetFirstChild(nsnull)) {
return eTransparencyOpaque; return eTransparencyOpaque;
} }
const nsStyleBackground* bg; const nsStyleBackground* bg;
if (!nsCSSRendering::FindBackground(aFrame->PresContext(), aFrame, &bg)) if (!nsCSSRendering::FindBackground(aBackgroundFrame->PresContext(),
aBackgroundFrame, &bg)) {
return eTransparencyTransparent; return eTransparencyTransparent;
}
if (NS_GET_A(bg->mBackgroundColor) < 255 || if (NS_GET_A(bg->mBackgroundColor) < 255 ||
// bottom layer's clip is used for the color // bottom layer's clip is used for the color
bg->BottomLayer().mClip != NS_STYLE_BG_CLIP_BORDER) bg->BottomLayer().mClip != NS_STYLE_BG_CLIP_BORDER)

Просмотреть файл

@ -961,10 +961,16 @@ public:
/** /**
* Determine if a widget is likely to require transparency or translucency. * Determine if a widget is likely to require transparency or translucency.
* @param aFrame the frame of a <window>, <popup> or <menupopup> element. * @param aBackgroundFrame The frame that the background is set on. For
* <window>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 * @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 * Get textrun construction flags determined by a given style; in particular

Просмотреть файл

@ -539,14 +539,7 @@ nsContainerFrame::SyncWindowProperties(nsPresContext* aPresContext,
if (!rootFrame) if (!rootFrame)
return; return;
nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(aFrame); nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(aFrame, rootFrame);
// 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;
}
nsIWidget* viewWidget = aView->GetWidget(); nsIWidget* viewWidget = aView->GetWidget();
viewWidget->SetTransparencyMode(mode); viewWidget->SetTransparencyMode(mode);
windowWidget->SetWindowShadowStyle(rootFrame->GetStyleUIReset()->mWindowShadow); windowWidget->SetWindowShadowStyle(rootFrame->GetStyleUIReset()->mWindowShadow);

Просмотреть файл

@ -251,7 +251,7 @@ nsMenuPopupFrame::CreateWidgetForView(nsIView* aView)
widgetData.clipSiblings = PR_TRUE; widgetData.clipSiblings = PR_TRUE;
widgetData.mPopupHint = mPopupType; widgetData.mPopupHint = mPopupType;
nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(this); nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(this, this);
PRBool viewHasTransparentContent = !mInContentShell && PRBool viewHasTransparentContent = !mInContentShell &&
(eTransparencyTransparent == (eTransparencyTransparent ==
mode); mode);