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

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

Issue 2033323002: :in-range and :out-of-range CSS selectors should check 'have range limitations.' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 18 matching lines...) Expand all
29 namespace blink { 29 namespace blink {
30 30
31 using namespace HTMLNames; 31 using namespace HTMLNames;
32 32
33 StepRange::StepRange() 33 StepRange::StepRange()
34 : m_maximum(100) 34 : m_maximum(100)
35 , m_minimum(0) 35 , m_minimum(0)
36 , m_step(1) 36 , m_step(1)
37 , m_stepBase(0) 37 , m_stepBase(0)
38 , m_hasStep(false) 38 , m_hasStep(false)
39 , m_hasRangeLimitations(false)
39 { 40 {
40 } 41 }
41 42
42 StepRange::StepRange(const StepRange& stepRange) 43 StepRange::StepRange(const StepRange& stepRange)
43 : m_maximum(stepRange.m_maximum) 44 : m_maximum(stepRange.m_maximum)
44 , m_minimum(stepRange.m_minimum) 45 , m_minimum(stepRange.m_minimum)
45 , m_step(stepRange.m_step) 46 , m_step(stepRange.m_step)
46 , m_stepBase(stepRange.m_stepBase) 47 , m_stepBase(stepRange.m_stepBase)
47 , m_stepDescription(stepRange.m_stepDescription) 48 , m_stepDescription(stepRange.m_stepDescription)
48 , m_hasStep(stepRange.m_hasStep) 49 , m_hasStep(stepRange.m_hasStep)
50 , m_hasRangeLimitations(stepRange.m_hasRangeLimitations)
49 { 51 {
50 } 52 }
51 53
52 StepRange::StepRange(const Decimal& stepBase, const Decimal& minimum, const Deci mal& maximum, const Decimal& step, const StepDescription& stepDescription) 54 StepRange::StepRange(const Decimal& stepBase, const Decimal& minimum, const Deci mal& maximum, bool hasRangeLimitations, const Decimal& step, const StepDescripti on& stepDescription)
53 : m_maximum(maximum) 55 : m_maximum(maximum)
54 , m_minimum(minimum) 56 , m_minimum(minimum)
55 , m_step(step.isFinite() ? step : 1) 57 , m_step(step.isFinite() ? step : 1)
56 , m_stepBase(stepBase.isFinite() ? stepBase : 1) 58 , m_stepBase(stepBase.isFinite() ? stepBase : 1)
57 , m_stepDescription(stepDescription) 59 , m_stepDescription(stepDescription)
58 , m_hasStep(step.isFinite()) 60 , m_hasStep(step.isFinite())
61 , m_hasRangeLimitations(hasRangeLimitations)
59 { 62 {
60 ASSERT(m_maximum.isFinite()); 63 ASSERT(m_maximum.isFinite());
61 ASSERT(m_minimum.isFinite()); 64 ASSERT(m_minimum.isFinite());
62 ASSERT(m_step.isFinite()); 65 ASSERT(m_step.isFinite());
63 ASSERT(m_stepBase.isFinite()); 66 ASSERT(m_stepBase.isFinite());
64 } 67 }
65 68
66 Decimal StepRange::acceptableError() const 69 Decimal StepRange::acceptableError() const
67 { 70 {
68 // FIXME: We should use DBL_MANT_DIG instead of FLT_MANT_DIG regarding to HT ML5 specification. 71 // FIXME: We should use DBL_MANT_DIG instead of FLT_MANT_DIG regarding to HT ML5 specification.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // ... that number subtracted from the step base is not an integral multiple 162 // ... that number subtracted from the step base is not an integral multiple
160 // of the allowed value step, the element is suffering from a step mismatch. 163 // of the allowed value step, the element is suffering from a step mismatch.
161 const Decimal remainder = (value - m_step * (value / m_step).round()).abs(); 164 const Decimal remainder = (value - m_step * (value / m_step).round()).abs();
162 // Accepts errors in lower fractional part which IEEE 754 single-precision 165 // Accepts errors in lower fractional part which IEEE 754 single-precision
163 // can't represent. 166 // can't represent.
164 const Decimal computedAcceptableError = acceptableError(); 167 const Decimal computedAcceptableError = acceptableError();
165 return computedAcceptableError < remainder && remainder < (m_step - computed AcceptableError); 168 return computedAcceptableError < remainder && remainder < (m_step - computed AcceptableError);
166 } 169 }
167 170
168 } // namespace blink 171 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/forms/StepRange.h ('k') | third_party/WebKit/Source/core/html/forms/StepRangeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698