Closed Bug 775403 Opened 12 years ago Closed 12 years ago

Focus (?) not working for tabs in Gaia browser app (virtual keyboard broken for remote content in browser)

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: cjones, Assigned: Felipe)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

This is almost certainly due to bug 774139.

Testing on http://people.mozilla.com/~cjones/events-mouse.html, which doesn't preventDefault() the touchstart event so should only get mouse events IIUC, I see

received event touchstart
received event mousedown
received event touchmove   <== wrong, I think
received event mousemove
received event touchmove
received event mousemove
...
received event touchend    <== also wrong, I think, maybe not
received event mouseup

This is probably confusing either our focus code or the JS form helper.
That sequence seems right to me. If you have listeners, you'll always get the touch events. And if the code called preventDefault() then it should stop getting mouse events, but will still get touch.
OK.  Good to know, my understanding was incorrect.
Alright, doesn't seem to be touch-event related.  Whew!

If I load this page

http://people.mozilla.com/~cjones/focus.html

as the "Template" app, set to run out-of-process, it brings up the VKB just fine.  If I remove the .focus() call and tap the app, it works just fine too.

However, if I load the same page in the browser app, it *doesn't* work, whether with explicit .focus() or tapping the input box.

This smells to me like a missing docShell.activate on the content side.  Dale, Justin, can you guys investigate?
No longer blocks: 774139
Component: DOM: Events → DOM: Other
Summary: Gaia virtual keyboard broken for remote content → Focus (?) not working for tabs in Gaia browser app (virtual keyboard broken for remote content in browser)
Another possibility is that this is a recent bug in the gaia browser app.  If so please close out.
Here's what I think is happening:

You remember when you were dealing with bug 761927 and debugging through nsFocusManager::SetFocusInner et. al?  The focus manager is activated by mouse or keyboard input events.

Now, in bug 774139, we stopped sending mouse events to the parent element, in favor of creating the phony mouse events in the content.  But this means that SetFocusInner won't get called and remote->Activate() won't be called (http://mxr.mozilla.org/mozilla-central/source/dom/base/nsFocusManager.cpp#1781)

The solution is that we can still block cross-process forwarding of mouse events in that case, but we make them reach the parent frame as well. This seems a more correct behavior.

Another hack solution would be to call remote->Activate()  in nsEventStateManager::HandleCrossProcessEvent, but that feels like a hack and I believe can fall into other focus issues.
Comment on attachment 643728 [details] [diff] [review]
Experiment

Fixes the bug for me.
Attachment #643728 - Flags: feedback+
Indeed a regression from forwarding touch events.
Blocks: 774139
No longer blocks: browser-api
Component: DOM: Other → DOM
A potential problem with this patch is that IIUC, it will result in synthesized mouse events *always* being delivered to in-process content, even if the content preventDefault().  I don't think that's all that serious of a problem but we'd need to test.
Attachment #643728 - Flags: review?(bugs)
Comment on attachment 643728 [details] [diff] [review]
Experiment

smaug is OK with delegating this review to me.
Attachment #643728 - Flags: review?(bugs) → review+
Assignee: nobody → felipc
Target Milestone: --- → mozilla17
https://hg.mozilla.org/mozilla-central/rev/f5f8ebf59bbf
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Blocks: 819102
See Also: → 981278
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: