[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

eric at webkit.org eric at webkit.org
Thu Feb 4 21:26:00 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit e5d23811223e2e5d521f54296609582bb66adb2e
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Jan 23 06:19:10 2010 +0000

    2010-01-22  James Robinson  <jamesr at chromium.org>
    
            Reviewed by Alexey Proskuryakov.
    
            Adds tests for the 'selected' attribute of <option>s
            https://bugs.webkit.org/show_bug.cgi?id=32641
    
            HTMLOptionElement_selected2 checks that the selected attribute is up to date immediately after the <select>
            parsed.  HTMLOptionElement_selected3 does the same, but checks immediately prior to the </select>.
    
            Also changes the expectation for add-remove-option-modification-event to reflect that we now pass.
    
            * fast/forms/HTMLOptionElement_selected-expected.txt:
            * fast/forms/HTMLOptionElement_selected.html:
            * fast/forms/HTMLOptionElement_selected2-expected.txt: Added.
            * fast/forms/HTMLOptionElement_selected2.html: Added.
            * fast/forms/HTMLOptionElement_selected3-expected.txt: Added.
            * fast/forms/HTMLOptionElement_selected3.html: Added.
            * fast/forms/add-remove-option-modification-event-expected.txt:
    2010-01-22  James Robinson  <jamesr at chromium.org>
    
            Reviewed by Alexey Proskuryakov.
    
            Ensures that the 'selected' attribute of an <option> is correct
            https://bugs.webkit.org/show_bug.cgi?id=32641
    
            Adds a check in OptionElement::selected() that checks if list items need to be recalculated and does so if needed,
            so the attribute is up to date more often.  Also gets rid of most of the recalcStyle() side effects.
    
             Our behavior now matches Firefox 3.5 and IE8 after the </select> is parsed.
    
             Tests: fast/forms/HTMLOptionElement_selected2.html
                    fast/forms/HTMLOptionElement_selected3.html
    
            * dom/SelectElement.cpp:
            (WebCore::SelectElement::setOptionsChangedOnRenderer):
            (WebCore::SelectElement::setRecalcListItems):
            (WebCore::SelectElement::recalcListItems):
            (WebCore::SelectElement::restoreFormControlState):
            (WebCore::SelectElement::reset):
            (WebCore::SelectElement::typeAheadFind):
            * dom/SelectElement.h:
            * html/HTMLOptionElement.cpp:
            (WebCore::HTMLOptionElement::selected):
            (WebCore::HTMLOptionElement::insertedIntoTree):
            * html/HTMLSelectElement.cpp:
            (WebCore::HTMLSelectElement::recalcStyle):
            (WebCore::HTMLSelectElement::recalcListItemsIfNeeded):
            * html/HTMLSelectElement.h:
            * wml/WMLSelectElement.cpp:
            (WebCore::WMLSelectElement::recalcStyle):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53761 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 50ecafd..3c43179 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,23 @@
+2010-01-22  James Robinson  <jamesr at chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Adds tests for the 'selected' attribute of <option>s
+        https://bugs.webkit.org/show_bug.cgi?id=32641
+
+        HTMLOptionElement_selected2 checks that the selected attribute is up to date immediately after the <select>
+        parsed.  HTMLOptionElement_selected3 does the same, but checks immediately prior to the </select>.
+
+        Also changes the expectation for add-remove-option-modification-event to reflect that we now pass.
+
+        * fast/forms/HTMLOptionElement_selected-expected.txt:
+        * fast/forms/HTMLOptionElement_selected.html:
+        * fast/forms/HTMLOptionElement_selected2-expected.txt: Added.
+        * fast/forms/HTMLOptionElement_selected2.html: Added.
+        * fast/forms/HTMLOptionElement_selected3-expected.txt: Added.
+        * fast/forms/HTMLOptionElement_selected3.html: Added.
+        * fast/forms/add-remove-option-modification-event-expected.txt:
+
 2010-01-22  Steve VanDeBogart  <vandebo at chromium.org>
 
         Reviewed by David Levin.
diff --git a/LayoutTests/fast/forms/HTMLOptionElement_selected-expected.txt b/LayoutTests/fast/forms/HTMLOptionElement_selected-expected.txt
index 7097cfe..98b9087 100644
--- a/LayoutTests/fast/forms/HTMLOptionElement_selected-expected.txt
+++ b/LayoutTests/fast/forms/HTMLOptionElement_selected-expected.txt
@@ -1,5 +1,6 @@
 The test below queries the selected property of the option. In both cases it should be selected, just as the result is when the select is visible. Bug 15088
 
 true
+0
 true
 
diff --git a/LayoutTests/fast/forms/HTMLOptionElement_selected.html b/LayoutTests/fast/forms/HTMLOptionElement_selected.html
index 181bb59..1c2d5f8 100644
--- a/LayoutTests/fast/forms/HTMLOptionElement_selected.html
+++ b/LayoutTests/fast/forms/HTMLOptionElement_selected.html
@@ -10,7 +10,7 @@
             var console = document.getElementById('console');
             var theOption = document.getElementById('theOption');
             console.innerHTML += theOption.selected + "<br>";
-            theOption.parentNode.selectedIndex;
+            console.innerHTML += theOption.parentNode.selectedIndex + "<br>";
             console.innerHTML += theOption.selected + "<br>";
         }
         </script>
