Bug 1249556 - Implement toggling details by keyboard. r=smaug

The user can switch to the main <summary> by tab key, and toggle the
<details> by either 'space' key or 'enter' key.

'return' key is handled with 'keypress', and the 'space' key is handled
with 'keyup' like the HTMLInputElement.

MozReview-Commit-ID: HE6IduUGCpj
This commit is contained in:
Ting-Yu Lin
2016-03-19 20:37:09 +08:00
parent ba91e0f587
commit 972d7f0af5
11 changed files with 210 additions and 54 deletions

View File

@@ -292,15 +292,8 @@ HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
eKeyPress == aVisitor.mEvent->mMessage) ||
(keyEvent->keyCode == NS_VK_SPACE &&
eKeyUp == aVisitor.mEvent->mMessage)) {
nsEventStatus status = nsEventStatus_eIgnore;
WidgetMouseEvent event(aVisitor.mEvent->mFlags.mIsTrusted,
eMouseClick, nullptr,
WidgetMouseEvent::eReal);
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD;
EventDispatcher::Dispatch(static_cast<nsIContent*>(this),
aVisitor.mPresContext, &event, nullptr,
&status);
DispatchSimulatedClick(this, aVisitor.mEvent->mFlags.mIsTrusted,
aVisitor.mPresContext);
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
}
}