Bug 1344839 - Don't allow transparent top-level windows on Windows. r?jimm draft
authorMike Conley <mconley@mozilla.com>
Tue, 21 Mar 2017 22:15:55 -0400
changeset 555180 7db95637eb8c79fc0b817a4c6b768b42475214b4
parent 555163 a3ce9317db8413a8249fa27a9a94de9a8b54f1d7
child 622562 eee5c1a81d86f4f19991e2b0651be99c39317931
push id52187
push usermconley@mozilla.com
push dateMon, 03 Apr 2017 20:25:00 +0000
reviewersjimm
bugs1344839
milestone55.0a1
Bug 1344839 - Don't allow transparent top-level windows on Windows. r?jimm MozReview-Commit-ID: 6bXHqDuUMw6
widget/windows/nsWindow.cpp
--- 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