Client may receive began editing callback for already focused text field
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Jun 2015 04:38:59 +0000 (04:38 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Jun 2015 04:38:59 +0000 (04:38 +0000)
commitd081ced0564f74d1e8c3e9146ce1695507121f93
treece8ce404ff5a11588649a2c8b88b15397aaa258b
parent3978fe3ab6d146ae7bae3a5adf2cc0e3e724c845
Client may receive began editing callback for already focused text field
https://bugs.webkit.org/show_bug.cgi?id=146074
<rdar://problem/21293562>

Reviewed by Darin Adler.

Source/WebCore:

Fixes an issue where the client would be notified that began editing in a text field
for each programmatic DOM focus event dispatched at the text field regardless of
whether the field was focused. The client should only be notified that began editing
exactly once when a text field becomes focused (either programmatically or by user interaction).

* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::forwardEvent): Move logic to dispatch editing began callback from here...
(WebCore::TextFieldInputType::handleFocusEvent): to here. This function is called when the
text field becomes newly focused.
* html/TextFieldInputType.h:

Tools:

Add a unit test to ensure that a client receives exactly one began editing
callback when a text field is newly focused. In particular, dispatching
a DOM focus event at an already focused text field does not dispatch a
began editing callback to the client.

* TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp:
(TestWebKitAPI::TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185692 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/html/TextFieldInputType.cpp
Source/WebCore/html/TextFieldInputType.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp