本文整理汇总了C++中nsHTMLReflowState::ComputedSizeAsContainerIfConstrained方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowState::ComputedSizeAsContainerIfConstrained方法的具体用法?C++ nsHTMLReflowState::ComputedSizeAsContainerIfConstrained怎么用?C++ nsHTMLReflowState::ComputedSizeAsContainerIfConstrained使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowState
的用法示例。
在下文中一共展示了nsHTMLReflowState::ComputedSizeAsContainerIfConstrained方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contentRect
bool
nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
const ReflowConfig& aConfig,
bool aUnboundedLastColumn,
nsCollapsingMargin* aCarriedOutBEndMargin,
ColumnBalanceData& aColData)
{
aColData.Reset();
bool allFit = true;
WritingMode wm = GetWritingMode();
bool isVertical = wm.IsVertical();
bool isRTL = !wm.IsBidiLTR();
bool shrinkingBSizeOnly = !NS_SUBTREE_DIRTY(this) &&
mLastBalanceBSize > aConfig.mColMaxBSize;
#ifdef DEBUG_roc
printf("*** Doing column reflow pass: mLastBalanceBSize=%d, mColMaxBSize=%d, RTL=%d\n"
" mBalanceColCount=%d, mColISize=%d, mColGap=%d\n",
mLastBalanceBSize, aConfig.mColMaxBSize, isRTL, aConfig.mBalanceColCount,
aConfig.mColISize, aConfig.mColGap);
#endif
DrainOverflowColumns();
const bool colBSizeChanged = mLastBalanceBSize != aConfig.mColMaxBSize;
if (colBSizeChanged) {
mLastBalanceBSize = aConfig.mColMaxBSize;
// XXX Seems like this could fire if incremental reflow pushed the column set
// down so we reflow incrementally with a different available height.
// We need a way to do an incremental reflow and be sure availableHeight
// changes are taken account of! Right now I think block frames with absolute
// children might exit early.
//NS_ASSERTION(aKidReason != eReflowReason_Incremental,
// "incremental reflow should not have changed the balance height");
}
// get our border and padding
LogicalMargin borderPadding = aReflowState.ComputedLogicalBorderPadding();
borderPadding.ApplySkipSides(GetLogicalSkipSides(&aReflowState));
nsRect contentRect(0, 0, 0, 0);
nsOverflowAreas overflowRects;
nsIFrame* child = mFrames.FirstChild();
LogicalPoint childOrigin(wm, borderPadding.IStart(wm),
borderPadding.BStart(wm));
// In vertical-rl mode, columns will not be correctly placed if the
// reflowState's ComputedWidth() is UNCONSTRAINED (in which case we'll get
// a containerSize.width of zero here). In that case, the column positions
// will be adjusted later, after our correct contentSize is known.
nsSize containerSize = aReflowState.ComputedSizeAsContainerIfConstrained();
// For RTL, since the columns might not fill the frame exactly, we
// need to account for the slop. Otherwise we'll waste time moving the
// columns by some tiny amount
// XXX when all of layout is converted to logical coordinates, we
// probably won't need to do this hack any more. For now, we
// confine it to the legacy horizontal-rl case
if (!isVertical && isRTL) {
nscoord availISize = aReflowState.AvailableISize();
if (aReflowState.ComputedISize() != NS_INTRINSICSIZE) {
availISize = aReflowState.ComputedISize();
}
if (availISize != NS_INTRINSICSIZE) {
childOrigin.I(wm) = containerSize.width - borderPadding.Left(wm) -
availISize;
#ifdef DEBUG_roc
printf("*** childOrigin.iCoord = %d\n", childOrigin.I(wm));
#endif
}
}
int columnCount = 0;
int contentBEnd = 0;
bool reflowNext = false;
while (child) {
// Try to skip reflowing the child. We can't skip if the child is dirty. We also can't
// skip if the next column is dirty, because the next column's first line(s)
// might be pullable back to this column. We can't skip if it's the last child
// because we need to obtain the bottom margin. We can't skip
// if this is the last column and we're supposed to assign unbounded
// height to it, because that could change the available height from
// the last time we reflowed it and we should try to pull all the
// content from its next sibling. (Note that it might be the last
// column, but not be the last child because the desired number of columns
// has changed.)
bool skipIncremental = !aReflowState.ShouldReflowAllKids()
&& !NS_SUBTREE_DIRTY(child)
&& child->GetNextSibling()
&& !(aUnboundedLastColumn && columnCount == aConfig.mBalanceColCount - 1)
&& !NS_SUBTREE_DIRTY(child->GetNextSibling());
// If we need to pull up content from the prev-in-flow then this is not just
// a height shrink. The prev in flow will have set the dirty bit.
// Check the overflow rect YMost instead of just the child's content height. The child
// may have overflowing content that cares about the available height boundary.
//.........这里部分代码省略.........
示例2: availSize
void
nsTableCellFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsTableCellFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
if (aReflowState.mFlags.mSpecialBSizeReflow) {
FirstInFlow()->AddStateBits(NS_TABLE_CELL_HAD_SPECIAL_REFLOW);
}
// see if a special bsize reflow needs to occur due to having a pct height
nsTableFrame::CheckRequestSpecialBSizeReflow(aReflowState);
aStatus = NS_FRAME_COMPLETE;
WritingMode wm = aReflowState.GetWritingMode();
LogicalSize availSize(wm, aReflowState.AvailableISize(),
aReflowState.AvailableBSize());
LogicalMargin borderPadding = aReflowState.ComputedLogicalPadding();
LogicalMargin border = GetBorderWidth(wm);
borderPadding += border;
// reduce available space by insets, if we're in a constrained situation
availSize.ISize(wm) -= borderPadding.IStartEnd(wm);
if (NS_UNCONSTRAINEDSIZE != availSize.BSize(wm)) {
availSize.BSize(wm) -= borderPadding.BStartEnd(wm);
}
// Try to reflow the child into the available space. It might not
// fit or might need continuing.
if (availSize.BSize(wm) < 0) {
availSize.BSize(wm) = 1;
}
nsHTMLReflowMetrics kidSize(wm, aDesiredSize.mFlags);
kidSize.ClearSize();
SetPriorAvailISize(aReflowState.AvailableISize());
nsIFrame* firstKid = mFrames.FirstChild();
NS_ASSERTION(firstKid, "Frame construction error, a table cell always has an inner cell frame");
nsTableFrame* tableFrame = GetTableFrame();
if (aReflowState.mFlags.mSpecialBSizeReflow) {
const_cast<nsHTMLReflowState&>(aReflowState).
SetComputedBSize(BSize(wm) - borderPadding.BStartEnd(wm));
DISPLAY_REFLOW_CHANGE();
}
else if (aPresContext->IsPaginated()) {
nscoord computedUnpaginatedBSize =
CalcUnpaginatedBSize(aPresContext, (nsTableCellFrame&)*this,
*tableFrame, borderPadding.BStartEnd(wm));
if (computedUnpaginatedBSize > 0) {
const_cast<nsHTMLReflowState&>(aReflowState).SetComputedBSize(computedUnpaginatedBSize);
DISPLAY_REFLOW_CHANGE();
}
}
else {
SetHasPctOverBSize(false);
}
WritingMode kidWM = firstKid->GetWritingMode();
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, firstKid,
availSize.ConvertTo(kidWM, wm));
// Don't be a percent height observer if we're in the middle of
// special-bsize reflow, in case we get an accidental NotifyPercentBSize()
// call (which we shouldn't honor during special-bsize reflow)
if (!aReflowState.mFlags.mSpecialBSizeReflow) {
// mPercentBSizeObserver is for children of cells in quirks mode,
// but only those than are tables in standards mode. NeedsToObserve
// will determine how far this is propagated to descendants.
kidReflowState.mPercentBSizeObserver = this;
}
// Don't propagate special bsize reflow state to our kids
kidReflowState.mFlags.mSpecialBSizeReflow = false;
if (aReflowState.mFlags.mSpecialBSizeReflow ||
FirstInFlow()->HasAnyStateBits(NS_TABLE_CELL_HAD_SPECIAL_REFLOW)) {
// We need to force the kid to have mBResize set if we've had a
// special reflow in the past, since the non-special reflow needs to
// resize back to what it was without the special bsize reflow.
kidReflowState.SetBResize(true);
}
nsSize containerSize =
aReflowState.ComputedSizeAsContainerIfConstrained();
LogicalPoint kidOrigin(wm, borderPadding.IStart(wm),
borderPadding.BStart(wm));
nsRect origRect = firstKid->GetRect();
nsRect origVisualOverflow = firstKid->GetVisualOverflowRect();
bool firstReflow = firstKid->HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
ReflowChild(firstKid, aPresContext, kidSize, kidReflowState,
wm, kidOrigin, containerSize, 0, aStatus);
if (NS_FRAME_OVERFLOW_IS_INCOMPLETE(aStatus)) {
// Don't pass OVERFLOW_INCOMPLETE through tables until they can actually handle it
//.........这里部分代码省略.........
示例3: rect
void
nsMathMLmtableOuterFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
nsAutoString value;
// we want to return a table that is anchored according to the align attribute
nsTableOuterFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
NS_ASSERTION(aDesiredSize.Height() >= 0, "illegal height for mtable");
NS_ASSERTION(aDesiredSize.Width() >= 0, "illegal width for mtable");
// see if the user has set the align attribute on the <mtable>
int32_t rowIndex = 0;
eAlign tableAlign = eAlign_axis;
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::align, value);
if (!value.IsEmpty()) {
ParseAlignAttribute(value, tableAlign, rowIndex);
}
// adjustments if there is a specified row from where to anchor the table
// (conceptually: when there is no row of reference, picture the table as if
// it is wrapped in a single big fictional row at dy = 0, this way of
// doing so allows us to have a single code path for all cases).
nscoord dy = 0;
WritingMode wm = aDesiredSize.GetWritingMode();
nscoord blockSize = aDesiredSize.BSize(wm);
nsIFrame* rowFrame = nullptr;
if (rowIndex) {
rowFrame = GetRowFrameAt(rowIndex);
if (rowFrame) {
// translate the coordinates to be relative to us and in our writing mode
nsIFrame* frame = rowFrame;
LogicalRect rect(wm, frame->GetRect(),
aReflowState.ComputedSizeAsContainerIfConstrained());
blockSize = rect.BSize(wm);
do {
dy += rect.BStart(wm);
frame = frame->GetParent();
} while (frame != this);
}
}
switch (tableAlign) {
case eAlign_top:
aDesiredSize.SetBlockStartAscent(dy);
break;
case eAlign_bottom:
aDesiredSize.SetBlockStartAscent(dy + blockSize);
break;
case eAlign_center:
aDesiredSize.SetBlockStartAscent(dy + blockSize / 2);
break;
case eAlign_baseline:
if (rowFrame) {
// anchor the table on the baseline of the row of reference
nscoord rowAscent = ((nsTableRowFrame*)rowFrame)->GetMaxCellAscent();
if (rowAscent) { // the row has at least one cell with 'vertical-align: baseline'
aDesiredSize.SetBlockStartAscent(dy + rowAscent);
break;
}
}
// in other situations, fallback to center
aDesiredSize.SetBlockStartAscent(dy + blockSize / 2);
break;
case eAlign_axis:
default: {
// XXX should instead use style data from the row of reference here ?
RefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
nsLayoutUtils::
FontSizeInflationFor(this));
nscoord axisHeight;
GetAxisHeight(aReflowState.rendContext->GetDrawTarget(), fm, axisHeight);
if (rowFrame) {
// anchor the table on the axis of the row of reference
// XXX fallback to baseline because it is a hard problem
// XXX need to fetch the axis of the row; would need rowalign=axis to work better
nscoord rowAscent = ((nsTableRowFrame*)rowFrame)->GetMaxCellAscent();
if (rowAscent) { // the row has at least one cell with 'vertical-align: baseline'
aDesiredSize.SetBlockStartAscent(dy + rowAscent);
break;
}
}
// in other situations, fallback to using half of the height
aDesiredSize.SetBlockStartAscent(dy + blockSize / 2 + axisHeight);
}
}
mReference.x = 0;
mReference.y = aDesiredSize.BlockStartAscent();
// just make-up a bounding metrics
mBoundingMetrics = nsBoundingMetrics();
mBoundingMetrics.ascent = aDesiredSize.BlockStartAscent();
mBoundingMetrics.descent = aDesiredSize.Height() -
aDesiredSize.BlockStartAscent();
mBoundingMetrics.width = aDesiredSize.Width();
mBoundingMetrics.leftBearing = 0;
mBoundingMetrics.rightBearing = aDesiredSize.Width();
//.........这里部分代码省略.........