Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1125)

Unified Diff: Source/core/html/HTMLTextAreaElement.cpp

Issue 543403003: Improve <textarea> validation performance. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLTextAreaElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLTextAreaElement.cpp
diff --git a/Source/core/html/HTMLTextAreaElement.cpp b/Source/core/html/HTMLTextAreaElement.cpp
index aee74dfd44c484d1eb9d6286225aeba93da99afc..fa9670b60852232e2fbd8f85406abf555dcd9bc9 100644
--- a/Source/core/html/HTMLTextAreaElement.cpp
+++ b/Source/core/html/HTMLTextAreaElement.cpp
@@ -490,15 +490,22 @@ String HTMLTextAreaElement::validationMessage() const
bool HTMLTextAreaElement::valueMissing() const
{
- return willValidate() && valueMissing(value());
+ // We should not call value() for performance.
+ return willValidate() && valueMissing(0);
+}
+
+bool HTMLTextAreaElement::valueMissing(const String* value) const
+{
+ return isRequiredFormControl() && !isDisabledOrReadOnly() && (value ? *value : this->value()).isEmpty();
}
bool HTMLTextAreaElement::tooLong() const
{
- return willValidate() && tooLong(value(), CheckDirtyFlag);
+ // We should not call value() for performance.
+ return willValidate() && tooLong(0, CheckDirtyFlag);
}
-bool HTMLTextAreaElement::tooLong(const String& value, NeedsToCheckDirtyFlag check) const
+bool HTMLTextAreaElement::tooLong(const String* value, NeedsToCheckDirtyFlag check) const
{
// Return false for the default value or value set by script even if it is
// longer than maxLength.
@@ -508,12 +515,12 @@ bool HTMLTextAreaElement::tooLong(const String& value, NeedsToCheckDirtyFlag che
int max = maxLength();
if (max < 0)
return false;
- return computeLengthForSubmission(value) > static_cast<unsigned>(max);
+ return computeLengthForSubmission(value ? *value : this->value()) > static_cast<unsigned>(max);
}
bool HTMLTextAreaElement::isValidValue(const String& candidate) const
{
- return !valueMissing(candidate) && !tooLong(candidate, IgnoreDirtyFlag);
+ return !valueMissing(&candidate) && !tooLong(&candidate, IgnoreDirtyFlag);
}
void HTMLTextAreaElement::accessKeyAction(bool)
« no previous file with comments | « Source/core/html/HTMLTextAreaElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698