Bug 1344839 - Don't allow transparent top-level windows on Windows. r?jimm
MozReview-Commit-ID: 6bXHqDuUMw6
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -3026,30 +3026,44 @@ nsWindow::SetCursor(imgIContainer* aCurs
return NS_OK;
}
/**************************************************************
*
* SECTION: nsIWidget::Get/SetTransparencyMode
*
- * Manage the transparency mode of the top-level window
- * containing this widget.
+ * Manage the transparency mode of the window containing this
+ * widget. Only works for popup and dialog windows when the
+ * Desktop Window Manager compositor is not enabled.
*
**************************************************************/
#ifdef MOZ_XUL
nsTransparencyMode nsWindow::GetTransparencyMode()
{
return GetTopLevelWindow(true)->GetWindowTranslucencyInner();
}
void nsWindow::SetTransparencyMode(nsTransparencyMode aMode)
{
- GetTopLevelWindow(true)->SetWindowTranslucencyInner(aMode);
+ nsWindow* window = GetTopLevelWindow(true);
+ MOZ_ASSERT(window);
+
+ if (!window || window->DestroyCalled()) {
+ return;
+ }
+
+ if (nsWindowType::eWindowType_toplevel == window->mWindowType &&
+ !nsUXThemeData::CheckForCompositor()) {
+ NS_WARNING("Cannot set transparency mode on top-level windows.");
+ return;
+ }
+
+ window->SetWindowTranslucencyInner(aMode);
}
void nsWindow::UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion)
{
if (!HasGlass() || GetParent())
return;
// If there is no opaque region or hidechrome=true, set margins