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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 bool RangeInputType::hasTouchEventHandler() const | 190 bool RangeInputType::hasTouchEventHandler() const |
191 { | 191 { |
192 return true; | 192 return true; |
193 } | 193 } |
194 | 194 |
195 void RangeInputType::handleKeydownEvent(KeyboardEvent* event) | 195 void RangeInputType::handleKeydownEvent(KeyboardEvent* event) |
196 { | 196 { |
197 if (element().isDisabledOrReadOnly()) | 197 if (element().isDisabledOrReadOnly()) |
198 return; | 198 return; |
199 | 199 |
200 const String& key = event->keyIdentifier(); | 200 const String& key = event->key(); |
201 | 201 |
202 const Decimal current = parseToNumberOrNaN(element().value()); | 202 const Decimal current = parseToNumberOrNaN(element().value()); |
203 ASSERT(current.isFinite()); | 203 ASSERT(current.isFinite()); |
204 | 204 |
205 StepRange stepRange(createStepRange(RejectAny)); | 205 StepRange stepRange(createStepRange(RejectAny)); |
206 | 206 |
207 | 207 |
208 // FIXME: We can't use stepUp() for the step value "any". So, we increase | 208 // FIXME: We can't use stepUp() for the step value "any". So, we increase |
209 // or decrease the value by 1/100 of the value range. Is it reasonable? | 209 // or decrease the value by 1/100 of the value range. Is it reasonable? |
210 const Decimal step = equalIgnoringCase(element().fastGetAttribute(stepAttr),
"any") ? (stepRange.maximum() - stepRange.minimum()) / 100 : stepRange.step(); | 210 const Decimal step = equalIgnoringCase(element().fastGetAttribute(stepAttr),
"any") ? (stepRange.maximum() - stepRange.minimum()) / 100 : stepRange.step(); |
211 const Decimal bigStep = std::max((stepRange.maximum() - stepRange.minimum())
/ 10, step); | 211 const Decimal bigStep = std::max((stepRange.maximum() - stepRange.minimum())
/ 10, step); |
212 | 212 |
213 TextDirection dir = LTR; | 213 TextDirection dir = LTR; |
214 bool isVertical = false; | 214 bool isVertical = false; |
215 if (element().layoutObject()) { | 215 if (element().layoutObject()) { |
216 dir = computedTextDirection(); | 216 dir = computedTextDirection(); |
217 ControlPart part = element().layoutObject()->style()->appearance(); | 217 ControlPart part = element().layoutObject()->style()->appearance(); |
218 isVertical = part == SliderVerticalPart; | 218 isVertical = part == SliderVerticalPart; |
219 } | 219 } |
220 | 220 |
221 Decimal newValue; | 221 Decimal newValue; |
222 if (key == "Up") | 222 if (key == "ArrowUp") |
223 newValue = current + step; | 223 newValue = current + step; |
224 else if (key == "Down") | 224 else if (key == "ArrowDown") |
225 newValue = current - step; | 225 newValue = current - step; |
226 else if (key == "Left") | 226 else if (key == "ArrowLeft") |
227 newValue = (isVertical || dir == RTL) ? current + step : current - step; | 227 newValue = (isVertical || dir == RTL) ? current + step : current - step; |
228 else if (key == "Right") | 228 else if (key == "ArrowRight") |
229 newValue = (isVertical || dir == RTL) ? current - step : current + step; | 229 newValue = (isVertical || dir == RTL) ? current - step : current + step; |
230 else if (key == "PageUp") | 230 else if (key == "PageUp") |
231 newValue = current + bigStep; | 231 newValue = current + bigStep; |
232 else if (key == "PageDown") | 232 else if (key == "PageDown") |
233 newValue = current - bigStep; | 233 newValue = current - bigStep; |
234 else if (key == "Home") | 234 else if (key == "Home") |
235 newValue = isVertical ? stepRange.maximum() : stepRange.minimum(); | 235 newValue = isVertical ? stepRange.maximum() : stepRange.minimum(); |
236 else if (key == "End") | 236 else if (key == "End") |
237 newValue = isVertical ? stepRange.minimum() : stepRange.maximum(); | 237 newValue = isVertical ? stepRange.minimum() : stepRange.maximum(); |
238 else | 238 else |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 right = middle; | 416 right = middle; |
417 } | 417 } |
418 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); |
419 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); |
420 if (closestRight - value < value - closestLeft) | 420 if (closestRight - value < value - closestLeft) |
421 return closestRight; | 421 return closestRight; |
422 return closestLeft; | 422 return closestLeft; |
423 } | 423 } |
424 | 424 |
425 } // namespace blink | 425 } // namespace blink |
OLD | NEW |