Bug 1100401 - Keep the default button's background appearance in sync with the text color. r?spohl
MozReview-Commit-ID: HzJ6cc2Fw40
--- 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;