Default <select multiple> expands up to 10 items instead of showing 4.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Nov 2011 07:11:27 +0000 (07:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Nov 2011 07:11:27 +0000 (07:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70765

Patch by Antaryami Pandia <antaryami.pandia@motorola.com> on 2011-11-08
Reviewed by Darin Adler.

Source/WebCore:

Tests: fast/forms/select-clientheight-large-size.html
       fast/forms/select-clientheight-with-multiple-attr.html

* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::size):

LayoutTests:

* fast/forms/select-clientheight-large-size-expected.txt: Added.
* fast/forms/select-clientheight-large-size.html: Added.
* fast/forms/select-clientheight-with-multiple-attr-expected.txt: Added.
* fast/forms/select-clientheight-with-multiple-attr.html: Added.
* platform/chromium/test_expectations.txt:
* platform/gtk/fast/forms/listbox-clip-expected.txt:
* platform/mac/test_expectations.txt:
* platform/qt/test_expectations.txt:
* platform/win/test_expectations.txt:

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/select-clientheight-large-size-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/select-clientheight-large-size.html [new file with mode: 0644]
LayoutTests/fast/forms/select-clientheight-with-multiple-attr-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/select-clientheight-with-multiple-attr.html [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/gtk/fast/forms/listbox-clip-expected.txt
LayoutTests/platform/mac/test_expectations.txt
LayoutTests/platform/qt/test_expectations.txt
LayoutTests/platform/win/test_expectations.txt
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderListBox.cpp

index 0787d18..b6e51e2 100644 (file)
@@ -1,3 +1,20 @@
+2011-11-08  Antaryami Pandia  <antaryami.pandia@motorola.com>
+
+        Default <select multiple> expands up to 10 items instead of showing 4.
+        https://bugs.webkit.org/show_bug.cgi?id=70765
+
+        Reviewed by Darin Adler.
+
+        * fast/forms/select-clientheight-large-size-expected.txt: Added.
+        * fast/forms/select-clientheight-large-size.html: Added.
+        * fast/forms/select-clientheight-with-multiple-attr-expected.txt: Added.
+        * fast/forms/select-clientheight-with-multiple-attr.html: Added.
+        * platform/chromium/test_expectations.txt:
+        * platform/gtk/fast/forms/listbox-clip-expected.txt:
+        * platform/mac/test_expectations.txt:
+        * platform/qt/test_expectations.txt:
+        * platform/win/test_expectations.txt:
+
 2011-11-08  Chris Evans  <cevans@google.com>
 
         Crash accessing font fact rule parent
diff --git a/LayoutTests/fast/forms/select-clientheight-large-size-expected.txt b/LayoutTests/fast/forms/select-clientheight-large-size-expected.txt
new file mode 100644 (file)
index 0000000..779c23f
--- /dev/null
@@ -0,0 +1,14 @@
+HTMLSelectElement multiple attribute test when no size is specified
+
+PASS clientHeight('select2') is clientHeight('select1')
+PASS getElemById('select2').setAttribute('size', '4'); clientHeight('select2') == clientHeight('select1') is true
+PASS getElemById('select2').setAttribute('size', '5'); clientHeight('select2') > clientHeight('select1') is true
+PASS getElemById('select2').setAttribute('size', '8'); clientHeight('select2') == multipleOfElement('select1', 2) is true
+PASS getElemById('select2').setAttribute('size', '12'); clientHeight('select2') == multipleOfElement('select1', 3) is true
+PASS getElemById('select2').setAttribute('size', '16'); clientHeight('select2') == multipleOfElement('select1', 4) is true
+PASS getElemById('select2').setAttribute('size', '400'); clientHeight('select2') == multipleOfElement('select1', 100) is true
+PASS getElemById('select2').setAttribute('size', '4000'); clientHeight('select2') == multipleOfElement('select1', 1000) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+  
diff --git a/LayoutTests/fast/forms/select-clientheight-large-size.html b/LayoutTests/fast/forms/select-clientheight-large-size.html
new file mode 100644 (file)
index 0000000..096be22
--- /dev/null
@@ -0,0 +1,67 @@
+<html>
+<head>
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p>HTMLSelectElement multiple attribute test when no size is specified</p>
+<div id="console"></div>
+
+<select multiple id="select1" >
+    <option value="0">0</option>
+    <option value="1">1</option>
+    <option value="2">2</option>
+    <option value="3">3</option>
+    <option value="4">4</option>
+    <option value="5">5</option>
+    <option value="6">6</option>
+    <option value="7">7</option>
+    <option value="8">8</option>
+    <option value="9">9</option>
+</select>
+
+<select multiple id="select2" ></select>
+
+<script>
+
+    function AddItem(Text,Value) {
+        var opt = document.createElement("option");
+        document.getElementById("select2").options.add(opt);
+
+        opt.text = Text;
+        opt.value = Value;
+
+    }
+
+    function getElemById(elemId) {
+        return document.getElementById(elemId);
+    }
+
+    function clientHeight(elemId) {
+        var element = getElemById(elemId);
+        return element.clientHeight;
+    }
+
+    function multipleOfElement(elemId, multiple) {
+        var element = getElemById(elemId);
+        var value = element.clientHeight * multiple + (multiple - 1);
+        return value;
+    }
+
+    var select = document.getElementById("select2");
+    
+    // Add large number of options
+    for (i=0 ; i<= 10000 ;i++)
+        AddItem(i, i);
+
+    shouldBe("clientHeight('select2')", "clientHeight('select1')");
+    shouldBeTrue("getElemById('select2').setAttribute('size', '4'); clientHeight('select2') == clientHeight('select1')");
+    shouldBeTrue("getElemById('select2').setAttribute('size', '5'); clientHeight('select2') > clientHeight('select1')");
+    shouldBeTrue("getElemById('select2').setAttribute('size', '8'); clientHeight('select2') == multipleOfElement('select1', 2)");
+    shouldBeTrue("getElemById('select2').setAttribute('size', '12'); clientHeight('select2') == multipleOfElement('select1', 3)");
+    shouldBeTrue("getElemById('select2').setAttribute('size', '16'); clientHeight('select2') == multipleOfElement('select1', 4)");
+    shouldBeTrue("getElemById('select2').setAttribute('size', '400'); clientHeight('select2') == multipleOfElement('select1', 100)");
+    shouldBeTrue("getElemById('select2').setAttribute('size', '4000'); clientHeight('select2') == multipleOfElement('select1', 1000)");
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/select-clientheight-with-multiple-attr-expected.txt b/LayoutTests/fast/forms/select-clientheight-with-multiple-attr-expected.txt
new file mode 100644 (file)
index 0000000..f94440e
--- /dev/null
@@ -0,0 +1,13 @@
+HTMLSelectElement multiple attribute test when no size is specified
+
+PASS clientHeight('sel2') is clientHeight('sel1')
+PASS getElemById('sel2').setAttribute('size', '5'); clientHeight('sel2') > clientHeight('sel1') is true
+PASS clientHeight('sel3') is clientHeight('sel1')
+PASS getElemById('sel3').setAttribute('size', '2'); clientHeight('sel3') is clientHeight('sel1')
+PASS getElemById('sel3').setAttribute('size', '0'); clientHeight('sel3') is clientHeight('sel1')
+PASS getElemById('sel3').setAttribute('size', ''); clientHeight('sel3') is clientHeight('sel1')
+PASS getElemById('sel3').setAttribute('size', '1+ef'); clientHeight('sel3') is clientHeight('sel1')
+PASS successfullyParsed is true
+
+TEST COMPLETE
+    
diff --git a/LayoutTests/fast/forms/select-clientheight-with-multiple-attr.html b/LayoutTests/fast/forms/select-clientheight-with-multiple-attr.html
new file mode 100644 (file)
index 0000000..2a1f15c
--- /dev/null
@@ -0,0 +1,57 @@
+<html>
+<head>
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p>HTMLSelectElement multiple attribute test when no size is specified</p>
+<div id="console"></div>
+
+<select multiple id="sel1" >
+    <option value="1">One</option>
+</select>
+
+<select multiple id="sel2" >
+    <option value="1">One</option>
+    <option value="2">Two</option>
+    <option value="3">Three</option>
+    <option value="4">Four</option>
+    <option value="5">Five</option>
+    <option value="6">Six</option>
+    <option value="7">Seven</option>
+    <option value="8">Eight</option>
+    <option value="9">Nine</option>
+    <option value="10">Ten</option>
+    <option value="11">Eleven</option>
+    <option value="12">Twelve</option>
+    <option value="13">Thirteen</option>
+    <option value="14">Fourteen</option>
+</select>
+
+<select multiple id="sel3" >
+    <option value="1">One</option>
+    <option value="2">Two</option>
+    <option value="3">Three</option>
+</select>
+
+<script>
+
+    function getElemById(elemId) {
+        return document.getElementById(elemId);
+    }
+
+    function clientHeight(elemId) {
+        var element = getElemById(elemId);
+        return element.clientHeight;
+    }
+
+    shouldBe("clientHeight('sel2')", "clientHeight('sel1')");
+    shouldBeTrue("getElemById('sel2').setAttribute('size', '5'); clientHeight('sel2') > clientHeight('sel1')");
+    shouldBe("clientHeight('sel3')", "clientHeight('sel1')");
+    shouldBe("getElemById('sel3').setAttribute('size', '2'); clientHeight('sel3')", "clientHeight('sel1')");
+    shouldBe("getElemById('sel3').setAttribute('size', '0'); clientHeight('sel3')", "clientHeight('sel1')");
+    shouldBe("getElemById('sel3').setAttribute('size', ''); clientHeight('sel3')", "clientHeight('sel1')");
+    shouldBe("getElemById('sel3').setAttribute('size', '1+ef'); clientHeight('sel3')", "clientHeight('sel1')");
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 56a73cd..abedcdc 100644 (file)
@@ -1968,6 +1968,9 @@ BUGUKAI SKIP MAC WIN : fast/text/international/bold-bengali.html = FAIL
 // They should be moved to the JavaScriptCore test suite.
 BUGCR42875 SKIP WONTFIX : sputnik = TEXT
 
+// Need rebaseline
+BUGWK70765 : fast/forms/listbox-clip.html = TEXT
+
 BUGWK38705 : http/tests/security/sandbox-inherit-to-initial-document-2.html = TEXT
 
 // WebKit roll 58791:58807
index e13e51e..da0ab3f 100644 (file)
@@ -3,6 +3,6 @@ layer at (0,0) size 800x600
 layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
-      RenderListBox {SELECT} at (0,2) size 100x106 [bgcolor=#FFFFFF] [border: (1px inset #808080)]
+      RenderListBox {SELECT} at (0,2) size 100x85 [bgcolor=#FFFFFF] [border: (1px inset #808080)]
       RenderText {#text} at (0,0) size 0x0
       RenderText {#text} at (0,0) size 0x0
index e78935b..564db4a 100644 (file)
@@ -25,6 +25,9 @@ BUGWK58192 : fast/canvas/webgl/gl-teximage.html = TEXT PASS
 BUGWK58192 : fast/frames/flattening/iframe-flattening-offscreen.html = TEXT PASS
 BUGWK58192 : svg/dom/SVGScriptElement/script-set-href.svg = TEXT PASS
 
+// Need rebaseline
+BUGWK70765 : fast/forms/listbox-clip.html = TEXT
+
 BUGWK67007 DEBUG : fast/ruby/after-block-doesnt-crash.html = CRASH
 BUGWK67007 DEBUG : fast/ruby/after-table-doesnt-crash.html = CRASH
 BUGWK67007 DEBUG : fast/ruby/generated-after-counter-doesnt-crash.html = CRASH
index 2488aaf..ecfa8ef 100644 (file)
@@ -16,4 +16,7 @@ BUGWK67007 DEBUG : fast/ruby/after-table-doesnt-crash.html = CRASH
 BUGWK67007 DEBUG : fast/ruby/generated-after-counter-doesnt-crash.html = CRASH
 BUGWK67007 DEBUG : fast/ruby/generated-before-and-after-counter-doesnt-crash.html = CRASH
 
+// Need rebaseline
+BUGWK70765 : fast/forms/listbox-clip.html = TEXT
+
 BUGWK62662 DEBUG : inspector/cookie-parser.html = CRASH PASS
index ff3b126..c3b6a1d 100644 (file)
@@ -8,4 +8,7 @@ BUGWK67007 DEBUG : fast/ruby/generated-after-counter-doesnt-crash.html = CRASH
 BUGWK67007 DEBUG : fast/ruby/generated-before-and-after-counter-doesnt-crash.html = CRASH
 
 // Need rebaseline
+BUGWK70765 : fast/forms/listbox-clip.html = TEXT
+
+// Need rebaseline
 BUGWK65361 : fast/forms/input-disabled-color.html = IMAGE+TEXT
index 2fa681c..50eeda0 100644 (file)
@@ -1,3 +1,16 @@
+2011-11-08  Antaryami Pandia  <antaryami.pandia@motorola.com>
+
+        Default <select multiple> expands up to 10 items instead of showing 4.
+        https://bugs.webkit.org/show_bug.cgi?id=70765
+
+        Reviewed by Darin Adler.
+
+        Tests: fast/forms/select-clientheight-large-size.html
+               fast/forms/select-clientheight-with-multiple-attr.html
+
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::size):
+
 2011-11-08  Chris Evans  <cevans@google.com>
 
         Crash accessing font fact rule parent
index 04e4d69..0b758a4 100644 (file)
@@ -70,8 +70,12 @@ const int rowSpacing = 1;
 
 const int optionsSpacingHorizontal = 2;
 
+// The minSize constant was originally defined to render scrollbars correctly.
+// This might vary for different platforms.
 const int minSize = 4;
-const int maxDefaultSize = 10;
+
+// Default size when the multiple attribute is present but size attribute is absent.
+const int defaultSize = 4;
 
 // FIXME: This hardcoded baselineAdjustment is what we used to do for the old
 // widget, but I'm not sure this is right for the new control.
@@ -216,7 +220,8 @@ int RenderListBox::size() const
     int specifiedSize = toHTMLSelectElement(node())->size();
     if (specifiedSize > 1)
         return max(minSize, specifiedSize);
-    return min(max(minSize, numItems()), maxDefaultSize);
+
+    return defaultSize;
 }
 
 int RenderListBox::numVisibleItems() const