| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = getFloatingPointAttribute(valueAttr); | 97 double value = getFloatingPointAttribute(valueAttr); |
| 98 // Otherwise, if the parsed value was greater than or equal to the maximum |
| 99 // value, then the current value of the progress bar is the maximum value |
| 100 // of the progress bar. Otherwise, if parsing the value attribute's value |
| 101 // resulted in an error, or a number less than or equal to zero, then the |
| 102 // current value of the progress bar is zero. |
| 98 return !std::isfinite(value) || value < 0 ? 0 : std::min(value, max()); | 103 return !std::isfinite(value) || value < 0 ? 0 : std::min(value, max()); |
| 99 } | 104 } |
| 100 | 105 |
| 101 void HTMLProgressElement::setValue(double value, ExceptionState& exceptionState) | 106 void HTMLProgressElement::setValue(double value) |
| 102 { | 107 { |
| 103 if (!std::isfinite(value)) { | |
| 104 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(value)
); | |
| 105 return; | |
| 106 } | |
| 107 setFloatingPointAttribute(valueAttr, std::max(value, 0.)); | 108 setFloatingPointAttribute(valueAttr, std::max(value, 0.)); |
| 108 } | 109 } |
| 109 | 110 |
| 110 double HTMLProgressElement::max() const | 111 double HTMLProgressElement::max() const |
| 111 { | 112 { |
| 112 double max = getFloatingPointAttribute(maxAttr); | 113 double max = getFloatingPointAttribute(maxAttr); |
| 114 // Otherwise, if the element has no max attribute, or if it has one but |
| 115 // parsing it resulted in an error, or if the parsed value was less than or |
| 116 // equal to zero, then the maximum value of the progress bar is 1.0. |
| 113 return !std::isfinite(max) || max <= 0 ? 1 : max; | 117 return !std::isfinite(max) || max <= 0 ? 1 : max; |
| 114 } | 118 } |
| 115 | 119 |
| 116 void HTMLProgressElement::setMax(double max, ExceptionState& exceptionState) | 120 void HTMLProgressElement::setMax(double max) |
| 117 { | 121 { |
| 118 if (!std::isfinite(max)) { | |
| 119 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(max)); | |
| 120 return; | |
| 121 } | |
| 122 // FIXME: The specification says we should ignore the input value if it is i
nferior or equal to 0. | 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 setFloatingPointAttribute(maxAttr, max > 0 ? max : 1); |
| 124 } | 124 } |
| 125 | 125 |
| 126 double HTMLProgressElement::position() const | 126 double HTMLProgressElement::position() const |
| 127 { | 127 { |
| 128 if (!isDeterminate()) | 128 if (!isDeterminate()) |
| 129 return HTMLProgressElement::IndeterminatePosition; | 129 return HTMLProgressElement::IndeterminatePosition; |
| 130 return value() / max(); | 130 return value() / max(); |
| 131 } | 131 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 inner->appendChild(bar); | 165 inner->appendChild(bar); |
| 166 } | 166 } |
| 167 | 167 |
| 168 bool HTMLProgressElement::shouldAppearIndeterminate() const | 168 bool HTMLProgressElement::shouldAppearIndeterminate() const |
| 169 { | 169 { |
| 170 return !isDeterminate(); | 170 return !isDeterminate(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace | 173 } // namespace |
| OLD | NEW |