diff --git a/LayoutTests/fast/forms/HTMLOptionElement_selected2-expected.txt b/LayoutTests/fast/forms/HTMLOptionElement_selected2-expected.txt
new file mode 100644
index 0000000..1172b7a
--- /dev/null
+++ b/LayoutTests/fast/forms/HTMLOptionElement_selected2-expected.txt
@@ -0,0 +1,7 @@
+This test checks that the selected property of an option is initialized correctly. https://bugs.webkit.org/show_bug.cgi?id=32641
+
+Before querying selectedIndex, [theOption].selected = true
+
+[theSelect].selectedIndex = 0
+
+After querying selectedIndex, [theOption].selected = true
diff --git a/LayoutTests/fast/forms/HTMLOptionElement_selected2.html b/LayoutTests/fast/forms/HTMLOptionElement_selected2.html
new file mode 100644
index 0000000..876e51c
--- /dev/null
+++ b/LayoutTests/fast/forms/HTMLOptionElement_selected2.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <p>This test checks that the selected property of an option is initialized correctly. https://bugs.webkit.org/show_bug.cgi?id=32641</p>
+    <p>Before querying selectedIndex, [theOption].selected = <span id="logOne"></span></p>
+    <p>[theSelect].selectedIndex = <span id="logTwo"></span></p>
+    <p>After querying selectedIndex, [theOption].selected = <span id="logThree"></span></p>
+    <select id="theSelect" style="display:none">
+      <option id="theOption">lalala</option>
+    </select>
+    <script>
+      if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+      var o = document.getElementById('theOption');
+      document.getElementById('logOne').textContent = o.selected;
+      document.getElementById('logTwo').textContent = document.getElementById('theSelect').selectedIndex;
+      document.getElementById('logThree').textContent = o.selected;
+    </script>
+ </body>
+</html>
+
diff --git a/LayoutTests/fast/forms/HTMLOptionElement_selected3-expected.txt b/LayoutTests/fast/forms/HTMLOptionElement_selected3-expected.txt
new file mode 100644
index 0000000..eb9c128
--- /dev/null
+++ b/LayoutTests/fast/forms/HTMLOptionElement_selected3-expected.txt
@@ -0,0 +1,7 @@
+This test checks that the selected property of an option is initialized correctly even prior to the </select> being parsed. https://bugs.webkit.org/show_bug.cgi?id=32641
+
+Before querying selectedIndex, [theOption].selected = true
+
+[theSelect].selectedIndex = 0
+
+After querying selectedIndex, [theOption].selected = true
diff --git a/LayoutTests/fast/forms/HTMLOptionElement_selected3.html b/LayoutTests/fast/forms/HTMLOptionElement_selected3.html
new file mode 100644
index 0000000..2520abe
--- /dev/null
+++ b/LayoutTests/fast/forms/HTMLOptionElement_selected3.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <p>This test checks that the selected property of an option is initialized correctly even prior to the &lt;/select&gt; being parsed. https://bugs.webkit.org/show_bug.cgi?id=32641</p>
+    <p>Before querying selectedIndex, [theOption].selected = <span id="logOne"></span></p>
+    <p>[theSelect].selectedIndex = <span id="logTwo"></span></p>
+    <p>After querying selectedIndex, [theOption].selected = <span id="logThree"></span></p>
+    <select id="theSelect" style="display:none">
+      <option id="theOption">lalala</option>
+    <script>
+      if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+      var o = document.getElementById('theOption');
+      document.getElementById('logOne').textContent = o.selected;
+      document.getElementById('logTwo').textContent = document.getElementById('theSelect').selectedIndex;
+      document.getElementById('logThree').textContent = o.selected;
+    </script>
+    </select>
+ </body>
+</html>
+
diff --git a/LayoutTests/fast/forms/add-remove-option-modification-event-expected.txt b/LayoutTests/fast/forms/add-remove-option-modification-event-expected.txt
index 818c47c..5e1d761 100644
--- a/LayoutTests/fast/forms/add-remove-option-modification-event-expected.txt
+++ b/LayoutTests/fast/forms/add-remove-option-modification-event-expected.txt
@@ -2,9 +2,6 @@ Test that SELECT is in correct state when handling a DOM modification event for
 
   
 
