INPUT_MULTIPLE_FIELDS_UI: Mouse click not on sub-fields in multiple fields input...
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Feb 2013 08:34:57 +0000 (08:34 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Feb 2013 08:34:57 +0000 (08:34 +0000)
commitd2689091c214b88106b8194c7591141ed9bc60c7
treeaa51d171b3d12fa63fbd03d439f9e2007150eab5
parent835e679c033d5e0b93b08439c3cae1a9192f5a2a
INPUT_MULTIPLE_FIELDS_UI: Mouse click not on sub-fields in multiple fields input  should not move focus
https://bugs.webkit.org/show_bug.cgi?id=109544

Reviewed by Kentaro Hara.

Source/WebCore:

This is similar to Bug 108914, "Should not move focus if the element
already has focus." We fixed a focus() case in Bug 108914. However we
still have the problem in a case of focusing by mouse click.

The fix for Bug 108914 intercepted focus() function to change the
behavior. However focus-by-click doesn't call focus(), but calls
FocusController::setFocusedNode. To fix this problem, we introduce
oldFocusedNode argument to handleFocusEvent, and
BaseMultipleFieldsDateAndTimeInputType::handleFocusEvent restores the
focus to oldFocusedNode if oldFocusedNode is one of sub-fields.
handleFocusEvent is called whenever the focused node is changed.

We don't need InputType::willCancelFocus any more because the new code
in handleFocusEvent covers it.

Tests: Update fast/forms/time-multiple-fields/time-multiple-fields-focus.html.

* html/HTMLTextFormControlElement.h:
(WebCore::HTMLTextFormControlElement::handleFocusEvent):
Add oldFocusedNode argument.
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::dispatchFocusEvent):
Pass oldFocusedNode to handleFocusEvent.

* html/HTMLInputElement.h:
(HTMLInputElement):
 - Add oldFocusedNode argument to handleFocusEvent.
 - Remove focus() override.
* html/HTMLInputElement.cpp: Remove focus() override.
(WebCore::HTMLInputElement::handleFocusEvent):
Pass oldFocusedNode to InputType::handleFocusEvent.
* html/InputType.cpp: Remove willCancelFocus.
(WebCore::InputType::handleFocusEvent):
Add oldFocusedNode argument.
* html/InputType.h:
(InputType): Ditto.
* html/PasswordInputType.cpp:
(WebCore::PasswordInputType::handleFocusEvent): Ditto.
* html/PasswordInputType.h:
(PasswordInputType): Ditto.

* html/BaseMultipleFieldsDateAndTimeInputType.h:
(BaseMultipleFieldsDateAndTimeInputType):
Remove willCancelFocus, and add oldFocusedNode argument to handleFocusEvent.
* html/BaseMultipleFieldsDateAndTimeInputType.cpp:
(WebCore::BaseMultipleFieldsDateAndTimeInputType::handleFocusEvent):
Pass oldFocusedNode to DateTimeEditElement::focusByOwner if the
direction is FocusDirectionNone.

* html/shadow/DateTimeEditElement.h:
(DateTimeEditElement): Add oldFocusedNode argument to focusByOwner.
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditElement::focusByOwner):
If oldFocusedNode is one of sub-fields, focus on it again.

LayoutTests:

* fast/forms/time-multiple-fields/time-multiple-fields-focus-expected.txt:
* fast/forms/time-multiple-fields/time-multiple-fields-focus.html:
Add test to click a delimiter.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142592 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-focus-expected.txt
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-focus.html
Source/WebCore/ChangeLog
Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp
Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/HTMLTextFormControlElement.cpp
Source/WebCore/html/HTMLTextFormControlElement.h
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/html/PasswordInputType.cpp
Source/WebCore/html/PasswordInputType.h
Source/WebCore/html/shadow/DateTimeEditElement.cpp
Source/WebCore/html/shadow/DateTimeEditElement.h