| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 | 86 |
| 87 int DateTimeNumericFieldElement::DefaultValueForStepDown() const { | 87 int DateTimeNumericFieldElement::DefaultValueForStepDown() const { |
| 88 return range_.maximum; | 88 return range_.maximum; |
| 89 } | 89 } |
| 90 | 90 |
| 91 int DateTimeNumericFieldElement::DefaultValueForStepUp() const { | 91 int DateTimeNumericFieldElement::DefaultValueForStepUp() const { |
| 92 return range_.minimum; | 92 return range_.minimum; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void DateTimeNumericFieldElement::SetFocused(bool value) { | 95 void DateTimeNumericFieldElement::SetFocused(bool value, |
| 96 WebFocusType focus_type) { |
| 96 if (!value) { | 97 if (!value) { |
| 97 int value = TypeAheadValue(); | 98 int value = TypeAheadValue(); |
| 98 type_ahead_buffer_.Clear(); | 99 type_ahead_buffer_.Clear(); |
| 99 if (value >= 0) | 100 if (value >= 0) |
| 100 SetValueAsInteger(value, kDispatchEvent); | 101 SetValueAsInteger(value, kDispatchEvent); |
| 101 } | 102 } |
| 102 DateTimeFieldElement::SetFocused(value); | 103 DateTimeFieldElement::SetFocused(value, focus_type); |
| 103 } | 104 } |
| 104 | 105 |
| 105 String DateTimeNumericFieldElement::FormatValue(int value) const { | 106 String DateTimeNumericFieldElement::FormatValue(int value) const { |
| 106 Locale& locale = LocaleForOwner(); | 107 Locale& locale = LocaleForOwner(); |
| 107 if (hard_limits_.maximum > 999) | 108 if (hard_limits_.maximum > 999) |
| 108 return locale.ConvertToLocalizedNumber(String::Format("%04d", value)); | 109 return locale.ConvertToLocalizedNumber(String::Format("%04d", value)); |
| 109 if (hard_limits_.maximum > 99) | 110 if (hard_limits_.maximum > 99) |
| 110 return locale.ConvertToLocalizedNumber(String::Format("%03d", value)); | 111 return locale.ConvertToLocalizedNumber(String::Format("%03d", value)); |
| 111 return locale.ConvertToLocalizedNumber(String::Format("%02d", value)); | 112 return locale.ConvertToLocalizedNumber(String::Format("%02d", value)); |
| 112 } | 113 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 int DateTimeNumericFieldElement::RoundUp(int n) const { | 231 int DateTimeNumericFieldElement::RoundUp(int n) const { |
| 231 n -= step_.step_base; | 232 n -= step_.step_base; |
| 232 if (n >= 0) | 233 if (n >= 0) |
| 233 n = (n + step_.step - 1) / step_.step * step_.step; | 234 n = (n + step_.step - 1) / step_.step * step_.step; |
| 234 else | 235 else |
| 235 n = -(-n / step_.step * step_.step); | 236 n = -(-n / step_.step * step_.step); |
| 236 return n + step_.step_base; | 237 return n + step_.step_base; |
| 237 } | 238 } |
| 238 | 239 |
| 239 } // namespace blink | 240 } // namespace blink |
| OLD | NEW |