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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 void HTMLProgressElement::attach(const AttachContext& context) | 88 void HTMLProgressElement::attach(const AttachContext& context) |
89 { | 89 { |
90 LabelableElement::attach(context); | 90 LabelableElement::attach(context); |
91 if (RenderProgress* render = renderProgress()) | 91 if (RenderProgress* render = renderProgress()) |
92 render->updateFromElement(); | 92 render->updateFromElement(); |
93 } | 93 } |
94 | 94 |
95 double HTMLProgressElement::value() const | 95 double HTMLProgressElement::value() const |
96 { | 96 { |
97 double value = parseToDoubleForNumberType(fastGetAttribute(valueAttr)); | 97 double value = getFloatingPointAttribute(valueAttr); |
98 return !std::isfinite(value) || value < 0 ? 0 : std::min(value, max()); | 98 return !std::isfinite(value) || value < 0 ? 0 : std::min(value, max()); |
99 } | 99 } |
100 | 100 |
101 void HTMLProgressElement::setValue(double value, ExceptionState& exceptionState) | 101 void HTMLProgressElement::setValue(double value, ExceptionState& exceptionState) |
102 { | 102 { |
103 if (!std::isfinite(value)) { | 103 if (!std::isfinite(value)) { |
104 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToSet("value", "HTMLProgressElement", ExceptionMessages::notAFiniteNumber(v
alue))); | 104 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToSet("value", "HTMLProgressElement", ExceptionMessages::notAFiniteNumber(v
alue))); |
105 return; | 105 return; |
106 } | 106 } |
107 setAttribute(valueAttr, String::number(value >= 0 ? value : 0)); | 107 setFloatingPointAttribute(valueAttr, std::max(value, 0.)); |
108 } | 108 } |
109 | 109 |
110 double HTMLProgressElement::max() const | 110 double HTMLProgressElement::max() const |
111 { | 111 { |
112 double max = parseToDoubleForNumberType(getAttribute(maxAttr)); | 112 double max = getFloatingPointAttribute(maxAttr); |
113 return !std::isfinite(max) || max <= 0 ? 1 : max; | 113 return !std::isfinite(max) || max <= 0 ? 1 : max; |
114 } | 114 } |
115 | 115 |
116 void HTMLProgressElement::setMax(double max, ExceptionState& exceptionState) | 116 void HTMLProgressElement::setMax(double max, ExceptionState& exceptionState) |
117 { | 117 { |
118 if (!std::isfinite(max)) { | 118 if (!std::isfinite(max)) { |
119 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToSet("max", "HTMLProgressElement", ExceptionMessages::notAFiniteNumber(max
))); | 119 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToSet("max", "HTMLProgressElement", ExceptionMessages::notAFiniteNumber(max
))); |
120 return; | 120 return; |
121 } | 121 } |
122 setAttribute(maxAttr, String::number(max > 0 ? max : 1)); | 122 // FIXME: The specification says we should ignore the input value if it is i
nferior or equal to 0. |
| 123 setFloatingPointAttribute(maxAttr, max > 0 ? max : 1); |
123 } | 124 } |
124 | 125 |
125 double HTMLProgressElement::position() const | 126 double HTMLProgressElement::position() const |
126 { | 127 { |
127 if (!isDeterminate()) | 128 if (!isDeterminate()) |
128 return HTMLProgressElement::IndeterminatePosition; | 129 return HTMLProgressElement::IndeterminatePosition; |
129 return value() / max(); | 130 return value() / max(); |
130 } | 131 } |
131 | 132 |
132 bool HTMLProgressElement::isDeterminate() const | 133 bool HTMLProgressElement::isDeterminate() const |
(...skipping 30 matching lines...) Expand all Loading... |
163 | 164 |
164 inner->appendChild(bar); | 165 inner->appendChild(bar); |
165 } | 166 } |
166 | 167 |
167 bool HTMLProgressElement::shouldAppearIndeterminate() const | 168 bool HTMLProgressElement::shouldAppearIndeterminate() const |
168 { | 169 { |
169 return !isDeterminate(); | 170 return !isDeterminate(); |
170 } | 171 } |
171 | 172 |
172 } // namespace | 173 } // namespace |
OLD | NEW |