| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 return field.release(); | 127 return field.release(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void DateTimeHourFieldElement::populateDateTimeFieldsState(DateTimeFieldsState&
dateTimeFieldsState) | 130 void DateTimeHourFieldElement::populateDateTimeFieldsState(DateTimeFieldsState&
dateTimeFieldsState) |
| 131 { | 131 { |
| 132 if (!hasValue()) { | 132 if (!hasValue()) { |
| 133 dateTimeFieldsState.setHour(DateTimeFieldsState::emptyValue); | 133 dateTimeFieldsState.setHour(DateTimeFieldsState::emptyValue); |
| 134 return; | 134 return; |
| 135 } | 135 } |
| 136 | 136 |
| 137 const int value = DateTimeNumericFieldElement::valueAsInteger(); | 137 const int value = valueAsInteger(); |
| 138 | 138 |
| 139 switch (maximum()) { | 139 switch (maximum()) { |
| 140 case 11: | 140 case 11: |
| 141 dateTimeFieldsState.setHour(value ? value : 12); | 141 dateTimeFieldsState.setHour(value ? value : 12); |
| 142 return; | 142 return; |
| 143 case 12: | 143 case 12: |
| 144 dateTimeFieldsState.setHour(value); | 144 dateTimeFieldsState.setHour(value); |
| 145 return; | 145 return; |
| 146 case 23: | 146 case 23: |
| 147 dateTimeFieldsState.setHour(value ? value % 12 : 12); | 147 dateTimeFieldsState.setHour(value ? value % 12 : 12); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 ASSERT_NOT_REACHED(); | 203 ASSERT_NOT_REACHED(); |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 void DateTimeHourFieldElement::setValueAsInteger(int valueAsHour23, EventBehavio
r eventBehavior) | 207 void DateTimeHourFieldElement::setValueAsInteger(int valueAsHour23, EventBehavio
r eventBehavior) |
| 208 { | 208 { |
| 209 const int value = Range(0, 23).clampValue(valueAsHour23) % m_alignment; | 209 const int value = Range(0, 23).clampValue(valueAsHour23) % m_alignment; |
| 210 DateTimeNumericFieldElement::setValueAsInteger(range().minimum && !value ? m
_alignment : value, eventBehavior); | 210 DateTimeNumericFieldElement::setValueAsInteger(range().minimum && !value ? m
_alignment : value, eventBehavior); |
| 211 } | 211 } |
| 212 | 212 |
| 213 int DateTimeHourFieldElement::valueAsInteger() const | |
| 214 { | |
| 215 return hasValue() ? DateTimeNumericFieldElement::valueAsInteger() % m_alignm
ent : -1; | |
| 216 } | |
| 217 | |
| 218 // ---------------------------- | 213 // ---------------------------- |
| 219 | 214 |
| 220 DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement(Document* docum
ent, FieldOwner& fieldOwner, const DateTimeNumericFieldElement::Parameters& para
meters) | 215 DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement(Document* docum
ent, FieldOwner& fieldOwner, const DateTimeNumericFieldElement::Parameters& para
meters) |
| 221 : DateTimeNumericFieldElement(document, fieldOwner, 0, 999, "---", parameter
s) | 216 : DateTimeNumericFieldElement(document, fieldOwner, 0, 999, "---", parameter
s) |
| 222 { | 217 { |
| 223 } | 218 } |
| 224 | 219 |
| 225 PassRefPtr<DateTimeMillisecondFieldElement> DateTimeMillisecondFieldElement::cre
ate(Document* document, FieldOwner& fieldOwner, const DateTimeNumericFieldElemen
t::Parameters& parameters) | 220 PassRefPtr<DateTimeMillisecondFieldElement> DateTimeMillisecondFieldElement::cre
ate(Document* document, FieldOwner& fieldOwner, const DateTimeNumericFieldElemen
t::Parameters& parameters) |
| 226 { | 221 { |
| 227 DEFINE_STATIC_LOCAL(AtomicString, millisecondPsuedoId, ("-webkit-datetime-ed
it-millisecond-field", AtomicString::ConstructFromLiteral)); | 222 DEFINE_STATIC_LOCAL(AtomicString, millisecondPsuedoId, ("-webkit-datetime-ed
it-millisecond-field", AtomicString::ConstructFromLiteral)); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 setValueAsInteger(value); | 528 setValueAsInteger(value); |
| 534 return; | 529 return; |
| 535 } | 530 } |
| 536 | 531 |
| 537 setEmptyValue(); | 532 setEmptyValue(); |
| 538 } | 533 } |
| 539 | 534 |
| 540 } // namespace WebCore | 535 } // namespace WebCore |
| 541 | 536 |
| 542 #endif | 537 #endif |
| OLD | NEW |