Bug 1705978 - Part 1: Track whether BrowsingContext is embedded in a content document, r=smaug

This will be used by APZ in a follow-up patch.

Differential Revision: https://phabricator.services.mozilla.com/D156721
This commit is contained in:
Nika Layzell 2022-09-12 06:20:38 +00:00
parent 4977904f7f
commit a696fb5ae6
2 changed files with 14 additions and 1 deletions

View File

@ -368,6 +368,8 @@ already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
MOZ_DIAGNOSTIC_ASSERT(parentBC->Group() == group);
MOZ_DIAGNOSTIC_ASSERT(parentBC->mType == aType);
fields.mEmbedderInnerWindowId = aParent->WindowID();
// Non-toplevel content documents are always embededed within content.
fields.mEmbeddedInContentDocument = parentBC->mType == Type::Content;
// XXX(farre): Can/Should we check aParent->IsLoading() here? (Bug
// 1608448) Check if the parent was itself loading already
@ -717,6 +719,8 @@ void BrowsingContext::SetEmbedderElement(Element* aEmbedder) {
if (aEmbedder) {
Transaction txn;
txn.SetEmbedderElementType(Some(aEmbedder->LocalName()));
txn.SetEmbeddedInContentDocument(
aEmbedder->OwnerDoc()->IsContentDocument());
if (nsCOMPtr<nsPIDOMWindowInner> inner =
do_QueryInterface(aEmbedder->GetOwnerGlobal())) {
txn.SetEmbedderInnerWindowId(inner->WindowID());

View File

@ -251,7 +251,11 @@ struct EmbedderColorSchemes {
FIELD(ParentInitiatedNavigationEpoch, uint64_t) \
/* This browsing context is for a synthetic image document wrapping an \
* image embedded in <object> or <embed>. */ \
FIELD(SyntheticDocumentContainer, bool)
FIELD(SyntheticDocumentContainer, bool) \
/* If true, this document is embedded within a content document, either \
* loaded in the parent (e.g. about:addons or the devtools toolbox), or in \
* a content process. */ \
FIELD(EmbeddedInContentDocument, bool)
// BrowsingContext, in this context, is the cross process replicated
// environment in which information about documents is stored. In
@ -1209,6 +1213,11 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
bool CanSet(FieldIndex<IDX_HasRestoreData>, bool aNewValue,
ContentParent* aSource);
bool CanSet(FieldIndex<IDX_EmbeddedInContentDocument>, bool,
ContentParent* aSource) {
return CheckOnlyEmbedderCanSet(aSource);
}
template <size_t I, typename T>
bool CanSet(FieldIndex<I>, const T&, ContentParent*) {
return true;