| 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 parseToDoubleForNumberType(getAttribute(minAttr), 0); | 76 return parseToDoubleForNumberType(getAttribute(minAttr), 0); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void HTMLMeterElement::setMin(double min, ExceptionState& es) | 79 void HTMLMeterElement::setMin(double min, ExceptionState& es) |
| 80 { | 80 { |
| 81 if (!std::isfinite(min)) { | 81 if (!std::isfinite(min)) { |
| 82 es.throwDOMException(NotSupportedError); | 82 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 83 return; | 83 return; |
| 84 } | 84 } |
| 85 setAttribute(minAttr, String::number(min)); | 85 setAttribute(minAttr, String::number(min)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 double HTMLMeterElement::max() const | 88 double HTMLMeterElement::max() const |
| 89 { | 89 { |
| 90 return std::max(parseToDoubleForNumberType(getAttribute(maxAttr), std::max(1
.0, min())), min()); | 90 return std::max(parseToDoubleForNumberType(getAttribute(maxAttr), std::max(1
.0, min())), min()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void HTMLMeterElement::setMax(double max, ExceptionState& es) | 93 void HTMLMeterElement::setMax(double max, ExceptionState& es) |
| 94 { | 94 { |
| 95 if (!std::isfinite(max)) { | 95 if (!std::isfinite(max)) { |
| 96 es.throwDOMException(NotSupportedError); | 96 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 97 return; | 97 return; |
| 98 } | 98 } |
| 99 setAttribute(maxAttr, String::number(max)); | 99 setAttribute(maxAttr, String::number(max)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 double HTMLMeterElement::value() const | 102 double HTMLMeterElement::value() const |
| 103 { | 103 { |
| 104 double value = parseToDoubleForNumberType(getAttribute(valueAttr), 0); | 104 double value = parseToDoubleForNumberType(getAttribute(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& es) | 108 void HTMLMeterElement::setValue(double value, ExceptionState& es) |
| 109 { | 109 { |
| 110 if (!std::isfinite(value)) { | 110 if (!std::isfinite(value)) { |
| 111 es.throwDOMException(NotSupportedError); | 111 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 112 return; | 112 return; |
| 113 } | 113 } |
| 114 setAttribute(valueAttr, String::number(value)); | 114 setAttribute(valueAttr, String::number(value)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 double HTMLMeterElement::low() const | 117 double HTMLMeterElement::low() const |
| 118 { | 118 { |
| 119 double low = parseToDoubleForNumberType(getAttribute(lowAttr), min()); | 119 double low = parseToDoubleForNumberType(getAttribute(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& es) | 123 void HTMLMeterElement::setLow(double low, ExceptionState& es) |
| 124 { | 124 { |
| 125 if (!std::isfinite(low)) { | 125 if (!std::isfinite(low)) { |
| 126 es.throwDOMException(NotSupportedError); | 126 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 127 return; | 127 return; |
| 128 } | 128 } |
| 129 setAttribute(lowAttr, String::number(low)); | 129 setAttribute(lowAttr, String::number(low)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 double HTMLMeterElement::high() const | 132 double HTMLMeterElement::high() const |
| 133 { | 133 { |
| 134 double high = parseToDoubleForNumberType(getAttribute(highAttr), max()); | 134 double high = parseToDoubleForNumberType(getAttribute(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& es) | 138 void HTMLMeterElement::setHigh(double high, ExceptionState& es) |
| 139 { | 139 { |
| 140 if (!std::isfinite(high)) { | 140 if (!std::isfinite(high)) { |
| 141 es.throwDOMException(NotSupportedError); | 141 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 setAttribute(highAttr, String::number(high)); | 144 setAttribute(highAttr, String::number(high)); |
| 145 } | 145 } |
| 146 | 146 |
| 147 double HTMLMeterElement::optimum() const | 147 double HTMLMeterElement::optimum() const |
| 148 { | 148 { |
| 149 double optimum = parseToDoubleForNumberType(getAttribute(optimumAttr), (max(
) + min()) / 2); | 149 double optimum = parseToDoubleForNumberType(getAttribute(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& es) | 153 void HTMLMeterElement::setOptimum(double optimum, ExceptionState& es) |
| 154 { | 154 { |
| 155 if (!std::isfinite(optimum)) { | 155 if (!std::isfinite(optimum)) { |
| 156 es.throwDOMException(NotSupportedError); | 156 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 setAttribute(optimumAttr, String::number(optimum)); | 159 setAttribute(optimumAttr, String::number(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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 RefPtr<MeterBarElement> bar = MeterBarElement::create(document()); | 231 RefPtr<MeterBarElement> bar = MeterBarElement::create(document()); |
| 232 m_value = MeterValueElement::create(document()); | 232 m_value = MeterValueElement::create(document()); |
| 233 m_value->setWidthPercentage(0); | 233 m_value->setWidthPercentage(0); |
| 234 m_value->updatePseudo(); | 234 m_value->updatePseudo(); |
| 235 bar->appendChild(m_value); | 235 bar->appendChild(m_value); |
| 236 | 236 |
| 237 inner->appendChild(bar); | 237 inner->appendChild(bar); |
| 238 } | 238 } |
| 239 | 239 |
| 240 } // namespace | 240 } // namespace |
| OLD | NEW |