F4 key should open the picker popup on Windows and Linux
authorkeishi@webkit.org <keishi@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Oct 2012 14:04:09 +0000 (14:04 +0000)
committerkeishi@webkit.org <keishi@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Oct 2012 14:04:09 +0000 (14:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=98754

Reviewed by Kent Tamura.

Source/WebCore:

On Windows, F4 key is used to open the combo box popup. We will introduce the same keybinding for picker popups.

Added test to calendar-picker-key-operations.html, date-suggestion-picker-key-operations.html, time-suggestion-picker-key-operations.html.

* html/BaseMultipleFieldsDateAndTimeInputType.cpp:
(WebCore::BaseMultipleFieldsDateAndTimeInputType::handleKeydownEvent): Open picker on F4 key if it is enabled.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::shouldOpenPickerWithF4Key): Returns true if we want to enable the F4 key binding on this platform. Return false for default.
(WebCore):
* rendering/RenderTheme.h:
(RenderTheme):
* rendering/RenderThemeChromiumLinux.cpp:
(WebCore::RenderThemeChromiumLinux::shouldOpenPickerWithF4Key): Returns true.
(WebCore):
* rendering/RenderThemeChromiumLinux.h:
* rendering/RenderThemeChromiumWin.cpp:
(WebCore):
(WebCore::RenderThemeChromiumWin::shouldOpenPickerWithF4Key): Returns true.
* rendering/RenderThemeChromiumWin.h:
(RenderThemeChromiumWin):

LayoutTests:

* fast/forms/date/calendar-picker-key-operations.html:
* platform/chromium-win/fast/forms/date/calendar-picker-key-operations-expected.txt: Added.
* platform/chromium-win/platform/chromium/fast/forms/date/date-suggestion-picker-key-operations-expected.txt:
* platform/chromium-win/platform/chromium/fast/forms/time/time-suggestion-picker-key-operations-expected.txt:
* platform/chromium/fast/forms/date/date-suggestion-picker-key-operations-expected.txt:
* platform/chromium/fast/forms/date/date-suggestion-picker-key-operations.html:
* platform/chromium/fast/forms/time/time-suggestion-picker-key-operations-expected.txt:
* platform/chromium/fast/forms/time/time-suggestion-picker-key-operations.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@131054 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/date/calendar-picker-key-operations.html
LayoutTests/platform/chromium-win/fast/forms/date/calendar-picker-key-operations-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-win/platform/chromium/fast/forms/date/date-suggestion-picker-key-operations-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-win/platform/chromium/fast/forms/time/time-suggestion-picker-key-operations-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/forms/date/date-suggestion-picker-key-operations-expected.txt
LayoutTests/platform/chromium/fast/forms/date/date-suggestion-picker-key-operations.html
LayoutTests/platform/chromium/fast/forms/time/time-suggestion-picker-key-operations-expected.txt
LayoutTests/platform/chromium/fast/forms/time/time-suggestion-picker-key-operations.html
Source/WebCore/ChangeLog
Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeChromiumLinux.cpp
Source/WebCore/rendering/RenderThemeChromiumLinux.h
Source/WebCore/rendering/RenderThemeChromiumWin.cpp
Source/WebCore/rendering/RenderThemeChromiumWin.h

index 327585b..4f42e4d 100644 (file)
@@ -1,3 +1,19 @@
+2012-10-11  Keishi Hattori  <keishi@webkit.org>
+
+        F4 key should open the picker popup on Windows and Linux
+        https://bugs.webkit.org/show_bug.cgi?id=98754
+
+        Reviewed by Kent Tamura.
+
+        * fast/forms/date/calendar-picker-key-operations.html:
+        * platform/chromium-win/fast/forms/date/calendar-picker-key-operations-expected.txt: Added.
+        * platform/chromium-win/platform/chromium/fast/forms/date/date-suggestion-picker-key-operations-expected.txt:
+        * platform/chromium-win/platform/chromium/fast/forms/time/time-suggestion-picker-key-operations-expected.txt:
+        * platform/chromium/fast/forms/date/date-suggestion-picker-key-operations-expected.txt:
+        * platform/chromium/fast/forms/date/date-suggestion-picker-key-operations.html:
+        * platform/chromium/fast/forms/time/time-suggestion-picker-key-operations-expected.txt:
+        * platform/chromium/fast/forms/time/time-suggestion-picker-key-operations.html:
+
 2012-10-11  Ádám Kallai  <kadam@inf.u-szeged.hu>
 
         [Qt] Reviewing Qt TestExpectations. Unskip now passing tests.
