Changeset 91058 in webkit


Ignore:
Timestamp:
Jul 15, 2011 1:10:54 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Clear the content of a search input form when 'Escape' is pressed.
https://bugs.webkit.org/show_bug.cgi?id=51897

Source/WebCore:

This change added handleKeydownEvent() to a search input form,
which clears the form and triggers a 'search' event when 'Escape' is pressed.

Patch by Kentaro Hara <haraken@google.com> on 2011-07-15
Reviewed by Kent Tamura.

Test: fast/forms/input-search-press-escape-key.html

  • html/SearchInputType.cpp:

(WebCore::SearchInputType::handleKeydownEvent):

  • html/SearchInputType.h:

LayoutTests:

The added test checks if the value in a search input form is cleared
and a 'search' event is triggered, when we press 'Escape' key.

Patch by Kentaro Hara <haraken@google.com> on 2011-07-15
Reviewed by Kent Tamura.

  • fast/forms/input-search-press-escape-key-expected.txt: Added.
  • fast/forms/input-search-press-escape-key.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r91055 r91058  
     12011-07-15  Kentaro Hara  <haraken@google.com>
     2
     3        Clear the content of a search input form when 'Escape' is pressed.
     4        https://bugs.webkit.org/show_bug.cgi?id=51897
     5
     6        The added test checks if the value in a search input form is cleared
     7        and a 'search' event is triggered, when we press 'Escape' key.
     8
     9        Reviewed by Kent Tamura.
     10
     11        * fast/forms/input-search-press-escape-key-expected.txt: Added.
     12        * fast/forms/input-search-press-escape-key.html: Added.
     13
    1142011-07-14  Hayato Ito  <hayato@chromium.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r91057 r91058  
     12011-07-15  Kentaro Hara  <haraken@google.com>
     2
     3        Clear the content of a search input form when 'Escape' is pressed.
     4        https://bugs.webkit.org/show_bug.cgi?id=51897
     5
     6        This change added handleKeydownEvent() to a search input form,
     7        which clears the form and triggers a 'search' event when 'Escape' is pressed.
     8
     9        Reviewed by Kent Tamura.
     10
     11        Test: fast/forms/input-search-press-escape-key.html
     12
     13        * html/SearchInputType.cpp:
     14        (WebCore::SearchInputType::handleKeydownEvent):
     15        * html/SearchInputType.h:
     16
    1172011-07-15  Alexandru Chiculita  <achicu@adobe.com>
    218
  • trunk/Source/WebCore/html/SearchInputType.cpp

    r91014 r91058  
    3333
    3434#include "HTMLInputElement.h"
     35#include "KeyboardEvent.h"
    3536#include "RenderTextControlSingleLine.h"
    3637#include "ShadowRoot.h"
     
    100101}
    101102
     103void SearchInputType::handleKeydownEvent(KeyboardEvent* event)
     104{
     105    if (element()->disabled() || element()->readOnly()) {
     106        TextFieldInputType::handleKeydownEvent(event);
     107        return;
     108    }
     109
     110    const String& key = event->keyIdentifier();
     111    if (key == "U+001B") {
     112        RefPtr<HTMLInputElement> input = element();
     113        input->setValueForUser("");
     114        input->onSearch();
     115        event->setDefaultHandled();
     116        return;
     117    }
     118    TextFieldInputType::handleKeydownEvent(event);
     119}
     120
    102121void SearchInputType::destroyShadowSubtree()
    103122{
  • trunk/Source/WebCore/html/SearchInputType.h

    r91014 r91058  
    5757    virtual HTMLElement* resultsButtonElement() const;
    5858    virtual HTMLElement* cancelButtonElement() const;
     59    virtual void handleKeydownEvent(KeyboardEvent*);
    5960
    6061    void searchEventTimerFired(Timer<SearchInputType>*);
Note: See TracChangeset for help on using the changeset viewer.