Bug 96997

Summary: [Qt][WK2] Focus out is not handled properly
Product: WebKit Reporter: Heikki Paajanen <hepaajan>
Component: New BugsAssignee: Michael Brüning <michael.bruning>
Status: RESOLVED FIXED    
Severity: Normal CC: abecsi, allan.jensen, cmarcelo, menard, michael.bruning, pnormand, webkit.review.bot, zoltan
Priority: P3    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Heikki Paajanen 2012-09-18 03:56:46 PDT
When (qml) WebView looses focus the focus status is not updated correctly to WebProcess.

QtWebPageEventHandler::handleFocusOutEvent calls WebPageProxy::viewStateDidChange which then 
checks the focus from QtPageClient::isViewFocused. QtPageClient::isViewFocused returns QQuickWebView::hasFocus 
but the actual "focus" property value has not changed yet and thus it returns true.

This can be seen e.g. in MiniBrowser by clicking address bar after launching as the caret
is left blinking on google search front page text input.
Comment 1 Michael Brüning 2012-09-19 08:58:17 PDT
I'll check this.
Comment 2 Michael Brüning 2012-09-21 08:37:01 PDT
Created attachment 165137 [details]
Patch
Comment 3 Michael Brüning 2012-09-21 08:38:09 PDT
The solution here might be a bit "hacky", but it seems to be the least complicated way. Better suggestions are welcome as always :)
Comment 4 Allan Sandfeld Jensen 2012-09-21 09:39:07 PDT
Would it possible to set the focus value on the UIProcess side as soon as the event is send to the WebProcess? Focus out shouldn't be an event the WebProcess can block anyway.
Comment 5 Michael Brüning 2012-09-24 07:31:11 PDT
(In reply to comment #4)
> Would it possible to set the focus value on the UIProcess side as soon as the event is send to the WebProcess? Focus out shouldn't be an event the WebProcess can block anyway.

It's not really the WebProcess "blocking" the focus, it's the UI process feeding it with the wrong value and hence the FocusController doesn't set the focus on the text element correctly.

Anyway, after digging through the focus event handling etc, I have found that

virtual void QQuickItem::itemChange(ItemChange change, const ItemChangeData &value);

is the right method to override here as also e.g. the QQuickTextInput uses that for deciding about lost focus (gaining focus seems to work...). Updated patch coming soon...
Comment 6 Michael Brüning 2012-09-24 07:36:55 PDT
Created attachment 165379 [details]
Patch
Comment 7 Michael Brüning 2012-09-24 08:11:20 PDT
As already correctly noted by Simon on irc, the call to QQuickItem::itemChange() will be changed to QQuickFlickable::itemChange().
Comment 8 Michael Brüning 2012-09-25 01:55:54 PDT
Created attachment 165559 [details]
Patch
Comment 9 Michael Brüning 2012-09-25 05:40:35 PDT
Created attachment 165592 [details]
Patch
Comment 10 WebKit Review Bot 2012-09-25 06:16:05 PDT
Comment on attachment 165592 [details]
Patch

Clearing flags on attachment: 165592

Committed r129496: <http://trac.webkit.org/changeset/129496>
Comment 11 WebKit Review Bot 2012-09-25 06:16:08 PDT
All reviewed patches have been landed.  Closing bug.