Bug 1100401 - Keep the default button's background appearance in sync with the text color. r=spohl
authorMarkus Stange <mstange@themasta.com>
Fri, 02 Sep 2016 14:02:49 -0400
changeset 312516 b462b3ebc32cdd8a54b35e52773191d3081f17a7
parent 312515 2fbd7f36b1cdea098f8d21418783148141f1df05
child 312517 e6f34a71e9867245df7b4f338d62565b77512713
push id30645
push userryanvm@gmail.com
push dateSat, 03 Sep 2016 15:18:20 +0000
treeherdermozilla-central@c6906f5fc278 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1100401
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1100401 - Keep the default button's background appearance in sync with the text color. r=spohl MozReview-Commit-ID: HzJ6cc2Fw40
widget/cocoa/nsNativeThemeCocoa.mm
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -1387,17 +1387,17 @@ nsNativeThemeCocoa::DrawButton(CGContext
       bdi.state = kThemeStateInactive;
     else
       bdi.state = kThemeStateActive;
   }
 
   if (inState.HasState(NS_EVENT_STATE_FOCUS) && isActive)
     bdi.adornment |= kThemeAdornmentFocus;
 
-  if (inIsDefault && !isDisabled && isActive &&
+  if (inIsDefault && !isDisabled &&
       !inState.HasState(NS_EVENT_STATE_ACTIVE)) {
     bdi.adornment |= kThemeAdornmentDefault;
     bdi.animation.time.start = 0;
     bdi.animation.time.current = CFAbsoluteTimeGetCurrent();
   }
 
   HIRect drawFrame = inBoxRect;
 
@@ -2463,21 +2463,32 @@ nsNativeThemeCocoa::DrawWidgetBackground
       bool isCheckbox = (aWidgetType == NS_THEME_CHECKBOX);
       DrawCheckboxOrRadio(cgContext, isCheckbox, macRect, GetCheckedOrSelected(aFrame, !isCheckbox),
                           eventState, aFrame);
     }
       break;
 
     case NS_THEME_BUTTON:
       if (IsDefaultButton(aFrame)) {
-        if (!IsDisabled(aFrame, eventState) && FrameIsInActiveWindow(aFrame) &&
+        // Check whether the default button is in a document that does not
+        // match the :-moz-window-inactive pseudoclass. This activeness check
+        // is different from the other "active window" checks in this file
+        // because we absolutely need the button's default button appearance to
+        // be in sync with its text color, and the text color is changed by
+        // such a :-moz-window-inactive rule. (That's because on 10.10 and up,
+        // default buttons in active windows have blue background and white
+        // text, and default buttons in inactive windows have white background
+        // and black text.)
+        EventStates docState = aFrame->GetContent()->OwnerDoc()->GetDocumentState();
+        bool isInActiveWindow = !docState.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE);
+        if (!IsDisabled(aFrame, eventState) && isInActiveWindow &&
             !QueueAnimatedContentForRefresh(aFrame->GetContent(), 10)) {
           NS_WARNING("Unable to animate button!");
         }
-        DrawButton(cgContext, kThemePushButton, macRect, true,
+        DrawButton(cgContext, kThemePushButton, macRect, isInActiveWindow,
                    kThemeButtonOff, kThemeAdornmentNone, eventState, aFrame);
       } else if (IsButtonTypeMenu(aFrame)) {
         DrawDropdown(cgContext, macRect, eventState, aWidgetType, aFrame);
       } else {
         DrawPushButton(cgContext, macRect, eventState, aWidgetType, aFrame,
                        nativeWidgetHeight);
       }
       break;