Bug 1884652 - Remove titlebars on panels and PopupLevel::Floating. r=mac-reviewers,bradwerth

These two features are totally unused and poorly supported.

Both were added in bug 552982, and Wayland doesn't support (nor have a
way of supporting) any of them.

Differential Revision: https://phabricator.services.mozilla.com/D204222
This commit is contained in:
Emilio Cobos Álvarez 2024-03-11 19:42:58 +00:00
Родитель 6031937db5
Коммит c9056b81ba
9 изменённых файлов: 24 добавлений и 114 удалений

Просмотреть файл

@ -220,21 +220,16 @@ widget::PopupLevel nsMenuPopupFrame::GetPopupLevel(bool aIsNoAutoHide) const {
}
// If the level attribute has been set, use that.
static Element::AttrValuesArray strings[] = {
nsGkAtoms::top, nsGkAtoms::parent, nsGkAtoms::floating, nullptr};
static Element::AttrValuesArray strings[] = {nsGkAtoms::top,
nsGkAtoms::parent, nullptr};
switch (mContent->AsElement()->FindAttrValueIn(
kNameSpaceID_None, nsGkAtoms::level, strings, eCaseMatters)) {
case 0:
return PopupLevel::Top;
case 1:
return PopupLevel::Parent;
case 2:
return PopupLevel::Floating;
}
// Panels with titlebars most likely want to be floating popups.
if (mContent->AsElement()->HasAttr(nsGkAtoms::titlebar)) {
return PopupLevel::Floating;
default:
break;
}
// If this panel is a noautohide panel, the default is the parent level.
@ -281,20 +276,6 @@ nsresult nsMenuPopupFrame::CreateWidgetForView(nsView* aView) {
}
}
nsAutoString title;
if (widgetData.mNoAutoHide &&
mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::titlebar,
nsGkAtoms::normal, eCaseMatters)) {
widgetData.mBorderStyle = widget::BorderStyle::Title;
mContent->AsElement()->GetAttr(nsGkAtoms::label, title);
if (mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::close,
nsGkAtoms::_true, eCaseMatters)) {
widgetData.mBorderStyle =
widgetData.mBorderStyle | widget::BorderStyle::Close;
}
}
bool remote = HasRemoteContent();
const auto mode = nsLayoutUtils::GetFrameTransparency(this, this);
@ -328,12 +309,6 @@ nsresult nsMenuPopupFrame::CreateWidgetForView(nsView* aView) {
PropagateStyleToWidget();
// most popups don't have a title so avoid setting the title if there isn't
// one
if (!title.IsEmpty()) {
widget->SetTitle(title);
}
return NS_OK;
}

Просмотреть файл

@ -11,7 +11,6 @@ support-files = [
"windowminmaxsize8.xhtml",
"windowminmaxsize9.xhtml",
"windowminmaxsize10.xhtml",
"titledpanelwindow.xhtml",
]
["test_bug159346.xhtml"]

Просмотреть файл

@ -125,12 +125,10 @@ function doPanelTest(panel)
function nextPopupTest(panel)
{
if (++gTestId >= popupTests.length) {
// Next, check a panel that has a titlebar to ensure that it is accounted for
// properly in the size.
var titledPanelWindow = window.browsingContext.topChromeWindow.open("titledpanelwindow.xhtml", "_blank", "chrome,resizable=yes");
SimpleTest.waitForFocus(titledPanelWindowOpened, titledPanelWindow);
SimpleTest.finish();
return;
}
else {
function setStyle(attr) {
if (attr in popupTests[gTestId])
panel.style[attr] = popupTests[gTestId][attr] + "px";
@ -148,34 +146,6 @@ function nextPopupTest(panel)
// Non-chrome shells require focus to open a popup.
SimpleTest.waitForFocus(() => { panel.openPopup() });
});
}
}
function titledPanelWindowOpened(panelwindow)
{
info("titledPanelWindowOpened");
var panel = panelwindow.document.documentElement.firstChild;
panel.addEventListener("popupshown", () => doTitledPanelTest(panel));
panel.addEventListener("popuphidden", () => done(panelwindow));
// See above as for why.
SimpleTest.executeSoon(() => {
SimpleTest.waitForFocus(() => { panel.openPopup() }, panelwindow);
});
}
function doTitledPanelTest(panel)
{
info("doTitledPanelTest");
var rect = panel.getBoundingClientRect();
is(rect.width, 120, "panel with titlebar width");
is(rect.height, 140, "panel with titlebar height");
panel.hidePopup();
}
function done(panelwindow)
{
panelwindow.close();
SimpleTest.finish();
}
]]>

