Comment 15 for bug 602877

Revision history for this message
In , WaywardGeek (waywardgeek) wrote :

Created an attachment (id=441149)
Patch based on using MoveFocus instead of TakeFocus

This patch works much better than the one where I forced the focus. The change is also localized to one function in nsHyperTextAccessible.cpp, rather than several files. Basically, rather than TakeFocus, I used MoveFocus with the nsIFocusManager::MOVEFOCUS_CARET flag as Neal suggested. I watched how MoveFocus gets called when I move with arrow keys, and I called it the same way. It relies on there being a selection, so rather than calling it before setting the selection where we use to call TakeFocus, I call MoveFocus after selection.

It is not clear to me if this change belongs in the SetSelectionRange function, or in SetCaretOffset, which simply calls SetSelectionRange. Since the call to TakeFocus in SetSelectionRange doesn't work on non-tabbabe elements, I reasoned that the change belongs there. However, I also see some versions of Firefox have removed the call to TakeFocus completely, which may make sense. I made my changes to changeset 41170:020a0670ef30, which is tagged "tip". If this patch looks like the right approach, I could use a pointer to how to Mozilla-fy it, and resubmit the patch.