Bug 1509222 - XUL toolbarbutton with checked="true' but not type="checkbox" doesn't get the pressed state, r=Jamie

Simply decouple the check for the checked attribute from the one for the type attribute.

Differential Revision: https://phabricator.services.mozilla.com/D12632

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Marco Zehe 2018-11-22 22:39:51 +00:00
Родитель f86d40d773
Коммит 36b5ca6aa6
2 изменённых файлов: 14 добавлений и 5 удалений

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

@ -32,6 +32,10 @@
testStates("radio-disabledradiogroup", STATE_UNAVAILABLE, 0 , STATE_FOCUSABLE);
testStates("button", STATE_FOCUSABLE, 0, STATE_UNAVAILABLE);
testStates("button-disabled", STATE_UNAVAILABLE, 0 , STATE_FOCUSABLE);
testStates("checkbutton",
STATE_FOCUSABLE | STATE_CHECKABLE | STATE_PRESSED);
testStates("fakecheckbutton", STATE_FOCUSABLE | STATE_PRESSED, 0,
STATE_CHECKABLE);
testStates("combobox", STATE_FOCUSABLE | STATE_HASPOPUP, 0, STATE_UNAVAILABLE);
testStates("combobox-disabled", STATE_UNAVAILABLE | STATE_HASPOPUP, 0, STATE_FOCUSABLE);
testStates("listbox", STATE_FOCUSABLE, 0, STATE_UNAVAILABLE);
@ -89,6 +93,9 @@
<button id="button" value="button"/>
<button id="button-disabled" disabled="true" value="button"/>
<button id="checkbutton" type="checkbox" checked="true"
value="checkbutton" />
<button id="fakecheckbutton" checked="true" value="fakecheckbutton" />
<menulist id="combobox">
<menupopup>

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

@ -100,11 +100,13 @@ XULButtonAccessible::NativeState() const
xulButtonElement->GetType(type);
if (type.EqualsLiteral("checkbox") || type.EqualsLiteral("radio")) {
state |= states::CHECKABLE;
bool checked = false;
xulButtonElement->GetChecked(&checked);
if (checked) {
state |= states::PRESSED;
}
}
// Some buttons can have their checked state set without being of type
// checkbox or radio. Expose the pressed state unconditionally.
bool checked = false;
xulButtonElement->GetChecked(&checked);
if (checked) {
state |= states::PRESSED;
}
}