Bug 1347402 part 2 - open a GetOwnerDoc() interface at the MediaDecoderOwner; r?jwwang draft
authorKaku Kuo <kaku@mozilla.com>
Wed, 15 Mar 2017 11:40:37 +0800
changeset 500353 b5c8187ed786aff6c72462d665d79488c574b780
parent 500352 6edf5eef27d110c00369e7da2562fd39591d7a99
child 500354 762bbf5db2b749d174b72ec2eb37bf42718861c5
push id49701
push userbmo:kaku@mozilla.com
push dateFri, 17 Mar 2017 03:54:30 +0000
reviewersjwwang
bugs1347402
milestone55.0a1
Bug 1347402 part 2 - open a GetOwnerDoc() interface at the MediaDecoderOwner; r?jwwang Open a GetOwnerDoc() method to the MediaDecoderOwner interface and then we can get the owner document via a pointer to MediaDecoderOwner in MediaDecoder. MozReview-Commit-ID: JCzQDLx1MsU
dom/html/HTMLMediaElement.cpp
dom/html/HTMLMediaElement.h
dom/media/MediaDecoderOwner.h
dom/media/gtest/MockMediaDecoderOwner.h
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -7404,16 +7404,22 @@ HTMLMediaElement::NotifyDecoderActivityC
 {
   if (mDecoder) {
     mDecoder->NotifyOwnerActivityChanged(!IsHidden(),
                                          mVisibilityState == Visibility::APPROXIMATELY_VISIBLE,
                                          IsInUncomposedDoc());
   }
 }
 
+nsIDocument*
+HTMLMediaElement::GetDocument() const
+{
+  return OwnerDoc();
+}
+
 bool HasDebuggerPrivilege(JSContext* aCx, JSObject* aObj)
 {
   return nsContentUtils::CallerHasPermission(aCx,
                                              NS_LITERAL_STRING("debugger"));
  }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -769,16 +769,18 @@ public:
   enum class CallerAPI {
     DRAW_IMAGE,
     CREATE_PATTERN,
     CREATE_IMAGEBITMAP,
     CAPTURE_STREAM,
   };
   void MarkAsContentSource(CallerAPI aAPI);
 
+  nsIDocument* GetDocument() const override;
+
 protected:
   virtual ~HTMLMediaElement();
 
   class AudioChannelAgentCallback;
   class ChannelLoader;
   class ErrorSink;
   class MediaLoadListener;
   class MediaStreamTracksAvailableCallback;
--- a/dom/media/MediaDecoderOwner.h
+++ b/dom/media/MediaDecoderOwner.h
@@ -152,14 +152,17 @@ public:
   // reference to the decoder to prevent further calls into the decoder.
   virtual void NotifyXPCOMShutdown() = 0;
 
   // Dispatches a "encrypted" event to the HTMLMediaElement, with the
   // provided init data. Actual dispatch may be delayed until HAVE_METADATA.
   // Main thread only.
   virtual void DispatchEncrypted(const nsTArray<uint8_t>& aInitData,
                                  const nsAString& aInitDataType) = 0;
+
+  // Return the decoder owner's owner document.
+  virtual nsIDocument* GetDocument() const = 0;
 };
 
 } // namespace mozilla
 
 #endif
 
--- a/dom/media/gtest/MockMediaDecoderOwner.h
+++ b/dom/media/gtest/MockMediaDecoderOwner.h
@@ -49,12 +49,13 @@ public:
   }
   void SetAudibleState(bool aAudible) override {}
   void NotifyXPCOMShutdown() override {}
   AbstractThread* AbstractMainThread() const override
   {
     // Non-DocGroup version for Mock.
     return AbstractThread::MainThread();
   }
+  nsIDocument* GetDocument() const { return nullptr; }
 };
 }
 
 #endif