Changeset 66001 in webkit


Ignore:
Timestamp:
Aug 25, 2010 2:45:06 AM (14 years ago)
Author:
tkent@chromium.org
Message:

<input type=number>: Support auto-repeat by mouse press
https://bugs.webkit.org/show_bug.cgi?id=44476

Reviewed by Shinichiro Hamaji

WebCore:

Like arrow button of scrollbars, spinbuttons of <input
type=number> should continue to increase/decrease their values
while the mouse button is pressed.

No new tests because the new behavior strongly depends on a timer.

  • rendering/TextControlInnerElements.cpp:

(WebCore::SpinButtonElement::SpinButtonElement):

Initializes the timer.

(WebCore::SpinButtonElement::defaultEventHandler):

Starts the timer by a mousedown event.

(WebCore::SpinButtonElement::startRepeatingTimer):
(WebCore::SpinButtonElement::stopRepeatingTimer):
(WebCore::SpinButtonElement::repeatingTimerFired):

  • rendering/TextControlInnerElements.h:

LayoutTests:

Update existing tests.

  • fast/forms/script-tests/input-spinbutton-capturing.js:
  • platform/mac/fast/forms/input-appearance-spinbutton-up-expected.checksum:
  • platform/mac/fast/forms/input-appearance-spinbutton-up-expected.png:
  • platform/mac/fast/forms/input-appearance-spinbutton-up-expected.txt:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r66000 r66001  
     12010-08-25  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Shinichiro Hamaji
     4
     5        <input type=number>: Support auto-repeat by mouse press
     6        https://bugs.webkit.org/show_bug.cgi?id=44476
     7
     8        Update existing tests.
     9
     10        * fast/forms/script-tests/input-spinbutton-capturing.js:
     11        * platform/mac/fast/forms/input-appearance-spinbutton-up-expected.checksum:
     12        * platform/mac/fast/forms/input-appearance-spinbutton-up-expected.png:
     13        * platform/mac/fast/forms/input-appearance-spinbutton-up-expected.txt:
     14
    1152010-08-25  Kent Tamura  <tkent@chromium.org>
    216
  • trunk/LayoutTests/fast/forms/script-tests/input-spinbutton-capturing.js

    r65997 r66001  
    1515    // clear and this click didn't work.
    1616    eventSender.mouseMoveTo(anotherInput.offsetLeft + anotherInput.offsetWidth - 10, anotherInput.offsetTop + anotherInput.offsetHeight / 4);
     17    eventSender.mouseMoveTo(anotherInput.offsetLeft + anotherInput.offsetWidth - 10, anotherInput.offsetTop + anotherInput.offsetHeight / 4 - 1);
    1718    eventSender.mouseDown();
    1819    eventSender.mouseUp();
  • trunk/LayoutTests/platform/mac/fast/forms/input-appearance-spinbutton-up-expected.checksum

    r61751 r66001  
    1 5c1b34460d03938fffe006161914f725
     100e1de48e3e84449e88ede94e8e11b58
  • trunk/LayoutTests/platform/mac/fast/forms/input-appearance-spinbutton-up-expected.txt

    r63403 r66001  
    1717  RenderBlock {DIV} at (3,3) size 165x21
    1818    RenderText {#text} at (1,0) size 12x21
    19       text run at (1,0) width 12: "0"
    20 caret: position 0 of child 0 {DIV} of child 5 {INPUT} of body
     19      text run at (1,0) width 12: "1"
     20caret: position 1 of child 0 {#text} of child 0 {DIV} of child 5 {INPUT} of body
  • trunk/WebCore/ChangeLog

    r65999 r66001  
     12010-08-25  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Shinichiro Hamaji
     4
     5        <input type=number>: Support auto-repeat by mouse press
     6        https://bugs.webkit.org/show_bug.cgi?id=44476
     7
     8        Like arrow button of scrollbars, spinbuttons of <input
     9        type=number> should continue to increase/decrease their values
     10        while the mouse button is pressed.
     11
     12        No new tests because the new behavior strongly depends on a timer.
     13
     14        * rendering/TextControlInnerElements.cpp:
     15        (WebCore::SpinButtonElement::SpinButtonElement):
     16         Initializes the timer.
     17        (WebCore::SpinButtonElement::defaultEventHandler):
     18         Starts the timer by a mousedown event.
     19        (WebCore::SpinButtonElement::startRepeatingTimer):
     20        (WebCore::SpinButtonElement::stopRepeatingTimer):
     21        (WebCore::SpinButtonElement::repeatingTimerFired):
     22        * rendering/TextControlInnerElements.h:
     23
    1242010-08-25  Gabor Loki  <loki@webkit.org>
    225
  • trunk/WebCore/rendering/TextControlInnerElements.cpp

    r65997 r66001  
    4040#include "RenderLayer.h"
    4141#include "RenderTextControlSingleLine.h"
     42#include "ScrollbarTheme.h"
    4243#include "SpeechInput.h"
    4344
     
    259260    , m_capturing(false)
    260261    , m_upDownState(Indeterminate)
     262    , m_pressStartingState(Indeterminate)
     263    , m_repeatingTimer(this, &SpinButtonElement::repeatingTimerFired)
    261264{
    262265}
     
    282285    }
    283286   
    284     MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
    285287    HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
    286288    if (input->disabled() || input->isReadOnlyFormControl()) {
     
    290292    }
    291293
     294    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
    292295    IntPoint local = roundedIntPoint(box->absoluteToLocal(mouseEvent->absoluteLocation(), false, true));
    293     if (event->type() == eventNames().clickEvent && mouseEvent->button() == LeftButton) {
     296    if (mouseEvent->type() == eventNames().mousedownEvent && mouseEvent->button() == LeftButton) {
    294297        if (box->borderBoxRect().contains(local)) {
    295298            RefPtr<Node> protector(input);
    296299            input->focus();
    297300            input->select();
    298             if (local.y() < box->height() / 2)
    299                 input->stepUpFromRenderer(1);
    300             else
    301                 input->stepUpFromRenderer(-1);
     301            input->stepUpFromRenderer(m_upDownState == Up ? 1 : -1);
    302302            event->setDefaultHandled();
    303         }
    304     } else if (event->type() == eventNames().mousemoveEvent) {
     303            startRepeatingTimer();
     304        }
     305    } else if (mouseEvent->type() == eventNames().mouseupEvent && mouseEvent->button() == LeftButton)
     306        stopRepeatingTimer();
     307    else if (event->type() == eventNames().mousemoveEvent) {
    305308        if (box->borderBoxRect().contains(local)) {
    306309            if (!m_capturing) {
     
    316319        } else {
    317320            if (m_capturing) {
     321                stopRepeatingTimer();
    318322                if (Frame* frame = document()->frame()) {
    319323                    frame->eventHandler()->setCapturingMouseEventsNode(0);
     
    326330    if (!event->defaultHandled())
    327331        HTMLDivElement::defaultEventHandler(event);
     332}
     333
     334void SpinButtonElement::startRepeatingTimer()
     335{
     336    m_pressStartingState = m_upDownState;
     337    ScrollbarTheme* theme = ScrollbarTheme::nativeTheme();
     338    m_repeatingTimer.start(theme->initialAutoscrollTimerDelay(), theme->autoscrollTimerDelay());
     339}
     340
     341void SpinButtonElement::stopRepeatingTimer()
     342{
     343    m_repeatingTimer.stop();
     344}
     345
     346void SpinButtonElement::repeatingTimerFired(Timer<SpinButtonElement>*)
     347{
     348    HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
     349    if (input->disabled() || input->isReadOnlyFormControl())
     350        return;
     351    // On Mac OS, NSStepper updates the value for the button under the mouse
     352    // cursor regardless of the button pressed at the beginning. So the
     353    // following check is not needed for Mac OS.
     354#if !OS(MAC_OS_X)
     355    if (m_upDownState != m_pressStartingState)
     356        return;
     357#endif
     358    input->stepUpFromRenderer(m_upDownState == Up ? 1 : -1);
    328359}
    329360
  • trunk/WebCore/rendering/TextControlInnerElements.h

    r65856 r66001  
    3030#include "HTMLDivElement.h"
    3131#include "SpeechInputListener.h"
     32#include "Timer.h"
    3233#include <wtf/Forward.h>
    3334
     
    108109    virtual bool isReadOnlyFormControl() const { return static_cast<Element*>(const_cast<SpinButtonElement*>(this)->shadowAncestorNode())->isReadOnlyFormControl(); }
    109110    virtual void defaultEventHandler(Event*);
     111    void startRepeatingTimer();
     112    void stopRepeatingTimer();
     113    void repeatingTimerFired(Timer<SpinButtonElement>*);
    110114    virtual void setHovered(bool = true);
    111115
    112116    bool m_capturing;
    113117    UpDownState m_upDownState;
     118    UpDownState m_pressStartingState;
     119    Timer<SpinButtonElement> m_repeatingTimer;
    114120};
    115121
Note: See TracChangeset for help on using the changeset viewer.