| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 m_editElement.addField(DateTimeHourFieldElement::create(document, m_edit
Element, 0, 23)); | 114 m_editElement.addField(DateTimeHourFieldElement::create(document, m_edit
Element, 0, 23)); |
| 115 return; | 115 return; |
| 116 | 116 |
| 117 case DateTimeFormat::FieldTypeHour24: | 117 case DateTimeFormat::FieldTypeHour24: |
| 118 m_editElement.addField(DateTimeHourFieldElement::create(document, m_edit
Element, 1, 24)); | 118 m_editElement.addField(DateTimeHourFieldElement::create(document, m_edit
Element, 1, 24)); |
| 119 return; | 119 return; |
| 120 | 120 |
| 121 case DateTimeFormat::FieldTypeMinute: { | 121 case DateTimeFormat::FieldTypeMinute: { |
| 122 RefPtr<DateTimeNumericFieldElement> field = DateTimeMinuteFieldElement::
create(document, m_editElement); | 122 RefPtr<DateTimeNumericFieldElement> field = DateTimeMinuteFieldElement::
create(document, m_editElement); |
| 123 m_editElement.addField(field); | 123 m_editElement.addField(field); |
| 124 if (shouldMinuteFieldReadOnly()) | 124 if (shouldMinuteFieldReadOnly()) { |
| 125 field->setValueAsDate(m_dateValue); |
| 125 field->setReadOnly(); | 126 field->setReadOnly(); |
| 127 } |
| 126 return; | 128 return; |
| 127 } | 129 } |
| 128 | 130 |
| 129 case DateTimeFormat::FieldTypeMonth: | 131 case DateTimeFormat::FieldTypeMonth: |
| 130 switch (count) { | 132 switch (count) { |
| 131 case countForNarrowMonth: // Fallthrough. | 133 case countForNarrowMonth: // Fallthrough. |
| 132 case countForAbbreviatedMonth: | 134 case countForAbbreviatedMonth: |
| 133 m_editElement.addField(DateTimeSymbolicMonthFieldElement::create(doc
ument, m_editElement, m_parameters.locale.shortMonthLabels())); | 135 m_editElement.addField(DateTimeSymbolicMonthFieldElement::create(doc
ument, m_editElement, m_parameters.locale.shortMonthLabels())); |
| 134 break; | 136 break; |
| 135 case countForFullMonth: | 137 case countForFullMonth: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 154 m_editElement.addField(DateTimeMonthFieldElement::create(document, m
_editElement, m_parameters.placeholderForMonth)); | 156 m_editElement.addField(DateTimeMonthFieldElement::create(document, m
_editElement, m_parameters.placeholderForMonth)); |
| 155 break; | 157 break; |
| 156 } | 158 } |
| 157 return; | 159 return; |
| 158 | 160 |
| 159 case DateTimeFormat::FieldTypePeriod: | 161 case DateTimeFormat::FieldTypePeriod: |
| 160 m_editElement.addField(DateTimeAMPMFieldElement::create(document, m_edit
Element, m_parameters.locale.timeAMPMLabels())); | 162 m_editElement.addField(DateTimeAMPMFieldElement::create(document, m_edit
Element, m_parameters.locale.timeAMPMLabels())); |
| 161 return; | 163 return; |
| 162 | 164 |
| 163 case DateTimeFormat::FieldTypeSecond: { | 165 case DateTimeFormat::FieldTypeSecond: { |
| 164 RefPtr<DateTimeSecondFieldElement> field = DateTimeSecondFieldElement::c
reate(document, m_editElement); | 166 RefPtr<DateTimeNumericFieldElement> field = DateTimeSecondFieldElement::
create(document, m_editElement); |
| 165 m_editElement.addField(field); | 167 m_editElement.addField(field); |
| 166 if (shouldSecondFieldReadOnly()) | 168 if (shouldSecondFieldReadOnly()) { |
| 169 field->setValueAsDate(m_dateValue); |
| 167 field->setReadOnly(); | 170 field->setReadOnly(); |
| 171 } |
| 168 | 172 |
| 169 if (needMillisecondField()) { | 173 if (needMillisecondField()) { |
| 170 visitLiteral(m_parameters.locale.localizedDecimalSeparator()); | 174 visitLiteral(m_parameters.locale.localizedDecimalSeparator()); |
| 171 visitField(DateTimeFormat::FieldTypeFractionalSecond, 3); | 175 visitField(DateTimeFormat::FieldTypeFractionalSecond, 3); |
| 172 } | 176 } |
| 173 return; | 177 return; |
| 174 } | 178 } |
| 175 | 179 |
| 176 case DateTimeFormat::FieldTypeFractionalSecond: { | 180 case DateTimeFormat::FieldTypeFractionalSecond: { |
| 177 RefPtr<DateTimeMillisecondFieldElement> field = DateTimeMillisecondField
Element::create(document, m_editElement); | 181 RefPtr<DateTimeNumericFieldElement> field = DateTimeMillisecondFieldElem
ent::create(document, m_editElement); |
| 178 m_editElement.addField(field); | 182 m_editElement.addField(field); |
| 179 if (shouldMillisecondFieldReadOnly()) | 183 if (shouldMillisecondFieldReadOnly()) { |
| 184 field->setValueAsDate(m_dateValue); |
| 180 field->setReadOnly(); | 185 field->setReadOnly(); |
| 186 } |
| 181 return; | 187 return; |
| 182 } | 188 } |
| 183 | 189 |
| 184 case DateTimeFormat::FieldTypeWeekOfYear: | 190 case DateTimeFormat::FieldTypeWeekOfYear: |
| 185 m_editElement.addField(DateTimeWeekFieldElement::create(document, m_edit
Element)); | 191 m_editElement.addField(DateTimeWeekFieldElement::create(document, m_edit
Element)); |
| 186 return; | 192 return; |
| 187 | 193 |
| 188 case DateTimeFormat::FieldTypeYear: { | 194 case DateTimeFormat::FieldTypeYear: { |
| 189 DateTimeYearFieldElement::Parameters yearParams; | 195 DateTimeYearFieldElement::Parameters yearParams; |
| 190 if (m_parameters.minimumYear == m_parameters.undefinedYear()) { | 196 if (m_parameters.minimumYear == m_parameters.undefinedYear()) { |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 HTMLDivElement::defaultEventHandler(event); | 461 HTMLDivElement::defaultEventHandler(event); |
| 456 } | 462 } |
| 457 | 463 |
| 458 void DateTimeEditElement::setValueAsDate(const LayoutParameters& layoutParameter
s, const DateComponents& date) | 464 void DateTimeEditElement::setValueAsDate(const LayoutParameters& layoutParameter
s, const DateComponents& date) |
| 459 { | 465 { |
| 460 layout(layoutParameters, date); | 466 layout(layoutParameters, date); |
| 461 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) | 467 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) |
| 462 m_fields[fieldIndex]->setValueAsDate(date); | 468 m_fields[fieldIndex]->setValueAsDate(date); |
| 463 } | 469 } |
| 464 | 470 |
| 465 void DateTimeEditElement::setValueAsDateTimeFieldsState(const DateTimeFieldsStat
e& dateTimeFieldsState, const DateComponents& dateForReadOnlyField) | 471 void DateTimeEditElement::setValueAsDateTimeFieldsState(const DateTimeFieldsStat
e& dateTimeFieldsState) |
| 466 { | 472 { |
| 467 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) | 473 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) |
| 468 m_fields[fieldIndex]->setValueAsDateTimeFieldsState(dateTimeFieldsState,
dateForReadOnlyField); | 474 m_fields[fieldIndex]->setValueAsDateTimeFieldsState(dateTimeFieldsState)
; |
| 469 } | 475 } |
| 470 | 476 |
| 471 void DateTimeEditElement::setEmptyValue(const LayoutParameters& layoutParameters
, const DateComponents& dateForReadOnlyField) | 477 void DateTimeEditElement::setEmptyValue(const LayoutParameters& layoutParameters
, const DateComponents& dateForReadOnlyField) |
| 472 { | 478 { |
| 473 layout(layoutParameters, dateForReadOnlyField); | 479 layout(layoutParameters, dateForReadOnlyField); |
| 474 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) | 480 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) |
| 475 m_fields[fieldIndex]->setEmptyValue(dateForReadOnlyField, DateTimeFieldE
lement::DispatchNoEvent); | 481 m_fields[fieldIndex]->setEmptyValue(DateTimeFieldElement::DispatchNoEven
t); |
| 476 } | 482 } |
| 477 | 483 |
| 478 bool DateTimeEditElement::hasFocusedField() | 484 bool DateTimeEditElement::hasFocusedField() |
| 479 { | 485 { |
| 480 return focusedFieldIndex() != invalidFieldIndex; | 486 return focusedFieldIndex() != invalidFieldIndex; |
| 481 } | 487 } |
| 482 | 488 |
| 483 void DateTimeEditElement::stepDown() | 489 void DateTimeEditElement::stepDown() |
| 484 { | 490 { |
| 485 if (DateTimeFieldElement* const field = focusedField()) | 491 if (DateTimeFieldElement* const field = focusedField()) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 511 { | 517 { |
| 512 DateTimeFieldsState dateTimeFieldsState; | 518 DateTimeFieldsState dateTimeFieldsState; |
| 513 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) | 519 for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) |
| 514 m_fields[fieldIndex]->populateDateTimeFieldsState(dateTimeFieldsState); | 520 m_fields[fieldIndex]->populateDateTimeFieldsState(dateTimeFieldsState); |
| 515 return dateTimeFieldsState; | 521 return dateTimeFieldsState; |
| 516 } | 522 } |
| 517 | 523 |
| 518 } // namespace WebCore | 524 } // namespace WebCore |
| 519 | 525 |
| 520 #endif | 526 #endif |
| OLD | NEW |