本文整理汇总了C++中nsHTMLReflowState::AvailableSize方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowState::AvailableSize方法的具体用法?C++ nsHTMLReflowState::AvailableSize怎么用?C++ nsHTMLReflowState::AvailableSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowState
的用法示例。
在下文中一共展示了nsHTMLReflowState::AvailableSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: margin
void
nsTableOuterFrame::OuterBeginReflowChild(nsPresContext* aPresContext,
nsIFrame* aChildFrame,
const nsHTMLReflowState& aOuterRS,
void* aChildRSSpace,
nscoord aAvailISize)
{
// work around pixel rounding errors, round down to ensure we don't exceed the avail height in
WritingMode wm = aChildFrame->GetWritingMode();
LogicalSize outerSize = aOuterRS.AvailableSize(wm);
nscoord availBSize = outerSize.BSize(wm);
if (NS_UNCONSTRAINEDSIZE != availBSize) {
if (mCaptionFrames.FirstChild() == aChildFrame) {
availBSize = NS_UNCONSTRAINEDSIZE;
} else {
LogicalMargin margin(wm);
GetChildMargin(aPresContext, aOuterRS, aChildFrame,
outerSize.ISize(wm), margin);
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != margin.BStart(wm),
"No unconstrainedsize arithmetic, please");
availBSize -= margin.BStart(wm);
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != margin.BEnd(wm),
"No unconstrainedsize arithmetic, please");
availBSize -= margin.BEnd(wm);
}
}
LogicalSize availSize(wm, aAvailISize, availBSize);
// create and init the child reflow state, using placement new on
// stack space allocated by the caller, so that the caller can destroy
// it
nsHTMLReflowState &childRS = * new (aChildRSSpace)
nsHTMLReflowState(aPresContext, aOuterRS, aChildFrame, availSize,
-1, -1, nsHTMLReflowState::CALLER_WILL_INIT);
InitChildReflowState(*aPresContext, childRS);
// see if we need to reset top-of-page due to a caption
if (childRS.mFlags.mIsTopOfPage &&
mCaptionFrames.FirstChild() == aChildFrame) {
uint8_t captionSide = GetCaptionSide();
if (captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM ||
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE) {
childRS.mFlags.mIsTopOfPage = false;
}
}
}
示例2: availSize
// get the margin and padding data. nsHTMLReflowState doesn't handle the
// case of auto margins
void
nsTableOuterFrame::GetChildMargin(nsPresContext* aPresContext,
const nsHTMLReflowState& aOuterRS,
nsIFrame* aChildFrame,
nscoord aAvailISize,
LogicalMargin& aMargin)
{
// construct a reflow state to compute margin and padding. Auto margins
// will not be computed at this time.
// create and init the child reflow state
// XXX We really shouldn't construct a reflow state to do this.
WritingMode wm = aChildFrame->GetWritingMode();
LogicalSize availSize(wm, aAvailISize, aOuterRS.AvailableSize(wm).BSize(wm));
nsHTMLReflowState childRS(aPresContext, aOuterRS, aChildFrame, availSize,
-1, -1, nsHTMLReflowState::CALLER_WILL_INIT);
InitChildReflowState(*aPresContext, childRS);
aMargin = childRS.ComputedLogicalMargin();
}
示例3: overflow
void
nsCanvasFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsCanvasFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_FRAME_TRACE_REFLOW_IN("nsCanvasFrame::Reflow");
// Initialize OUT parameter
aStatus = NS_FRAME_COMPLETE;
nsCanvasFrame* prevCanvasFrame = static_cast<nsCanvasFrame*>
(GetPrevInFlow());
if (prevCanvasFrame) {
AutoFrameListPtr overflow(aPresContext,
prevCanvasFrame->StealOverflowFrames());
if (overflow) {
NS_ASSERTION(overflow->OnlyChild(),
"must have doc root as canvas frame's only child");
nsContainerFrame::ReparentFrameViewList(*overflow, prevCanvasFrame, this);
// Prepend overflow to the our child list. There may already be
// children placeholders for fixed-pos elements, which don't get
// reflowed but must not be lost until the canvas frame is destroyed.
mFrames.InsertFrames(this, nullptr, *overflow);
}
}
// 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.ComputedWidth(), aReflowState.ComputedHeight()));
// Reflow our one and only normal child frame. It's either the root
// element's frame or a placeholder for that frame, if the root element
// is abs-pos or fixed-pos. We may have additional children which
// are placeholders for continuations of fixed-pos content, but those
// don't need to be reflowed. The normal child is always comes before
// the fixed-pos placeholders, because we insert it at the start
// of the child list, above.
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
if (mFrames.IsEmpty()) {
// We have no child frame, so return an empty size
aDesiredSize.Width() = aDesiredSize.Height() = 0;
} else {
nsIFrame* kidFrame = mFrames.FirstChild();
bool kidDirty = (kidFrame->GetStateBits() & NS_FRAME_IS_DIRTY) != 0;
nsHTMLReflowState
kidReflowState(aPresContext, aReflowState, kidFrame,
aReflowState.AvailableSize(kidFrame->GetWritingMode()));
if (aReflowState.IsVResize() &&
(kidFrame->GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_HEIGHT)) {
// Tell our kid it's being vertically resized too. Bit of a
// hack for framesets.
kidReflowState.SetVResize(true);
}
WritingMode wm = aReflowState.GetWritingMode();
WritingMode kidWM = kidReflowState.GetWritingMode();
nscoord containerWidth = aReflowState.ComputedWidth();
LogicalMargin margin = kidReflowState.ComputedLogicalMargin();
LogicalPoint kidPt(kidWM, margin.IStart(kidWM), margin.BStart(kidWM));
kidReflowState.ApplyRelativePositioning(&kidPt, containerWidth);
// Reflow the frame
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
kidWM, kidPt, containerWidth, 0, aStatus);
// Complete the reflow and position and size the child frame
FinishReflowChild(kidFrame, aPresContext, kidDesiredSize, &kidReflowState,
kidWM, kidPt, containerWidth, 0);
if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) {
nsIFrame* nextFrame = kidFrame->GetNextInFlow();
NS_ASSERTION(nextFrame || aStatus & NS_FRAME_REFLOW_NEXTINFLOW,
"If it's incomplete and has no nif yet, it must flag a nif reflow.");
if (!nextFrame) {
nextFrame = aPresContext->PresShell()->FrameConstructor()->
CreateContinuingFrame(aPresContext, kidFrame, this);
SetOverflowFrames(nsFrameList(nextFrame, nextFrame));
// Root overflow containers will be normal children of
// the canvas frame, but that's ok because there
// aren't any other frames we need to isolate them from
// during reflow.
}
if (NS_FRAME_OVERFLOW_IS_INCOMPLETE(aStatus)) {
nextFrame->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
}
}
// If the child frame was just inserted, then we're responsible for making sure
// it repaints
if (kidDirty) {
// But we have a new child, which will affect our background, so
//.........这里部分代码省略.........
示例4: kidDesiredSize
void
ViewportFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("ViewportFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_FRAME_TRACE_REFLOW_IN("ViewportFrame::Reflow");
// Initialize OUT parameters
aStatus = NS_FRAME_COMPLETE;
// Because |Reflow| sets ComputedBSize() on the child to our
// ComputedBSize().
AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
// 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.ComputedWidth(), aReflowState.ComputedHeight()));
// Reflow the main content first so that the placeholders of the
// fixed-position frames will be in the right places on an initial
// reflow.
nscoord kidBSize = 0;
WritingMode wm = aReflowState.GetWritingMode();
if (mFrames.NotEmpty()) {
// Deal with a non-incremental reflow or an incremental reflow
// targeted at our one-and-only principal child frame.
if (aReflowState.ShouldReflowAllKids() ||
aReflowState.IsVResize() ||
NS_SUBTREE_DIRTY(mFrames.FirstChild())) {
// Reflow our one-and-only principal child frame
nsIFrame* kidFrame = mFrames.FirstChild();
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
WritingMode wm = kidFrame->GetWritingMode();
LogicalSize availableSpace = aReflowState.AvailableSize(wm);
nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
kidFrame, availableSpace);
// Reflow the frame
kidReflowState.SetComputedBSize(aReflowState.ComputedBSize());
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
0, 0, 0, aStatus);
kidBSize = kidDesiredSize.BSize(wm);
FinishReflowChild(kidFrame, aPresContext, kidDesiredSize, nullptr, 0, 0, 0);
} else {
kidBSize = LogicalSize(wm, mFrames.FirstChild()->GetSize()).BSize(wm);
}
}
NS_ASSERTION(aReflowState.AvailableISize() != NS_UNCONSTRAINEDSIZE,
"shouldn't happen anymore");
// Return the max size as our desired size
LogicalSize maxSize(wm, aReflowState.AvailableISize(),
// Being flowed initially at an unconstrained block size
// means we should return our child's intrinsic size.
aReflowState.ComputedBSize() != NS_UNCONSTRAINEDSIZE
? aReflowState.ComputedBSize()
: kidBSize);
aDesiredSize.SetSize(wm, maxSize);
aDesiredSize.SetOverflowAreasToDesiredBounds();
if (HasAbsolutelyPositionedChildren()) {
// Make a copy of the reflow state and change the computed width and height
// to reflect the available space for the fixed items
nsHTMLReflowState reflowState(aReflowState);
if (reflowState.AvailableBSize() == NS_UNCONSTRAINEDSIZE) {
// We have an intrinsic-height document with abs-pos/fixed-pos children.
// Set the available height and mComputedHeight to our chosen height.
reflowState.AvailableBSize() = maxSize.BSize(wm);
// Not having border/padding simplifies things
NS_ASSERTION(reflowState.ComputedPhysicalBorderPadding() == nsMargin(0,0,0,0),
"Viewports can't have border/padding");
reflowState.SetComputedBSize(maxSize.BSize(wm));
}
nsRect rect = AdjustReflowStateAsContainingBlock(&reflowState);
nsOverflowAreas* overflowAreas = &aDesiredSize.mOverflowAreas;
nsIScrollableFrame* rootScrollFrame =
aPresContext->PresShell()->GetRootScrollFrameAsScrollable();
if (rootScrollFrame && !rootScrollFrame->IsIgnoringViewportClipping()) {
overflowAreas = nullptr;
}
AbsPosReflowFlags flags =
AbsPosReflowFlags::eCBWidthAndHeightChanged; // XXX could be optimized
GetAbsoluteContainingBlock()->Reflow(this, aPresContext, reflowState, aStatus,
rect, flags, overflowAreas);
}
if (mFrames.NotEmpty()) {
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, mFrames.FirstChild());
}
//.........这里部分代码省略.........
示例5: kidDesiredSize
void
nsVideoFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsVideoFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("enter nsVideoFrame::Reflow: availSize=%d,%d",
aReflowState.AvailableWidth(), aReflowState.AvailableHeight()));
NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
aStatus = NS_FRAME_COMPLETE;
aMetrics.Width() = aReflowState.ComputedWidth();
aMetrics.Height() = aReflowState.ComputedHeight();
// stash this away so we can compute our inner area later
mBorderPadding = aReflowState.ComputedPhysicalBorderPadding();
aMetrics.Width() += mBorderPadding.left + mBorderPadding.right;
aMetrics.Height() += mBorderPadding.top + mBorderPadding.bottom;
// Reflow the child frames. We may have up to two, an image frame
// which is the poster, and a box frame, which is the video controls.
for (nsIFrame* child : mFrames) {
if (child->GetContent() == mPosterImage) {
// Reflow the poster frame.
nsImageFrame* imageFrame = static_cast<nsImageFrame*>(child);
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
WritingMode wm = imageFrame->GetWritingMode();
LogicalSize availableSize = aReflowState.AvailableSize(wm);
LogicalSize cbSize = aMetrics.Size(aMetrics.GetWritingMode()).
ConvertTo(wm, aMetrics.GetWritingMode());
nsHTMLReflowState kidReflowState(aPresContext,
aReflowState,
imageFrame,
availableSize,
&cbSize);
nsRect posterRenderRect;
if (ShouldDisplayPoster()) {
posterRenderRect =
nsRect(nsPoint(mBorderPadding.left, mBorderPadding.top),
nsSize(aReflowState.ComputedWidth(),
aReflowState.ComputedHeight()));
}
kidReflowState.SetComputedWidth(posterRenderRect.width);
kidReflowState.SetComputedHeight(posterRenderRect.height);
ReflowChild(imageFrame, aPresContext, kidDesiredSize, kidReflowState,
posterRenderRect.x, posterRenderRect.y, 0, aStatus);
FinishReflowChild(imageFrame, aPresContext,
kidDesiredSize, &kidReflowState,
posterRenderRect.x, posterRenderRect.y, 0);
} else if (child->GetContent() == mVideoControls) {
// Reflow the video controls frame.
nsBoxLayoutState boxState(PresContext(), aReflowState.rendContext);
nsSize size = child->GetSize();
nsBoxFrame::LayoutChildAt(boxState,
child,
nsRect(mBorderPadding.left,
mBorderPadding.top,
aReflowState.ComputedWidth(),
aReflowState.ComputedHeight()));
if (child->GetSize() != size) {
RefPtr<nsRunnable> event = new DispatchResizeToControls(child->GetContent());
nsContentUtils::AddScriptRunner(event);
}
} else if (child->GetContent() == mCaptionDiv) {
// Reflow to caption div
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
WritingMode wm = child->GetWritingMode();
LogicalSize availableSize = aReflowState.AvailableSize(wm);
LogicalSize cbSize = aMetrics.Size(aMetrics.GetWritingMode()).
ConvertTo(wm, aMetrics.GetWritingMode());
nsHTMLReflowState kidReflowState(aPresContext,
aReflowState,
child,
availableSize,
&cbSize);
nsSize size(aReflowState.ComputedWidth(), aReflowState.ComputedHeight());
size.width -= kidReflowState.ComputedPhysicalBorderPadding().LeftRight();
size.height -= kidReflowState.ComputedPhysicalBorderPadding().TopBottom();
kidReflowState.SetComputedWidth(std::max(size.width, 0));
kidReflowState.SetComputedHeight(std::max(size.height, 0));
ReflowChild(child, aPresContext, kidDesiredSize, kidReflowState,
mBorderPadding.left, mBorderPadding.top, 0, aStatus);
FinishReflowChild(child, aPresContext,
kidDesiredSize, &kidReflowState,
mBorderPadding.left, mBorderPadding.top, 0);
}
}
aMetrics.SetOverflowAreasToDesiredBounds();
FinishAndStoreOverflow(&aMetrics);
//.........这里部分代码省略.........
示例6: kidMetrics
void
nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aReflowStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsFirstLetterFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aReflowStatus);
// Grab overflow list
DrainOverflowFrames(aPresContext);
nsIFrame* kid = mFrames.FirstChild();
// Setup reflow state for our child
WritingMode wm = aReflowState.GetWritingMode();
LogicalSize availSize = aReflowState.AvailableSize();
const LogicalMargin& bp = aReflowState.ComputedLogicalBorderPadding();
NS_ASSERTION(availSize.ISize(wm) != NS_UNCONSTRAINEDSIZE,
"should no longer use unconstrained inline size");
availSize.ISize(wm) -= bp.IStartEnd(wm);
if (NS_UNCONSTRAINEDSIZE != availSize.BSize(wm)) {
availSize.BSize(wm) -= bp.BStartEnd(wm);
}
WritingMode lineWM = aMetrics.GetWritingMode();
nsHTMLReflowMetrics kidMetrics(lineWM);
// Reflow the child
if (!aReflowState.mLineLayout) {
// When there is no lineLayout provided, we provide our own. The
// only time that the first-letter-frame is not reflowing in a
// line context is when its floating.
WritingMode kidWritingMode = GetWritingMode(kid);
LogicalSize kidAvailSize = availSize.ConvertTo(kidWritingMode, wm);
nsHTMLReflowState rs(aPresContext, aReflowState, kid, kidAvailSize);
nsLineLayout ll(aPresContext, nullptr, &aReflowState, nullptr, nullptr);
ll.BeginLineReflow(bp.IStart(wm), bp.BStart(wm),
availSize.ISize(wm), NS_UNCONSTRAINEDSIZE,
false, true, kidWritingMode,
nsSize(aReflowState.AvailableWidth(),
aReflowState.AvailableHeight()));
rs.mLineLayout = ≪
ll.SetInFirstLetter(true);
ll.SetFirstLetterStyleOK(true);
kid->Reflow(aPresContext, kidMetrics, rs, aReflowStatus);
ll.EndLineReflow();
ll.SetInFirstLetter(false);
// In the floating first-letter case, we need to set this ourselves;
// nsLineLayout::BeginSpan will set it in the other case
mBaseline = kidMetrics.BlockStartAscent();
// Place and size the child and update the output metrics
LogicalSize convertedSize = kidMetrics.Size(lineWM).ConvertTo(wm, lineWM);
kid->SetRect(nsRect(bp.IStart(wm), bp.BStart(wm),
convertedSize.ISize(wm), convertedSize.BSize(wm)));
kid->FinishAndStoreOverflow(&kidMetrics);
kid->DidReflow(aPresContext, nullptr, nsDidReflowStatus::FINISHED);
convertedSize.ISize(wm) += bp.IStartEnd(wm);
convertedSize.BSize(wm) += bp.BStartEnd(wm);
aMetrics.SetSize(wm, convertedSize);
aMetrics.SetBlockStartAscent(kidMetrics.BlockStartAscent() +
bp.BStart(wm));
// Ensure that the overflow rect contains the child textframe's
// overflow rect.
// Note that if this is floating, the overline/underline drawable
// area is in the overflow rect of the child textframe.
aMetrics.UnionOverflowAreasWithDesiredBounds();
ConsiderChildOverflow(aMetrics.mOverflowAreas, kid);
FinishAndStoreOverflow(&aMetrics);
}
else {
// Pretend we are a span and reflow the child frame
nsLineLayout* ll = aReflowState.mLineLayout;
bool pushedFrame;
ll->SetInFirstLetter(
mStyleContext->GetPseudo() == nsCSSPseudoElements::firstLetter);
ll->BeginSpan(this, &aReflowState, bp.IStart(wm),
availSize.ISize(wm), &mBaseline);
ll->ReflowFrame(kid, aReflowStatus, &kidMetrics, pushedFrame);
NS_ASSERTION(lineWM.IsVertical() == wm.IsVertical(),
"we're assuming we can mix sizes between lineWM and wm "
"since we shouldn't have orthogonal writing modes within "
"a line.");
aMetrics.ISize(lineWM) = ll->EndSpan(this) + bp.IStartEnd(wm);
ll->SetInFirstLetter(false);
nsLayoutUtils::SetBSizeFromFontMetrics(this, aMetrics, bp, lineWM, wm);
}
if (!NS_INLINE_IS_BREAK_BEFORE(aReflowStatus)) {
//.........这里部分代码省略.........