Changeset 19336 in webkit


Ignore:
Timestamp:
Feb 1, 2007 12:36:53 AM (17 years ago)
Author:
darin
Message:

LayoutTests:

Reviewed by Maciej.

  • test for <rdar://problem/4887428> REGRESSION: Implement slight delay for firing incremental onSearch event
  • fast/forms/search-event-delay-expected.txt: Added.
  • fast/forms/search-event-delay.html: Added.

WebCore:

Reviewed by Maciej.

  • fix <rdar://problem/4887428> REGRESSION: Implement slight delay for firing incremental onSearch event
  • rendering/RenderTextControl.h:
  • rendering/RenderTextControl.cpp: (WebCore::RenderTextControl::RenderTextControl): Set up timer. (WebCore::RenderTextControl::subtreeHasChanged): Start timer here instead of immediately sending event. (WebCore::RenderTextControl::searchEventTimerFired): Added. Sends search event. (WebCore::RenderTextControl::stopSearchEventTimer): Added. (WebCore::RenderTextControl::startSearchEventTimer): Added. Sends search event right away if there is no text. If there is some text, sets the timer using the same delay rule as NSSearchField. If you keep typing, then the timer keeps getting reset 0.2 seconds into the future until you pause.
  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::onSearch): Tell the renderer to stop the timer, since we're sending a search event. This helps when a caller other than the timer decides to send an explicit search event.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r19331 r19336  
     12007-02-01  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Maciej.
     4
     5        - test for <rdar://problem/4887428> REGRESSION: Implement slight delay for firing incremental onSearch event
     6
     7        * fast/forms/search-event-delay-expected.txt: Added.
     8        * fast/forms/search-event-delay.html: Added.
     9
    1102007-01-31  Darin Adler  <darin@apple.com>
    211
  • trunk/WebCore/ChangeLog

    r19335 r19336  
     12007-02-01  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Maciej.
     4
     5        - fix <rdar://problem/4887428> REGRESSION: Implement slight delay for firing incremental onSearch event
     6
     7        * rendering/RenderTextControl.h:
     8        * rendering/RenderTextControl.cpp:
     9        (WebCore::RenderTextControl::RenderTextControl): Set up timer.
     10        (WebCore::RenderTextControl::subtreeHasChanged): Start timer here instead of immediately sending event.
     11        (WebCore::RenderTextControl::searchEventTimerFired): Added. Sends search event.
     12        (WebCore::RenderTextControl::stopSearchEventTimer): Added.
     13        (WebCore::RenderTextControl::startSearchEventTimer): Added. Sends search event right away if there is
     14        no text. If there is some text, sets the timer using the same delay rule as NSSearchField. If you keep
     15        typing, then the timer keeps getting reset 0.2 seconds into the future until you pause.
     16
     17        * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::onSearch): Tell the renderer to
     18        stop the timer, since we're sending a search event. This helps when a caller other than
     19        the timer decides to send an explicit search event.
     20
    1212007-02-01  Maciej Stachowiak  <mjs@apple.com>
    222
  • trunk/WebCore/html/HTMLInputElement.cpp

    r19313 r19336  
    15381538{
    15391539    ASSERT(isSearchField());
     1540    if (renderer())
     1541        static_cast<RenderTextControl*>(renderer())->stopSearchEventTimer();
    15401542    dispatchHTMLEvent(searchEvent, true, false);
    15411543}
  • trunk/WebCore/rendering/RenderTextControl.cpp

    r19313 r19336  
    5959    , m_searchPopup(0)
    6060    , m_searchPopupIsVisible(false)
     61    , m_searchEventTimer(this, &RenderTextControl::searchEventTimerFired)
    6162{
    6263}
     
    480481        // If the incremental attribute is set, then dispatch the search event
    481482        if (!input->getAttribute(incrementalAttr).isNull())
    482             input->onSearch();
     483            startSearchEventTimer();
    483484
    484485        if (!wasDirty) {
     
    997998}
    998999
     1000void RenderTextControl::searchEventTimerFired(Timer<RenderTextControl>*)
     1001{
     1002    static_cast<HTMLInputElement*>(node())->onSearch();
     1003}
     1004
     1005void RenderTextControl::stopSearchEventTimer()
     1006{
     1007    m_searchEventTimer.stop();
     1008}
     1009
     1010void RenderTextControl::startSearchEventTimer()
     1011{
     1012    unsigned length = text().length();
     1013
     1014    // If there's no text, fire the event right away.
     1015    if (!length) {
     1016        m_searchEventTimer.stop();
     1017        static_cast<HTMLInputElement*>(node())->onSearch();
     1018        return;
     1019    }
     1020
     1021    // After typing the first key, we wait 0.5 seconds.
     1022    // After the second key, 0.4 seconds, then 0.3, then 0.2 from then on.
     1023    m_searchEventTimer.startOneShot(max(0.2, 0.6 - 0.1 * length));
     1024}
     1025
    9991026} // namespace WebCore
  • trunk/WebCore/rendering/RenderTextControl.h

    r19313 r19336  
    2424#include "PopupMenuClient.h"
    2525#include "RenderBlock.h"
     26#include "Timer.h"
    2627
    2728namespace WebCore {
     
    8990    void hidePopup();
    9091
     92    void stopSearchEventTimer();
     93
    9194private:
    9295    // PopupMenuClient methods
     
    117120    void updateCancelButtonVisibility(RenderStyle*);
    118121    const AtomicString& autosaveName() const;
     122    void startSearchEventTimer();
     123    void searchEventTimerFired(Timer<RenderTextControl>*);
    119124
    120125    RefPtr<HTMLTextFieldInnerElement> m_innerBlock;
     
    130135    bool m_searchPopupIsVisible;
    131136    mutable Vector<String> m_recentSearches;
     137
     138    Timer<RenderTextControl> m_searchEventTimer;
    132139};
    133140
Note: See TracChangeset for help on using the changeset viewer.