| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 PassOwnPtr<InputType> NumberInputType::create(HTMLInputElement* element) | 99 PassOwnPtr<InputType> NumberInputType::create(HTMLInputElement* element) |
| 100 { | 100 { |
| 101 return adoptPtr(new NumberInputType(element)); | 101 return adoptPtr(new NumberInputType(element)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 const AtomicString& NumberInputType::formControlType() const | 104 const AtomicString& NumberInputType::formControlType() const |
| 105 { | 105 { |
| 106 return InputTypeNames::number(); | 106 return InputTypeNames::number(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void NumberInputType::setValue(const String& sanitizedValue, bool valueChanged,
TextFieldEventBehavior eventBehavior) |
| 110 { |
| 111 if (!valueChanged && sanitizedValue.isEmpty() && !element()->innerTextValue(
).isEmpty()) |
| 112 updateInnerTextValue(); |
| 113 TextFieldInputType::setValue(sanitizedValue, valueChanged, eventBehavior); |
| 114 } |
| 115 |
| 109 double NumberInputType::valueAsDouble() const | 116 double NumberInputType::valueAsDouble() const |
| 110 { | 117 { |
| 111 return parseToDoubleForNumberType(element()->value()); | 118 return parseToDoubleForNumberType(element()->value()); |
| 112 } | 119 } |
| 113 | 120 |
| 114 void NumberInputType::setValueAsDouble(double newValue, TextFieldEventBehavior e
ventBehavior, ExceptionCode& ec) const | 121 void NumberInputType::setValueAsDouble(double newValue, TextFieldEventBehavior e
ventBehavior, ExceptionCode& ec) const |
| 115 { | 122 { |
| 116 // FIXME: We should use numeric_limits<double>::max for number input type. | 123 // FIXME: We should use numeric_limits<double>::max for number input type. |
| 117 const double floatMax = numeric_limits<float>::max(); | 124 const double floatMax = numeric_limits<float>::max(); |
| 118 if (newValue < -floatMax) { | 125 if (newValue < -floatMax) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 294 |
| 288 void NumberInputType::stepAttributeChanged() | 295 void NumberInputType::stepAttributeChanged() |
| 289 { | 296 { |
| 290 InputType::stepAttributeChanged(); | 297 InputType::stepAttributeChanged(); |
| 291 | 298 |
| 292 if (element()->renderer()) | 299 if (element()->renderer()) |
| 293 element()->renderer()->setNeedsLayoutAndPrefWidthsRecalc(); | 300 element()->renderer()->setNeedsLayoutAndPrefWidthsRecalc(); |
| 294 } | 301 } |
| 295 | 302 |
| 296 } // namespace WebCore | 303 } // namespace WebCore |
| OLD | NEW |