-Failed
-     Expected: true
-     Actual: false
-
+Passed
 Passed
 Passed
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ec52f44..45cfc2d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,36 @@
+2010-01-22  James Robinson  <jamesr at chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Ensures that the 'selected' attribute of an <option> is correct
+        https://bugs.webkit.org/show_bug.cgi?id=32641
+
+        Adds a check in OptionElement::selected() that checks if list items need to be recalculated and does so if needed,
+        so the attribute is up to date more often.  Also gets rid of most of the recalcStyle() side effects.
+
+         Our behavior now matches Firefox 3.5 and IE8 after the </select> is parsed.
+
+         Tests: fast/forms/HTMLOptionElement_selected2.html
+                fast/forms/HTMLOptionElement_selected3.html
+
+        * dom/SelectElement.cpp:
+        (WebCore::SelectElement::setOptionsChangedOnRenderer):
+        (WebCore::SelectElement::setRecalcListItems):
+        (WebCore::SelectElement::recalcListItems):
+        (WebCore::SelectElement::restoreFormControlState):
+        (WebCore::SelectElement::reset):
+        (WebCore::SelectElement::typeAheadFind):
+        * dom/SelectElement.h:
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::selected):
+        (WebCore::HTMLOptionElement::insertedIntoTree):
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::recalcStyle):
+        (WebCore::HTMLSelectElement::recalcListItemsIfNeeded):
+        * html/HTMLSelectElement.h:
+        * wml/WMLSelectElement.cpp:
+        (WebCore::WMLSelectElement::recalcStyle):
+
 2010-01-22  Chris Rogers  <crogers at google.com>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/dom/SelectElement.cpp b/WebCore/dom/SelectElement.cpp
index 4f7712d..866b6ca 100644
--- a/WebCore/dom/SelectElement.cpp
+++ b/WebCore/dom/SelectElement.cpp
@@ -222,28 +222,21 @@ void SelectElement::scrollToSelection(SelectElementData& data, Element* element)
         toRenderListBox(renderer)->selectionChanged();
 }
 
