Bug 1113006 - Screen manager ScreenForBrowser message should return primary screen as fallback (r=mconley)
authorBill McCloskey <wmccloskey@mozilla.com>
Thu, 18 Dec 2014 17:36:20 -0800
changeset 220556 06d89851a3a53496aca56cf1c333d7ed26f177d1
parent 220555 f49d4632197b752f93aca8cba741137e95b606cf
child 220557 7ff7bcdb127185d14ae77f67a467ae30f6458134
push id10503
push userryanvm@gmail.com
push dateFri, 19 Dec 2014 20:13:42 +0000
treeherderfx-team@98ee95ac6be5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1113006
milestone37.0a1
Bug 1113006 - Screen manager ScreenForBrowser message should return primary screen as fallback (r=mconley)
dom/ipc/ScreenManagerParent.cpp
--- a/dom/ipc/ScreenManagerParent.cpp
+++ b/dom/ipc/ScreenManagerParent.cpp
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set sw=4 ts=8 et tw=80 : */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/unused.h"
 #include "nsIWidget.h"
@@ -126,24 +126,28 @@ ScreenManagerParent::RecvScreenForBrowse
   // process.
   memset(aRetVal, 0, sizeof(ScreenDetails));
 #endif
 
   // Find the mWidget associated with the tabparent, and then return
   // the nsIScreen it's on.
   TabParent* tabParent = static_cast<TabParent*>(aBrowser);
   nsCOMPtr<nsIWidget> widget = tabParent->GetWidget();
-  if (!widget) {
-    return true;
-  }
 
   nsCOMPtr<nsIScreen> screen;
-  if (widget->GetNativeData(NS_NATIVE_WINDOW)) {
-    mScreenMgr->ScreenForNativeWidget(widget->GetNativeData(NS_NATIVE_WINDOW),
-                                      getter_AddRefs(screen));
+  if (widget) {
+    if (widget->GetNativeData(NS_NATIVE_WINDOW)) {
+      mScreenMgr->ScreenForNativeWidget(widget->GetNativeData(NS_NATIVE_WINDOW),
+                                        getter_AddRefs(screen));
+    }
+  } else {
+    nsresult rv = mScreenMgr->GetPrimaryScreen(getter_AddRefs(screen));
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return true;
+    }
   }
 
   NS_ENSURE_TRUE(screen, true);
 
   ScreenDetails details;
   if (!ExtractScreenDetails(screen, details)) {
     return true;
   }