Closed Bug 1743346 Opened 4 years ago Closed 4 years ago

`TextInputListener::HandleEvent` should refer native key bindings, then, refer our shortcut key definition

Categories

(Core :: DOM: Editor, defect, P2)

defect

Tracking

()

RESOLVED FIXED
96 Branch
Tracking Status
firefox96 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(2 files)

This is opposite from HTMLEditor. If HTMLEditor, we refer native key bindings in keypress event listener of the Document node.
https://searchfox.org/mozilla-central/rev/70b32246fce5ca1f53af573a21c1939df58cb969/editor/libeditor/EditorEventListener.cpp#641-644

Then, the event will be handled later by the global key listeners:
https://searchfox.org/mozilla-central/rev/70b32246fce5ca1f53af573a21c1939df58cb969/dom/events/GlobalKeyListener.cpp#163-164

However, TextInputListener refers opposite order:
https://searchfox.org/mozilla-central/rev/70b32246fce5ca1f53af573a21c1939df58cb969/dom/html/TextControlState.cpp#970-972,976,989,1019

I think that native key bindings should be respected than our definition.

Severity: -- → S3
Priority: -- → P2

Ctrl-a works as "Move caret to beginning of a line" in data:text/html,<div contenteditable>abc<br>def</div>?

(copy the data URI, and paste it into the URL bar, then, test Ctrl-a)

Flags: needinfo?(lilydjwg)

It works with that data URI. (But that's the least important one: contenteditable editors usually have their set of key bindings. The most use case I use for Ctrl-a is in the urlbar with which I add a keyword to specify a search site.)

With the try build:

Ctrl-a works, but Ctrl-p crashes it every time (in a <textarea>; and Ctrl-n crashes twice out of three tries, the other one opens a new window). Here's a report: https://crash-stats.mozilla.org/report/index/998f0a88-1d46-4cbf-84d1-a9f570211129. I have Ctrl-p and Ctrl-n setup in GTK's stylesheet to move cursor up and down respectively.

Alt-a (which has been setup to select all for GtkTextView) in <input> and <textarea> also crashes: https://crash-stats.mozilla.org/report/index/47bbbdac-ca5e-4ce1-8e35-50add0211129

Flags: needinfo?(lilydjwg)
  •  if (aCommands.Length() == 1u &&
    
  •      aCommands[1u] == static_cast<CommandInt>(Command::SelectAll)) {
    

Oh, my silly mistake! I'll create a new test build.

Here is new build: https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/OhaMj0a0T-KGIQUUH9OXxQ/runs/0/artifacts/public/build/target.tar.bz2

Could you check this again?

And if would not mind, could you attach your config file of the system settings?

Flags: needinfo?(lilydjwg)

The new build works for Ctrl-a, Alt-a and Ctrl-p without issues.

Flags: needinfo?(lilydjwg)
Attached file keys.css

This is my ~/.config/gtk-3.0/keys.css, @imported by ~/.config/gtk-3.0/gtk.css

Thank you! I'll post the patches soon.

Oddly, TextInputHandler which is keyboard event handler for
<input type="text"> and <textarea> handles our shortcut keys
first, then, refer native key bindings. So if a key combination
matches in both definitions, our shortcut key wins.

On the other hand, if HTMLEditor has focus, keypress event
listener on the Document node hanldes native key bindings:
https://searchfox.org/mozilla-central/rev/70b32246fce5ca1f53af573a21c1939df58cb969/editor/libeditor/EditorEventListener.cpp#641-644

Then, global key listener will be run later:
https://searchfox.org/mozilla-central/rev/70b32246fce5ca1f53af573a21c1939df58cb969/dom/events/GlobalKeyListener.cpp#163-164

Perhaps, it's better to refer native key bindings first because
unusual shortcut key definition must be caused by customization
by the user in the system level.

Therefore, this patch makes the order switchable with the new
pref for making it easier to back it out.

Depends on D132450

Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/49043994c79b Make `TextInputHandler::HandleEvent` handle native key bindings first, then, our shortcut keys r=smaug
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 96 Branch

Thank you!

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: