Title: [125522] trunk/Source/WebCore
Revision
125522
Author
[email protected]
Date
2012-08-14 01:44:42 -0700 (Tue, 14 Aug 2012)

Log Message

[Forms] Move wheel event handler to spin button class
https://bugs.webkit.org/show_bug.cgi?id=93928

Reviewed by Kent Tamura.

This patch moves implmentation of wheel event handling from TextFieldInput
class to SpinButtonElement class to share implementation in TextFieldInput
class, and DateTimeEditElement.

No new tests. This patch doesn't change behavior. fast/orms/number/number-wheel.html
covers this change.

* html/BaseDateAndTimeInputType.cpp: Removed handleWheelEvent() implementation.
* html/BaseDateAndTimeInputType.h:
(BaseDateAndTimeInputType): Removed handleWheelEvent() declaration.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::defaultEventHandler): Removed wheel event handling.
* html/InputType.cpp: Removed handleWheelEvent() implementation.
* html/InputType.h:
(InputType): Removed handleWheelEvent() declaration.
* html/NumberInputType.cpp: Removed handleWheelEvent() implementation.
* html/NumberInputType.h:
(NumberInputType): Removed handleWheelEvent() declaration.
* html/TextFieldInputType.cpp: Removed handleWheelEventForSpinButton() declaration.
(WebCore::TextFieldInputType::forwardEvent): Changed to call SpinButtonElement::forwardEvent().
* html/TextFieldInputType.h:
(TextFieldInputType): Removed handleWheelEventForSpinButton() declaration.
* html/shadow/TextControlInnerElements.cpp:
(WebCore::SpinButtonElement::forwardEvent): Moved implementation of wheel event handling code
from TextFieldInputType::handleWheelEventForSpinButton().
* html/shadow/TextControlInnerElements.h:
(SpinButtonElement): Added forwardEvent() declaration.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125521 => 125522)


--- trunk/Source/WebCore/ChangeLog	2012-08-14 08:23:03 UTC (rev 125521)
+++ trunk/Source/WebCore/ChangeLog	2012-08-14 08:44:42 UTC (rev 125522)
@@ -1,3 +1,38 @@
+2012-08-14  Yoshifumi Inoue  <[email protected]>
+
+        [Forms] Move wheel event handler to spin button class
+        https://bugs.webkit.org/show_bug.cgi?id=93928
+
+        Reviewed by Kent Tamura.
+
+        This patch moves implmentation of wheel event handling from TextFieldInput
+        class to SpinButtonElement class to share implementation in TextFieldInput
+        class, and DateTimeEditElement.
+
+        No new tests. This patch doesn't change behavior. fast/orms/number/number-wheel.html
+        covers this change.
+
+        * html/BaseDateAndTimeInputType.cpp: Removed handleWheelEvent() implementation.
+        * html/BaseDateAndTimeInputType.h:
+        (BaseDateAndTimeInputType): Removed handleWheelEvent() declaration.
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::defaultEventHandler): Removed wheel event handling.
+        * html/InputType.cpp: Removed handleWheelEvent() implementation.
+        * html/InputType.h:
+        (InputType): Removed handleWheelEvent() declaration.
+        * html/NumberInputType.cpp: Removed handleWheelEvent() implementation.
+        * html/NumberInputType.h:
+        (NumberInputType): Removed handleWheelEvent() declaration.
+        * html/TextFieldInputType.cpp: Removed handleWheelEventForSpinButton() declaration.
+        (WebCore::TextFieldInputType::forwardEvent): Changed to call SpinButtonElement::forwardEvent().
+        * html/TextFieldInputType.h:
+        (TextFieldInputType): Removed handleWheelEventForSpinButton() declaration.
+        * html/shadow/TextControlInnerElements.cpp:
+        (WebCore::SpinButtonElement::forwardEvent): Moved implementation of wheel event handling code
+        from TextFieldInputType::handleWheelEventForSpinButton().
+        * html/shadow/TextControlInnerElements.h:
+        (SpinButtonElement): Added forwardEvent() declaration.
+
 2012-08-14  Shinya Kawanaka  <[email protected]>
 
         AuthorShadowDOM for meter element

Modified: trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp (125521 => 125522)


--- trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp	2012-08-14 08:23:03 UTC (rev 125521)
+++ trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp	2012-08-14 08:44:42 UTC (rev 125522)
@@ -103,12 +103,6 @@
         TextFieldInputType::handleKeydownEvent(event);
 }
 
