[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

tkent at chromium.org tkent at chromium.org
Wed Dec 22 11:25:47 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a0c6424efc75e484bd226573e0b5c00d58e5ff43
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jul 23 02:29:32 2010 +0000

    maxLength should not be applied to non-text types
    https://bugs.webkit.org/show_bug.cgi?id=42814
    
    Reviewed by Darin Adler.
    
    WebCore:
    
    According to the HTML5 specification, maxLength attribute should
    be applied to text, search, url, tel, email, and password types.
    
    Test: fast/forms/input-maxlength-unsupported.html
    
    * dom/InputElement.cpp:
    (WebCore::InputElement::handleBeforeTextInsertedEvent):
     Apply maxLength() only if supportsMaxLength() is true.
    * dom/InputElement.h:
    * html/HTMLInputElement.cpp:
    (WebCore::HTMLInputElement::patternMismatch):
     Code cleanup by isTextType().
    (WebCore::HTMLInputElement::tooLong):
     ditto.
    (WebCore::HTMLInputElement::isTextType):
     Added. This returns true for types with maxLength/pattern/placeholder.
    * html/HTMLInputElement.h:
    (WebCore::HTMLInputElement::supportsMaxLength):
     Added. Just calls isTextType().
    (WebCore::HTMLInputElement::supportsPlaceholder):
     Code cleanup by isTextType().
    * wml/WMLInputElement.h:
    (WebCore::WMLInputElement::supportsMaxLength):
     Added. Always returns true.
    
    LayoutTests:
    
    * fast/forms/input-maxlength-unsupported-expected.txt: Added.
    * fast/forms/input-maxlength-unsupported.html: Added.
    * fast/forms/script-tests/input-maxlength-unsupported.js: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63942 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index c11413d..0c8b320 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2010-07-22  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        maxLength should not be applied to non-text types
+        https://bugs.webkit.org/show_bug.cgi?id=42814
+
+        * fast/forms/input-maxlength-unsupported-expected.txt: Added.
+        * fast/forms/input-maxlength-unsupported.html: Added.
+        * fast/forms/script-tests/input-maxlength-unsupported.js: Added.
+
 2010-07-22  Cosmin Truta  <ctruta at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/forms/input-maxlength-unsupported-expected.txt b/LayoutTests/fast/forms/input-maxlength-unsupported-expected.txt
new file mode 100644
index 0000000..a60ae42
--- /dev/null
+++ b/LayoutTests/fast/forms/input-maxlength-unsupported-expected.txt
@@ -0,0 +1,10 @@
+A test for maxlength attribute of an input element with non-text type
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS input.value is "1234"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/input-maxlength-unsupported.html b/LayoutTests/fast/forms/input-maxlength-unsupported.html
new file mode 100644
index 0000000..f9835ab
--- /dev/null
+++ b/LayoutTests/fast/forms/input-maxlength-unsupported.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/input-maxlength-unsupported.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/script-tests/input-maxlength-unsupported.js b/LayoutTests/fast/forms/script-tests/input-maxlength-unsupported.js
new file mode 100644
index 0000000..31c9ebe
--- /dev/null
+++ b/LayoutTests/fast/forms/script-tests/input-maxlength-unsupported.js
@@ -0,0 +1,12 @@
+description('A test for maxlength attribute of an input element with non-text type');
+
+var input = document.createElement('input');
+input.maxLength = 2;
+input.type = 'number';
+document.body.appendChild(input);
+input.focus();
+document.execCommand('insertText', false, '1234');
+shouldBe('input.value', '"1234"');
+
+input.parentNode.removeChild(input);
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ed6c1b3..12690e9 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,35 @@
+2010-07-22  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        maxLength should not be applied to non-text types
+        https://bugs.webkit.org/show_bug.cgi?id=42814
+
+        According to the HTML5 specification, maxLength attribute should
+        be applied to text, search, url, tel, email, and password types.
+
+        Test: fast/forms/input-maxlength-unsupported.html
+
+        * dom/InputElement.cpp:
+        (WebCore::InputElement::handleBeforeTextInsertedEvent):
+         Apply maxLength() only if supportsMaxLength() is true.
+        * dom/InputElement.h:
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::patternMismatch):
+         Code cleanup by isTextType().
+        (WebCore::HTMLInputElement::tooLong):
+         ditto.
+        (WebCore::HTMLInputElement::isTextType):
+         Added. This returns true for types with maxLength/pattern/placeholder.
+        * html/HTMLInputElement.h:
+        (WebCore::HTMLInputElement::supportsMaxLength):
+         Added. Just calls isTextType().
+        (WebCore::HTMLInputElement::supportsPlaceholder):
+         Code cleanup by isTextType().
+        * wml/WMLInputElement.h:
+        (WebCore::WMLInputElement::supportsMaxLength):
+         Added. Always returns true.
+
 2010-07-22  Ryosuke Niwa  <rniwa at webkit.org>
 
         Reviewed by Kent Tamura.
diff --git a/WebCore/dom/InputElement.cpp b/WebCore/dom/InputElement.cpp
index ce98197..2a53b77 100644
--- a/WebCore/dom/InputElement.cpp
+++ b/WebCore/dom/InputElement.cpp
@@ -204,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.
diff --git a/WebCore/dom/InputElement.h b/WebCore/dom/InputElement.h
index 0f164f9..dc87b3d 100644
--- a/WebCore/dom/InputElement.h
+++ b/WebCore/dom/InputElement.h
@@ -43,6 +43,7 @@ public:
     virtual bool isPasswordField() const = 0;
     virtual bool isSearchField() const = 0;
     virtual bool isTextField() const = 0;
