Bug 1765109 - Make TextEventDispatcher::MaybeQueryWritingModeAtSelection not try to query selection if it's unavailable r=m_kato

We resolve editing commands on Linux and macOS to respect the system settings
of every key press when an `eKeyPress` event is sent to a remote process, and
it requires `WritingMode` at selection for arrow key handling for example.
Therefore, the parent process try to get the information.

However, in the case, the query succeeds only when IME has focus since
`ContentCacheInParent` does not have any data when IME does not have focus.
Therefore, `TextEventDispatcher::MaybeQueryWritingModeAtSelection` should
check the IME state before dispatching `eQuerySelectedText` event to avoid
the warnings and unnecessary runtime cost.

Differential Revision: https://phabricator.services.mozilla.com/D143901
This commit is contained in:
Masayuki Nakano 2022-04-19 11:41:52 +00:00
parent f56be3984d
commit b3f898a618

View File

@ -240,6 +240,16 @@ Maybe<WritingMode> TextEventDispatcher::MaybeQueryWritingModeAtSelection()
return Nothing();
}
// If a remote content has focus and IME does not have focus, it's going to
// fail eQuerySelectedText in ContentCacheParent. For avoiding to waste
// unnecessary runtime cost and to prevent unnecessary warnings, we should
// not dispatch the event in the case.
const InputContext inputContext = mWidget->GetInputContext();
if (XRE_IsE10sParentProcess() && inputContext.IsOriginContentProcess() &&
!inputContext.mIMEState.IsEditable()) {
return Nothing();
}
WidgetQueryContentEvent querySelectedTextEvent(true, eQuerySelectedText,
mWidget);
nsEventStatus status = nsEventStatus_eIgnore;