зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1851641 - Fix hiding cursor while typing. r=masayuki
This didn't work properly for non-native key bindings because: https://hg.mozilla.org/mozilla-central/rev/8934e6e6ccb6 Moved the DetachedFromEditorOrDefaultPrevented() check before the "hide cursor" check, rather than after. This was a quick fix, because if we're detached from the editor, then GetPresContext would assert. But I didn't realize at the time (since it was a long time since I wrote the patch) that most events there actually are default-prevented. To fix this, split the checks. Checks for DetachedFromEditor() first, and only after potentially hiding the cursor check whether the event is default-prevented. Differential Revision: https://phabricator.services.mozilla.com/D187536
This commit is contained in:
Родитель
ba309a7f96
Коммит
cc72d328af
|
@ -643,10 +643,6 @@ nsresult EditorEventListener::KeyPress(WidgetKeyboardEvent* aKeyboardEvent) {
|
|||
return rv;
|
||||
}
|
||||
|
||||
if (DetachedFromEditorOrDefaultPrevented(aKeyboardEvent)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
auto GetWidget = [&]() -> nsIWidget* {
|
||||
if (aKeyboardEvent->mWidget) {
|
||||
return aKeyboardEvent->mWidget;
|
||||
|
@ -659,6 +655,10 @@ nsresult EditorEventListener::KeyPress(WidgetKeyboardEvent* aKeyboardEvent) {
|
|||
return presContext->GetTextInputHandlingWidget();
|
||||
};
|
||||
|
||||
if (DetachedFromEditor()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (LookAndFeel::GetInt(LookAndFeel::IntID::HideCursorWhileTyping)) {
|
||||
if (nsPresContext* pc = GetPresContext()) {
|
||||
if (nsIWidget* widget = GetWidget()) {
|
||||
|
@ -667,6 +667,10 @@ nsresult EditorEventListener::KeyPress(WidgetKeyboardEvent* aKeyboardEvent) {
|
|||
}
|
||||
}
|
||||
|
||||
if (aKeyboardEvent->DefaultPrevented()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!ShouldHandleNativeKeyBindings(aKeyboardEvent)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче