Bug 1722833 - Tweak default button :active state rendering. r=mac-reviewers,spohl

Before this patch we were drawing default buttons as follows:

(no state):          Drawn as a regular default button, with white text.
:active:hover:       Drawn as a pressed non-default button, with white text.
:active:not(:hover): Drawn as a regular non-default button, with regular button text (black in light mode, white in dark mode).

With this patch, we are drawing default buttons as follows:

(no state):          Unchanged.
:active:hover:       Drawn as a pressed *default* button, with white text.
:active:not(:hover): Drawn as a regular *default* button, with white text.

So we're changing both the pressed state and the "dragged" state.

The pressed state looks the same as before on all macOS versions prior to macOS 12;
on those versions, pressed default buttons and pressed non-default buttons look the same.
It's only on macOS 12 that the two diverge.

The "dragged" state didn't seem to match any native behavior in the past, and is corrected
for all macOS versions now.

Differential Revision: https://phabricator.services.mozilla.com/D128616
This commit is contained in:
Markus Stange 2021-10-18 21:29:41 +00:00
Родитель b910e0fd90
Коммит eb296ef5d2
2 изменённых файлов: 2 добавлений и 12 удалений

Просмотреть файл

@ -23,12 +23,6 @@ button:where([default="true"]:not(:-moz-window-inactive)) {
color: -moz-mac-defaultbuttontext;
}
/* Likewise, when active (mousedown) but not hovering, the default button
* background isn't drawn, override the previous selector for that case: */
button:where([default="true"]:active:not(:hover)) {
color: ButtonText;
}
.button-text {
margin-block: 1px;
margin-inline: 3px 2px;

Просмотреть файл

@ -2307,13 +2307,9 @@ Maybe<nsNativeThemeCocoa::WidgetInfo> nsNativeThemeCocoa::ComputeWidgetInfo(
// 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);
bool hasDefaultButtonLook = isInActiveWindow && !eventState.HasState(NS_EVENT_STATE_ACTIVE);
ButtonType buttonType =
hasDefaultButtonLook ? ButtonType::eDefaultPushButton : ButtonType::eRegularPushButton;
ControlParams params = ComputeControlParams(aFrame, eventState);
params.insideActiveWindow = isInActiveWindow;
return Some(WidgetInfo::Button(ButtonParams{params, buttonType}));
params.insideActiveWindow = !docState.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE);
return Some(WidgetInfo::Button(ButtonParams{params, ButtonType::eDefaultPushButton}));
}
if (IsButtonTypeMenu(aFrame)) {
ControlParams controlParams = ComputeControlParams(aFrame, eventState);