index 3e875fc..7f36bf5 100644 (file)
@@ -116,6 +116,10 @@ function test2() {
     shouldBeNull('document.getElementById("mock-page-popup")');
     shouldBe('document.getElementById("date").value', '"1999-12-26"');
 
+    sendKey(document.getElementById('date'), "F4");
+    if (document.getElementById('mock-page-popup'))
+        testPassed("F4 opened picker.");
+
     finishJSTest();
 }
 
diff --git a/LayoutTests/platform/chromium-win/fast/forms/date/calendar-picker-key-operations-expected.txt b/LayoutTests/platform/chromium-win/fast/forms/date/calendar-picker-key-operations-expected.txt
new file mode 100644 (file)
index 0000000..cdf5d64
--- /dev/null
@@ -0,0 +1,60 @@
+Tests if calendar picker key bindings work as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Check that page popup doesn't exist at first.
+PASS document.getElementById("mock-page-popup") is null
+Check that page popup exists.
+PASS popupWindow.pagePopupController.toString() is "[object PagePopupController]"
+PASS selectedDate() is "2000-01-02"
+PASS currentMonth() is "2000-0"
+Check that arrow keys work properly even when going between weeks and months.
+PASS selectedDate() is "1999-12-26"
+PASS currentMonth() is "2000-0"
+PASS selectedDate() is "2000-01-02"
+PASS currentMonth() is "1999-11"
+PASS selectedDate() is "1999-12-26"
+PASS currentMonth() is "2000-0"
+PASS selectedDate() is "2000-01-02"
+PASS currentMonth() is "2000-0"
+PASS selectedDate() is "1999-12-26"
+PASS currentMonth() is "2000-0"
+PASS selectedDate() is "2000-01-08"
+PASS currentMonth() is "1999-11"
+PASS selectedDate() is "1999-12-26"
+PASS currentMonth() is "2000-0"
+press m
+FAIL selectedDate() should be 2000-01-26. Was 2000-01-30.
+PASS currentMonth() is "2000-1"
+press shift + m
+PASS selectedDate() is "1999-12-26"
+PASS currentMonth() is "2000-0"
+press y
+PASS selectedDate() is "2000-12-31"
+PASS currentMonth() is "2001-0"
+press shift + y
+PASS selectedDate() is "1999-12-26"
+PASS currentMonth() is "2000-0"
+press d
+PASS selectedDate() is "2009-12-27"
+PASS currentMonth() is "2010-0"
+press shift + d
+PASS selectedDate() is "1999-12-26"
+PASS currentMonth() is "2000-0"
+PASS document.getElementById("mock-page-popup") is null
+PASS document.getElementById("date").value is "1999-12-26"
+PASS testToday() || testToday() is true
+Check if tabbing works.
+PASS focusedElement() is ".days-area-container"
+PASS focusedElement() is ".today-button[value=Today]"
+PASS focusedElement() is ".clear-button[value=Clear]"
+PASS focusedElement() is ".year-month-button[value=<<]"
+PASS focusedElement() is ".clear-button[value=Clear]"
+PASS document.getElementById("mock-page-popup") is null
+PASS document.getElementById("date").value is "1999-12-26"
+PASS F4 opened picker.
+PASS successfullyParsed is true
+
+TEST COMPLETE
diff --git a/LayoutTests/platform/chromium-win/platform/chromium/fast/forms/date/date-suggestion-picker-key-operations-expected.txt b/LayoutTests/platform/chromium-win/platform/chromium/fast/forms/date/date-suggestion-picker-key-operations-expected.txt
new file mode 100644 (file)
index 0000000..c540a3f
--- /dev/null
@@ -0,0 +1,43 @@
+CONSOLE MESSAGE: line 89: null
+Tests that key bindings work as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Check that page popup doesn't exist at first.
+PASS document.getElementById("mock-page-popup") is null
+Check that page popup exists.
+PASS popupWindow.pagePopupController.toString() is "[object PagePopupController]"
+Check that up/down arrow keys work.
+PASS highlightedEntry() is null
+PASS highlightedEntry() is "2012-01-01"
+PASS highlightedEntry() is "2012-01-02"
+PASS highlightedEntry() is "2012-01-01"
+Check that up arrow key at top of list does nothing.
+PASS highlightedEntry() is "2012-01-01"
+PASS highlightedEntry() is "2012-01-02"
+Check that page up/down arrow keys work.
+PASS highlightedEntry() is "2012-02-09"
+PASS highlightedEntry() is "2012-02-29"
+PASS highlightedEntry() is "2012-01-21"
+PASS highlightedEntry() is "2012-02-29"
+PASS highlightedEntry() is "@openCalendarPicker"
+Check that down arrow key at bottom of list does nothing.
+PASS highlightedEntry() is "@openCalendarPicker"
+Check that enter key sets the highlighted value.
+PASS highlightedEntry() is "2012-03-08"
+PASS document.getElementById("mock-page-popup") is null
+PASS document.getElementById("date").value is "2012-03-08"
+Reopen popup.
+PASS highlightedEntry() is "@openCalendarPicker"
+Open calendar picker.
+Confirm calendar picker did open.
+PASS popupWindow.document.getElementById("main").classList.contains("calendar-picker") is true
+Check that escape key closes the popup.
+PASS document.getElementById("mock-page-popup") is null
+PASS document.getElementById("date").value is "2012-03-08"
+PASS F4 opened picker.
+PASS successfullyParsed is true
+
+TEST COMPLETE
diff --git a/LayoutTests/platform/chromium-win/platform/chromium/fast/forms/time/time-suggestion-picker-key-operations-expected.txt b/LayoutTests/platform/chromium-win/platform/chromium/fast/forms/time/time-suggestion-picker-key-operations-expected.txt
new file mode 100644 (file)
index 0000000..93e9445
--- /dev/null
@@ -0,0 +1,34 @@
+Check that page popup doesn't exist at first.
+PASS document.getElementById("mock-page-popup") is null
+PASS popupWindow.pagePopupController.toString() is "[object PagePopupController]"
+Check that page popup exists.
+PASS popupWindow.pagePopupController.toString() is "[object PagePopupController]"
+Check that up/down arrow keys work.
+PASS highlightedEntry() is null
+PASS highlightedEntry() is "01:01"
+PASS highlightedEntry() is "01:02"
+PASS highlightedEntry() is "01:01"
+Check that up arrow key at top of list does nothing.
+PASS highlightedEntry() is "01:01"
+PASS highlightedEntry() is "01:02"
+Check that page up/down arrow keys work.
+PASS highlightedEntry() is "01:40"
+PASS highlightedEntry() is "02:00"
+PASS highlightedEntry() is "01:21"
+PASS highlightedEntry() is "02:00"
+PASS highlightedEntry() is "02:08"
+Check that down arrow key at bottom of list does nothing.
+PASS highlightedEntry() is "02:08"
+Check that enter key sets the highlighted value.
+PASS highlightedEntry() is "02:07"
+PASS document.getElementById("mock-page-popup") is null
+PASS document.getElementById("time").value is "02:07"
+Reopen popup.
+Check that escape key closes the popup.
+PASS document.getElementById("mock-page-popup") is null
+PASS document.getElementById("time").value is "02:07"
+PASS F4 opened picker.
+PASS successfullyParsed is true
+
+TEST COMPLETE
index 969161f..38b1583 100644 (file)
@@ -29,15 +29,14 @@ PASS highlightedEntry() is "2012-03-08"
 PASS document.getElementById("mock-page-popup") is null
 PASS document.getElementById("date").value is "2012-03-08"
 Reopen popup.
