Bug 1757797 - Don't use native tooltip drawing on Windows. r=dao,cmartin

This removes the rounded, native-looking tooltips on Windows 7, but I don't
think it's too concerning, let me know if you disagree.  I'm not sure what's
our Windows 7 support status, but in any case this regression would be
relatively minimal.

On regular (non-HCM) Windows 10+ we just fill a rect with infobackground color
and so on, so there shouldn't be any effective behavior change.

On HCM we go through the themed codepath and fail catastrophically, so just
don't do it.

Differential Revision: https://phabricator.services.mozilla.com/D143754
This commit is contained in:
Emilio Cobos Alvarez 2022-04-14 21:05:57 +00:00
parent ac30b8f24b
commit 7d2c51de76
5 changed files with 2 additions and 53 deletions

View File

@ -10,8 +10,6 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
tooltip {
appearance: auto;
-moz-default-appearance: tooltip;
border: 1px solid InfoText;
padding: 2px 3px;
max-width: 40em;

View File

@ -702,8 +702,6 @@ mozilla::Maybe<nsUXThemeClass> nsNativeThemeWin::GetThemeClass(
case StyleAppearance::Textarea:
case StyleAppearance::FocusOutline:
return Some(eUXEdit);
case StyleAppearance::Tooltip:
return Some(eUXTooltip);
case StyleAppearance::Toolbox:
return Some(eUXRebar);
case StyleAppearance::MozWinMediaToolbox:
@ -932,11 +930,6 @@ nsresult nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame,
aState = TS_FOCUSED; // TFS_EDITBORDER_FOCUSED;
return NS_OK;
}
case StyleAppearance::Tooltip: {
aPart = TTP_STANDARD;
aState = TS_NORMAL;
return NS_OK;
}
case StyleAppearance::ProgressBar: {
bool vertical = IsVerticalProgress(aFrame);
aPart = vertical ? PP_BARVERT : PP_BAR;
@ -2335,7 +2328,6 @@ nsNativeThemeWin::WidgetStateChanged(nsIFrame* aFrame,
aAppearance == StyleAppearance::Resizerpanel ||
aAppearance == StyleAppearance::Progresschunk ||
aAppearance == StyleAppearance::ProgressBar ||
aAppearance == StyleAppearance::Tooltip ||
aAppearance == StyleAppearance::Tabpanels ||
aAppearance == StyleAppearance::Tabpanel ||
aAppearance == StyleAppearance::Separator ||
@ -2506,9 +2498,8 @@ nsITheme::Transparency nsNativeThemeWin::GetWidgetTransparency(
HANDLE theme = GetTheme(aAppearance);
// For the classic theme we don't really have a way of knowing
if (!theme) {
// menu backgrounds and tooltips which can't be themed are opaque
if (aAppearance == StyleAppearance::Menupopup ||
aAppearance == StyleAppearance::Tooltip) {
// menu backgrounds which can't be themed are opaque
if (aAppearance == StyleAppearance::Menupopup) {
return eOpaque;
}
return eUnknownTransparency;
@ -2562,7 +2553,6 @@ bool nsNativeThemeWin::ClassicThemeSupportsWidget(nsIFrame* aFrame,
case StyleAppearance::SpinnerDownbutton:
case StyleAppearance::Listbox:
case StyleAppearance::Treeview:
case StyleAppearance::Tooltip:
case StyleAppearance::Statusbar:
case StyleAppearance::Statusbarpanel:
case StyleAppearance::Resizerpanel:
@ -2627,9 +2617,6 @@ LayoutDeviceIntMargin nsNativeThemeWin::ClassicGetWidgetBorder(
result.right = aFrame->GetNextSibling() ? 3 : 1;
break;
}
case StyleAppearance::Tooltip:
result.top = result.left = result.bottom = result.right = 1;
break;
case StyleAppearance::ProgressBar:
result.top = result.left = result.bottom = result.right = 1;
break;
@ -2734,7 +2721,6 @@ nsresult nsNativeThemeWin::ClassicGetMinimumWidgetSize(
case StyleAppearance::Statusbarpanel:
case StyleAppearance::Resizerpanel:
case StyleAppearance::Progresschunk:
case StyleAppearance::Tooltip:
case StyleAppearance::ProgressBar:
case StyleAppearance::Tab:
case StyleAppearance::Tabpanel:
@ -2949,7 +2935,6 @@ nsresult nsNativeThemeWin::ClassicGetThemePartAndState(
case StyleAppearance::Statusbarpanel:
case StyleAppearance::Resizerpanel:
case StyleAppearance::Progresschunk:
case StyleAppearance::Tooltip:
case StyleAppearance::ProgressBar:
case StyleAppearance::Tab:
case StyleAppearance::Tabpanel:
@ -3334,13 +3319,6 @@ RENDER_AGAIN:
break;
}
// Draw ToolTip background
case StyleAppearance::Tooltip:
::FrameRect(hdc, &widgetRect, ::GetSysColorBrush(COLOR_WINDOWFRAME));
InflateRect(&widgetRect, -1, -1);
::FillRect(hdc, &widgetRect, ::GetSysColorBrush(COLOR_INFOBK));
break;
case StyleAppearance::Groupbox:
::DrawEdge(hdc, &widgetRect, EDGE_ETCHED, BF_RECT | BF_ADJUST);
::FillRect(hdc, &widgetRect, (HBRUSH)(COLOR_BTNFACE + 1));

View File

@ -87,8 +87,6 @@ const wchar_t* nsUXThemeData::GetClassName(nsUXThemeClass cls) {
return L"Button";
case eUXEdit:
return L"Edit";
case eUXTooltip:
return L"Tooltip";
case eUXRebar:
return L"Rebar";
case eUXMediaRebar:

View File

@ -19,7 +19,6 @@
enum nsUXThemeClass {
eUXButton = 0,
eUXEdit,
eUXTooltip,
eUXRebar,
eUXMediaRebar,
eUXCommunicationsRebar,

View File

@ -1830,30 +1830,6 @@ void nsWindow::SetThemeRegion() {
}
}
}
// Popup types that have a visual styles region applied (bug 376408). This can
// be expanded for other window types as needed. The regions are applied
// generically to the base window so default constants are used for part and
// state. At some point we might need part and state values from
// nsNativeThemeWin's GetThemePartAndState, but currently windows that change
// shape based on state haven't come up.
else if (!HasGlass() &&
(mWindowType == eWindowType_popup && !IsPopupWithTitleBar() &&
(mPopupType == ePopupTypeTooltip ||
mPopupType == ePopupTypePanel))) {
HRGN hRgn = nullptr;
RECT rect = {0, 0, mBounds.Width(), mBounds.Height()};
HDC dc = ::GetDC(mWnd);
GetThemeBackgroundRegion(nsUXThemeData::GetTheme(eUXTooltip), dc,
TTP_STANDARD, TS_NORMAL, &rect, &hRgn);
if (hRgn) {
if (!SetWindowRgn(mWnd, hRgn,
false)) // do not delete or alter hRgn if accepted.
DeleteObject(hRgn);
}
::ReleaseDC(mWnd, dc);
}
}
/**************************************************************