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 = TextDirection::Ltr; | 193 TextDirection dir = TextDirection::kLtr; |
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 == TextDirection::Rtl) ? current + step | 207 newValue = (isVertical || dir == TextDirection::kRtl) ? current + step |
208 : current - step; | 208 : current - step; |
209 } else if (key == "ArrowRight") { | 209 } else if (key == "ArrowRight") { |
210 newValue = (isVertical || dir == TextDirection::Rtl) ? current - step | 210 newValue = (isVertical || dir == TextDirection::kRtl) ? current - step |
211 : current + step; | 211 : current + step; |
212 } else if (key == "PageUp") { | 212 } else if (key == "PageUp") { |
213 newValue = current + bigStep; | 213 newValue = current + bigStep; |
214 } else if (key == "PageDown") { | 214 } else if (key == "PageDown") { |
215 newValue = current - bigStep; | 215 newValue = current - bigStep; |
216 } else if (key == "Home") { | 216 } else if (key == "Home") { |
217 newValue = isVertical ? stepRange.maximum() : stepRange.minimum(); | 217 newValue = isVertical ? stepRange.maximum() : stepRange.minimum(); |
218 } else if (key == "End") { | 218 } else if (key == "End") { |
219 newValue = isVertical ? stepRange.minimum() : stepRange.maximum(); | 219 newValue = isVertical ? stepRange.minimum() : stepRange.maximum(); |
220 } else { | 220 } else { |
221 return; // Did not match any key binding. | 221 return; // Did not match any key binding. |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 : Decimal::infinity(Decimal::Negative); | 404 : Decimal::infinity(Decimal::Negative); |
405 const Decimal closestRight = middle != m_tickMarkValues.size() | 405 const Decimal closestRight = middle != m_tickMarkValues.size() |
406 ? m_tickMarkValues[middle] | 406 ? m_tickMarkValues[middle] |
407 : Decimal::infinity(Decimal::Positive); | 407 : Decimal::infinity(Decimal::Positive); |
408 if (closestRight - value < value - closestLeft) | 408 if (closestRight - value < value - closestLeft) |
409 return closestRight; | 409 return closestRight; |
410 return closestLeft; | 410 return closestLeft; |
411 } | 411 } |
412 | 412 |
413 } // namespace blink | 413 } // namespace blink |
OLD | NEW |