Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
INPUT_MULTIPLE_FIELDS_UI: Mouse click not on sub-fields in multiple f…
…ields 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. Canonical link: https://commits.webkit.org/127831@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142592 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
8712a4b
commit 33588627ff5e2dd2b61b40854d9cb9a08ba37930
Showing
16 changed files
with
118 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<script src="../../js/resources/js-test-pre.js"></script> | ||
<input id="timeInput" type="time" value="01:01" autofocus> | ||
<input id="timeInput" type="time" value="01:01" style="font-size:20px" autofocus> | ||
<script> | ||
function dispatchKeyEventTo(type, key, target) { | ||
var event = document.createEvent('KeyboardEvent'); | ||
event.initKeyboardEvent(type, true, true, document.defaultView, key); | ||
target.dispatchEvent(event); | ||
} | ||
|
||
function pseudoOfFocused() { | ||
return internals.youngestShadowRoot(timeInput).activeElement.getAttribute("pseudo"); | ||
} | ||
|
||
description('Check if focus() for focused input does not change focused sub-field.'); | ||
debug('Move focus to the second sub-field, then press Up key:'); | ||
debug('Move focus to the second sub-field:'); | ||
var timeInput = document.getElementById('timeInput'); | ||
shouldBe('document.activeElement', 'timeInput'); | ||
dispatchKeyEventTo('keydown', 'Right', timeInput); | ||
dispatchKeyEventTo('keydown', 'Up', timeInput); | ||
shouldBeEqualToString('timeInput.value', '01:02'); | ||
shouldBeEqualToString('pseudoOfFocused(timeInput)', '-webkit-datetime-edit-minute-field'); | ||
shouldBeEqualToString('timeInput.focus(); pseudoOfFocused(timeInput)', '-webkit-datetime-edit-minute-field'); | ||
|
||
debug('Calls focus(), then press Up key:'); | ||
timeInput.focus(); | ||
dispatchKeyEventTo('keydown', 'Up', timeInput); | ||
shouldBeEqualToString('timeInput.value', '01:03'); | ||
debug('Click on a delimiter between sub-fields, then check if focused element is not changed:'); | ||
var focusedField = internals.youngestShadowRoot(timeInput).activeElement; | ||
eventSender.mouseMoveTo(focusedField.offsetLeft + focusedField.offsetWidth + 10, focusedField.offsetTop + 10); | ||
eventSender.mouseDown(); | ||
eventSender.mouseUp(); | ||
shouldBeEqualToString('pseudoOfFocused(timeInput)', '-webkit-datetime-edit-minute-field'); | ||
</script> | ||
<script src="../../js/resources/js-test-post.js"></script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters