Bug 1347402 part 3 - get owner document via polymorphism; r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Wed, 15 Mar 2017 14:56:05 +0800
changeset 500336 f687e8abd41108f8db7d6d60f139ebebb4147e43
parent 500335 6c120a119ccda07b8ee4085884cb174920829cc8
child 500337 077a28833893548ff8fbd69a3bc439d8de822e96
push id49692
push userbmo:kaku@mozilla.com
push dateFri, 17 Mar 2017 03:16:50 +0000
reviewersjwwang
bugs1347402
milestone55.0a1
Bug 1347402 part 3 - get owner document via polymorphism; r?jwwang MozReview-Commit-ID: GCr2xQyST4X
dom/media/MediaDecoder.cpp
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -584,21 +584,17 @@ MediaDecoder::OnPlaybackErrorEvent(const
 }
 
 void
 MediaDecoder::OnDecoderDoctorEvent(DecoderDoctorEvent aEvent)
 {
   MOZ_ASSERT(NS_IsMainThread());
   // OnDecoderDoctorEvent is disconnected at shutdown time.
   MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
-  HTMLMediaElement* element = GetOwner()->GetMediaElement();
-  if (!element) {
-    return;
-  }
-  nsIDocument* doc = element->OwnerDoc();
+  nsIDocument* doc = GetOwner()->GetDocument();
   if (!doc) {
     return;
   }
   DecoderDoctorDiagnostics diags;
   diags.StoreEvent(doc, aEvent, __func__);
 }
 
 void
@@ -1292,21 +1288,21 @@ MediaDecoder::DurationChanged()
 }
 
 void
 MediaDecoder::NotifyCompositor()
 {
   MediaDecoderOwner* owner = GetOwner();
   NS_ENSURE_TRUE_VOID(owner);
 
-  dom::HTMLMediaElement* element = owner->GetMediaElement();
-  NS_ENSURE_TRUE_VOID(element);
+  nsIDocument* ownerDoc = owner->GetDocument();
+  NS_ENSURE_TRUE_VOID(ownerDoc);
 
   RefPtr<LayerManager> layerManager =
-    nsContentUtils::LayerManagerForDocument(element->OwnerDoc());
+    nsContentUtils::LayerManagerForDocument(ownerDoc);
   if (layerManager) {
     RefPtr<KnowsCompositor> knowsCompositor = layerManager->AsShadowForwarder();
     mCompositorUpdatedEvent.Notify(knowsCompositor);
   }
 }
 
 void
 MediaDecoder::SetElementVisibility(bool aIsDocumentVisible,