Bug 1284350. Reland on top of backouts "Bug 1299065 - invisible elements in the foreground should also be recorded; r=gerald" r=kaku
authorKaku Kuo <kaku@mozilla.com>
Tue, 30 Aug 2016 14:53:04 +0800
changeset 339247 f56deec592bd3cff3e7f9eacb4786a3e50626fca
parent 339246 8de973bd95adf8b7106bb196343ebb7bf420aba8
child 339248 1851b78b5a9673ee422f189b92e5f1e86b82a01c
child 339261 eed2a76f1a596aa4847996136dfd7517484a8f0b
push id10033
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:50:26 +0000
treeherdermozilla-aurora@5dddbefdf759 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, kaku
bugs1284350, 1299065
milestone51.0a1
Bug 1284350. Reland on top of backouts "Bug 1299065 - invisible elements in the foreground should also be recorded; r=gerald" r=kaku Instead of "not visible", "approximately visible", and "visible" (in display port) we now have "approximately not visible", and "approximately visible" which includes "visible".
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -6044,20 +6044,28 @@ HTMLMediaElement::OnVisibilityChange(Vis
   }
 
   switch (aNewVisibility) {
     case Visibility::UNTRACKED: {
         MOZ_ASSERT_UNREACHABLE("Shouldn't notify for untracked visibility");
         break;
     }
     case Visibility::APPROXIMATELY_NONVISIBLE: {
+      if (mPlayTime.IsStarted()) {
+        // Not visible, play time is running -> Start hidden play time if needed.
+        HiddenVideoStart();
+      }
+
       mDecoder->NotifyOwnerActivityChanged(false);
       break;
     }
     case Visibility::APPROXIMATELY_VISIBLE: {
+      // Visible -> Just pause hidden play time (no-op if already paused).
+      HiddenVideoStop();
+
       mDecoder->NotifyOwnerActivityChanged(true);
       break;
     }
   }
 
 }
 #ifdef MOZ_EME
 MediaKeys*