Bug 1294788 - Disable AssumeThemePartAndStateAreTransparent() on high contrast mode since Win8.1 r=jrmuizel
authorsotaro <sotaro.ikeda.g@gmail.com>
Fri, 22 Sep 2017 19:07:15 +0900
changeset 669139 aba0a23d94341acf31fc97ecc11955b5fad612fa
parent 669138 81ab59f300ac4a54f6cb4fc78052c3a625675d51
child 669140 029c7b6eee9921c386484ef666946db49c976fc0
push id81223
push usergpascutto@mozilla.com
push dateFri, 22 Sep 2017 15:21:17 +0000
reviewersjrmuizel
bugs1294788, 888870
milestone58.0a1
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
widget/windows/nsNativeThemeWin.cpp
--- 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