INPUT_MULTIPLE_FIELDS_UI: Disable focus navigation by right/left keys in RTL locales
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Dec 2012 10:20:05 +0000 (10:20 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Dec 2012 10:20:05 +0000 (10:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=104644

Reviewed by Hajime Morita.

Source/WebCore:

Pressing the left key should focus on the field at the left of the
current focused field, and pressing the right key should focus on the
field at the right of the current focused field. This works well in LTR
locales.
In RTL locale, the current code doesn't work. We disable this behavior
for RTL locales for now. This issue will be handled in Bug 104650.

No new tests. Update some *-multiple-fields tests for new behavior.

* html/shadow/DateTimeFieldElement.cpp:
(WebCore::DateTimeFieldElement::defaultKeyboardEventHandler):
If this sub-field is in an RTL locale, we don't change focus.
(WebCore::DateTimeFieldElement::localeForOwner):
Moved from DateTimeNumericFieldElement.
* html/shadow/DateTimeFieldElement.h:
(DateTimeFieldElement): Remove isRTL, add localeForOwner.
* html/shadow/DateTimeNumericFieldElement.cpp: Remove localeForOwner.
* html/shadow/DateTimeNumericFieldElement.h:
(DateTimeNumericFieldElement): Ditto.

LayoutTests:

* fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events-expected.txt:
* fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events.html:
* fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events-expected.txt:
* fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events.html:
* fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events-expected.txt:
* fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events.html:
* fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt:
* fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html:

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events-expected.txt
LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events.html
LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events-expected.txt
LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events.html
LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events-expected.txt
LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events.html
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html
Source/WebCore/ChangeLog
Source/WebCore/html/shadow/DateTimeFieldElement.cpp
Source/WebCore/html/shadow/DateTimeFieldElement.h
Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp
Source/WebCore/html/shadow/DateTimeNumericFieldElement.h

index 31eb26e..1da27d4 100644 (file)
@@ -1,3 +1,19 @@
+2012-12-11  Kent Tamura  <tkent@chromium.org>
+
+        INPUT_MULTIPLE_FIELDS_UI: Disable focus navigation by right/left keys in RTL locales
+        https://bugs.webkit.org/show_bug.cgi?id=104644
+
+        Reviewed by Hajime Morita.
+
+        * fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events-expected.txt:
+        * fast/forms/date-multiple-fields/date-multiple-fields-keyboard-events.html:
+        * fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events-expected.txt:
+        * fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-keyboard-events.html:
+        * fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events-expected.txt:
+        * fast/forms/month-multiple-fields/month-multiple-fields-keyboard-events.html:
+        * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt:
+        * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html:
+
 2012-12-11  Pavel Podivilov  <podivilov@google.com>
 
         [Chromium] Unreviewed, remove "platform/blackberry [ WontFix ]" from test expectations
index c012cc5..5c1efd6 100644 (file)
@@ -51,7 +51,8 @@ PASS input.value is ""
 == Typeahead ==
 PASS input.value is "2012-12-01"
 PASS input.value is "2012-12-02"
-== RTL Left/Right keys ==
+== RTL focus navigation ==
+The tests in this block fail on platforms without the lang-attribute-aware-form-control-UI feature.
 PASS input.value is "2012-09-01"
 PASS input.value is "2012-02-01"
 PASS input.value is "2012-03-01"
index 17da50f..e94d5eb 100644 (file)
@@ -189,18 +189,20 @@ keyDown('rightArrow'); // -> 12/[01]/2012
 keyDown('2'); //          -> 12/[02]/2012
 shouldBeEqualToString('input.value', '2012-12-02');
 
-// The tests in the following block fail on platforms without the
-// lang-attribute-aware-form-control-UI feature.
 input.setAttribute("lang", "he-il");
-beginTest('RTL Left/Right keys', '2012-09-28');
-// 2012/09/[28]
-keyDown('1'); //          -> 2012/09/[01]
+beginTest('RTL focus navigation', '2012-09-28');
+debug('The tests in this block fail on platforms without the lang-attribute-aware-form-control-UI feature.');
+// Both of the logical order and visual order are: dd/MM/yyyy
+// Initial state:            [28]/09/2012
+keyDown('upArrow'); //    -> [29]/09/2012
+keyDown('rightArrow'); // -> [01]/09/2012
+keyDown('1'); //          -> [01]/09/2012
 shouldBeEqualToString('input.value', '2012-09-01');
-keyDown('rightArrow'); //  -> 2012/[09]/01
-keyDown('2'); //          -> [2012]/02/01
+keyDown('\t'); //         -> 01/[09]/2012
+keyDown('2'); //          -> 01/02/[2012]
 shouldBeEqualToString('input.value', '2012-02-01');
-keyDown('leftArrow'); // -> 2012/[02]/01
-keyDown('3'); //          -> [2012]/03/01
+keyDown('\t', ['shiftKey']); // -> 01/[02]/2012/
+keyDown('3'); //          -> 01/03/[2012]
 shouldBeEqualToString('input.value', '2012-03-01');
 input.removeAttribute("lang");
 
index b8ba6ac..2edb940 100644 (file)
@@ -48,7 +48,8 @@ PASS input.value is ""
 == Typeahead ==
 PASS input.value is "2012-12-01T00:00"
 PASS input.value is "2012-12-02T00:00"
-== RTL Left/Right keys ==
+== RTL focus navigation ==
+The tests in this block fail on platforms without the lang-attribute-aware-form-control-UI feature.
 PASS input.value is "2012-09-01T23:00"
 PASS input.value is "2012-02-01T01:00"
 PASS input.value is "0008-03-01T01:00"
index 77b013f..2f14ced 100644 (file)
@@ -199,22 +199,22 @@ keyDown('rightArrow'); // -> 12/[01]/2012 12:00 AM
 keyDown('2'); //          -> 12/[02]/2012 12:00 AM
 shouldBeEqualToString('input.value', '2012-12-02T00:00');
 
-// The tests in the following block fail on platforms without the
-// lang-attribute-aware-form-control-UI feature.
 input.setAttribute('lang', 'he-il');
-beginTest('RTL Left/Right keys', '2012-09-28T23:00');
-// 00:23 2012/09/[28]
-keyDown('1'); //          -> 00:23 2012/09/[01]
+beginTest('RTL focus navigation', '2012-09-28T23:00');
+debug('The tests in this block fail on platforms without the lang-attribute-aware-form-control-UI feature.');
+// The logicla order: dd/MM/yyyy hh:mm
+// The visual order: hh:mm dd/MM/yyyy
+keyDown('1'); //          -> 23:00 [01]/09/2012
 shouldBeEqualToString('input.value', '2012-09-01T23:00');
-keyDown('rightArrow'); //  -> 00:23 2012/[09]/01
-keyDown('2'); //          -> 00:23 [2012]/02/01
-keyDown('rightArrow'); //  -> 00:[23] 2012/09/01
-keyDown('1'); //  -> 00:[01] 2012/09/01
+keyDown('\t'); //         -> 23:00 01/[09]/2012
+keyDown('2'); //          -> 23:00 01/02/[2012]
+keyDown('\t'); //         -> [23]:00 2012/09/01
+keyDown('1'); //          -> [01]:00 01/09/2012
 shouldBeEqualToString('input.value', '2012-02-01T01:00');
-keyDown('leftArrow'); // -> 00:01 [2012]/09/01
-keyDown('8'); //          -> 00:01 [0008]/09/01
-keyDown('leftArrow'); // -> 00:01 0008/[09]/01
-keyDown('3'); //          -> 00:01 [0008]/03/01
+keyDown('\t', ['shiftKey']); // -> 01:00 01/09/[2012]
+keyDown('8'); //                -> 01:00 01/09/[0008]
+keyDown('\t', ['shiftKey']); // -> 01:00 01/[09]/0008
+keyDown('3'); //                -> 01:00 01/03/[0008]
 shouldBeEqualToString('input.value', '0008-03-01T01:00');
 input.removeAttribute('lang');
 
index 14c9648..c698d99 100644 (file)
@@ -66,7 +66,8 @@ PASS input.value is "2012-12"
 PASS input.value is "2012-12"
 == Typeahead should search from current selection ==
 PASS input.value is "2012-06"
-== RTL Left/Right keys ==
+== RTL focus navigation ==
+The tests in this block fail on platforms without the lang-attribute-aware-form-control-UI feature.
 PASS input.value is "2012-10"
 PASS input.value is "0002-10"
 PASS input.value is "0002-11"
index 5a84e91..972892b 100644 (file)
@@ -205,14 +205,13 @@ beginTest('Typeahead should search from current selection', '2012-01');
 keyDown('j'); //          -> [Jun] 2012
 shouldBeEqualToString('input.value', '2012-06');
 
-// The tests in the following block fail on platforms without the
-// lang-attribute-aware-form-control-UI feature.
 input.setAttribute("lang", "he-il");
-beginTest('RTL Left/Right keys', '2012-09');
+beginTest('RTL focus navigation', '2012-09');
+debug('The tests in this block fail on platforms without the lang-attribute-aware-form-control-UI feature.');
 keyDown('upArrow'); // -> 2012 [M10]
 shouldBeEqualToString('input.value', '2012-10');
-keyDown('leftArrow'); // -> [2012] M10
-keyDown('2'); //         -> [0002] M10
+keyDown('\t'); //      -> [2012] M10
+keyDown('2'); //       -> [0002] M10
 shouldBeEqualToString('input.value', '0002-10');
 keyDown('\t', ['shiftKey']); // -> 0002 [M10]
 keyDown('upArrow'); //          -> 0002 [M11]
index 1b9f626..66f04e8 100644 (file)
@@ -44,7 +44,8 @@ PASS input.value is ""
 == Typeahead ==
 PASS input.value is "12:01:56"
 PASS input.value is "12:02:56"
-== RTL Left/Right keys ==
+== RTL focus navigation ==
+The tests in this block fail on platforms without the lang-attribute-aware-form-control-UI feature.
 PASS input.value is "01:56"
 PASS input.value is "01:02"
 PASS input.value is "03:02"
index eb2164d..194dcad 100644 (file)
@@ -164,16 +164,15 @@ keyDown('leftArrow');
 keyDown('2');
 shouldBeEqualToString('input.value', '12:02:56');
 
-// The tests in the following block fail on platforms without the
-// lang-attribute-aware-form-control-UI feature.
 input.setAttribute("lang", "he-il");
-beginTest('RTL Left/Right keys', '04:56');
+beginTest('RTL focus navigation', '04:56');
+debug('The tests in this block fail on platforms without the lang-attribute-aware-form-control-UI feature.');
 keyDown('1'); //          -> [01]:56
 shouldBeEqualToString('input.value', '01:56');
-keyDown('rightArrow'); // -> 01:[56]
+keyDown('\t'); //          -> 01:[56]
 keyDown('2'); //          -> 01:[02]
 shouldBeEqualToString('input.value', '01:02');
-keyDown('leftArrow'); //  -> [01]:02
+keyDown('\t', ['shiftKey']); // -> [01]:02
 keyDown('3'); //          -> [03]:02
 shouldBeEqualToString('input.value', '03:02');
 input.removeAttribute("lang");
index 31ed288..34322f0 100644 (file)
@@ -1,3 +1,30 @@
+2012-12-11  Kent Tamura  <tkent@chromium.org>
+
+        INPUT_MULTIPLE_FIELDS_UI: Disable focus navigation by right/left keys in RTL locales
+        https://bugs.webkit.org/show_bug.cgi?id=104644
+
+        Reviewed by Hajime Morita.
+
+        Pressing the left key should focus on the field at the left of the
+        current focused field, and pressing the right key should focus on the
+        field at the right of the current focused field. This works well in LTR
+        locales.
+        In RTL locale, the current code doesn't work. We disable this behavior
+        for RTL locales for now. This issue will be handled in Bug 104650.
+
+        No new tests. Update some *-multiple-fields tests for new behavior.
+
+        * html/shadow/DateTimeFieldElement.cpp:
+        (WebCore::DateTimeFieldElement::defaultKeyboardEventHandler):
+        If this sub-field is in an RTL locale, we don't change focus.
+        (WebCore::DateTimeFieldElement::localeForOwner):
+        Moved from DateTimeNumericFieldElement.
+        * html/shadow/DateTimeFieldElement.h:
+        (DateTimeFieldElement): Remove isRTL, add localeForOwner.
+        * html/shadow/DateTimeNumericFieldElement.cpp: Remove localeForOwner.
+        * html/shadow/DateTimeNumericFieldElement.h:
+        (DateTimeNumericFieldElement): Ditto.
+
 2012-12-11  Pavel Podivilov  <podivilov@google.com>
 
         Remove pango files deleted at r137263 form WebCore.gypi.
index 1714cb9..4434c97 100644 (file)
@@ -31,6 +31,7 @@
 #include "HTMLNames.h"
 #include "KeyboardEvent.h"
 #include "LocalizedStrings.h"
+#include "PlatformLocale.h"
 #include "RenderObject.h"
 #include "Text.h"
 #include <wtf/text/WTFString.h>
@@ -90,7 +91,9 @@ void DateTimeFieldElement::defaultKeyboardEventHandler(KeyboardEvent* keyboardEv
     if (keyIdentifier == "Left") {
         if (!m_fieldOwner)
             return;
-        if (isRTL() ? m_fieldOwner->focusOnNextField(*this) : m_fieldOwner->focusOnPreviousField(*this))
+        // FIXME: We'd like to use FocusController::advanceFocus(FocusDirectionLeft, ...)
+        // but it doesn't work for shadow nodes. webkit.org/b/104650
+        if (!localeForOwner().isRTL() && m_fieldOwner->focusOnPreviousField(*this))
             keyboardEvent->setDefaultHandled();
         return;
     }
@@ -98,7 +101,9 @@ void DateTimeFieldElement::defaultKeyboardEventHandler(KeyboardEvent* keyboardEv
     if (keyIdentifier == "Right") {
         if (!m_fieldOwner)
             return;
-        if (isRTL() ? m_fieldOwner->focusOnPreviousField(*this) : m_fieldOwner->focusOnNextField(*this))
+        // FIXME: We'd like to use FocusController::advanceFocus(FocusDirectionRight, ...)
+        // but it doesn't work for shadow nodes. webkit.org/b/104650
+        if (!localeForOwner().isRTL() && m_fieldOwner->focusOnNextField(*this))
             keyboardEvent->setDefaultHandled();
         return;
     }
@@ -163,9 +168,9 @@ bool DateTimeFieldElement::isReadOnly() const
     return fastHasAttribute(readonlyAttr);
 }
 
-bool DateTimeFieldElement::isRTL() const
+Locale& DateTimeFieldElement::localeForOwner() const
 {
-    return renderer() && renderer()->style()->direction() == RTL;
+    return document()->getCachedLocale(localeIdentifier());
 }
 
 AtomicString DateTimeFieldElement::localeIdentifier() const
index d49c61b..ad97fb0 100644 (file)
@@ -84,6 +84,7 @@ protected:
     void focusOnNextField();
     virtual void handleKeyboardEvent(KeyboardEvent*) = 0;
     void initialize(const AtomicString& pseudo, const String& axHelpText);
+    Locale& localeForOwner() const;
     AtomicString localeIdentifier() const;
     virtual int maximum() const = 0;
     virtual int minimum() const = 0;
@@ -93,7 +94,6 @@ private:
     void defaultKeyboardEventHandler(KeyboardEvent*);
     virtual bool isDateTimeFieldElement() const OVERRIDE;
     virtual bool isFocusable() const OVERRIDE FINAL;
-    bool isRTL() const;
     virtual bool supportsFocus() const OVERRIDE FINAL;
 
     FieldOwner* m_fieldOwner;
index c9b062e..2cd7bf3 100644 (file)
@@ -150,11 +150,6 @@ bool DateTimeNumericFieldElement::hasValue() const
     return m_hasValue;
 }
 
-Locale& DateTimeNumericFieldElement::localeForOwner() const
-{
-    return document()->getCachedLocale(localeIdentifier());
-}
-
 int DateTimeNumericFieldElement::maximum() const
 {
     return m_range.maximum;
index 4babfdb..d413b93 100644 (file)
@@ -78,7 +78,6 @@ private:
     virtual String value() const OVERRIDE FINAL;
 
     String formatValue(int) const;
-    Locale& localeForOwner() const;
 
     DOMTimeStamp m_lastDigitCharTime;
     const String m_placeholder;