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 21 matching lines...) Expand all Loading... |
32 #include "core/events/KeyboardEvent.h" | 32 #include "core/events/KeyboardEvent.h" |
33 #include "core/layout/TextRunConstructor.h" | 33 #include "core/layout/TextRunConstructor.h" |
34 #include "core/style/ComputedStyle.h" | 34 #include "core/style/ComputedStyle.h" |
35 #include "platform/text/PlatformLocale.h" | 35 #include "platform/text/PlatformLocale.h" |
36 #include "wtf/text/WTFString.h" | 36 #include "wtf/text/WTFString.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 using namespace HTMLNames; | 40 using namespace HTMLNames; |
41 | 41 |
42 static String emptyValueAXText() | |
43 { | |
44 return Locale::defaultLocale().queryString(WebLocalizedString::AXDateTimeFie
ldEmptyValueText); | |
45 } | |
46 | |
47 DateTimeFieldElement::FieldOwner::~FieldOwner() | 42 DateTimeFieldElement::FieldOwner::~FieldOwner() |
48 { | 43 { |
49 } | 44 } |
50 | 45 |
51 DateTimeFieldElement::DateTimeFieldElement(Document& document, FieldOwner& field
Owner) | 46 DateTimeFieldElement::DateTimeFieldElement(Document& document, FieldOwner& field
Owner) |
52 : HTMLSpanElement(document) | 47 : HTMLSpanElement(document) |
53 , m_fieldOwner(&fieldOwner) | 48 , m_fieldOwner(&fieldOwner) |
54 { | 49 { |
55 } | 50 } |
56 | 51 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 { | 147 { |
153 if (!m_fieldOwner) | 148 if (!m_fieldOwner) |
154 return; | 149 return; |
155 m_fieldOwner->focusOnNextField(*this); | 150 m_fieldOwner->focusOnNextField(*this); |
156 } | 151 } |
157 | 152 |
158 void DateTimeFieldElement::initialize(const AtomicString& pseudo, const String&
axHelpText, int axMinimum, int axMaximum) | 153 void DateTimeFieldElement::initialize(const AtomicString& pseudo, const String&
axHelpText, int axMinimum, int axMaximum) |
159 { | 154 { |
160 // On accessibility, DateTimeFieldElement acts like spin button. | 155 // On accessibility, DateTimeFieldElement acts like spin button. |
161 setAttribute(roleAttr, AtomicString("spinbutton")); | 156 setAttribute(roleAttr, AtomicString("spinbutton")); |
162 setAttribute(aria_valuetextAttr, AtomicString(emptyValueAXText())); | 157 setAttribute(aria_valuetextAttr, AtomicString(visibleValue())); |
163 setAttribute(aria_valueminAttr, AtomicString::number(axMinimum)); | 158 setAttribute(aria_valueminAttr, AtomicString::number(axMinimum)); |
164 setAttribute(aria_valuemaxAttr, AtomicString::number(axMaximum)); | 159 setAttribute(aria_valuemaxAttr, AtomicString::number(axMaximum)); |
165 | 160 |
166 setAttribute(aria_helpAttr, AtomicString(axHelpText)); | 161 setAttribute(aria_helpAttr, AtomicString(axHelpText)); |
167 setShadowPseudoId(pseudo); | 162 setShadowPseudoId(pseudo); |
168 appendChild(Text::create(document(), visibleValue())); | 163 appendChild(Text::create(document(), visibleValue())); |
169 } | 164 } |
170 | 165 |
171 bool DateTimeFieldElement::isDateTimeFieldElement() const | 166 bool DateTimeFieldElement::isDateTimeFieldElement() const |
172 { | 167 { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 { | 215 { |
221 Text* const textNode = toText(firstChild()); | 216 Text* const textNode = toText(firstChild()); |
222 const String newVisibleValue = visibleValue(); | 217 const String newVisibleValue = visibleValue(); |
223 DCHECK_GT(newVisibleValue.length(), 0u); | 218 DCHECK_GT(newVisibleValue.length(), 0u); |
224 | 219 |
225 if (textNode->wholeText() == newVisibleValue) | 220 if (textNode->wholeText() == newVisibleValue) |
226 return; | 221 return; |
227 | 222 |
228 textNode->replaceWholeText(newVisibleValue); | 223 textNode->replaceWholeText(newVisibleValue); |
229 if (hasValue()) { | 224 if (hasValue()) { |
230 setAttribute(aria_valuetextAttr, AtomicString(newVisibleValue)); | |
231 setAttribute(aria_valuenowAttr, AtomicString::number(valueForARIAValueNo
w())); | 225 setAttribute(aria_valuenowAttr, AtomicString::number(valueForARIAValueNo
w())); |
232 } else { | 226 } else { |
233 setAttribute(aria_valuetextAttr, AtomicString(emptyValueAXText())); | |
234 removeAttribute(aria_valuenowAttr); | 227 removeAttribute(aria_valuenowAttr); |
235 } | 228 } |
| 229 setAttribute(aria_valuetextAttr, AtomicString(newVisibleValue)); |
236 | 230 |
237 if (eventBehavior == DispatchEvent && m_fieldOwner) | 231 if (eventBehavior == DispatchEvent && m_fieldOwner) |
238 m_fieldOwner->fieldValueChanged(); | 232 m_fieldOwner->fieldValueChanged(); |
239 } | 233 } |
240 | 234 |
241 int DateTimeFieldElement::valueForARIAValueNow() const | 235 int DateTimeFieldElement::valueForARIAValueNow() const |
242 { | 236 { |
243 return valueAsInteger(); | 237 return valueAsInteger(); |
244 } | 238 } |
245 | 239 |
246 } // namespace blink | 240 } // namespace blink |
247 | 241 |
OLD | NEW |