| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 183 |
| 184 // FIXME: We can't use stepUp() for the step value "any". So, we increase | 184 // FIXME: We can't use stepUp() for the step value "any". So, we increase |
| 185 // or decrease the value by 1/100 of the value range. Is it reasonable? | 185 // or decrease the value by 1/100 of the value range. Is it reasonable? |
| 186 const Decimal step = | 186 const Decimal step = |
| 187 equalIgnoringCase(element().fastGetAttribute(stepAttr), "any") | 187 equalIgnoringCase(element().fastGetAttribute(stepAttr), "any") |
| 188 ? (stepRange.maximum() - stepRange.minimum()) / 100 | 188 ? (stepRange.maximum() - stepRange.minimum()) / 100 |
| 189 : stepRange.step(); | 189 : stepRange.step(); |
| 190 const Decimal bigStep = | 190 const Decimal bigStep = |
| 191 std::max((stepRange.maximum() - stepRange.minimum()) / 10, step); | 191 std::max((stepRange.maximum() - stepRange.minimum()) / 10, step); |
| 192 | 192 |
| 193 TextDirection dir = LTR; | 193 TextDirection dir = TextDirection::Ltr; |
| 194 bool isVertical = false; | 194 bool isVertical = false; |
| 195 if (element().layoutObject()) { | 195 if (element().layoutObject()) { |
| 196 dir = computedTextDirection(); | 196 dir = computedTextDirection(); |
| 197 ControlPart part = element().layoutObject()->style()->appearance(); | 197 ControlPart part = element().layoutObject()->style()->appearance(); |
| 198 isVertical = part == SliderVerticalPart; | 198 isVertical = part == SliderVerticalPart; |
| 199 } | 199 } |
| 200 | 200 |
| 201 Decimal newValue; | 201 Decimal newValue; |
| 202 if (key == "ArrowUp") | 202 if (key == "ArrowUp") { |
| 203 newValue = current + step; | 203 newValue = current + step; |
| 204 else if (key == "ArrowDown") | 204 } else if (key == "ArrowDown") { |
| 205 newValue = current - step; | 205 newValue = current - step; |
| 206 else if (key == "ArrowLeft") | 206 } else if (key == "ArrowLeft") { |
| 207 newValue = (isVertical || dir == RTL) ? current + step : current - step; | 207 newValue = (isVertical || dir == TextDirection::Rtl) ? current + step |
| 208 else if (key == "ArrowRight") | 208 : current - step; |
| 209 newValue = (isVertical || dir == RTL) ? current - step : current + step; | 209 } else if (key == "ArrowRight") { |
| 210 else if (key == "PageUp") | 210 newValue = (isVertical || dir == TextDirection::Rtl) ? current - step |
| 211 : current + step; |
| 212 } else if (key == "PageUp") { |
| 211 newValue = current + bigStep; | 213 newValue = current + bigStep; |
| 212 else if (key == "PageDown") | 214 } else if (key == "PageDown") { |
| 213 newValue = current - bigStep; | 215 newValue = current - bigStep; |
| 214 else if (key == "Home") | 216 } else if (key == "Home") { |
| 215 newValue = isVertical ? stepRange.maximum() : stepRange.minimum(); | 217 newValue = isVertical ? stepRange.maximum() : stepRange.minimum(); |
| 216 else if (key == "End") | 218 } else if (key == "End") { |
| 217 newValue = isVertical ? stepRange.minimum() : stepRange.maximum(); | 219 newValue = isVertical ? stepRange.minimum() : stepRange.maximum(); |
| 218 else | 220 } else { |
| 219 return; // Did not match any key binding. | 221 return; // Did not match any key binding. |
| 222 } |
| 220 | 223 |
| 221 newValue = stepRange.clampValue(newValue); | 224 newValue = stepRange.clampValue(newValue); |
| 222 | 225 |
| 223 if (newValue != current) { | 226 if (newValue != current) { |
| 224 EventQueueScope scope; | 227 EventQueueScope scope; |
| 225 TextFieldEventBehavior eventBehavior = DispatchInputAndChangeEvent; | 228 TextFieldEventBehavior eventBehavior = DispatchInputAndChangeEvent; |
| 226 setValueAsDecimal(newValue, eventBehavior, IGNORE_EXCEPTION); | 229 setValueAsDecimal(newValue, eventBehavior, IGNORE_EXCEPTION); |
| 227 | 230 |
| 228 if (AXObjectCache* cache = element().document().existingAXObjectCache()) | 231 if (AXObjectCache* cache = element().document().existingAXObjectCache()) |
| 229 cache->handleValueChanged(&element()); | 232 cache->handleValueChanged(&element()); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 : Decimal::infinity(Decimal::Negative); | 404 : Decimal::infinity(Decimal::Negative); |
| 402 const Decimal closestRight = middle != m_tickMarkValues.size() | 405 const Decimal closestRight = middle != m_tickMarkValues.size() |
| 403 ? m_tickMarkValues[middle] | 406 ? m_tickMarkValues[middle] |
| 404 : Decimal::infinity(Decimal::Positive); | 407 : Decimal::infinity(Decimal::Positive); |
| 405 if (closestRight - value < value - closestLeft) | 408 if (closestRight - value < value - closestLeft) |
| 406 return closestRight; | 409 return closestRight; |
| 407 return closestLeft; | 410 return closestLeft; |
| 408 } | 411 } |
| 409 | 412 |
| 410 } // namespace blink | 413 } // namespace blink |
| OLD | NEW |