| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND | |
| 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 16 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE | |
| 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
| 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
| 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| 23 * SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #ifndef DateTimeSymbolicFieldElement_h | |
| 27 #define DateTimeSymbolicFieldElement_h | |
| 28 | |
| 29 #include "core/html/forms/TypeAhead.h" | |
| 30 #include "core/html/shadow/DateTimeFieldElement.h" | |
| 31 | |
| 32 namespace blink { | |
| 33 | |
| 34 // DateTimeSymbolicFieldElement represents non-numeric field of data time | |
| 35 // format, such as: AM/PM, and month. | |
| 36 class DateTimeSymbolicFieldElement : public DateTimeFieldElement, | |
| 37 public TypeAheadDataSource { | |
| 38 WTF_MAKE_NONCOPYABLE(DateTimeSymbolicFieldElement); | |
| 39 | |
| 40 protected: | |
| 41 DateTimeSymbolicFieldElement(Document&, | |
| 42 FieldOwner&, | |
| 43 const Vector<String>&, | |
| 44 int minimum, | |
| 45 int maximum); | |
| 46 size_t SymbolsSize() const { return symbols_.size(); } | |
| 47 bool HasValue() const final; | |
| 48 void Initialize(const AtomicString& pseudo, const String& ax_help_text); | |
| 49 void SetEmptyValue(EventBehavior = kDispatchNoEvent) final; | |
| 50 void SetValueAsInteger(int, EventBehavior = kDispatchNoEvent) final; | |
| 51 int ValueAsInteger() const final; | |
| 52 | |
| 53 private: | |
| 54 static const int kInvalidIndex = -1; | |
| 55 | |
| 56 String VisibleEmptyValue() const; | |
| 57 bool IndexIsInRange(int index) const { | |
| 58 return index >= minimum_index_ && index <= maximum_index_; | |
| 59 } | |
| 60 | |
| 61 // DateTimeFieldElement functions. | |
| 62 void HandleKeyboardEvent(KeyboardEvent*) final; | |
| 63 float MaximumWidth(const ComputedStyle&) override; | |
| 64 void StepDown() final; | |
| 65 void StepUp() final; | |
| 66 String Value() const final; | |
| 67 int ValueForARIAValueNow() const final; | |
| 68 String VisibleValue() const final; | |
| 69 | |
| 70 // TypeAheadDataSource functions. | |
| 71 int IndexOfSelectedOption() const override; | |
| 72 int OptionCount() const override; | |
| 73 String OptionAtIndex(int index) const override; | |
| 74 | |
| 75 const Vector<String> symbols_; | |
| 76 | |
| 77 // We use AtomicString to share visible empty value among multiple | |
| 78 // DateTimeEditElements in the page. | |
| 79 const AtomicString visible_empty_value_; | |
| 80 int selected_index_; | |
| 81 TypeAhead type_ahead_; | |
| 82 const int minimum_index_; | |
| 83 const int maximum_index_; | |
| 84 }; | |
| 85 | |
| 86 } // namespace blink | |
| 87 | |
| 88 #endif | |
| OLD | NEW |