-void BaseDateAndTimeInputType::handleWheelEvent(WheelEvent* event)
-{
-    if (shouldHaveSpinButton())
-        handleWheelEventForSpinButton(event);
-}
-
 Decimal BaseDateAndTimeInputType::parseToNumber(const String& source, const Decimal& defaultValue) const
 {
     DateComponents date;

Modified: trunk/Source/WebCore/html/BaseDateAndTimeInputType.h (125521 => 125522)


--- trunk/Source/WebCore/html/BaseDateAndTimeInputType.h	2012-08-14 08:23:03 UTC (rev 125521)
+++ trunk/Source/WebCore/html/BaseDateAndTimeInputType.h	2012-08-14 08:44:42 UTC (rev 125522)
@@ -58,7 +58,6 @@
     virtual bool typeMismatch() const OVERRIDE;
     virtual Decimal defaultValueForStepUp() const OVERRIDE;
     virtual bool isSteppable() const OVERRIDE;
-    virtual void handleWheelEvent(WheelEvent*) OVERRIDE;
     virtual String serialize(const Decimal&) const OVERRIDE;
     virtual String serializeWithMilliseconds(double) const;
     virtual String localizeValue(const String&) const OVERRIDE;

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (125521 => 125522)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-08-14 08:23:03 UTC (rev 125521)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-08-14 08:44:42 UTC (rev 125522)
@@ -56,7 +56,6 @@
 #include "SearchInputType.h"
 #include "ShadowRoot.h"
 #include "ScriptEventListener.h"
-#include "WheelEvent.h"
 #include <wtf/MathExtras.h>
 #include <wtf/StdLibExtras.h>
 
@@ -1155,12 +1154,6 @@
     if (evt->isBeforeTextInsertedEvent())
         m_inputType->handleBeforeTextInsertedEvent(static_cast<BeforeTextInsertedEvent*>(evt));
 
-    if (evt->hasInterface(eventNames().interfaceForWheelEvent)) {
-        m_inputType->handleWheelEvent(static_cast<WheelEvent*>(evt));
-        if (evt->defaultHandled())
-            return;
-    }
-
     if (evt->isMouseEvent() && evt->type() == eventNames().mousedownEvent) {
         m_inputType->handleMouseDownEvent(static_cast<MouseEvent*>(evt));
         if (evt->defaultHandled())

Modified: trunk/Source/WebCore/html/InputType.cpp (125521 => 125522)


--- trunk/Source/WebCore/html/InputType.cpp	2012-08-14 08:23:03 UTC (rev 125521)
+++ trunk/Source/WebCore/html/InputType.cpp	2012-08-14 08:44:42 UTC (rev 125522)
@@ -423,10 +423,6 @@
 {
 }
 
-void InputType::handleWheelEvent(WheelEvent*)
-{
-}
-
 #if ENABLE(TOUCH_EVENTS)
 void InputType::handleTouchEvent(TouchEvent*)
 {

Modified: trunk/Source/WebCore/html/InputType.h (125521 => 125522)


--- trunk/Source/WebCore/html/InputType.h	2012-08-14 08:23:03 UTC (rev 125521)
+++ trunk/Source/WebCore/html/InputType.h	2012-08-14 08:44:42 UTC (rev 125522)
@@ -62,7 +62,6 @@
 class RenderObject;
 class RenderStyle;
 class TouchEvent;
-class WheelEvent;
 
 typedef int ExceptionCode;
 
@@ -194,7 +193,6 @@
     virtual void handleKeypressEvent(KeyboardEvent*);
     virtual void handleKeyupEvent(KeyboardEvent*);
     virtual void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*);
-    virtual void handleWheelEvent(WheelEvent*);
 #if ENABLE(TOUCH_EVENTS)
     virtual void handleTouchEvent(TouchEvent*);
 #endif

Modified: trunk/Source/WebCore/html/NumberInputType.cpp (125521 => 125522)


--- trunk/Source/WebCore/html/NumberInputType.cpp	2012-08-14 08:23:03 UTC (rev 125521)
+++ trunk/Source/WebCore/html/NumberInputType.cpp	2012-08-14 08:44:42 UTC (rev 125522)
@@ -200,11 +200,6 @@
         TextFieldInputType::handleKeydownEvent(event);
 }
 
-void NumberInputType::handleWheelEvent(WheelEvent* event)
-{
-    handleWheelEventForSpinButton(event);
-}
-
 Decimal NumberInputType::parseToNumber(const String& src, const Decimal& defaultValue) const
 {
     return parseToDecimalForNumberType(src, defaultValue);

Modified: trunk/Source/WebCore/html/NumberInputType.h (125521 => 125522)


--- trunk/Source/WebCore/html/NumberInputType.h	2012-08-14 08:23:03 UTC (rev 125521)
+++ trunk/Source/WebCore/html/NumberInputType.h	2012-08-14 08:44:42 UTC (rev 125522)
@@ -51,7 +51,6 @@
     virtual bool isSteppable() const OVERRIDE;
     virtual StepRange createStepRange(AnyStepHandling) const OVERRIDE;
     virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE;
-    virtual void handleWheelEvent(WheelEvent*) OVERRIDE;
     virtual Decimal parseToNumber(const String&, const Decimal&) const OVERRIDE;
     virtual String serialize(const Decimal&) const OVERRIDE;
     virtual void handleBlurEvent() OVERRIDE;

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (125521 => 125522)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2012-08-14 08:23:03 UTC (rev 125521)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2012-08-14 08:44:42 UTC (rev 125522)
@@ -163,21 +163,14 @@
     event->setDefaultHandled();
 }
 
-void TextFieldInputType::handleWheelEventForSpinButton(WheelEvent* event)
-{
-    if (element()->disabled() || element()->readOnly() || !element()->focused())
-        return;
-    if (event->wheelDeltaY() > 0)
-        spinButtonStepUp();
-    else if (event->wheelDeltaY() < 0)
-        spinButtonStepDown();
-    else
-        return;
-    event->setDefaultHandled();
-}
-
 void TextFieldInputType::forwardEvent(Event* event)
 {
+    if (m_innerSpinButton) {
+        m_innerSpinButton->forwardEvent(event);
+        if (event->defaultHandled())
+            return;
+    }
+
     if (element()->renderer() && (event->isMouseEvent() || event->isDragEvent() || event->hasInterface(eventNames().interfaceForWheelEvent) || event->type() == eventNames().blurEvent || event->type() == eventNames().focusEvent)) {
         RenderTextControlSingleLine* renderTextControl = toRenderTextControlSingleLine(element()->renderer());
         if (event->type() == eventNames().blurEvent) {

Modified: trunk/Source/WebCore/html/TextFieldInputType.h (125521 => 125522)


--- trunk/Source/WebCore/html/TextFieldInputType.h	2012-08-14 08:23:03 UTC (rev 125521)
+++ trunk/Source/WebCore/html/TextFieldInputType.h	2012-08-14 08:44:42 UTC (rev 125522)
@@ -48,7 +48,6 @@
     virtual bool canSetSuggestedValue() OVERRIDE;
     virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE;
     void handleKeydownEventForSpinButton(KeyboardEvent*);
-    void handleWheelEventForSpinButton(WheelEvent*);
 
     virtual HTMLElement* containerElement() const OVERRIDE;
     virtual HTMLElement* innerBlockElement() const OVERRIDE;

Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp (125521 => 125522)


--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2012-08-14 08:23:03 UTC (rev 125521)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2012-08-14 08:44:42 UTC (rev 125522)
@@ -45,6 +45,7 @@
 #include "SpeechInputEvent.h"
 #include "TextEvent.h"
 #include "TextEventInputType.h"
+#include "WheelEvent.h"
 
 namespace WebCore {
 
@@ -342,6 +343,22 @@
         HTMLDivElement::defaultEventHandler(event);
 }
 
+void SpinButtonElement::forwardEvent(Event* event)
+{
+    if (!renderBox())
+        return;
+
+    if (!event->hasInterface(eventNames().interfaceForWheelEvent))
+        return;
+
+    HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowHost());
+    if (input->disabled() || input->readOnly() || !input->focused())
+        return;
+
+    doStepAction(static_cast<WheelEvent*>(event)->wheelDeltaY());
+    event->setDefaultHandled();
+}
+
 bool SpinButtonElement::willRespondToMouseMoveEvents()
 {
     const HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowHost());

Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.h (125521 => 125522)


--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.h	2012-08-14 08:23:03 UTC (rev 125521)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.h	2012-08-14 08:44:42 UTC (rev 125522)
@@ -118,6 +118,8 @@
     virtual bool willRespondToMouseMoveEvents() OVERRIDE;
     virtual bool willRespondToMouseClickEvents() OVERRIDE;
 
+    void forwardEvent(Event*);
+
 private:
     SpinButtonElement(Document*, StepActionHandler&);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to