mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 07:18:39 +09:00
Issue #1986 - Part 2: Add IsItemInlineAxisMainAxis() and rework some nsFrame code.
It turns out part 10 was actually needed, but Bug 1449838 had a significantly better version of what that code does that was easy enough to backport to what we have. As far as I can tell, this passes the relevant reftests now.
This commit is contained in:
parent
7527371d78
commit
c3e18955ad
3 changed files with 58 additions and 7 deletions
|
|
@ -1990,6 +1990,10 @@ FlexItem::FlexItem(ReflowInput& aFlexItemReflowInput,
|
|||
"placeholder frames should not be treated as flex items");
|
||||
MOZ_ASSERT(!(mFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW),
|
||||
"out-of-flow frames should not be treated as flex items");
|
||||
MOZ_ASSERT(mIsInlineAxisMainAxis ==
|
||||
nsFlexContainerFrame::IsItemInlineAxisMainAxis(mFrame),
|
||||
"public API should be consistent with internal state (about "
|
||||
"whether flex item's inline axis is flex container's main axis)");
|
||||
|
||||
const ReflowInput* containerRS = aFlexItemReflowInput.mParentReflowInput;
|
||||
if (IsLegacyBox(containerRS->mFrame)) {
|
||||
|
|
@ -4421,6 +4425,41 @@ nsFlexContainerFrame::CalculatePackingSpace(uint32_t aNumThingsToPack,
|
|||
*aPackingSpaceRemaining -= totalEdgePackingSpace;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
nsFlexContainerFrame::IsItemInlineAxisMainAxis(nsIFrame* aFrame)
|
||||
{
|
||||
MOZ_ASSERT(aFrame && aFrame->IsFlexItem(), "expecting arg to be a flex item");
|
||||
const WritingMode flexItemWM = aFrame->GetWritingMode();
|
||||
const nsIFrame* flexContainer = aFrame->GetParent();
|
||||
|
||||
if (IsLegacyBox(flexContainer)) {
|
||||
// For legacy boxes, the main axis is determined by "box-orient", and we can
|
||||
// just directly check if that's vertical, and compare that to whether the
|
||||
// item's WM is also vertical:
|
||||
bool boxOrientIsVertical =
|
||||
(flexContainer->StyleXUL()->mBoxOrient == StyleBoxOrient::Vertical);
|
||||
return flexItemWM.IsVertical() == boxOrientIsVertical;
|
||||
}
|
||||
|
||||
// For modern CSS flexbox, we get our return value by asking two questions
|
||||
// and comparing their answers.
|
||||
// Question 1: does aFrame have the same inline axis as its flex container?
|
||||
bool itemInlineAxisIsParallelToParent =
|
||||
!flexItemWM.IsOrthogonalTo(flexContainer->GetWritingMode());
|
||||
|
||||
// Question 2: is aFrame's flex container row-oriented? (This tells us
|
||||
// whether the flex container's main axis is its inline axis.)
|
||||
auto flexDirection = flexContainer->StylePosition()->mFlexDirection;
|
||||
bool flexContainerIsRowOriented =
|
||||
flexDirection == NS_STYLE_FLEX_DIRECTION_ROW ||
|
||||
flexDirection == NS_STYLE_FLEX_DIRECTION_ROW_REVERSE;
|
||||
|
||||
// aFrame's inline axis is its flex container's main axis IFF the above
|
||||
// questions have the same answer.
|
||||
return flexContainerIsRowOriented == itemInlineAxisIsParallelToParent;
|
||||
}
|
||||
|
||||
void
|
||||
nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
|
||||
ReflowOutput& aDesiredSize,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue