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
--- 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