| 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 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 27 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
| 28 #include "DateTimeFieldElement.h" | 28 #include "DateTimeFieldElement.h" |
| 29 | 29 |
| 30 #include "DateComponents.h" | 30 #include "DateComponents.h" |
| 31 #include "HTMLNames.h" | 31 #include "HTMLNames.h" |
| 32 #include "KeyboardEvent.h" | 32 #include "KeyboardEvent.h" |
| 33 #include "LocalizedStrings.h" | 33 #include "LocalizedStrings.h" |
| 34 #include "PlatformLocale.h" |
| 34 #include "RenderObject.h" | 35 #include "RenderObject.h" |
| 35 #include "Text.h" | 36 #include "Text.h" |
| 36 #include <wtf/text/WTFString.h> | 37 #include <wtf/text/WTFString.h> |
| 37 | 38 |
| 38 namespace WebCore { | 39 namespace WebCore { |
| 39 | 40 |
| 40 using namespace HTMLNames; | 41 using namespace HTMLNames; |
| 41 | 42 |
| 42 DateTimeFieldElement::FieldOwner::~FieldOwner() | 43 DateTimeFieldElement::FieldOwner::~FieldOwner() |
| 43 { | 44 { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (keyboardEvent->getModifierState("Alt")) | 84 if (keyboardEvent->getModifierState("Alt")) |
| 84 return; | 85 return; |
| 85 keyboardEvent->setDefaultHandled(); | 86 keyboardEvent->setDefaultHandled(); |
| 86 stepDown(); | 87 stepDown(); |
| 87 return; | 88 return; |
| 88 } | 89 } |
| 89 | 90 |
| 90 if (keyIdentifier == "Left") { | 91 if (keyIdentifier == "Left") { |
| 91 if (!m_fieldOwner) | 92 if (!m_fieldOwner) |
| 92 return; | 93 return; |
| 93 if (isRTL() ? m_fieldOwner->focusOnNextField(*this) : m_fieldOwner->focu
sOnPreviousField(*this)) | 94 // FIXME: We'd like to use FocusController::advanceFocus(FocusDirectionL
eft, ...) |
| 95 // but it doesn't work for shadow nodes. webkit.org/b/104650 |
| 96 if (!localeForOwner().isRTL() && m_fieldOwner->focusOnPreviousField(*thi
s)) |
| 94 keyboardEvent->setDefaultHandled(); | 97 keyboardEvent->setDefaultHandled(); |
| 95 return; | 98 return; |
| 96 } | 99 } |
| 97 | 100 |
| 98 if (keyIdentifier == "Right") { | 101 if (keyIdentifier == "Right") { |
| 99 if (!m_fieldOwner) | 102 if (!m_fieldOwner) |
| 100 return; | 103 return; |
| 101 if (isRTL() ? m_fieldOwner->focusOnPreviousField(*this) : m_fieldOwner->
focusOnNextField(*this)) | 104 // FIXME: We'd like to use FocusController::advanceFocus(FocusDirectionR
ight, ...) |
| 105 // but it doesn't work for shadow nodes. webkit.org/b/104650 |
| 106 if (!localeForOwner().isRTL() && m_fieldOwner->focusOnNextField(*this)) |
| 102 keyboardEvent->setDefaultHandled(); | 107 keyboardEvent->setDefaultHandled(); |
| 103 return; | 108 return; |
| 104 } | 109 } |
| 105 | 110 |
| 106 if (keyIdentifier == "Up") { | 111 if (keyIdentifier == "Up") { |
| 107 keyboardEvent->setDefaultHandled(); | 112 keyboardEvent->setDefaultHandled(); |
| 108 stepUp(); | 113 stepUp(); |
| 109 return; | 114 return; |
| 110 } | 115 } |
| 111 | 116 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (m_fieldOwner && m_fieldOwner->isFieldOwnerDisabledOrReadOnly()) | 161 if (m_fieldOwner && m_fieldOwner->isFieldOwnerDisabledOrReadOnly()) |
| 157 return false; | 162 return false; |
| 158 return HTMLElement::isFocusable(); | 163 return HTMLElement::isFocusable(); |
| 159 } | 164 } |
| 160 | 165 |
| 161 bool DateTimeFieldElement::isReadOnly() const | 166 bool DateTimeFieldElement::isReadOnly() const |
| 162 { | 167 { |
| 163 return fastHasAttribute(readonlyAttr); | 168 return fastHasAttribute(readonlyAttr); |
| 164 } | 169 } |
| 165 | 170 |
| 166 bool DateTimeFieldElement::isRTL() const | 171 Locale& DateTimeFieldElement::localeForOwner() const |
| 167 { | 172 { |
| 168 return renderer() && renderer()->style()->direction() == RTL; | 173 return document()->getCachedLocale(localeIdentifier()); |
| 169 } | 174 } |
| 170 | 175 |
| 171 AtomicString DateTimeFieldElement::localeIdentifier() const | 176 AtomicString DateTimeFieldElement::localeIdentifier() const |
| 172 { | 177 { |
| 173 return m_fieldOwner ? m_fieldOwner->localeIdentifier() : nullAtom; | 178 return m_fieldOwner ? m_fieldOwner->localeIdentifier() : nullAtom; |
| 174 } | 179 } |
| 175 | 180 |
| 176 float DateTimeFieldElement::maximumWidth(const Font&) | 181 float DateTimeFieldElement::maximumWidth(const Font&) |
| 177 { | 182 { |
| 178 const float paddingLeftAndRight = 2; // This should match to html.css. | 183 const float paddingLeftAndRight = 2; // This should match to html.css. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 204 setAttribute(aria_valuetextAttr, hasValue() ? newVisibleValue : AXDateTimeFi
eldEmptyValueText()); | 209 setAttribute(aria_valuetextAttr, hasValue() ? newVisibleValue : AXDateTimeFi
eldEmptyValueText()); |
| 205 setAttribute(aria_valuenowAttr, newVisibleValue); | 210 setAttribute(aria_valuenowAttr, newVisibleValue); |
| 206 | 211 |
| 207 if (eventBehavior == DispatchEvent && m_fieldOwner) | 212 if (eventBehavior == DispatchEvent && m_fieldOwner) |
| 208 m_fieldOwner->fieldValueChanged(); | 213 m_fieldOwner->fieldValueChanged(); |
| 209 } | 214 } |
| 210 | 215 |
| 211 } // namespace WebCore | 216 } // namespace WebCore |
| 212 | 217 |
| 213 #endif | 218 #endif |
| OLD | NEW |