From 7eaac1fcf74ffe210bcf9bbce5d50ebe2965791d Mon Sep 17 00:00:00 2001 From: "mitz@apple.com" Date: Thu, 13 Dec 2007 00:23:34 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28666 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 10 ++++++++++ .../menulist-selection-reset-expected.txt | 2 ++ .../fast/forms/menulist-selection-reset.html | 14 ++++++++++++++ WebCore/ChangeLog | 17 +++++++++++++++++ WebCore/html/HTMLSelectElement.cpp | 18 ++++++++++-------- WebCore/html/HTMLSelectElement.h | 2 +- 6 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 LayoutTests/fast/forms/menulist-selection-reset-expected.txt create mode 100644 LayoutTests/fast/forms/menulist-selection-reset.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index d622dbb5cda5..60e910870fb4 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2007-12-12 Dan Bernstein + + 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. + 2007-12-12 Beth Dakin Reviewed by Niko. diff --git a/LayoutTests/fast/forms/menulist-selection-reset-expected.txt b/LayoutTests/fast/forms/menulist-selection-reset-expected.txt new file mode 100644 index 000000000000..aa44e7c9f911 --- /dev/null +++ b/LayoutTests/fast/forms/menulist-selection-reset-expected.txt @@ -0,0 +1,2 @@ + +PASS diff --git a/LayoutTests/fast/forms/menulist-selection-reset.html b/LayoutTests/fast/forms/menulist-selection-reset.html new file mode 100644 index 000000000000..20ac958e09d6 --- /dev/null +++ b/LayoutTests/fast/forms/menulist-selection-reset.html @@ -0,0 +1,14 @@ + +

+

+ diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index d6b5e74b56ad..17576385df89 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,20 @@ +2007-12-12 Dan Bernstein + + 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: + 2007-12-12 Adele Peterson Reviewed by Geoff. diff --git a/WebCore/html/HTMLSelectElement.cpp b/WebCore/html/HTMLSelectElement.cpp index 50c4e74905bc..12b078157da3 100644 --- a/WebCore/html/HTMLSelectElement.cpp +++ b/WebCore/html/HTMLSelectElement.cpp @@ -494,7 +494,7 @@ PassRefPtr HTMLSelectElement::options() return new HTMLOptionsCollection(this); } -void HTMLSelectElement::recalcListItems() const +void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const { m_listItems.clear(); HTMLOptionElement* foundSelected = 0; @@ -513,12 +513,14 @@ void HTMLSelectElement::recalcListItems() const if (current->hasTagName(optionTag)) { m_listItems.append(static_cast(current)); - if (!foundSelected && (usesMenuList() || (!m_multiple && static_cast(current)->selected()))) { - foundSelected = static_cast(current); - foundSelected->setSelectedState(true); - } else if (foundSelected && !m_multiple && static_cast(current)->selected()) { - foundSelected->setSelectedState(false); - foundSelected = static_cast(current); + if (updateSelectedStates) { + if (!foundSelected && (usesMenuList() || (!m_multiple && static_cast(current)->selected()))) { + foundSelected = static_cast(current); + foundSelected->setSelectedState(true); + } else if (foundSelected && !m_multiple && static_cast(current)->selected()) { + foundSelected->setSelectedState(false); + foundSelected = static_cast(current); + } } } if (current->hasTagName(hrTag)) @@ -1091,7 +1093,7 @@ void HTMLSelectElement::scrollToSelection() void HTMLSelectElement::checkListItems() const { Vector items = m_listItems; - recalcListItems(); + recalcListItems(false); ASSERT(items == m_listItems); } diff --git a/WebCore/html/HTMLSelectElement.h b/WebCore/html/HTMLSelectElement.h index 7097145cb28c..5573fab6edad 100644 --- a/WebCore/html/HTMLSelectElement.h +++ b/WebCore/html/HTMLSelectElement.h @@ -138,7 +138,7 @@ public: void scrollToSelection(); private: - void recalcListItems() const; + void recalcListItems(bool updateSelectedStates = true) const; void checkListItems() const; void deselectItems(HTMLOptionElement* excludeElement = 0); -- 2.36.0