Просмотреть файл

@ -1,5 +0,0 @@
<?xml-stylesheet href='chrome://global/skin' type='text/css'?>
<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' align='start' pack='start' style='-moz-appearance: none; margin: 0; padding: 0; border: 0;'>
<panel noautohide='true' titlebar='normal' style="background: white; min-width: 120px; min-height: 140px"/>
<label value='Test'/>
</window>

Просмотреть файл

@ -37,11 +37,6 @@ enum class PopupLevel : uint8_t {
// The popup appears just above its parent and maintains its position
// relative to the parent.
Parent,
// The popup is a floating popup used for tool palettes. A parent window must
// be specified, but a platform implementation need not use this. On Windows,
// floating is generally equivalent to parent. On Mac, floating puts the
// popup at toplevel, but it will hide when the application is deactivated.
Floating,
// The popup appears on top of other windows, including those of other
// applications.
Top,

Просмотреть файл

@ -2860,18 +2860,10 @@ void nsCocoaWindow::SetPopupWindowLevel() {
if (!mWindow) {
return;
}
// Floating popups are at the floating level and hide when the window is
// deactivated.
if (mPopupLevel == PopupLevel::Floating) {
mWindow.level = NSFloatingWindowLevel;
mWindow.hidesOnDeactivate = YES;
} else {
// Otherwise, this is a top-level or parent popup. Parent popups always
// appear just above their parent and essentially ignore the level.
mWindow.level = NSPopUpMenuWindowLevel;
mWindow.hidesOnDeactivate = NO;
}
}
void nsCocoaWindow::SetInputContext(const InputContext& aContext,

Просмотреть файл

@ -367,13 +367,6 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
PopupLevel GetPopupLevel() { return mPopupLevel; }
// return true if this is a popup widget with a native titlebar
bool IsPopupWithTitleBar() const {
return (mWindowType == WindowType::Popup &&
mBorderStyle != BorderStyle::Default &&
mBorderStyle & BorderStyle::Title);
}
void ReparentNativeWidget(nsIWidget* aNewParent) override {}
const SizeConstraints GetSizeConstraints() override;

Просмотреть файл

@ -1310,13 +1310,6 @@ DWORD nsWindow::WindowStyle() {
if (mBorderStyle == BorderStyle::None ||
!(mBorderStyle & BorderStyle::Maximize))
style &= ~WS_MAXIMIZEBOX;
if (IsPopupWithTitleBar()) {
style |= WS_CAPTION;
if (mBorderStyle & BorderStyle::Close) {
style |= WS_SYSMENU;
}
}
}
if (mIsChildWindow) {
@ -3664,7 +3657,7 @@ LayoutDeviceIntPoint nsWindow::WidgetToScreenOffset() {
}
LayoutDeviceIntMargin nsWindow::ClientToWindowMargin() {
if (mWindowType == WindowType::Popup && !IsPopupWithTitleBar()) {
if (mWindowType == WindowType::Popup) {
return {};
}

Просмотреть файл

@ -453,7 +453,6 @@ STATIC_ATOMS = [
Atom("flags", "flags"),
Atom("flex", "flex"),
Atom("flip", "flip"),
Atom("floating", "floating"),
Atom("floor", "floor"),
Atom("flowlength", "flowlength"),
Atom("focus", "focus"),
@ -1244,7 +1243,6 @@ STATIC_ATOMS = [
Atom("thumb", "thumb"),
Atom("time", "time"),
Atom("title", "title"),
Atom("titlebar", "titlebar"),
Atom("titletip", "titletip"),
Atom("toggle", "toggle"),
Atom("token", "token"),