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

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

Issue 84713002: Add number() static methods to AtomicString class (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 double value = parseToDoubleForNumberType(fastGetAttribute(valueAttr)); 97 double value = parseToDoubleForNumberType(fastGetAttribute(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 setAttribute(valueAttr, AtomicString::number(value >= 0 ? value : 0));
eseidel 2013/11/24 21:37:44 std::max(0, value)?
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 = parseToDoubleForNumberType(getAttribute(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 setAttribute(maxAttr, AtomicString::number(max > 0 ? max : 1));
eseidel 2013/11/24 21:37:44 std::max(1, value)?
Inactive 2013/11/24 22:06:20 This is not equivalent. 0.5 is a valid input value
123 } 123 }
124 124
125 double HTMLProgressElement::position() const 125 double HTMLProgressElement::position() const
126 { 126 {
127 if (!isDeterminate()) 127 if (!isDeterminate())
128 return HTMLProgressElement::IndeterminatePosition; 128 return HTMLProgressElement::IndeterminatePosition;
129 return value() / max(); 129 return value() / max();
130 } 130 }
131 131
132 bool HTMLProgressElement::isDeterminate() const 132 bool HTMLProgressElement::isDeterminate() const
(...skipping 30 matching lines...) Expand all
163 163
164 inner->appendChild(bar); 164 inner->appendChild(bar);
165 } 165 }
166 166
167 bool HTMLProgressElement::shouldAppearIndeterminate() const 167 bool HTMLProgressElement::shouldAppearIndeterminate() const
168 { 168 {
169 return !isDeterminate(); 169 return !isDeterminate();
170 } 170 }
171 171
172 } // namespace 172 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698