Bug 1227285 part 1 - Add a nsHTMLReflowState ctor flag to request shrink-wrap behavior. r=dholbert

This commit is contained in:
Mats Palmgren 2015-12-02 14:12:23 +01:00
parent e98cb50956
commit 7579d57491
2 changed files with 18 additions and 1 deletions

View File

@ -79,6 +79,9 @@ nsHTMLReflowState::nsHTMLReflowState(nsPresContext* aPresContext,
if (aFlags & DUMMY_PARENT_REFLOW_STATE) {
mFlags.mDummyParentReflowState = true;
}
if (aFlags & COMPUTE_SIZE_SHRINK_WRAP) {
mFlags.mShrinkWrap = true;
}
if (!(aFlags & CALLER_WILL_INIT)) {
Init(aPresContext);
@ -219,6 +222,7 @@ nsHTMLReflowState::nsHTMLReflowState(
mFlags.mIsColumnBalancing = false;
mFlags.mIsFlexContainerMeasuringHeight = false;
mFlags.mDummyParentReflowState = false;
mFlags.mShrinkWrap = !!(aFlags & COMPUTE_SIZE_SHRINK_WRAP);
mDiscoveredClearance = nullptr;
mPercentBSizeObserver = (aParentReflowState.mPercentBSizeObserver &&
@ -1588,6 +1592,10 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
typedef nsIFrame::ComputeSizeFlags ComputeSizeFlags;
ComputeSizeFlags computeSizeFlags = ComputeSizeFlags::eDefault;
if (mFlags.mShrinkWrap) {
computeSizeFlags =
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
}
if (wm.IsOrthogonalTo(cbwm)) {
if (bStartIsAuto || bEndIsAuto) {
computeSizeFlags =
@ -2288,6 +2296,10 @@ nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
typedef nsIFrame::ComputeSizeFlags ComputeSizeFlags;
ComputeSizeFlags computeSizeFlags =
isBlock ? ComputeSizeFlags::eDefault : ComputeSizeFlags::eShrinkWrap;
if (mFlags.mShrinkWrap) {
computeSizeFlags =
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
}
nsIFrame* parent = frame->GetParent();
nsIAtom* parentFrameType = parent ? parent->GetType() : nullptr;

View File

@ -583,6 +583,7 @@ public:
// but its in a paginated environment
// (e.g. columns), it should always
// reflow its placeholder children.
uint16_t mShrinkWrap:1; // stores the COMPUTE_SIZE_SHRINK_WRAP ctor flag
} mFlags;
// Logical and physical accessors for the resize flags. All users should go
@ -673,7 +674,11 @@ public:
// Indicates that the calling function will initialize the reflow state, and
// that the constructor should not call Init().
CALLER_WILL_INIT = (1<<1)
CALLER_WILL_INIT = (1<<1),
// The caller wants shrink-wrap behavior (i.e. ComputeSizeFlags::eShrinkWrap
// will be passed to ComputeSize()).
COMPUTE_SIZE_SHRINK_WRAP = (1<<2),
};
// This method initializes various data members. It is automatically