Chromium Code Reviews| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 #include "core/html/HTMLInputElement.h" | 48 #include "core/html/HTMLInputElement.h" |
| 49 #include "core/html/InputTypeNames.h" | 49 #include "core/html/InputTypeNames.h" |
| 50 #include "core/html/StepRange.h" | 50 #include "core/html/StepRange.h" |
| 51 #include "core/html/parser/HTMLParserIdioms.h" | 51 #include "core/html/parser/HTMLParserIdioms.h" |
| 52 #include "core/html/shadow/SliderThumbElement.h" | 52 #include "core/html/shadow/SliderThumbElement.h" |
| 53 #include "core/platform/PlatformMouseEvent.h" | 53 #include "core/platform/PlatformMouseEvent.h" |
| 54 #include "core/rendering/RenderSlider.h" | 54 #include "core/rendering/RenderSlider.h" |
| 55 #include <wtf/MathExtras.h> | 55 #include <wtf/MathExtras.h> |
| 56 #include <wtf/PassOwnPtr.h> | 56 #include <wtf/PassOwnPtr.h> |
| 57 | 57 |
| 58 #if ENABLE(DATALIST_ELEMENT) | |
| 59 #include "core/html/HTMLDataListElement.h" | 58 #include "core/html/HTMLDataListElement.h" |
|
tkent
2013/05/20 21:32:11
Please merge these #include to the above block.
| |
| 60 #include "core/html/HTMLOptionElement.h" | 59 #include "core/html/HTMLOptionElement.h" |
| 61 #include <wtf/NonCopyingSort.h> | 60 #include <wtf/NonCopyingSort.h> |
| 62 #endif | |
| 63 | 61 |
| 64 namespace WebCore { | 62 namespace WebCore { |
| 65 | 63 |
| 66 using namespace HTMLNames; | 64 using namespace HTMLNames; |
| 67 using namespace std; | 65 using namespace std; |
| 68 | 66 |
| 69 static const int rangeDefaultMinimum = 0; | 67 static const int rangeDefaultMinimum = 0; |
| 70 static const int rangeDefaultMaximum = 100; | 68 static const int rangeDefaultMaximum = 100; |
| 71 static const int rangeDefaultStep = 1; | 69 static const int rangeDefaultStep = 1; |
| 72 static const int rangeDefaultStepBase = 0; | 70 static const int rangeDefaultStepBase = 0; |
| 73 static const int rangeStepScaleFactor = 1; | 71 static const int rangeStepScaleFactor = 1; |
| 74 | 72 |
| 75 static Decimal ensureMaximum(const Decimal& proposedValue, const Decimal& minimu m, const Decimal& fallbackValue) | 73 static Decimal ensureMaximum(const Decimal& proposedValue, const Decimal& minimu m, const Decimal& fallbackValue) |
| 76 { | 74 { |
| 77 return proposedValue >= minimum ? proposedValue : std::max(minimum, fallback Value); | 75 return proposedValue >= minimum ? proposedValue : std::max(minimum, fallback Value); |
| 78 } | 76 } |
| 79 | 77 |
| 80 PassOwnPtr<InputType> RangeInputType::create(HTMLInputElement* element) | 78 PassOwnPtr<InputType> RangeInputType::create(HTMLInputElement* element) |
| 81 { | 79 { |
| 82 return adoptPtr(new RangeInputType(element)); | 80 return adoptPtr(new RangeInputType(element)); |
| 83 } | 81 } |
| 84 | 82 |
| 85 RangeInputType::RangeInputType(HTMLInputElement* element) | 83 RangeInputType::RangeInputType(HTMLInputElement* element) |
| 86 : InputType(element) | 84 : InputType(element) |
| 87 #if ENABLE(DATALIST_ELEMENT) | |
| 88 , m_tickMarkValuesDirty(true) | 85 , m_tickMarkValuesDirty(true) |
| 89 #endif | |
| 90 { | 86 { |
| 91 } | 87 } |
| 92 | 88 |
| 93 void RangeInputType::attach() | 89 void RangeInputType::attach() |
| 94 { | 90 { |
| 95 observeFeatureIfVisible(UseCounter::InputTypeRange); | 91 observeFeatureIfVisible(UseCounter::InputTypeRange); |
| 96 } | 92 } |
| 97 | 93 |
| 98 bool RangeInputType::isRangeControl() const | 94 bool RangeInputType::isRangeControl() const |
| 99 { | 95 { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 HTMLElement* RangeInputType::sliderThumbElement() const | 321 HTMLElement* RangeInputType::sliderThumbElement() const |
| 326 { | 322 { |
| 327 return sliderThumbElementOf(element()); | 323 return sliderThumbElementOf(element()); |
| 328 } | 324 } |
| 329 | 325 |
| 330 HTMLElement* RangeInputType::sliderTrackElement() const | 326 HTMLElement* RangeInputType::sliderTrackElement() const |
| 331 { | 327 { |
| 332 return sliderTrackElementOf(element()); | 328 return sliderTrackElementOf(element()); |
| 333 } | 329 } |
| 334 | 330 |
| 335 #if ENABLE(DATALIST_ELEMENT) | |
| 336 void RangeInputType::listAttributeTargetChanged() | 331 void RangeInputType::listAttributeTargetChanged() |
| 337 { | 332 { |
| 338 m_tickMarkValuesDirty = true; | 333 m_tickMarkValuesDirty = true; |
| 339 HTMLElement* sliderTrackElement = sliderTrackElementOf(element()); | 334 HTMLElement* sliderTrackElement = sliderTrackElementOf(element()); |
| 340 if (sliderTrackElement->renderer()) | 335 if (sliderTrackElement->renderer()) |
| 341 sliderTrackElement->renderer()->setNeedsLayout(true); | 336 sliderTrackElement->renderer()->setNeedsLayout(true); |
| 342 } | 337 } |
| 343 | 338 |
| 344 static bool decimalCompare(const Decimal& a, const Decimal& b) | 339 static bool decimalCompare(const Decimal& a, const Decimal& b) |
| 345 { | 340 { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 left = middle; | 389 left = middle; |
| 395 else | 390 else |
| 396 right = middle; | 391 right = middle; |
| 397 } | 392 } |
| 398 const Decimal closestLeft = middle ? m_tickMarkValues[middle - 1] : Decimal: :infinity(Decimal::Negative); | 393 const Decimal closestLeft = middle ? m_tickMarkValues[middle - 1] : Decimal: :infinity(Decimal::Negative); |
| 399 const Decimal closestRight = middle != m_tickMarkValues.size() ? m_tickMarkV alues[middle] : Decimal::infinity(Decimal::Positive); | 394 const Decimal closestRight = middle != m_tickMarkValues.size() ? m_tickMarkV alues[middle] : Decimal::infinity(Decimal::Positive); |
| 400 if (closestRight - value < value - closestLeft) | 395 if (closestRight - value < value - closestLeft) |
| 401 return closestRight; | 396 return closestRight; |
| 402 return closestLeft; | 397 return closestLeft; |
| 403 } | 398 } |
| 404 #endif | |
| 405 | 399 |
| 406 } // namespace WebCore | 400 } // namespace WebCore |
| OLD | NEW |