| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 DateTimeFieldElement::FieldOwner::~FieldOwner() | 43 DateTimeFieldElement::FieldOwner::~FieldOwner() |
| 44 { | 44 { |
| 45 } | 45 } |
| 46 | 46 |
| 47 DateTimeFieldElement::DateTimeFieldElement(Document* document, FieldOwner& field
Owner) | 47 DateTimeFieldElement::DateTimeFieldElement(Document* document, FieldOwner& field
Owner) |
| 48 : HTMLElement(spanTag, document) | 48 : HTMLElement(spanTag, document) |
| 49 , m_fieldOwner(&fieldOwner) | 49 , m_fieldOwner(&fieldOwner) |
| 50 { | 50 { |
| 51 // On accessibility, DateTimeFieldElement acts like spin button. | 51 // On accessibility, DateTimeFieldElement acts like spin button. |
| 52 setAttribute(roleAttr, "spinbutton"); | 52 setAttribute(roleAttr, "spinbutton"); |
| 53 setAttribute(aria_valuetextAttr, AXDateTimeFieldEmptyValueText()); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void DateTimeFieldElement::defaultEventHandler(Event* event) | 56 void DateTimeFieldElement::defaultEventHandler(Event* event) |
| 56 { | 57 { |
| 57 if (event->type() == eventNames().blurEvent) | 58 if (event->type() == eventNames().blurEvent) |
| 58 didBlur(); | 59 didBlur(); |
| 59 | 60 |
| 60 if (event->type() == eventNames().focusEvent) | 61 if (event->type() == eventNames().focusEvent) |
| 61 didFocus(); | 62 didFocus(); |
| 62 | 63 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 void DateTimeFieldElement::updateVisibleValue(EventBehavior eventBehavior) | 200 void DateTimeFieldElement::updateVisibleValue(EventBehavior eventBehavior) |
| 200 { | 201 { |
| 201 Text* const textNode = toText(firstChild()); | 202 Text* const textNode = toText(firstChild()); |
| 202 const String newVisibleValue = visibleValue(); | 203 const String newVisibleValue = visibleValue(); |
| 203 ASSERT(newVisibleValue.length() > 0); | 204 ASSERT(newVisibleValue.length() > 0); |
| 204 | 205 |
| 205 if (textNode->wholeText() == newVisibleValue) | 206 if (textNode->wholeText() == newVisibleValue) |
| 206 return; | 207 return; |
| 207 | 208 |
| 208 textNode->replaceWholeText(newVisibleValue, ASSERT_NO_EXCEPTION); | 209 textNode->replaceWholeText(newVisibleValue, ASSERT_NO_EXCEPTION); |
| 209 setAttribute(aria_valuetextAttr, hasValue() ? newVisibleValue : AXDateTimeFi
eldEmptyValueText()); | 210 if (hasValue()) { |
| 210 setAttribute(aria_valuenowAttr, newVisibleValue); | 211 setAttribute(aria_valuetextAttr, newVisibleValue); |
| 212 setAttribute(aria_valuenowAttr, String::number(valueForARIAValueNow())); |
| 213 } else { |
| 214 setAttribute(aria_valuetextAttr, AXDateTimeFieldEmptyValueText()); |
| 215 removeAttribute(aria_valuenowAttr); |
| 216 } |
| 211 | 217 |
| 212 if (eventBehavior == DispatchEvent && m_fieldOwner) | 218 if (eventBehavior == DispatchEvent && m_fieldOwner) |
| 213 m_fieldOwner->fieldValueChanged(); | 219 m_fieldOwner->fieldValueChanged(); |
| 214 } | 220 } |
| 215 | 221 |
| 222 int DateTimeFieldElement::valueForARIAValueNow() const |
| 223 { |
| 224 return valueAsInteger(); |
| 225 } |
| 226 |
| 216 } // namespace WebCore | 227 } // namespace WebCore |
| 217 | 228 |
| 218 #endif | 229 #endif |
| OLD | NEW |