diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index 90d7bc867079..d85027c25528 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -665,15 +665,16 @@ nsVideoFrame::OnVisibilityChange(Visibility aOldVisibility, Visibility aNewVisibility, Maybe aNonvisibleAction) { - nsCOMPtr imageLoader = do_QueryInterface(mPosterImage); - if (!imageLoader) { - nsContainerFrame::OnVisibilityChange(aOldVisibility, aNewVisibility, - aNonvisibleAction); - return; + if (HasVideoElement()) { + nsCOMPtr mediaDomElement = do_QueryInterface(mContent); + mediaDomElement->OnVisibilityChange(aOldVisibility, aNewVisibility); } - imageLoader->OnVisibilityChange(aOldVisibility, aNewVisibility, - aNonvisibleAction); + nsCOMPtr imageLoader = do_QueryInterface(mPosterImage); + if (imageLoader) { + imageLoader->OnVisibilityChange(aOldVisibility, aNewVisibility, + aNonvisibleAction); + } nsContainerFrame::OnVisibilityChange(aOldVisibility, aNewVisibility, aNonvisibleAction);