+    virtual bool supportsMaxLength() const = 0;
     virtual bool hasSpinButton() const { return false; }
 #if ENABLE(INPUT_SPEECH)
     virtual bool isSpeechEnabled() const = 0;
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index eca5035..a87bfa6 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -247,87 +247,34 @@ bool HTMLInputElement::valueMissing() const
 
 bool HTMLInputElement::patternMismatch() const
 {
-    switch (inputType()) {
-    case BUTTON:
-    case CHECKBOX:
-    case COLOR:
-    case DATE:
-    case DATETIME:
-    case DATETIMELOCAL:
-    case FILE:
-    case HIDDEN:
-    case IMAGE:
-    case ISINDEX:
-    case MONTH:
-    case NUMBER:
-    case RADIO:
-    case RANGE:
-    case RESET:
-    case SUBMIT:
-    case TIME:
-    case WEEK:
+    if (!isTextType())
         return false;
-    case EMAIL:
-    case PASSWORD:
-    case SEARCH:
-    case TELEPHONE:
-    case TEXT:
-    case URL:
-        const AtomicString& pattern = getAttribute(patternAttr);
-        String value = this->value();
-         // Empty values can't be mismatched
-        if (pattern.isEmpty() || value.isEmpty())
-            return false;
-        RegularExpression patternRegExp(pattern, TextCaseSensitive);
-        int matchLength = 0;
-        int valueLength = value.length();
-        int matchOffset = patternRegExp.match(value, 0, &matchLength);
-        return matchOffset || matchLength != valueLength;
-    }
-    ASSERT_NOT_REACHED();
-    return false;
+    const AtomicString& pattern = getAttribute(patternAttr);
+    String value = this->value();
+    // Empty values can't be mismatched
+    if (pattern.isEmpty() || value.isEmpty())
+        return false;
+    RegularExpression patternRegExp(pattern, TextCaseSensitive);
+    int matchLength = 0;
+    int valueLength = value.length();
+    int matchOffset = patternRegExp.match(value, 0, &matchLength);
+    return matchOffset || matchLength != valueLength;
 }
 
 bool HTMLInputElement::tooLong() const
 {
-    switch (inputType()) {
-    case EMAIL:
-    case PASSWORD:
-    case SEARCH:
-    case TELEPHONE:
-    case TEXT:
-    case URL: {
-        int max = maxLength();
-        if (max < 0)
-            return false;
-        // Return false for the default value even if it is longer than maxLength.
-        bool userEdited = !m_data.value().isNull();
-        if (!userEdited)
-            return false;
-        return numGraphemeClusters(value()) > static_cast<unsigned>(max);
-    }
-    case BUTTON:
-    case CHECKBOX:
-    case COLOR:
-    case DATE:
-    case DATETIME:
-    case DATETIMELOCAL:
-    case FILE:
-    case HIDDEN:
-    case IMAGE:
-    case ISINDEX:
-    case MONTH:
-    case NUMBER:
-    case RADIO:
-    case RANGE:
-    case RESET:
-    case SUBMIT:
-    case TIME:
-    case WEEK:
+    // We use isTextType() instead of supportsMaxLength() because of the
+    // 'virtual' overhead.
+    if (!isTextType())
         return false;
-    }
-    ASSERT_NOT_REACHED();
-    return false;
+    int max = maxLength();
+    if (max < 0)
+        return false;
+    // Return false for the default value even if it is longer than maxLength.
+    bool userEdited = !m_data.value().isNull();
+    if (!userEdited)
+        return false;
+    return numGraphemeClusters(value()) > static_cast<unsigned>(max);
 }
 
 bool HTMLInputElement::rangeUnderflow() const
@@ -1450,6 +1397,40 @@ bool HTMLInputElement::isTextField() const
     return false;
 }
 
+bool HTMLInputElement::isTextType() const
+{
+    switch (inputType()) {
+    case EMAIL:
+    case PASSWORD:
+    case SEARCH:
+    case TELEPHONE:
+    case TEXT:
+    case URL:
+        return true;
+    case BUTTON:
+    case CHECKBOX:
+    case COLOR:
+    case DATE:
+    case DATETIME:
+    case DATETIMELOCAL:
+    case FILE:
+    case HIDDEN:
+    case IMAGE:
+    case ISINDEX:
+    case MONTH:
+    case NUMBER:
+    case RADIO:
+    case RANGE:
+    case RESET:
+    case SUBMIT:
+    case TIME:
+    case WEEK:
+        return false;
+    }
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
 void HTMLInputElement::setChecked(bool nowChecked, bool sendChangeEvent)
 {
     if (checked() == nowChecked)
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index 3b9ba88..72ac589 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -290,7 +290,10 @@ private:
     void registerForActivationCallbackIfNeeded();
     void unregisterForActivationCallbackIfNeeded();
 
-    virtual bool supportsPlaceholder() const { return isTextField(); }
+    virtual bool supportsMaxLength() const { return isTextType(); }
+    bool isTextType() const;
+
+    virtual bool supportsPlaceholder() const { return isTextType() || inputType() == ISINDEX; }
     virtual bool isEmptyValue() const { return value().isEmpty(); }
     virtual void handleFocusEvent();
     virtual void handleBlurEvent();
diff --git a/WebCore/wml/WMLInputElement.h b/WebCore/wml/WMLInputElement.h
index b8748fd..fe1ae89 100644
--- a/WebCore/wml/WMLInputElement.h
+++ b/WebCore/wml/WMLInputElement.h
@@ -96,6 +96,7 @@ private:
     friend class WMLCardElement;
     void initialize();
 
+    virtual bool supportsMaxLength() const { return true; }
     String validateInputMask(const String&);
     unsigned cursorPositionToMaskIndex(unsigned);
     String constrainValue(const String&) const;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list