From 595dccd4e76e24fee11f7ec8658f08997c049944 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Wed, 7 Feb 2018 15:28:48 +1300 Subject: [PATCH] Bug 1431674 - Backed out changeset 9d197f1860e6. r=backout MozReview-Commit-ID: wP0aucXgzA --HG-- extra : rebase_source : ad67234e7dff431c875bce5aac5b88e3c497dc78 --- dom/base/nsDocument.cpp | 1 + dom/html/HTMLMediaElement.cpp | 121 +--------------------------------- dom/html/HTMLMediaElement.h | 2 - 3 files changed, 2 insertions(+), 122 deletions(-) diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 131fc69d0b79..597e681104a8 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -8816,6 +8816,7 @@ nsDocument::OnPageHide(bool aPersisted, mVisible = false; UpdateVisibilityState(); + EnumerateExternalResources(NotifyPageHide, &aPersisted); EnumerateActivityObservers(NotifyActivityChanged, nullptr); diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 54fdeaa27f39..f3f8551b9596 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -24,7 +24,6 @@ #include "TimeRanges.h" #include "nsGenericHTMLElement.h" #include "nsAttrValueInlines.h" -#include "nsDocShellLoadTypes.h" #include "nsPresContext.h" #include "nsIClassOfService.h" #include "nsIPresShell.h" @@ -3950,105 +3949,6 @@ private: NS_IMPL_ISUPPORTS(HTMLMediaElement::ShutdownObserver, nsIObserver) -class HTMLMediaElement::ForceReloadListener : public nsIWebProgressListener - , public nsSupportsWeakReference -{ -public: - NS_DECL_ISUPPORTS - - void Subscribe(HTMLMediaElement* aPtr, nsIWebProgress* aWebProgress) - { - MOZ_DIAGNOSTIC_ASSERT(!mWeak); - MOZ_DIAGNOSTIC_ASSERT(aWebProgress); - mWeak = aPtr; - aWebProgress->AddProgressListener(this, - nsIWebProgress::NOTIFY_STATE_NETWORK); - } - void Unsubscribe(nsIWebProgress* aWebProgress) - { - MOZ_DIAGNOSTIC_ASSERT(mWeak); - mWeak = nullptr; - if (aWebProgress) { - aWebProgress->RemoveProgressListener(this); - } - } - - NS_IMETHODIMP OnStateChange(nsIWebProgress* aWebProgress, - nsIRequest* aRequest, - uint32_t aProgressStateFlags, - nsresult aStatus) override - { - MOZ_DIAGNOSTIC_ASSERT(mWeak); - if ((aProgressStateFlags & STATE_IS_NETWORK) && - (aProgressStateFlags & STATE_START)) { - // Query the LoadType to see if it's a ctrl+F5. - nsCOMPtr shell(do_QueryInterface(aWebProgress)); - if (shell) { - uint32_t loadType; - shell->GetLoadType(&loadType); - if (LOAD_RELOAD_BYPASS_PROXY_AND_CACHE == loadType && mWeak->mDecoder) { - mWeak->ShutdownDecoder(); - } - } - } - return NS_OK; - } - - NS_IMETHODIMP - OnProgressChange(nsIWebProgress* aProgress, - nsIRequest* aRequest, - int32_t aCurSelfProgress, - int32_t aMaxSelfProgress, - int32_t aCurTotalProgress, - int32_t aMaxTotalProgress) override - { - NS_NOTREACHED("notification excluded in AddProgressListener(...)"); - return NS_OK; - } - - NS_IMETHODIMP - OnLocationChange(nsIWebProgress* aWebProgress, - nsIRequest* aRequest, - nsIURI* aLocation, - uint32_t aFlags) override - { - NS_NOTREACHED("notification excluded in AddProgressListener(...)"); - return NS_OK; - } - - NS_IMETHODIMP - OnStatusChange(nsIWebProgress* aWebProgress, - nsIRequest* aRequest, - nsresult aStatus, - const char16_t* aMessage) override - { - NS_NOTREACHED("notification excluded in AddProgressListener(...)"); - return NS_OK; - } - - NS_IMETHODIMP - OnSecurityChange(nsIWebProgress* aWebProgress, - nsIRequest* aRequest, - uint32_t aState) override - { - NS_NOTREACHED("notification excluded in AddProgressListener(...)"); - return NS_OK; - } - -protected: - virtual ~ForceReloadListener() - { - MOZ_DIAGNOSTIC_ASSERT(!mWeak); - } - -private: - HTMLMediaElement* mWeak = nullptr; -}; - -NS_IMPL_ISUPPORTS(HTMLMediaElement::ForceReloadListener, - nsIWebProgressListener, - nsISupportsWeakReference) - HTMLMediaElement::HTMLMediaElement(already_AddRefed& aNodeInfo) : nsGenericHTMLElement(aNodeInfo), mMainThreadEventTarget(OwnerDoc()->EventTargetFor(TaskCategory::Other)), @@ -4123,33 +4023,14 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed& aNo NotifyOwnerDocumentActivityChanged(); mShutdownObserver->Subscribe(this); - nsIDocShell* docShell = OwnerDoc()->GetDocShell(); - if (docShell) { - nsCOMPtr root; - docShell->GetSameTypeRootTreeItem(getter_AddRefs(root)); - nsCOMPtr webProgress = do_GetInterface(root); - if (webProgress) { - mForceReloadListener = new ForceReloadListener(); - mForceReloadListener->Subscribe(this, webProgress); - } - } } HTMLMediaElement::~HTMLMediaElement() { NS_ASSERTION(!mHasSelfReference, "How can we be destroyed if we're still holding a self reference?"); + mShutdownObserver->Unsubscribe(); - nsIDocShell* docShell = OwnerDoc()->GetDocShell(); - nsCOMPtr webProgress; - if (docShell) { - nsCOMPtr root; - docShell->GetSameTypeRootTreeItem(getter_AddRefs(root)); - webProgress = do_GetInterface(root); - } - if (mForceReloadListener) { - mForceReloadListener->Unsubscribe(webProgress); - } if (mVideoFrameContainer) { mVideoFrameContainer->ForgetElement(); diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h index 047ce6dd9fef..8e68057ac572 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -813,7 +813,6 @@ protected: class StreamListener; class StreamSizeListener; class ShutdownObserver; - class ForceReloadListener; MediaDecoderOwner::NextFrameStatus NextFrameStatus(); @@ -1403,7 +1402,6 @@ protected: RefPtr mSelectedVideoStreamTrack; const RefPtr mShutdownObserver; - RefPtr mForceReloadListener; // Holds a reference to the MediaSource, if any, referenced by the src // attribute on the media element.