mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1877879 - Implement isActiveInTab and use it for PromptParent. r=smaug,Gijs
Differential Revision: https://phabricator.services.mozilla.com/D200245
This commit is contained in:
parent
ce1354921c
commit
cb6d45ee22
@ -132,7 +132,7 @@ export class PromptParent extends JSWindowActorParent {
|
||||
|
||||
switch (message.name) {
|
||||
case "Prompt:Open":
|
||||
if (!this.windowContext.isCurrentGlobal) {
|
||||
if (!this.windowContext.isActiveInTab) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,11 @@ interface WindowGlobalParent : WindowContext {
|
||||
|
||||
readonly attribute boolean isCurrentGlobal;
|
||||
|
||||
// This should return true if the window is currently visible in its tab.
|
||||
// (A more technically accurate name would be something like
|
||||
// "isActiveInRootNavigable".)
|
||||
readonly attribute boolean isActiveInTab;
|
||||
|
||||
readonly attribute unsigned long long outerWindowId;
|
||||
readonly attribute unsigned long long contentParentId;
|
||||
|
||||
|
@ -661,6 +661,23 @@ bool WindowGlobalParent::IsCurrentGlobal() {
|
||||
return CanSend() && BrowsingContext()->GetCurrentWindowGlobal() == this;
|
||||
}
|
||||
|
||||
bool WindowGlobalParent::IsActiveInTab() {
|
||||
if (!CanSend()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CanonicalBrowsingContext* bc = BrowsingContext();
|
||||
if (!bc || bc->GetCurrentWindowGlobal() != this) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We check the top BC so we don't need to worry about getting a stale value.
|
||||
// That may not be necessary.
|
||||
MOZ_ASSERT(bc->Top()->IsInBFCache() == bc->IsInBFCache(),
|
||||
"BFCache bit out of sync?");
|
||||
return bc->AncestorsAreCurrent() && !bc->Top()->IsInBFCache();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class ShareHandler final : public PromiseNativeHandler {
|
||||
|
@ -145,6 +145,8 @@ class WindowGlobalParent final : public WindowContext,
|
||||
|
||||
bool IsCurrentGlobal();
|
||||
|
||||
bool IsActiveInTab();
|
||||
|
||||
bool IsProcessRoot();
|
||||
|
||||
uint32_t ContentBlockingEvents();
|
||||
|
Loading…
Reference in New Issue
Block a user