| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 void DateTimeFieldElement::defaultKeyboardEventHandler(KeyboardEvent* keyboardEv
ent) | 90 void DateTimeFieldElement::defaultKeyboardEventHandler(KeyboardEvent* keyboardEv
ent) |
| 91 { | 91 { |
| 92 if (keyboardEvent->type() != EventTypeNames::keydown) | 92 if (keyboardEvent->type() != EventTypeNames::keydown) |
| 93 return; | 93 return; |
| 94 | 94 |
| 95 if (isDisabled() || isFieldOwnerDisabled()) | 95 if (isDisabled() || isFieldOwnerDisabled()) |
| 96 return; | 96 return; |
| 97 | 97 |
| 98 const String& keyIdentifier = keyboardEvent->keyIdentifier(); | 98 const String& key = keyboardEvent->key(); |
| 99 | 99 |
| 100 if (keyIdentifier == "Left") { | 100 if (key == "ArrowLeft") { |
| 101 if (!m_fieldOwner) | 101 if (!m_fieldOwner) |
| 102 return; | 102 return; |
| 103 // FIXME: We'd like to use FocusController::advanceFocus(FocusDirectionL
eft, ...) | 103 // FIXME: We'd like to use FocusController::advanceFocus(FocusDirectionL
eft, ...) |
| 104 // but it doesn't work for shadow nodes. webkit.org/b/104650 | 104 // but it doesn't work for shadow nodes. webkit.org/b/104650 |
| 105 if (!localeForOwner().isRTL() && m_fieldOwner->focusOnPreviousField(*thi
s)) | 105 if (!localeForOwner().isRTL() && m_fieldOwner->focusOnPreviousField(*thi
s)) |
| 106 keyboardEvent->setDefaultHandled(); | 106 keyboardEvent->setDefaultHandled(); |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 | 109 |
| 110 if (keyIdentifier == "Right") { | 110 if (key == "ArrowRight") { |
| 111 if (!m_fieldOwner) | 111 if (!m_fieldOwner) |
| 112 return; | 112 return; |
| 113 // FIXME: We'd like to use FocusController::advanceFocus(FocusDirectionR
ight, ...) | 113 // FIXME: We'd like to use FocusController::advanceFocus(FocusDirectionR
ight, ...) |
| 114 // but it doesn't work for shadow nodes. webkit.org/b/104650 | 114 // but it doesn't work for shadow nodes. webkit.org/b/104650 |
| 115 if (!localeForOwner().isRTL() && m_fieldOwner->focusOnNextField(*this)) | 115 if (!localeForOwner().isRTL() && m_fieldOwner->focusOnNextField(*this)) |
| 116 keyboardEvent->setDefaultHandled(); | 116 keyboardEvent->setDefaultHandled(); |
| 117 return; | 117 return; |
| 118 } | 118 } |
| 119 | 119 |
| 120 if (isFieldOwnerReadOnly()) | 120 if (isFieldOwnerReadOnly()) |
| 121 return; | 121 return; |
| 122 | 122 |
| 123 if (keyIdentifier == "Down") { | 123 if (key == "ArrowDown") { |
| 124 if (keyboardEvent->getModifierState("Alt")) | 124 if (keyboardEvent->getModifierState("Alt")) |
| 125 return; | 125 return; |
| 126 keyboardEvent->setDefaultHandled(); | 126 keyboardEvent->setDefaultHandled(); |
| 127 stepDown(); | 127 stepDown(); |
| 128 return; | 128 return; |
| 129 } | 129 } |
| 130 | 130 |
| 131 if (keyIdentifier == "Up") { | 131 if (key == "ArrowUp") { |
| 132 keyboardEvent->setDefaultHandled(); | 132 keyboardEvent->setDefaultHandled(); |
| 133 stepUp(); | 133 stepUp(); |
| 134 return; | 134 return; |
| 135 } | 135 } |
| 136 | 136 |
| 137 if (keyIdentifier == "U+0008" || keyIdentifier == "U+007F") { | 137 if (key == "Backspace" || key == "Delete") { |
| 138 keyboardEvent->setDefaultHandled(); | 138 keyboardEvent->setDefaultHandled(); |
| 139 setEmptyValue(DispatchEvent); | 139 setEmptyValue(DispatchEvent); |
| 140 return; | 140 return; |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 void DateTimeFieldElement::setFocus(bool value) | 144 void DateTimeFieldElement::setFocus(bool value) |
| 145 { | 145 { |
| 146 if (m_fieldOwner) | 146 if (m_fieldOwner) |
| 147 value ? m_fieldOwner->didFocusOnField() : m_fieldOwner->didBlurFromField
(); | 147 value ? m_fieldOwner->didFocusOnField() : m_fieldOwner->didBlurFromField
(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 m_fieldOwner->fieldValueChanged(); | 238 m_fieldOwner->fieldValueChanged(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 int DateTimeFieldElement::valueForARIAValueNow() const | 241 int DateTimeFieldElement::valueForARIAValueNow() const |
| 242 { | 242 { |
| 243 return valueAsInteger(); | 243 return valueAsInteger(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 } // namespace blink | 246 } // namespace blink |
| 247 | 247 |
| OLD | NEW |