[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

tkent at chromium.org tkent at chromium.org
Wed Apr 7 23:41:49 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit fe6c71e00f276041cf780ce872b603e40ac3cb2c
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Nov 14 15:21:46 2009 +0000

    2009-11-14  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            Add tests for reading/writing .type property of HTMLInputElement.
            https://bugs.webkit.org/show_bug.cgi?id=29004
    
            * fast/forms/input-type-change3-expected.txt: Added.
            * fast/forms/input-type-change3.html: Added.
            * fast/forms/script-tests/input-type-change3.js: Added.
    
    2009-11-14  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            - Recognizes date/datetime/datetime-local/month/time/week types of INPUT element.
              They have no dedicated UI and no type validation for now.
            - Clean up setInputType() and formControlType() of HTMLInputElement.
            https://bugs.webkit.org/show_bug.cgi?id=29004
    
            Test: fast/forms/input-type-change3.html
    
            * html/HTMLInputElement.cpp:
            (WebCore::HTMLInputElement::valueMissing):
            (WebCore::HTMLInputElement::patternMismatch):
            (WebCore::HTMLInputElement::tooLong):
            (WebCore::createTypeMap): Initializer for a static local variable.
            (WebCore::HTMLInputElement::setInputType):
            (WebCore::createFormControlTypes): Initializer for a static local variable.
            (WebCore::HTMLInputElement::formControlType):
            (WebCore::HTMLInputElement::saveFormControlState):
            (WebCore::HTMLInputElement::restoreFormControlState):
            (WebCore::HTMLInputElement::accessKeyAction):
            (WebCore::HTMLInputElement::rendererIsNeeded):
            (WebCore::HTMLInputElement::createRenderer):
            (WebCore::HTMLInputElement::appendFormData):
            (WebCore::HTMLInputElement::isTextField):
            (WebCore::HTMLInputElement::valueWithDefault):
            (WebCore::HTMLInputElement::storesValueSeparateFromAttribute):
            (WebCore::HTMLInputElement::defaultEventHandler):
            (WebCore::HTMLInputElement::isRequiredFormControl):
            (WebCore::HTMLInputElement::dataList):
            * html/HTMLInputElement.h: Add new values to InputType enum, and define numberOfTypes.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50996 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6655e34..1f1b590 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2009-11-14  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Add tests for reading/writing .type property of HTMLInputElement.
+        https://bugs.webkit.org/show_bug.cgi?id=29004
+
+        * fast/forms/input-type-change3-expected.txt: Added.
+        * fast/forms/input-type-change3.html: Added.
+        * fast/forms/script-tests/input-type-change3.js: Added.
+
 2009-11-14  Gustavo Noronha Silva  <gustavo.noronha at collabora.co.uk>
 
         Skip new test that needs new DRT infrastructure, with bug filled.
diff --git a/LayoutTests/fast/forms/input-type-change3-expected.txt b/LayoutTests/fast/forms/input-type-change3-expected.txt
new file mode 100644
index 0000000..b3b5755
--- /dev/null
+++ b/LayoutTests/fast/forms/input-type-change3-expected.txt
@@ -0,0 +1,44 @@
+Tests for writing and reading .type property of HTMLInputElement.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS input.type is "text"
+PASS input.type for "file" is correctly "file".
+PASS input.type for "text" is correctly "text".
+PASS input.type for "TEXT" is correctly "text".
+PASS input.type for " text " is correctly "text".
+PASS input.type for "button" is correctly "button".
+PASS input.type for " button " is correctly "text".
+PASS input.type for "checkbox" is correctly "checkbox".
+PASS input.type for "color" is correctly "color".
+PASS input.type for "date" is correctly "date".
+PASS input.type for "datetime" is correctly "datetime".
+PASS input.type for "datetime-local" is correctly "datetime-local".
+PASS input.type for "datetimelocal" is correctly "text".
+PASS input.type for "datetime_local" is correctly "text".
+PASS input.type for "email" is correctly "email".
+PASS input.type for "file" is correctly "email".
+PASS input.type for "hidden" is correctly "hidden".
+PASS input.type for "image" is correctly "image".
+PASS input.type for "isindex" is correctly "text".
+PASS input.type for "khtml_isindex" is correctly "".
+PASS input.type for "month" is correctly "month".
+PASS input.type for "number" is correctly "number".
+PASS input.type for "password" is correctly "password".
+PASS input.type for "passwd" is correctly "text".
+PASS input.type for "radio" is correctly "radio".
+PASS input.type for "range" is correctly "range".
+PASS input.type for "reset" is correctly "reset".
+PASS input.type for "search" is correctly "search".
+PASS input.type for "submit" is correctly "submit".
+PASS input.type for "tel" is correctly "tel".
+PASS input.type for "telephone" is correctly "text".
+PASS input.type for "time" is correctly "time".
+PASS input.type for "url" is correctly "url".
+PASS input.type for "uri" is correctly "text".
+PASS input.type for "week" is correctly "week".
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/input-type-change3.html b/LayoutTests/fast/forms/input-type-change3.html
new file mode 100644
index 0000000..f19820f
--- /dev/null
+++ b/LayoutTests/fast/forms/input-type-change3.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-type-change3.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/script-tests/input-type-change3.js b/LayoutTests/fast/forms/script-tests/input-type-change3.js
new file mode 100644
index 0000000..fcce7fa
--- /dev/null
+++ b/LayoutTests/fast/forms/script-tests/input-type-change3.js
@@ -0,0 +1,56 @@
+description('Tests for writing and reading .type property of HTMLInputElement.');
+
+var input = document.createElement('input');
+document.body.appendChild(input);
+
+// The default type is "text".
+shouldBe('input.type', '"text"');
+
+function check(value, expected)
+{
+    input.type = value;
+    if (input.type == expected)
+        testPassed('input.type for "' + value + '" is correctly "' + input.type + '".');
+    else
+        testFailed('input.type for "' + value + '" is incorrectly "' + input.type + '", should be "' + expected + '".');
+}
+
+// The type is not specified explicitly.  We can change it to "file".
+check("file", "file");
+
+check("text", "text");
+check("TEXT", "text");  // input.type must return a lower case value according to DOM Level 2.
+check(" text ", "text");
+check("button", "button");
+check(" button ", "text");
+check("checkbox", "checkbox");
+check("color", "color");
+check("date", "date");
+check("datetime", "datetime");
+check("datetime-local", "datetime-local");
+check("datetimelocal", "text");
+check("datetime_local", "text");
+check("email", "email");
+check("file", "email"); // We can't change a concrete type to file for a security reason.
+check("hidden", "hidden");
+check("image", "image");
+check("isindex", "text");
+check("khtml_isindex", "");
+check("month", "month");
+check("number", "number");
+check("password", "password");
+check("passwd", "text");
+check("radio", "radio");
+check("range", "range");
+check("reset", "reset");
+check("search", "search");
+check("submit", "submit");
+check("tel", "tel");
+check("telephone", "text");
+check("time", "time");
+check("url", "url");
+check("uri", "text");
+check("week", "week");
+
+var successfullyParsed = true;
+
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 06f647d..9fa0915 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,37 @@
+2009-11-14  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        - Recognizes date/datetime/datetime-local/month/time/week types of INPUT element.
+          They have no dedicated UI and no type validation for now.
+        - Clean up setInputType() and formControlType() of HTMLInputElement.
+        https://bugs.webkit.org/show_bug.cgi?id=29004
+
+        Test: fast/forms/input-type-change3.html
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::valueMissing):
+        (WebCore::HTMLInputElement::patternMismatch):
+        (WebCore::HTMLInputElement::tooLong):
+        (WebCore::createTypeMap):
+        (WebCore::HTMLInputElement::setInputType):
+        (WebCore::createFormControlTypes):
+        (WebCore::HTMLInputElement::formControlType):
+        (WebCore::HTMLInputElement::saveFormControlState):
+        (WebCore::HTMLInputElement::restoreFormControlState):
+        (WebCore::HTMLInputElement::accessKeyAction):
+        (WebCore::HTMLInputElement::rendererIsNeeded):
+        (WebCore::HTMLInputElement::createRenderer):
+        (WebCore::HTMLInputElement::appendFormData):
+        (WebCore::HTMLInputElement::isTextField):
+        (WebCore::HTMLInputElement::valueWithDefault):
+        (WebCore::HTMLInputElement::storesValueSeparateFromAttribute):
+        (WebCore::HTMLInputElement::defaultEventHandler):
+        (WebCore::HTMLInputElement::isRequiredFormControl):
+        (WebCore::HTMLInputElement::dataList):
+        * html/HTMLInputElement.h:
+        (WebCore::HTMLInputElement::):
+
 2009-11-13  Chris Fleizach  <cfleizach at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index f25c908..e341d0e 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -59,7 +59,9 @@
 #include "RenderText.h"
 #include "RenderTextControlSingleLine.h"
 #include "RenderTheme.h"
