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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #include "core/html/shadow/DateTimeNumericFieldElement.h" | 26 #include "core/html/shadow/DateTimeNumericFieldElement.h" |
27 | 27 |
28 #include "core/CSSPropertyNames.h" | 28 #include "core/CSSPropertyNames.h" |
29 #include "core/CSSValueKeywords.h" | 29 #include "core/CSSValueKeywords.h" |
30 #include "core/events/KeyboardEvent.h" | 30 #include "core/events/KeyboardEvent.h" |
31 #include "platform/fonts/Font.h" | 31 #include "platform/fonts/Font.h" |
32 #include "platform/text/PlatformLocale.h" | 32 #include "platform/text/PlatformLocale.h" |
33 #include "platform/text/TextRun.h" | 33 #include "platform/text/TextRun.h" |
34 | 34 |
35 using namespace WTF::Unicode; | |
36 | |
37 namespace blink { | 35 namespace blink { |
38 | 36 |
39 int DateTimeNumericFieldElement::Range::clampValue(int value) const { | 37 int DateTimeNumericFieldElement::Range::clampValue(int value) const { |
40 return std::min(std::max(value, minimum), maximum); | 38 return std::min(std::max(value, minimum), maximum); |
41 } | 39 } |
42 | 40 |
43 bool DateTimeNumericFieldElement::Range::isInRange(int value) const { | 41 bool DateTimeNumericFieldElement::Range::isInRange(int value) const { |
44 return value >= minimum && value <= maximum; | 42 return value >= minimum && value <= maximum; |
45 } | 43 } |
46 | 44 |
(...skipping 13 matching lines...) Expand all Loading... |
60 m_step(step), | 58 m_step(step), |
61 m_value(0), | 59 m_value(0), |
62 m_hasValue(false) { | 60 m_hasValue(false) { |
63 DCHECK_NE(m_step.step, 0); | 61 DCHECK_NE(m_step.step, 0); |
64 DCHECK_LE(m_range.minimum, m_range.maximum); | 62 DCHECK_LE(m_range.minimum, m_range.maximum); |
65 DCHECK_LE(m_hardLimits.minimum, m_hardLimits.maximum); | 63 DCHECK_LE(m_hardLimits.minimum, m_hardLimits.maximum); |
66 | 64 |
67 // We show a direction-neutral string such as "--" as a placeholder. It | 65 // We show a direction-neutral string such as "--" as a placeholder. It |
68 // should follow the direction of numeric values. | 66 // should follow the direction of numeric values. |
69 if (localeForOwner().isRTL()) { | 67 if (localeForOwner().isRTL()) { |
70 CharDirection dir = direction(formatValue(this->maximum())[0]); | 68 WTF::Unicode::CharDirection dir = |
71 if (dir == LeftToRight || dir == EuropeanNumber || dir == ArabicNumber) { | 69 WTF::Unicode::direction(formatValue(this->maximum())[0]); |
| 70 if (dir == WTF::Unicode::LeftToRight || |
| 71 dir == WTF::Unicode::EuropeanNumber || |
| 72 dir == WTF::Unicode::ArabicNumber) { |
72 setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueBidiOverride); | 73 setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueBidiOverride); |
73 setInlineStyleProperty(CSSPropertyDirection, CSSValueLtr); | 74 setInlineStyleProperty(CSSPropertyDirection, CSSValueLtr); |
74 } | 75 } |
75 } | 76 } |
76 } | 77 } |
77 | 78 |
78 float DateTimeNumericFieldElement::maximumWidth(const ComputedStyle& style) { | 79 float DateTimeNumericFieldElement::maximumWidth(const ComputedStyle& style) { |
79 float maximumWidth = computeTextWidth(style, m_placeholder); | 80 float maximumWidth = computeTextWidth(style, m_placeholder); |
80 maximumWidth = | 81 maximumWidth = |
81 std::max(maximumWidth, computeTextWidth(style, formatValue(maximum()))); | 82 std::max(maximumWidth, computeTextWidth(style, formatValue(maximum()))); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 int DateTimeNumericFieldElement::roundUp(int n) const { | 230 int DateTimeNumericFieldElement::roundUp(int n) const { |
230 n -= m_step.stepBase; | 231 n -= m_step.stepBase; |
231 if (n >= 0) | 232 if (n >= 0) |
232 n = (n + m_step.step - 1) / m_step.step * m_step.step; | 233 n = (n + m_step.step - 1) / m_step.step * m_step.step; |
233 else | 234 else |
234 n = -(-n / m_step.step * m_step.step); | 235 n = -(-n / m_step.step * m_step.step); |
235 return n + m_step.stepBase; | 236 return n + m_step.stepBase; |
236 } | 237 } |
237 | 238 |
238 } // namespace blink | 239 } // namespace blink |
OLD | NEW |