OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 72 } |
73 | 73 |
74 double HTMLMeterElement::min() const | 74 double HTMLMeterElement::min() const |
75 { | 75 { |
76 return getFloatingPointAttribute(minAttr, 0); | 76 return getFloatingPointAttribute(minAttr, 0); |
77 } | 77 } |
78 | 78 |
79 void HTMLMeterElement::setMin(double min, ExceptionState& exceptionState) | 79 void HTMLMeterElement::setMin(double min, ExceptionState& exceptionState) |
80 { | 80 { |
81 if (!std::isfinite(min)) { | 81 if (!std::isfinite(min)) { |
82 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToSet("min", "HTMLMeterElement", ExceptionMessages::notAFiniteNumber(min)))
; | 82 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::n
otAFiniteNumber(min)); |
83 return; | 83 return; |
84 } | 84 } |
85 setFloatingPointAttribute(minAttr, min); | 85 setFloatingPointAttribute(minAttr, min); |
86 } | 86 } |
87 | 87 |
88 double HTMLMeterElement::max() const | 88 double HTMLMeterElement::max() const |
89 { | 89 { |
90 return std::max(getFloatingPointAttribute(maxAttr, std::max(1.0, min())), mi
n()); | 90 return std::max(getFloatingPointAttribute(maxAttr, std::max(1.0, min())), mi
n()); |
91 } | 91 } |
92 | 92 |
93 void HTMLMeterElement::setMax(double max, ExceptionState& exceptionState) | 93 void HTMLMeterElement::setMax(double max, ExceptionState& exceptionState) |
94 { | 94 { |
95 if (!std::isfinite(max)) { | 95 if (!std::isfinite(max)) { |
96 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToSet("max", "HTMLMeterElement", ExceptionMessages::notAFiniteNumber(max)))
; | 96 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::n
otAFiniteNumber(max)); |
97 return; | 97 return; |
98 } | 98 } |
99 setFloatingPointAttribute(maxAttr, max); | 99 setFloatingPointAttribute(maxAttr, max); |
100 } | 100 } |
101 | 101 |
102 double HTMLMeterElement::value() const | 102 double HTMLMeterElement::value() const |
103 { | 103 { |
104 double value = getFloatingPointAttribute(valueAttr, 0); | 104 double value = getFloatingPointAttribute(valueAttr, 0); |
105 return std::min(std::max(value, min()), max()); | 105 return std::min(std::max(value, min()), max()); |
106 } | 106 } |
107 | 107 |
108 void HTMLMeterElement::setValue(double value, ExceptionState& exceptionState) | 108 void HTMLMeterElement::setValue(double value, ExceptionState& exceptionState) |
109 { | 109 { |
110 if (!std::isfinite(value)) { | 110 if (!std::isfinite(value)) { |
111 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToSet("value", "HTMLMeterElement", ExceptionMessages::notAFiniteNumber(valu
e))); | 111 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::n
otAFiniteNumber(value)); |
112 return; | 112 return; |
113 } | 113 } |
114 setFloatingPointAttribute(valueAttr, value); | 114 setFloatingPointAttribute(valueAttr, value); |
115 } | 115 } |
116 | 116 |
117 double HTMLMeterElement::low() const | 117 double HTMLMeterElement::low() const |
118 { | 118 { |
119 double low = getFloatingPointAttribute(lowAttr, min()); | 119 double low = getFloatingPointAttribute(lowAttr, min()); |
120 return std::min(std::max(low, min()), max()); | 120 return std::min(std::max(low, min()), max()); |
121 } | 121 } |
122 | 122 |
123 void HTMLMeterElement::setLow(double low, ExceptionState& exceptionState) | 123 void HTMLMeterElement::setLow(double low, ExceptionState& exceptionState) |
124 { | 124 { |
125 if (!std::isfinite(low)) { | 125 if (!std::isfinite(low)) { |
126 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToSet("low", "HTMLMeterElement", ExceptionMessages::notAFiniteNumber(low)))
; | 126 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::n
otAFiniteNumber(low)); |
127 return; | 127 return; |
128 } | 128 } |
129 setFloatingPointAttribute(lowAttr, low); | 129 setFloatingPointAttribute(lowAttr, low); |
130 } | 130 } |
131 | 131 |
132 double HTMLMeterElement::high() const | 132 double HTMLMeterElement::high() const |
133 { | 133 { |
134 double high = getFloatingPointAttribute(highAttr, max()); | 134 double high = getFloatingPointAttribute(highAttr, max()); |
135 return std::min(std::max(high, low()), max()); | 135 return std::min(std::max(high, low()), max()); |
136 } | 136 } |
137 | 137 |
138 void HTMLMeterElement::setHigh(double high, ExceptionState& exceptionState) | 138 void HTMLMeterElement::setHigh(double high, ExceptionState& exceptionState) |
139 { | 139 { |
140 if (!std::isfinite(high)) { | 140 if (!std::isfinite(high)) { |
141 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToSet("high", "HTMLMeterElement", ExceptionMessages::notAFiniteNumber(high)
)); | 141 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::n
otAFiniteNumber(high)); |
142 return; | 142 return; |
143 } | 143 } |
144 setFloatingPointAttribute(highAttr, high); | 144 setFloatingPointAttribute(highAttr, high); |
145 } | 145 } |
146 | 146 |
147 double HTMLMeterElement::optimum() const | 147 double HTMLMeterElement::optimum() const |
148 { | 148 { |
149 double optimum = getFloatingPointAttribute(optimumAttr, (max() + min()) / 2)
; | 149 double optimum = getFloatingPointAttribute(optimumAttr, (max() + min()) / 2)
; |
150 return std::min(std::max(optimum, min()), max()); | 150 return std::min(std::max(optimum, min()), max()); |
151 } | 151 } |
152 | 152 |
153 void HTMLMeterElement::setOptimum(double optimum, ExceptionState& exceptionState
) | 153 void HTMLMeterElement::setOptimum(double optimum, ExceptionState& exceptionState
) |
154 { | 154 { |
155 if (!std::isfinite(optimum)) { | 155 if (!std::isfinite(optimum)) { |
156 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToSet("optimum", "HTMLMeterElement", ExceptionMessages::notAFiniteNumber(op
timum))); | 156 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::n
otAFiniteNumber(optimum)); |
157 return; | 157 return; |
158 } | 158 } |
159 setFloatingPointAttribute(optimumAttr, optimum); | 159 setFloatingPointAttribute(optimumAttr, optimum); |
160 } | 160 } |
161 | 161 |
162 HTMLMeterElement::GaugeRegion HTMLMeterElement::gaugeRegion() const | 162 HTMLMeterElement::GaugeRegion HTMLMeterElement::gaugeRegion() const |
163 { | 163 { |
164 double lowValue = low(); | 164 double lowValue = low(); |
165 double highValue = high(); | 165 double highValue = high(); |
166 double theValue = value(); | 166 double theValue = value(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 RefPtr<MeterBarElement> bar = MeterBarElement::create(document()); | 230 RefPtr<MeterBarElement> bar = MeterBarElement::create(document()); |
231 m_value = MeterValueElement::create(document()); | 231 m_value = MeterValueElement::create(document()); |
232 m_value->setWidthPercentage(0); | 232 m_value->setWidthPercentage(0); |
233 m_value->updatePseudo(); | 233 m_value->updatePseudo(); |
234 bar->appendChild(m_value); | 234 bar->appendChild(m_value); |
235 | 235 |
236 inner->appendChild(bar); | 236 inner->appendChild(bar); |
237 } | 237 } |
238 | 238 |
239 } // namespace | 239 } // namespace |
OLD | NEW |