Diff
Modified: trunk/LayoutTests/ChangeLog (141394 => 141395)
--- trunk/LayoutTests/ChangeLog 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/LayoutTests/ChangeLog 2013-01-31 11:17:40 UTC (rev 141395)
@@ -1,3 +1,13 @@
+2013-01-31 Kent Tamura <[email protected]>
+
+ Click on a label element won't select input[type=date]
+ https://bugs.webkit.org/show_bug.cgi?id=108428
+
+ Reviewed by Kentaro Hara.
+
+ * fast/forms/date/date-click-on-label-expected.txt: Added.
+ * fast/forms/date/date-click-on-label.html: Added.
+
2013-01-30 Yury Semikhatsky <[email protected]>
Web Inspector: test that nodes from the same detached DOM tree will get into one group in heap snapshot
Added: trunk/LayoutTests/fast/forms/date/date-click-on-label-expected.txt (0 => 141395)
--- trunk/LayoutTests/fast/forms/date/date-click-on-label-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/date/date-click-on-label-expected.txt 2013-01-31 11:17:40 UTC (rev 141395)
@@ -0,0 +1,8 @@
+Check if clicking a label focuses on a date input in it.
+PASS document.activeElement.id is "body"
+Clicking a label.
+PASS document.activeElement.id is "date1"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Label:
Added: trunk/LayoutTests/fast/forms/date/date-click-on-label.html (0 => 141395)
--- trunk/LayoutTests/fast/forms/date/date-click-on-label.html (rev 0)
+++ trunk/LayoutTests/fast/forms/date/date-click-on-label.html 2013-01-31 11:17:40 UTC (rev 141395)
@@ -0,0 +1,18 @@
+<!DOCTYPE>
+<body id=body>
+<script src=""
+
+<label id="label1">Label: <input type="date" id="date1"></label>
+<script>
+debug('Check if clicking a label focuses on a date input in it.');
+// Force layout because we can't focus on elements without RenderBox.
+document.body.offsetLeft;
+shouldBeEqualToString('document.activeElement.id', 'body');
+debug('Clicking a label.');
+var clickEvent = document.createEvent('MouseEvent');
+clickEvent.initEvent('click', true, true);
+document.getElementById('label1').dispatchEvent(clickEvent);
+shouldBeEqualToString('document.activeElement.id', 'date1');
+</script>
+<script src=""
+</body>
Modified: trunk/Source/WebCore/ChangeLog (141394 => 141395)
--- trunk/Source/WebCore/ChangeLog 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/Source/WebCore/ChangeLog 2013-01-31 11:17:40 UTC (rev 141395)
@@ -1,3 +1,54 @@
+2013-01-31 Kent Tamura <[email protected]>
+
+ Click on a label element won't select input[type=date]
+ https://bugs.webkit.org/show_bug.cgi?id=108428
+
+ Reviewed by Kentaro Hara.
+
+ date/time input types with INPUT_MULTIPLE_FIELDS_UI are not
+ mouse-focusable. <input> as a shadow host never gets focus and
+ sub-fields in its shadow tree are focusable. Howevever, the click
+ handling of <label> checked isMouseFocusable. We introduce new function
+ isFocusableByClickOnLabel to HTMLElement. It's default implementation is
+ same as isMouseFocusable, and we add special handling for
+ BaseMultipleFieldsDateAndTimeInputType::isFocusableByClickOnLabel.
+
+ Also, date/time input types without INPUT_MULTIPLE_FIELDS_UI were not
+ mouse-focusable by a mistake. It should be mouse-focusable.
+
+ Test: fast/forms/date/date-click-on-label.html
+
+ * html/HTMLElement.cpp:
+ (WebCore::HTMLElement::isFocusableByClickOnLabel):
+ Added. Just calls isMouseFocusable.
+ * html/HTMLElement.h:
+ (HTMLElement): Declare isFocusableByClickOnLabel.
+ * html/HTMLLabelElement.cpp:
+ (WebCore::HTMLLabelElement::defaultEventHandler):
+ Calls isFocusableByClickOnLabel instead of isMouseFocusable.
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::isFocusableByClickOnLabel):
+ Delegate to InputType::isFocusableByClickOnLabel.
+ * html/HTMLInputElement.h:
+ (HTMLInputElement): Declare isFocusableByClickOnLabel.
+ * html/InputType.cpp:
+ (WebCore::InputType::isFocusableByClickOnLabel):
+ Added. Calls isMouseFocusable.
+ * html/InputType.h:
+ (InputType): Declare isFocusableByClickOnLabel.
+
+ * html/BaseMultipleFieldsDateAndTimeInputType.cpp:
+ (WebCore::BaseMultipleFieldsDateAndTimeInputType::isFocusableByClickOnLabel):
+ Added. Use the same logic with textfields.
+ * html/BaseMultipleFieldsDateAndTimeInputType.h:
+ (BaseMultipleFieldsDateAndTimeInputType): Declare isFocusableByClickOnLabel.
+ * html/BaseChooserOnlyDateAndTimeInputType.cpp:
+ (WebCore::BaseChooserOnlyDateAndTimeInputType::isMouseFocusable):
+ Added. Use the same logic with textfields.
+ * html/BaseChooserOnlyDateAndTimeInputType.h:
+ (BaseChooserOnlyDateAndTimeInputType): Declare isMouseFocusable.
+
2013-01-31 Kentaro Hara <[email protected]>
Rename WheelEvent::Granularity to WheelEvent::DeltaMode
Modified: trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp (141394 => 141395)
--- trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp 2013-01-31 11:17:40 UTC (rev 141395)
@@ -131,5 +131,10 @@
BaseClickableWithKeyInputType::accessKeyAction(element(), sendMouseEvents);
}
+bool BaseChooserOnlyDateAndTimeInputType::isMouseFocusable() const
+{
+ return element()->isTextFormControlFocusable();
}
+
+}
#endif
Modified: trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h (141394 => 141395)
--- trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h 2013-01-31 11:17:40 UTC (rev 141395)
@@ -52,6 +52,7 @@
virtual void handleKeypressEvent(KeyboardEvent*) OVERRIDE;
virtual void handleKeyupEvent(KeyboardEvent*) OVERRIDE;
virtual void accessKeyAction(bool sendMouseEvents) OVERRIDE;
+ virtual bool isMouseFocusable() const OVERRIDE;
// DateTimeChooserClient functions:
virtual void didChooseValue(const String&) OVERRIDE;
Modified: trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp (141394 => 141395)
--- trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp 2013-01-31 11:17:40 UTC (rev 141395)
@@ -283,6 +283,11 @@
return element()->value().isEmpty() && m_dateTimeEditElement && m_dateTimeEditElement->anyEditableFieldsHaveValues();
}
+bool BaseMultipleFieldsDateAndTimeInputType::isFocusableByClickOnLabel() const
+{
+ return element()->isTextFormControlFocusable();
+}
+
bool BaseMultipleFieldsDateAndTimeInputType::isKeyboardFocusable(KeyboardEvent*) const
{
return false;
Modified: trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h (141394 => 141395)
--- trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h 2013-01-31 11:17:40 UTC (rev 141395)
@@ -86,6 +86,7 @@
virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE FINAL;
virtual bool hasBadInput() const OVERRIDE;
virtual bool hasCustomFocusLogic() const OVERRIDE FINAL;
+ virtual bool isFocusableByClickOnLabel() const OVERRIDE;
virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE FINAL;
virtual bool isMouseFocusable() const OVERRIDE FINAL;
virtual void minOrMaxAttributeChanged() OVERRIDE FINAL;
Modified: trunk/Source/WebCore/html/HTMLElement.cpp (141394 => 141395)
--- trunk/Source/WebCore/html/HTMLElement.cpp 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/Source/WebCore/html/HTMLElement.cpp 2013-01-31 11:17:40 UTC (rev 141395)
@@ -1163,6 +1163,11 @@
style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.rgb()));
}
+bool HTMLElement::isFocusableByClickOnLabel() const
+{
+ return isMouseFocusable();
+}
+
} // namespace WebCore
#ifndef NDEBUG
Modified: trunk/Source/WebCore/html/HTMLElement.h (141394 => 141395)
--- trunk/Source/WebCore/html/HTMLElement.h 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/Source/WebCore/html/HTMLElement.h 2013-01-31 11:17:40 UTC (rev 141395)
@@ -107,6 +107,7 @@
#endif
virtual bool isLabelable() const { return false; }
+ virtual bool isFocusableByClickOnLabel() const;
protected:
HTMLElement(const QualifiedName& tagName, Document*, ConstructionType);
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (141394 => 141395)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2013-01-31 11:17:40 UTC (rev 141395)
@@ -1232,6 +1232,11 @@
return attribute.name() == srcAttr || attribute.name() == formactionAttr || HTMLTextFormControlElement::isURLAttribute(attribute);
}
+bool HTMLInputElement::isFocusableByClickOnLabel() const
+{
+ return m_inputType->isFocusableByClickOnLabel();
+}
+
String HTMLInputElement::defaultValue() const
{
return fastGetAttribute(valueAttr);
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (141394 => 141395)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2013-01-31 11:17:40 UTC (rev 141395)
@@ -360,7 +360,7 @@
virtual void postDispatchEventHandler(Event*, void* dataFromPreDispatch);
virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
-
+ virtual bool isFocusableByClickOnLabel() const OVERRIDE;
virtual bool isInRange() const;
virtual bool isOutOfRange() const;
Modified: trunk/Source/WebCore/html/HTMLLabelElement.cpp (141394 => 141395)
--- trunk/Source/WebCore/html/HTMLLabelElement.cpp 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/Source/WebCore/html/HTMLLabelElement.cpp 2013-01-31 11:17:40 UTC (rev 141395)
@@ -136,8 +136,7 @@
// Click the corresponding control.
element->dispatchSimulatedClick(evt);
- // If the control can be focused via the mouse, then do that too.
- if (element->isMouseFocusable())
+ if (element->isFocusableByClickOnLabel())
element->focus();
processingClick = false;
Modified: trunk/Source/WebCore/html/InputType.cpp (141394 => 141395)
--- trunk/Source/WebCore/html/InputType.cpp 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/Source/WebCore/html/InputType.cpp 2013-01-31 11:17:40 UTC (rev 141395)
@@ -547,6 +547,11 @@
return true;
}
+bool InputType::isFocusableByClickOnLabel() const
+{
+ return isMouseFocusable();
+}
+
bool InputType::isKeyboardFocusable(KeyboardEvent* event) const
{
return element()->isTextFormControlKeyboardFocusable(event);
Modified: trunk/Source/WebCore/html/InputType.h (141394 => 141395)
--- trunk/Source/WebCore/html/InputType.h 2013-01-31 11:10:44 UTC (rev 141394)
+++ trunk/Source/WebCore/html/InputType.h 2013-01-31 11:17:40 UTC (rev 141395)
@@ -201,6 +201,7 @@
virtual bool shouldSubmitImplicitly(Event*);
virtual PassRefPtr<HTMLFormElement> formForSubmission() const;
virtual bool hasCustomFocusLogic() const;
+ virtual bool isFocusableByClickOnLabel() const;
virtual bool isKeyboardFocusable(KeyboardEvent*) const;
virtual bool isMouseFocusable() const;
virtual bool shouldUseInputMethod() const;