зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1472602 - Sticky/relative position fixes in nsTableWrapperFrame. r=dholbert
Captions should be relatively-positioned (other browsers support this as well). This ensures we correctly save their normal positions and thus that the sticky scroll container knows how to reposition them correctly. Avoid registering inner table frames with the sticky scroll container to make the assertion sound in cases of sticky-positioned tables. Differential Revision: https://phabricator.services.mozilla.com/D147092
This commit is contained in:
Родитель
f6bc444db3
Коммит
a8cfb8a96f
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<title>position:relative should work on table captions</title>
|
||||
<link rel="match" href="position-relative-table-top-ref.html" />
|
||||
<link rel="help" href="https://www.w3.org/TR/css-position-3/#rel-pos" />
|
||||
<meta name="assert" content="This test checks that the position:relative top constraint behaves correctly for <caption> elements">
|
||||
<style>
|
||||
table {
|
||||
border-collapse:collapse;
|
||||
}
|
||||
|
||||
caption {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
position: relative;
|
||||
top: 100px;
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.group {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.indicator {
|
||||
position: absolute;
|
||||
background-color: red;
|
||||
left: 0;
|
||||
top: 100px;
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="group">
|
||||
<div class="indicator"></div>
|
||||
<table>
|
||||
<caption></caption>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div>You should see a green box above. No red should be visible.</div>
|
||||
|
Загрузка…
Ссылка в новой задаче