| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 void DateTimeNumericFieldElement::stepUp() { | 192 void DateTimeNumericFieldElement::stepUp() { |
| 193 int newValue = roundUp(m_hasValue ? m_value + 1 : defaultValueForStepUp()); | 193 int newValue = roundUp(m_hasValue ? m_value + 1 : defaultValueForStepUp()); |
| 194 if (!m_range.isInRange(newValue)) | 194 if (!m_range.isInRange(newValue)) |
| 195 newValue = roundUp(m_range.minimum); | 195 newValue = roundUp(m_range.minimum); |
| 196 m_typeAheadBuffer.clear(); | 196 m_typeAheadBuffer.clear(); |
| 197 setValueAsInteger(newValue, DispatchEvent); | 197 setValueAsInteger(newValue, DispatchEvent); |
| 198 } | 198 } |
| 199 | 199 |
| 200 String DateTimeNumericFieldElement::value() const { | 200 String DateTimeNumericFieldElement::value() const { |
| 201 return m_hasValue ? formatValue(m_value) : emptyString(); | 201 return m_hasValue ? formatValue(m_value) : emptyString; |
| 202 } | 202 } |
| 203 | 203 |
| 204 int DateTimeNumericFieldElement::valueAsInteger() const { | 204 int DateTimeNumericFieldElement::valueAsInteger() const { |
| 205 return m_hasValue ? m_value : -1; | 205 return m_hasValue ? m_value : -1; |
| 206 } | 206 } |
| 207 | 207 |
| 208 int DateTimeNumericFieldElement::typeAheadValue() const { | 208 int DateTimeNumericFieldElement::typeAheadValue() const { |
| 209 if (m_typeAheadBuffer.length()) | 209 if (m_typeAheadBuffer.length()) |
| 210 return m_typeAheadBuffer.toString().toInt(); | 210 return m_typeAheadBuffer.toString().toInt(); |
| 211 return -1; | 211 return -1; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 229 int DateTimeNumericFieldElement::roundUp(int n) const { | 229 int DateTimeNumericFieldElement::roundUp(int n) const { |
| 230 n -= m_step.stepBase; | 230 n -= m_step.stepBase; |
| 231 if (n >= 0) | 231 if (n >= 0) |
| 232 n = (n + m_step.step - 1) / m_step.step * m_step.step; | 232 n = (n + m_step.step - 1) / m_step.step * m_step.step; |
| 233 else | 233 else |
| 234 n = -(-n / m_step.step * m_step.step); | 234 n = -(-n / m_step.step * m_step.step); |
| 235 return n + m_step.stepBase; | 235 return n + m_step.stepBase; |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace blink | 238 } // namespace blink |
| OLD | NEW |