forked from mirrors/gecko-dev
Bug 1647430 - part2 : store DocTreeHadAudibleMedia in WindowContext. r=nika
After we enable Fissions, we can't always access the top level document because it might be in another process. Therefore, we should move `mDocTreeHadAudibleMedia` from document to the top window context, which can ensure that we set the value correctly even if setting `mDocTreeHadAudibleMedia` happens in a different process which is different from the process where the top level document exists. Differential Revision: https://phabricator.services.mozilla.com/D83162
This commit is contained in:
parent
f88c326e31
commit
37f08f36a0
5 changed files with 18 additions and 15 deletions
|
|
@ -162,6 +162,11 @@ bool WindowContext::CanSet(FieldIndex<IDX_IsSecureContext>,
|
|||
return CheckOnlyOwningProcessCanSet(aSource);
|
||||
}
|
||||
|
||||
bool WindowContext::CanSet(FieldIndex<IDX_DocTreeHadAudibleMedia>,
|
||||
const bool& aValue, ContentParent* aSource) {
|
||||
return GetBrowsingContext()->IsTop();
|
||||
}
|
||||
|
||||
bool WindowContext::CanSet(FieldIndex<IDX_AutoplayPermission>,
|
||||
const uint32_t& aValue, ContentParent* aSource) {
|
||||
return CheckOnlyOwningProcessCanSet(aSource);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ class BrowsingContextGroup;
|
|||
* mixed content loads to happen */ \
|
||||
FIELD(AllowMixedContent, bool) \
|
||||
FIELD(EmbedderPolicy, nsILoadInfo::CrossOriginEmbedderPolicy) \
|
||||
/* True if this document tree contained an HTMLMediaElement that \
|
||||
* played audibly. This should only be set on top level context. */ \
|
||||
FIELD(DocTreeHadAudibleMedia, bool) \
|
||||
FIELD(AutoplayPermission, uint32_t) \
|
||||
FIELD(DelegatedPermissions, \
|
||||
PermissionDelegateHandler::DelegatedPermissionList) \
|
||||
|
|
@ -161,6 +164,8 @@ class WindowContext : public nsISupports, public nsWrapperCache {
|
|||
ContentParent* aSource);
|
||||
bool CanSet(FieldIndex<IDX_IsSecureContext>, const bool& aIsSecureContext,
|
||||
ContentParent* aSource);
|
||||
bool CanSet(FieldIndex<IDX_DocTreeHadAudibleMedia>, const bool& aValue,
|
||||
ContentParent* aSource);
|
||||
bool CanSet(FieldIndex<IDX_AutoplayPermission>, const uint32_t& aValue,
|
||||
ContentParent* aSource);
|
||||
bool CanSet(FieldIndex<IDX_SHEntryHasUserInteraction>,
|
||||
|
|
|
|||
|
|
@ -1320,7 +1320,6 @@ Document::Document(const char* aContentType)
|
|||
mParserAborted(false),
|
||||
mReportedUseCounters(false),
|
||||
mHasReportedShadowDOMUsage(false),
|
||||
mDocTreeHadAudibleMedia(false),
|
||||
mDocTreeHadPlayRevoked(false),
|
||||
mHasDelayedRefreshEvent(false),
|
||||
mLoadEventFiring(false),
|
||||
|
|
@ -1906,11 +1905,6 @@ Document::~Document() {
|
|||
ScalarAdd(Telemetry::ScalarID::MATHML_DOC_COUNT, 1);
|
||||
}
|
||||
|
||||
ScalarAdd(Telemetry::ScalarID::MEDIA_PAGE_COUNT, 1);
|
||||
if (mDocTreeHadAudibleMedia) {
|
||||
ScalarAdd(Telemetry::ScalarID::MEDIA_PAGE_HAD_MEDIA_COUNT, 1);
|
||||
}
|
||||
|
||||
if (IsHTMLDocument()) {
|
||||
switch (GetCompatibilityMode()) {
|
||||
case eCompatibility_FullStandards:
|
||||
|
|
@ -15276,12 +15270,10 @@ bool Document::ConsumeTransientUserGestureActivation() {
|
|||
}
|
||||
|
||||
void Document::SetDocTreeHadAudibleMedia() {
|
||||
Document* topLevelDoc = GetTopLevelContentDocument();
|
||||
if (!topLevelDoc) {
|
||||
return;
|
||||
RefPtr<WindowContext> topWc = GetTopLevelWindowContext();
|
||||
if (topWc && !topWc->GetDocTreeHadAudibleMedia()) {
|
||||
topWc->SetDocTreeHadAudibleMedia(true);
|
||||
}
|
||||
|
||||
topLevelDoc->mDocTreeHadAudibleMedia = true;
|
||||
}
|
||||
|
||||
void Document::SetDocTreeHadPlayRevoked() {
|
||||
|
|
|
|||
|
|
@ -4544,10 +4544,6 @@ class Document : public nsINode,
|
|||
|
||||
bool mHasReportedShadowDOMUsage : 1;
|
||||
|
||||
// True if this document contained, either directly or in a subdocument,
|
||||
// an HTMLMediaElement that played audibly. This should only be set on
|
||||
// top level content documents.
|
||||
bool mDocTreeHadAudibleMedia : 1;
|
||||
// True if this document contained, either directly or in a subdocument,
|
||||
// an HTMLMediaElement that was playing inaudibly and became audible and we
|
||||
// paused the HTMLMediaElement because it wasn't allowed to autoplay audibly.
|
||||
|
|
|
|||
|
|
@ -724,6 +724,11 @@ void WindowGlobalParent::ActorDestroy(ActorDestroyReason aWhy) {
|
|||
mixedContentLevel = MIXED_DISPLAY_CONTENT;
|
||||
}
|
||||
Accumulate(Telemetry::MIXED_CONTENT_PAGE_LOAD, mixedContentLevel);
|
||||
|
||||
ScalarAdd(Telemetry::ScalarID::MEDIA_PAGE_COUNT, 1);
|
||||
if (GetDocTreeHadAudibleMedia()) {
|
||||
ScalarAdd(Telemetry::ScalarID::MEDIA_PAGE_HAD_MEDIA_COUNT, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// If there are any non-discarded nested contexts when this WindowContext is
|
||||
|
|
|
|||
Loading…
Reference in a new issue