diff --git a/layout/generic/StickyScrollContainer.cpp b/layout/generic/StickyScrollContainer.cpp index 5616ad3fbe4b..9d49b56cc445 100644 --- a/layout/generic/StickyScrollContainer.cpp +++ b/layout/generic/StickyScrollContainer.cpp @@ -345,7 +345,16 @@ void StickyScrollContainer::GetScrollRanges(nsIFrame* aFrame, void StickyScrollContainer::PositionContinuations(nsIFrame* aFrame) { NS_ASSERTION(nsLayoutUtils::IsFirstContinuationOrIBSplitSibling(aFrame), "Should be starting from the first continuation"); - nsPoint translation = ComputePosition(aFrame) - aFrame->GetNormalPosition(); + bool hadProperty; + nsPoint translation = + ComputePosition(aFrame) - aFrame->GetNormalPosition(&hadProperty); + if (NS_WARN_IF(!hadProperty)) { + // If the frame was never relatively positioned, don't move its position + // dynamically. There are a variety of frames for which `position` doesn't + // really apply like frames inside svg which would get here and be sticky + // only in one direction. + return; + } // Move all continuation frames by the same amount. for (nsIFrame* cont = aFrame; cont; diff --git a/layout/tables/nsTableWrapperFrame.cpp b/layout/tables/nsTableWrapperFrame.cpp index c2e3c290e93e..25ed8230848b 100644 --- a/layout/tables/nsTableWrapperFrame.cpp +++ b/layout/tables/nsTableWrapperFrame.cpp @@ -1010,7 +1010,7 @@ void nsTableWrapperFrame::Reflow(nsPresContext* aPresContext, captionMargin, captionOrigin, wm); FinishReflowChild(mCaptionFrames.FirstChild(), aPresContext, *captionMet, captionRI.ptr(), wm, captionOrigin, containerSize, - ReflowChildFlags::Default); + ReflowChildFlags::ApplyRelativePositioning); captionRI.reset(); } // XXX If the bsize is constrained then we need to check whether @@ -1019,6 +1019,7 @@ void nsTableWrapperFrame::Reflow(nsPresContext* aPresContext, LogicalPoint innerOrigin(wm); GetInnerOrigin(captionSide, containSize, captionSize, captionMargin, innerSize, innerOrigin, wm); + // NOTE: Relative positioning on the table applies to the whole table wrapper. FinishReflowChild(InnerTableFrame(), aPresContext, innerMet, innerRI.ptr(), wm, innerOrigin, containerSize, ReflowChildFlags::Default); innerRI.reset(); diff --git a/testing/web-platform/tests/css/css-position/position-relative-table-caption.html b/testing/web-platform/tests/css/css-position/position-relative-table-caption.html new file mode 100644 index 000000000000..20ff62888008 --- /dev/null +++ b/testing/web-platform/tests/css/css-position/position-relative-table-caption.html @@ -0,0 +1,43 @@ + +position:relative should work on table captions + + + + + +
+
+ + +
+
+ +
You should see a green box above. No red should be visible.
+