bug 805017 - Disable screen timeout when DOMFullscreen is enabled r=jst
authorBrad Lassey <blassey@mozilla.com>
Thu, 01 Nov 2012 08:40:11 -0400
changeset 112293 18da095f136a610fb23198c35304fdbb68023faf
parent 112292 e8f94aee02aa390f50a287acfd182a5eb34f3bf9
child 112294 71d1523adf8d200bf13c4fdef459284d8410b26e
push id23809
push useremorley@mozilla.com
push dateMon, 05 Nov 2012 15:24:12 +0000
treeherdermozilla-central@358c9830d166 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs805017
milestone19.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 805017 - Disable screen timeout when DOMFullscreen is enabled r=jst
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -16,16 +16,17 @@
 #include "nsHistory.h"
 #include "nsPerformance.h"
 #include "nsDOMNavigationTiming.h"
 #include "nsBarProps.h"
 #include "nsDOMStorage.h"
 #include "nsDOMOfflineResourceList.h"
 #include "nsError.h"
 #include "nsIIdleService.h"
+#include "nsIPowerManagerService.h"
 
 #ifdef XP_WIN
 #ifdef GetClassName
 #undef GetClassName
 #endif // GetClassName
 #endif // XP_WIN
 
 // Helper Classes
@@ -4583,16 +4584,27 @@ nsGlobalWindow::SetFullScreenInternal(bo
   if (!mFullScreen) {
     // Force exit from DOM full-screen mode. This is so that if we're in
     // DOM full-screen mode and the user exits full-screen mode with
     // the browser full-screen mode toggle keyboard-shortcut, we'll detect
     // that and leave DOM API full-screen mode too.
     nsIDocument::ExitFullScreen(false);
   }
 
+  if (!mWakeLock && mFullScreen) {
+    nsCOMPtr<nsIPowerManagerService> pmService =
+      do_GetService(POWERMANAGERSERVICE_CONTRACTID);
+    NS_ENSURE_TRUE(pmService, NS_OK);
+
+    pmService->NewWakeLock(NS_LITERAL_STRING("DOM_Fullscreen"), this, getter_AddRefs(mWakeLock));
+  } else if (mWakeLock && !mFullScreen) {
+    mWakeLock->Unlock();
+    mWakeLock = NULL;
+  }
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetFullScreen(bool* aFullScreen)
 {
   FORWARD_TO_OUTER(GetFullScreen, (aFullScreen), NS_ERROR_NOT_INITIALIZED);
 
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -60,16 +60,17 @@
 #include "nsIIDBFactory.h"
 #include "nsFrameMessageManager.h"
 #include "mozilla/TimeStamp.h"
 #include "nsIDOMTouchEvent.h"
 #include "nsIInlineEventHandlers.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsIDOMApplicationRegistry.h"
 #include "nsIIdleObserver.h"
+#include "nsIDOMWakeLock.h"
 
 // JS includes
 #include "jsapi.h"
 
 #define DEFAULT_HOME_PAGE "www.mozilla.org"
 #define PREF_BROWSER_STARTUP_HOMEPAGE "browser.startup.homepage"
 
 // Amount of time allowed between alert/prompt/confirm before enabling
@@ -631,16 +632,18 @@ protected:
   bool mCurrentlyIdle;
 
   // Set to true when a fuzz time needs to be applied
   // to active notifications to the idle observer.
   bool mAddActiveEventFuzzTime;
 
   nsCOMPtr <nsIIdleService> mIdleService;
 
+  nsCOMPtr <nsIDOMMozWakeLock> mWakeLock;
+
   static bool sIdleObserversAPIFuzzTimeDisabled;
 
   friend class HashchangeCallback;
   friend class nsBarProp;
 
   // Object Management
   virtual ~nsGlobalWindow();
   void CleanUp(bool aIgnoreModalDialog);