本文整理汇总了C++中nsHTMLReflowMetrics::ClearSize方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowMetrics::ClearSize方法的具体用法?C++ nsHTMLReflowMetrics::ClearSize怎么用?C++ nsHTMLReflowMetrics::ClearSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowMetrics
的用法示例。
在下文中一共展示了nsHTMLReflowMetrics::ClearSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kidSize
void
nsTableColGroupFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsTableColGroupFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_ASSERTION(nullptr!=mContent, "bad state -- null content for frame");
const nsStyleVisibility* groupVis = StyleVisibility();
bool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
if (collapseGroup) {
GetTableFrame()->SetNeedToCollapse(true);
}
// for every content child that (is a column thingy and does not already have a frame)
// create a frame and adjust it's style
for (nsIFrame *kidFrame = mFrames.FirstChild(); kidFrame;
kidFrame = kidFrame->GetNextSibling()) {
// Give the child frame a chance to reflow, even though we know it'll have 0 size
nsHTMLReflowMetrics kidSize(aReflowState);
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
LogicalSize(kidFrame->GetWritingMode()));
nsReflowStatus status;
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, 0, 0, 0, status);
FinishReflowChild(kidFrame, aPresContext, kidSize, nullptr, 0, 0, 0);
}
aDesiredSize.ClearSize();
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例2: while
void
nsPlaceholderFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
#ifdef DEBUG
// We should be getting reflowed before our out-of-flow.
// If this is our first reflow, and our out-of-flow has already received its
// first reflow (before us), complain.
// XXXdholbert This "look for a previous continuation or IB-split sibling"
// code could use nsLayoutUtils::GetPrevContinuationOrIBSplitSibling(), if
// we ever add a function like that. (We currently have a "Next" version.)
if ((GetStateBits() & NS_FRAME_FIRST_REFLOW) &&
!(mOutOfFlowFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
// Unfortunately, this can currently happen when the placeholder is in a
// later continuation or later IB-split sibling than its out-of-flow (as
// is the case in some of our existing unit tests). So for now, in that
// case, we'll warn instead of asserting.
bool isInContinuationOrIBSplit = false;
nsIFrame* ancestor = this;
while ((ancestor = ancestor->GetParent())) {
if (ancestor->GetPrevContinuation() ||
ancestor->Properties().Get(IBSplitPrevSibling())) {
isInContinuationOrIBSplit = true;
break;
}
}
if (isInContinuationOrIBSplit) {
NS_WARNING("Out-of-flow frame got reflowed before its placeholder");
} else {
NS_ERROR("Out-of-flow frame got reflowed before its placeholder");
}
}
#endif
DO_GLOBAL_REFLOW_COUNT("nsPlaceholderFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
aDesiredSize.ClearSize();
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例3: StyleVisibility
void
nsTableColFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsTableColFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
aDesiredSize.ClearSize();
const nsStyleVisibility* colVis = StyleVisibility();
bool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
if (collapseCol) {
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
tableFrame->SetNeedToCollapse(true);
}
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例4: childDesiredSize
void
nsMathMLTokenFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
mPresentationData.flags &= ~NS_MATHML_ERROR;
// initializations needed for empty markup like <mtag></mtag>
aDesiredSize.ClearSize();
aDesiredSize.SetBlockStartAscent(0);
aDesiredSize.mBoundingMetrics = nsBoundingMetrics();
nsIFrame* childFrame = GetFirstPrincipalChild();
while (childFrame) {
// ask our children to compute their bounding metrics
nsHTMLReflowMetrics childDesiredSize(aReflowState.GetWritingMode(),
aDesiredSize.mFlags
| NS_REFLOW_CALC_BOUNDING_METRICS);
WritingMode wm = childFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
childFrame, availSize);
ReflowChild(childFrame, aPresContext, childDesiredSize,
childReflowState, aStatus);
//NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
childFrame = childFrame->GetNextSibling();
}
// place and size children
FinalizeReflow(aReflowState.rendContext->GetDrawTarget(), aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例5: baseSize
void
nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
nsReflowStatus childStatus;
mPresentationData.flags &= ~NS_MATHML_ERROR;
aDesiredSize.ClearSize();
aDesiredSize.SetBlockStartAscent(0);
nsBoundingMetrics bmSqr, bmBase, bmIndex;
DrawTarget* drawTarget = aReflowState.rendContext->GetDrawTarget();
//////////////////
// Reflow Children
int32_t count = 0;
nsIFrame* baseFrame = nullptr;
nsIFrame* indexFrame = nullptr;
nsHTMLReflowMetrics baseSize(aReflowState);
nsHTMLReflowMetrics indexSize(aReflowState);
nsIFrame* childFrame = mFrames.FirstChild();
while (childFrame) {
// ask our children to compute their bounding metrics
nsHTMLReflowMetrics childDesiredSize(aReflowState,
aDesiredSize.mFlags
| NS_REFLOW_CALC_BOUNDING_METRICS);
WritingMode wm = childFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
childFrame, availSize);
ReflowChild(childFrame, aPresContext,
childDesiredSize, childReflowState, childStatus);
//NS_ASSERTION(NS_FRAME_IS_COMPLETE(childStatus), "bad status");
if (0 == count) {
// base
baseFrame = childFrame;
baseSize = childDesiredSize;
bmBase = childDesiredSize.mBoundingMetrics;
}
else if (1 == count) {
// index
indexFrame = childFrame;
indexSize = childDesiredSize;
bmIndex = childDesiredSize.mBoundingMetrics;
}
count++;
childFrame = childFrame->GetNextSibling();
}
if (2 != count) {
// report an error, encourage people to get their markups in order
ReportChildCountError();
ReflowError(drawTarget, aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
// Call DidReflow() for the child frames we successfully did reflow.
DidReflowChildren(mFrames.FirstChild(), childFrame);
return;
}
////////////
// Prepare the radical symbol and the overline bar
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this);
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation);
nscoord ruleThickness, leading, psi;
GetRadicalParameters(fm, StyleFont()->mMathDisplay ==
NS_MATHML_DISPLAYSTYLE_BLOCK,
ruleThickness, leading, psi);
// built-in: adjust clearance psi to emulate \mathstrut using '1' (TexBook, p.131)
char16_t one = '1';
nsBoundingMetrics bmOne =
nsLayoutUtils::AppUnitBoundsOfString(&one, 1, *fm, drawTarget);
if (bmOne.ascent > bmBase.ascent)
psi += bmOne.ascent - bmBase.ascent;
// make sure that the rule appears on on screen
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
if (ruleThickness < onePixel) {
ruleThickness = onePixel;
}
// adjust clearance psi to get an exact number of pixels -- this
// gives a nicer & uniform look on stacked radicals (bug 130282)
nscoord delta = psi % onePixel;
if (delta)
psi += onePixel - delta; // round up
// Stretch the radical symbol to the appropriate height if it is not big enough.
nsBoundingMetrics contSize = bmBase;
contSize.descent = bmBase.ascent + bmBase.descent + psi;
contSize.ascent = ruleThickness;
//.........这里部分代码省略.........
示例6: childDesiredSize
void
nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
mPresentationData.flags &= ~NS_MATHML_ERROR;
aDesiredSize.ClearSize();
aDesiredSize.SetBlockStartAscent(0);
aDesiredSize.mBoundingMetrics = nsBoundingMetrics();
int32_t i;
const nsStyleFont* font = StyleFont();
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this);
RefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
fontSizeInflation);
nscoord axisHeight, em;
GetAxisHeight(*aReflowState.rendContext, fm, axisHeight);
GetEmHeight(fm, em);
// leading to be left at the top and the bottom of stretched chars
nscoord leading = NSToCoordRound(0.2f * em);
/////////////
// Reflow children
// Asking each child to cache its bounding metrics
// Note that we don't use the base method nsMathMLContainerFrame::Reflow()
// because we want to stretch our fences, separators and stretchy frames using
// the *same* initial aDesiredSize.mBoundingMetrics. If we were to use the base
// method here, our stretchy frames will be stretched and placed, and we may
// end up stretching our fences/separators with a different aDesiredSize.
// XXX The above decision was revisited in bug 121748 and this code can be
// refactored to use nsMathMLContainerFrame::Reflow() at some stage.
nsReflowStatus childStatus;
nsIFrame* firstChild = GetFirstPrincipalChild();
nsIFrame* childFrame = firstChild;
nscoord ascent = 0, descent = 0;
if (firstChild || mOpenChar || mCloseChar || mSeparatorsCount > 0) {
// We use the ASCII metrics to get our minimum height. This way,
// if we have borders or a background, they will fit better with
// other elements on the line.
ascent = fm->MaxAscent();
descent = fm->MaxDescent();
}
while (childFrame) {
nsHTMLReflowMetrics childDesiredSize(aReflowState,
aDesiredSize.mFlags
| NS_REFLOW_CALC_BOUNDING_METRICS);
WritingMode wm = childFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
childFrame, availSize);
ReflowChild(childFrame, aPresContext, childDesiredSize,
childReflowState, childStatus);
//NS_ASSERTION(NS_FRAME_IS_COMPLETE(childStatus), "bad status");
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
mozilla::WritingMode outerWM = aReflowState.GetWritingMode();
nscoord childDescent = childDesiredSize.BSize(outerWM) -
childDesiredSize.BlockStartAscent();
if (descent < childDescent)
descent = childDescent;
if (ascent < childDesiredSize.BlockStartAscent())
ascent = childDesiredSize.BlockStartAscent();
childFrame = childFrame->GetNextSibling();
}
/////////////
// Ask stretchy children to stretch themselves
nsBoundingMetrics containerSize;
nsStretchDirection stretchDir = NS_STRETCH_DIRECTION_VERTICAL;
GetPreferredStretchSize(*aReflowState.rendContext,
0, /* i.e., without embellishments */
stretchDir, containerSize);
childFrame = firstChild;
while (childFrame) {
nsIMathMLFrame* mathmlChild = do_QueryFrame(childFrame);
if (mathmlChild) {
nsHTMLReflowMetrics childDesiredSize(aReflowState);
// retrieve the metrics that was stored at the previous pass
GetReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
mathmlChild->Stretch(*aReflowState.rendContext,
stretchDir, containerSize, childDesiredSize);
// store the updated metrics
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
nscoord childDescent = childDesiredSize.Height() - childDesiredSize.BlockStartAscent();
if (descent < childDescent)
descent = childDescent;
//.........这里部分代码省略.........
示例7: captionMet
void
nsTableOuterFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aOuterRS,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsTableOuterFrame");
DISPLAY_REFLOW(aPresContext, this, aOuterRS, aDesiredSize, aStatus);
uint8_t captionSide = GetCaptionSide();
// Initialize out parameters
aDesiredSize.ClearSize();
aStatus = NS_FRAME_COMPLETE;
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
// Set up our kids. They're already present, on an overflow list,
// or there are none so we'll create them now
MoveOverflowToChildList();
}
// Use longs to get more-aligned space.
#define LONGS_IN_HTMLRS \
((sizeof(nsHTMLReflowState) + sizeof(long) - 1) / sizeof(long))
long captionRSSpace[LONGS_IN_HTMLRS];
nsHTMLReflowState *captionRS =
static_cast<nsHTMLReflowState*>((void*)captionRSSpace);
long innerRSSpace[LONGS_IN_HTMLRS];
nsHTMLReflowState *innerRS =
static_cast<nsHTMLReflowState*>((void*) innerRSSpace);
nsRect origInnerRect = InnerTableFrame()->GetRect();
nsRect origInnerVisualOverflow = InnerTableFrame()->GetVisualOverflowRect();
bool innerFirstReflow =
(InnerTableFrame()->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
nsRect origCaptionRect;
nsRect origCaptionVisualOverflow;
bool captionFirstReflow;
if (mCaptionFrames.NotEmpty()) {
origCaptionRect = mCaptionFrames.FirstChild()->GetRect();
origCaptionVisualOverflow =
mCaptionFrames.FirstChild()->GetVisualOverflowRect();
captionFirstReflow =
(mCaptionFrames.FirstChild()->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
}
// ComputeAutoSize has to match this logic.
WritingMode wm;
if (captionSide == NO_SIDE) {
// We don't have a caption.
wm = InnerTableFrame()->GetWritingMode();
OuterBeginReflowChild(aPresContext, InnerTableFrame(), aOuterRS,
innerRSSpace, aOuterRS.ComputedSize(wm).ISize(wm));
} else if (captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT) {
// nsTableCaptionFrame::ComputeAutoSize takes care of making side
// captions small. Compute the caption's size first, and tell the
// table to fit in what's left.
wm = mCaptionFrames.FirstChild()->GetWritingMode();
OuterBeginReflowChild(aPresContext, mCaptionFrames.FirstChild(), aOuterRS,
captionRSSpace, aOuterRS.ComputedSize(wm).ISize(wm));
nscoord innerAvailISize = aOuterRS.ComputedSize(wm).ISize(wm) -
captionRS->ComputedSizeWithMarginBorderPadding(wm).ISize(wm);
OuterBeginReflowChild(aPresContext, InnerTableFrame(), aOuterRS,
innerRSSpace, innerAvailISize);
} else if (captionSide == NS_STYLE_CAPTION_SIDE_TOP ||
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM) {
// Compute the table's size first, and then prevent the caption from
// being wider unless it has to be.
//
// Note that CSS 2.1 (but not 2.0) says:
// The width of the anonymous box is the border-edge width of the
// table box inside it
// We don't actually make our anonymous box that width (if we did,
// it would break 'auto' margins), but this effectively does that.
wm = InnerTableFrame()->GetWritingMode();
OuterBeginReflowChild(aPresContext, InnerTableFrame(), aOuterRS,
innerRSSpace, aOuterRS.ComputedSize(wm).ISize(wm));
// It's good that CSS 2.1 says not to include margins, since we
// can't, since they already been converted so they exactly
// fill the available width (ignoring the margin on one side if
// neither are auto). (We take advantage of that later when we call
// GetCaptionOrigin, though.)
nscoord innerBorderWidth =
innerRS->ComputedSizeWithBorderPadding(wm).ISize(wm);
OuterBeginReflowChild(aPresContext, mCaptionFrames.FirstChild(), aOuterRS,
captionRSSpace, innerBorderWidth);
} else {
NS_ASSERTION(captionSide == NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE ||
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE,
"unexpected caption-side");
// Size the table and the caption independently.
wm = mCaptionFrames.FirstChild()->GetWritingMode();
OuterBeginReflowChild(aPresContext, mCaptionFrames.FirstChild(), aOuterRS,
captionRSSpace, aOuterRS.ComputedSize(wm).ISize(wm));
wm = InnerTableFrame()->GetWritingMode();
OuterBeginReflowChild(aPresContext, InnerTableFrame(), aOuterRS,
innerRSSpace, aOuterRS.ComputedSize(wm).ISize(wm));
}
//.........这里部分代码省略.........