Bug 1767558 Make `IMContextWrapper::EnsureToCacheContentSelection` try to query with owner widget if there is no last focused widget r=m_kato

It tries to query selection with last focused widget.  However, if no widget
has gotten focused yet, it causes the warning.

I think that in such case, it should try it with owner widget which is typically
managed by same `PresShell` in these days.

Differential Revision: https://phabricator.services.mozilla.com/D145396
This commit is contained in:
Masayuki Nakano 2022-05-09 06:10:41 +00:00
Родитель 5e6b541ce8
Коммит ab4c034d48
1 изменённых файлов: 5 добавлений и 3 удалений

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

@ -3250,7 +3250,9 @@ bool IMContextWrapper::EnsureToCacheContentSelection(
return true;
}
if (NS_WARN_IF(!mLastFocusedWindow)) {
RefPtr<nsWindow> dispatcherWindow =
mLastFocusedWindow ? mLastFocusedWindow : mOwnerWindow;
if (NS_WARN_IF(!dispatcherWindow)) {
MOZ_LOG(gIMELog, LogLevel::Error,
("0x%p EnsureToCacheContentSelection(), FAILED, due to "
"no focused window",
@ -3260,9 +3262,9 @@ bool IMContextWrapper::EnsureToCacheContentSelection(
nsEventStatus status;
WidgetQueryContentEvent querySelectedTextEvent(true, eQuerySelectedText,
mLastFocusedWindow);
dispatcherWindow);
InitEvent(querySelectedTextEvent);
mLastFocusedWindow->DispatchEvent(&querySelectedTextEvent, status);
dispatcherWindow->DispatchEvent(&querySelectedTextEvent, status);
if (NS_WARN_IF(querySelectedTextEvent.Failed())) {
MOZ_LOG(gIMELog, LogLevel::Error,
("0x%p EnsureToCacheContentSelection(), FAILED, due to "