Index: Source/core/html/forms/BaseTextInputType.cpp |
diff --git a/Source/core/html/forms/BaseTextInputType.cpp b/Source/core/html/forms/BaseTextInputType.cpp |
index b7029e5b00e445f037b35b29e2b5baa701225656..9ee4ab54e517401cb94de4ff6f30f0ff78f1f01a 100644 |
--- a/Source/core/html/forms/BaseTextInputType.cpp |
+++ b/Source/core/html/forms/BaseTextInputType.cpp |
@@ -32,9 +32,23 @@ namespace blink { |
using namespace HTMLNames; |
-bool BaseTextInputType::isTextType() const |
+int BaseTextInputType::maxLength() const |
{ |
- return true; |
+ return element().maxLength(); |
+} |
+ |
+bool BaseTextInputType::tooLong(const String& value, HTMLTextFormControlElement::NeedsToCheckDirtyFlag check) const |
+{ |
+ int max = element().maxLength(); |
+ if (max < 0) |
+ return false; |
+ if (check == HTMLTextFormControlElement::CheckDirtyFlag) { |
+ // Return false for the default value or a value set by a script even if |
+ // it is longer than maxLength. |
+ if (!element().hasDirtyValue() || !element().lastChangeWasUserEdit()) |
+ return false; |
+ } |
+ return value.length() > static_cast<unsigned>(max); |
} |
bool BaseTextInputType::patternMismatch(const String& value) const |