bug 281241 if a content based column looses its content based children we need to create anonymous cols r=bzbarsky
authorBernd <bmlk@gmx.de>
Sat, 06 Mar 2010 10:53:02 +0100
changeset 39017 ccc04ad335a837f0450ad4f6cd5a3b4c0fe5e48e
parent 39016 eb5e823a2995d32a526a83ed9d54abccc428cf48
child 39018 a4b34d3053c5f1d9b0abd32c7748c53d70ce72f5
push idunknown
push userunknown
push dateunknown
reviewersbzbarsky
bugs281241
milestone1.9.3a3pre
bug 281241 if a content based column looses its content based children we need to create anonymous cols r=bzbarsky
layout/reftests/bugs/281241-1-ref.html
layout/reftests/bugs/281241-1.html
layout/reftests/bugs/281241-2.html
layout/reftests/bugs/reftest.list
layout/tables/nsTableColGroupFrame.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/281241-1-ref.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html>
+  <head>
+   <title>col removal</title>
+  </head>
+  <body>
+  <table border>
+   <colgroup width="500px">
+   </colgroup>
+   <tr><td>&nbsp;</td></tr>
+  </table>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/281241-1.html
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html>
+ <head>
+  <title>col removal</title>
+  <script type="text/javascript">
+   function foo ()
+   {
+     var out =document.getElementById('outer');
+     var int   =document.getElementById('inner');
+     out.removeChild(int);
+   }
+  </script>
+ </head>
+ <body onload="foo()">
+
+  <table border>
+   <colgroup width="500px" id="outer">
+    <col width="200px" id="inner">
+   </colgroup>
+   <tr><td>&nbsp;</td></tr>
+  </table>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/281241-2.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html>
+ <body>
+  <table border>
+   <colgroup width="100px">
+     <script>var v = document.body.offsetHeight;</script>
+     <col width="500px">
+   </colgroup>
+   <tr><td>&nbsp;</td></tr>
+  </table>
+ </body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -253,16 +253,18 @@ skip-if(MOZ_WIDGET_TOOLKIT=="cocoa") != 
 == 272646-2a.xul 272646-2-ref.xul
 == 272646-2b.xul 272646-2-ref.xul
 == 272646-2c.xul 272646-2-ref.xul
 == 273681-1.html 273681-1-ref.html
 == 278266-1a.html 278266-1-ref.html
 == 278266-1b.html 278266-1-ref.html
 == 280708-1a.html 280708-1-ref.html
 == 280708-1b.html 280708-1-ref.html
+== 281241-1.html 281241-1-ref.html
+== 281241-2.html 281241-1-ref.html
 == 283686-1.html about:blank
 == 283686-2.html 283686-2-ref.html
 == 283686-3.html about:blank
 fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") HTTP == 289480.html#top 289480-ref.html # basically-verbatim acid2 test, HTTP for a 404 page -- bug 409329 for the non-Mac failures
 == 290129-1.html 290129-1-ref.html
 == 291078-1.html 291078-1-ref.html
 == 291078-2.html 291078-2-ref.html
 == 291262-1.html 291262-1-ref.html
--- a/layout/tables/nsTableColGroupFrame.cpp
+++ b/layout/tables/nsTableColGroupFrame.cpp
@@ -319,20 +319,22 @@ nsTableColGroupFrame::RemoveChild(nsTabl
 
 NS_IMETHODIMP
 nsTableColGroupFrame::RemoveFrame(nsIAtom*        aListName,
                                   nsIFrame*       aOldFrame)
 {
   NS_ASSERTION(!aListName, "unexpected child list");
 
   if (!aOldFrame) return NS_OK;
-
+  PRBool contentRemoval = PR_FALSE;
+  
   if (nsGkAtoms::tableColFrame == aOldFrame->GetType()) {
     nsTableColFrame* colFrame = (nsTableColFrame*)aOldFrame;
     if (colFrame->GetColType() == eColContent) {
+      contentRemoval = PR_TRUE;
       // Remove any anonymous column frames this <col> produced via a colspan
       nsTableColFrame* col = colFrame->GetNextCol();
       nsTableColFrame* nextCol;
       while (col && col->GetColType() == eColAnonymousCol) {
         NS_ASSERTION(col->GetStyleContext() == colFrame->GetStyleContext() &&
                      col->GetContent() == colFrame->GetContent(),
                      "How did that happen??");
         nextCol = col->GetNextCol();
@@ -345,16 +347,21 @@ nsTableColGroupFrame::RemoveFrame(nsIAto
     // 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);
+    if (mFrames.IsEmpty() && contentRemoval && 
+        GetColType() == eColGroupContent) {
+      tableFrame->AppendAnonymousColFrames(this, GetSpan(),
+                                           eColAnonymousColGroup, PR_TRUE);
+    }
   }
   else {
     mFrames.DestroyFrame(aOldFrame);
   }
 
   return NS_OK;
 }