Bug 1294788 - Disable AssumeThemePartAndStateAreTransparent() on high contrast mode since Win8.1 r=jrmuizel
The problem happened only on themed widget. The problem was triggered by
Bug 888870. It just added Windows 8.1 support. When high contrast mode was enabled on Win 10, background color problem happend on themed widgets. There were 2 patterns.
- After hover the menu item, its background color remained highlighted
- After hover the menu item, its background color became black
From it, the problem seemed to be caused by background color drawing of themed widgets. nsNativeThemeWin::DrawWidgetBackground() does the background color drawing. AssumeThemePartAndStateAreTransparent() controls skipping background color drawing of themed widgets. If AssumeThemePartAndStateAreTransparent() was removed, the problem was addressed. From it, how DrawThemeBackground() works seems to be changed on high contrast mode since since Win8.1. To address the problem, the patch remove the skipping on high contrast mode since since Win8.1
--- a/widget/windows/nsNativeThemeWin.cpp
+++ b/widget/windows/nsNativeThemeWin.cpp
@@ -1487,17 +1487,18 @@ nsNativeThemeWin::GetThemePartAndState(n
aPart = 0;
aState = 0;
return NS_ERROR_FAILURE;
}
static bool
AssumeThemePartAndStateAreTransparent(int32_t aPart, int32_t aState)
{
- if (aPart == MENU_POPUPITEM && aState == MBI_NORMAL) {
+ if (!(IsWin8Point1OrLater() && nsUXThemeData::IsHighContrastOn()) &&
+ aPart == MENU_POPUPITEM && aState == MBI_NORMAL) {
return true;
}
return false;
}
// When running with per-monitor DPI (on Win8.1+), and rendering on a display
// with a different DPI setting from the system's default scaling, we need to
// apply scaling to native-themed elements as the Windows theme APIs assume