-Check that escape key closes the popup.
-PASS document.getElementById("mock-page-popup") is null
-PASS document.getElementById("date").value is "2012-03-08"
-Reopen popup.
 PASS highlightedEntry() is "@openCalendarPicker"
 Open calendar picker.
 Confirm calendar picker did open.
 PASS popupWindow.document.getElementById("main").classList.contains("calendar-picker") is true
+Check that escape key closes the popup.
+PASS document.getElementById("mock-page-popup") is null
+PASS document.getElementById("date").value is "2012-03-08"
 PASS successfullyParsed is true
 
 TEST COMPLETE
+
index e124c63..49f83ba 100644 (file)
@@ -150,22 +150,7 @@ function test1() {
 
 function test2() {
     popupWindow.removeEventListener("resize", test2, false);
-
-    popupWindow.focus();
-
-    debug('Check that escape key closes the popup.');
-    eventSender.keyDown('\x1B');
-    shouldBeNull('document.getElementById("mock-page-popup")');
-    shouldBe('document.getElementById("date").value', '"2012-03-08"');
-
-    debug('Reopen popup.');
-    openPicker(document.getElementById('date'));
     popupWindow.addEventListener("resize", test3, false);
-}
-
-function test3() {
-    popupWindow.removeEventListener("resize", test3, false);
-    popupWindow.addEventListener("resize", test4, false);
 
     popupWindow.focus();
 
@@ -178,12 +163,21 @@ function test3() {
     eventSender.keyDown('\n');
 }
 
-function test4() {
-    popupWindow.removeEventListener("resize", test4, false);
+function test3() {
+    popupWindow.removeEventListener("resize", test3, false);
 
     debug('Confirm calendar picker did open.');
     shouldBeTrue('popupWindow.document.getElementById("main").classList.contains("calendar-picker")');
 
+    debug('Check that escape key closes the popup.');
+    eventSender.keyDown('\x1B');
+    shouldBeNull('document.getElementById("mock-page-popup")');
+    shouldBe('document.getElementById("date").value', '"2012-03-08"');
+
+    sendKey(document.getElementById('date'), "F4");
+    if (document.getElementById('mock-page-popup'))
+        testPassed("F4 opened picker.");
+
     clearTimeout(timeoutTimer);
     finishJSTest();
 }
index b96cee6..adce66a 100644 (file)
@@ -27,8 +27,7 @@ Reopen popup.
 Check that escape key closes the popup.
 PASS document.getElementById("mock-page-popup") is null
 PASS document.getElementById("time").value is "02:07"
-Reopen popup.
 PASS successfullyParsed is true
 
 TEST COMPLETE
+
index 9017cdc..bae9acd 100644 (file)
@@ -155,8 +155,9 @@ function test2() {
     shouldBeNull('document.getElementById("mock-page-popup")');
     shouldBe('document.getElementById("time").value', '"02:07"');
 
-    debug('Reopen popup.');
-    openPicker(document.getElementById('time'));
+    sendKey(document.getElementById('time'), "F4");
+    if (document.getElementById('mock-page-popup'))
+        testPassed("F4 opened picker.");
 
     clearTimeout(timeoutTimer);
     finishJSTest();
index 0541b66..c210fd0 100644 (file)
@@ -1,3 +1,31 @@
+2012-10-11  Keishi Hattori  <keishi@webkit.org>
+
+        F4 key should open the picker popup on Windows and Linux
+        https://bugs.webkit.org/show_bug.cgi?id=98754
+
+        Reviewed by Kent Tamura.
+
+        On Windows, F4 key is used to open the combo box popup. We will introduce the same keybinding for picker popups.
+
+        Added test to calendar-picker-key-operations.html, date-suggestion-picker-key-operations.html, time-suggestion-picker-key-operations.html.
+
+        * html/BaseMultipleFieldsDateAndTimeInputType.cpp:
+        (WebCore::BaseMultipleFieldsDateAndTimeInputType::handleKeydownEvent): Open picker on F4 key if it is enabled.
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::shouldOpenPickerWithF4Key): Returns true if we want to enable the F4 key binding on this platform. Return false for default.
+        (WebCore):
+        * rendering/RenderTheme.h:
+        (RenderTheme):
+        * rendering/RenderThemeChromiumLinux.cpp:
+        (WebCore::RenderThemeChromiumLinux::shouldOpenPickerWithF4Key): Returns true.
+        (WebCore):
+        * rendering/RenderThemeChromiumLinux.h:
+        * rendering/RenderThemeChromiumWin.cpp:
+        (WebCore):
+        (WebCore::RenderThemeChromiumWin::shouldOpenPickerWithF4Key): Returns true.
+        * rendering/RenderThemeChromiumWin.h:
+        (RenderThemeChromiumWin):
+
 2012-10-11  John J. Barton  <johnjbarton@chromium.org>
 
         Web Inspector: Zebra stripe the console
index f30086e..a4668e1 100644 (file)
@@ -187,8 +187,15 @@ void BaseMultipleFieldsDateAndTimeInputType::disabledAttributeChanged()
 
 void BaseMultipleFieldsDateAndTimeInputType::handleKeydownEvent(KeyboardEvent* event)
 {
-    if (m_pickerIndicatorIsVisible && event->keyIdentifier() == "Down" && event->getModifierState("Alt")) {
-        m_pickerIndicatorElement->openPopup();
+    Document* document = element()->document();
+    RefPtr<RenderTheme> theme = document->page() ? document->page()->theme() : RenderTheme::defaultTheme();
+    if (theme->shouldOpenPickerWithF4Key() && event->keyIdentifier() == "F4") {
+        if (m_pickerIndicatorElement)
+            m_pickerIndicatorElement->openPopup();
+        event->setDefaultHandled();
+    } else if (m_pickerIndicatorIsVisible && event->keyIdentifier() == "Down" && event->getModifierState("Alt")) {
+        if (m_pickerIndicatorElement)
+            m_pickerIndicatorElement->openPopup();
         event->setDefaultHandled();
     } else
         forwardEvent(event);
index e4259c4..bb19dc2 100644 (file)
@@ -1274,4 +1274,9 @@ String RenderTheme::fileListNameForWidth(const FileList* fileList, const Font& f
     return StringTruncator::centerTruncate(string, width, font, StringTruncator::EnableRoundingHacks);
 }
 
+bool RenderTheme::shouldOpenPickerWithF4Key() const
+{
+    return false;
+}
+
 } // namespace WebCore
index a63745a..5db2836 100644 (file)
@@ -244,6 +244,8 @@ public:
 
     virtual void paintPlugInSnapshotOverlay(RenderSnapshottedPlugIn*, const PaintInfo&, const LayoutPoint&) const { }
 
+    virtual bool shouldOpenPickerWithF4Key() const;
+
 protected:
     // The platform selection color.
     virtual Color platformActiveSelectionBackgroundColor() const;
index 90251ad..8af4fc7 100644 (file)
@@ -377,4 +377,9 @@ bool RenderThemeChromiumLinux::paintProgressBar(RenderObject* o, const PaintInfo
 
 #endif
 
+bool RenderThemeChromiumLinux::shouldOpenPickerWithF4Key() const
+{
+    return true;
+}
+
 } // namespace WebCore
index 3e23f5b..5fc4b35 100644 (file)
@@ -84,6 +84,8 @@ namespace WebCore {
         virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&);
 #endif
 
+        virtual bool shouldOpenPickerWithF4Key() const OVERRIDE;
+
         static void setSelectionColors(unsigned activeBackgroundColor,
                                        unsigned activeForegroundColor,
                                        unsigned inactiveBackgroundColor,
index 9f30a26..04e893f 100644 (file)
@@ -809,4 +809,9 @@ bool RenderThemeChromiumWin::paintProgressBar(RenderObject* o, const PaintInfo&
 
 #endif
 
+bool RenderThemeChromiumWin::shouldOpenPickerWithF4Key() const
+{
+    return true;
+}
+
 } // namespace WebCore
index 14134c5..85cca45 100644 (file)
@@ -100,6 +100,8 @@ namespace WebCore {
         virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&);
 #endif
 
+        virtual bool shouldOpenPickerWithF4Key() const OVERRIDE;
+
     protected:
         virtual double caretBlinkIntervalInternal() const;