Bug 422678. Table rows whose style-height doesn't fit in the available height (but whose cells do) should be marked incomplete during reflow. r=bernd,sr=dbaron
authorroc+@cs.cmu.edu
Tue, 08 Apr 2008 05:28:34 -0700
changeset 14040 20344020785dbbe2dc09a54fd15d18e3af5293d4
parent 14039 077f70ec9144c1651cf71a8b4ce85ff8b7bea69c
child 14041 a195941b6c0824698664bfa0cb2021dcce0f0bd8
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbernd, dbaron
bugs422678
milestone1.9pre
Bug 422678. Table rows whose style-height doesn't fit in the available height (but whose cells do) should be marked incomplete during reflow. r=bernd,sr=dbaron
layout/reftests/bugs/231823-1-ref.html
layout/reftests/bugs/231823-1.html
layout/reftests/bugs/422249-1-ref.html
layout/reftests/bugs/422249-1.html
layout/reftests/bugs/422678-1-ref.html
layout/reftests/bugs/422678-1.html
layout/reftests/bugs/reftest.list
layout/tables/nsTableCellFrame.cpp
layout/tables/nsTableRowFrame.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/231823-1-ref.html
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML>
+<html class="reftest-print">
+<body>
+<div style="height:1087px;">
+<div>Location:  </div>
+
+<p>
+We are located at 333 West San Carlos Street, Suite 1650, San Jose.
+Our building has a parking garage, and we will validate your parking.
+After you park, as you are walking out of the parking garage, you will
+see a bank of elevators. These elevators only go up and down in the
+garage &#150; they don&#x2019;t connect to the office building. You
+should walk past those elevators, walk out of the garage, walk across a
+courtyard, and into the doors for the main building. There is another
+bank of elevators in that building. Take these elevators to the 16th
+Floor.
+</p>
+
+<p>
+From Highway 280 heading northbound to San Jose:  Take the Guadalupe
+Parkway exit, also called Highway 87.  This exit splits into a
+northbound and a southbound direction.  Take the northbound direction.
+Once on the Guadalupe Parkway take the first exit, which is the Santa
+Clara Street exit.  Bear right on Santa Clara Street as you come off
+that exit.  The first light you come to is Almaden Blvd.  Turn right on
+Almaden.  Go down 3 lights to West San Carlos Street.  Turn right on
+West San Carlos.  The next light you come to is a small street called
+Woz Way. Turn right on Woz.  The parking garage for our building is on
+your right.   Turn right into the garage.  Then follow the directions
+above from the garage to our office.
+</p>
+
+<p>
+From Highway 101 heading southbound to San Jose:  Take the Guadalupe
+Parkway exit, also called Highway 87.  Stay on the Guadalupe as it
+turns into a surface street and you cross over Hedding and Coleman.
+Once it turns into an expressway again, the second exit is the Park
+Avenue exit.  Take this exit.  Turn left on Park Avenue.  After you
+turn left you will come under the freeway and immediately come to a
+traffic light at a small street called  Woz Way.  Turn right on Woz
+Way.  The parking garage for our building is on your left.  Turn left
+into the garage.  Then follow the directions above from the garage to
+our office.
+</p>
+
+<p>
+From Highway 101 heading northbound to San Jose:  Turn on to Highway
+280 headed north.  Then follow directions above for Highway 280 heading
+northbound to San Jose.
+</p>
+
+<p>
+From Highway 880:  Take Highway 880 to Highway 280 South, and then
+follow directions above from Highway 280 heading southbound to San
+Jose.
+</p>
+</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/231823-1.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html class="reftest-print">
+<body>
+<table cellspacing="0" cellpadding="0">
+	<tr>
+		<td rowspan="2" valign="top">
+<div>Location:  </div>
+
+<p>
+We are located at 333 West San Carlos Street, Suite 1650, San Jose.
+Our building has a parking garage, and we will validate your parking.
+After you park, as you are walking out of the parking garage, you will
+see a bank of elevators. These elevators only go up and down in the
+garage &#150; they don&#x2019;t connect to the office building. You
+should walk past those elevators, walk out of the garage, walk across a
+courtyard, and into the doors for the main building. There is another
+bank of elevators in that building. Take these elevators to the 16th
+Floor.
+</p>
+
+<p>
+From Highway 280 heading northbound to San Jose:  Take the Guadalupe
+Parkway exit, also called Highway 87.  This exit splits into a
+northbound and a southbound direction.  Take the northbound direction.
+Once on the Guadalupe Parkway take the first exit, which is the Santa
+Clara Street exit.  Bear right on Santa Clara Street as you come off
+that exit.  The first light you come to is Almaden Blvd.  Turn right on
+Almaden.  Go down 3 lights to West San Carlos Street.  Turn right on
+West San Carlos.  The next light you come to is a small street called
+Woz Way. Turn right on Woz.  The parking garage for our building is on
+your right.   Turn right into the garage.  Then follow the directions
+above from the garage to our office.
+</p>
+
+<p>
+From Highway 101 heading southbound to San Jose:  Take the Guadalupe
+Parkway exit, also called Highway 87.  Stay on the Guadalupe as it
+turns into a surface street and you cross over Hedding and Coleman.
+Once it turns into an expressway again, the second exit is the Park
+Avenue exit.  Take this exit.  Turn left on Park Avenue.  After you
+turn left you will come under the freeway and immediately come to a
+traffic light at a small street called  Woz Way.  Turn right on Woz
+Way.  The parking garage for our building is on your left.  Turn left
+into the garage.  Then follow the directions above from the garage to
+our office.
+</p>
+
+<p>
+From Highway 101 heading northbound to San Jose:  Turn on to Highway
+280 headed north.  Then follow directions above for Highway 280 heading
+northbound to San Jose.
+</p>
+
+<p>
+From Highway 880:  Take Highway 880 to Highway 280 South, and then
+follow directions above from Highway 280 heading southbound to San
+Jose.
+</p>
+		</td>
+
+	</tr>
+	<tr height="1087">
+	</tr>
+</table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/422249-1-ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+<html class="reftest-print">
+<head><style>
+ .tall { 
+   border: 1px solid black;
+   line-height: 20px;
+ }
+</style></head>
+<body style="margin:0">
+  <table class="tall" cellspacing="0" cellpadding="0"><td valign="top">
+    <div style="height:2000px;">
+      a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i
+      <br>j<br>k<br>l<br>m<br>n<br>o<br>p<br>q<br>r<br>s<br>t<br>u<br>v<br>w<br>x
+      <br>y<br>z<br>a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i<br>j<br>k<br>l
+      <br>m<br>n<br>o<br>p<br>q<br>r<br>s<br>t<br>u<br>v<br>w<br>x<br>y<br>z
+      <br>a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i<br>j<br>k<br>l<br>m<br>n</td>
+    </div>
+  </table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/422249-1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html class="reftest-print">
+<head><style>
+ .tall { 
+   border: 1px solid black;
+   height: 2002px;
+   line-height: 20px;
+ }
+</style></head>
+<body style="margin:0">
+  <table class="tall" cellspacing="0" cellpadding="0"><td valign="top">a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i
+    <br>j<br>k<br>l<br>m<br>n<br>o<br>p<br>q<br>r<br>s<br>t<br>u<br>v<br>w<br>x
+    <br>y<br>z<br>a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i<br>j<br>k<br>l
+    <br>m<br>n<br>o<br>p<br>q<br>r<br>s<br>t<br>u<br>v<br>w<br>x<br>y<br>z
+    <br>a<br>b<br>c<br>d<br>e<br>f<br>g<br>h<br>i<br>j<br>k<br>l<br>m<br>n</td>
+  </table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/422678-1-ref.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML>
+<html class="reftest-print">
+<body>
+<table border="1">
+  <tbody>
+    <tr>
+      <td style="background:yellow;"><div style="height:800px;">Hello</div></td>
+    </tr>
+  </tbody>
+</table> 
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/422678-1.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML>
+<html class="reftest-print">
+<body>
+<table border="1">
+  <tbody>
+    <tr>
+      <td style="background:yellow; height:800px;" valign="top">Hello</td>
+    </tr>
+  </tbody>
+</table> 
+</body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -121,16 +121,17 @@ fails == 25888-3r.html 25888-3r-ref.html
 == 201293-1c.html 201293-1-ref.html
 == 201293-1d.html 201293-1-ref.html
 == 206516-1.html 206516-1-ref.html
 == 210876-1.html 210876-1-ref.html
 == 212563-1.html 212563-1-ref.html
 == 214077-1a.html 214077-1-ref.html
 == 214077-1b.html 214077-1-ref.html
 == 218473-1.html 218473-1-ref.html