-void SelectElement::recalcStyle(SelectElementData& data, Element* element)
+void SelectElement::setOptionsChangedOnRenderer(SelectElementData& data, Element* element)
 {
-    RenderObject* renderer = element->renderer();
-    if (element->childNeedsStyleRecalc() && renderer) {
+    if (RenderObject* renderer = element->renderer()) {
         if (data.usesMenuList())
             toRenderMenuList(renderer)->setOptionsChanged(true);
         else
             toRenderListBox(renderer)->setOptionsChanged(true);
-    } else if (data.shouldRecalcListItems())
-        recalcListItems(data, element);
+    }
 }
 
 void SelectElement::setRecalcListItems(SelectElementData& data, Element* element)
 {
     data.setShouldRecalcListItems(true);
     data.setActiveSelectionAnchorIndex(-1); // Manual selection anchor is reset when manipulating the select programmatically.
-    if (RenderObject* renderer = element->renderer()) {
-        if (data.usesMenuList())
-            toRenderMenuList(renderer)->setOptionsChanged(true);
-        else
-            toRenderListBox(renderer)->setOptionsChanged(true);
-    }
+    setOptionsChangedOnRenderer(data, element);
     element->setNeedsStyleRecalc();
 }
 
@@ -252,6 +245,8 @@ void SelectElement::recalcListItems(SelectElementData& data, const Element* elem
     Vector<Element*>& listItems = data.rawListItems();
     listItems.clear();
 
+    data.setShouldRecalcListItems(false);
+
     OptionElement* foundSelected = 0;
     for (Node* currentNode = element->firstChild(); currentNode;) {
         if (!currentNode->isElementNode()) {
@@ -297,8 +292,6 @@ void SelectElement::recalcListItems(SelectElementData& data, const Element* elem
         // <select>'s subtree at this point.
         currentNode = currentNode->traverseNextSibling(element);
     }
-
-    data.setShouldRecalcListItems(false);
 }
 
 int SelectElement::selectedIndex(const SelectElementData& data, const Element* element)
@@ -447,7 +440,7 @@ void SelectElement::restoreFormControlState(SelectElementData& data, Element* el
             optionElement->setSelectedState(state[i] == 'X');
     }
 
-    element->setNeedsStyleRecalc();
+    setOptionsChangedOnRenderer(data, element);
 }
 
 void SelectElement::parseMultipleAttribute(SelectElementData& data, Element* element, MappedAttribute* attribute)
@@ -521,6 +514,7 @@ void SelectElement::reset(SelectElementData& data, Element* element)
     if (!selectedOption && firstOption && data.usesMenuList())
         firstOption->setSelectedState(true);
 
+    setOptionsChangedOnRenderer(data, element);
     element->setNeedsStyleRecalc();
 }
     
@@ -895,6 +889,8 @@ void SelectElement::typeAheadFind(SelectElementData& data, Element* element, Key
             setSelectedIndex(data, element, listToOptionIndex(data, element, index));
             if (!data.usesMenuList())
                 listBoxOnChange(data, element);
+
+            setOptionsChangedOnRenderer(data, element);
             element->setNeedsStyleRecalc();
             return;
         }
diff --git a/WebCore/dom/SelectElement.h b/WebCore/dom/SelectElement.h
index 4cc76a0..6891c22 100644
--- a/WebCore/dom/SelectElement.h
+++ b/WebCore/dom/SelectElement.h
@@ -75,7 +75,6 @@ protected:
     static void listBoxOnChange(SelectElementData&, Element*);
     static void menuListOnChange(SelectElementData&, Element*);
     static void scrollToSelection(SelectElementData&, Element*);
-    static void recalcStyle(SelectElementData&, Element*);
     static void setRecalcListItems(SelectElementData&, Element*);
     static void recalcListItems(SelectElementData&, const Element*, bool updateSelectedStates = true);
     static int selectedIndex(const SelectElementData&, const Element*);
