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

Side by Side Diff: third_party/WebKit/Source/core/html/forms/RangeInputType.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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 StepRange RangeInputType::createStepRange(AnyStepHandling anyStepHandling) const 134 StepRange RangeInputType::createStepRange(AnyStepHandling anyStepHandling) const
135 { 135 {
136 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (rang eDefaultStep, rangeDefaultStepBase, rangeStepScaleFactor)); 136 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (rang eDefaultStep, rangeDefaultStepBase, rangeStepScaleFactor));
137 137
138 const Decimal stepBase = findStepBase(rangeDefaultStepBase); 138 const Decimal stepBase = findStepBase(rangeDefaultStepBase);
139 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), r angeDefaultMinimum); 139 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), r angeDefaultMinimum);
140 const Decimal maximum = ensureMaximum(parseToNumber(element().fastGetAttribu te(maxAttr), rangeDefaultMaximum), minimum, rangeDefaultMaximum); 140 const Decimal maximum = ensureMaximum(parseToNumber(element().fastGetAttribu te(maxAttr), rangeDefaultMaximum), minimum, rangeDefaultMaximum);
141 141
142 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 142 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
143 return StepRange(stepBase, minimum, maximum, step, stepDescription); 143 // Range type always has range limitations because it has default
144 // minimum/maximum.
145 // https://html.spec.whatwg.org/multipage/forms.html#range-state-(type=range ):concept-input-min-default
146 const bool hasRangeLimitations = true;
147 return StepRange(stepBase, minimum, maximum, hasRangeLimitations, step, step Description);
144 } 148 }
145 149
146 bool RangeInputType::isSteppable() const 150 bool RangeInputType::isSteppable() const
147 { 151 {
148 return true; 152 return true;
149 } 153 }
150 154
151 void RangeInputType::handleMouseDownEvent(MouseEvent* event) 155 void RangeInputType::handleMouseDownEvent(MouseEvent* event)
152 { 156 {
153 if (element().isDisabledOrReadOnly()) 157 if (element().isDisabledOrReadOnly())
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 right = middle; 416 right = middle;
413 } 417 }
414 const Decimal closestLeft = middle ? m_tickMarkValues[middle - 1] : Decimal: :infinity(Decimal::Negative); 418 const Decimal closestLeft = middle ? m_tickMarkValues[middle - 1] : Decimal: :infinity(Decimal::Negative);
415 const Decimal closestRight = middle != m_tickMarkValues.size() ? m_tickMarkV alues[middle] : Decimal::infinity(Decimal::Positive); 419 const Decimal closestRight = middle != m_tickMarkValues.size() ? m_tickMarkV alues[middle] : Decimal::infinity(Decimal::Positive);
416 if (closestRight - value < value - closestLeft) 420 if (closestRight - value < value - closestLeft)
417 return closestRight; 421 return closestRight;
418 return closestLeft; 422 return closestLeft;
419 } 423 }
420 424
421 } // namespace blink 425 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/forms/InputType.cpp ('k') | third_party/WebKit/Source/core/html/forms/StepRange.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698