Changeset 139036 in webkit
- Timestamp:
- Jan 7, 2013 11:19:15 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r139034 r139036 1 2013-01-07 Kunihiko Sakamoto <ksakamoto@chromium.org> 2 3 INPUT_MULTIPLE_FIELDS_UI: Step-up/-down of month/day field should respect min/max attributes 4 https://bugs.webkit.org/show_bug.cgi?id=106212 5 6 Reviewed by Kent Tamura. 7 8 * fast/forms/date-multiple-fields/date-multiple-fields-readonly-subfield-expected.txt: 9 * fast/forms/date-multiple-fields/date-multiple-fields-readonly-subfield.html: Add tests for month and day fields. 10 * fast/forms/date-multiple-fields/date-multiple-fields-stepup-stepdown-from-renderer-expected.txt: Added. 11 * fast/forms/date-multiple-fields/date-multiple-fields-stepup-stepdown-from-renderer.html: Added. 12 * fast/forms/month-multiple-fields/month-multiple-fields-readonly-subfield-expected.txt: Added. 13 * fast/forms/month-multiple-fields/month-multiple-fields-readonly-subfield.html: Added. 14 * fast/forms/month-multiple-fields/month-multiple-fields-stepup-stepdown-from-renderer-expected.txt: Added. 15 * fast/forms/month-multiple-fields/month-multiple-fields-stepup-stepdown-from-renderer.html: Added. 16 1 17 2013-01-07 Christophe Dumez <christophe.dumez@intel.com> 2 18 -
trunk/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-readonly-subfield-expected.txt
r138148 r139036 15 15 PASS isReadOnlyField(createDateInput("2012-01-01", "2012-12-31", "2012-05-30"), pseudoYear) is true 16 16 PASS isReadOnlyField(createDateInput("2012-01-01", "2012-12-31", "2013-01-01"), pseudoYear) is false 17 Month field: 18 PASS isReadOnlyField(createDateInput("", "", ""), pseudoMonth) is false 19 PASS isReadOnlyField(createDateInput("2012-12-17", "", ""), pseudoMonth) is false 20 PASS isReadOnlyField(createDateInput("", "2012-12-17", ""), pseudoMonth) is false 21 PASS isReadOnlyField(createDateInput("", "", "2012-12-17"), pseudoMonth) is false 22 PASS isReadOnlyField(createDateInput("2012-12-01", "2012-12-31", ""), pseudoMonth) is true 23 PASS isReadOnlyField(createDateInput("2012-11-01", "2013-12-31", ""), pseudoMonth) is false 24 PASS isReadOnlyField(createDateInput("2012-12-01", "2013-12-31", ""), pseudoMonth) is false 25 PASS isReadOnlyField(createDateInput("2012-12-01", "2012-12-31", "2012-12-15"), pseudoMonth) is true 26 PASS isReadOnlyField(createDateInput("2012-12-01", "2012-12-31", "2012-11-30"), pseudoMonth) is false 27 Day field: 28 PASS isReadOnlyField(createDateInput("", "", ""), pseudoDay) is false 29 PASS isReadOnlyField(createDateInput("2012-12-17", "", ""), pseudoDay) is false 30 PASS isReadOnlyField(createDateInput("", "2012-12-17", ""), pseudoDay) is false 31 PASS isReadOnlyField(createDateInput("", "", "2012-12-17"), pseudoDay) is false 32 PASS isReadOnlyField(createDateInput("2012-12-17", "2012-12-17", ""), pseudoDay) is true 33 PASS isReadOnlyField(createDateInput("2012-12-17", "2013-12-18", ""), pseudoDay) is false 34 PASS isReadOnlyField(createDateInput("2012-11-17", "2012-12-17", ""), pseudoDay) is false 35 PASS isReadOnlyField(createDateInput("2012-12-17", "2013-12-17", ""), pseudoDay) is false 36 PASS isReadOnlyField(createDateInput("2012-12-17", "2012-12-17", "2012-12-17"), pseudoDay) is true 37 PASS isReadOnlyField(createDateInput("2012-12-17", "2012-12-17", "2012-12-18"), pseudoDay) is false 17 38 PASS successfullyParsed is true 18 39 -
trunk/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-readonly-subfield.html
r138148 r139036 40 40 shouldBeFalse('isReadOnlyField(createDateInput("2012-01-01", "2012-12-31", "2013-01-01"), pseudoYear)'); 41 41 42 debug('Month field:'); 43 shouldBeFalse('isReadOnlyField(createDateInput("", "", ""), pseudoMonth)'); 44 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "", ""), pseudoMonth)'); 45 shouldBeFalse('isReadOnlyField(createDateInput("", "2012-12-17", ""), pseudoMonth)'); 46 shouldBeFalse('isReadOnlyField(createDateInput("", "", "2012-12-17"), pseudoMonth)'); 47 shouldBeTrue('isReadOnlyField(createDateInput("2012-12-01", "2012-12-31", ""), pseudoMonth)'); 48 shouldBeFalse('isReadOnlyField(createDateInput("2012-11-01", "2013-12-31", ""), pseudoMonth)'); 49 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-01", "2013-12-31", ""), pseudoMonth)'); 50 shouldBeTrue('isReadOnlyField(createDateInput("2012-12-01", "2012-12-31", "2012-12-15"), pseudoMonth)'); 51 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-01", "2012-12-31", "2012-11-30"), pseudoMonth)'); 52 53 debug('Day field:'); 54 shouldBeFalse('isReadOnlyField(createDateInput("", "", ""), pseudoDay)'); 55 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "", ""), pseudoDay)'); 56 shouldBeFalse('isReadOnlyField(createDateInput("", "2012-12-17", ""), pseudoDay)'); 57 shouldBeFalse('isReadOnlyField(createDateInput("", "", "2012-12-17"), pseudoDay)'); 58 shouldBeTrue('isReadOnlyField(createDateInput("2012-12-17", "2012-12-17", ""), pseudoDay)'); 59 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "2013-12-18", ""), pseudoDay)'); 60 shouldBeFalse('isReadOnlyField(createDateInput("2012-11-17", "2012-12-17", ""), pseudoDay)'); 61 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "2013-12-17", ""), pseudoDay)'); 62 shouldBeTrue('isReadOnlyField(createDateInput("2012-12-17", "2012-12-17", "2012-12-17"), pseudoDay)'); 63 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "2012-12-17", "2012-12-18"), pseudoDay)'); 64 42 65 </script> 43 66 <script src="../../js/resources/js-test-post.js"></script> -
trunk/Source/WebCore/ChangeLog
r139033 r139036 1 2013-01-07 Kunihiko Sakamoto <ksakamoto@chromium.org> 2 3 INPUT_MULTIPLE_FIELDS_UI: Step-up/-down of month/day field should respect min/max attributes 4 https://bugs.webkit.org/show_bug.cgi?id=106212 5 6 Reviewed by Kent Tamura. 7 8 Make step-up/-down of the month and day fields respect the min/max 9 attributes of the element. 10 Note that these fields still accept any keyboard inputs (the element 11 becomes 'invalid' state when out-of-bounds values entered). 12 13 Tests: fast/forms/date-multiple-fields/date-multiple-fields-readonly-subfield.html 14 fast/forms/date-multiple-fields/date-multiple-fields-stepup-stepdown-from-renderer.html 15 fast/forms/month-multiple-fields/month-multiple-fields-readonly-subfield.html 16 fast/forms/month-multiple-fields/month-multiple-fields-stepup-stepdown-from-renderer.html 17 18 * css/html.css: Add CSS rules for month and day fields. 19 * html/shadow/DateTimeEditElement.cpp: 20 (WebCore::DateTimeEditBuilder::visitField): 21 Compute minimum/maximum values of month/day fields from the min/max 22 parameters of the element. If minimum, maximum, and current value is 23 the same, makes the field read-only. 24 * html/shadow/DateTimeFieldElements.cpp: 25 (WebCore::DateTimeAMPMFieldElement::DateTimeAMPMFieldElement): Add mininum/maximum arguments. 26 (WebCore::DateTimeDayFieldElement::DateTimeDayFieldElement): Ditto. 27 (WebCore::DateTimeDayFieldElement::create): Ditto. 28 (WebCore::DateTimeDayFieldElement::clampValueForHardLimits): Added. 29 (WebCore::DateTimeMonthFieldElement::DateTimeMonthFieldElement): Add mininum/maximum arguments. 30 (WebCore::DateTimeMonthFieldElement::create): Ditto. 31 (WebCore::DateTimeMonthFieldElement::clampValueForHardLimits): Added. 32 (WebCore::DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement): Add mininum/maximum arguments. 33 (WebCore::DateTimeSymbolicMonthFieldElement::create): Ditto. 34 * html/shadow/DateTimeFieldElements.h: 35 (DateTimeDayFieldElement): Add mininum/maximum arguments and declare clampValueForHardLimits. 36 (DateTimeMonthFieldElement): Ditto. 37 (DateTimeSymbolicMonthFieldElement): Add mininum/maximum arguments. 38 * html/shadow/DateTimeSymbolicFieldElement.cpp: 39 (WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement): Add mininum/maximum arguments. 40 (WebCore::DateTimeSymbolicFieldElement::maximum): Returns m_maximumIndex + 1 as it assumes 1-origin value. 41 (WebCore::DateTimeSymbolicFieldElement::minimum): Ditto. 42 (WebCore::DateTimeSymbolicFieldElement::stepDown): Restrict value to m_minimumIndex-m_maximumIndex. 43 (WebCore::DateTimeSymbolicFieldElement::stepUp): Ditto. 44 * html/shadow/DateTimeSymbolicFieldElement.h: 45 (DateTimeSymbolicFieldElement): Add m_minimumIndex and m_maximumIndex. 46 (WebCore::DateTimeSymbolicFieldElement::isInRange): Added. 47 1 48 2013-01-07 Viatcheslav Ostapenko <sl.ostapenko@samsung.com> 2 49 -
trunk/Source/WebCore/css/html.css
r138709 r139036 581 581 582 582 input::-webkit-datetime-edit-year-field[readonly], 583 input::-webkit-datetime-edit-month-field[readonly], 584 input::-webkit-datetime-edit-day-field[readonly], 583 585 input::-webkit-datetime-edit-ampm-field[readonly], 584 586 input::-webkit-datetime-edit-hour-field[readonly], -
trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp
r138254 r139036 106 106 107 107 switch (fieldType) { 108 case DateTimeFormat::FieldTypeDayOfMonth: 109 m_editElement.addField(DateTimeDayFieldElement::create(document, m_editElement, m_parameters.placeholderForDay)); 110 return; 108 case DateTimeFormat::FieldTypeDayOfMonth: { 109 int minDay = 1, maxDay = 31; 110 if (m_parameters.minimum.type() != DateComponents::Invalid 111 && m_parameters.maximum.type() != DateComponents::Invalid 112 && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear() 113 && m_parameters.minimum.month() == m_parameters.maximum.month() 114 && m_parameters.minimum.monthDay() <= m_parameters.maximum.monthDay()) { 115 minDay = m_parameters.minimum.monthDay(); 116 maxDay = m_parameters.maximum.monthDay(); 117 } 118 RefPtr<DateTimeFieldElement> field = DateTimeDayFieldElement::create(document, m_editElement, m_parameters.placeholderForDay, minDay, maxDay); 119 m_editElement.addField(field); 120 if (minDay == maxDay && minDay == m_dateValue.monthDay()) { 121 field->setValueAsDate(m_dateValue); 122 field->setReadOnly(); 123 } 124 return; 125 } 111 126 112 127 case DateTimeFormat::FieldTypeHour11: { … … 165 180 } 166 181 167 case DateTimeFormat::FieldTypeMonth: 182 case DateTimeFormat::FieldTypeMonth: // Fallthrough. 183 case DateTimeFormat::FieldTypeMonthStandAlone: { 184 int minMonth = 0, maxMonth = 11; 185 if (m_parameters.minimum.type() != DateComponents::Invalid 186 && m_parameters.maximum.type() != DateComponents::Invalid 187 && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear() 188 && m_parameters.minimum.month() <= m_parameters.maximum.month()) { 189 minMonth = m_parameters.minimum.month(); 190 maxMonth = m_parameters.maximum.month(); 191 } 192 RefPtr<DateTimeFieldElement> field; 168 193 switch (count) { 169 194 case countForNarrowMonth: // Fallthrough. 170 195 case countForAbbreviatedMonth: 171 m_editElement.addField(DateTimeSymbolicMonthFieldElement::create(document, m_editElement, m_parameters.locale.shortMonthLabels()));196 field = DateTimeSymbolicMonthFieldElement::create(document, m_editElement, fieldType == DateTimeFormat::FieldTypeMonth ? m_parameters.locale.shortMonthLabels() : m_parameters.locale.shortStandAloneMonthLabels(), minMonth, maxMonth); 172 197 break; 173 198 case countForFullMonth: 174 m_editElement.addField(DateTimeSymbolicMonthFieldElement::create(document, m_editElement, m_parameters.locale.monthLabels()));199 field = DateTimeSymbolicMonthFieldElement::create(document, m_editElement, fieldType == DateTimeFormat::FieldTypeMonth ? m_parameters.locale.monthLabels() : m_parameters.locale.standAloneMonthLabels(), minMonth, maxMonth); 175 200 break; 176 201 default: 177 m_editElement.addField(DateTimeMonthFieldElement::create(document, m_editElement, m_parameters.placeholderForMonth));202 field = DateTimeMonthFieldElement::create(document, m_editElement, m_parameters.placeholderForMonth, minMonth + 1, maxMonth + 1); 178 203 break; 179 204 } 180 return; 181 182 case DateTimeFormat::FieldTypeMonthStandAlone: 183 switch (count) { 184 case countForNarrowMonth: // Fallthrough. 185 case countForAbbreviatedMonth: 186 m_editElement.addField(DateTimeSymbolicMonthFieldElement::create(document, m_editElement, m_parameters.locale.shortStandAloneMonthLabels())); 187 break; 188 case countForFullMonth: 189 m_editElement.addField(DateTimeSymbolicMonthFieldElement::create(document, m_editElement, m_parameters.locale.standAloneMonthLabels())); 190 break; 191 default: 192 m_editElement.addField(DateTimeMonthFieldElement::create(document, m_editElement, m_parameters.placeholderForMonth)); 193 break; 194 } 195 return; 205 m_editElement.addField(field); 206 if (minMonth == maxMonth && minMonth == m_dateValue.month()) { 207 field->setValueAsDate(m_dateValue); 208 field->setReadOnly(); 209 } 210 return; 211 } 196 212 197 213 case DateTimeFormat::FieldTypePeriod: { -
trunk/Source/WebCore/html/shadow/DateTimeFieldElements.cpp
r137733 r139036 37 37 38 38 DateTimeAMPMFieldElement::DateTimeAMPMFieldElement(Document* document, FieldOwner& fieldOwner, const Vector<String>& ampmLabels) 39 : DateTimeSymbolicFieldElement(document, fieldOwner, ampmLabels )39 : DateTimeSymbolicFieldElement(document, fieldOwner, ampmLabels, 0, 1) 40 40 { 41 41 } … … 72 72 // ---------------------------- 73 73 74 DateTimeDayFieldElement::DateTimeDayFieldElement(Document* document, FieldOwner& fieldOwner, const String& placeholder )75 : DateTimeNumericFieldElement(document, fieldOwner, 1, 31, placeholder)76 { 77 } 78 79 PassRefPtr<DateTimeDayFieldElement> DateTimeDayFieldElement::create(Document* document, FieldOwner& fieldOwner, const String& placeholder )74 DateTimeDayFieldElement::DateTimeDayFieldElement(Document* document, FieldOwner& fieldOwner, const String& placeholder, int minimum, int maximum) 75 : DateTimeNumericFieldElement(document, fieldOwner, minimum, maximum, placeholder) 76 { 77 } 78 79 PassRefPtr<DateTimeDayFieldElement> DateTimeDayFieldElement::create(Document* document, FieldOwner& fieldOwner, const String& placeholder, int minimum, int maximum) 80 80 { 81 81 DEFINE_STATIC_LOCAL(AtomicString, dayPsuedoId, ("-webkit-datetime-edit-day-field", AtomicString::ConstructFromLiteral)); 82 RefPtr<DateTimeDayFieldElement> field = adoptRef(new DateTimeDayFieldElement(document, fieldOwner, placeholder.isEmpty() ? ASCIILiteral("--") : placeholder ));82 RefPtr<DateTimeDayFieldElement> field = adoptRef(new DateTimeDayFieldElement(document, fieldOwner, placeholder.isEmpty() ? ASCIILiteral("--") : placeholder, minimum, maximum)); 83 83 field->initialize(dayPsuedoId, AXDayOfMonthFieldText()); 84 84 return field.release(); … … 109 109 110 110 setEmptyValue(); 111 } 112 113 int DateTimeDayFieldElement::clampValueForHardLimits(int value) const 114 { 115 return Range(1, 31).clampValue(value); 111 116 } 112 117 … … 300 305 // ---------------------------- 301 306 302 DateTimeMonthFieldElement::DateTimeMonthFieldElement(Document* document, FieldOwner& fieldOwner, const String& placeholder )303 : DateTimeNumericFieldElement(document, fieldOwner, 1, 12, placeholder)304 { 305 } 306 307 PassRefPtr<DateTimeMonthFieldElement> DateTimeMonthFieldElement::create(Document* document, FieldOwner& fieldOwner, const String& placeholder )307 DateTimeMonthFieldElement::DateTimeMonthFieldElement(Document* document, FieldOwner& fieldOwner, const String& placeholder, int minimum, int maximum) 308 : DateTimeNumericFieldElement(document, fieldOwner, minimum, maximum, placeholder) 309 { 310 } 311 312 PassRefPtr<DateTimeMonthFieldElement> DateTimeMonthFieldElement::create(Document* document, FieldOwner& fieldOwner, const String& placeholder, int minimum, int maximum) 308 313 { 309 314 DEFINE_STATIC_LOCAL(AtomicString, monthPsuedoId, ("-webkit-datetime-edit-month-field", AtomicString::ConstructFromLiteral)); 310 RefPtr<DateTimeMonthFieldElement> field = adoptRef(new DateTimeMonthFieldElement(document, fieldOwner, placeholder.isEmpty() ? ASCIILiteral("--") : placeholder ));315 RefPtr<DateTimeMonthFieldElement> field = adoptRef(new DateTimeMonthFieldElement(document, fieldOwner, placeholder.isEmpty() ? ASCIILiteral("--") : placeholder, minimum, maximum)); 311 316 field->initialize(monthPsuedoId, AXMonthFieldText()); 312 317 return field.release(); … … 339 344 } 340 345 346 int DateTimeMonthFieldElement::clampValueForHardLimits(int value) const 347 { 348 return Range(1, 12).clampValue(value); 349 } 350 341 351 // ---------------------------- 342 352 … … 382 392 // ---------------------------- 383 393 384 DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement(Document* document, FieldOwner& fieldOwner, const Vector<String>& labels )385 : DateTimeSymbolicFieldElement(document, fieldOwner, labels )386 { 387 } 388 389 PassRefPtr<DateTimeSymbolicMonthFieldElement> DateTimeSymbolicMonthFieldElement::create(Document* document, FieldOwner& fieldOwner, const Vector<String>& labels )394 DateTimeSymbolicMonthFieldElement::DateTimeSymbolicMonthFieldElement(Document* document, FieldOwner& fieldOwner, const Vector<String>& labels, int minimum, int maximum) 395 : DateTimeSymbolicFieldElement(document, fieldOwner, labels, minimum, maximum) 396 { 397 } 398 399 PassRefPtr<DateTimeSymbolicMonthFieldElement> DateTimeSymbolicMonthFieldElement::create(Document* document, FieldOwner& fieldOwner, const Vector<String>& labels, int minimum, int maximum) 390 400 { 391 401 DEFINE_STATIC_LOCAL(AtomicString, monthPsuedoId, ("-webkit-datetime-edit-month-field", AtomicString::ConstructFromLiteral)); 392 RefPtr<DateTimeSymbolicMonthFieldElement> field = adoptRef(new DateTimeSymbolicMonthFieldElement(document, fieldOwner, labels ));402 RefPtr<DateTimeSymbolicMonthFieldElement> field = adoptRef(new DateTimeSymbolicMonthFieldElement(document, fieldOwner, labels, minimum, maximum)); 393 403 field->initialize(monthPsuedoId, AXMonthFieldText()); 394 404 return field.release(); -
trunk/Source/WebCore/html/shadow/DateTimeFieldElements.h
r137733 r139036 52 52 53 53 public: 54 static PassRefPtr<DateTimeDayFieldElement> create(Document*, FieldOwner&, const String& placeholder); 55 56 private: 57 DateTimeDayFieldElement(Document*, FieldOwner&, const String& placeholder); 58 59 // DateTimeFieldElement functions. 60 virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL; 61 virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL; 62 virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL; 54 static PassRefPtr<DateTimeDayFieldElement> create(Document*, FieldOwner&, const String& placeholder, int minimum, int maximum); 55 56 private: 57 DateTimeDayFieldElement(Document*, FieldOwner&, const String& placeholder, int minimum, int maximum); 58 59 // DateTimeFieldElement functions. 60 virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL; 61 virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL; 62 virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL; 63 64 // DateTimeNumericFieldElement function. 65 virtual int clampValueForHardLimits(int) const OVERRIDE FINAL; 63 66 }; 64 67 … … 122 125 123 126 public: 124 static PassRefPtr<DateTimeMonthFieldElement> create(Document*, FieldOwner&, const String& placeholder); 125 126 private: 127 DateTimeMonthFieldElement(Document*, FieldOwner&, const String& placeholder); 128 129 // DateTimeFieldElement functions. 130 virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL; 131 virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL; 132 virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL; 127 static PassRefPtr<DateTimeMonthFieldElement> create(Document*, FieldOwner&, const String& placeholder, int minimum, int maximum); 128 129 private: 130 DateTimeMonthFieldElement(Document*, FieldOwner&, const String& placeholder, int minimum, int maximum); 131 132 // DateTimeFieldElement functions. 133 virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL; 134 virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL; 135 virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL; 136 137 // DateTimeNumericFieldElement function. 138 virtual int clampValueForHardLimits(int) const OVERRIDE FINAL; 133 139 }; 134 140 … … 152 158 153 159 public: 154 static PassRefPtr<DateTimeSymbolicMonthFieldElement> create(Document*, FieldOwner&, const Vector<String>& );155 156 private: 157 DateTimeSymbolicMonthFieldElement(Document*, FieldOwner&, const Vector<String>& );160 static PassRefPtr<DateTimeSymbolicMonthFieldElement> create(Document*, FieldOwner&, const Vector<String>&, int minimum, int maximum); 161 162 private: 163 DateTimeSymbolicMonthFieldElement(Document*, FieldOwner&, const Vector<String>&, int minimum, int maximum); 158 164 159 165 // DateTimeFieldElement functions. -
trunk/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp
r136808 r139036 48 48 } 49 49 50 DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement(Document* document, FieldOwner& fieldOwner, const Vector<String>& symbols )50 DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement(Document* document, FieldOwner& fieldOwner, const Vector<String>& symbols, int minimum, int maximum) 51 51 : DateTimeFieldElement(document, fieldOwner) 52 52 , m_symbols(symbols) … … 54 54 , m_selectedIndex(-1) 55 55 , m_typeAhead(this) 56 , m_minimumIndex(minimum) 57 , m_maximumIndex(maximum) 56 58 { 57 59 ASSERT(!symbols.isEmpty()); 60 ASSERT(m_minimumIndex >= 0); 61 ASSERT(m_maximumIndex < static_cast<int>(m_symbols.size())); 62 ASSERT(m_minimumIndex <= m_maximumIndex); 58 63 } 59 64 … … 90 95 int DateTimeSymbolicFieldElement::maximum() const 91 96 { 92 return static_cast<int>(m_symbols.size());97 return m_maximumIndex + 1; 93 98 } 94 99 95 100 int DateTimeSymbolicFieldElement::minimum() const 96 101 { 97 return 1;102 return m_minimumIndex + 1; 98 103 } 99 104 … … 114 119 void DateTimeSymbolicFieldElement::stepDown() 115 120 { 116 const int size = m_symbols.size(); 117 m_selectedIndex = hasValue() ? (m_selectedIndex + size - 1) % size : size - 1; 121 if (hasValue()) { 122 if (!isInRange(--m_selectedIndex)) 123 m_selectedIndex = m_maximumIndex; 124 } else 125 m_selectedIndex = m_maximumIndex; 118 126 updateVisibleValue(DispatchEvent); 119 127 } … … 121 129 void DateTimeSymbolicFieldElement::stepUp() 122 130 { 123 m_selectedIndex = hasValue() ? (m_selectedIndex + 1) % m_symbols.size() : 0; 131 if (hasValue()) { 132 if (!isInRange(++m_selectedIndex)) 133 m_selectedIndex = m_minimumIndex; 134 } else 135 m_selectedIndex = m_minimumIndex; 124 136 updateVisibleValue(DispatchEvent); 125 137 } -
trunk/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.h
r136808 r139036 39 39 40 40 protected: 41 DateTimeSymbolicFieldElement(Document*, FieldOwner&, const Vector<String>& );41 DateTimeSymbolicFieldElement(Document*, FieldOwner&, const Vector<String>&, int minimum, int maximum); 42 42 size_t symbolsSize() const { return m_symbols.size(); } 43 43 virtual bool hasValue() const OVERRIDE FINAL; … … 50 50 51 51 String visibleEmptyValue() const; 52 bool isInRange(int index) const { return index >= m_minimumIndex && index <= m_maximumIndex; } 52 53 53 54 // DateTimeFieldElement functions. … … 73 74 int m_selectedIndex; 74 75 TypeAhead m_typeAhead; 76 const int m_minimumIndex; 77 const int m_maximumIndex; 75 78 }; 76 79
Note: See TracChangeset
for help on using the changeset viewer.