Commit e3bf720b authored by tkent@chromium.org's avatar tkent@chromium.org

Calendar Picker: Open a calendar picker by keyboard operation

https://bugs.webkit.org/show_bug.cgi?id=84680

Reviewed by Kentaro Hara.

Source/WebCore:

- Open a calendar picker by the down arrow key.
- Remove stepping down/up by keyboard and wheel operations.
  This behavior was for text fields with spin buttons. Because the date
type doesn't have spin buttons, we should remove this behavior.

No new tests for opening a calendar picker. This behavior is not
testable by DRT yet. For removal of stepping up/down,
fast/forms/date/date-stepup-stepdown-from-renderer.html is updated.

* html/BaseDateAndTimeInputType.cpp:
(WebCore::BaseDateAndTimeInputType::handleKeydownEvent):
Check shouldHaveSpinButton() before spin button key operations.
(WebCore::BaseDateAndTimeInputType::handleWheelEvent):
Check shouldHaveSpinButton() before spin button wheel operations.
* html/BaseDateAndTimeInputType.h:
(BaseDateAndTimeInputType):
Make handleKeydownEvent() protected because a subclass overrides it.
* html/DateInputType.cpp:
(WebCore::DateInputType::handleKeydownEvent):
Open a calendar picker by the down arrow key.
* html/DateInputType.h:
(DateInputType): Add handleKeydownEvent() declaration.
* html/shadow/CalendarPickerElement.h:
(CalendarPickerElement): Make openPopup() public because DateInputType calls it.

LayoutTests:

