Bug 1585070 - move nsPIDOMWindowOuter::mIsActive to BrowsingContext. r=kmag
A new `BrowsingContext` field has been added to track the active browser window for the `:-moz-window-inactive` pseudoclass. This field takes the place of `nsPIDOMWindowOuter::mIsActive`. With this change `:-moz-window-inactive` is now fission compatible. Differential Revision: https://phabricator.services.mozilla.com/D86422
This commit is contained in:
@@ -542,6 +542,23 @@ void BrowsingContext::CleanUpDanglingRemoteOuterWindowProxies(
|
||||
js::RemapRemoteWindowProxies(aCx, &cb, aOuter);
|
||||
}
|
||||
|
||||
bool BrowsingContext::GetIsActiveBrowserWindow() {
|
||||
if (!XRE_IsParentProcess()) {
|
||||
return Top()->GetIsActiveBrowserWindowInternal();
|
||||
}
|
||||
|
||||
// chrome:// urls loaded in the parent won't receive
|
||||
// their own activation so we defer to the top chrome
|
||||
// Browsing Context when in the parent process.
|
||||
RefPtr<CanonicalBrowsingContext> chromeTop =
|
||||
Canonical()->TopCrossChromeBoundary();
|
||||
return chromeTop->GetIsActiveBrowserWindowInternal();
|
||||
}
|
||||
|
||||
void BrowsingContext::SetIsActiveBrowserWindow(bool aActive) {
|
||||
Unused << SetIsActiveBrowserWindowInternal(aActive);
|
||||
}
|
||||
|
||||
bool BrowsingContext::FullscreenAllowed() const {
|
||||
for (auto* current = this; current; current = current->GetParent()) {
|
||||
if (!current->GetFullscreenAllowedByOwner()) {
|
||||
@@ -2311,6 +2328,36 @@ bool BrowsingContext::CheckOnlyOwningProcessCanSet(ContentParent* aSource) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BrowsingContext::CanSet(FieldIndex<IDX_IsActiveBrowserWindowInternal>,
|
||||
const bool& aValue, ContentParent* aSource) {
|
||||
// Should only be set in the parent process.
|
||||
return XRE_IsParentProcess() && !aSource && IsTop();
|
||||
}
|
||||
|
||||
void BrowsingContext::DidSet(FieldIndex<IDX_IsActiveBrowserWindowInternal>,
|
||||
bool aOldValue) {
|
||||
bool isActivateEvent = GetIsActiveBrowserWindowInternal();
|
||||
// The browser window containing this context has changed
|
||||
// activation state so update window inactive document states
|
||||
// for all in-process documents.
|
||||
PreOrderWalk([isActivateEvent](BrowsingContext* aContext) {
|
||||
if (RefPtr<Document> doc = aContext->GetExtantDocument()) {
|
||||
doc->UpdateDocumentStates(NS_DOCUMENT_STATE_WINDOW_INACTIVE, true);
|
||||
|
||||
if (XRE_IsContentProcess() &&
|
||||
(!aContext->GetParent() || !aContext->GetParent()->IsInProcess())) {
|
||||
// Send the inner window an activate/deactivate event if
|
||||
// the context is the top of a sub-tree of in-process
|
||||
// contexts.
|
||||
nsContentUtils::DispatchEventOnlyToChrome(
|
||||
doc, doc->GetWindow()->GetCurrentInnerWindow(),
|
||||
isActivateEvent ? u"activate"_ns : u"deactivate"_ns,
|
||||
CanBubble::eYes, Cancelable::eYes, nullptr);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool BrowsingContext::CanSet(FieldIndex<IDX_AllowContentRetargeting>,
|
||||
const bool& aAllowContentRetargeting,
|
||||
ContentParent* aSource) {
|
||||
|
||||
Reference in New Issue
Block a user