Bug 490182. Ask to reflow the right frame. r=bernd, sr=dbaron.
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 11 May 2009 09:17:25 -0400
changeset 28202 c532f17489f7fd4df1ea716c68449e36dacd70e2
parent 28201 32b257e12435d540dee9cdd77626b5637dea2f10
child 28203 b749959e07f3ec3de65f171b10d4dadc4a59eb1c
push idunknown
push userunknown
push dateunknown
reviewersbernd, dbaron
bugs490182
milestone1.9.2a1pre
Bug 490182. Ask to reflow the right frame. r=bernd, sr=dbaron.
layout/reftests/bugs/490182-1-ref.html
layout/reftests/bugs/490182-1a.html
layout/reftests/bugs/490182-1b.html
layout/reftests/bugs/reftest.list
layout/tables/nsTableColGroupFrame.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/490182-1-ref.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+</head>
+<body>
+<table border="2" id="table">
+<col id="col1">
+<col width=200 id="col2">
+<tr>
+<td>100?</td><td>200</td>
+</tr>
+</table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/490182-1a.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script type="text/javascript">
+function boom()
+{
+  var table = document.getElementById("table");
+  var col1 = document.getElementById("col1");
+  var next = col1.nextSibling;
+  
+  table.removeChild(col1);
+  reflow();
+  table.insertBefore(col1, next);
+  reflow();  
+  col1.removeAttribute("width");
+}
+
+function reflow() { document.documentElement.offsetHeight; }
+
+</script>
+</head>
+<body onload="boom();">
+<table border="2" id="table">
+<col width=100 id="col1">
+<col width=200 id="col2">
+<tr>
+<td>100?</td><td>200</td>
+</tr>
+</table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/490182-1b.html
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script type="text/javascript">
+function boom()
+{
+  var table = document.getElementById("table");
+  var col1 = document.createElement("col");
+  col1.setAttribute("width", "100");
+  var next = document.getElementById("col2");
+  
+  table.insertBefore(col1, next);
+  reflow();
+  col1.removeAttribute("width");
+}
+
+function reflow() { document.documentElement.offsetHeight; }
+
+</script>
+</head>
+<body onload="boom();">
+<table border="2" id="table">
+<col width=200 id="col2">
+<tr>
+<td>100?</td><td>200</td>
+</tr>
+</table>
+</BODY>
+</HTML>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1224,11 +1224,13 @@ fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 
 == 486052-2d.html 486052-2-ref.html
 == 486052-2e.html 486052-2-ref.html
 == 486052-2f.html 486052-2-ref.html
 == 486052-2g.html 486052-2-ref.html
 == 486848-1.xul 486848-1-ref.xul
 == 487539-1.html about:blank
 == 488390-1.html 488390-1-ref.html
 == 488685-1.html 488685-1-ref.html
+== 490182-1a.html 490182-1-ref.html
+== 490182-1b.html 490182-1-ref.html
 == 490173-1.html 490173-1-ref.html
 == 490173-2.html 490173-2-ref.html
 fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") == 488692-1.html 488692-1-ref.html # needs EXTEND_PAD on non-Mac for correct scaling behaviour
--- a/layout/tables/nsTableColGroupFrame.cpp
+++ b/layout/tables/nsTableColGroupFrame.cpp
@@ -297,21 +297,17 @@ nsTableColGroupFrame::InsertFrames(nsIAt
 
 void
 nsTableColGroupFrame::InsertColsReflow(PRInt32         aColIndex,
                                        nsIFrame*       aFirstFrame,
                                        nsIFrame*       aLastFrame)
 {
   AddColsToTable(aColIndex, PR_TRUE, aFirstFrame, aLastFrame);
 
-  nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
-  if (!tableFrame)
-    return;
-
-  PresContext()->PresShell()->FrameNeedsReflow(tableFrame,
+  PresContext()->PresShell()->FrameNeedsReflow(this,
                                                nsIPresShell::eTreeChange,
                                                NS_FRAME_HAS_DIRTY_CHILDREN);
 }
 
 void
 nsTableColGroupFrame::RemoveChild(nsTableColFrame& aChild,
                                   PRBool           aResetSubsequentColIndices)
 {
@@ -329,21 +325,18 @@ nsTableColGroupFrame::RemoveChild(nsTabl
       }
       else {
         nsIFrame* nextGroup = GetNextSibling();
         if (nextGroup) // reset next and all following colgroups
           ResetColIndices(nextGroup, colIndex);
       }
     }
   }
-  nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
-  if (!tableFrame)
-    return;
 
-  PresContext()->PresShell()->FrameNeedsReflow(tableFrame,
+  PresContext()->PresShell()->FrameNeedsReflow(this,
                                                nsIPresShell::eTreeChange,
                                                NS_FRAME_HAS_DIRTY_CHILDREN);
 }
 
 NS_IMETHODIMP
 nsTableColGroupFrame::RemoveFrame(nsIAtom*        aListName,
                                   nsIFrame*       aOldFrame)
 {
@@ -363,27 +356,24 @@ nsTableColGroupFrame::RemoveFrame(nsIAto
                      "How did that happen??");
         nextCol = col->GetNextCol();
         RemoveFrame(nsnull, col);
         col = nextCol;
       }
     }
     
     PRInt32 colIndex = colFrame->GetColIndex();
+    // The RemoveChild call handles calling FrameNeedsReflow on us.
     RemoveChild(*colFrame, PR_TRUE);
     
     nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
     if (!tableFrame)
       return NS_ERROR_NULL_POINTER;
 
     tableFrame->RemoveCol(this, colIndex, PR_TRUE, PR_TRUE);
-
-    PresContext()->PresShell()->FrameNeedsReflow(tableFrame,
-                                                 nsIPresShell::eTreeChange,
-                                                 NS_FRAME_HAS_DIRTY_CHILDREN);
   }
   else {
     mFrames.DestroyFrame(aOldFrame);
   }
 
   return NS_OK;
 }