@@ -422,13 +422,15 @@ already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
422
422
423
423
fields.Get <IDX_HistoryID>() = nsID::GenerateUUID ();
424
424
fields.Get <IDX_ExplicitActive>() = [&] {
425
- if (parentBC || aType == Type::Content ) {
425
+ if (parentBC) {
426
426
// Non-root browsing-contexts inherit their status from its parent.
427
- // Top-content either gets managed by the top chrome, or gets manually
428
- // managed by the front-end (see ManuallyManagesActiveness). In any case
429
- // we want to start off as inactive.
430
427
return ExplicitActiveStatus::None;
431
428
}
429
+ if (aType == Type::Content) {
430
+ // Content gets managed by the chrome front-end / embedder element and
431
+ // starts as inactive.
432
+ return ExplicitActiveStatus::Inactive;
433
+ }
432
434
// Chrome starts as active.
433
435
return ExplicitActiveStatus::Active;
434
436
}();
@@ -737,24 +739,21 @@ void BrowsingContext::SetEmbedderElement(Element* aEmbedder) {
737
739
txn.SetEmbedderInnerWindowId (inner->WindowID ());
738
740
}
739
741
txn.SetFullscreenAllowedByOwner (OwnerAllowsFullscreen (*aEmbedder));
740
- if (XRE_IsParentProcess () && aEmbedder-> IsXULElement () && IsTopContent ()) {
742
+ if (XRE_IsParentProcess () && IsTopContent ()) {
741
743
nsAutoString messageManagerGroup;
742
- aEmbedder->GetAttr (nsGkAtoms::messagemanagergroup, messageManagerGroup);
743
- txn.SetMessageManagerGroup (messageManagerGroup);
744
- txn.SetUseGlobalHistory (
745
- !aEmbedder->HasAttr (nsGkAtoms::disableglobalhistory));
746
- if (!aEmbedder->HasAttr (nsGkAtoms::manualactiveness)) {
747
- // We're active iff the parent cross-chrome-boundary is active. Note we
748
- // can't just use this->Canonical()->GetParentCrossChromeBoundary here,
749
- // since mEmbedderElement is still null at this point.
750
- RefPtr bc = aEmbedder->OwnerDoc ()->GetBrowsingContext ();
751
- const bool isActive = bc && bc->IsActive ();
752
- txn.SetExplicitActive (isActive ? ExplicitActiveStatus::Active
753
- : ExplicitActiveStatus::Inactive);
754
- if (auto * bp = Canonical ()->GetBrowserParent ()) {
755
- bp->SetRenderLayers (isActive);
744
+ if (aEmbedder->IsXULElement ()) {
745
+ aEmbedder->GetAttr (nsGkAtoms::messagemanagergroup, messageManagerGroup);
746
+ if (!aEmbedder->AttrValueIs (kNameSpaceID_None ,
747
+ nsGkAtoms::initiallyactive,
748
+ nsGkAtoms::_false, eIgnoreCase)) {
749
+ txn.SetExplicitActive (ExplicitActiveStatus::Active);
756
750
}
757
751
}
752
+ txn.SetMessageManagerGroup (messageManagerGroup);
753
+
754
+ bool useGlobalHistory =
755
+ !aEmbedder->HasAttr (nsGkAtoms::disableglobalhistory);
756
+ txn.SetUseGlobalHistory (useGlobalHistory);
758
757
}
759
758
760
759
MOZ_ALWAYS_SUCCEEDS (txn.Commit (this ));
@@ -2635,16 +2634,8 @@ void BrowsingContext::DidSet(FieldIndex<IDX_GVInaudibleAutoplayRequestStatus>) {
2635
2634
" browsing context" );
2636
2635
}
2637
2636
2638
- bool BrowsingContext::CanSet (FieldIndex<IDX_ExplicitActive>,
2639
- const ExplicitActiveStatus&,
2640
- ContentParent* aSource) {
2641
- return XRE_IsParentProcess () && IsTop () && !aSource;
2642
- }
2643
-
2644
2637
void BrowsingContext::DidSet (FieldIndex<IDX_ExplicitActive>,
2645
2638
ExplicitActiveStatus aOldValue) {
2646
- MOZ_ASSERT (IsTop ());
2647
-
2648
2639
const bool isActive = IsActive ();
2649
2640
const bool wasActive = [&] {
2650
2641
if (aOldValue != ExplicitActiveStatus::None) {
@@ -2657,43 +2648,32 @@ void BrowsingContext::DidSet(FieldIndex<IDX_ExplicitActive>,
2657
2648
return ;
2658
2649
}
2659
2650
2660
- Group ()->UpdateToplevelsSuspendedIfNeeded ();
2661
- if (XRE_IsParentProcess ()) {
2662
- if (BrowserParent* bp = Canonical ()->GetBrowserParent ()) {
2663
- bp->RecomputeProcessPriority ();
2651
+ if (IsTop ()) {
2652
+ Group ()->UpdateToplevelsSuspendedIfNeeded ();
2653
+
2654
+ if (XRE_IsParentProcess ()) {
2655
+ auto * bc = Canonical ();
2656
+ if (BrowserParent* bp = bc->GetBrowserParent ()) {
2657
+ bp->RecomputeProcessPriority ();
2664
2658
#if defined(XP_WIN) && defined(ACCESSIBILITY)
2665
- if (a11y::Compatibility::IsDolphin ()) {
2666
- // update active accessible documents on windows
2667
- if (a11y::DocAccessibleParent* tabDoc =
2668
- bp->GetTopLevelDocAccessible ()) {
2669
- HWND window = tabDoc->GetEmulatedWindowHandle ();
2670
- MOZ_ASSERT (window);
2671
- if (window) {
2672
- if (isActive) {
2673
- a11y::nsWinUtils::ShowNativeWindow (window);
2674
- } else {
2675
- a11y::nsWinUtils::HideNativeWindow (window);
2659
+ if (a11y::Compatibility::IsDolphin ()) {
2660
+ // update active accessible documents on windows
2661
+ if (a11y::DocAccessibleParent* tabDoc =
2662
+ bp->GetTopLevelDocAccessible ()) {
2663
+ HWND window = tabDoc->GetEmulatedWindowHandle ();
2664
+ MOZ_ASSERT (window);
2665
+ if (window) {
2666
+ if (isActive) {
2667
+ a11y::nsWinUtils::ShowNativeWindow (window);
2668
+ } else {
2669
+ a11y::nsWinUtils::HideNativeWindow (window);
2670
+ }
2676
2671
}
2677
2672
}
2678
2673
}
2679
- }
2680
2674
#endif
2681
- }
2682
-
2683
- // NOTE(emilio): Ideally we'd want to reuse the ExplicitActiveStatus::None
2684
- // set-up, but that's non-trivial to do because in content processes we
2685
- // can't access the top-cross-chrome-boundary bc.
2686
- auto manageTopDescendant = [&](auto * aChild) {
2687
- if (!aChild->ManuallyManagesActiveness ()) {
2688
- aChild->SetIsActiveInternal (isActive, IgnoreErrors ());
2689
- if (BrowserParent* bp = aChild->GetBrowserParent ()) {
2690
- bp->SetRenderLayers (isActive);
2691
- }
2692
2675
}
2693
- return CallState::Continue;
2694
- };
2695
- Canonical ()->CallOnAllTopDescendants (manageTopDescendant,
2696
- /* aIncludeNestedBrowsers = */ false );
2676
+ }
2697
2677
}
2698
2678
2699
2679
PreOrderWalk ([&](BrowsingContext* aContext) {
0 commit comments