- Revision
- 133427
- Author
- [email protected]
- Date
- 2012-11-04 15:16:13 -0800 (Sun, 04 Nov 2012)
Log Message
BaseChooserOnlyDateAndTimeInputType should have BaseClickableWithKeyInputType behavior
https://bugs.webkit.org/show_bug.cgi?id=101039
Reviewed by Hajime Morita.
Add BaseClickableWithKeyInputType behavior to
BaseChooserOnlyDateAndTimeInputType. It means date/time input types
without ENABLE_INPUT_MULTIPLE_FIELDS_UI receive DOMActivate events by
pressing space or enter key. They're going to open a date/time chooser
by DOMActive event.
Because BaseChooserOnlyDateAndTimeInputType inherits from
BaseDateAndTimeInputType, it can't inherit
BaseClickableWithKeyInputType. So, this patch adds static helper
functions to BaseClickableWithKeyInputType, and
BaseChooserOnlyDateAndTimeInputType uses them.
This patch doesn't change behavior yet because Chromimum-Android port
intercepts user events and doesn't deliver them to date/time input
elements.
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::BaseChooserOnlyDateAndTimeInputType::handleDOMActivateEvent):
Add an empty implementation with a FIXME comment.
(WebCore::BaseChooserOnlyDateAndTimeInputType::handleKeydownEvent):
Add BaseClickableWithKeyInputType behavior by a helper function.
(WebCore::BaseChooserOnlyDateAndTimeInputType::handleKeypressEvent): Ditto.
(WebCore::BaseChooserOnlyDateAndTimeInputType::handleKeyupEvent): Ditto.
(WebCore::BaseChooserOnlyDateAndTimeInputType::accessKeyAction): Ditto.
* html/BaseChooserOnlyDateAndTimeInputType.h:
(BaseChooserOnlyDateAndTimeInputType): Add function declarations.
* html/BaseClickableWithKeyInputType.cpp:
Add static helper functions, and existing member functions use them.
* html/BaseClickableWithKeyInputType.h:
(BaseClickableWithKeyInputType): Add declarations of the helper functions.
* html/InputType.h:
(InputType): Make dispatchSimulatedClickIfActive public because it is
called from a helper function.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (133426 => 133427)
--- trunk/Source/WebCore/ChangeLog 2012-11-04 22:30:25 UTC (rev 133426)
+++ trunk/Source/WebCore/ChangeLog 2012-11-04 23:16:13 UTC (rev 133427)
@@ -1,3 +1,44 @@
+2012-11-04 Kent Tamura <[email protected]>
+
+ BaseChooserOnlyDateAndTimeInputType should have BaseClickableWithKeyInputType behavior
+ https://bugs.webkit.org/show_bug.cgi?id=101039
+
+ Reviewed by Hajime Morita.
+
+ Add BaseClickableWithKeyInputType behavior to
+ BaseChooserOnlyDateAndTimeInputType. It means date/time input types
+ without ENABLE_INPUT_MULTIPLE_FIELDS_UI receive DOMActivate events by
+ pressing space or enter key. They're going to open a date/time chooser
+ by DOMActive event.
+
+ Because BaseChooserOnlyDateAndTimeInputType inherits from
+ BaseDateAndTimeInputType, it can't inherit
+ BaseClickableWithKeyInputType. So, this patch adds static helper
+ functions to BaseClickableWithKeyInputType, and
+ BaseChooserOnlyDateAndTimeInputType uses them.
+
+ This patch doesn't change behavior yet because Chromimum-Android port
+ intercepts user events and doesn't deliver them to date/time input
+ elements.
+
+ * html/BaseChooserOnlyDateAndTimeInputType.cpp:
+ (WebCore::BaseChooserOnlyDateAndTimeInputType::handleDOMActivateEvent):
+ Add an empty implementation with a FIXME comment.
+ (WebCore::BaseChooserOnlyDateAndTimeInputType::handleKeydownEvent):
+ Add BaseClickableWithKeyInputType behavior by a helper function.
+ (WebCore::BaseChooserOnlyDateAndTimeInputType::handleKeypressEvent): Ditto.
+ (WebCore::BaseChooserOnlyDateAndTimeInputType::handleKeyupEvent): Ditto.
+ (WebCore::BaseChooserOnlyDateAndTimeInputType::accessKeyAction): Ditto.
+ * html/BaseChooserOnlyDateAndTimeInputType.h:
+ (BaseChooserOnlyDateAndTimeInputType): Add function declarations.
+ * html/BaseClickableWithKeyInputType.cpp:
+ Add static helper functions, and existing member functions use them.
+ * html/BaseClickableWithKeyInputType.h:
+ (BaseClickableWithKeyInputType): Add declarations of the helper functions.
+ * html/InputType.h:
+ (InputType): Make dispatchSimulatedClickIfActive public because it is
+ called from a helper function.
+
2012-11-04 Sheriff Bot <[email protected]>
Unreviewed, rolling out r133416.
Modified: trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp (133426 => 133427)
--- trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp 2012-11-04 22:30:25 UTC (rev 133426)
+++ trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp 2012-11-04 23:16:13 UTC (rev 133427)
@@ -33,5 +33,31 @@
{
}
+void BaseChooserOnlyDateAndTimeInputType::handleDOMActivateEvent(Event*)
+{
+ // FIXME: start date-time chooser. webkit.org/b/101038.
}
+
+void BaseChooserOnlyDateAndTimeInputType::handleKeydownEvent(KeyboardEvent* event)
+{
+ BaseClickableWithKeyInputType::handleKeydownEvent(element(), event);
+}
+
+void BaseChooserOnlyDateAndTimeInputType::handleKeypressEvent(KeyboardEvent* event)
+{
+ BaseClickableWithKeyInputType::handleKeypressEvent(element(), event);
+}
+
+void BaseChooserOnlyDateAndTimeInputType::handleKeyupEvent(KeyboardEvent* event)
+{
+ BaseClickableWithKeyInputType::handleKeyupEvent(*this, event);
+}
+
+void BaseChooserOnlyDateAndTimeInputType::accessKeyAction(bool sendMouseEvents)
+{
+ BaseDateAndTimeInputType::accessKeyAction(sendMouseEvents);
+ BaseClickableWithKeyInputType::accessKeyAction(element(), sendMouseEvents);
+}
+
+}
#endif
Modified: trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h (133426 => 133427)
--- trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h 2012-11-04 22:30:25 UTC (rev 133426)
+++ trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h 2012-11-04 23:16:13 UTC (rev 133427)
@@ -27,6 +27,7 @@
#define BaseChooserOnlyDateAndTimeInputType_h
#if ENABLE(DATE_AND_TIME_INPUT_TYPES) && !ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+#include "BaseClickableWithKeyInputType.h"
#include "BaseDateAndTimeInputType.h"
namespace WebCore {
@@ -37,7 +38,13 @@
BaseChooserOnlyDateAndTimeInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
virtual ~BaseChooserOnlyDateAndTimeInputType();
- // FIXME: Composite BaseClickableWithKeyInputType behavior. webkit.org/b/101039.
+private:
+ // InputType functions:
+ virtual void handleDOMActivateEvent(Event*) OVERRIDE;
+ virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE;
+ virtual void handleKeypressEvent(KeyboardEvent*) OVERRIDE;
+ virtual void handleKeyupEvent(KeyboardEvent*) OVERRIDE;
+ virtual void accessKeyAction(bool sendMouseEvents) OVERRIDE;
};
}
Modified: trunk/Source/WebCore/html/BaseClickableWithKeyInputType.cpp (133426 => 133427)
--- trunk/Source/WebCore/html/BaseClickableWithKeyInputType.cpp 2012-11-04 22:30:25 UTC (rev 133426)
+++ trunk/Source/WebCore/html/BaseClickableWithKeyInputType.cpp 2012-11-04 23:16:13 UTC (rev 133427)
@@ -39,21 +39,21 @@
using namespace HTMLNames;
-void BaseClickableWithKeyInputType::handleKeydownEvent(KeyboardEvent* event)
+void BaseClickableWithKeyInputType::handleKeydownEvent(HTMLInputElement* element, KeyboardEvent* event)
{
const String& key = event->keyIdentifier();
if (key == "U+0020") {
- element()->setActive(true, true);
+ element->setActive(true, true);
// No setDefaultHandled(), because IE dispatches a keypress in this case
// and the caller will only dispatch a keypress if we don't call setDefaultHandled().
}
}
-void BaseClickableWithKeyInputType::handleKeypressEvent(KeyboardEvent* event)
+void BaseClickableWithKeyInputType::handleKeypressEvent(HTMLInputElement* element, KeyboardEvent* event)
{
int charCode = event->charCode();
if (charCode == '\r') {
- element()->dispatchSimulatedClick(event);
+ element->dispatchSimulatedClick(event);
event->setDefaultHandled();
return;
}
@@ -63,23 +63,42 @@
}
}
-void BaseClickableWithKeyInputType::handleKeyupEvent(KeyboardEvent* event)
+void BaseClickableWithKeyInputType::handleKeyupEvent(InputType& inputType, KeyboardEvent* event)
{
const String& key = event->keyIdentifier();
if (key != "U+0020")
return;
// Simulate mouse click for spacebar for button types.
- dispatchSimulatedClickIfActive(event);
+ inputType.dispatchSimulatedClickIfActive(event);
}
// FIXME: Could share this with BaseCheckableInputType and RangeInputType if we had a common base class.
-void BaseClickableWithKeyInputType::accessKeyAction(bool sendMouseEvents)
+void BaseClickableWithKeyInputType::accessKeyAction(HTMLInputElement* element, bool sendMouseEvents)
{
- InputType::accessKeyAction(sendMouseEvents);
-
// Send mouse button events if the caller specified sendMouseEvents.
// FIXME: The comment above is no good. It says what we do, but not why.
- element()->dispatchSimulatedClick(0, sendMouseEvents);
+ element->dispatchSimulatedClick(0, sendMouseEvents);
}
+void BaseClickableWithKeyInputType::handleKeydownEvent(KeyboardEvent* event)
+{
+ handleKeydownEvent(element(), event);
+}
+
+void BaseClickableWithKeyInputType::handleKeypressEvent(KeyboardEvent* event)
+{
+ handleKeypressEvent(element(), event);
+}
+
+void BaseClickableWithKeyInputType::handleKeyupEvent(KeyboardEvent* event)
+{
+ handleKeyupEvent(*this, event);
+}
+
+void BaseClickableWithKeyInputType::accessKeyAction(bool sendMouseEvents)
+{
+ InputType::accessKeyAction(sendMouseEvents);
+ accessKeyAction(element(), sendMouseEvents);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/html/BaseClickableWithKeyInputType.h (133426 => 133427)
--- trunk/Source/WebCore/html/BaseClickableWithKeyInputType.h 2012-11-04 22:30:25 UTC (rev 133426)
+++ trunk/Source/WebCore/html/BaseClickableWithKeyInputType.h 2012-11-04 23:16:13 UTC (rev 133427)
@@ -37,6 +37,12 @@
// Base of input types that dispatches a simulated click on space/return key.
class BaseClickableWithKeyInputType : public InputType {
+public:
+ static void handleKeydownEvent(HTMLInputElement*, KeyboardEvent*);
+ static void handleKeypressEvent(HTMLInputElement*, KeyboardEvent*);
+ static void handleKeyupEvent(InputType&, KeyboardEvent*);
+ static void accessKeyAction(HTMLInputElement*, bool sendMouseEvents);
+
protected:
BaseClickableWithKeyInputType(HTMLInputElement* element) : InputType(element) { }
Modified: trunk/Source/WebCore/html/InputType.h (133426 => 133427)
--- trunk/Source/WebCore/html/InputType.h 2012-11-04 22:30:25 UTC (rev 133426)
+++ trunk/Source/WebCore/html/InputType.h 2012-11-04 23:16:13 UTC (rev 133427)
@@ -306,10 +306,11 @@
virtual unsigned height() const;
virtual unsigned width() const;
+ void dispatchSimulatedClickIfActive(KeyboardEvent*) const;
+
protected:
InputType(HTMLInputElement* element) : m_element(element) { }
HTMLInputElement* element() const { return m_element; }
- void dispatchSimulatedClickIfActive(KeyboardEvent*) const;
Chrome* chrome() const;
Decimal parseToNumberOrNaN(const String&) const;