Bug 604737 - nsHTMLFieldSetElement::RemoveChildAt should update mFirstLegend. r=smaug a=blocking
authorMounir Lamouri <mounir.lamouri@gmail.com>
Thu, 21 Oct 2010 13:11:01 +0200
changeset 56299 af39f954a01ffb493fd9ad36e42c295a2f00525f
parent 56298 5164a685fa81bda71467c7d164f4a592e0a4fe8e
child 56300 80a39b6421b574f71aadd4f1231427e5089eda68
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, blocking
bugs604737
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 604737 - nsHTMLFieldSetElement::RemoveChildAt should update mFirstLegend. r=smaug a=blocking
content/html/content/src/nsHTMLFieldSetElement.cpp
layout/reftests/bugs/604737-ref.html
layout/reftests/bugs/604737.html
layout/reftests/bugs/reftest.list
--- a/content/html/content/src/nsHTMLFieldSetElement.cpp
+++ b/content/html/content/src/nsHTMLFieldSetElement.cpp
@@ -211,23 +211,25 @@ nsHTMLFieldSetElement::InsertChildAt(nsI
 }
 
 nsresult
 nsHTMLFieldSetElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify,
                                      PRBool aMutationEvent /* = PR_TRUE */)
 {
   bool firstLegendHasChanged = false;
 
-  if (GetChildAt(aIndex) == mFirstLegend) {
+  if (mFirstLegend && (GetChildAt(aIndex) == mFirstLegend)) {
     // If we are removing the first legend we have to found another one.
-    for (nsIContent* child = mFirstLegend; child;
-         child = child->GetNextSibling()) {
+    nsIContent* child = mFirstLegend->GetNextSibling();
+    mFirstLegend = nsnull;
+    firstLegendHasChanged = true;
+
+    for (; child; child = child->GetNextSibling()) {
       if (child->IsHTML(nsGkAtoms::legend)) {
         mFirstLegend = child;
-        firstLegendHasChanged = true;
         break;
       }
     }
   }
 
   nsresult rv = nsGenericHTMLFormElement::RemoveChildAt(aIndex, aNotify, aMutationEvent);
   NS_ENSURE_SUCCESS(rv, rv);
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/604737-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <fieldset disabled>
+      <legend>
+        <input>
+      </legend>
+    </fieldset>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/604737.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html class='reftest-wait'>
+  <body onload="document.getElementsByTagName('fieldset')[0].removeChild(document.getElementById('l'));
+                document.documentElement.className = '';">
+    <fieldset disabled>
+      <legend id='l'>
+        <input>
+      </legend>
+      <legend>
+        <input>
+      </legend>
+    </fieldset>
+  </body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1514,11 +1514,12 @@ asserts(0-1) == 582146-1.html about:blan
 == 594624-1.html 594624-1-ref.html
 == 594737-1.html 594737-1-ref.html
 == 597721-1.html 597721-1-ref.html
 == 599113-1.html 599113-1-ref.html
 fails-if(!haveTestPlugin) == 599476.html 599476-ref.html
 == 600045-1.html 600045-1-ref.html
 == 600803-1.html 600803-1-ref.html
 == 600974-1.html 600974-1-ref.html
+== 604737.html 604737-ref.html
 == 600974-2.html 600974-1-ref.html
 == 600974-3.html 600974-1-ref.html
 == 605157-1.xhtml 605157-1-ref.xhtml