Bug 1299718 part 3 - call MarkAsContentSource() at where using video element as a source; r?gerald,kamidphish,mtseng
MozReview-Commit-ID: LiP9B12DAkX
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -2459,17 +2459,19 @@ CanvasRenderingContext2D::CreatePattern(
HTMLImageElement* img = &aSource.GetAsHTMLImageElement();
if (img->IntrinsicState().HasState(NS_EVENT_STATE_BROKEN)) {
aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
htmlElement = img;
} else if (aSource.IsHTMLVideoElement()) {
- htmlElement = &aSource.GetAsHTMLVideoElement();
+ auto& video = aSource.GetAsHTMLVideoElement();
+ video.MarkAsContentSource(mozilla::dom::HTMLVideoElement::CallerAPI::CREATE_PATTERN);
+ htmlElement = &video;
} else {
// Special case for ImageBitmap
ImageBitmap& imgBitmap = aSource.GetAsImageBitmap();
EnsureTarget();
RefPtr<SourceSurface> srcSurf = imgBitmap.PrepareForDrawTarget(mTarget);
if (!srcSurf) {
JSContext* context = nsContentUtils::GetCurrentJSContext();
if (context) {
@@ -4760,16 +4762,17 @@ CanvasRenderingContext2D::DrawImage(cons
imgSize = gfx::IntSize(imageBitmap.Width(), imageBitmap.Height());
}
else {
if (aImage.IsHTMLImageElement()) {
HTMLImageElement* img = &aImage.GetAsHTMLImageElement();
element = img;
} else {
HTMLVideoElement* video = &aImage.GetAsHTMLVideoElement();
+ video->MarkAsContentSource(mozilla::dom::HTMLVideoElement::CallerAPI::DRAW_IMAGE);
element = video;
}
srcSurf =
CanvasImageCache::LookupCanvas(element, mCanvasElement, &imgSize, mIsSkiaGL);
}
nsLayoutUtils::DirectDrawInfo drawInfo;
--- a/dom/canvas/ImageBitmap.cpp
+++ b/dom/canvas/ImageBitmap.cpp
@@ -788,16 +788,18 @@ ImageBitmap::CreateInternal(nsIGlobalObj
return ret.forget();
}
/* static */ already_AddRefed<ImageBitmap>
ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, HTMLVideoElement& aVideoEl,
const Maybe<IntRect>& aCropRect, ErrorResult& aRv)
{
+ aVideoEl.MarkAsContentSource(mozilla::dom::HTMLVideoElement::CallerAPI::CREATE_IMAGEBITMAP);
+
// Check network state.
if (aVideoEl.NetworkState() == HTMLMediaElement::NETWORK_EMPTY) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
// Check ready state.
// Cannot be HTMLMediaElement::HAVE_NOTHING or HTMLMediaElement::HAVE_METADATA.
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -2541,16 +2541,18 @@ HTMLMediaElement::AddCaptureMediaTrackTo
already_AddRefed<DOMMediaStream>
HTMLMediaElement::CaptureStreamInternal(bool aFinishWhenEnded,
bool aCaptureAudio,
MediaStreamGraph* aGraph)
{
MOZ_RELEASE_ASSERT(aGraph);
+ MarkAsContentSource(CallerAPI::CAPTURE_STREAM);
+
nsPIDOMWindowInner* window = OwnerDoc()->GetInnerWindow();
if (!window) {
return nullptr;
}
#ifdef MOZ_EME
if (ContainsRestrictedContent()) {
return nullptr;
}