Bug 1282710 part 2 - Plumb the visibility event from nsIFrame to nsIDOMMediaElemnt; r=seth draft
authorKaku Kuo <tkuo@mozilla.com>
Wed, 29 Jun 2016 17:36:24 +0800
changeset 383430 4e9de97f321492a4035e80312b682cbd0f20980d
parent 383429 9bb393314e33d7352a485d6013540ae87b2aeb9e
child 524478 ba43faaebdba3fd1a1ed4469c91e9fa03300d698
push id22024
push usertkuo@mozilla.com
push dateMon, 04 Jul 2016 05:32:04 +0000
reviewersseth
bugs1282710
milestone50.0a1
Bug 1282710 part 2 - Plumb the visibility event from nsIFrame to nsIDOMMediaElemnt; r=seth MozReview-Commit-ID: DnlTghYdrug
layout/generic/nsVideoFrame.cpp
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -660,25 +660,26 @@ nsVideoFrame::AttributeChanged(int32_t a
                                             aModType);
 }
 
 void
 nsVideoFrame::OnVisibilityChange(Visibility aOldVisibility,
                                  Visibility aNewVisibility,
                                  Maybe<OnNonvisible> aNonvisibleAction)
 {
-  nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mPosterImage);
-  if (!imageLoader) {
-    nsContainerFrame::OnVisibilityChange(aOldVisibility, aNewVisibility,
-                                         aNonvisibleAction);
-    return;
+  if (HasVideoElement()) {
+    nsCOMPtr<nsIDOMHTMLMediaElement> mediaDomElement = do_QueryInterface(mContent);
+    mediaDomElement->OnVisibilityChange(aOldVisibility, aNewVisibility);
   }
 
-  imageLoader->OnVisibilityChange(aOldVisibility, aNewVisibility,
-                                  aNonvisibleAction);
+  nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mPosterImage);
+  if (imageLoader) {
+    imageLoader->OnVisibilityChange(aOldVisibility, aNewVisibility,
+                                    aNonvisibleAction);
+  }
 
   nsContainerFrame::OnVisibilityChange(aOldVisibility, aNewVisibility,
                                        aNonvisibleAction);
 }
 
 bool nsVideoFrame::HasVideoElement() {
   nsCOMPtr<nsIDOMHTMLMediaElement> mediaDomElement = do_QueryInterface(mContent);
   return mediaDomElement->IsVideo();