Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1403)

Side by Side Diff: Source/core/html/HTMLMeterElement.cpp

Issue 262753004: Replace all remaining IDL finitude type checks with [TypeChecking=Unrestricted] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLMeterElement.h ('k') | Source/core/html/HTMLMeterElement.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 void HTMLMeterElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) 65 void HTMLMeterElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value)
66 { 66 {
67 if (name == valueAttr || name == minAttr || name == maxAttr || name == lowAt tr || name == highAttr || name == optimumAttr) 67 if (name == valueAttr || name == minAttr || name == maxAttr || name == lowAt tr || name == highAttr || name == optimumAttr)
68 didElementStateChange(); 68 didElementStateChange();
69 else 69 else
70 LabelableElement::parseAttribute(name, value); 70 LabelableElement::parseAttribute(name, value);
71 } 71 }
72 72
73 double HTMLMeterElement::value() const
74 {
75 double value = getFloatingPointAttribute(valueAttr, 0);
76 return std::min(std::max(value, min()), max());
77 }
78
79 void HTMLMeterElement::setValue(double value)
80 {
81 setFloatingPointAttribute(valueAttr, value);
82 }
83
73 double HTMLMeterElement::min() const 84 double HTMLMeterElement::min() const
74 { 85 {
75 return getFloatingPointAttribute(minAttr, 0); 86 return getFloatingPointAttribute(minAttr, 0);
76 } 87 }
77 88
78 void HTMLMeterElement::setMin(double min, ExceptionState& exceptionState) 89 void HTMLMeterElement::setMin(double min)
79 { 90 {
80 if (!std::isfinite(min)) {
81 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(min));
82 return;
83 }
84 setFloatingPointAttribute(minAttr, min); 91 setFloatingPointAttribute(minAttr, min);
85 } 92 }
86 93
87 double HTMLMeterElement::max() const 94 double HTMLMeterElement::max() const
88 { 95 {
89 return std::max(getFloatingPointAttribute(maxAttr, std::max(1.0, min())), mi n()); 96 return std::max(getFloatingPointAttribute(maxAttr, std::max(1.0, min())), mi n());
90 } 97 }
91 98
92 void HTMLMeterElement::setMax(double max, ExceptionState& exceptionState) 99 void HTMLMeterElement::setMax(double max)
93 { 100 {
94 if (!std::isfinite(max)) {
95 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(max));
96 return;
97 }
98 setFloatingPointAttribute(maxAttr, max); 101 setFloatingPointAttribute(maxAttr, max);
99 } 102 }
100 103
101 double HTMLMeterElement::value() const
102 {
103 double value = getFloatingPointAttribute(valueAttr, 0);
104 return std::min(std::max(value, min()), max());
105 }
106
107 void HTMLMeterElement::setValue(double value, ExceptionState& exceptionState)
108 {
109 if (!std::isfinite(value)) {
110 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(value) );
111 return;
112 }
113 setFloatingPointAttribute(valueAttr, value);
114 }
115
116 double HTMLMeterElement::low() const 104 double HTMLMeterElement::low() const
117 { 105 {
118 double low = getFloatingPointAttribute(lowAttr, min()); 106 double low = getFloatingPointAttribute(lowAttr, min());
119 return std::min(std::max(low, min()), max()); 107 return std::min(std::max(low, min()), max());
120 } 108 }
121 109
122 void HTMLMeterElement::setLow(double low, ExceptionState& exceptionState) 110 void HTMLMeterElement::setLow(double low)
123 { 111 {
124 if (!std::isfinite(low)) {
125 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(low));
126 return;
127 }
128 setFloatingPointAttribute(lowAttr, low); 112 setFloatingPointAttribute(lowAttr, low);
129 } 113 }
130 114
131 double HTMLMeterElement::high() const 115 double HTMLMeterElement::high() const
132 { 116 {
133 double high = getFloatingPointAttribute(highAttr, max()); 117 double high = getFloatingPointAttribute(highAttr, max());
134 return std::min(std::max(high, low()), max()); 118 return std::min(std::max(high, low()), max());
135 } 119 }
136 120
137 void HTMLMeterElement::setHigh(double high, ExceptionState& exceptionState) 121 void HTMLMeterElement::setHigh(double high)
138 { 122 {
139 if (!std::isfinite(high)) {
140 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(high)) ;
141 return;
142 }
143 setFloatingPointAttribute(highAttr, high); 123 setFloatingPointAttribute(highAttr, high);
144 } 124 }
145 125
146 double HTMLMeterElement::optimum() const 126 double HTMLMeterElement::optimum() const
147 { 127 {
148 double optimum = getFloatingPointAttribute(optimumAttr, (max() + min()) / 2) ; 128 double optimum = getFloatingPointAttribute(optimumAttr, (max() + min()) / 2) ;
149 return std::min(std::max(optimum, min()), max()); 129 return std::min(std::max(optimum, min()), max());
150 } 130 }
151 131
152 void HTMLMeterElement::setOptimum(double optimum, ExceptionState& exceptionState ) 132 void HTMLMeterElement::setOptimum(double optimum)
153 { 133 {
154 if (!std::isfinite(optimum)) {
155 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(optimu m));
156 return;
157 }
158 setFloatingPointAttribute(optimumAttr, optimum); 134 setFloatingPointAttribute(optimumAttr, optimum);
159 } 135 }
160 136
161 HTMLMeterElement::GaugeRegion HTMLMeterElement::gaugeRegion() const 137 HTMLMeterElement::GaugeRegion HTMLMeterElement::gaugeRegion() const
162 { 138 {
163 double lowValue = low(); 139 double lowValue = low();
164 double highValue = high(); 140 double highValue = high();
165 double theValue = value(); 141 double theValue = value();
166 double optimumValue = optimum(); 142 double optimumValue = optimum();
167 143
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 RefPtr<MeterBarElement> bar = MeterBarElement::create(document()); 205 RefPtr<MeterBarElement> bar = MeterBarElement::create(document());
230 m_value = MeterValueElement::create(document()); 206 m_value = MeterValueElement::create(document());
231 m_value->setWidthPercentage(0); 207 m_value->setWidthPercentage(0);
232 m_value->updatePseudo(); 208 m_value->updatePseudo();
233 bar->appendChild(m_value); 209 bar->appendChild(m_value);
234 210
235 inner->appendChild(bar); 211 inner->appendChild(bar);
236 } 212 }
237 213
238 } // namespace 214 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMeterElement.h ('k') | Source/core/html/HTMLMeterElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698