diff options
Diffstat (limited to 'WebCore/dom/InputElement.cpp')
-rw-r--r-- | WebCore/dom/InputElement.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/WebCore/dom/InputElement.cpp b/WebCore/dom/InputElement.cpp index 079dd56..2a53b77 100644 --- a/WebCore/dom/InputElement.cpp +++ b/WebCore/dom/InputElement.cpp @@ -145,20 +145,7 @@ void InputElement::setValueFromRenderer(InputElementData& data, InputElement* in notifyFormStateChanged(element); } -String InputElement::sanitizeValue(const InputElement* inputElement, const String& proposedValue) -{ -#if ENABLE(WCSS) - InputElementData data = const_cast<InputElement*>(inputElement)->data(); - if (!isConformToInputMask(data, proposedValue)) { - if (isConformToInputMask(data, data.value())) - return data.value(); - return String(); - } -#endif - return InputElement::sanitizeUserInputValue(inputElement, proposedValue, s_maximumLength); -} - -String InputElement::sanitizeUserInputValue(const InputElement* inputElement, const String& proposedValue, int maxLength) +static String replaceEOLAndLimitLength(const InputElement* inputElement, const String& proposedValue, int maxLength) { if (!inputElement->isTextField()) return proposedValue; @@ -179,6 +166,24 @@ String InputElement::sanitizeUserInputValue(const InputElement* inputElement, co return string.left(newLength); } +String InputElement::sanitizeValueForTextField(const InputElement* inputElement, const String& proposedValue) +{ +#if ENABLE(WCSS) + InputElementData data = const_cast<InputElement*>(inputElement)->data(); + if (!isConformToInputMask(data, proposedValue)) { + if (isConformToInputMask(data, data.value())) + return data.value(); + return String(); + } +#endif + return replaceEOLAndLimitLength(inputElement, proposedValue, s_maximumLength); +} + +String InputElement::sanitizeUserInputValue(const InputElement* inputElement, const String& proposedValue, int maxLength) +{ + return replaceEOLAndLimitLength(inputElement, proposedValue, maxLength); +} + void InputElement::handleBeforeTextInsertedEvent(InputElementData& data, InputElement* inputElement, Element* element, Event* event) { ASSERT(event->isBeforeTextInsertedEvent()); @@ -199,7 +204,7 @@ void InputElement::handleBeforeTextInsertedEvent(InputElementData& data, InputEl // Selected characters will be removed by the next text event. unsigned baseLength = oldLength - selectionLength; - unsigned maxLength = static_cast<unsigned>(data.maxLength()); // maxLength() can never be negative. + unsigned maxLength = static_cast<unsigned>(inputElement->supportsMaxLength() ? data.maxLength() : s_maximumLength); // maxLength() can never be negative. unsigned appendableLength = maxLength > baseLength ? maxLength - baseLength : 0; // Truncate the inserted text to avoid violating the maxLength and other constraints. @@ -245,7 +250,7 @@ void InputElement::parseMaxLengthAttribute(InputElementData& data, InputElement* void InputElement::updateValueIfNeeded(InputElementData& data, InputElement* inputElement) { String oldValue = data.value(); - String newValue = sanitizeValue(inputElement, oldValue); + String newValue = inputElement->sanitizeValue(oldValue); if (newValue != oldValue) inputElement->setValue(newValue); } |