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

Side by Side Diff: third_party/WebKit/Source/core/html/forms/StepRange.cpp

Issue 2390563002: Reflow comments in core/html/forms/. (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 m_stepDescription(stepDescription), 60 m_stepDescription(stepDescription),
61 m_hasStep(step.isFinite()), 61 m_hasStep(step.isFinite()),
62 m_hasRangeLimitations(hasRangeLimitations) { 62 m_hasRangeLimitations(hasRangeLimitations) {
63 DCHECK(m_maximum.isFinite()); 63 DCHECK(m_maximum.isFinite());
64 DCHECK(m_minimum.isFinite()); 64 DCHECK(m_minimum.isFinite());
65 DCHECK(m_step.isFinite()); 65 DCHECK(m_step.isFinite());
66 DCHECK(m_stepBase.isFinite()); 66 DCHECK(m_stepBase.isFinite());
67 } 67 }
68 68
69 Decimal StepRange::acceptableError() const { 69 Decimal StepRange::acceptableError() const {
70 // FIXME: We should use DBL_MANT_DIG instead of FLT_MANT_DIG regarding to HTML 5 specification. 70 // FIXME: We should use DBL_MANT_DIG instead of FLT_MANT_DIG regarding to
71 // HTML5 specification.
71 DEFINE_STATIC_LOCAL(const Decimal, twoPowerOfFloatMantissaBits, 72 DEFINE_STATIC_LOCAL(const Decimal, twoPowerOfFloatMantissaBits,
72 (Decimal::Positive, 0, UINT64_C(1) << FLT_MANT_DIG)); 73 (Decimal::Positive, 0, UINT64_C(1) << FLT_MANT_DIG));
73 return m_stepDescription.stepValueShouldBe == StepValueShouldBeReal 74 return m_stepDescription.stepValueShouldBe == StepValueShouldBeReal
74 ? m_step / twoPowerOfFloatMantissaBits 75 ? m_step / twoPowerOfFloatMantissaBits
75 : Decimal(0); 76 : Decimal(0);
76 } 77 }
77 78
78 Decimal StepRange::alignValueForStep(const Decimal& currentValue, 79 Decimal StepRange::alignValueForStep(const Decimal& currentValue,
79 const Decimal& newValue) const { 80 const Decimal& newValue) const {
80 DEFINE_STATIC_LOCAL(const Decimal, tenPowerOf21, (Decimal::Positive, 21, 1)); 81 DEFINE_STATIC_LOCAL(const Decimal, tenPowerOf21, (Decimal::Positive, 21, 1));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 121
121 Decimal step = parseToDecimalForNumberType(stepString); 122 Decimal step = parseToDecimalForNumberType(stepString);
122 if (!step.isFinite() || step <= 0) 123 if (!step.isFinite() || step <= 0)
123 return stepDescription.defaultValue(); 124 return stepDescription.defaultValue();
124 125
125 switch (stepDescription.stepValueShouldBe) { 126 switch (stepDescription.stepValueShouldBe) {
126 case StepValueShouldBeReal: 127 case StepValueShouldBeReal:
127 step *= stepDescription.stepScaleFactor; 128 step *= stepDescription.stepScaleFactor;
128 break; 129 break;
129 case ParsedStepValueShouldBeInteger: 130 case ParsedStepValueShouldBeInteger:
130 // For date, month, and week, the parsed value should be an integer for so me types. 131 // For date, month, and week, the parsed value should be an integer for
132 // some types.
131 step = std::max(step.round(), Decimal(1)); 133 step = std::max(step.round(), Decimal(1));
132 step *= stepDescription.stepScaleFactor; 134 step *= stepDescription.stepScaleFactor;
133 break; 135 break;
134 case ScaledStepValueShouldBeInteger: 136 case ScaledStepValueShouldBeInteger:
135 // For datetime, datetime-local, time, the result should be an integer. 137 // For datetime, datetime-local, time, the result should be an integer.
136 step *= stepDescription.stepScaleFactor; 138 step *= stepDescription.stepScaleFactor;
137 step = std::max(step.round(), Decimal(1)); 139 step = std::max(step.round(), Decimal(1));
138 break; 140 break;
139 default: 141 default:
140 NOTREACHED(); 142 NOTREACHED();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 Decimal alignedMaximum = base + ((maximum() - base) / step).floor() * step; 185 Decimal alignedMaximum = base + ((maximum() - base) / step).floor() * step;
184 if (alignedMaximum > maximum()) 186 if (alignedMaximum > maximum())
185 alignedMaximum -= step; 187 alignedMaximum -= step;
186 DCHECK_LE(alignedMaximum, maximum()); 188 DCHECK_LE(alignedMaximum, maximum());
187 if (alignedMaximum < minimum()) 189 if (alignedMaximum < minimum())
188 return Decimal::nan(); 190 return Decimal::nan();
189 return alignedMaximum; 191 return alignedMaximum;
190 } 192 }
191 193
192 } // namespace blink 194 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698