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

Unified Diff: third_party/WebKit/Source/core/html/HTMLInputElement.cpp

Issue 1615003002: Fix behavior of HTMLInputElement.maxLength/minLength getter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set to -1 for invalid attribute or negative Created 4 years, 10 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
Index: third_party/WebKit/Source/core/html/HTMLInputElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
index b516a88512ac7f75842d34bffa22692d14b3cb04..fcd36e4c43633421e0013b08ff347aedf3399e9b 100644
--- a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
@@ -103,7 +103,7 @@ HTMLInputElement::HTMLInputElement(Document& document, HTMLFormElement* form, bo
: HTMLTextFormControlElement(inputTag, document, form)
, m_size(defaultSize)
, m_maxLength(maximumLength)
- , m_minLength(0)
+ , m_minLength(-1)
, m_maxResults(-1)
, m_isChecked(false)
, m_reflectsCheckedAttribute(true)
@@ -1365,6 +1365,8 @@ const AtomicString& HTMLInputElement::alt() const
int HTMLInputElement::maxLength() const
{
+ if (!hasAttribute(maxlengthAttr))
+ return -1;
return m_maxLength;
}
@@ -1679,9 +1681,9 @@ void HTMLInputElement::updatePlaceholderText()
void HTMLInputElement::parseMaxLengthAttribute(const AtomicString& value)
{
int maxLength;
- if (!parseHTMLInteger(value, maxLength))
- maxLength = maximumLength;
- if (maxLength < 0 || maxLength > maximumLength)
+ if (!parseHTMLInteger(value, maxLength) || maxLength < 0)
+ maxLength = -1;
+ if (maxLength > maximumLength)
maxLength = maximumLength;
int oldMaxLength = m_maxLength;
m_maxLength = maxLength;
@@ -1693,10 +1695,8 @@ void HTMLInputElement::parseMaxLengthAttribute(const AtomicString& value)
void HTMLInputElement::parseMinLengthAttribute(const AtomicString& value)
{
int minLength;
- if (!parseHTMLInteger(value, minLength))
- minLength = 0;
- if (minLength < 0)
- minLength = 0;
+ if (!parseHTMLInteger(value, minLength) || minLength < 0)
+ minLength = -1;
m_minLength = minLength;
setNeedsValidityCheck();
}

Powered by Google App Engine
This is Rietveld 408576698