Bug 766902 - Don't listen for fullscreenchange when screen has been locked by an application. r=smaug
authorMounir Lamouri <mounir.lamouri@gmail.com>
Fri, 22 Jun 2012 10:53:03 +0200
changeset 97372 71f3a9a2b160385610e68ebdd76c977ad90cea7a
parent 97371 c0221764624b1866ba8fa475b460bbc5134b864e
child 97373 054217b5399b247525c3ef717f6c907494abedf5
push id11009
push usermlamouri@mozilla.com
push dateFri, 22 Jun 2012 08:59:25 +0000
treeherdermozilla-inbound@5a1a4ae9172d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs766902
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 766902 - Don't listen for fullscreenchange when screen has been locked by an application. r=smaug
dom/base/nsScreen.cpp
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -313,61 +313,56 @@ nsScreen::GetMozOrientation(nsAString& a
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsScreen::MozLockOrientation(const nsAString& aOrientation, bool* aReturn)
 {
   ScreenOrientation orientation;
+  *aReturn = false;
 
   if (aOrientation.EqualsLiteral("portrait")) {
     orientation = eScreenOrientation_Portrait;
   } else if (aOrientation.EqualsLiteral("portrait-primary")) {
     orientation = eScreenOrientation_PortraitPrimary;
   } else if (aOrientation.EqualsLiteral("portrait-secondary")) {
     orientation = eScreenOrientation_PortraitSecondary;
   } else if (aOrientation.EqualsLiteral("landscape")) {
     orientation = eScreenOrientation_Landscape;
   } else if (aOrientation.EqualsLiteral("landscape-primary")) {
     orientation = eScreenOrientation_LandscapePrimary;
   } else if (aOrientation.EqualsLiteral("landscape-secondary")) {
     orientation = eScreenOrientation_LandscapeSecondary;
   } else {
-    *aReturn = false;
     return NS_OK;
   }
 
   if (!GetOwner()) {
-    *aReturn = false;
     return NS_OK;
   }
 
-  if (!IsChromeType(GetOwner()->GetDocShell())) {
+  // Chrome code and apps can always lock the screen orientation.
+  if (!IsChromeType(GetOwner()->GetDocShell()) &&
+      !static_cast<nsGlobalWindow*>(GetOwner())->IsPartOfApp()) {
     nsCOMPtr<nsIDOMDocument> doc;
     GetOwner()->GetDocument(getter_AddRefs(doc));
     if (!doc) {
-      *aReturn = false;
       return NS_OK;
     }
 
-    // Apps and frames contained in apps can lock orientation.
-    // But non-apps can lock orientation only if they're fullscreen.
-    if (!static_cast<nsGlobalWindow*>(GetOwner())->IsPartOfApp()) {
-      bool fullscreen;
-      doc->GetMozFullScreen(&fullscreen);
-      if (!fullscreen) {
-        *aReturn = false;
-        return NS_OK;
-      }
+    // Non-apps content can lock orientation only if fullscreen.
+    bool fullscreen;
+    doc->GetMozFullScreen(&fullscreen);
+    if (!fullscreen) {
+      return NS_OK;
     }
 
     nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(GetOwner());
     if (!target) {
-      *aReturn = false;
       return NS_OK;
     }
 
     if (!mEventListener) {
       mEventListener = new FullScreenEventListener();
     }
 
     target->AddSystemEventListener(NS_LITERAL_STRING("mozfullscreenchange"),