| OLD | NEW |
| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #include "core/rendering/RenderSlider.h" | 54 #include "core/rendering/RenderSlider.h" |
| 55 #include "platform/PlatformMouseEvent.h" | 55 #include "platform/PlatformMouseEvent.h" |
| 56 #include "wtf/MathExtras.h" | 56 #include "wtf/MathExtras.h" |
| 57 #include "wtf/NonCopyingSort.h" | 57 #include "wtf/NonCopyingSort.h" |
| 58 #include "wtf/PassOwnPtr.h" | 58 #include "wtf/PassOwnPtr.h" |
| 59 #include <limits> | 59 #include <limits> |
| 60 | 60 |
| 61 namespace WebCore { | 61 namespace WebCore { |
| 62 | 62 |
| 63 using namespace HTMLNames; | 63 using namespace HTMLNames; |
| 64 using namespace std; | |
| 65 | 64 |
| 66 static const int rangeDefaultMinimum = 0; | 65 static const int rangeDefaultMinimum = 0; |
| 67 static const int rangeDefaultMaximum = 100; | 66 static const int rangeDefaultMaximum = 100; |
| 68 static const int rangeDefaultStep = 1; | 67 static const int rangeDefaultStep = 1; |
| 69 static const int rangeDefaultStepBase = 0; | 68 static const int rangeDefaultStepBase = 0; |
| 70 static const int rangeStepScaleFactor = 1; | 69 static const int rangeStepScaleFactor = 1; |
| 71 | 70 |
| 72 static Decimal ensureMaximum(const Decimal& proposedValue, const Decimal& minimu
m, const Decimal& fallbackValue) | 71 static Decimal ensureMaximum(const Decimal& proposedValue, const Decimal& minimu
m, const Decimal& fallbackValue) |
| 73 { | 72 { |
| 74 return proposedValue >= minimum ? proposedValue : std::max(minimum, fallback
Value); | 73 return proposedValue >= minimum ? proposedValue : std::max(minimum, fallback
Value); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 185 |
| 187 const Decimal current = parseToNumberOrNaN(element().value()); | 186 const Decimal current = parseToNumberOrNaN(element().value()); |
| 188 ASSERT(current.isFinite()); | 187 ASSERT(current.isFinite()); |
| 189 | 188 |
| 190 StepRange stepRange(createStepRange(RejectAny)); | 189 StepRange stepRange(createStepRange(RejectAny)); |
| 191 | 190 |
| 192 | 191 |
| 193 // FIXME: We can't use stepUp() for the step value "any". So, we increase | 192 // FIXME: We can't use stepUp() for the step value "any". So, we increase |
| 194 // or decrease the value by 1/100 of the value range. Is it reasonable? | 193 // or decrease the value by 1/100 of the value range. Is it reasonable? |
| 195 const Decimal step = equalIgnoringCase(element().fastGetAttribute(stepAttr),
"any") ? (stepRange.maximum() - stepRange.minimum()) / 100 : stepRange.step(); | 194 const Decimal step = equalIgnoringCase(element().fastGetAttribute(stepAttr),
"any") ? (stepRange.maximum() - stepRange.minimum()) / 100 : stepRange.step(); |
| 196 const Decimal bigStep = max((stepRange.maximum() - stepRange.minimum()) / 10
, step); | 195 const Decimal bigStep = std::max((stepRange.maximum() - stepRange.minimum())
/ 10, step); |
| 197 | 196 |
| 198 bool isVertical = false; | 197 bool isVertical = false; |
| 199 if (element().renderer()) { | 198 if (element().renderer()) { |
| 200 ControlPart part = element().renderer()->style()->appearance(); | 199 ControlPart part = element().renderer()->style()->appearance(); |
| 201 isVertical = part == SliderVerticalPart; | 200 isVertical = part == SliderVerticalPart; |
| 202 } | 201 } |
| 203 | 202 |
| 204 Decimal newValue; | 203 Decimal newValue; |
| 205 if (key == "Up") | 204 if (key == "Up") |
| 206 newValue = current + step; | 205 newValue = current + step; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 right = middle; | 387 right = middle; |
| 389 } | 388 } |
| 390 const Decimal closestLeft = middle ? m_tickMarkValues[middle - 1] : Decimal:
:infinity(Decimal::Negative); | 389 const Decimal closestLeft = middle ? m_tickMarkValues[middle - 1] : Decimal:
:infinity(Decimal::Negative); |
| 391 const Decimal closestRight = middle != m_tickMarkValues.size() ? m_tickMarkV
alues[middle] : Decimal::infinity(Decimal::Positive); | 390 const Decimal closestRight = middle != m_tickMarkValues.size() ? m_tickMarkV
alues[middle] : Decimal::infinity(Decimal::Positive); |
| 392 if (closestRight - value < value - closestLeft) | 391 if (closestRight - value < value - closestLeft) |
| 393 return closestRight; | 392 return closestRight; |
| 394 return closestLeft; | 393 return closestLeft; |
| 395 } | 394 } |
| 396 | 395 |
| 397 } // namespace WebCore | 396 } // namespace WebCore |
| OLD | NEW |