author | Edgar Chen <echen@mozilla.com> |
Tue, 27 Aug 2019 21:22:19 +0000 | |
changeset 490477 | ab1e0dacd90a8a729b064755a70c8af73618e634 |
parent 490476 | 49c4394e81be207a8dbb9661349f44fe9a3b47b4 |
child 490478 | 1d7d0461c58297298478a016aede70cefb78e691 |
push id | 36504 |
push user | ccoroiu@mozilla.com |
push date | Thu, 29 Aug 2019 04:08:39 +0000 |
treeherder | mozilla-central@7004b8779a36 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | alwu |
bugs | 1576627 |
milestone | 70.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -14817,30 +14817,16 @@ void Document::NotifyUserGestureActivati bool Document::HasBeenUserGestureActivated() { RefPtr<BrowsingContext> bc = GetBrowsingContext(); if (!bc) { return false; } return bc->GetUserGestureActivation(); } -void Document::MaybeNotifyAutoplayBlocked() { - Document* topLevelDoc = GetTopLevelContentDocument(); - if (!topLevelDoc) { - return; - } - - // This event is used to notify front-end side that we've blocked autoplay, - // so front-end side should show blocking icon as well. - RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher( - topLevelDoc, NS_LITERAL_STRING("GloballyAutoplayBlocked"), - CanBubble::eYes, ChromeOnlyDispatch::eYes); - asyncDispatcher->PostDOMEvent(); -} - void Document::ClearUserGestureActivation() { if (!HasBeenUserGestureActivated()) { return; } RefPtr<BrowsingContext> bc = GetBrowsingContext(); if (!bc) { return; }
--- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -4112,20 +4112,16 @@ class Document : public nsINode, * element containing the subdocument containing aFrame, and/or find the * nearest non-anonymous ancestor in this document. * Returns null if there is no such element. */ nsIContent* GetContentInThisDocument(nsIFrame* aFrame) const; void ReportShadowDOMUsage(); - // When the doc is blocked permanantly, we would dispatch event to notify - // front-end side to show blocking icon. - void MaybeNotifyAutoplayBlocked(); - // Sets flags for media autoplay telemetry. void SetDocTreeHadAudibleMedia(); void SetDocTreeHadPlayRevoked(); dom::XPathEvaluator* XPathEvaluator(); void MaybeInitializeFinalizeFrameLoaders();
--- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -3871,22 +3871,36 @@ void HTMLMediaElement::DispatchEventsWhe DispatchAsyncEvent(NS_LITERAL_STRING("blocked")); } #if defined(MOZ_WIDGET_ANDROID) RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher( this, NS_LITERAL_STRING("MozAutoplayMediaBlocked"), CanBubble::eYes, ChromeOnlyDispatch::eYes); asyncDispatcher->PostDOMEvent(); #endif - OwnerDoc()->MaybeNotifyAutoplayBlocked(); + MaybeNotifyAutoplayBlocked(); ReportToConsole(nsIScriptError::warningFlag, "BlockAutoplayError"); mHasPlayEverBeenBlocked = true; mHasEverBeenBlockedForAutoplay = true; } +void HTMLMediaElement::MaybeNotifyAutoplayBlocked() { + Document* topLevelDoc = OwnerDoc()->GetTopLevelContentDocument(); + if (!topLevelDoc) { + return; + } + + // This event is used to notify front-end side that we've blocked autoplay, + // so front-end side should show blocking icon as well. + RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher( + topLevelDoc, NS_LITERAL_STRING("GloballyAutoplayBlocked"), + CanBubble::eYes, ChromeOnlyDispatch::eYes); + asyncDispatcher->PostDOMEvent(); +} + void HTMLMediaElement::PlayInternal(bool aHandlingUserInput) { if (mPreloadAction == HTMLMediaElement::PRELOAD_NONE) { // The media load algorithm will be initiated by a user interaction. // We want to boost the channel priority for better responsiveness. // Note this must be done before UpdatePreloadAction() which will // update |mPreloadAction|. mUseUrgentStartForChannel = true; } @@ -6094,17 +6108,17 @@ void HTMLMediaElement::SuspendOrResumeEl DispatchPendingMediaEvents(); } // If the media element has been blocked and isn't still allowed to play // when it comes back from the bfcache, we would notify front end to show // the blocking icon in order to inform user that the site is still being // blocked. if (mHasEverBeenBlockedForAutoplay && !AutoplayPolicy::IsAllowedToPlay(*this)) { - OwnerDoc()->MaybeNotifyAutoplayBlocked(); + MaybeNotifyAutoplayBlocked(); } } } } bool HTMLMediaElement::IsBeingDestroyed() { Document* ownerDoc = OwnerDoc(); nsIDocShell* docShell = ownerDoc ? ownerDoc->GetDocShell() : nullptr;
--- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -1301,16 +1301,20 @@ class HTMLMediaElement : public nsGeneri // Calculate the audio track silence proportion and then report the telemetry // result. we would report the result when decoder is destroyed. void ReportAudioTrackSilenceProportionTelemetry(); // When the play is not allowed, dispatch related events which are used for // testing or changing control UI. void DispatchEventsWhenPlayWasNotAllowed(); + // When the doc is blocked permanantly, we would dispatch event to notify + // front-end side to show blocking icon. + void MaybeNotifyAutoplayBlocked(); + // The current decoder. Load() has been called on this decoder. // At most one of mDecoder and mSrcStream can be non-null. RefPtr<MediaDecoder> mDecoder; // The DocGroup-specific nsISerialEventTarget of this HTML element on the main // thread. nsCOMPtr<nsISerialEventTarget> mMainThreadEventTarget;