Bug 1379332: When computing abspos CB content-box size, don't bother subtracting borderpadding if CB is a 0-sized child of a XUL-collapsed frame. r=mats

If border & padding were ignored for sizing the containing block (which can
happen, if the containing block is a chlid of a XUL-collapsed frame), then we
don't need to subtract border & padding when computing the frame's content-box
size for its abspos descendants.

MozReview-Commit-ID: JGnzShl8m67

--HG--
extra : rebase_source : 1cead4ce6b403af634c8f9bde0852dce4ee7edc5
This commit is contained in:
Daniel Holbert 2017-10-20 16:40:43 -07:00
Родитель 9ee09abd54
Коммит 828b7077b9
4 изменённых файлов: 49 добавлений и 3 удалений

Просмотреть файл

@ -1093,6 +1093,14 @@ ReflowInput::ApplyRelativePositioning(nsIFrame* aFrame,
} }
} }
// Returns true if aFrame is non-null, a XUL frame, and "XUL-collapsed" (which
// only becomes a valid question to ask if we know it's a XUL frame).
static bool
IsXULCollapsedXULFrame(nsIFrame* aFrame)
{
return aFrame && aFrame->IsXULBoxFrame() && aFrame->IsXULCollapsed();
}
nsIFrame* nsIFrame*
ReflowInput::GetHypotheticalBoxContainer(nsIFrame* aFrame, ReflowInput::GetHypotheticalBoxContainer(nsIFrame* aFrame,
nscoord& aCBIStartEdge, nscoord& aCBIStartEdge,
@ -1128,9 +1136,23 @@ ReflowInput::GetHypotheticalBoxContainer(nsIFrame* aFrame,
NS_ASSERTION(!(aFrame->GetStateBits() & NS_FRAME_IN_REFLOW), NS_ASSERTION(!(aFrame->GetStateBits() & NS_FRAME_IN_REFLOW),
"aFrame shouldn't be in reflow; we'll lie if it is"); "aFrame shouldn't be in reflow; we'll lie if it is");
WritingMode wm = aFrame->GetWritingMode(); WritingMode wm = aFrame->GetWritingMode();
LogicalMargin borderPadding = aFrame->GetLogicalUsedBorderAndPadding(wm); // Compute CB's offset & content-box size by subtracting borderpadding from
aCBIStartEdge = borderPadding.IStart(wm); // frame size. Exception: if the CB is 0-sized, it *might* be a child of a
aCBSize = aFrame->GetLogicalSize(wm) - borderPadding.Size(wm); // XUL-collapsed frame and might have nonzero borderpadding that was simply
// discarded during its layout. (See the child-zero-sizing in
// nsSprocketLayout::XULLayout()). In that case, we ignore the
// borderpadding here (just like we did when laying it out), or else we'd
// produce a bogus negative content-box size.
aCBIStartEdge = 0;
aCBSize = aFrame->GetLogicalSize(wm);
if (!aCBSize.IsAllZero() ||
(!IsXULCollapsedXULFrame(aFrame->GetParent()))) {
// aFrame is not XUL-collapsed (nor is it a child of a XUL-collapsed
// frame), so we can go ahead and subtract out border padding.
LogicalMargin borderPadding = aFrame->GetLogicalUsedBorderAndPadding(wm);
aCBIStartEdge += borderPadding.IStart(wm);
aCBSize -= borderPadding.Size(wm);
}
} }
return aFrame; return aFrame;

Просмотреть файл

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox style="visibility: collapse; position: relative">
<textbox>
<hbox style="position: absolute; width: 10px; height: 10px">
</hbox>
</textbox>
</hbox>
</window>

Просмотреть файл

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<hbox style="position: relative;visibility: collapse;">
<hbox style="padding:5px; border: 5px solid black">
<hbox style="position: absolute; width: 10px; height: 10px">
</hbox>
</hbox>
</hbox>
</window>

Просмотреть файл

@ -97,3 +97,9 @@ load 583957-1.html
load 617089.html load 617089.html
load menulist-focused.xhtml load menulist-focused.xhtml
load 716503.html load 716503.html
# Bug 1379332's tests need stylo to be disabled in order for the
# 'visiblity:collapse' to take effect (which is needed to trigger the assertion
# that these tests are screening for, in unpatched builds):
pref(layout.css.servo.enabled,false) load 1379332-1.xul
pref(layout.css.servo.enabled,false) load 1379332-2.xul