Bug 1520088 - part2 : ensure logging result can always be executed. r=cpearce
authorAlastor Wu <alwu@mozilla.com>
Wed, 16 Jan 2019 01:04:40 +0000
changeset 514132 1d2fcf021b32addc028800b6f0b315c7c4779b3d
parent 514131 eb086e6c019f0cf11bedf536cbf601f401181e27
child 514133 2ce9b482cda2d1ca16f063754be1bd43515de585
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1520088
milestone66.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 1520088 - part2 : ensure logging result can always be executed. r=cpearce Ensure we can always see the debug log for the autoplay result. Differential Revision: https://phabricator.services.mozilla.com/D16524
dom/media/AutoplayPolicy.cpp
--- a/dom/media/AutoplayPolicy.cpp
+++ b/dom/media/AutoplayPolicy.cpp
@@ -163,18 +163,17 @@ static bool IsEnableBlockingWebAudioByUs
          IsWindowAllowedToPlay(aElement.OwnerDoc()->GetInnerWindow());
 }
 
 /* static */ bool AutoplayPolicy::WouldBeAllowedToPlayIfAutoplayDisabled(
     const AudioContext& aContext) {
   return IsAudioContextAllowedToPlay(aContext);
 }
 
-/* static */ bool AutoplayPolicy::IsAllowedToPlay(
-    const HTMLMediaElement& aElement) {
+static bool IsAllowedToPlayInternal(const HTMLMediaElement& aElement) {
   const uint32_t autoplayDefault = DefaultAutoplayBehaviour();
   // TODO : this old way would be removed when user-gestures-needed becomes
   // as a default option to block autoplay.
   if (!Preferences::GetBool("media.autoplay.enabled.user-gestures-needed",
                             false)) {
     // If element is blessed, it would always be allowed to play().
     return (autoplayDefault == nsIAutoplay::ALLOWED || aElement.IsBlessed() ||
             EventStateManager::IsHandlingUserInput());
@@ -185,22 +184,25 @@ static bool IsEnableBlockingWebAudioByUs
   }
 
   if (IsWindowAllowedToPlay(aElement.OwnerDoc()->GetInnerWindow())) {
     AUTOPLAY_LOG("Autoplay allowed as window is allowed to play, media %p.",
                  &aElement);
     return true;
   }
 
-  const bool result = IsMediaElementAllowedToPlay(aElement) ||
-                      autoplayDefault == nsIAutoplay::ALLOWED;
+  return IsMediaElementAllowedToPlay(aElement) ||
+         autoplayDefault == nsIAutoplay::ALLOWED;
+}
 
+/* static */ bool AutoplayPolicy::IsAllowedToPlay(
+    const HTMLMediaElement& aElement) {
+  const bool result = IsAllowedToPlayInternal(aElement);
   AUTOPLAY_LOG("IsAllowedToPlay, mediaElement=%p, isAllowToPlay=%s", &aElement,
                result ? "allowed" : "blocked");
-
   return result;
 }
 
 /* static */ bool AutoplayPolicy::IsAllowedToPlay(
     const AudioContext& aContext) {
   if (!IsEnableBlockingWebAudioByUserGesturePolicy()) {
     return true;
   }