Bug 747442 - Unlock orientation only if the received mozfullscreenchange is for fullscreen being disabled. r=smaug a=mfinkle
authorMounir Lamouri <mounir.lamouri@gmail.com>
Mon, 23 Apr 2012 10:30:58 +0200
changeset 95423 6b26bdffa1bc8e79d72bc9986764177f1c914c3b
parent 95422 e29b3d77f80802e46c3a0b5f1d78330a76b59ca5
child 95424 85abf12e5c83b480f75bea9d42b0e2b136c6ab80
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, mfinkle
bugs747442
milestone14.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 747442 - Unlock orientation only if the received mozfullscreenchange is for fullscreen being disabled. r=smaug a=mfinkle
dom/base/nsScreen.cpp
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -421,15 +421,33 @@ nsScreen::FullScreenEventListener::Handl
   aEvent->GetType(eventType);
 
   MOZ_ASSERT(eventType.EqualsLiteral("mozfullscreenchange"));
 #endif
 
   nsCOMPtr<nsIDOMEventTarget> target;
   aEvent->GetCurrentTarget(getter_AddRefs(target));
 
+  // We have to make sure that the event we got is the event sent when
+  // fullscreen is disabled because we could get one when fullscreen
+  // got enabled if the lock call is done at the same moment.
+  nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(target);
+  MOZ_ASSERT(window);
+
+  nsCOMPtr<nsIDOMDocument> doc;
+  window->GetDocument(getter_AddRefs(doc));
+  // If we have no doc, we will just continue, remove the event and unlock.
+  // This is an edge case were orientation lock and fullscreen is meaningless.
+  if (doc) {
+    bool fullscreen;
+    doc->GetMozFullScreen(&fullscreen);
+    if (fullscreen) {
+      return NS_OK;
+    }
+  }
+
   target->RemoveSystemEventListener(NS_LITERAL_STRING("mozfullscreenchange"),
                                     this, true);
 
   hal::UnlockScreenOrientation();
 
   return NS_OK;
 }