@@ -100,6 +99,7 @@ protected:
 private:
     static void menuListDefaultEventHandler(SelectElementData&, Element*, Event*, HTMLFormElement*);
     static void listBoxDefaultEventHandler(SelectElementData&, Element*, Event*, HTMLFormElement*);
+    static void setOptionsChangedOnRenderer(SelectElementData&, Element*);
 };
 
 // HTML/WMLSelectElement hold this struct as member variable
diff --git a/WebCore/html/HTMLOptionElement.cpp b/WebCore/html/HTMLOptionElement.cpp
index b436667..8598e87 100644
--- a/WebCore/html/HTMLOptionElement.cpp
+++ b/WebCore/html/HTMLOptionElement.cpp
@@ -137,6 +137,8 @@ void HTMLOptionElement::setValue(const String& value)
 
 bool HTMLOptionElement::selected() const
 {
+    if (HTMLSelectElement* select = ownerSelectElement())
+        select->recalcListItemsIfNeeded();
     return m_data.selected();
 }
 
@@ -220,7 +222,8 @@ void HTMLOptionElement::insertedIntoTree(bool deep)
 {
     if (HTMLSelectElement* select = ownerSelectElement()) {
         select->setRecalcListItems();
-        if (selected())
+        // Avoid our selected() getter since it will recalculate list items incorrectly for us.
+        if (m_data.selected())
             select->setSelectedIndex(index(), false);
         select->scrollToSelection();
     }
diff --git a/WebCore/html/HTMLSelectElement.cpp b/WebCore/html/HTMLSelectElement.cpp
index 2409f31..5f5c855 100644
--- a/WebCore/html/HTMLSelectElement.cpp
+++ b/WebCore/html/HTMLSelectElement.cpp
@@ -4,6 +4,7 @@
  *           (C) 2001 Dirk Mueller (mueller at kde.org)
  * Copyright (C) 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
  *           (C) 2006 Alexey Proskuryakov (ap at nypop.com)
+ * Copyright (C) 2010 Google Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -59,7 +60,6 @@ bool HTMLSelectElement::checkDTD(const Node* newChild)
 
 void HTMLSelectElement::recalcStyle(StyleChange change)
 {
-    SelectElement::recalcStyle(m_data, this);
     HTMLFormControlElementWithState::recalcStyle(change);
 }
 
@@ -261,6 +261,12 @@ void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const
     SelectElement::recalcListItems(const_cast<SelectElementData&>(m_data), this, updateSelectedStates);
 }
 
+void HTMLSelectElement::recalcListItemsIfNeeded()
+{
+    if (m_data.shouldRecalcListItems())
+        recalcListItems();
+}
+
 void HTMLSelectElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
 {
     setRecalcListItems();
diff --git a/WebCore/html/HTMLSelectElement.h b/WebCore/html/HTMLSelectElement.h
index 8f575d2..d772e4d 100644
--- a/WebCore/html/HTMLSelectElement.h
+++ b/WebCore/html/HTMLSelectElement.h
@@ -3,6 +3,7 @@
  *           (C) 1999 Antti Koivisto (koivisto at kde.org)
  *           (C) 2000 Dirk Mueller (mueller at kde.org)
  * Copyright (C) 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -58,6 +59,7 @@ public:
     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
 
     void setRecalcListItems();
+    void recalcListItemsIfNeeded();
 
     virtual const Vector<Element*>& listItems() const { return m_data.listItems(this); }
 
diff --git a/WebCore/wml/WMLSelectElement.cpp b/WebCore/wml/WMLSelectElement.cpp
index 03ca05a..e6041f4 100644
--- a/WebCore/wml/WMLSelectElement.cpp
+++ b/WebCore/wml/WMLSelectElement.cpp
@@ -83,7 +83,6 @@ void WMLSelectElement::selectAll()
 
 void WMLSelectElement::recalcStyle(StyleChange change)
 {
-    SelectElement::recalcStyle(m_data, this);
     WMLFormControlElement::recalcStyle(change);
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list