本文整理汇总了C++中nsHTMLReflowMetrics::ScrollableOverflow方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowMetrics::ScrollableOverflow方法的具体用法?C++ nsHTMLReflowMetrics::ScrollableOverflow怎么用?C++ nsHTMLReflowMetrics::ScrollableOverflow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowMetrics
的用法示例。
在下文中一共展示了nsHTMLReflowMetrics::ScrollableOverflow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: maxSize
void
nsPageContentFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsPageContentFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
aStatus = NS_FRAME_COMPLETE; // initialize out parameter
if (GetPrevInFlow() && (GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
nsresult rv = aPresContext->PresShell()->FrameConstructor()
->ReplicateFixedFrames(this);
if (NS_FAILED(rv)) {
return;
}
}
// Set our size up front, since some parts of reflow depend on it
// being already set. Note that the computed height may be
// unconstrained; that's ok. Consumers should watch out for that.
nsSize maxSize(aReflowState.ComputedWidth(),
aReflowState.ComputedHeight());
SetSize(maxSize);
// A PageContentFrame must always have one child: the canvas frame.
// Resize our frame allowing it only to be as big as we are
// XXX Pay attention to the page's border and padding...
if (mFrames.NotEmpty()) {
nsIFrame* frame = mFrames.FirstChild();
WritingMode wm = frame->GetWritingMode();
LogicalSize logicalSize(wm, maxSize);
nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
frame, logicalSize);
kidReflowState.SetComputedBSize(logicalSize.BSize(wm));
// Reflow the page content area
ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, 0, 0, 0, aStatus);
// The document element's background should cover the entire canvas, so
// take into account the combined area and any space taken up by
// absolutely positioned elements
nsMargin padding(0,0,0,0);
// XXXbz this screws up percentage padding (sets padding to zero
// in the percentage padding case)
kidReflowState.mStylePadding->GetPadding(padding);
// This is for shrink-to-fit, and therefore we want to use the
// scrollable overflow, since the purpose of shrink to fit is to
// make the content that ought to be reachable (represented by the
// scrollable overflow) fit in the page.
if (frame->HasOverflowAreas()) {
// The background covers the content area and padding area, so check
// for children sticking outside the child frame's padding edge
nscoord xmost = aDesiredSize.ScrollableOverflow().XMost();
if (xmost > aDesiredSize.Width()) {
nscoord widthToFit = xmost + padding.right +
kidReflowState.mStyleBorder->GetComputedBorderWidth(NS_SIDE_RIGHT);
float ratio = float(maxSize.width) / widthToFit;
NS_ASSERTION(ratio >= 0.0 && ratio < 1.0, "invalid shrink-to-fit ratio");
mPD->mShrinkToFitRatio = std::min(mPD->mShrinkToFitRatio, ratio);
}
}
// Place and size the child
FinishReflowChild(frame, aPresContext, aDesiredSize, &kidReflowState, 0, 0, 0);
NS_ASSERTION(aPresContext->IsDynamic() || !NS_FRAME_IS_FULLY_COMPLETE(aStatus) ||
!frame->GetNextInFlow(), "bad child flow list");
}
// Reflow our fixed frames
nsReflowStatus fixedStatus = NS_FRAME_COMPLETE;
ReflowAbsoluteFrames(aPresContext, aDesiredSize, aReflowState, fixedStatus);
NS_ASSERTION(NS_FRAME_IS_COMPLETE(fixedStatus), "fixed frames can be truncated, but not incomplete");
// Return our desired size
WritingMode wm = aReflowState.GetWritingMode();
LogicalSize finalSize(wm);
finalSize.ISize(wm) = aReflowState.ComputedISize();
if (aReflowState.ComputedBSize() != NS_UNCONSTRAINEDSIZE) {
finalSize.BSize(wm) = aReflowState.ComputedBSize();
}
aDesiredSize.SetSize(wm, finalSize);
FinishAndStoreOverflow(&aDesiredSize);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例2: maxSize
NS_IMETHODIMP
nsPageContentFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsPageContentFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
aStatus = NS_FRAME_COMPLETE; // initialize out parameter
nsresult rv = NS_OK;
if (GetPrevInFlow() && (GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
nsresult rv = aPresContext->PresShell()->FrameConstructor()
->ReplicateFixedFrames(this);
NS_ENSURE_SUCCESS(rv, rv);
}
// Set our size up front, since some parts of reflow depend on it
// being already set. Note that the computed height may be
// unconstrained; that's ok. Consumers should watch out for that.
SetSize(nsSize(aReflowState.availableWidth, aReflowState.availableHeight));
// A PageContentFrame must always have one child: the canvas frame.
// Resize our frame allowing it only to be as big as we are
// XXX Pay attention to the page's border and padding...
if (mFrames.NotEmpty()) {
nsIFrame* frame = mFrames.FirstChild();
nsSize maxSize(aReflowState.availableWidth, aReflowState.availableHeight);
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, frame, maxSize);
kidReflowState.SetComputedHeight(aReflowState.availableHeight);
mPD->mPageContentSize = aReflowState.availableWidth;
// Reflow the page content area
rv = ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, 0, 0, 0, aStatus);
NS_ENSURE_SUCCESS(rv, rv);
// The document element's background should cover the entire canvas, so
// take into account the combined area and any space taken up by
// absolutely positioned elements
nsMargin padding(0,0,0,0);
// XXXbz this screws up percentage padding (sets padding to zero
// in the percentage padding case)
kidReflowState.mStylePadding->GetPadding(padding);
// This is for shrink-to-fit, and therefore we want to use the
// scrollable overflow, since the purpose of shrink to fit is to
// make the content that ought to be reachable (represented by the
// scrollable overflow) fit in the page.
if (frame->HasOverflowAreas()) {
// The background covers the content area and padding area, so check
// for children sticking outside the child frame's padding edge
nscoord xmost = aDesiredSize.ScrollableOverflow().XMost();
if (xmost > aDesiredSize.width) {
mPD->mPageContentXMost =
xmost +
kidReflowState.mStyleBorder->GetActualBorderWidth(NS_SIDE_RIGHT) +
padding.right;
}
}
// Place and size the child
FinishReflowChild(frame, aPresContext, &kidReflowState, aDesiredSize, 0, 0, 0);
NS_ASSERTION(aPresContext->IsDynamic() || !NS_FRAME_IS_FULLY_COMPLETE(aStatus) ||
!frame->GetNextInFlow(), "bad child flow list");
}
// Reflow our fixed frames
nsReflowStatus fixedStatus = NS_FRAME_COMPLETE;
mFixedContainer.Reflow(this, aPresContext, aReflowState, fixedStatus,
aReflowState.availableWidth,
aReflowState.availableHeight,
PR_FALSE, PR_TRUE, PR_TRUE, // XXX could be optimized
nsnull /* ignore overflow */);
NS_ASSERTION(NS_FRAME_IS_COMPLETE(fixedStatus), "fixed frames can be truncated, but not incomplete");
// Return our desired size
aDesiredSize.width = aReflowState.availableWidth;
if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) {
aDesiredSize.height = aReflowState.availableHeight;
}
FinishAndStoreOverflow(&aDesiredSize);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return NS_OK;
}
示例3: indent
//.........这里部分代码省略.........
}
} else {
nsSize containingBlockSize =
CalculateContainingBlockSizeForAbsolutes(*reflowState,
nsSize(aMetrics.width,
aMetrics.height));
// Mark frames that depend on changes we just made to this frame as dirty:
// Now we can assume that the padding edge hasn't moved.
// We need to reflow the absolutes if one of them depends on
// its placeholder position, or the containing block size in a
// direction in which the containing block size might have
// changed.
bool cbWidthChanged = aMetrics.width != oldSize.width;
bool isRoot = !GetContent()->GetParent();
// If isRoot and we have auto height, then we are the initial
// containing block and the containing block height is the
// viewport height, which can't change during incremental
// reflow.
bool cbHeightChanged =
!(isRoot && NS_UNCONSTRAINEDSIZE == reflowState->ComputedHeight()) &&
aMetrics.height != oldSize.height;
absoluteContainer->Reflow(this, aPresContext, *reflowState,
state.mReflowStatus,
containingBlockSize.width,
containingBlockSize.height, true,
cbWidthChanged, cbHeightChanged,
&aMetrics.mOverflowAreas);
//XXXfr Why isn't this rv (and others in this file) checked/returned?
}
}
// Determine if we need to repaint our border, background or outline
CheckInvalidateSizeChange(aMetrics);
FinishAndStoreOverflow(&aMetrics);
// Clear the float manager pointer in the block reflow state so we
// don't waste time translating the coordinate system back on a dead
// float manager.
if (needFloatManager)
state.mFloatManager = nsnull;
aStatus = state.mReflowStatus;
#ifdef DEBUG
// Between when we drain pushed floats and when we complete reflow,
// we're allowed to have multiple continuations of the same float on
// our floats list, since a first-in-flow might get pushed to a later
// continuation of its containing block. But it's not permitted
// outside that time.
nsLayoutUtils::AssertNoDuplicateContinuations(this, mFloats);
if (gNoisyReflow) {
IndentBy(stdout, gNoiseIndent);
ListTag(stdout);
printf(": status=%x (%scomplete) metrics=%d,%d carriedMargin=%d",
aStatus, NS_FRAME_IS_COMPLETE(aStatus) ? "" : "not ",
aMetrics.width, aMetrics.height,
aMetrics.mCarriedOutBottomMargin.get());
if (HasOverflowAreas()) {
printf(" overflow-vis={%d,%d,%d,%d}",
aMetrics.VisualOverflow().x,
aMetrics.VisualOverflow().y,
aMetrics.VisualOverflow().width,
aMetrics.VisualOverflow().height);
printf(" overflow-scr={%d,%d,%d,%d}",
aMetrics.ScrollableOverflow().x,
aMetrics.ScrollableOverflow().y,
aMetrics.ScrollableOverflow().width,
aMetrics.ScrollableOverflow().height);
}
printf("\n");
}
if (gLameReflowMetrics) {
PRTime end = PR_Now();
PRInt32 ectc = nsLineBox::GetCtorCount();
PRInt32 numLines = mLines.size();
if (!numLines) numLines = 1;
PRTime delta, perLineDelta, lines;
LL_I2L(lines, numLines);
LL_SUB(delta, end, start);
LL_DIV(perLineDelta, delta, lines);
ListTag(stdout);
char buf[400];
PR_snprintf(buf, sizeof(buf),
": %lld elapsed (%lld per line) (%d lines; %d new lines)",
delta, perLineDelta, numLines, ectc - ctc);
printf("%s\n", buf);
}
#endif
NS_FRAME_SET_TRUNCATION(aStatus, (*reflowState), aMetrics);
return rv;
}