+== 231823-1.html 231823-1-ref.html
 == 234686-1.html 234686-ref.html
 == 234686-2.html 234686-ref.html
 == 234686-3.html 234686-ref.html
 == 234686-4.html 234686-ref.html
 == 234686-5.html 234686-ref.html
 == 234686-6.html 234686-ref.html
 == 234686-7.html 234686-ref.html
 == 234686-8.html 234686-ref.html
@@ -770,17 +771,19 @@ fails == 413027-3.html 413027-3-ref.html
 == 420351-1.html 420351-1-ref.html
 == 421069.html 421069-ref.html
 == 421069.html 421069-ref2.html
 == 421069-ref.html 421069-ref2.html
 == 421234-1.html 421234-1-ref.html
 == 421419-1.html 421419-1-ref.html
 == 421885-1.xml 421885-1-ref.xml
 == 421955-1.html 421955-1-ref.html
+== 422249-1.html 422249-1-ref.html
 == 422394-1.html 422394-1-ref.html
+== 422678-1.html 422678-1-ref.html
 == 423130-1.html 423130-1-ref.html
 == 423385-1.html 423385-1-ref.html
 == 423599-1.html 423599-1-ref.html
 == 423676-1.html 423676-1-ref.html
 == 424074-1.xul 424074-1-ref.xul
 != 424074-1.xul 424074-1-ref2.xul
 fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 424074-1-ref2.xul 424074-1-ref3.xul
 == 424236-10.html 424236-10-ref.html
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -906,17 +906,29 @@ NS_METHOD nsTableCellFrame::Reflow(nsPre
   }
 
 #ifdef NS_DEBUG
   DebugCheckChildSize(firstKid, kidSize, availSize);
 #endif
 
   // 0 dimensioned cells need to be treated specially in Standard/NavQuirks mode 
   // see testcase "emptyCells.html"
