Bug 1532682 - Make HTMLVideoElement::EndCloningVisually completely sever references between source and target video elements. r=jya
☠☠ backed out by da85432905df ☠ ☠
authorMike Conley <mconley@mozilla.com>
Thu, 07 Mar 2019 21:00:45 +0000
changeset 520901 9b8ef8d817750751af255a622bcf208a7db1c3b2
parent 520900 a75985a8a0863ad2df578643c7507193115973f8
child 520902 7bc5e1d2789611b17adcdb4483bc1aea9199a26b
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1532682
milestone67.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 1532682 - Make HTMLVideoElement::EndCloningVisually completely sever references between source and target video elements. r=jya Differential Revision: https://phabricator.services.mozilla.com/D22109
dom/html/HTMLVideoElement.cpp
--- a/dom/html/HTMLVideoElement.cpp
+++ b/dom/html/HTMLVideoElement.cpp
@@ -28,16 +28,17 @@
 #include "MediaDecoderStateMachine.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/WakeLock.h"
 #include "mozilla/dom/power/PowerManagerService.h"
 #include "mozilla/dom/Performance.h"
 #include "mozilla/dom/TimeRanges.h"
 #include "mozilla/dom/VideoPlaybackQuality.h"
 #include "mozilla/dom/VideoStreamTrack.h"
+#include "mozilla/Unused.h"
 
 #include <algorithm>
 #include <limits>
 
 nsGenericHTMLElement* NS_NewHTMLVideoElement(
     already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
     mozilla::dom::FromParser aFromParser) {
   mozilla::dom::HTMLVideoElement* element =
@@ -175,19 +176,17 @@ HTMLVideoElement::IsAttributeMapped(cons
 nsMapRuleToAttributesFunc HTMLVideoElement::GetAttributeMappingFunction()
     const {
   return &MapAttributesIntoRule;
 }
 
 void HTMLVideoElement::UnbindFromTree(bool aDeep, bool aNullParent) {
   if (mVisualCloneSource) {
     mVisualCloneSource->EndCloningVisually();
-    SetVisualCloneSource(nullptr);
   } else if (mVisualCloneTarget) {
-    mVisualCloneTarget->SetVisualCloneSource(nullptr);
     EndCloningVisually();
   }
 
   HTMLMediaElement::UnbindFromTree(aDeep, aNullParent);
 }
 
 nsresult HTMLVideoElement::SetAcceptHeader(nsIHttpChannel* aChannel) {
   nsAutoCString value(
@@ -452,16 +451,21 @@ void HTMLVideoElement::CloneElementVisua
              "Can't clone a video that's not bound to a DOM tree.");
   MOZ_ASSERT(!aTargetVideo.mUnboundFromTree,
              "Can't clone to a video that's not bound to a DOM tree.");
   if (mUnboundFromTree || aTargetVideo.mUnboundFromTree) {
     rv.Throw(NS_ERROR_UNEXPECTED);
     return;
   }
 
+  // Do we already have a visual clone target? If so, shut it down.
+  if (mVisualCloneTarget) {
+    EndCloningVisually();
+  }
+
   if (!SetVisualCloneTarget(&aTargetVideo)) {
     rv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   if (!aTargetVideo.SetVisualCloneSource(this)) {
     mVisualCloneTarget = nullptr;
     rv.Throw(NS_ERROR_FAILURE);
@@ -508,13 +512,14 @@ void HTMLVideoElement::EndCloningVisuall
     VideoFrameContainer* container =
         mVisualCloneTarget->GetVideoFrameContainer();
     if (container && mVisualCloneTarget->mSelectedVideoStreamTrack) {
       mVisualCloneTarget->mSelectedVideoStreamTrack->RemoveVideoOutput(
           container);
     }
   }
 
-  mVisualCloneTarget = nullptr;
+  Unused << mVisualCloneTarget->SetVisualCloneSource(nullptr);
+  Unused << SetVisualCloneTarget(nullptr);
 }
 
 }  // namespace dom
 }  // namespace mozilla