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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 | 346 |
347 void RangeInputType::updateTickMarkValues() | 347 void RangeInputType::updateTickMarkValues() |
348 { | 348 { |
349 if (!m_tickMarkValuesDirty) | 349 if (!m_tickMarkValuesDirty) |
350 return; | 350 return; |
351 m_tickMarkValues.clear(); | 351 m_tickMarkValues.clear(); |
352 m_tickMarkValuesDirty = false; | 352 m_tickMarkValuesDirty = false; |
353 HTMLDataListElement* dataList = element().dataList(); | 353 HTMLDataListElement* dataList = element().dataList(); |
354 if (!dataList) | 354 if (!dataList) |
355 return; | 355 return; |
356 RefPtr<HTMLCollection> options = dataList->options(); | 356 RefPtrWillBeRawPtr<HTMLCollection> options = dataList->options(); |
357 m_tickMarkValues.reserveCapacity(options->length()); | 357 m_tickMarkValues.reserveCapacity(options->length()); |
358 for (unsigned i = 0; i < options->length(); ++i) { | 358 for (unsigned i = 0; i < options->length(); ++i) { |
359 Element* element = options->item(i); | 359 Element* element = options->item(i); |
360 HTMLOptionElement* optionElement = toHTMLOptionElement(element); | 360 HTMLOptionElement* optionElement = toHTMLOptionElement(element); |
361 String optionValue = optionElement->value(); | 361 String optionValue = optionElement->value(); |
362 if (!this->element().isValidValue(optionValue)) | 362 if (!this->element().isValidValue(optionValue)) |
363 continue; | 363 continue; |
364 m_tickMarkValues.append(parseToNumber(optionValue, Decimal::nan())); | 364 m_tickMarkValues.append(parseToNumber(optionValue, Decimal::nan())); |
365 } | 365 } |
366 m_tickMarkValues.shrinkToFit(); | 366 m_tickMarkValues.shrinkToFit(); |
(...skipping 27 matching lines...) Expand all Loading... |
394 right = middle; | 394 right = middle; |
395 } | 395 } |
396 const Decimal closestLeft = middle ? m_tickMarkValues[middle - 1] : Decimal:
:infinity(Decimal::Negative); | 396 const Decimal closestLeft = middle ? m_tickMarkValues[middle - 1] : Decimal:
:infinity(Decimal::Negative); |
397 const Decimal closestRight = middle != m_tickMarkValues.size() ? m_tickMarkV
alues[middle] : Decimal::infinity(Decimal::Positive); | 397 const Decimal closestRight = middle != m_tickMarkValues.size() ? m_tickMarkV
alues[middle] : Decimal::infinity(Decimal::Positive); |
398 if (closestRight - value < value - closestLeft) | 398 if (closestRight - value < value - closestLeft) |
399 return closestRight; | 399 return closestRight; |
400 return closestLeft; | 400 return closestLeft; |
401 } | 401 } |
402 | 402 |
403 } // namespace WebCore | 403 } // namespace WebCore |
OLD | NEW |