+#include "StringHash.h"
 #include "TextEvent.h"
+#include <wtf/HashMap.h>
 #include <wtf/MathExtras.h>
 #include <wtf/StdLibExtras.h>
 
@@ -126,14 +128,20 @@ bool HTMLInputElement::valueMissing() const
         return false;
 
     switch (inputType()) {
-        case TEXT:
-        case SEARCH:
-        case URL:
-        case TELEPHONE:
+        case DATE:
+        case DATETIME:
+        case DATETIMELOCAL:
         case EMAIL:
-        case PASSWORD:
-        case NUMBER:
         case FILE:
+        case MONTH:
+        case NUMBER:
+        case PASSWORD:
+        case SEARCH:
+        case TELEPHONE:
+        case TEXT:
+        case TIME:
+        case URL:
+        case WEEK:
             return value().isEmpty();
         case CHECKBOX:
             return !checked();
@@ -141,13 +149,13 @@ bool HTMLInputElement::valueMissing() const
             return !document()->checkedRadioButtons().checkedButtonForGroup(name());
         case COLOR:
             return false;
+        case BUTTON:
         case HIDDEN:
-        case RANGE:
-        case SUBMIT:
         case IMAGE:
-        case RESET:
-        case BUTTON:
         case ISINDEX:
+        case RANGE:
+        case RESET:
+        case SUBMIT:
             break;
     }
 
