#include "core/html/forms/RangeInputType.h"
#include "HTMLNames.h"
+#include "InputTypeNames.h"
#include "bindings/v8/ExceptionStatePlaceholder.h"
#include "core/accessibility/AXObjectCache.h"
#include "core/events/KeyboardEvent.h"
#include "core/html/HTMLDivElement.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/HTMLOptionElement.h"
-#include "core/html/forms/InputTypeNames.h"
#include "core/html/forms/StepRange.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/html/shadow/ShadowElementNames.h"
const AtomicString& RangeInputType::formControlType() const
{
- return InputTypeNames::range();
+ return InputTypeNames::range;
}
double RangeInputType::valueAsDouble() const
return parseToDoubleForNumberType(element().value());
}
-void RangeInputType::setValueAsDecimal(const Decimal& newValue, TextFieldEventBehavior eventBehavior, ExceptionState&) const
+void RangeInputType::setValueAsDouble(double newValue, TextFieldEventBehavior eventBehavior, ExceptionState& exceptionState) const
{
- element().setValue(serialize(newValue), eventBehavior);
+ setValueAsDecimal(Decimal::fromDouble(newValue), eventBehavior, exceptionState);
}
bool RangeInputType::typeMismatchFor(const String& value) const
{
DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (rangeDefaultStep, rangeDefaultStepBase, rangeStepScaleFactor));
+ const Decimal stepBase = findStepBase(rangeDefaultStepBase);
const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), rangeDefaultMinimum);
const Decimal maximum = ensureMaximum(parseToNumber(element().fastGetAttribute(maxAttr), rangeDefaultMaximum), minimum, rangeDefaultMaximum);
const AtomicString& precisionValue = element().fastGetAttribute(precisionAttr);
if (!precisionValue.isNull()) {
const Decimal step = equalIgnoringCase(precisionValue, "float") ? Decimal::nan() : 1;
- return StepRange(minimum, minimum, maximum, step, stepDescription);
+ return StepRange(stepBase, minimum, maximum, step, stepDescription);
}
const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
- return StepRange(minimum, minimum, maximum, step, stepDescription);
+ return StepRange(stepBase, minimum, maximum, step, stepDescription);
}
bool RangeInputType::isSteppable() const
return;
if (event->type() == EventTypeNames::touchend) {
+ element().dispatchFormControlChangeEvent();
event->setDefaultHandled();
return;
}
if (newValue != current) {
EventQueueScope scope;
- TextFieldEventBehavior eventBehavior = DispatchChangeEvent;
+ TextFieldEventBehavior eventBehavior = DispatchInputAndChangeEvent;
setValueAsDecimal(newValue, eventBehavior, IGNORE_EXCEPTION);
if (AXObjectCache* cache = element().document().existingAXObjectCache())
cache->postNotification(&element(), AXObjectCache::AXValueChanged, true);
- element().dispatchFormControlChangeEvent();
}
event->setDefaultHandled();
Document& document = element().document();
RefPtr<HTMLDivElement> track = HTMLDivElement::create(document);
- track->setPart(AtomicString("-webkit-slider-runnable-track", AtomicString::ConstructFromLiteral));
+ track->setShadowPseudoId(AtomicString("-webkit-slider-runnable-track", AtomicString::ConstructFromLiteral));
track->setAttribute(idAttr, ShadowElementNames::sliderTrack());
track->appendChild(SliderThumbElement::create(document));
RefPtr<HTMLElement> container = SliderContainerElement::create(document);
return serializeForNumberType(stepRange.clampValue(proposedNumericValue));
}
+void RangeInputType::disabledAttributeChanged()
+{
+ if (element().isDisabledFormControl())
+ sliderThumbElement()->stopDragging();
+}
+
bool RangeInputType::shouldRespectListAttribute()
{
- return InputType::themeSupportsDataListUI(this);
+ return true;
}
inline SliderThumbElement* RangeInputType::sliderThumbElement() const
RefPtr<HTMLCollection> options = dataList->options();
m_tickMarkValues.reserveCapacity(options->length());
for (unsigned i = 0; i < options->length(); ++i) {
- Node* node = options->item(i);
- HTMLOptionElement* optionElement = toHTMLOptionElement(node);
+ Element* element = options->item(i);
+ HTMLOptionElement* optionElement = toHTMLOptionElement(element);
String optionValue = optionElement->value();
- if (!element().isValidValue(optionValue))
+ if (!this->element().isValidValue(optionValue))
continue;
m_tickMarkValues.append(parseToNumber(optionValue, Decimal::nan()));
}