-  SetContentEmpty(0 == kidSize.height);
+  nsIFrame* prevInFlow = GetPrevInFlow();
+  PRBool isEmpty;
+  if (prevInFlow) {
+    isEmpty = static_cast<nsTableCellFrame*>(prevInFlow)->GetContentEmpty();
+  } else {
+    // XXX this is a bad way to check for empty content. There are various
+    // ways the cell could have content but the kid could end up with zero
+    // height. See
+    // http://www.w3.org/TR/CSS21/tables.html#empty-cells
+    // and bug 76331.
+    isEmpty = kidSize.height == 0;
+  }
+  SetContentEmpty(isEmpty);
 
   // Place the child
   FinishReflowChild(firstKid, aPresContext, &kidReflowState, kidSize,
                     kidOrigin.x, kidOrigin.y, 0);
 
   nsTableFrame::InvalidateFrame(firstKid, origRect, origOverflowRect,
                                 firstReflow);
     
--- a/layout/tables/nsTableRowFrame.cpp
+++ b/layout/tables/nsTableRowFrame.cpp
@@ -793,17 +793,18 @@ nsTableRowFrame::ReflowChildren(nsPresCo
   PRInt32 cellColSpan = 1;  // must be defined here so it's set properly for non-cell kids
   
   nsTableIterator iter(*this);
   // remember the col index of the previous cell to handle rowspans into this row
   PRInt32 firstPrevColIndex = (iter.IsLeftToRight()) ? -1 : aTableFrame.GetColCount();
   PRInt32 prevColIndex  = firstPrevColIndex;
   nscoord x = 0; // running total of children x offset
 
-  nscoord paginatedHeight = 0;
+  // This computes the max of all cell heights
+  nscoord cellMaxHeight = 0;
 
   // Reflow each of our existing cell frames
   for (nsIFrame* kidFrame = iter.First(); kidFrame; kidFrame = iter.Next()) {
     nsIAtom* frameType = kidFrame->GetType();
     if (!IS_TABLE_CELL(frameType)) {
       // XXXldb nsCSSFrameConstructor needs to enforce this!
       NS_NOTREACHED("yikes, a non-row child");
 
@@ -941,20 +942,20 @@ nsTableRowFrame::ReflowChildren(nsPresCo
         if (!kidFrame->GetFirstChild(nsnull)->GetFirstChild(nsnull))
           ascent = desiredSize.height;
         else
           ascent = ((nsTableCellFrame *)kidFrame)->GetCellBaseline();
         nscoord descent = desiredSize.height - ascent;
         UpdateHeight(desiredSize.height, ascent, descent, &aTableFrame, cellFrame);
       }
       else {
-        paginatedHeight = PR_MAX(paginatedHeight, desiredSize.height);
+        cellMaxHeight = PR_MAX(cellMaxHeight, desiredSize.height);
         PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan((nsTableCellFrame&)*kidFrame);
         if (1 == rowSpan) {
-          SetContentHeight(paginatedHeight);
+          SetContentHeight(cellMaxHeight);
         }
       }
 
       // Place the child
       if (NS_UNCONSTRAINEDSIZE != availColWidth) {
         desiredSize.width = PR_MAX(availCellWidth, availColWidth);
       }
 
@@ -1005,22 +1006,24 @@ nsTableRowFrame::ReflowChildren(nsPresCo
         SetUnpaginatedHeight(aPresContext, aDesiredSize.height);
       }
       if (isPaginated && HasUnpaginatedHeight()) {
         aDesiredSize.height = PR_MAX(aDesiredSize.height, GetUnpaginatedHeight(aPresContext));
       }
     }
   }
   else { // constrained height, paginated
-    aDesiredSize.height = paginatedHeight;
-    if (aDesiredSize.height <= aReflowState.availableHeight) {
-      nscoord height = CalcHeightFromUnpaginatedHeight(aPresContext, *this);
-      aDesiredSize.height = PR_MAX(aDesiredSize.height, height);
-      aDesiredSize.height = PR_MIN(aDesiredSize.height, aReflowState.availableHeight);
+    // Compute the height we should have from style (subtracting the
+    // height from our prev-in-flows from the style height)
+    nscoord styleHeight = CalcHeightFromUnpaginatedHeight(aPresContext, *this);
+    if (styleHeight > aReflowState.availableHeight) {
+      styleHeight = aReflowState.availableHeight;
+      NS_FRAME_SET_INCOMPLETE(aStatus);
     }
+    aDesiredSize.height = PR_MAX(cellMaxHeight, styleHeight);
   }
   nsRect rowRect(0, 0, aDesiredSize.width, aDesiredSize.height);
   aDesiredSize.mOverflowArea.UnionRect(aDesiredSize.mOverflowArea, rowRect);
   FinishAndStoreOverflow(&aDesiredSize);
   return rv;
 }
 
 /** Layout the entire row.