2008-11-24 Glenn Wilson <gwilson@chromium.org>
authordarin@chromium.org <darin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Nov 2008 21:40:25 +0000 (21:40 +0000)
committerdarin@chromium.org <darin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Nov 2008 21:40:25 +0000 (21:40 +0000)
        Reviewed by Darin Adler.

        http://bugs.webkit.org/show_bug.cgi?id=18703
        "Changing the 'size' property on a text input does not affect its length"

        Text fields would not repaint themselves after having their "size"
        attributes modified.  This fix tells the object to recalculate its
        width and repaint itself when its "size" attribute is parsed.

        Test: fast/js/text-field-resize.html

        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::parseMappedAttribute):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@38722 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/js/text-field-resize-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/text-field-resize.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLInputElement.cpp

index 7f824d3..851b6e4 100644 (file)
@@ -1,3 +1,16 @@
+2008-11-24  Glenn Wilson  <gwilson@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        http://bugs.webkit.org/show_bug.cgi?id=18703
+        "Changing the 'size' property on a text input does not affect its length"
+
+        Added a new test to verify that the width of text input 
+        fields can be modified by javascript using the "size" attribute.
+
+        * fast/js/text-field-resize-expected.txt: Added.
+        * fast/js/text-field-resize.html: Added.
+
 2008-11-24  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/js/text-field-resize-expected.txt b/LayoutTests/fast/js/text-field-resize-expected.txt
new file mode 100644 (file)
index 0000000..12ef90d
--- /dev/null
@@ -0,0 +1,3 @@
+SUCCESS
+SUCCESS
diff --git a/LayoutTests/fast/js/text-field-resize.html b/LayoutTests/fast/js/text-field-resize.html
new file mode 100644 (file)
index 0000000..8decfa3
--- /dev/null
@@ -0,0 +1,37 @@
+<HTML>
+<HEAD>
+<SCRIPT>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function log(s)
+{
+    document.getElementById("console").appendChild(document.createTextNode(s));
+    document.getElementById("console").appendChild(document.createElement("br"));
+}
+
+function resize() {
+    var input_field_width_before_resize = document.getElementById('success').clientWidth;
+    document.getElementById('success').size=30;
+    var input_field_width_after_resize = document.getElementById('success').clientWidth;
+    if(input_field_width_after_resize > input_field_width_before_resize) {
+        log("SUCCESS");
+    } else {
+        log("FAIL");
+    }
+    input_field_width_before_resize = document.getElementById('success').clientWidth;
+    document.getElementById('success').setAttribute("size", 40);
+    input_field_width_after_resize = document.getElementById('success').clientWidth;
+    if(input_field_width_after_resize > input_field_width_before_resize) {
+        log("SUCCESS");
+    } else {
+        log("FAIL");
+    }
+}
+</SCRIPT>
+</HEAD>
+<BODY onLoad="resize();">
+<span id="console"></span>
+<input type="text" id="success" size="2">
+</BODY>
+</HTML>
index 16b14ab..406f98e 100644 (file)
@@ -1,3 +1,19 @@
+2008-11-24  Glenn Wilson  <gwilson@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        http://bugs.webkit.org/show_bug.cgi?id=18703
+        "Changing the 'size' property on a text input does not affect its length"
+
+        Text fields would not repaint themselves after having their "size" 
+        attributes modified.  This fix tells the object to recalculate its 
+        width and repaint itself when its "size" attribute is parsed.
+
+        Test: fast/js/text-field-resize.html
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::parseMappedAttribute):
+
 2008-11-24  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Darin Adler
index f782e7e..fe3ce64 100644 (file)
@@ -640,6 +640,8 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr)
         setChanged();
     } else if (attr->name() == sizeAttr) {
         m_size = !attr->isNull() ? attr->value().toInt() : 20;
+        if (renderer())
+            renderer()->setNeedsLayoutAndPrefWidthsRecalc();
     } else if (attr->name() == altAttr) {
         if (renderer() && inputType() == IMAGE)
             static_cast<RenderImage*>(renderer())->updateAltText();