<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[28666] trunk</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/28666">28666</a></dd>
<dt>Author</dt> <dd>mitz@apple.com</dd>
<dt>Date</dt> <dd>2007-12-12 16:23:34 -0800 (Wed, 12 Dec 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>WebCore:

        Reviewed by John Sullivan.

        - fix a bug in debug builds only where selecting an earlier item in
          a popup selects the first item

        Test: fast/forms/menulist-selection-reset.html

        * html/HTMLSelectElement.cpp:
        (WebCore::HTMLSelectElement::recalcListItems): Added an argument that
        tells that function whether it should update the selected state of
        option elements.
        (WebCore::HTMLSelectElement::checkListItems): Changed to pass false
        as the above argument.
        * html/HTMLSelectElement.h:

LayoutTests:

        Reviewed by John Sullivan.

        - test for a bug in debug builds only where selecting an earlier item in
          a popup selects the first item

        * fast/forms/menulist-selection-reset-expected.txt: Added.
        * fast/forms/menulist-selection-reset.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorehtmlHTMLSelectElementcpp">trunk/WebCore/html/HTMLSelectElement.cpp</a></li>
<li><a href="#trunkWebCorehtmlHTMLSelectElementh">trunk/WebCore/html/HTMLSelectElement.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastformsmenulistselectionresetexpectedtxt">trunk/LayoutTests/fast/forms/menulist-selection-reset-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastformsmenulistselectionresethtml">trunk/LayoutTests/fast/forms/menulist-selection-reset.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (28665 => 28666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2007-12-13 00:02:21 UTC (rev 28665)
+++ trunk/LayoutTests/ChangeLog        2007-12-13 00:23:34 UTC (rev 28666)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2007-12-12  Dan Bernstein  &lt;mitz@apple.com&gt;
+
+        Reviewed by John Sullivan.
+
+        - test for a bug in debug builds only where selecting an earlier item in
+          a popup selects the first item
+
+        * fast/forms/menulist-selection-reset-expected.txt: Added.
+        * fast/forms/menulist-selection-reset.html: Added.
+
</ins><span class="cx"> 2007-12-12  Beth Dakin  &lt;bdakin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Niko.
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsmenulistselectionresetexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/menulist-selection-reset-expected.txt (0 => 28666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/menulist-selection-reset-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/forms/menulist-selection-reset-expected.txt        2007-12-13 00:23:34 UTC (rev 28666)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsmenulistselectionresethtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/menulist-selection-reset.html (0 => 28666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/menulist-selection-reset.html                                (rev 0)
+++ trunk/LayoutTests/fast/forms/menulist-selection-reset.html        2007-12-13 00:23:34 UTC (rev 28666)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+&lt;select id=&quot;select&quot;&gt;
+    &lt;option&gt;FAIL&lt;/option&gt;
+    &lt;option&gt;PASS&lt;/option&gt;
+    &lt;option selected=&quot;true&quot;&gt;Did not run&lt;/option&gt;
+&lt;/select&gt;
+&lt;p id=&quot;result&quot;&gt;
+&lt;/p&gt;
+&lt;script&gt;
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    select.selectedIndex = 1;
+    result.innerText = select.selectedIndex == 1 ? &quot;PASS&quot; : &quot;FAIL&quot;;
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (28665 => 28666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-12-13 00:02:21 UTC (rev 28665)
+++ trunk/WebCore/ChangeLog        2007-12-13 00:23:34 UTC (rev 28666)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2007-12-12  Dan Bernstein  &lt;mitz@apple.com&gt;
+
+        Reviewed by John Sullivan.
+
+        - fix a bug in debug builds only where selecting an earlier item in
+          a popup selects the first item
+
+        Test: fast/forms/menulist-selection-reset.html
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::recalcListItems): Added an argument that
+        tells that function whether it should update the selected state of
+        option elements.
+        (WebCore::HTMLSelectElement::checkListItems): Changed to pass false
+        as the above argument.
+        * html/HTMLSelectElement.h:
+
</ins><span class="cx"> 2007-12-12  Adele Peterson  &lt;adele@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Geoff.
</span></span></pre></div>
<a id="trunkWebCorehtmlHTMLSelectElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/html/HTMLSelectElement.cpp (28665 => 28666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/HTMLSelectElement.cpp        2007-12-13 00:02:21 UTC (rev 28665)
+++ trunk/WebCore/html/HTMLSelectElement.cpp        2007-12-13 00:23:34 UTC (rev 28666)
</span><span class="lines">@@ -494,7 +494,7 @@
</span><span class="cx">     return new HTMLOptionsCollection(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLSelectElement::recalcListItems() const
</del><ins>+void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const
</ins><span class="cx"> {
</span><span class="cx">     m_listItems.clear();
</span><span class="cx">     HTMLOptionElement* foundSelected = 0;
</span><span class="lines">@@ -513,12 +513,14 @@
</span><span class="cx"> 
</span><span class="cx">         if (current-&gt;hasTagName(optionTag)) {
</span><span class="cx">             m_listItems.append(static_cast&lt;HTMLElement*&gt;(current));
</span><del>-            if (!foundSelected &amp;&amp; (usesMenuList() || (!m_multiple &amp;&amp; static_cast&lt;HTMLOptionElement*&gt;(current)-&gt;selected()))) {
-                foundSelected = static_cast&lt;HTMLOptionElement*&gt;(current);
-                foundSelected-&gt;setSelectedState(true);
-            } else if (foundSelected &amp;&amp; !m_multiple &amp;&amp; static_cast&lt;HTMLOptionElement*&gt;(current)-&gt;selected()) {
-                foundSelected-&gt;setSelectedState(false);
-                foundSelected = static_cast&lt;HTMLOptionElement*&gt;(current);
</del><ins>+            if (updateSelectedStates) {
+                if (!foundSelected &amp;&amp; (usesMenuList() || (!m_multiple &amp;&amp; static_cast&lt;HTMLOptionElement*&gt;(current)-&gt;selected()))) {
+                    foundSelected = static_cast&lt;HTMLOptionElement*&gt;(current);
+                    foundSelected-&gt;setSelectedState(true);
+                } else if (foundSelected &amp;&amp; !m_multiple &amp;&amp; static_cast&lt;HTMLOptionElement*&gt;(current)-&gt;selected()) {
+                    foundSelected-&gt;setSelectedState(false);
+                    foundSelected = static_cast&lt;HTMLOptionElement*&gt;(current);
+                }
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">         if (current-&gt;hasTagName(hrTag))
</span><span class="lines">@@ -1091,7 +1093,7 @@
</span><span class="cx"> void HTMLSelectElement::checkListItems() const
</span><span class="cx"> {
</span><span class="cx">     Vector&lt;HTMLElement*&gt; items = m_listItems;
</span><del>-    recalcListItems();
</del><ins>+    recalcListItems(false);
</ins><span class="cx">     ASSERT(items == m_listItems);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCorehtmlHTMLSelectElementh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/html/HTMLSelectElement.h (28665 => 28666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/HTMLSelectElement.h        2007-12-13 00:02:21 UTC (rev 28665)
+++ trunk/WebCore/html/HTMLSelectElement.h        2007-12-13 00:23:34 UTC (rev 28666)
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx">     void scrollToSelection();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    void recalcListItems() const;
</del><ins>+    void recalcListItems(bool updateSelectedStates = true) const;
</ins><span class="cx">     void checkListItems() const;
</span><span class="cx"> 
</span><span class="cx">     void deselectItems(HTMLOptionElement* excludeElement = 0);
</span></span></pre>
</div>
</div>

</body>
</html>