Bug 1421660: Add a hack for the sticky container of table cells and such. r?bz draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 01 Dec 2017 21:29:05 +0100
changeset 706636 320ff19f0e905a05e9f2240ff9954c73257ba498
parent 706635 679bc0250123c5e696c94109666b035a33b10a1b
child 706637 d61a44c6a2cf27fd233006b8d3d1bac9ebc748e0
push id91862
push userbmo:emilio@crisal.io
push dateSat, 02 Dec 2017 23:34:31 +0000
reviewersbz
bugs1421660
milestone59.0a1
Bug 1421660: Add a hack for the sticky container of table cells and such. r?bz This matches Blink's behavior. MozReview-Commit-ID: AkUB4MFzwZK
layout/generic/StickyScrollContainer.cpp
--- a/layout/generic/StickyScrollContainer.cpp
+++ b/layout/generic/StickyScrollContainer.cpp
@@ -172,16 +172,25 @@ StickyScrollContainer::ComputeStickyLimi
   nsIFrame* cbFrame = aFrame->GetContainingBlock();
   NS_ASSERTION(cbFrame == scrolledFrame ||
     nsLayoutUtils::IsProperAncestorFrame(scrolledFrame, cbFrame),
     "Scroll frame should be an ancestor of the containing block");
 
   nsRect rect =
     nsLayoutUtils::GetAllInFlowRectsUnion(aFrame, aFrame->GetParent());
 
+  // FIXME(bug 1421660): Table row groups aren't supposed to be containing
+  // blocks, but we treat them as such (maybe it's the right thing to do!).
+  // Anyway, not having this basically disables position: sticky on table cells,
+  // which would be really unfortunate, and doesn't match what other browsers
+  // do.
+  if (cbFrame != scrolledFrame && cbFrame->IsTableRowGroupFrame()) {
+    cbFrame = cbFrame->GetContainingBlock();
+  }
+
   // Containing block limits for the position of aFrame relative to its parent.
   // The margin box of the sticky element stays within the content box of the
   // contaning-block element.
   if (cbFrame != scrolledFrame) {
     *aContain = nsLayoutUtils::
       GetAllInFlowRectsUnion(cbFrame, aFrame->GetParent(),
                              nsLayoutUtils::RECTS_USE_CONTENT_BOX);
     nsRect marginRect = nsLayoutUtils::