* fast/forms/date/date-stepup-stepdown-from-renderer-expected.txt:
* fast/forms/date/date-stepup-stepdown-from-renderer.html:
Stepping up/down by kerboard was removed. Update the test to confirm it doesn't work.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@115155 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ce6fc322
2012-04-24 Kent Tamura <tkent@chromium.org>
Calendar Picker: Open a calendar picker by keyboard operation
https://bugs.webkit.org/show_bug.cgi?id=84680
Reviewed by Kentaro Hara.
* fast/forms/date/date-stepup-stepdown-from-renderer-expected.txt:
* fast/forms/date/date-stepup-stepdown-from-renderer.html:
Stepping up/down by kerboard was removed. Update the test to confirm it doesn't work.
2012-04-24 Alpha Lam <hclam@chromium.org>
[chromium] Unreviewed test expectations update.
......
Check stepping-up and -down for date input fields from renderer. No cases of empty initial values.
Check if stepping-up and -down for date input fields from renderer does not work.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Function arguments are (value, step, {min or max}, [stepCount]).
Normal cases
PASS stepUp("2010-02-10", null, null) is "2010-02-11"
PASS stepDown("2010-02-10", null, null) is "2010-02-09"
PASS stepUp("2010-02-10", null, null, 10) is "2010-02-20"
PASS stepDown("2010-02-10", null, null, 11) is "2010-01-30"
PASS stepUp("1970-01-01", "4", null, 2) is "1970-01-09"
PASS stepDown("1970-01-01", "4", null, 3) is "1969-12-20"
Step=any
PASS stepUp("2010-02-10", "any", null) is "2010-02-11"
PASS stepDown("2010-02-10", "any", null) is "2010-02-09"
Overflow/underflow
PASS stepUp("2010-02-10", "3.40282346e+38", null) is "275760-09-13"
PASS stepDown("2010-02-10", "3.40282346e+38", null) is "1970-01-01"
PASS stepUp("2010-02-10", "1", "2010-02-10") is "2010-02-10"
PASS stepDown("2010-02-10", "1", "2010-02-10") is "2010-02-10"
stepDown()/stepUp() for stepMismatch values
PASS stepDown("2010-02-10", "3", "2010-02-06") is "2010-02-09"
PASS stepUp("1970-01-02", "2", "") is "1970-01-03"
PASS stepUp("2010-02-10") is "2010-02-10"
PASS successfullyParsed is true
......
......@@ -7,10 +7,9 @@
<p id="description"></p>
<div id="console"></div>
<script>
description('Check stepping-up and -down for date input fields from renderer. No cases of empty initial values.');
description('Check if stepping-up and -down for date input fields from renderer does not work.');
var input = document.createElement('input');
var invalidStateErr = '"Error: INVALID_STATE_ERR: DOM Exception 11"';
function sendKey(keyName) {
var event = document.createEvent('KeyboardEvent');
......@@ -18,61 +17,22 @@ function sendKey(keyName) {
input.dispatchEvent(event);
}
function setInputAttributes(min, max, step, value) {
input.min = min;
input.max = max;
input.step = step;
input.value = value;
}
function stepUp(value, step, max, optionalStepCount) {
setInputAttributes(null, max, step, value);
if (typeof optionalStepCount != "undefined")
if (optionalStepCount < 0)
for (var i = 0; i < -optionalStepCount; i++)
sendKey('Down');
else
for (var i = 0; i < optionalStepCount; i++)
sendKey('Up');
else
sendKey('Up');
input.value = value;
sendKey('Up');
return input.value;
}
function stepDown(value, step, min, optionalStepCount) {
setInputAttributes(min, null, step, value);
if (typeof optionalStepCount != "undefined")
if (optionalStepCount < 0)
for (var i = 0; i < -optionalStepCount; i++)
sendKey('Up');
else
for (var i = 0; i < optionalStepCount; i++)
sendKey('Down');
else
sendKey('Down');
input.value = value;
sendKey('Down');
return input.value;
}
input.type = 'date';
debug('Function arguments are (value, step, {min or max}, [stepCount]).');
debug('Normal cases');
shouldBe('stepUp("2010-02-10", null, null)', '"2010-02-11"');
shouldBe('stepDown("2010-02-10", null, null)', '"2010-02-09"');
shouldBe('stepUp("2010-02-10", null, null, 10)', '"2010-02-20"');
shouldBe('stepDown("2010-02-10", null, null, 11)', '"2010-01-30"');
shouldBe('stepUp("1970-01-01", "4", null, 2)', '"1970-01-09"');
shouldBe('stepDown("1970-01-01", "4", null, 3)', '"1969-12-20"');
debug('Step=any');
shouldBe('stepUp("2010-02-10", "any", null)', '"2010-02-11"');
shouldBe('stepDown("2010-02-10", "any", null)', '"2010-02-09"');
debug('Overflow/underflow');
shouldBe('stepUp("2010-02-10", "3.40282346e+38", null)','"275760-09-13"');
shouldBe('stepDown("2010-02-10", "3.40282346e+38", null)', '"1970-01-01"');
shouldBe('stepUp("2010-02-10", "1", "2010-02-10")', '"2010-02-10"');
shouldBe('stepDown("2010-02-10", "1", "2010-02-10")', '"2010-02-10"');
debug('stepDown()/stepUp() for stepMismatch values');
shouldBe('stepDown("2010-02-10", "3", "2010-02-06")', '"2010-02-09"');
shouldBe('stepUp("1970-01-02", "2", "")', '"1970-01-03"');
shouldBe('stepUp("2010-02-10")', '"2010-02-10"');
// The following check was disabled because it tries to open a calendar picker and DRT crashes.
//shouldBe('stepDown("2010-02-10")', '"2010-02-10"');
debug('');
</script>
......
2012-04-24 Kent Tamura <tkent@chromium.org>
Calendar Picker: Open a calendar picker by keyboard operation
https://bugs.webkit.org/show_bug.cgi?id=84680
Reviewed by Kentaro Hara.
- Open a calendar picker by the down arrow key.
- Remove stepping down/up by keyboard and wheel operations.
This behavior was for text fields with spin buttons. Because the date
type doesn't have spin buttons, we should remove this behavior.
No new tests for opening a calendar picker. This behavior is not
testable by DRT yet. For removal of stepping up/down,
fast/forms/date/date-stepup-stepdown-from-renderer.html is updated.
* html/BaseDateAndTimeInputType.cpp:
(WebCore::BaseDateAndTimeInputType::handleKeydownEvent):
Check shouldHaveSpinButton() before spin button key operations.
(WebCore::BaseDateAndTimeInputType::handleWheelEvent):
Check shouldHaveSpinButton() before spin button wheel operations.
* html/BaseDateAndTimeInputType.h:
(BaseDateAndTimeInputType):
Make handleKeydownEvent() protected because a subclass overrides it.
* html/DateInputType.cpp:
(WebCore::DateInputType::handleKeydownEvent):
Open a calendar picker by the down arrow key.
* html/DateInputType.h:
(DateInputType): Add handleKeydownEvent() declaration.
* html/shadow/CalendarPickerElement.h:
(CalendarPickerElement): Make openPopup() public because DateInputType calls it.
2012-04-24 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r115099, r115102, and r115127.
......@@ -132,14 +132,16 @@ double BaseDateAndTimeInputType::stepBase() const
void BaseDateAndTimeInputType::handleKeydownEvent(KeyboardEvent* event)
{
handleKeydownEventForSpinButton(event);
if (shouldHaveSpinButton())
handleKeydownEventForSpinButton(event);
if (!event->defaultHandled())
TextFieldInputType::handleKeydownEvent(event);
}
void BaseDateAndTimeInputType::handleWheelEvent(WheelEvent* event)
{
handleWheelEventForSpinButton(event);
if (shouldHaveSpinButton())
handleWheelEventForSpinButton(event);
}
double BaseDateAndTimeInputType::parseToDouble(const String& src, double defaultValue) const
......
......@@ -41,6 +41,7 @@ namespace WebCore {
class BaseDateAndTimeInputType : public TextFieldInputType {
protected:
BaseDateAndTimeInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE;
virtual double parseToDouble(const String&, double) const OVERRIDE;
virtual bool parseToDateComponents(const String&, DateComponents*) const OVERRIDE;
String serializeWithComponents(const DateComponents&) const;
......@@ -62,7 +63,6 @@ private:
virtual bool isSteppable() const OVERRIDE;
virtual bool stepMismatch(const String&, double) const OVERRIDE;
virtual double stepBase() const OVERRIDE;
virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE;
virtual void handleWheelEvent(WheelEvent*) OVERRIDE;
virtual String serialize(double) const OVERRIDE;
virtual String serializeWithMilliseconds(double) const;
......
......@@ -35,6 +35,7 @@
#include "DateComponents.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "KeyboardEvent.h"
#include "LocalizedDate.h"
#include <wtf/PassOwnPtr.h>
......@@ -129,6 +130,19 @@ bool DateInputType::shouldHaveSpinButton() const
return false;
}
void DateInputType::handleKeydownEvent(KeyboardEvent* event)
{
if (element()->disabled() || element()->readOnly())
return;
if (event->keyIdentifier() == "Down") {
if (m_pickerElement)
m_pickerElement->openPopup();
event->setDefaultHandled();
return;
}
BaseDateAndTimeInputType::handleKeydownEvent(event);
}
void DateInputType::handleBlurEvent()
{
if (m_pickerElement)
......
......@@ -58,6 +58,7 @@ private:
#if ENABLE(CALENDAR_PICKER)
virtual void createShadowSubtree() OVERRIDE;
virtual void destroyShadowSubtree() OVERRIDE;
virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE;
virtual void handleBlurEvent() OVERRIDE;
virtual bool supportsPlaceholder() const OVERRIDE;
virtual bool usesFixedPlaceholder() const OVERRIDE;
......
......@@ -43,6 +43,7 @@ class PagePopup;
class CalendarPickerElement : public HTMLDivElement, public PagePopupClient {
public:
static PassRefPtr<CalendarPickerElement> create(Document*);
void openPopup();
void closePopup();
private:
......@@ -58,7 +59,6 @@ private:
virtual void didClosePopup() OVERRIDE;
HTMLInputElement* hostInput();
void openPopup();
PagePopup* m_popup;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment