Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: Source/core/html/forms/RangeInputType.cpp

Issue 488763002: Introduce HTMLDataListOptionsCollection subclass for HTMLCollection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 26 matching lines...) Expand all
37 #include "core/InputTypeNames.h" 37 #include "core/InputTypeNames.h"
38 #include "core/accessibility/AXObjectCache.h" 38 #include "core/accessibility/AXObjectCache.h"
39 #include "core/events/KeyboardEvent.h" 39 #include "core/events/KeyboardEvent.h"
40 #include "core/events/MouseEvent.h" 40 #include "core/events/MouseEvent.h"
41 #include "core/events/ScopedEventQueue.h" 41 #include "core/events/ScopedEventQueue.h"
42 #include "core/dom/Touch.h" 42 #include "core/dom/Touch.h"
43 #include "core/events/TouchEvent.h" 43 #include "core/events/TouchEvent.h"
44 #include "core/dom/TouchList.h" 44 #include "core/dom/TouchList.h"
45 #include "core/dom/shadow/ShadowRoot.h" 45 #include "core/dom/shadow/ShadowRoot.h"
46 #include "core/html/HTMLDataListElement.h" 46 #include "core/html/HTMLDataListElement.h"
47 #include "core/html/HTMLDataListOptionsCollection.h"
47 #include "core/html/HTMLDivElement.h" 48 #include "core/html/HTMLDivElement.h"
48 #include "core/html/HTMLInputElement.h" 49 #include "core/html/HTMLInputElement.h"
49 #include "core/html/HTMLOptionElement.h" 50 #include "core/html/HTMLOptionElement.h"
50 #include "core/html/forms/StepRange.h" 51 #include "core/html/forms/StepRange.h"
51 #include "core/html/parser/HTMLParserIdioms.h" 52 #include "core/html/parser/HTMLParserIdioms.h"
52 #include "core/html/shadow/ShadowElementNames.h" 53 #include "core/html/shadow/ShadowElementNames.h"
53 #include "core/html/shadow/SliderThumbElement.h" 54 #include "core/html/shadow/SliderThumbElement.h"
54 #include "core/rendering/RenderSlider.h" 55 #include "core/rendering/RenderSlider.h"
55 #include "platform/PlatformMouseEvent.h" 56 #include "platform/PlatformMouseEvent.h"
56 #include "wtf/MathExtras.h" 57 #include "wtf/MathExtras.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 340
340 void RangeInputType::updateTickMarkValues() 341 void RangeInputType::updateTickMarkValues()
341 { 342 {
342 if (!m_tickMarkValuesDirty) 343 if (!m_tickMarkValuesDirty)
343 return; 344 return;
344 m_tickMarkValues.clear(); 345 m_tickMarkValues.clear();
345 m_tickMarkValuesDirty = false; 346 m_tickMarkValuesDirty = false;
346 HTMLDataListElement* dataList = element().dataList(); 347 HTMLDataListElement* dataList = element().dataList();
347 if (!dataList) 348 if (!dataList)
348 return; 349 return;
349 RefPtrWillBeRawPtr<HTMLCollection> options = dataList->options(); 350 RefPtrWillBeRawPtr<HTMLDataListOptionsCollection> options = dataList->option s();
350 m_tickMarkValues.reserveCapacity(options->length()); 351 m_tickMarkValues.reserveCapacity(options->length());
351 for (unsigned i = 0; i < options->length(); ++i) { 352 for (unsigned i = 0; i < options->length(); ++i) {
352 Element* element = options->item(i); 353 HTMLOptionElement* optionElement = options->item(i);
353 HTMLOptionElement* optionElement = toHTMLOptionElement(element);
354 String optionValue = optionElement->value(); 354 String optionValue = optionElement->value();
355 if (!this->element().isValidValue(optionValue)) 355 if (!this->element().isValidValue(optionValue))
356 continue; 356 continue;
357 m_tickMarkValues.append(parseToNumber(optionValue, Decimal::nan())); 357 m_tickMarkValues.append(parseToNumber(optionValue, Decimal::nan()));
358 } 358 }
359 m_tickMarkValues.shrinkToFit(); 359 m_tickMarkValues.shrinkToFit();
360 nonCopyingSort(m_tickMarkValues.begin(), m_tickMarkValues.end(), decimalComp are); 360 nonCopyingSort(m_tickMarkValues.begin(), m_tickMarkValues.end(), decimalComp are);
361 } 361 }
362 362
363 Decimal RangeInputType::findClosestTickMarkValue(const Decimal& value) 363 Decimal RangeInputType::findClosestTickMarkValue(const Decimal& value)
(...skipping 23 matching lines...) Expand all
387 right = middle; 387 right = middle;
388 } 388 }
389 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);
390 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);
391 if (closestRight - value < value - closestLeft) 391 if (closestRight - value < value - closestLeft)
392 return closestRight; 392 return closestRight;
393 return closestLeft; 393 return closestLeft;
394 } 394 }
395 395
396 } // namespace blink 396 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698