⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 185692 in webkit


Ignore:
Timestamp:
Jun 17, 2015, 9:38:59 PM (11 years ago)
Author:
dbates@webkit.org
Message:

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):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185683 r185692  
     12015-06-17  Daniel Bates  <dabates@apple.com>
     2
     3        Client may receive began editing callback for already focused text field
     4        https://bugs.webkit.org/show_bug.cgi?id=146074
     5        <rdar://problem/21293562>
     6
     7        Reviewed by Darin Adler.
     8
     9        Fixes an issue where the client would be notified that began editing in a text field
     10        for each programmatic DOM focus event dispatched at the text field regardless of
     11        whether the field was focused. The client should only be notified that began editing
     12        exactly once when a text field becomes focused (either programmatically or by user interaction).
     13
     14        * html/TextFieldInputType.cpp:
     15        (WebCore::TextFieldInputType::forwardEvent): Move logic to dispatch editing began callback from here...
     16        (WebCore::TextFieldInputType::handleFocusEvent): to here. This function is called when the
     17        text field becomes newly focused.
     18        * html/TextFieldInputType.h:
     19
    1202015-06-17  Alex Christensen  <achristensen@webkit.org>
    221
  • trunk/Source/WebCore/html/TextFieldInputType.cpp

    r185173 r185692  
    207207
    208208                capsLockStateMayHaveChanged();
    209             } else if (event->type() == eventNames().focusEvent) {
    210                 if (Frame* frame = element().document().frame())
    211                     frame->editor().textFieldDidBeginEditing(&element());
     209            } else if (event->type() == eventNames().focusEvent)
    212210                capsLockStateMayHaveChanged();
    213             }
    214211
    215212            element().forwardEvent(event);
    216213        }
    217214    }
     215}
     216
     217void TextFieldInputType::handleFocusEvent(Node* oldFocusedNode, FocusDirection)
     218{
     219    ASSERT_UNUSED(oldFocusedNode, oldFocusedNode != &element());
     220    if (Frame* frame = element().document().frame())
     221        frame->editor().textFieldDidBeginEditing(&element());
    218222}
    219223
  • trunk/Source/WebCore/html/TextFieldInputType.h

    r185089 r185692  
    6565    virtual void readonlyAttributeChanged() override final;
    6666    virtual bool supportsReadOnly() const override final;
     67    void handleFocusEvent(Node* oldFocusedNode, FocusDirection) override final;
    6768    virtual void handleBlurEvent() override final;
    6869    virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) override;
  • trunk/Tools/ChangeLog

    r185691 r185692  
     12015-06-17  Daniel Bates  <dabates@apple.com>
     2
     3        Client may receive began editing callback for already focused text field
     4        https://bugs.webkit.org/show_bug.cgi?id=146074
     5        <rdar://problem/21293562>
     6
     7        Reviewed by Darin Adler.
     8
     9        Add a unit test to ensure that a client receives exactly one began editing
     10        callback when a text field is newly focused. In particular, dispatching
     11        a DOM focus event at an already focused text field does not dispatch a
     12        began editing callback to the client.
     13
     14        * TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp:
     15        (TestWebKitAPI::TEST_F):
     16
    1172015-06-17  Hyungwook Lee  <hyungwook.lee@navercorp.com>
    218
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp

    r185169 r185692  
    121121}
    122122
     123TEST_F(WebKit2TextFieldBeginAndEditEditingTest, TextFieldDidBeginShouldNotBeDispatchedForAlreadyFocusedField)
     124{
     125    executeJavaScriptAndCheckDidReceiveMessage("focusTextField('input'); focusTextField('input')", "DidReceiveTextFieldDidBeginEditing");
     126    executeJavaScriptAndCheckDidReceiveMessage("blurTextField('input')", "DidReceiveTextFieldDidEndEditing");
     127}
     128
    123129} // namespace TestWebKitAPI
    124130
Note: See TracChangeset for help on using the changeset viewer.