本文整理汇总了C++中nsHTMLReflowState::ComputedHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowState::ComputedHeight方法的具体用法?C++ nsHTMLReflowState::ComputedHeight怎么用?C++ nsHTMLReflowState::ComputedHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowState
的用法示例。
在下文中一共展示了nsHTMLReflowState::ComputedHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: availSize
void
nsTextControlFrame::ReflowTextControlChild(nsIFrame* aKid,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsHTMLReflowMetrics& aParentDesiredSize)
{
// compute available size and frame offsets for child
nsSize availSize(aReflowState.ComputedWidth(),
aReflowState.ComputedHeight());
availSize.width = std::max(availSize.width, 0);
availSize.height = std::max(availSize.height, 0);
nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
aKid, availSize);
// Set computed width and computed height for the child
nscoord width = availSize.width;
width -= kidReflowState.mComputedMargin.LeftRight() +
kidReflowState.mComputedBorderPadding.LeftRight();
width = std::max(width, 0);
kidReflowState.SetComputedWidth(width);
nscoord height = availSize.height;
height -= kidReflowState.mComputedMargin.TopBottom() +
kidReflowState.mComputedBorderPadding.TopBottom();
height = std::max(height, 0);
kidReflowState.SetComputedHeight(height);
// compute the offsets
nscoord xOffset = aReflowState.mComputedBorderPadding.left
+ kidReflowState.mComputedMargin.left;
nscoord yOffset = aReflowState.mComputedBorderPadding.top
+ kidReflowState.mComputedMargin.top;
// reflow the child
nsHTMLReflowMetrics desiredSize;
ReflowChild(aKid, aPresContext, desiredSize, kidReflowState,
xOffset, yOffset, 0, aStatus);
// place the child
FinishReflowChild(aKid, aPresContext, &kidReflowState,
desiredSize, xOffset, yOffset, 0);
// consider the overflow
aParentDesiredSize.mOverflowAreas.UnionWith(desiredSize.mOverflowAreas);
}
示例2: max
nscoord
nsSplittableFrame::GetEffectiveComputedHeight(const nsHTMLReflowState& aReflowState,
nscoord aConsumedHeight) const
{
nscoord height = aReflowState.ComputedHeight();
if (height == NS_INTRINSICSIZE) {
return NS_INTRINSICSIZE;
}
if (aConsumedHeight == NS_INTRINSICSIZE) {
aConsumedHeight = GetConsumedHeight();
}
height -= aConsumedHeight;
// We may have stretched the frame beyond its computed height. Oh well.
return std::max(0, height);
}
示例3: kidReflowState
void
nsTextControlFrame::ReflowTextControlChild(nsIFrame* aKid,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsHTMLReflowMetrics& aParentDesiredSize)
{
// compute available size and frame offsets for child
WritingMode wm = aKid->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSizeWithPadding(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
aKid, availSize, nullptr,
nsHTMLReflowState::CALLER_WILL_INIT);
// Override padding with our computed padding in case we got it from theming or percentage
kidReflowState.Init(aPresContext, nullptr, nullptr, &aReflowState.ComputedPhysicalPadding());
// Set computed width and computed height for the child
kidReflowState.SetComputedWidth(aReflowState.ComputedWidth());
kidReflowState.SetComputedHeight(aReflowState.ComputedHeight());
// Offset the frame by the size of the parent's border
nscoord xOffset = aReflowState.ComputedPhysicalBorderPadding().left -
aReflowState.ComputedPhysicalPadding().left;
nscoord yOffset = aReflowState.ComputedPhysicalBorderPadding().top -
aReflowState.ComputedPhysicalPadding().top;
// reflow the child
nsHTMLReflowMetrics desiredSize(aReflowState);
ReflowChild(aKid, aPresContext, desiredSize, kidReflowState,
xOffset, yOffset, 0, aStatus);
// place the child
FinishReflowChild(aKid, aPresContext, desiredSize,
&kidReflowState, xOffset, yOffset, 0);
// consider the overflow
aParentDesiredSize.mOverflowAreas.UnionWith(desiredSize.mOverflowAreas);
}
示例4: Reflow
NS_IMETHODIMP nsProgressFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsProgressFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_ASSERTION(mBarDiv, "Progress bar div must exist!");
NS_ASSERTION(!GetPrevContinuation(),
"nsProgressFrame should not have continuations; if it does we "
"need to call RegUnregAccessKey only for the first.");
if (mState & NS_FRAME_FIRST_REFLOW) {
nsFormControlFrame::RegUnRegAccessKey(this, true);
}
nsIFrame* barFrame = mBarDiv->GetPrimaryFrame();
NS_ASSERTION(barFrame, "The progress frame should have a child with a frame!");
ReflowBarFrame(barFrame, aPresContext, aReflowState, aStatus);
aDesiredSize.width = aReflowState.ComputedWidth() +
aReflowState.mComputedBorderPadding.LeftRight();
aDesiredSize.height = aReflowState.ComputedHeight() +
aReflowState.mComputedBorderPadding.TopBottom();
aDesiredSize.height = NS_CSS_MINMAX(aDesiredSize.height,
aReflowState.mComputedMinHeight,
aReflowState.mComputedMaxHeight);
aDesiredSize.SetOverflowAreasToDesiredBounds();
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, barFrame);
FinishAndStoreOverflow(&aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return NS_OK;
}
示例5: clone
// Helper-function that lets us clone the button's reflow state, but with its
// ComputedWidth and ComputedHeight reduced by the amount of renderer-specific
// focus border and padding that we're using. (This lets us provide a more
// appropriate content-box size for descendents' percent sizes to resolve
// against.)
static nsHTMLReflowState
CloneReflowStateWithReducedContentBox(
const nsHTMLReflowState& aButtonReflowState,
const nsMargin& aFocusPadding)
{
nscoord adjustedWidth =
aButtonReflowState.ComputedWidth() - aFocusPadding.LeftRight();
adjustedWidth = std::max(0, adjustedWidth);
// (Only adjust height if it's an actual length.)
nscoord adjustedHeight = aButtonReflowState.ComputedHeight();
if (adjustedHeight != NS_INTRINSICSIZE) {
adjustedHeight -= aFocusPadding.TopBottom();
adjustedHeight = std::max(0, adjustedHeight);
}
nsHTMLReflowState clone(aButtonReflowState);
clone.SetComputedWidth(adjustedWidth);
clone.SetComputedHeight(adjustedHeight);
return clone;
}
示例6: an
static nscoord
FloatMarginWidth(const nsHTMLReflowState& aCBReflowState,
nscoord aFloatAvailableWidth,
nsIFrame *aFloat,
const nsCSSOffsetState& aFloatOffsetState)
{
AutoMaybeDisableFontInflation an(aFloat);
return aFloat->ComputeSize(
aCBReflowState.rendContext,
nsSize(aCBReflowState.ComputedWidth(),
aCBReflowState.ComputedHeight()),
aFloatAvailableWidth,
nsSize(aFloatOffsetState.ComputedPhysicalMargin().LeftRight(),
aFloatOffsetState.ComputedPhysicalMargin().TopBottom()),
nsSize(aFloatOffsetState.ComputedPhysicalBorderPadding().LeftRight() -
aFloatOffsetState.ComputedPhysicalPadding().LeftRight(),
aFloatOffsetState.ComputedPhysicalBorderPadding().TopBottom() -
aFloatOffsetState.ComputedPhysicalPadding().TopBottom()),
nsSize(aFloatOffsetState.ComputedPhysicalPadding().LeftRight(),
aFloatOffsetState.ComputedPhysicalPadding().TopBottom()),
true).width +
aFloatOffsetState.ComputedPhysicalMargin().LeftRight() +
aFloatOffsetState.ComputedPhysicalBorderPadding().LeftRight();
}
示例7: GetStyleColumn
nsColumnSetFrame::ReflowConfig
nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState)
{
const nsStyleColumn* colStyle = GetStyleColumn();
nscoord availContentWidth = GetAvailableContentWidth(aReflowState);
if (aReflowState.ComputedWidth() != NS_INTRINSICSIZE) {
availContentWidth = aReflowState.ComputedWidth();
}
nscoord colHeight = GetAvailableContentHeight(aReflowState);
if (aReflowState.ComputedHeight() != NS_INTRINSICSIZE) {
colHeight = aReflowState.ComputedHeight();
}
nscoord colGap = GetColumnGap(this, colStyle);
PRInt32 numColumns = colStyle->mColumnCount;
const PRUint32 MAX_NESTED_COLUMN_BALANCING = 2;
PRUint32 cnt = 1;
for (const nsHTMLReflowState* rs = aReflowState.parentReflowState; rs && cnt
< MAX_NESTED_COLUMN_BALANCING; rs = rs->parentReflowState) {
if (rs->mFlags.mIsColumnBalancing) {
++cnt;
}
}
if (cnt == MAX_NESTED_COLUMN_BALANCING) {
numColumns = 1;
}
nscoord colWidth;
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
colWidth = colStyle->mColumnWidth.GetCoordValue();
NS_ASSERTION(colWidth >= 0, "negative column width");
// Reduce column count if necessary to make columns fit in the
// available width. Compute max number of columns that fit in
// availContentWidth, satisfying colGap*(maxColumns - 1) +
// colWidth*maxColumns <= availContentWidth
if (availContentWidth != NS_INTRINSICSIZE && colGap + colWidth > 0
&& numColumns > 0) {
// This expression uses truncated rounding, which is what we
// want
PRInt32 maxColumns = (availContentWidth + colGap)/(colGap + colWidth);
numColumns = NS_MAX(1, NS_MIN(numColumns, maxColumns));
}
} else if (numColumns > 0 && availContentWidth != NS_INTRINSICSIZE) {
nscoord widthMinusGaps = availContentWidth - colGap*(numColumns - 1);
colWidth = widthMinusGaps/numColumns;
} else {
colWidth = NS_INTRINSICSIZE;
}
// Take care of the situation where there's only one column but it's
// still too wide
colWidth = NS_MAX(1, NS_MIN(colWidth, availContentWidth));
nscoord expectedWidthLeftOver = 0;
if (colWidth != NS_INTRINSICSIZE && availContentWidth != NS_INTRINSICSIZE) {
// distribute leftover space
// First, determine how many columns will be showing if the column
// count is auto
if (numColumns <= 0) {
// choose so that colGap*(nominalColumnCount - 1) +
// colWidth*nominalColumnCount is nearly availContentWidth
// make sure to round down
if (colGap + colWidth > 0) {
numColumns = (availContentWidth + colGap)/(colGap + colWidth);
}
if (numColumns <= 0) {
numColumns = 1;
}
}
// Compute extra space and divide it among the columns
nscoord extraSpace =
NS_MAX(0, availContentWidth - (colWidth*numColumns + colGap*(numColumns - 1)));
nscoord extraToColumns = extraSpace/numColumns;
colWidth += extraToColumns;
expectedWidthLeftOver = extraSpace - (extraToColumns*numColumns);
}
// NOTE that the non-balancing behavior for non-auto computed height
// is not in the CSS3 columns draft as of 18 January 2001
if (aReflowState.ComputedHeight() == NS_INTRINSICSIZE) {
// Balancing!
if (numColumns <= 0) {
// Hmm, auto column count, column width or available width is unknown,
// and balancing is required. Let's just use one column then.
numColumns = 1;
}
colHeight = NS_MIN(mLastBalanceHeight, GetAvailableContentHeight(aReflowState));
} else {
// No balancing, so don't limit the column count
numColumns = PR_INT32_MAX;
}
#ifdef DEBUG_roc
printf("*** nsColumnSetFrame::ChooseColumnStrategy: numColumns=%d, colWidth=%d, expectedWidthLeftOver=%d, colHeight=%d, colGap=%d\n",
numColumns, colWidth, expectedWidthLeftOver, colHeight, colGap);
#endif
ReflowConfig config = { numColumns, colWidth, expectedWidthLeftOver, colGap, colHeight };
//.........这里部分代码省略.........
示例8: contentRect
//.........这里部分代码省略.........
&& child->GetScrollableOverflowRect().YMost() <= aConfig.mColMaxHeight;
nscoord childContentBottom = 0;
if (!reflowNext && (skipIncremental || skipResizeHeightShrink)) {
// This child does not need to be reflowed, but we may need to move it
MoveChildTo(this, child, childOrigin);
// If this is the last frame then make sure we get the right status
nsIFrame* kidNext = child->GetNextSibling();
if (kidNext) {
aStatus = (kidNext->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)
? NS_FRAME_OVERFLOW_INCOMPLETE
: NS_FRAME_NOT_COMPLETE;
} else {
aStatus = mLastFrameStatus;
}
childContentBottom = nsLayoutUtils::CalculateContentBottom(child);
#ifdef DEBUG_roc
printf("*** Skipping child #%d %p (incremental %d, resize height shrink %d): status = %d\n",
columnCount, (void*)child, skipIncremental, skipResizeHeightShrink, aStatus);
#endif
} else {
nsSize availSize(aConfig.mColWidth, aConfig.mColMaxHeight);
if (aUnboundedLastColumn && columnCount == aConfig.mBalanceColCount - 1) {
availSize.height = GetAvailableContentHeight(aReflowState);
}
if (reflowNext)
child->AddStateBits(NS_FRAME_IS_DIRTY);
nsHTMLReflowState kidReflowState(PresContext(), aReflowState, child,
availSize, availSize.width,
aReflowState.ComputedHeight());
kidReflowState.mFlags.mIsTopOfPage = true;
kidReflowState.mFlags.mTableIsSplittable = false;
kidReflowState.mFlags.mIsColumnBalancing = aConfig.mBalanceColCount < PR_INT32_MAX;
#ifdef DEBUG_roc
printf("*** Reflowing child #%d %p: availHeight=%d\n",
columnCount, (void*)child,availSize.height);
#endif
// Note if the column's next in flow is not being changed by this incremental reflow.
// This may allow the current column to avoid trying to pull lines from the next column.
if (child->GetNextSibling() &&
!(GetStateBits() & NS_FRAME_IS_DIRTY) &&
!(child->GetNextSibling()->GetStateBits() & NS_FRAME_IS_DIRTY)) {
kidReflowState.mFlags.mNextInFlowUntouched = true;
}
nsHTMLReflowMetrics kidDesiredSize(aDesiredSize.mFlags);
// XXX it would be cool to consult the float manager for the
// previous block to figure out the region of floats from the
// previous column that extend into this column, and subtract
// that region from the new float manager. So you could stick a
// really big float in the first column and text in following
// columns would flow around it.
// Reflow the frame
ReflowChild(child, PresContext(), kidDesiredSize, kidReflowState,
childOrigin.x + kidReflowState.mComputedMargin.left,
childOrigin.y + kidReflowState.mComputedMargin.top,
0, aStatus);
示例9: mBlock
nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState,
nsPresContext* aPresContext,
nsBlockFrame* aFrame,
bool aBStartMarginRoot,
bool aBEndMarginRoot,
bool aBlockNeedsFloatManager,
nscoord aConsumedBSize)
: mBlock(aFrame),
mPresContext(aPresContext),
mReflowState(aReflowState),
mContentArea(aReflowState.GetWritingMode()),
mPushedFloats(nullptr),
mOverflowTracker(nullptr),
mBorderPadding(mReflowState.ComputedLogicalBorderPadding()),
mPrevBEndMargin(),
mLineNumber(0),
mFlags(0),
mFloatBreakType(NS_STYLE_CLEAR_NONE),
mConsumedBSize(aConsumedBSize)
{
if (!sFloatFragmentsInsideColumnPrefCached) {
sFloatFragmentsInsideColumnPrefCached = true;
Preferences::AddBoolVarCache(&sFloatFragmentsInsideColumnEnabled,
"layout.float-fragments-inside-column.enabled");
}
SetFlag(BRS_FLOAT_FRAGMENTS_INSIDE_COLUMN_ENABLED, sFloatFragmentsInsideColumnEnabled);
WritingMode wm = aReflowState.GetWritingMode();
SetFlag(BRS_ISFIRSTINFLOW, aFrame->GetPrevInFlow() == nullptr);
SetFlag(BRS_ISOVERFLOWCONTAINER, IS_TRUE_OVERFLOW_CONTAINER(aFrame));
nsIFrame::LogicalSides logicalSkipSides =
aFrame->GetLogicalSkipSides(&aReflowState);
mBorderPadding.ApplySkipSides(logicalSkipSides);
// Note that mContainerSize is the physical size, needed to
// convert logical block-coordinates in vertical-rl writing mode
// (measured from a RHS origin) to physical coordinates within the
// containing block.
// If aReflowState doesn't have a constrained ComputedWidth(), we set
// mContainerSize.width to zero, which means lines will be positioned
// (physically) incorrectly; we will fix them up at the end of
// nsBlockFrame::Reflow, after we know the total block-size of the
// frame.
mContainerSize.width = aReflowState.ComputedWidth();
if (mContainerSize.width == NS_UNCONSTRAINEDSIZE) {
mContainerSize.width = 0;
}
mContainerSize.width += mBorderPadding.LeftRight(wm);
// For now at least, we don't do that fix-up for mContainerHeight.
// It's only used in nsBidiUtils::ReorderFrames for vertical rtl
// writing modes, which aren't fully supported for the time being.
mContainerSize.height = aReflowState.ComputedHeight() +
mBorderPadding.TopBottom(wm);
if ((aBStartMarginRoot && !logicalSkipSides.BStart()) ||
0 != mBorderPadding.BStart(wm)) {
SetFlag(BRS_ISBSTARTMARGINROOT, true);
SetFlag(BRS_APPLYBSTARTMARGIN, true);
}
if ((aBEndMarginRoot && !logicalSkipSides.BEnd()) ||
0 != mBorderPadding.BEnd(wm)) {
SetFlag(BRS_ISBENDMARGINROOT, true);
}
if (aBlockNeedsFloatManager) {
SetFlag(BRS_FLOAT_MGR, true);
}
mFloatManager = aReflowState.mFloatManager;
NS_ASSERTION(mFloatManager,
"FloatManager should be set in nsBlockReflowState" );
if (mFloatManager) {
// Save the coordinate system origin for later.
mFloatManager->GetTranslation(mFloatManagerI, mFloatManagerB);
mFloatManager->PushState(&mFloatManagerStateBefore); // never popped
}
mReflowStatus = NS_FRAME_COMPLETE;
mNextInFlow = static_cast<nsBlockFrame*>(mBlock->GetNextInFlow());
LAYOUT_WARN_IF_FALSE(NS_UNCONSTRAINEDSIZE != aReflowState.ComputedISize(),
"have unconstrained width; this should only result "
"from very large sizes, not attempts at intrinsic "
"width calculation");
mContentArea.ISize(wm) = aReflowState.ComputedISize();
// Compute content area height. Unlike the width, if we have a
// specified style height we ignore it since extra content is
// managed by the "overflow" property. When we don't have a
// specified style height then we may end up limiting our height if
// the availableHeight is constrained (this situation occurs when we
// are paginated).
if (NS_UNCONSTRAINEDSIZE != aReflowState.AvailableBSize()) {
// We are in a paginated situation. The bottom edge is just inside
// the bottom border and padding. The content area height doesn't
// include either border or padding edge.
//.........这里部分代码省略.........
示例10: indent
void
nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
const nsRect& aContainingBlock,
bool aConstrainHeight,
nsIFrame* aKidFrame,
nsReflowStatus& aStatus,
nsOverflowAreas* aOverflowAreas)
{
#ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) {
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent);
printf("abs pos ");
if (aKidFrame) {
nsAutoString name;
aKidFrame->GetFrameName(name);
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
}
char width[16];
char height[16];
PrettyUC(aReflowState.AvailableWidth(), width);
PrettyUC(aReflowState.AvailableHeight(), height);
printf(" a=%s,%s ", width, height);
PrettyUC(aReflowState.ComputedWidth(), width);
PrettyUC(aReflowState.ComputedHeight(), height);
printf("c=%s,%s \n", width, height);
}
AutoNoisyIndenter indent(nsBlockFrame::gNoisy);
#endif // DEBUG
WritingMode wm = aKidFrame->GetWritingMode();
nscoord availISize = LogicalSize(wm, aContainingBlock.Size()).ISize(wm);
if (availISize == -1) {
NS_ASSERTION(aReflowState.ComputedSize(wm).ISize(wm) !=
NS_UNCONSTRAINEDSIZE,
"Must have a useful inline-size _somewhere_");
availISize =
aReflowState.ComputedSizeWithPadding(wm).ISize(wm);
}
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
LogicalSize(wm, availISize,
NS_UNCONSTRAINEDSIZE),
aContainingBlock.width,
aContainingBlock.height);
// Get the border values
const nsMargin& border = aReflowState.mStyleBorder->GetComputedBorder();
bool constrainHeight = (aReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE)
&& aConstrainHeight
// Don't split if told not to (e.g. for fixed frames)
&& (aDelegatingFrame->GetType() != nsGkAtoms::inlineFrame)
//XXX we don't handle splitting frames for inline absolute containing blocks yet
&& (aKidFrame->GetRect().y <= aReflowState.AvailableHeight());
// Don't split things below the fold. (Ideally we shouldn't *have*
// anything totally below the fold, but we can't position frames
// across next-in-flow breaks yet.
if (constrainHeight) {
kidReflowState.AvailableHeight() = aReflowState.AvailableHeight() - border.top
- kidReflowState.ComputedPhysicalMargin().top;
if (NS_AUTOOFFSET != kidReflowState.ComputedPhysicalOffsets().top)
kidReflowState.AvailableHeight() -= kidReflowState.ComputedPhysicalOffsets().top;
}
// Do the reflow
aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
// If we're solving for 'left' or 'top', then compute it now that we know the
// width/height
if ((NS_AUTOOFFSET == kidReflowState.ComputedPhysicalOffsets().left) ||
(NS_AUTOOFFSET == kidReflowState.ComputedPhysicalOffsets().top)) {
nscoord aContainingBlockWidth = aContainingBlock.width;
nscoord aContainingBlockHeight = aContainingBlock.height;
if (-1 == aContainingBlockWidth) {
// Get the containing block width/height
kidReflowState.ComputeContainingBlockRectangle(aPresContext,
&aReflowState,
aContainingBlockWidth,
aContainingBlockHeight);
}
if (NS_AUTOOFFSET == kidReflowState.ComputedPhysicalOffsets().left) {
NS_ASSERTION(NS_AUTOOFFSET != kidReflowState.ComputedPhysicalOffsets().right,
"Can't solve for both left and right");
kidReflowState.ComputedPhysicalOffsets().left = aContainingBlockWidth -
kidReflowState.ComputedPhysicalOffsets().right -
kidReflowState.ComputedPhysicalMargin().right -
kidDesiredSize.Width() -
kidReflowState.ComputedPhysicalMargin().left;
}
if (NS_AUTOOFFSET == kidReflowState.ComputedPhysicalOffsets().top) {
kidReflowState.ComputedPhysicalOffsets().top = aContainingBlockHeight -
kidReflowState.ComputedPhysicalOffsets().bottom -
kidReflowState.ComputedPhysicalMargin().bottom -
kidDesiredSize.Height() -
//.........这里部分代码省略.........
示例11: reflowState
void
nsProgressFrame::ReflowBarFrame(nsIFrame* aBarFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
bool vertical = GetStyleDisplay()->mOrient == NS_STYLE_ORIENT_VERTICAL;
nsHTMLReflowState reflowState(aPresContext, aReflowState, aBarFrame,
nsSize(aReflowState.ComputedWidth(),
NS_UNCONSTRAINEDSIZE));
nscoord size = vertical ? aReflowState.ComputedHeight()
: aReflowState.ComputedWidth();
nscoord xoffset = aReflowState.mComputedBorderPadding.left;
nscoord yoffset = aReflowState.mComputedBorderPadding.top;
double position;
nsCOMPtr<nsIDOMHTMLProgressElement> progressElement =
do_QueryInterface(mContent);
progressElement->GetPosition(&position);
// Force the bar's size to match the current progress.
// When indeterminate, the progress' size will be 100%.
if (position >= 0.0) {
size *= position;
}
if (!vertical && GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
xoffset += aReflowState.ComputedWidth() - size;
}
// The bar size is fixed in these cases:
// - the progress position is determined: the bar size is fixed according
// to it's value.
// - the progress position is indeterminate and the bar appearance should be
// shown as native: the bar size is forced to 100%.
// Otherwise (when the progress is indeterminate and the bar appearance isn't
// native), the bar size isn't fixed and can be set by the author.
if (position != -1 || ShouldUseNativeStyle()) {
if (vertical) {
// We want the bar to begin at the bottom.
yoffset += aReflowState.ComputedHeight() - size;
size -= reflowState.mComputedMargin.TopBottom() +
reflowState.mComputedBorderPadding.TopBottom();
size = NS_MAX(size, 0);
reflowState.SetComputedHeight(size);
} else {
size -= reflowState.mComputedMargin.LeftRight() +
reflowState.mComputedBorderPadding.LeftRight();
size = NS_MAX(size, 0);
reflowState.SetComputedWidth(size);
}
} else if (vertical) {
// For vertical progress bars, we need to position the bar specificly when
// the width isn't constrained (position == -1 and !ShouldUseNativeStyle())
// because aReflowState.ComputedHeight() - size == 0.
yoffset += aReflowState.ComputedHeight() - reflowState.ComputedHeight();
}
xoffset += reflowState.mComputedMargin.left;
yoffset += reflowState.mComputedMargin.top;
nsHTMLReflowMetrics barDesiredSize;
ReflowChild(aBarFrame, aPresContext, barDesiredSize, reflowState, xoffset,
yoffset, 0, aStatus);
FinishReflowChild(aBarFrame, aPresContext, &reflowState, barDesiredSize,
xoffset, yoffset, 0);
}
示例12: indent
void
nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
const nsRect& aContainingBlock,
AbsPosReflowFlags aFlags,
nsIFrame* aKidFrame,
nsReflowStatus& aStatus,
nsOverflowAreas* aOverflowAreas)
{
#ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) {
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent);
printf("abs pos ");
if (aKidFrame) {
nsAutoString name;
aKidFrame->GetFrameName(name);
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
}
char width[16];
char height[16];
PrettyUC(aReflowState.AvailableWidth(), width, 16);
PrettyUC(aReflowState.AvailableHeight(), height, 16);
printf(" a=%s,%s ", width, height);
PrettyUC(aReflowState.ComputedWidth(), width, 16);
PrettyUC(aReflowState.ComputedHeight(), height, 16);
printf("c=%s,%s \n", width, height);
}
AutoNoisyIndenter indent(nsBlockFrame::gNoisy);
#endif // DEBUG
WritingMode wm = aKidFrame->GetWritingMode();
LogicalSize logicalCBSize(wm, aContainingBlock.Size());
nscoord availISize = logicalCBSize.ISize(wm);
if (availISize == -1) {
NS_ASSERTION(aReflowState.ComputedSize(wm).ISize(wm) !=
NS_UNCONSTRAINEDSIZE,
"Must have a useful inline-size _somewhere_");
availISize =
aReflowState.ComputedSizeWithPadding(wm).ISize(wm);
}
uint32_t rsFlags = 0;
if (aFlags & AbsPosReflowFlags::eIsGridContainerCB) {
// When a grid container generates the abs.pos. CB for a *child* then
// the static-position is the CB origin (i.e. of the grid area rect).
// https://drafts.csswg.org/css-grid/#static-position
nsIFrame* placeholder =
aPresContext->PresShell()->GetPlaceholderFrameFor(aKidFrame);
if (placeholder && placeholder->GetParent() == aDelegatingFrame) {
rsFlags |= nsHTMLReflowState::STATIC_POS_IS_CB_ORIGIN;
}
}
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
LogicalSize(wm, availISize,
NS_UNCONSTRAINEDSIZE),
&logicalCBSize, rsFlags);
// Get the border values
WritingMode outerWM = aReflowState.GetWritingMode();
const LogicalMargin border(outerWM,
aReflowState.mStyleBorder->GetComputedBorder());
const LogicalMargin margin =
kidReflowState.ComputedLogicalMargin().ConvertTo(outerWM, wm);
bool constrainBSize = (aReflowState.AvailableBSize() != NS_UNCONSTRAINEDSIZE)
&& (aFlags & AbsPosReflowFlags::eConstrainHeight)
// Don't split if told not to (e.g. for fixed frames)
&& (aDelegatingFrame->GetType() != nsGkAtoms::inlineFrame)
//XXX we don't handle splitting frames for inline absolute containing blocks yet
&& (aKidFrame->GetLogicalRect(aContainingBlock.Size()).BStart(wm) <=
aReflowState.AvailableBSize());
// Don't split things below the fold. (Ideally we shouldn't *have*
// anything totally below the fold, but we can't position frames
// across next-in-flow breaks yet.
if (constrainBSize) {
kidReflowState.AvailableBSize() =
aReflowState.AvailableBSize() - border.ConvertTo(wm, outerWM).BStart(wm) -
kidReflowState.ComputedLogicalMargin().BStart(wm);
if (NS_AUTOOFFSET != kidReflowState.ComputedLogicalOffsets().BStart(wm)) {
kidReflowState.AvailableBSize() -=
kidReflowState.ComputedLogicalOffsets().BStart(wm);
}
}
// Do the reflow
nsHTMLReflowMetrics kidDesiredSize(kidReflowState);
aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
const LogicalSize kidSize = kidDesiredSize.Size(wm).ConvertTo(outerWM, wm);
LogicalMargin offsets =
kidReflowState.ComputedLogicalOffsets().ConvertTo(outerWM, wm);
// If we're solving for start in either inline or block direction,
// then compute it now that we know the dimensions.
if ((NS_AUTOOFFSET == offsets.IStart(outerWM)) ||
(NS_AUTOOFFSET == offsets.BStart(outerWM))) {
if (-1 == logicalCBSize.ISize(wm)) {
// Get the containing block width/height
//.........这里部分代码省略.........
示例13: trackReflowState
void
nsRangeFrame::ReflowAnonymousContent(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState)
{
// The width/height of our content box, which is the available width/height
// for our anonymous content:
nscoord rangeFrameContentBoxWidth = aReflowState.ComputedWidth();
nscoord rangeFrameContentBoxHeight = aReflowState.ComputedHeight();
if (rangeFrameContentBoxHeight == NS_AUTOHEIGHT) {
rangeFrameContentBoxHeight = 0;
}
nsIFrame* trackFrame = mTrackDiv->GetPrimaryFrame();
if (trackFrame) { // display:none?
// Position the track:
// The idea here is that we allow content authors to style the width,
// height, border and padding of the track, but we ignore margin and
// positioning properties and do the positioning ourself to keep the center
// of the track's border box on the center of the nsRangeFrame's content
// box.
nsHTMLReflowState trackReflowState(aPresContext, aReflowState, trackFrame,
nsSize(aReflowState.ComputedWidth(),
NS_UNCONSTRAINEDSIZE));
// Find the x/y position of the track frame such that it will be positioned
// as described above. These coordinates are with respect to the
// nsRangeFrame's border-box.
nscoord trackX = rangeFrameContentBoxWidth / 2;
nscoord trackY = rangeFrameContentBoxHeight / 2;
// Account for the track's border and padding (we ignore its margin):
trackX -= trackReflowState.ComputedPhysicalBorderPadding().left +
trackReflowState.ComputedWidth() / 2;
trackY -= trackReflowState.ComputedPhysicalBorderPadding().top +
trackReflowState.ComputedHeight() / 2;
// Make relative to our border box instead of our content box:
trackX += aReflowState.ComputedPhysicalBorderPadding().left;
trackY += aReflowState.ComputedPhysicalBorderPadding().top;
nsReflowStatus frameStatus;
nsHTMLReflowMetrics trackDesiredSize(aReflowState);
ReflowChild(trackFrame, aPresContext, trackDesiredSize,
trackReflowState, trackX, trackY, 0, frameStatus);
MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(frameStatus),
"We gave our child unconstrained height, so it should be complete");
FinishReflowChild(trackFrame, aPresContext, trackDesiredSize,
&trackReflowState, trackX, trackY, 0);
}
nsIFrame* thumbFrame = mThumbDiv->GetPrimaryFrame();
if (thumbFrame) { // display:none?
nsHTMLReflowState thumbReflowState(aPresContext, aReflowState, thumbFrame,
nsSize(aReflowState.ComputedWidth(),
NS_UNCONSTRAINEDSIZE));
// Where we position the thumb depends on its size, so we first reflow
// the thumb at {0,0} to obtain its size, then position it afterwards.
nsReflowStatus frameStatus;
nsHTMLReflowMetrics thumbDesiredSize(aReflowState);
ReflowChild(thumbFrame, aPresContext, thumbDesiredSize,
thumbReflowState, 0, 0, 0, frameStatus);
MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(frameStatus),
"We gave our child unconstrained height, so it should be complete");
FinishReflowChild(thumbFrame, aPresContext, thumbDesiredSize,
&thumbReflowState, 0, 0, 0);
DoUpdateThumbPosition(thumbFrame, nsSize(aDesiredSize.Width(),
aDesiredSize.Height()));
}
nsIFrame* rangeProgressFrame = mProgressDiv->GetPrimaryFrame();
if (rangeProgressFrame) { // display:none?
nsHTMLReflowState progressReflowState(aPresContext, aReflowState,
rangeProgressFrame,
nsSize(aReflowState.ComputedWidth(),
NS_UNCONSTRAINEDSIZE));
// We first reflow the range-progress frame at {0,0} to obtain its
// unadjusted dimensions, then we adjust it to so that the appropriate edge
// ends at the thumb.
nsReflowStatus frameStatus;
nsHTMLReflowMetrics progressDesiredSize(aReflowState);
ReflowChild(rangeProgressFrame, aPresContext,
progressDesiredSize, progressReflowState, 0, 0,
0, frameStatus);
MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(frameStatus),
"We gave our child unconstrained height, so it should be complete");
FinishReflowChild(rangeProgressFrame, aPresContext,
progressDesiredSize, &progressReflowState, 0, 0, 0);
DoUpdateRangeProgressFrame(rangeProgressFrame, nsSize(aDesiredSize.Width(),
aDesiredSize.Height()));
}
//.........这里部分代码省略.........
示例14: state
void
nsLeafBoxFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// This is mostly a copy of nsBoxFrame::Reflow().
// We aren't able to share an implementation because of the frame
// class hierarchy. If you make changes here, please keep
// nsBoxFrame::Reflow in sync.
DO_GLOBAL_REFLOW_COUNT("nsLeafBoxFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_ASSERTION(aReflowState.ComputedWidth() >=0 &&
aReflowState.ComputedHeight() >= 0, "Computed Size < 0");
#ifdef DO_NOISY_REFLOW
printf("\n-------------Starting LeafBoxFrame Reflow ----------------------------\n");
printf("%p ** nsLBF::Reflow %d R: ", this, myCounter++);
switch (aReflowState.reason) {
case eReflowReason_Initial:
printf("Ini");break;
case eReflowReason_Incremental:
printf("Inc");break;
case eReflowReason_Resize:
printf("Rsz");break;
case eReflowReason_StyleChange:
printf("Sty");break;
case eReflowReason_Dirty:
printf("Drt ");
break;
default:printf("<unknown>%d", aReflowState.reason);break;
}
printSize("AW", aReflowState.AvailableWidth());
printSize("AH", aReflowState.AvailableHeight());
printSize("CW", aReflowState.ComputedWidth());
printSize("CH", aReflowState.ComputedHeight());
printf(" *\n");
#endif
aStatus = NS_FRAME_COMPLETE;
// create the layout state
nsBoxLayoutState state(aPresContext, aReflowState.rendContext);
nsSize computedSize(aReflowState.ComputedWidth(),aReflowState.ComputedHeight());
nsMargin m;
m = aReflowState.ComputedPhysicalBorderPadding();
//GetBorderAndPadding(m);
// this happens sometimes. So lets handle it gracefully.
if (aReflowState.ComputedHeight() == 0) {
nsSize minSize = GetMinSize(state);
computedSize.height = minSize.height - m.top - m.bottom;
}
nsSize prefSize(0,0);
// if we are told to layout intrinic then get our preferred size.
if (computedSize.width == NS_INTRINSICSIZE || computedSize.height == NS_INTRINSICSIZE) {
prefSize = GetPrefSize(state);
nsSize minSize = GetMinSize(state);
nsSize maxSize = GetMaxSize(state);
prefSize = BoundsCheck(minSize, prefSize, maxSize);
}
// get our desiredSize
if (aReflowState.ComputedWidth() == NS_INTRINSICSIZE) {
computedSize.width = prefSize.width;
} else {
computedSize.width += m.left + m.right;
}
if (aReflowState.ComputedHeight() == NS_INTRINSICSIZE) {
computedSize.height = prefSize.height;
} else {
computedSize.height += m.top + m.bottom;
}
// handle reflow state min and max sizes
// XXXbz the width handling here seems to be wrong, since
// mComputedMin/MaxWidth is a content-box size, whole
// computedSize.width is a border-box size...
if (computedSize.width > aReflowState.ComputedMaxWidth())
computedSize.width = aReflowState.ComputedMaxWidth();
if (computedSize.width < aReflowState.ComputedMinWidth())
computedSize.width = aReflowState.ComputedMinWidth();
// Now adjust computedSize.height for our min and max computed
// height. The only problem is that those are content-box sizes,
// while computedSize.height is a border-box size. So subtract off
// m.TopBottom() before adjusting, then readd it.
computedSize.height = std::max(0, computedSize.height - m.TopBottom());
//.........这里部分代码省略.........
示例15: indent
nsresult
nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nscoord aContainingBlockWidth,
nscoord aContainingBlockHeight,
PRBool aConstrainHeight,
nsIFrame* aKidFrame,
nsReflowStatus& aStatus,
nsOverflowAreas* aOverflowAreas)
{
#ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) {
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent);
printf("abs pos ");
if (aKidFrame) {
nsAutoString name;
aKidFrame->GetFrameName(name);
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
}
char width[16];
char height[16];
PrettyUC(aReflowState.availableWidth, width);
PrettyUC(aReflowState.availableHeight, height);
printf(" a=%s,%s ", width, height);
PrettyUC(aReflowState.ComputedWidth(), width);
PrettyUC(aReflowState.ComputedHeight(), height);
printf("c=%s,%s \n", width, height);
}
AutoNoisyIndenter indent(nsBlockFrame::gNoisy);
#endif // DEBUG
// Store position and overflow rect so taht we can invalidate the correct
// area if the position changes
nsRect oldOverflowRect(aKidFrame->GetVisualOverflowRect() +
aKidFrame->GetPosition());
nsRect oldRect = aKidFrame->GetRect();
nsresult rv;
// Get the border values
const nsMargin& border = aReflowState.mStyleBorder->GetActualBorder();
nscoord availWidth = aContainingBlockWidth;
if (availWidth == -1) {
NS_ASSERTION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
"Must have a useful width _somewhere_");
availWidth =
aReflowState.ComputedWidth() + aReflowState.mComputedPadding.LeftRight();
}
nsHTMLReflowMetrics kidDesiredSize;
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
nsSize(availWidth, NS_UNCONSTRAINEDSIZE),
aContainingBlockWidth,
aContainingBlockHeight);
// Send the WillReflow() notification and position the frame
aKidFrame->WillReflow(aPresContext);
PRBool constrainHeight = (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE)
&& aConstrainHeight
// Don't split if told not to (e.g. for fixed frames)
&& (aDelegatingFrame->GetType() != nsGkAtoms::positionedInlineFrame)
//XXX we don't handle splitting frames for inline absolute containing blocks yet
&& (aKidFrame->GetRect().y <= aReflowState.availableHeight);
// Don't split things below the fold. (Ideally we shouldn't *have*
// anything totally below the fold, but we can't position frames
// across next-in-flow breaks yet.
if (constrainHeight) {
kidReflowState.availableHeight = aReflowState.availableHeight - border.top
- kidReflowState.mComputedMargin.top;
if (NS_AUTOOFFSET != kidReflowState.mComputedOffsets.top)
kidReflowState.availableHeight -= kidReflowState.mComputedOffsets.top;
}
// Do the reflow
rv = aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
// If we're solving for 'left' or 'top', then compute it now that we know the
// width/height
if ((NS_AUTOOFFSET == kidReflowState.mComputedOffsets.left) ||
(NS_AUTOOFFSET == kidReflowState.mComputedOffsets.top)) {
if (-1 == aContainingBlockWidth) {
// Get the containing block width/height
kidReflowState.ComputeContainingBlockRectangle(aPresContext,
&aReflowState,
aContainingBlockWidth,
aContainingBlockHeight);
}
if (NS_AUTOOFFSET == kidReflowState.mComputedOffsets.left) {
NS_ASSERTION(NS_AUTOOFFSET != kidReflowState.mComputedOffsets.right,
"Can't solve for both left and right");
kidReflowState.mComputedOffsets.left = aContainingBlockWidth -
kidReflowState.mComputedOffsets.right -
kidReflowState.mComputedMargin.right -
kidDesiredSize.width -
kidReflowState.mComputedMargin.left;
}
//.........这里部分代码省略.........