Title: [106430] trunk
Revision
106430
Author
[email protected]
Date
2012-01-31 21:37:49 -0800 (Tue, 31 Jan 2012)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=76801
Listboxes incorrectly display contents when cleared and then re-populated.

Whenever the number of items in the listbox is less than the size of listbox (number of visible items the listbox can accomodate),
we set the listbox scroll-offset to zero. The scroll-offset of the Scrollbar should also be set to 0 so that when the listbox is re-populated,
scrollbar position and the content inside the listbox are in sync.

Source/WebCore:

Patch by Joe Thomas <[email protected]> on 2012-01-31
Reviewed by Andreas Kling.

Tests: fast/forms/listbox-clear-restore.html

* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::computeLogicalHeight): Setting the scroll-offset of the Scrollbar to 0 when scrollbar is not needed.

LayoutTests:

Added test case.

Patch by Joe Thomas <[email protected]> on 2012-01-31
Reviewed by Andreas Kling.

* fast/forms/listbox-clear-restore-expected.html: Added.
* fast/forms/listbox-clear-restore.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106429 => 106430)


--- trunk/LayoutTests/ChangeLog	2012-02-01 05:25:09 UTC (rev 106429)
+++ trunk/LayoutTests/ChangeLog	2012-02-01 05:37:49 UTC (rev 106430)
@@ -1,3 +1,19 @@
+2012-01-31  Joe Thomas  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=76801
+        Listboxes incorrectly display contents when cleared and then re-populated.
+
+        Whenever the number of items in the listbox is less than the size of listbox (number of visible items the listbox can accomodate),
+        we set the listbox scroll-offset to zero. The scroll-offset of the Scrollbar should also be set to 0 so that when the listbox is re-populated,
+        scrollbar position and the content inside the listbox are in sync.
+
+        Added test case.
+
+        Reviewed by Andreas Kling.
+
+        * fast/forms/listbox-clear-restore-expected.html: Added.
+        * fast/forms/listbox-clear-restore.html: Added.
+
 2012-01-31  Yuzo Fujishima  <[email protected]>
 
         [Chromium] Unreviewed test expectation change.

Added: trunk/LayoutTests/fast/forms/listbox-clear-restore-expected.html (0 => 106430)


--- trunk/LayoutTests/fast/forms/listbox-clear-restore-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/listbox-clear-restore-expected.html	2012-02-01 05:37:49 UTC (rev 106430)
@@ -0,0 +1,25 @@
+<!DOCTYPE>
+<html>
+<body _onload_="test()">
+<select id="myList" size="10" multiple></select>
+<script>
+function populateList()
+{
+    var myList = document.getElementById("myList");
+    var item;
+
+    for (var ii = 0; ii < 20; ii++) {
+        item = document.createElement("option");
+        item.value = ii;
+        item.appendChild(document.createTextNode("Item #" + ii));
+        myList.appendChild(item);
+    }
+}
+
+function test()
+{
+    populateList();
+}
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/listbox-clear-restore.html (0 => 106430)


--- trunk/LayoutTests/fast/forms/listbox-clear-restore.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/listbox-clear-restore.html	2012-02-01 05:37:49 UTC (rev 106430)
@@ -0,0 +1,54 @@
+<!DOCTYPE>
+<html>
+<body _onload_="test()">
+<select id="myList" size="10" multiple></select>
+<script>
+function populateList()
+{
+    var myList = document.getElementById("myList");
+    var item;
+
+    for (var ii = 0; ii < 20; ii++) {
+        item = document.createElement("option");
+        item.value = ii;
+        item.appendChild(document.createTextNode("Item #" + ii));
+        myList.appendChild(item);
+    }
+}
+
+function clearList()
+{
+    var myList = document.getElementById("myList");
+    var items = myList.getElementsByTagName("option");
+
+    for (var ii = items.length-1; ii >= 0; ii--) {
+        myList.removeChild(items[ii]);
+    }
+}
+
+function populateListTimeout()
+{
+    populateList();
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+function clearListTimeout()
+{
+    clearList();
+    setTimeout(populateListTimeout, 0);
+}
+
+function test()
+{
+    if (window.layoutTestController)
+        layoutTestController.waitUntilDone();
+
+    populateList();
+    document.getElementById("myList").selectedIndex = 19;
+    window.setTimeout(clearListTimeout, 0);
+}
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (106429 => 106430)


--- trunk/Source/WebCore/ChangeLog	2012-02-01 05:25:09 UTC (rev 106429)
+++ trunk/Source/WebCore/ChangeLog	2012-02-01 05:37:49 UTC (rev 106430)
@@ -1,3 +1,19 @@
+2012-01-31  Joe Thomas  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=76801
+        Listboxes incorrectly display contents when cleared and then re-populated.
+
+        Whenever the number of items in the listbox is less than the size of listbox (number of visible items the listbox can accomodate),
+        we set the listbox scroll-offset to zero. The scroll-offset of the Scrollbar should also be set to 0 so that when the listbox is re-populated,
+        scrollbar position and the content inside the listbox are in sync.
+
+        Reviewed by Andreas Kling.
+
+        Tests: fast/forms/listbox-clear-restore.html
+
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::computeLogicalHeight): Setting the scroll-offset of the Scrollbar to 0 when scrollbar is not needed.
+
 2012-01-31  Gyuyoung Kim  <[email protected]>
 
         Unreviewed. Fix build break after r106373.

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (106429 => 106430)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2012-02-01 05:25:09 UTC (rev 106429)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2012-02-01 05:37:49 UTC (rev 106430)
@@ -254,8 +254,10 @@
         m_vBar->setEnabled(enabled);
         m_vBar->setSteps(1, max(1, numVisibleItems() - 1), itemHeight);
         m_vBar->setProportion(numVisibleItems(), numItems());
-        if (!enabled)
+        if (!enabled) {
+            scrollToYOffsetWithoutAnimation(0);
             m_indexOffset = 0;
+        }
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to