Bug 1765423 - Make tooltips look nicer with default window themes. r=dao

For that, make the Windows rounded-rect code apply to tooltips as well.

Differential Revision: https://phabricator.services.mozilla.com/D145327
This commit is contained in:
Emilio Cobos Álvarez 2022-05-03 17:30:45 +00:00
Родитель ae63baa75c
Коммит f3edc98c4b
2 изменённых файлов: 23 добавлений и 8 удалений

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

@ -19,11 +19,25 @@ tooltip {
}
@media (-moz-windows-default-theme) {
/* We use Window / WindowText instead on the default theme because the
default yellowish styles are somewhat ugly */
tooltip {
background-color: Window;
color: WindowText;
/* These are the same colors as --menu-background-color and co., but we
can't quite use them because the default tooltip is native anonymous and
doesn't inherit from the root. */
background-color: #f9f9fb;
color: #15141a;
border-color: #cfcfd8;
/* Force a rounded-rect dropshadow to appear. */
-moz-window-shadow: cliprounded;
border-radius: 4px;
}
@media (prefers-color-scheme: dark) {
tooltip {
background-color: #2b2a33;
color: #fbfbfe;
border-color: #5b5b66;
}
}
}

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

@ -1816,7 +1816,8 @@ static bool ShouldHaveRoundedMenuDropShadow(nsWindow* aWindow) {
// XXX this is apparently still needed in Windows 7 and later
void nsWindow::ClearThemeRegion() {
if (mWindowType == eWindowType_popup &&
(mPopupType == ePopupTypeMenu || mPopupType == ePopupTypePanel) &&
(mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypeMenu ||
mPopupType == ePopupTypePanel) &&
ShouldHaveRoundedMenuDropShadow(this)) {
SetWindowRgn(mWnd, nullptr, false);
} else if (!HasGlass() &&
@ -1830,9 +1831,9 @@ void nsWindow::ClearThemeRegion() {
void nsWindow::SetThemeRegion() {
// Clip the window to the rounded rect area of the popup if needed.
if (mWindowType == eWindowType_popup &&
(mPopupType == ePopupTypeMenu || mPopupType == ePopupTypePanel)) {
nsView* view = nsView::GetViewFor(this);
if (view) {
(mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypeMenu ||
mPopupType == ePopupTypePanel)) {
if (nsView* view = nsView::GetViewFor(this)) {
LayoutDeviceIntSize size =
nsLayoutUtils::GetBorderRadiusForMenuDropShadow(view->GetFrame());
if (size.width || size.height) {