WebCore/ChangeLog

 12010-08-23 Kent Tamura <tkent@chromium.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 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-22 Andreas Kling <andreas.kling@nokia.com>
225
326 Reviewed by Kenneth Rohde Christiansen.

WebCore/rendering/TextControlInnerElements.cpp

3939#include "Page.h"
4040#include "RenderLayer.h"
4141#include "RenderTextControlSingleLine.h"
 42#include "ScrollbarTheme.h"
4243#include "SpeechInput.h"
4344
4445namespace WebCore {

@@inline SpinButtonElement::SpinButtonElement(Node* shadowParent)
255256 : TextControlInnerElement(shadowParent->document(), shadowParent)
256257 , m_capturing(false)
257258 , m_upDownState(Indeterminate)
 259 , m_repeatingTimer(this, &SpinButtonElement::repeatingTimerFired)
258260{
259261}
260262

@@void SpinButtonElement::defaultEventHandler(Event* event)
293295 }
294296
295297 IntPoint local = roundedIntPoint(box->absoluteToLocal(mouseEvent->absoluteLocation(), false, true));
296  if (event->type() == eventNames().clickEvent) {
 298 if (mouseEvent->type() == eventNames().mousedownEvent && mouseEvent->button() == LeftButton) {
297299 if (box->borderBoxRect().contains(local)) {
298300 RefPtr<Node> protector(input);
299301 input->focus();
300302 input->select();
301  if (local.y() < box->height() / 2)
302  input->stepUpFromRenderer(1);
303  else
304  input->stepUpFromRenderer(-1);
 303 input->stepUpFromRenderer(m_upDownState == Up ? 1 : -1);
305304 event->setDefaultHandled();
 305 startRepeatingTimer();
306306 }
307  } else if (event->type() == eventNames().mousemoveEvent) {
 307 } else if (mouseEvent->type() == eventNames().mouseupEvent && mouseEvent->button() == LeftButton)
 308 stopRepeatingTimer();
 309 else if (event->type() == eventNames().mousemoveEvent) {
308310 if (box->borderBoxRect().contains(local)) {
309311 if (!m_capturing) {
310312 if (Frame* frame = document()->frame()) {

@@void SpinButtonElement::defaultEventHandler(Event* event)
318320 renderer()->repaint();
319321 } else {
320322 if (m_capturing) {
 323 stopRepeatingTimer();
321324 if (Frame* frame = document()->frame()) {
322325 frame->eventHandler()->setCapturingMouseEventsNode(0);
323326 m_capturing = false;

@@void SpinButtonElement::defaultEventHandler(Event* event)
330333 HTMLDivElement::defaultEventHandler(event);
331334}
332335
 336void SpinButtonElement::startRepeatingTimer()
 337{
 338 ScrollbarTheme* theme = ScrollbarTheme::nativeTheme();
 339 m_repeatingTimer.start(theme->initialAutoscrollTimerDelay(), theme->autoscrollTimerDelay());
 340}
 341
 342void SpinButtonElement::stopRepeatingTimer()
 343{
 344 m_repeatingTimer.stop();
 345}
 346
 347void SpinButtonElement::repeatingTimerFired(Timer<SpinButtonElement>*)
 348{
 349 HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
 350 if (input->disabled() || input->isReadOnlyFormControl())
 351 return;
 352 input->stepUpFromRenderer(m_upDownState == Up ? 1 : -1);
 353}
 354
333355void SpinButtonElement::setHovered(bool flag)
334356{
335357 if (!hovered() && flag)

WebCore/rendering/TextControlInnerElements.h

2929
3030#include "HTMLDivElement.h"
3131#include "SpeechInputListener.h"
 32#include "Timer.h"
3233#include <wtf/Forward.h>
3334
3435namespace WebCore {

@@private:
107108 virtual bool isEnabledFormControl() const { return static_cast<Element*>(const_cast<SpinButtonElement*>(this)->shadowAncestorNode())->isEnabledFormControl(); }
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 Timer<SpinButtonElement> m_repeatingTimer;
114119};
115120
116121#if ENABLE(INPUT_SPEECH)