#include "config.h"
#include "core/html/forms/NumberInputType.h"
-#include <limits>
#include "HTMLNames.h"
+#include "InputTypeNames.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "core/events/KeyboardEvent.h"
#include "core/html/HTMLInputElement.h"
-#include "core/html/forms/InputTypeNames.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/rendering/RenderTextControl.h"
#include "platform/text/PlatformLocale.h"
#include "wtf/MathExtras.h"
#include "wtf/PassOwnPtr.h"
+#include <limits>
namespace WebCore {
-using WebKit::WebLocalizedString;
+using blink::WebLocalizedString;
using namespace HTMLNames;
using namespace std;
return RealNumberRenderSize(sizeOfSign + sizeOfZero , numberOfZeroAfterDecimalPoint + sizeOfDigits);
}
-PassRefPtr<InputType> NumberInputType::create(HTMLInputElement& element)
+PassRefPtrWillBeRawPtr<InputType> NumberInputType::create(HTMLInputElement& element)
{
- return adoptRef(new NumberInputType(element));
+ return adoptRefWillBeNoop(new NumberInputType(element));
}
void NumberInputType::countUsage()
const AtomicString& NumberInputType::formControlType() const
{
- return InputTypeNames::number();
+ return InputTypeNames::number;
}
void NumberInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior)
{
if (!valueChanged && sanitizedValue.isEmpty() && !element().innerTextValue().isEmpty())
- updateInnerTextValue();
+ element().updateView();
TextFieldInputType::setValue(sanitizedValue, valueChanged, eventBehavior);
}
return parseToDoubleForNumberType(element().value());
}
-void NumberInputType::setValueAsDouble(double newValue, TextFieldEventBehavior eventBehavior, ExceptionState& es) const
+void NumberInputType::setValueAsDouble(double newValue, TextFieldEventBehavior eventBehavior, ExceptionState& exceptionState) const
{
- // FIXME: We should use numeric_limits<double>::max for number input type.
- const double floatMax = numeric_limits<float>::max();
- if (newValue < -floatMax) {
- es.throwUninformativeAndGenericDOMException(InvalidStateError);
- return;
- }
- if (newValue > floatMax) {
- es.throwUninformativeAndGenericDOMException(InvalidStateError);
- return;
- }
element().setValue(serializeForNumberType(newValue), eventBehavior);
}
-void NumberInputType::setValueAsDecimal(const Decimal& newValue, TextFieldEventBehavior eventBehavior, ExceptionState& es) const
+void NumberInputType::setValueAsDecimal(const Decimal& newValue, TextFieldEventBehavior eventBehavior, ExceptionState& exceptionState) const
{
- // FIXME: We should use numeric_limits<double>::max for number input type.
- const Decimal floatMax = Decimal::fromDouble(numeric_limits<float>::max());
- if (newValue < -floatMax) {
- es.throwUninformativeAndGenericDOMException(InvalidStateError);
- return;
- }
- if (newValue > floatMax) {
- es.throwUninformativeAndGenericDOMException(InvalidStateError);
- return;
- }
element().setValue(serializeForNumberType(newValue), eventBehavior);
}
StepRange NumberInputType::createStepRange(AnyStepHandling anyStepHandling) const
{
DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (numberDefaultStep, numberDefaultStepBase, numberStepScaleFactor));
- const Decimal stepBase = parseToDecimalForNumberType(element().fastGetAttribute(minAttr), numberDefaultStepBase);
- // FIXME: We should use numeric_limits<double>::max for number input type.
- const Decimal floatMax = Decimal::fromDouble(numeric_limits<float>::max());
- const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), -floatMax);
- const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), floatMax);
- const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
- return StepRange(stepBase, minimum, maximum, step, stepDescription);
+ const Decimal doubleMax = Decimal::fromDouble(numeric_limits<double>::max());
+ return InputType::createStepRange(anyStepHandling, numberDefaultStepBase, -doubleMax, doubleMax, stepDescription);
}
bool NumberInputType::sizeShouldIncludeDecoration(int defaultSize, int& preferredSize) const
element().renderer()->setNeedsLayoutAndPrefWidthsRecalc();
}
+bool NumberInputType::supportsSelectionAPI() const
+{
+ return false;
+}
+
} // namespace WebCore