- Revision
- 141960
- Author
- [email protected]
- Date
- 2013-02-05 18:34:32 -0800 (Tue, 05 Feb 2013)
Log Message
INPUT_MULTIPLE_FIELDS_UI: Read-only inputs should be focusable
https://bugs.webkit.org/show_bug.cgi?id=108795
Reviewed by Kentaro Hara.
Source/WebCore:
According to the standard [1], readonly form controls should be focusable.
- Sub-fields should be focusable if they are read-only. We should check
isDisabled mainly.
- All keyboard operations should not be handled if a field is disabled,
and focus navigation keyboard operations should be handled even if a
field is read-only.
[1] http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#the-readonly-attribute
No new tests. Update
fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html
for the new behavior.
* html/BaseMultipleFieldsDateAndTimeInputType.cpp:
(WebCore::BaseMultipleFieldsDateAndTimeInputType::isKeyboardFocusable):
Make <input> focusable even if it is read-only.
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditElement::isFieldOwnerDisabled):
Separate isFieldOwnerDisabledOrReadOnly into two.
(WebCore::DateTimeEditElement::isFieldOwnerReadOnly): Ditto.
(WebCore::DateTimeEditElement::updateUIState):
We don't need to focus out if this is read-only.
* html/shadow/DateTimeEditElement.h:
(DateTimeEditElement): Separate isFieldOwnerDisabledOrReadOnly into two.
* html/shadow/DateTimeFieldElement.cpp:
(WebCore::DateTimeFieldElement::defaultEventHandler):
Skip handleKeyboardEvent if the field is disabled or the owner input is
disabled or read-only. handleKeyboardEvent handles editing key
operations.
(WebCore::DateTimeFieldElement::defaultKeyboardEventHandler):
If this field is disabled or the owner input is disabled, all keyboard
inputs are ignored.
If this field is read-only, we handle only left and right arrows to
change focus, and skip down/up/backspace/del keys.
(WebCore::DateTimeFieldElement::isFieldOwnerDisabled):
A helper function to check disable state of the owner input.
(WebCore::DateTimeFieldElement::isFieldOwnerReadOnly):
A helper function to check read-only state of the owner input.
(WebCore::DateTimeFieldElement::isFocusable):
This field should be focusable if it is read-only and not disabled.
* html/shadow/DateTimeFieldElement.h:
(FieldOwner): Separate isFieldOwnerDisabledOrReadOnly into two.
(DateTimeFieldElement):
Declare isFieldOwnerDisabled and isFieldOwnerReadOnly.
* html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::handleKeyboardEvent):
Remove redundant isDisabled check. It is done in
DateTimeFieldElement::defaultEventHandler.
LayoutTests:
* fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt:
* fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (141959 => 141960)
--- trunk/LayoutTests/ChangeLog 2013-02-06 02:27:39 UTC (rev 141959)
+++ trunk/LayoutTests/ChangeLog 2013-02-06 02:34:32 UTC (rev 141960)
@@ -1,3 +1,13 @@
+2013-02-05 Kent Tamura <[email protected]>
+
+ INPUT_MULTIPLE_FIELDS_UI: Read-only inputs should be focusable
+ https://bugs.webkit.org/show_bug.cgi?id=108795
+
+ Reviewed by Kentaro Hara.
+
+ * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt:
+ * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html:
+
2013-02-05 Eric Carlson <[email protected]>
[Mac] Complete plumbing so captions menu can indicate track type
Modified: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt (141959 => 141960)
--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt 2013-02-06 02:27:39 UTC (rev 141959)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt 2013-02-06 02:34:32 UTC (rev 141960)
@@ -38,8 +38,17 @@
PASS input.value is "03:05"
PASS input.value is "07:05"
PASS document.activeElement.id is "another"
-== Tab navigation should skip disabled/readonly inputs ==
+== Tab navigation should skip disabled inputs ==
PASS document.activeElement.id is "another"
+== Tab navigation should not skip readonly inputs, but editing operations should be ignored. ==
+PASS document.activeElement.id is "input"
+PASS pseudoOfFocusedSubField(input) is "-webkit-datetime-edit-hour-field"
+PASS keyDown("upArrow"); input.value is "01:01"
+PASS keyDown("downArrow"); input.value is "01:01"
+PASS pseudoOfFocusedSubField(input) is "-webkit-datetime-edit-minute-field"
+PASS keyDown("3"); input.value is "01:01"
+PASS pseudoOfFocusedSubField(input) is "-webkit-datetime-edit-ampm-field"
+PASS pseudoOfFocusedSubField(input) is "-webkit-datetime-edit-minute-field"
PASS document.activeElement.id is "another"
== Shfit+Tab key ==
PASS input.value is "15:00"
Modified: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html (141959 => 141960)
--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html 2013-02-06 02:27:39 UTC (rev 141959)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html 2013-02-06 02:34:32 UTC (rev 141960)
@@ -26,6 +26,11 @@
internals.settings.setLangAttributeAwareFormControlUIEnabled(true);
var input = document.getElementById("input");
+function pseudoOfFocusedSubField(host)
+{
+ return internals.youngestShadowRoot(host).activeElement.getAttribute("pseudo")
+}
+
function keyDown(key, modifiers)
{
if (!window.eventSender)
@@ -136,16 +141,31 @@
keyDown('\t');
shouldBeEqualToString('document.activeElement.id', 'another');
-beginTest('Tab navigation should skip disabled/readonly inputs', '');
+beginTest('Tab navigation should skip disabled inputs', '');
before.focus();
input.disabled = true;
keyDown('\t');
shouldBeEqualToString('document.activeElement.id', 'another');
input.disabled = false;
+beginTest('Tab navigation should not skip readonly inputs, but editing operations should be ignored.', '');
before.focus();
+input.value = '01:01';
input.readOnly = true;
keyDown('\t');
+shouldBeEqualToString('document.activeElement.id', 'input');
+shouldBeEqualToString('pseudoOfFocusedSubField(input)', '-webkit-datetime-edit-hour-field');
+shouldBeEqualToString('keyDown("upArrow"); input.value', '01:01');
+shouldBeEqualToString('keyDown("downArrow"); input.value', '01:01');
+keyDown('rightArrow');
+shouldBeEqualToString('pseudoOfFocusedSubField(input)', '-webkit-datetime-edit-minute-field');
+shouldBeEqualToString('keyDown("3"); input.value', '01:01');
+keyDown('\t');
+shouldBeEqualToString('pseudoOfFocusedSubField(input)', '-webkit-datetime-edit-ampm-field');
+keyDown('leftArrow');
+shouldBeEqualToString('pseudoOfFocusedSubField(input)', '-webkit-datetime-edit-minute-field');
+keyDown('\t');
+keyDown('\t');
shouldBeEqualToString('document.activeElement.id', 'another');
input.readOnly = false;
Modified: trunk/Source/WebCore/ChangeLog (141959 => 141960)
--- trunk/Source/WebCore/ChangeLog 2013-02-06 02:27:39 UTC (rev 141959)
+++ trunk/Source/WebCore/ChangeLog 2013-02-06 02:34:32 UTC (rev 141960)
@@ -1,3 +1,60 @@
+2013-02-05 Kent Tamura <[email protected]>
+
+ INPUT_MULTIPLE_FIELDS_UI: Read-only inputs should be focusable
+ https://bugs.webkit.org/show_bug.cgi?id=108795
+
+ Reviewed by Kentaro Hara.
+
+ According to the standard [1], readonly form controls should be focusable.
+
+ - Sub-fields should be focusable if they are read-only. We should check
+ isDisabled mainly.
+ - All keyboard operations should not be handled if a field is disabled,
+ and focus navigation keyboard operations should be handled even if a
+ field is read-only.
+
+ [1] http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#the-readonly-attribute
+
+ No new tests. Update
+ fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html
+ for the new behavior.
+
+ * html/BaseMultipleFieldsDateAndTimeInputType.cpp:
+ (WebCore::BaseMultipleFieldsDateAndTimeInputType::isKeyboardFocusable):
+ Make <input> focusable even if it is read-only.
+ * html/shadow/DateTimeEditElement.cpp:
+ (WebCore::DateTimeEditElement::isFieldOwnerDisabled):
+ Separate isFieldOwnerDisabledOrReadOnly into two.
+ (WebCore::DateTimeEditElement::isFieldOwnerReadOnly): Ditto.
+ (WebCore::DateTimeEditElement::updateUIState):
+ We don't need to focus out if this is read-only.
+ * html/shadow/DateTimeEditElement.h:
+ (DateTimeEditElement): Separate isFieldOwnerDisabledOrReadOnly into two.
+ * html/shadow/DateTimeFieldElement.cpp:
+ (WebCore::DateTimeFieldElement::defaultEventHandler):
+ Skip handleKeyboardEvent if the field is disabled or the owner input is
+ disabled or read-only. handleKeyboardEvent handles editing key
+ operations.
+ (WebCore::DateTimeFieldElement::defaultKeyboardEventHandler):
+ If this field is disabled or the owner input is disabled, all keyboard
+ inputs are ignored.
+ If this field is read-only, we handle only left and right arrows to
+ change focus, and skip down/up/backspace/del keys.
+ (WebCore::DateTimeFieldElement::isFieldOwnerDisabled):
+ A helper function to check disable state of the owner input.
+ (WebCore::DateTimeFieldElement::isFieldOwnerReadOnly):
+ A helper function to check read-only state of the owner input.
+ (WebCore::DateTimeFieldElement::isFocusable):
+ This field should be focusable if it is read-only and not disabled.
+ * html/shadow/DateTimeFieldElement.h:
+ (FieldOwner): Separate isFieldOwnerDisabledOrReadOnly into two.
+ (DateTimeFieldElement):
+ Declare isFieldOwnerDisabled and isFieldOwnerReadOnly.
+ * html/shadow/DateTimeNumericFieldElement.cpp:
+ (WebCore::DateTimeNumericFieldElement::handleKeyboardEvent):
+ Remove redundant isDisabled check. It is done in
+ DateTimeFieldElement::defaultEventHandler.
+
2013-02-05 Eric Carlson <[email protected]>
[Mac] Complete plumbing so captions menu can indicate track type
Modified: trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp (141959 => 141960)
--- trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp 2013-02-06 02:27:39 UTC (rev 141959)
+++ trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp 2013-02-06 02:34:32 UTC (rev 141960)
@@ -296,8 +296,7 @@
bool BaseMultipleFieldsDateAndTimeInputType::isKeyboardFocusable(KeyboardEvent*) const
{
- // FIXME: This should be focusable even if readOnly(). webkit.org/b/108795.
- return element()->isTextFormControlFocusable() && !element()->readOnly();
+ return element()->isTextFormControlFocusable();
}
bool BaseMultipleFieldsDateAndTimeInputType::isMouseFocusable() const
Modified: trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp (141959 => 141960)
--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp 2013-02-06 02:27:39 UTC (rev 141959)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp 2013-02-06 02:34:32 UTC (rev 141960)
@@ -575,11 +575,16 @@
return m_editControlOwner && m_editControlOwner->isEditControlOwnerDisabled();
}
-bool DateTimeEditElement::isFieldOwnerDisabledOrReadOnly() const
+bool DateTimeEditElement::isFieldOwnerDisabled() const
{
- return isDisabled() || isReadOnly();
+ return isDisabled();
}
+bool DateTimeEditElement::isFieldOwnerReadOnly() const
+{
+ return isReadOnly();
+}
+
bool DateTimeEditElement::isReadOnly() const
{
return m_editControlOwner && m_editControlOwner->isEditControlOwnerReadOnly();
@@ -711,7 +716,7 @@
void DateTimeEditElement::updateUIState()
{
- if (isDisabled() || isReadOnly()) {
+ if (isDisabled()) {
if (DateTimeFieldElement* field = focusedField())
field->blur();
}
Modified: trunk/Source/WebCore/html/shadow/DateTimeEditElement.h (141959 => 141960)
--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.h 2013-02-06 02:27:39 UTC (rev 141959)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.h 2013-02-06 02:34:32 UTC (rev 141960)
@@ -138,7 +138,8 @@
virtual void fieldValueChanged() OVERRIDE FINAL;
virtual bool focusOnNextField(const DateTimeFieldElement&) OVERRIDE FINAL;
virtual bool focusOnPreviousField(const DateTimeFieldElement&) OVERRIDE FINAL;
- virtual bool isFieldOwnerDisabledOrReadOnly() const OVERRIDE FINAL;
+ virtual bool isFieldOwnerDisabled() const OVERRIDE FINAL;
+ virtual bool isFieldOwnerReadOnly() const OVERRIDE FINAL;
virtual AtomicString localeIdentifier() const OVERRIDE FINAL;
Vector<DateTimeFieldElement*, maximumNumberOfFields> m_fields;
Modified: trunk/Source/WebCore/html/shadow/DateTimeFieldElement.cpp (141959 => 141960)
--- trunk/Source/WebCore/html/shadow/DateTimeFieldElement.cpp 2013-02-06 02:27:39 UTC (rev 141959)
+++ trunk/Source/WebCore/html/shadow/DateTimeFieldElement.cpp 2013-02-06 02:34:32 UTC (rev 141960)
@@ -63,9 +63,11 @@
if (event->isKeyboardEvent()) {
KeyboardEvent* keyboardEvent = static_cast<KeyboardEvent*>(event);
- handleKeyboardEvent(keyboardEvent);
- if (keyboardEvent->defaultHandled())
- return;
+ if (!isDisabled() && !isFieldOwnerDisabled() && !isFieldOwnerReadOnly()) {
+ handleKeyboardEvent(keyboardEvent);
+ if (keyboardEvent->defaultHandled())
+ return;
+ }
defaultKeyboardEventHandler(keyboardEvent);
if (keyboardEvent->defaultHandled())
return;
@@ -79,16 +81,11 @@
if (keyboardEvent->type() != eventNames().keydownEvent)
return;
+ if (isDisabled() || isFieldOwnerDisabled())
+ return;
+
const String& keyIdentifier = keyboardEvent->keyIdentifier();
- if (keyIdentifier == "Down") {
- if (keyboardEvent->getModifierState("Alt"))
- return;
- keyboardEvent->setDefaultHandled();
- stepDown();
- return;
- }
-
if (keyIdentifier == "Left") {
if (!m_fieldOwner)
return;
@@ -109,6 +106,17 @@
return;
}
+ if (isFieldOwnerReadOnly())
+ return;
+
+ if (keyIdentifier == "Down") {
+ if (keyboardEvent->getModifierState("Alt"))
+ return;
+ keyboardEvent->setDefaultHandled();
+ stepDown();
+ return;
+ }
+
if (keyIdentifier == "Up") {
keyboardEvent->setDefaultHandled();
stepUp();
@@ -155,11 +163,21 @@
return true;
}
+bool DateTimeFieldElement::isFieldOwnerDisabled() const
+{
+ return m_fieldOwner && m_fieldOwner->isFieldOwnerDisabled();
+}
+
+bool DateTimeFieldElement::isFieldOwnerReadOnly() const
+{
+ return m_fieldOwner && m_fieldOwner->isFieldOwnerReadOnly();
+}
+
bool DateTimeFieldElement::isFocusable() const
{
if (isDisabled())
return false;
- if (m_fieldOwner && m_fieldOwner->isFieldOwnerDisabledOrReadOnly())
+ if (isFieldOwnerDisabled())
return false;
return HTMLElement::isFocusable();
}
Modified: trunk/Source/WebCore/html/shadow/DateTimeFieldElement.h (141959 => 141960)
--- trunk/Source/WebCore/html/shadow/DateTimeFieldElement.h 2013-02-06 02:27:39 UTC (rev 141959)
+++ trunk/Source/WebCore/html/shadow/DateTimeFieldElement.h 2013-02-06 02:34:32 UTC (rev 141960)
@@ -56,7 +56,8 @@
virtual void fieldValueChanged() = 0;
virtual bool focusOnNextField(const DateTimeFieldElement&) = 0;
virtual bool focusOnPreviousField(const DateTimeFieldElement&) = 0;
- virtual bool isFieldOwnerDisabledOrReadOnly() const = 0;
+ virtual bool isFieldOwnerDisabled() const = 0;
+ virtual bool isFieldOwnerReadOnly() const = 0;
virtual AtomicString localeIdentifier() const = 0;
};
@@ -93,6 +94,8 @@
private:
void defaultKeyboardEventHandler(KeyboardEvent*);
virtual bool isDateTimeFieldElement() const OVERRIDE;
+ bool isFieldOwnerDisabled() const;
+ bool isFieldOwnerReadOnly() const;
virtual bool supportsFocus() const OVERRIDE FINAL;
FieldOwner* m_fieldOwner;
Modified: trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp (141959 => 141960)
--- trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp 2013-02-06 02:27:39 UTC (rev 141959)
+++ trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp 2013-02-06 02:34:32 UTC (rev 141960)
@@ -126,9 +126,7 @@
void DateTimeNumericFieldElement::handleKeyboardEvent(KeyboardEvent* keyboardEvent)
{
- if (isDisabled())
- return;
-
+ ASSERT(!isDisabled());
if (keyboardEvent->type() != eventNames().keypressEvent)
return;