Skip to content

Commit 644a6bc

Browse files
committed
Bug 1870512 - Simplify ShouldAttachToTopLevel(), and revert patch for bug 1869891. r=tnikkel
Definitely not for 122, but I think we should try this. Note that this doesn't affect nsMenuPopupFrames, which create the widget on their own here: https://searchfox.org/mozilla-central/rev/07937a5d00e0f65611d8b3bd2992c7603aeaa70d/layout/xul/nsMenuPopupFrame.cpp#266 It only affects windows with popup=yes, which right now are only the nsXULAlerts windows. I'll look into trying to unify the macOS set-up, which right now unconditionally uses this (presumably to get an nsChildView for each top-level nsCocoaWindow). Maybe that can be handled internally by the widget layer, we'll see. Differential Revision: https://phabricator.services.mozilla.com/D196664
1 parent 7b521ee commit 644a6bc

File tree

2 files changed

+10
-29
lines changed

2 files changed

+10
-29
lines changed

layout/base/PresShell.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11607,14 +11607,6 @@ void PresShell::SyncWindowProperties(bool aSync) {
1160711607
windowWidget->SetTransparencyMode(mode);
1160811608
windowWidget->SetWindowShadowStyle(shadow);
1160911609

11610-
nsCOMPtr<nsIWidget> viewWidget = view->GetWidget();
11611-
if (viewWidget != windowWidget) {
11612-
// Happens on macOS (where we have an nsChildView as a child of an
11613-
// nsCocoaWindow), and in popup=yes windows in other platforms, in
11614-
// practice.
11615-
viewWidget->SetTransparencyMode(mode);
11616-
}
11617-
1161811610
// For macOS, apply color scheme overrides to the top level window widget.
1161911611
if (auto scheme = pc->GetOverriddenOrEmbedderColorScheme()) {
1162011612
windowWidget->SetColorScheme(scheme);

layout/base/nsDocumentViewer.cpp

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3252,33 +3252,22 @@ bool nsDocumentViewer::ShouldAttachToTopLevel() {
32523252
return false;
32533253
}
32543254

3255-
if (!mContainer) {
3256-
return false;
3257-
}
3258-
32593255
// We always attach when using puppet widgets
32603256
if (nsIWidget::UsePuppetWidgets()) {
32613257
return true;
32623258
}
32633259

3264-
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || \
3265-
defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_UIKIT)
3266-
if (!mPresContext) {
3267-
return false;
3268-
}
3269-
3270-
// On windows, in the parent process we also attach, but just to
3271-
// chrome items
3272-
auto winType = mParentWidget->GetWindowType();
3273-
if ((winType == widget::WindowType::TopLevel ||
3274-
winType == widget::WindowType::Dialog ||
3275-
winType == widget::WindowType::Invisible) &&
3276-
mPresContext->IsChrome()) {
3277-
return true;
3278-
}
3279-
#endif
3280-
3260+
// FIXME(emilio): Can we unify this between macOS and aother platforms?
3261+
#ifdef XP_MACOSX
32813262
return false;
3263+
#else
3264+
# ifdef DEBUG
3265+
nsIWidgetListener* parentListener = mParentWidget->GetWidgetListener();
3266+
MOZ_ASSERT(!parentListener || !parentListener->GetView(),
3267+
"Expect a top level widget");
3268+
# endif
3269+
return true;
3270+
#endif
32823271
}
32833272

32843273
//------------------------------------------------------------

0 commit comments

Comments
 (0)