@@ -158,25 +166,31 @@ bool HTMLInputElement::valueMissing() const
 bool HTMLInputElement::patternMismatch() const
 {
     switch (inputType()) {
-        case ISINDEX:
+        case BUTTON:
         case CHECKBOX:
-        case RADIO:
-        case SUBMIT:
-        case RESET:
+        case COLOR:
+        case DATE:
+        case DATETIME:
+        case DATETIMELOCAL:
         case FILE:
         case HIDDEN:
         case IMAGE:
-        case BUTTON:
-        case RANGE:
+        case ISINDEX:
+        case MONTH:
         case NUMBER:
-        case COLOR:
+        case RADIO:
+        case RANGE:
+        case RESET:
+        case SUBMIT:
+        case TIME:
+        case WEEK:
             return false;
-        case TEXT:
-        case SEARCH:
-        case URL:
-        case TELEPHONE:
         case EMAIL:
         case PASSWORD:
+        case SEARCH:
+        case TELEPHONE:
+        case TEXT:
+        case URL:
             const AtomicString& pattern = getAttribute(patternAttr);
             String value = this->value();
 
@@ -217,15 +231,21 @@ bool HTMLInputElement::tooLong() const
     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();
@@ -372,46 +392,41 @@ void HTMLInputElement::setType(const String& t)
         setAttribute(typeAttr, t);
 }
 
+typedef HashMap<String, HTMLInputElement::InputType, CaseFoldingHash> InputTypeMap;
+static const InputTypeMap* createTypeMap()
+{
+    InputTypeMap* map = new InputTypeMap;
+    map->add("button", HTMLInputElement::BUTTON);
+    map->add("checkbox", HTMLInputElement::CHECKBOX);
+    map->add("color", HTMLInputElement::COLOR);
+    map->add("date", HTMLInputElement::DATE);
+    map->add("datetime", HTMLInputElement::DATETIME);
+    map->add("datetime-local", HTMLInputElement::DATETIMELOCAL);
+    map->add("email", HTMLInputElement::EMAIL);
+    map->add("file", HTMLInputElement::FILE);
+    map->add("hidden", HTMLInputElement::HIDDEN);
+    map->add("image", HTMLInputElement::IMAGE);
+    map->add("khtml_isindex", HTMLInputElement::ISINDEX);
+    map->add("month", HTMLInputElement::MONTH);
+    map->add("number", HTMLInputElement::NUMBER);
+    map->add("password", HTMLInputElement::PASSWORD);
+    map->add("radio", HTMLInputElement::RADIO);
+    map->add("range", HTMLInputElement::RANGE);
+    map->add("reset", HTMLInputElement::RESET);
+    map->add("search", HTMLInputElement::SEARCH);
+    map->add("submit", HTMLInputElement::SUBMIT);
+    map->add("tel", HTMLInputElement::TELEPHONE);
+    map->add("time", HTMLInputElement::TIME);
+    map->add("url", HTMLInputElement::URL);
+    map->add("week", HTMLInputElement::WEEK);
+    // No need to register "text" because it is the default type.
+    return map;
+}
+
 void HTMLInputElement::setInputType(const String& t)
 {
-    InputType newType;
-    
-    if (equalIgnoringCase(t, "password"))
-        newType = PASSWORD;
-    else if (equalIgnoringCase(t, "checkbox"))
-        newType = CHECKBOX;
-    else if (equalIgnoringCase(t, "radio"))
-        newType = RADIO;
-    else if (equalIgnoringCase(t, "submit"))
-        newType = SUBMIT;
-    else if (equalIgnoringCase(t, "reset"))
-        newType = RESET;
-    else if (equalIgnoringCase(t, "file"))
-        newType = FILE;
-    else if (equalIgnoringCase(t, "hidden"))
-        newType = HIDDEN;
-    else if (equalIgnoringCase(t, "image"))
-        newType = IMAGE;
-    else if (equalIgnoringCase(t, "button"))
-        newType = BUTTON;
-    else if (equalIgnoringCase(t, "khtml_isindex"))
-        newType = ISINDEX;
-    else if (equalIgnoringCase(t, "search"))
-        newType = SEARCH;
-    else if (equalIgnoringCase(t, "range"))
-        newType = RANGE;
-    else if (equalIgnoringCase(t, "email"))
-        newType = EMAIL;
-    else if (equalIgnoringCase(t, "number"))
-        newType = NUMBER;
-    else if (equalIgnoringCase(t, "tel"))
-        newType = TELEPHONE;
-    else if (equalIgnoringCase(t, "url"))
-        newType = URL;
-    else if (equalIgnoringCase(t, "color"))
-        newType = COLOR;
-    else
-        newType = TEXT;
+    static const InputTypeMap* typeMap = createTypeMap();
+    InputType newType = t.isNull() ? TEXT : typeMap->get(t);
 
     // IMPORTANT: Don't allow the type to be changed to FILE after the first
     // type change, otherwise a JavaScript programmer would be able to set a text
@@ -482,82 +497,42 @@ void HTMLInputElement::setInputType(const String& t)
         m_imageLoader.clear();
 }
 
+static const AtomicString* createFormControlTypes()
+{
+    AtomicString* types = new AtomicString[HTMLInputElement::numberOfTypes];
+    // The values must be lowercased because they will be the return values of
+    //  input.type and it must be lowercase according to DOM Level 2.
+    types[HTMLInputElement::BUTTON] = "button";
+    types[HTMLInputElement::CHECKBOX] = "checkbox";
+    types[HTMLInputElement::COLOR] = "color";
+    types[HTMLInputElement::DATE] = "date";
+    types[HTMLInputElement::DATETIME] = "datetime";
+    types[HTMLInputElement::DATETIMELOCAL] = "datetime-local";
+    types[HTMLInputElement::EMAIL] = "email";
+    types[HTMLInputElement::FILE] = "file";
+    types[HTMLInputElement::HIDDEN] = "hidden";
+    types[HTMLInputElement::IMAGE] = "image";
+    types[HTMLInputElement::ISINDEX] = emptyAtom;
+    types[HTMLInputElement::MONTH] = "month";
+    types[HTMLInputElement::NUMBER] = "number";
+    types[HTMLInputElement::PASSWORD] = "password";
+    types[HTMLInputElement::RADIO] = "radio";
+    types[HTMLInputElement::RANGE] = "range";
+    types[HTMLInputElement::RESET] = "reset";
+    types[HTMLInputElement::SEARCH] = "search";
+    types[HTMLInputElement::SUBMIT] = "submit";
+    types[HTMLInputElement::TELEPHONE] = "tel";
+    types[HTMLInputElement::TEXT] = "text";
+    types[HTMLInputElement::TIME] = "time";
+    types[HTMLInputElement::URL] = "url";
+    types[HTMLInputElement::WEEK] = "week";
+    return types;
+}
+
 const AtomicString& HTMLInputElement::formControlType() const
 {
-    // needs to be lowercase according to DOM spec
-    switch (inputType()) {
-        case BUTTON: {
-            DEFINE_STATIC_LOCAL(const AtomicString, button, ("button"));
-            return button;
-        }
-        case CHECKBOX: {
-            DEFINE_STATIC_LOCAL(const AtomicString, checkbox, ("checkbox"));
-            return checkbox;
-        }
-        case COLOR: {
-            DEFINE_STATIC_LOCAL(const AtomicString, color, ("color"));
-            return color;
-        }
-        case EMAIL: {
-            DEFINE_STATIC_LOCAL(const AtomicString, email, ("email"));
-            return email;
-        }
-        case FILE: {
-            DEFINE_STATIC_LOCAL(const AtomicString, file, ("file"));
-            return file;
-        }
-        case HIDDEN: {
-            DEFINE_STATIC_LOCAL(const AtomicString, hidden, ("hidden"));
-            return hidden;
-        }
-        case IMAGE: {
-            DEFINE_STATIC_LOCAL(const AtomicString, image, ("image"));
-            return image;
-        }
-        case ISINDEX:
-            return emptyAtom;
-        case NUMBER: {
-            DEFINE_STATIC_LOCAL(const AtomicString, number, ("number"));
-            return number;
-        }
-        case PASSWORD: {
-            DEFINE_STATIC_LOCAL(const AtomicString, password, ("password"));
-            return password;
-        }
-        case RADIO: {
-            DEFINE_STATIC_LOCAL(const AtomicString, radio, ("radio"));
-            return radio;
-        }
-        case RANGE: {
-            DEFINE_STATIC_LOCAL(const AtomicString, range, ("range"));
-            return range;
-        }
-        case RESET: {
-            DEFINE_STATIC_LOCAL(const AtomicString, reset, ("reset"));
-            return reset;
-        }
-        case SEARCH: {
-            DEFINE_STATIC_LOCAL(const AtomicString, search, ("search"));
-            return search;
-        }
-        case SUBMIT: {
-            DEFINE_STATIC_LOCAL(const AtomicString, submit, ("submit"));
-            return submit;
-        }
-        case TELEPHONE: {
-            DEFINE_STATIC_LOCAL(const AtomicString, telephone, ("tel"));
-            return telephone;
-        }
-        case TEXT: {
-            DEFINE_STATIC_LOCAL(const AtomicString, text, ("text"));
-            return text;
-        }
-        case URL: {
-            DEFINE_STATIC_LOCAL(const AtomicString, url, ("url"));
-            return url;
-        }
-    }
-    return emptyAtom;
+    static const AtomicString* formControlTypes = createFormControlTypes();
+    return formControlTypes[inputType()];
 }
 
 bool HTMLInputElement::saveFormControlState(String& result) const
@@ -568,11 +543,15 @@ bool HTMLInputElement::saveFormControlState(String& result) const
     switch (inputType()) {
         case BUTTON:
         case COLOR:
+        case DATE:
+        case DATETIME:
+        case DATETIMELOCAL:
         case EMAIL:
         case FILE:
         case HIDDEN:
         case IMAGE:
         case ISINDEX:
+        case MONTH:
         case NUMBER:
         case RANGE:
         case RESET:
@@ -580,7 +559,9 @@ bool HTMLInputElement::saveFormControlState(String& result) const
         case SUBMIT:
         case TELEPHONE:
         case TEXT:
+        case TIME:
         case URL:
+        case WEEK:
             result = value();
             return true;
         case CHECKBOX:
@@ -600,11 +581,15 @@ void HTMLInputElement::restoreFormControlState(const String& state)
     switch (inputType()) {
         case BUTTON:
         case COLOR:
+        case DATE:
+        case DATETIME:
+        case DATETIMELOCAL:
         case EMAIL:
         case FILE:
         case HIDDEN:
         case IMAGE:
         case ISINDEX:
+        case MONTH:
         case NUMBER:
         case RANGE:
         case RESET:
@@ -612,7 +597,9 @@ void HTMLInputElement::restoreFormControlState(const String& state)
         case SUBMIT:
         case TELEPHONE:
         case TEXT:
+        case TIME:
         case URL:
+        case WEEK:
             setValue(state);
             break;
         case CHECKBOX:
@@ -655,14 +642,20 @@ void HTMLInputElement::accessKeyAction(bool sendToAnyElement)
             // a no-op for this type
             break;
         case COLOR:
+        case DATE:
+        case DATETIME:
+        case DATETIMELOCAL:
         case EMAIL:
         case ISINDEX:
+        case MONTH:
         case NUMBER:
         case PASSWORD:
         case SEARCH:
         case TELEPHONE:
         case TEXT:
+        case TIME:
         case URL:
+        case WEEK:
             // should never restore previous selection here
             focus(false);
             break;
@@ -789,30 +782,9 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr)
 
 bool HTMLInputElement::rendererIsNeeded(RenderStyle *style)
 {
-    switch (inputType()) {
-        case BUTTON:
-        case CHECKBOX:
-        case COLOR:
-        case EMAIL:
-        case FILE:
-        case IMAGE:
-        case ISINDEX:
-        case NUMBER:
-        case PASSWORD:
-        case RADIO:
-        case RANGE:
-        case RESET:
-        case SEARCH:
-        case SUBMIT:
-        case TELEPHONE:
-        case TEXT:
-        case URL:
-            return HTMLFormControlElementWithState::rendererIsNeeded(style);
-        case HIDDEN:
-            return false;
-    }
-    ASSERT(false);
-    return false;
+    if (inputType() == HIDDEN)
+        return false;
+    return HTMLFormControlElementWithState::rendererIsNeeded(style);
 }
 
 RenderObject *HTMLInputElement::createRenderer(RenderArena *arena, RenderStyle *style)
@@ -834,14 +806,20 @@ RenderObject *HTMLInputElement::createRenderer(RenderArena *arena, RenderStyle *
         case RANGE:
             return new (arena) RenderSlider(this);
         case COLOR:
+        case DATE:
+        case DATETIME:
+        case DATETIMELOCAL:
         case EMAIL:
         case ISINDEX:
+        case MONTH:
         case NUMBER:
         case PASSWORD:
         case SEARCH:
         case TELEPHONE:
         case TEXT:
+        case TIME:
         case URL:
+        case WEEK:
             return new (arena) RenderTextControlSingleLine(this, placeholderShouldBeVisible());
     }
     ASSERT(false);
@@ -921,16 +899,22 @@ bool HTMLInputElement::appendFormData(FormDataList& encoding, bool multipart)
 
     switch (inputType()) {
         case COLOR:
+        case DATE:
+        case DATETIME:
+        case DATETIMELOCAL:
         case EMAIL:
         case HIDDEN:
         case ISINDEX:
+        case MONTH:
         case NUMBER:
         case PASSWORD:
         case RANGE:
         case SEARCH:
         case TELEPHONE:
         case TEXT:
+        case TIME:
         case URL:
+        case WEEK:
             // always successful
             encoding.appendData(name(), value());
             return true;
@@ -1008,6 +992,40 @@ void HTMLInputElement::reset()
     m_useDefaultChecked = true;
 }
 
+bool HTMLInputElement::isTextField() const
+{
+    switch (inputType()) {
+    case COLOR:
+    case DATE:
+    case DATETIME:
+    case DATETIMELOCAL:
+    case EMAIL:
+    case ISINDEX:
+    case MONTH:
+    case NUMBER:
+    case PASSWORD:
+    case SEARCH:
+    case TELEPHONE:
+    case TEXT:
+    case TIME:
+    case URL:
+    case WEEK:
+        return true;
+    case BUTTON:
+    case CHECKBOX:
+    case FILE:
+    case HIDDEN:
+    case IMAGE:
+    case RADIO:
+    case RANGE:
+    case RESET:
+    case SUBMIT:
+        return false;
+    }
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
 void HTMLInputElement::setChecked(bool nowChecked, bool sendChangeEvent)
 {
     if (checked() == nowChecked)
@@ -1099,11 +1117,15 @@ String HTMLInputElement::valueWithDefault() const
             case BUTTON:
             case CHECKBOX:
             case COLOR:
+            case DATE:
+            case DATETIME:
+            case DATETIMELOCAL:
             case EMAIL:
             case FILE:
             case HIDDEN:
             case IMAGE:
             case ISINDEX:
+            case MONTH:
             case NUMBER:
             case PASSWORD:
             case RADIO:
@@ -1111,7 +1133,9 @@ String HTMLInputElement::valueWithDefault() const
             case SEARCH:
             case TELEPHONE:
             case TEXT:
+            case TIME:
             case URL:
+            case WEEK:
                 break;
             case RESET:
                 v = resetButtonDefaultLabel();
@@ -1209,16 +1233,22 @@ bool HTMLInputElement::storesValueSeparateFromAttribute() const
         case SUBMIT:
             return false;
         case COLOR:
+        case DATE:
+        case DATETIME:
+        case DATETIMELOCAL:
         case EMAIL:
         case FILE:
         case ISINDEX:
+        case MONTH:
         case NUMBER:
         case PASSWORD:
         case RANGE:
         case SEARCH:
         case TELEPHONE:
         case TEXT:
+        case TIME:
         case URL:
+        case WEEK:
             return true;
     }
     return false;
@@ -1385,16 +1415,22 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
             switch (inputType()) {
                 case CHECKBOX:
                 case COLOR:
+                case DATE:
+                case DATETIME:
+                case DATETIMELOCAL:
                 case EMAIL:
                 case HIDDEN:
                 case ISINDEX:
+                case MONTH:
                 case NUMBER:
                 case PASSWORD:
                 case RANGE:
                 case SEARCH:
                 case TELEPHONE:
                 case TEXT:
+                case TIME:
                 case URL:
+                case WEEK:
                     // Simulate mouse click on the default form button for enter for these types of elements.
                     clickDefaultFormButton = true;
                     break;
@@ -1513,16 +1549,22 @@ void HTMLInputElement::defaultEventHandler(Event* evt)
                         clickElement = true;
                     break;
                 case COLOR:
+                case DATE:
+                case DATETIME:
+                case DATETIMELOCAL:
                 case EMAIL:
                 case HIDDEN:
                 case ISINDEX:
+                case MONTH:
                 case NUMBER:
                 case PASSWORD:
                 case RANGE:
                 case SEARCH:
                 case TELEPHONE:
                 case TEXT:
+                case TIME:
                 case URL:
+                case WEEK:
                     break;
             }
         }
@@ -1753,25 +1795,31 @@ bool HTMLInputElement::isRequiredFormControl() const
         return false;
 
     switch (inputType()) {
-        case TEXT:
-        case SEARCH:
-        case URL:
-        case TELEPHONE:
+        case CHECKBOX:
+        case DATE:
+        case DATETIME:
+        case DATETIMELOCAL:
         case EMAIL:
-        case PASSWORD:
+        case FILE:
+        case MONTH:
         case NUMBER:
-        case CHECKBOX:
+        case PASSWORD:
         case RADIO:
-        case FILE:
+        case SEARCH:
+        case TELEPHONE:
+        case TEXT:
+        case TIME:
+        case URL:
+        case WEEK:
             return true;
-        case HIDDEN:
-        case RANGE:
-        case SUBMIT:
-        case IMAGE:
-        case RESET:
         case BUTTON:
         case COLOR:
+        case HIDDEN:
+        case IMAGE:
         case ISINDEX:
+        case RANGE:
+        case RESET:
+        case SUBMIT:
             return false;
     }
 
@@ -1873,29 +1921,35 @@ HTMLDataListElement* HTMLInputElement::dataList() const
         return 0;
 
     switch (inputType()) {
-    case TEXT:
-    case SEARCH:
-    case URL:
-    case TELEPHONE:
+    case COLOR:
+    case DATE:
+    case DATETIME:
+    case DATETIMELOCAL:
     case EMAIL:
+    case MONTH:
     case NUMBER:
     case RANGE:
-    case COLOR: {
+    case SEARCH:
+    case TELEPHONE:
+    case TEXT:
+    case TIME:
+    case URL:
+    case WEEK: {
         Element* element = document()->getElementById(getAttribute(listAttr));
         if (element && element->hasTagName(datalistTag))
             return static_cast<HTMLDataListElement*>(element);
         break;
     }
-    case HIDDEN:
-    case PASSWORD:
+    case BUTTON:
     case CHECKBOX:
-    case RADIO:
     case FILE:
-    case SUBMIT:
+    case HIDDEN:
     case IMAGE:
-    case RESET:
-    case BUTTON:
     case ISINDEX:
+    case PASSWORD:
+    case RADIO:
+    case RESET:
+    case SUBMIT:
         break;
     }
     return 0;
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index 0e2da32..71d21d6 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -40,7 +40,7 @@ class VisibleSelection;
 class HTMLInputElement : public HTMLTextFormControlElement, public InputElement {
 public:
     enum InputType {
-        TEXT,
+        TEXT = 0, // TEXT must be 0.
         PASSWORD,
         ISINDEX,
         CHECKBOX,
@@ -57,9 +57,17 @@ public:
         NUMBER,
         TELEPHONE,
         URL,
-        COLOR
+        COLOR,
+        DATE,
+        DATETIME,
+        DATETIMELOCAL,
+        MONTH,
+        TIME,
+        WEEK,
+        // If you add new types or change the order of enum values, update numberOfTypes below.
     };
-    
+    static const int numberOfTypes = WEEK + 1;
+
     enum AutoCompleteSetting {
         Uninitialized,
         On,
@@ -105,7 +113,7 @@ public:
 
     bool isTextButton() const { return m_type == SUBMIT || m_type == RESET || m_type == BUTTON; }
     virtual bool isRadioButton() const { return m_type == RADIO; }
-    virtual bool isTextField() const { return m_type == TEXT || m_type == PASSWORD || m_type == SEARCH || m_type == ISINDEX || m_type == EMAIL || m_type == NUMBER || m_type == TELEPHONE || m_type == URL || m_type == COLOR; }
+    virtual bool isTextField() const;
     virtual bool isSearchField() const { return m_type == SEARCH; }
     virtual bool isInputTypeHidden() const { return m_type == HIDDEN; }
     virtual bool isPasswordField() const { return m_type == PASSWORD; }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list