Bug 809671 - Don't change wake lock state if visibility doesn't change. r=jlebar
authorKan-Ru Chen (陳侃如) <kanru@kanru.info>
Fri, 09 Nov 2012 16:00:26 -0500
changeset 112875 191155ed17b0989a8210ed4c07c163a6e851770b
parent 112874 e57d9d6a66aeda907c6db8d331f765b39244faf3
child 112876 0e0750c14c491abac564321317e4f268e76c573e
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjlebar
bugs809671
milestone19.0a1
Bug 809671 - Don't change wake lock state if visibility doesn't change. r=jlebar
dom/power/WakeLock.cpp
--- a/dom/power/WakeLock.cpp
+++ b/dom/power/WakeLock.cpp
@@ -170,19 +170,20 @@ WakeLock::HandleEvent(nsIDOMEvent *aEven
   nsAutoString type;
   aEvent->GetType(type);
 
   if (type.EqualsLiteral("mozvisibilitychange")) {
     nsCOMPtr<nsIDOMEventTarget> target;
     aEvent->GetTarget(getter_AddRefs(target));
     nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(target);
     NS_ENSURE_STATE(domDoc);
+    bool oldHidden = mHidden;
     domDoc->GetMozHidden(&mHidden);
 
-    if (mLocked) {
+    if (mLocked && oldHidden != mHidden) {
       hal::ModifyWakeLock(mTopic,
                           hal::WAKE_LOCK_NO_CHANGE,
                           mHidden ? hal::WAKE_LOCK_ADD_ONE : hal::WAKE_LOCK_REMOVE_ONE);
     }
 
     return NS_OK;
   }