Bug 1675894 - Fire selectionchange from disconnected text controls r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D98810
This commit is contained in:
Kagami Sascha Rosylight
2020-12-05 07:50:41 +00:00
parent 07a9844db6
commit 24c18c473d
2 changed files with 106 additions and 119 deletions

View File

@@ -2098,10 +2098,19 @@ void TextControlState::SetSelectionRange(
if (changed) {
// It sure would be nice if we had an existing Element* or so to work with.
RefPtr<AsyncEventDispatcher> asyncDispatcher =
new AsyncEventDispatcher(mTextCtrlElement, u"select"_ns,
CanBubble::eYes, ChromeOnlyDispatch::eNo);
RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(
mTextCtrlElement, eFormSelect, CanBubble::eYes);
asyncDispatcher->PostDOMEvent();
// SelectionChangeEventDispatcher covers this when !IsSelectionCached().
// XXX(krosylight): Shouldn't it fire before select event?
// Currently Gecko and Blink both fire selectionchange after select.
if (IsSelectionCached() &&
StaticPrefs::dom_select_events_textcontrols_enabled()) {
asyncDispatcher = new AsyncEventDispatcher(
mTextCtrlElement, eSelectionChange, CanBubble::eNo);
asyncDispatcher->PostDOMEvent();
}
}
if (NS_FAILED(rv)) {