Bug 1677254 - Make select event from select() uncancelable r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D97068
This commit is contained in:
Kagami Sascha Rosylight
2020-11-15 02:32:22 +00:00
parent 6082baa482
commit 326140995d
5 changed files with 18 additions and 46 deletions

View File

@@ -3010,7 +3010,8 @@ void HTMLInputElement::Select() {
return;
}
if (DispatchSelectEvent(presContext) && fm) {
DispatchSelectEvent(presContext);
if (fm) {
fm->SetFocus(this, nsIFocusManager::FLAG_NOSCROLL);
// ensure that the element is actually focused
@@ -3021,22 +3022,16 @@ void HTMLInputElement::Select() {
}
}
bool HTMLInputElement::DispatchSelectEvent(nsPresContext* aPresContext) {
nsEventStatus status = nsEventStatus_eIgnore;
void HTMLInputElement::DispatchSelectEvent(nsPresContext* aPresContext) {
// If already handling select event, don't dispatch a second.
if (!mHandlingSelectEvent) {
WidgetEvent event(true, eFormSelect);
mHandlingSelectEvent = true;
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), aPresContext,
&event, nullptr, &status);
&event);
mHandlingSelectEvent = false;
}
// If the DOM event was not canceled (e.g. by a JS event handler
// returning false)
return (status == nsEventStatus_eIgnore);
}
void HTMLInputElement::SelectAll(nsPresContext* aPresContext) {
@@ -3735,9 +3730,8 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
nsIFocusManager::FLAG_BYMOVEFOCUS)) {
RefPtr<nsPresContext> presContext =
GetPresContext(eForComposedDoc);
if (DispatchSelectEvent(presContext)) {
SelectAll(presContext);
}
DispatchSelectEvent(presContext);
SelectAll(presContext);
}
}
}