Bug 423823. Clip overflowing background when tbody is scrollable. r=fantasai,sr=dbaron
authorRobert O'Callahan <robert@ocallahan.org>
Sat, 16 Aug 2008 21:10:29 +1200
changeset 16738 36c88ee6e809eb014b11873643ee8809f6fc98ca
parent 16737 ac09191be21423b3d1ee0e56e472f69ffc9bb34f
child 16739 3c275aadab369f5121387dd01ef294dc01a3aee7
push idunknown
push userunknown
push dateunknown
reviewersfantasai, dbaron
bugs423823
milestone1.9.1a2pre
Bug 423823. Clip overflowing background when tbody is scrollable. r=fantasai,sr=dbaron
layout/reftests/bugs/423823-1-ref.html
layout/reftests/bugs/423823-1.html
layout/reftests/bugs/reftest.list
layout/tables/nsTablePainter.cpp
layout/tables/nsTableRowGroupFrame.cpp
layout/tables/nsTableRowGroupFrame.h
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/423823-1-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<div style="width:200px; height:100px; background:yellow;"></div>
+<br>
+<div style="width:200px; height:100px; background:yellow; overflow:scroll;">
+  <div style="height:200px; width:200px;"></div>
+</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/423823-1.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<table cellspacing="0" cellpadding="0" style="width:200px;">
+  <tbody style="height:100px; overflow:hidden;">
+    <tr style="background:yellow;"><td><div style="height:200px;"></div>
+  </tbody>
+</table>
+<br>
+<table cellspacing="0" cellpadding="0" style="width:200px;">
+  <tbody style="height:100px; overflow:scroll;">
+    <tr style="background:yellow;"><td><div style="height:200px;"></div>
+  </tbody>
+</table>
+</body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -815,16 +815,17 @@ skip-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 
 == 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
+== 423823-1.html 423823-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-1.html 424236-1-ref.html
 == 424236-2.html 424236-2-ref.html
 == 424236-3.html 424236-3-ref.html
 == 424236-4.html 424236-4-ref.html
 == 424236-5.html 424236-5-ref.html
--- a/layout/tables/nsTablePainter.cpp
+++ b/layout/tables/nsTablePainter.cpp
@@ -438,17 +438,18 @@ TableBackgroundPainter::PaintTable(nsTab
 
   for (PRUint32 i = 0; i < rowGroups.Length(); i++) {
     nsTableRowGroupFrame* rg = rowGroups[i];
     mRowGroup.SetFrame(rg);
     // Need to compute the right rect via GetOffsetTo, since the row
     // group may not be a child of the table.
     mRowGroup.mRect.MoveTo(rg->GetOffsetTo(aTableFrame));
     if (mRowGroup.mRect.Intersects(mDirtyRect - mRenderPt)) {
-      nsresult rv = PaintRowGroup(rg, rg->IsPseudoStackingContextFromStyle());
+      nsresult rv = PaintRowGroup(rg,
+              rg->IsPseudoStackingContextFromStyle() || rg->IsScrolled());
       if (NS_FAILED(rv)) return rv;
     }
   }
   return NS_OK;
 }
 
 nsresult
 TableBackgroundPainter::PaintRowGroup(nsTableRowGroupFrame* aFrame,
--- a/layout/tables/nsTableRowGroupFrame.cpp
+++ b/layout/tables/nsTableRowGroupFrame.cpp
@@ -282,17 +282,17 @@ DisplayRows(nsDisplayListBuilder* aBuild
 NS_IMETHODIMP
 nsTableRowGroupFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                        const nsRect&           aDirtyRect,
                                        const nsDisplayListSet& aLists)
 {
   if (!IsVisibleInSelection(aBuilder))
     return NS_OK;
 
-  PRBool isRoot = aBuilder->IsAtRootOfPseudoStackingContext();
+  PRBool isRoot = aBuilder->IsAtRootOfPseudoStackingContext() || IsScrolled();
   nsDisplayTableItem* item = nsnull;
   if (isRoot) {
     // This background is created regardless of whether this frame is
     // visible or not. Visibility decisions are delegated to the
     // table background painter.
     item = new (aBuilder) nsDisplayTableRowGroupBackground(this);
     nsresult rv = aLists.BorderBackground()->AppendNewToTop(item);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/layout/tables/nsTableRowGroupFrame.h
+++ b/layout/tables/nsTableRowGroupFrame.h
@@ -38,16 +38,17 @@
 #define nsTableRowGroupFrame_h__
 
 #include "nscore.h"
 #include "nsHTMLContainerFrame.h"
 #include "nsIAtom.h"
 #include "nsILineIterator.h"
 #include "nsTablePainter.h"
 #include "nsTArray.h"
+#include "nsCSSAnonBoxes.h"
 
 class nsTableFrame;
 class nsTableRowFrame;
 class nsTableCellFrame;
 
 struct nsRowGroupReflowState {
   const nsHTMLReflowState& reflowState;  // Our reflow state
 
@@ -357,16 +358,23 @@ public:
   /**
    * Set up the row cursor. After this, call AppendFrame for every
    * child frame in sibling order. Ensure that the child frame y and YMost values
    * form non-decreasing sequences (should always be true for table rows);
    * if this is violated, call ClearRowCursor(). If we return nsnull, then we
    * decided not to use a cursor or we already have one set up.
    */
   FrameCursorData* SetupRowCursor();
+  
+  PRBool IsScrolled() {
+    // Note that if mOverflowY is CLIP, so is mOverflowX, and we need to clip the background
+    // as if the rowgroup is scrollable.
+    return GetStyleContext()->GetPseudoType() == nsCSSAnonBoxes::scrolledContent ||
+           GetStyleDisplay()->mOverflowY == NS_STYLE_OVERFLOW_CLIP;
+  }
 
 protected:
   nsTableRowGroupFrame(nsStyleContext* aContext);
 
   void InitChildReflowState(nsPresContext&     aPresContext, 
                             PRBool             aBorderCollapse,
                             nsHTMLReflowState& aReflowState);