[Webkit-unassigned] [Bug 51897] Escape should clear search field

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jul 13 19:51:56 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=51897





--- Comment #4 from Kentaro Hara <haraken at google.com>  2011-07-13 19:51:56 PST ---
(From update of attachment 100667)
View in context: https://bugs.webkit.org/attachment.cgi?id=100667&action=review

>> LayoutTests/fast/forms/input-search-press-escape-key.html:28
>> +    eventSender.keyDown("escape");
> 
> Do you need to use eventSender?
> Doesn't the following event dispatching work?
>  var event = document.createEvent('KeyboardEvents');
>  event.initKeyboardEvent(...);
>  input.dispatchEvent(event);

Keyboard event dispatching does fire the event but does nothing because of the bug: http://code.google.com/p/chromium/issues/detail?id=52408
This bug happens on not only Linux Chromium 14.0.822.0 but also Mac Safari 5.0.5 and even Linux Firefox 5.0. 

You can test it here:
http://haraken.info/null/keyevent.html

Provided that the above test code is not wrong, I am not sure but I guess that this is not a bug and there must be some strong reason (security or something?) that browsers are forbidding dispatching keyboard events. But if this is really a bug to be fixed and you think that we should first fix the keyboard event dispatching bug, then I will fix it and then come back to this search form bug later.

>> Source/WebCore/html/SearchInputType.cpp:110
>> +        input->onSearch();
> 
> setValueForUser() dispatches 'change' event and a JavaScript handler can delete 'input'.
> You need to use RefPtr<HTMLInputElement>.

OK. I will fix it in the next patch.

>>> Source/WebCore/html/SearchInputType.cpp:113
>>> +        TextFieldInputType::handleKeydownEvent(event);
>> 
>> Does this mean it's impossible for content to handle 'esc' specially?  I wonder if this maybe belongs on keypress rather than keydown.
> 
> Agree with Evan.

I am not sure for this. I agree that it becomes impossible for content to handle 'Escape', if we handle it in handleKeydownEvent(). However, it seems that most key events for input elements are being handled not by handleKeypressEvent() but by handleKeydownEvent(). For example, TextFieldInputType.cpp, NumberInputType.cpp and RangeInputType.cpp have handleKeydownEvent() but do not have handleKeypressEvent(). Also, if we handle 'Escape' in handleKeypressEvent(), then it becomes impossible to test it by eventSender.keyDown("escape") (, although whether we should test it by eventSender.keyDown() or not is debatable as I described above).

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list