Bug 1269046 part 4: Set flags on nsPlaceholderFrame & ReflowInput to track abspos frames that need CSS Box Alignment to resolve static position. r=mats

(We'll react to the ReflowInput flags and do the actual CSS Box Alignment in a
later patch in this series.)

MozReview-Commit-ID: EZd7npWSzQI
This commit is contained in:
Daniel Holbert 2016-10-31 08:58:18 -07:00
Родитель 6512700680
Коммит 689d473b8d
4 изменённых файлов: 48 добавлений и 0 удалений

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

@ -233,6 +233,7 @@ ReflowInput::ReflowInput(
mFlags.mShrinkWrap = !!(aFlags & COMPUTE_SIZE_SHRINK_WRAP);
mFlags.mUseAutoBSize = !!(aFlags & COMPUTE_SIZE_USE_AUTO_BSIZE);
mFlags.mStaticPosIsCBOrigin = !!(aFlags & STATIC_POS_IS_CB_ORIGIN);
mFlags.mIOffsetsNeedCSSAlign = mFlags.mBOffsetsNeedCSSAlign = false;
mDiscoveredClearance = nullptr;
mPercentBSizeObserver = (aParentReflowInput.mPercentBSizeObserver &&
@ -1556,6 +1557,8 @@ ReflowInput::InitAbsoluteConstraints(nsPresContext* aPresContext,
nsHypotheticalPosition hypotheticalPos;
if ((iStartIsAuto && iEndIsAuto) || (bStartIsAuto && bEndIsAuto)) {
if (mFlags.mStaticPosIsCBOrigin) {
// XXXdholbert This whole clause should be removed in bug 1269017, where
// we'll be making abpsos grid children share our CSS Box Alignment code.
hypotheticalPos.mWritingMode = cbwm;
hypotheticalPos.mIStart = nscoord(0);
hypotheticalPos.mBStart = nscoord(0);
@ -1565,6 +1568,20 @@ ReflowInput::InitAbsoluteConstraints(nsPresContext* aPresContext,
NS_ASSERTION(placeholderFrame, "no placeholder frame");
CalculateHypotheticalPosition(aPresContext, placeholderFrame, cbrs,
hypotheticalPos, aFrameType);
if (placeholderFrame->HasAnyStateBits(
PLACEHOLDER_STATICPOS_NEEDS_CSSALIGN)) {
DebugOnly<nsIFrame*> placeholderParent = placeholderFrame->GetParent();
MOZ_ASSERT(placeholderParent, "shouldn't have unparented placeholders");
MOZ_ASSERT(placeholderParent->IsFlexOrGridContainer(),
"This flag should only be set on grid/flex children");
// If the (as-yet unknown) static position will determine the inline
// and/or block offsets, set flags to note those offsets aren't valid
// until we can do CSS Box Alignment on the OOF frame.
mFlags.mIOffsetsNeedCSSAlign = (iStartIsAuto && iEndIsAuto);
mFlags.mBOffsetsNeedCSSAlign = (bStartIsAuto && bEndIsAuto);
}
}
}

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

@ -218,6 +218,24 @@ public:
uint32_t mShrinkWrap:1; // stores the COMPUTE_SIZE_SHRINK_WRAP ctor flag
uint32_t mUseAutoBSize:1; // stores the COMPUTE_SIZE_USE_AUTO_BSIZE ctor flag
uint32_t mStaticPosIsCBOrigin:1; // the STATIC_POS_IS_CB_ORIGIN ctor flag
// If set, the following two flags indicate that:
// (1) this frame is absolutely-positioned (or fixed-positioned).
// (2) this frame's static position depends on the CSS Box Alignment.
// (3) we do need to compute the static position, because the frame's
// {Inline and/or Block} offsets actually depend on it.
// When these bits are set, the offset values (IStart/IEnd, BStart/BEnd)
// represent the "start" edge of the frame's CSS Box Alignment container
// area, in that axis -- and these offsets need to be further-resolved
// (with CSS Box Alignment) after we know the OOF frame's size.
// NOTE: The "I" and "B" (for "Inline" and "Block") refer the axes of the
// *containing block's writing-mode*, NOT mFrame's own writing-mode. This
// is purely for convenience, since that's the writing-mode we're dealing
// with when we set & react to these bits.
// XXXdholbert These new bits will probably make the "mStaticPosIsCBOrigin"
// bit obsolete -- consider removing it in bug 1269017.
uint32_t mIOffsetsNeedCSSAlign:1;
uint32_t mBOffsetsNeedCSSAlign:1;
};
#ifdef DEBUG

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

@ -4512,6 +4512,10 @@ nsFlexContainerFrame::ReflowPlaceholders(nsPresContext* aPresContext,
childDesiredSize, &childReflowInput,
outerWM, aContentBoxOrigin, aContainerSize, 0);
// Mark the placeholder frame to indicate that it's not actually at the
// element's static position, because we need to apply CSS Alignment after
// we determine the OOF's size:
placeholder->AddStateBits(PLACEHOLDER_STATICPOS_NEEDS_CSSALIGN);
}
}

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

@ -591,6 +591,15 @@ FRAME_STATE_BIT(Placeholder, 22, PLACEHOLDER_FOR_FIXEDPOS)
FRAME_STATE_BIT(Placeholder, 23, PLACEHOLDER_FOR_POPUP)
FRAME_STATE_BIT(Placeholder, 24, PLACEHOLDER_FOR_TOPLAYER)
// This bit indicates that the out-of-flow frame's static position needs to be
// determined using the CSS Box Alignment properties
// ([align,justify]-[self,content]). When this is set, the placeholder frame's
// position doesn't represent the static position, as it usually would --
// rather, it represents the logical start corner of the alignment containing
// block. Then, after we've determined the out-of-flow frame's size, we can
// resolve the actual static position using the alignment properties.
FRAME_STATE_BIT(Placeholder, 25, PLACEHOLDER_STATICPOS_NEEDS_CSSALIGN)
// == Frame state bits that apply to table cell frames ========================