Changeset 142592 in webkit
- Timestamp:
- Feb 12, 2013 12:34:57 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r142588 r142592 1 2013-02-12 Kent Tamura <tkent@chromium.org> 2 3 INPUT_MULTIPLE_FIELDS_UI: Mouse click not on sub-fields in multiple fields input should not move focus 4 https://bugs.webkit.org/show_bug.cgi?id=109544 5 6 Reviewed by Kentaro Hara. 7 8 * fast/forms/time-multiple-fields/time-multiple-fields-focus-expected.txt: 9 * fast/forms/time-multiple-fields/time-multiple-fields-focus.html: 10 Add test to click a delimiter. 11 1 12 2013-02-11 KwangYong Choi <ky0.choi@samsung.com> 2 13 -
trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-focus-expected.txt
r141887 r142592 4 4 5 5 6 Move focus to the second sub-field , then press Up key:6 Move focus to the second sub-field: 7 7 PASS document.activeElement is timeInput 8 PASS timeInput.value is "01:02" 9 Calls focus(), then press Up key: 10 PASS timeInput.value is "01:03" 8 PASS pseudoOfFocused(timeInput) is "-webkit-datetime-edit-minute-field" 9 PASS timeInput.focus(); pseudoOfFocused(timeInput) is "-webkit-datetime-edit-minute-field" 10 Click on a delimiter between sub-fields, then check if focused element is not changed: 11 PASS pseudoOfFocused(timeInput) is "-webkit-datetime-edit-minute-field" 11 12 PASS successfullyParsed is true 12 13 -
trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-focus.html
r141887 r142592 2 2 <body> 3 3 <script src="../../js/resources/js-test-pre.js"></script> 4 <input id="timeInput" type="time" value="01:01" autofocus>4 <input id="timeInput" type="time" value="01:01" style="font-size:20px" autofocus> 5 5 <script> 6 6 function dispatchKeyEventTo(type, key, target) { … … 10 10 } 11 11 12 function pseudoOfFocused() { 13 return internals.youngestShadowRoot(timeInput).activeElement.getAttribute("pseudo"); 14 } 15 12 16 description('Check if focus() for focused input does not change focused sub-field.'); 13 debug('Move focus to the second sub-field , then press Up key:');17 debug('Move focus to the second sub-field:'); 14 18 var timeInput = document.getElementById('timeInput'); 15 19 shouldBe('document.activeElement', 'timeInput'); 16 20 dispatchKeyEventTo('keydown', 'Right', timeInput); 17 dispatchKeyEventTo('keydown', 'Up', timeInput);18 shouldBeEqualToString('timeInput. value', '01:02');21 shouldBeEqualToString('pseudoOfFocused(timeInput)', '-webkit-datetime-edit-minute-field'); 22 shouldBeEqualToString('timeInput.focus(); pseudoOfFocused(timeInput)', '-webkit-datetime-edit-minute-field'); 19 23 20 debug('Calls focus(), then press Up key:'); 21 timeInput.focus(); 22 dispatchKeyEventTo('keydown', 'Up', timeInput); 23 shouldBeEqualToString('timeInput.value', '01:03'); 24 debug('Click on a delimiter between sub-fields, then check if focused element is not changed:'); 25 var focusedField = internals.youngestShadowRoot(timeInput).activeElement; 26 eventSender.mouseMoveTo(focusedField.offsetLeft + focusedField.offsetWidth + 10, focusedField.offsetTop + 10); 27 eventSender.mouseDown(); 28 eventSender.mouseUp(); 29 shouldBeEqualToString('pseudoOfFocused(timeInput)', '-webkit-datetime-edit-minute-field'); 24 30 </script> 25 31 <script src="../../js/resources/js-test-post.js"></script> -
trunk/Source/WebCore/ChangeLog
r142591 r142592 1 2013-02-12 Kent Tamura <tkent@chromium.org> 2 3 INPUT_MULTIPLE_FIELDS_UI: Mouse click not on sub-fields in multiple fields input should not move focus 4 https://bugs.webkit.org/show_bug.cgi?id=109544 5 6 Reviewed by Kentaro Hara. 7 8 This is similar to Bug 108914, "Should not move focus if the element 9 already has focus." We fixed a focus() case in Bug 108914. However we 10 still have the problem in a case of focusing by mouse click. 11 12 The fix for Bug 108914 intercepted focus() function to change the 13 behavior. However focus-by-click doesn't call focus(), but calls 14 FocusController::setFocusedNode. To fix this problem, we introduce 15 oldFocusedNode argument to handleFocusEvent, and 16 BaseMultipleFieldsDateAndTimeInputType::handleFocusEvent restores the 17 focus to oldFocusedNode if oldFocusedNode is one of sub-fields. 18 handleFocusEvent is called whenever the focused node is changed. 19 20 We don't need InputType::willCancelFocus any more because the new code 21 in handleFocusEvent covers it. 22 23 Tests: Update fast/forms/time-multiple-fields/time-multiple-fields-focus.html. 24 25 * html/HTMLTextFormControlElement.h: 26 (WebCore::HTMLTextFormControlElement::handleFocusEvent): 27 Add oldFocusedNode argument. 28 * html/HTMLTextFormControlElement.cpp: 29 (WebCore::HTMLTextFormControlElement::dispatchFocusEvent): 30 Pass oldFocusedNode to handleFocusEvent. 31 32 * html/HTMLInputElement.h: 33 (HTMLInputElement): 34 - Add oldFocusedNode argument to handleFocusEvent. 35 - Remove focus() override. 36 * html/HTMLInputElement.cpp: Remove focus() override. 37 (WebCore::HTMLInputElement::handleFocusEvent): 38 Pass oldFocusedNode to InputType::handleFocusEvent. 39 * html/InputType.cpp: Remove willCancelFocus. 40 (WebCore::InputType::handleFocusEvent): 41 Add oldFocusedNode argument. 42 * html/InputType.h: 43 (InputType): Ditto. 44 * html/PasswordInputType.cpp: 45 (WebCore::PasswordInputType::handleFocusEvent): Ditto. 46 * html/PasswordInputType.h: 47 (PasswordInputType): Ditto. 48 49 * html/BaseMultipleFieldsDateAndTimeInputType.h: 50 (BaseMultipleFieldsDateAndTimeInputType): 51 Remove willCancelFocus, and add oldFocusedNode argument to handleFocusEvent. 52 * html/BaseMultipleFieldsDateAndTimeInputType.cpp: 53 (WebCore::BaseMultipleFieldsDateAndTimeInputType::handleFocusEvent): 54 Pass oldFocusedNode to DateTimeEditElement::focusByOwner if the 55 direction is FocusDirectionNone. 56 57 * html/shadow/DateTimeEditElement.h: 58 (DateTimeEditElement): Add oldFocusedNode argument to focusByOwner. 59 * html/shadow/DateTimeEditElement.cpp: 60 (WebCore::DateTimeEditElement::focusByOwner): 61 If oldFocusedNode is one of sub-fields, focus on it again. 62 1 63 2013-02-12 Takashi Sakamoto <tasak@google.com> 2 64 -
trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp
r141960 r142592 242 242 } 243 243 244 bool BaseMultipleFieldsDateAndTimeInputType::willCancelFocus(bool restorePreviousSelection, FocusDirection direction) 245 { 246 return direction == FocusDirectionNone && m_dateTimeEditElement && m_dateTimeEditElement->hasFocusedField(); 247 } 248 249 void BaseMultipleFieldsDateAndTimeInputType::handleFocusEvent(FocusDirection direction) 244 void BaseMultipleFieldsDateAndTimeInputType::handleFocusEvent(Node* oldFocusedNode, FocusDirection direction) 250 245 { 251 246 if (!m_dateTimeEditElement) … … 254 249 if (element()->document()->page()) 255 250 element()->document()->page()->focusController()->advanceFocus(direction, 0); 251 } else if (direction == FocusDirectionNone) { 252 m_dateTimeEditElement->focusByOwner(oldFocusedNode); 256 253 } else 257 254 m_dateTimeEditElement->focusByOwner(); -
trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h
r142248 r142592 82 82 virtual void destroyShadowSubtree() OVERRIDE FINAL; 83 83 virtual void disabledAttributeChanged() OVERRIDE FINAL; 84 virtual bool willCancelFocus(bool restorePreviousSelection, FocusDirection) OVERRIDE;85 84 virtual void forwardEvent(Event*) OVERRIDE FINAL; 86 virtual void handleFocusEvent( FocusDirection) OVERRIDE;85 virtual void handleFocusEvent(Node* oldFocusedNode, FocusDirection) OVERRIDE; 87 86 virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE FINAL; 88 87 virtual bool hasBadInput() const OVERRIDE; -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r141887 r142592 371 371 } 372 372 373 void HTMLInputElement::focus(bool restorePreviousSelection, FocusDirection direction)374 {375 if (!m_inputType->willCancelFocus(restorePreviousSelection, direction))376 HTMLTextFormControlElement::focus(restorePreviousSelection, direction);377 }378 379 373 bool HTMLInputElement::hasCustomFocusLogic() const 380 374 { … … 434 428 } 435 429 436 void HTMLInputElement::handleFocusEvent( FocusDirection direction)437 { 438 m_inputType->handleFocusEvent( direction);430 void HTMLInputElement::handleFocusEvent(Node* oldFocusedNode, FocusDirection direction) 431 { 432 m_inputType->handleFocusEvent(oldFocusedNode, direction); 439 433 } 440 434 -
trunk/Source/WebCore/html/HTMLInputElement.h
r141887 r142592 281 281 virtual void blur() OVERRIDE; 282 282 void defaultBlur(); 283 virtual void focus(bool restorePreviousSelection = true, FocusDirection = FocusDirectionNone) OVERRIDE;284 283 285 284 virtual const AtomicString& name() const OVERRIDE; … … 379 378 virtual bool isEmptyValue() const OVERRIDE { return innerTextValue().isEmpty(); } 380 379 virtual bool isEmptySuggestedValue() const { return suggestedValue().isEmpty(); } 381 virtual void handleFocusEvent( FocusDirection) OVERRIDE;380 virtual void handleFocusEvent(Node* oldFocusedNode, FocusDirection) OVERRIDE; 382 381 virtual void handleBlurEvent(); 383 382 -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r142247 r142592 89 89 if (supportsPlaceholder()) 90 90 updatePlaceholderVisibility(false); 91 handleFocusEvent( direction);91 handleFocusEvent(oldFocusedNode.get(), direction); 92 92 HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedNode, direction); 93 93 } -
trunk/Source/WebCore/html/HTMLTextFormControlElement.h
r141738 r142592 128 128 virtual bool isEmptySuggestedValue() const { return true; } 129 129 // Called in dispatchFocusEvent(), after placeholder process, before calling parent's dispatchFocusEvent(). 130 virtual void handleFocusEvent( FocusDirection) { }130 virtual void handleFocusEvent(Node* /* oldFocusedNode */, FocusDirection) { } 131 131 // Called in dispatchBlurEvent(), after placeholder process, before calling parent's dispatchBlurEvent(). 132 132 virtual void handleBlurEvent() { } -
trunk/Source/WebCore/html/InputType.cpp
r142271 r142592 472 472 } 473 473 474 bool InputType::willCancelFocus(bool, FocusDirection)475 {476 return false;477 }478 479 474 void InputType::createShadowSubtree() 480 475 { … … 564 559 } 565 560 566 void InputType::handleFocusEvent( FocusDirection)561 void InputType::handleFocusEvent(Node*, FocusDirection) 567 562 { 568 563 } -
trunk/Source/WebCore/html/InputType.h
r142290 r142592 205 205 virtual bool isMouseFocusable() const; 206 206 virtual bool shouldUseInputMethod() const; 207 virtual void handleFocusEvent( FocusDirection);207 virtual void handleFocusEvent(Node* oldFocusedNode, FocusDirection); 208 208 virtual void handleBlurEvent(); 209 209 virtual void accessKeyAction(bool sendMouseEvents); … … 215 215 216 216 virtual void blur(); 217 virtual bool willCancelFocus(bool restorePreviousSelection, FocusDirection);218 217 219 218 // Shadow tree handling -
trunk/Source/WebCore/html/PasswordInputType.cpp
r141835 r142592 96 96 } 97 97 98 void PasswordInputType::handleFocusEvent( FocusDirection direction)98 void PasswordInputType::handleFocusEvent(Node* oldFocusedNode, FocusDirection direction) 99 99 { 100 BaseTextInputType::handleFocusEvent( direction);100 BaseTextInputType::handleFocusEvent(oldFocusedNode, direction); 101 101 if (element()->document()->frame()) 102 102 element()->document()->setUseSecureKeyboardEntryWhenActive(true); -
trunk/Source/WebCore/html/PasswordInputType.h
r141835 r142592 51 51 virtual bool shouldRespectSpeechAttribute() OVERRIDE; 52 52 virtual bool isPasswordField() const OVERRIDE; 53 virtual void handleFocusEvent( FocusDirection) OVERRIDE;53 virtual void handleFocusEvent(Node* oldFocusedNode, FocusDirection) OVERRIDE; 54 54 virtual void handleBlurEvent() OVERRIDE; 55 55 }; -
trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp
r141960 r142592 510 510 } 511 511 512 void DateTimeEditElement::focusByOwner() 513 { 512 void DateTimeEditElement::focusByOwner(Node* oldFocusedNode) 513 { 514 if (oldFocusedNode && oldFocusedNode->isElementNode() && toElement(oldFocusedNode)->isDateTimeFieldElement()) { 515 DateTimeFieldElement* oldFocusedField = static_cast<DateTimeFieldElement*>(oldFocusedNode); 516 size_t index = fieldIndexOf(*oldFocusedField); 517 if (index != invalidFieldIndex && oldFocusedField->isFocusable()) { 518 oldFocusedField->focus(); 519 return; 520 } 521 } 514 522 focusOnNextFocusableField(0); 515 523 } -
trunk/Source/WebCore/html/shadow/DateTimeEditElement.h
r141960 r142592 90 90 Element* fieldsWrapperElement() const; 91 91 void focusIfNoFocus(); 92 void focusByOwner(); 92 // If oldFocusedNode is one of sub-fields, focus on it. Otherwise focus on 93 // the first sub-field. 94 void focusByOwner(Node* oldFocusedNode = 0); 93 95 bool hasFocusedField(); 94 96 void readOnlyStateChanged();
Note: See TracChangeset
for help on using the changeset viewer.