本文整理汇总了C++中nsHTMLReflowMetrics::SetTopAscent方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowMetrics::SetTopAscent方法的具体用法?C++ nsHTMLReflowMetrics::SetTopAscent怎么用?C++ nsHTMLReflowMetrics::SetTopAscent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowMetrics
的用法示例。
在下文中一共展示了nsHTMLReflowMetrics::SetTopAscent方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: availSize
void
nsMathMLTokenFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// initializations needed for empty markup like <mtag></mtag>
aDesiredSize.Width() = aDesiredSize.Height() = 0;
aDesiredSize.SetTopAscent(0);
aDesiredSize.mBoundingMetrics = nsBoundingMetrics();
nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
nsIFrame* childFrame = GetFirstPrincipalChild();
while (childFrame) {
// ask our children to compute their bounding metrics
nsHTMLReflowMetrics childDesiredSize(aReflowState.GetWritingMode(),
aDesiredSize.mFlags
| NS_REFLOW_CALC_BOUNDING_METRICS);
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, aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例2: while
NS_IMETHODIMP
nsTextControlFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsTextControlFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
// make sure that the form registers itself on the initial/first reflow
if (mState & NS_FRAME_FIRST_REFLOW) {
nsFormControlFrame::RegUnRegAccessKey(this, true);
}
// set values of reflow's out parameters
aDesiredSize.Width() = aReflowState.ComputedWidth() +
aReflowState.ComputedPhysicalBorderPadding().LeftRight();
aDesiredSize.Height() = aReflowState.ComputedHeight() +
aReflowState.ComputedPhysicalBorderPadding().TopBottom();
// computation of the ascent wrt the input height
nscoord lineHeight = aReflowState.ComputedHeight();
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
if (!IsSingleLineTextControl()) {
lineHeight = nsHTMLReflowState::CalcLineHeight(StyleContext(),
NS_AUTOHEIGHT, inflation);
}
nsRefPtr<nsFontMetrics> fontMet;
nsresult rv = nsLayoutUtils::GetFontMetricsForFrame(this,
getter_AddRefs(fontMet),
inflation);
NS_ENSURE_SUCCESS(rv, rv);
// now adjust for our borders and padding
aDesiredSize.SetTopAscent(
nsLayoutUtils::GetCenteredFontBaseline(fontMet, lineHeight)
+ aReflowState.ComputedPhysicalBorderPadding().top);
// overflow handling
aDesiredSize.SetOverflowAreasToDesiredBounds();
// perform reflow on all kids
nsIFrame* kid = mFrames.FirstChild();
while (kid) {
ReflowTextControlChild(kid, aPresContext, aReflowState, aStatus, aDesiredSize);
kid = kid->GetNextSibling();
}
// take into account css properties that affect overflow handling
FinishAndStoreOverflow(&aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return NS_OK;
}
示例3: childSize
// For token elements, mBoundingMetrics is computed at the ReflowToken
// pass, it is not computed here because our children may be text frames
// that do not implement the GetBoundingMetrics() interface.
/* virtual */ nsresult
nsMathMLTokenFrame::Place(nsRenderingContext& aRenderingContext,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
mBoundingMetrics = nsBoundingMetrics();
for (nsIFrame* childFrame = GetFirstPrincipalChild(); childFrame;
childFrame = childFrame->GetNextSibling()) {
nsHTMLReflowMetrics childSize(aDesiredSize.GetWritingMode());
GetReflowAndBoundingMetricsFor(childFrame, childSize,
childSize.mBoundingMetrics, nullptr);
// compute and cache the bounding metrics
mBoundingMetrics += childSize.mBoundingMetrics;
}
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
nscoord ascent = fm->MaxAscent();
nscoord descent = fm->MaxDescent();
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
aDesiredSize.Width() = mBoundingMetrics.width;
aDesiredSize.SetTopAscent(std::max(mBoundingMetrics.ascent, ascent));
aDesiredSize.Height() = aDesiredSize.TopAscent() +
std::max(mBoundingMetrics.descent, descent);
if (aPlaceOrigin) {
nscoord dy, dx = 0;
for (nsIFrame* childFrame = GetFirstPrincipalChild(); childFrame;
childFrame = childFrame->GetNextSibling()) {
nsHTMLReflowMetrics childSize(aDesiredSize.GetWritingMode());
GetReflowAndBoundingMetricsFor(childFrame, childSize,
childSize.mBoundingMetrics);
// place and size the child; (dx,0) makes the caret happy - bug 188146
dy = childSize.Height() == 0 ? 0 : aDesiredSize.TopAscent() - childSize.TopAscent();
FinishReflowChild(childFrame, PresContext(), childSize, nullptr, dx, dy, 0);
dx += childSize.Width();
}
}
SetReference(nsPoint(0, aDesiredSize.TopAscent()));
return NS_OK;
}
示例4: ProcessAttributes
void
nsMathMLmspaceFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
ProcessAttributes(aPresContext);
mBoundingMetrics = nsBoundingMetrics();
mBoundingMetrics.width = mWidth;
mBoundingMetrics.ascent = mHeight;
mBoundingMetrics.descent = mDepth;
mBoundingMetrics.leftBearing = 0;
mBoundingMetrics.rightBearing = mBoundingMetrics.width;
aDesiredSize.SetTopAscent(mHeight);
aDesiredSize.Width() = std::max(0, mBoundingMetrics.width);
aDesiredSize.Height() = aDesiredSize.TopAscent() + mDepth;
// Also return our bounding metrics
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例5: availSize
nsresult
nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aReflowStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsFirstLetterFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aReflowStatus);
nsresult rv = NS_OK;
// Grab overflow list
DrainOverflowFrames(aPresContext);
nsIFrame* kid = mFrames.FirstChild();
// Setup reflow state for our child
nsSize availSize(aReflowState.AvailableWidth(), aReflowState.AvailableHeight());
const nsMargin& bp = aReflowState.ComputedPhysicalBorderPadding();
nscoord lr = bp.left + bp.right;
nscoord tb = bp.top + bp.bottom;
NS_ASSERTION(availSize.width != NS_UNCONSTRAINEDSIZE,
"should no longer use unconstrained widths");
availSize.width -= lr;
if (NS_UNCONSTRAINEDSIZE != availSize.height) {
availSize.height -= tb;
}
// 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.
nsHTMLReflowState rs(aPresContext, aReflowState, kid, availSize);
nsLineLayout ll(aPresContext, nullptr, &aReflowState, nullptr);
ll.BeginLineReflow(bp.left, bp.top, availSize.width, NS_UNCONSTRAINEDSIZE,
false, true,
ll.LineContainerFrame()->GetWritingMode(kid),
aReflowState.AvailableWidth());
rs.mLineLayout = ≪
ll.SetInFirstLetter(true);
ll.SetFirstLetterStyleOK(true);
kid->WillReflow(aPresContext);
kid->Reflow(aPresContext, aMetrics, 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 = aMetrics.TopAscent();
}
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.left, availSize.width, &mBaseline);
ll->ReflowFrame(kid, aReflowStatus, &aMetrics, pushedFrame);
ll->EndSpan(this);
ll->SetInFirstLetter(false);
}
// Place and size the child and update the output metrics
kid->SetRect(nsRect(bp.left, bp.top, aMetrics.Width(), aMetrics.Height()));
kid->FinishAndStoreOverflow(&aMetrics);
kid->DidReflow(aPresContext, nullptr, nsDidReflowStatus::FINISHED);
aMetrics.Width() += lr;
aMetrics.Height() += tb;
aMetrics.SetTopAscent(aMetrics.TopAscent() + bp.top);
// 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);
if (!NS_INLINE_IS_BREAK_BEFORE(aReflowStatus)) {
// Create a continuation or remove existing continuations based on
// the reflow completion status.
if (NS_FRAME_IS_COMPLETE(aReflowStatus)) {
if (aReflowState.mLineLayout) {
aReflowState.mLineLayout->SetFirstLetterStyleOK(false);
}
nsIFrame* kidNextInFlow = kid->GetNextInFlow();
if (kidNextInFlow) {
// Remove all of the childs next-in-flows
static_cast<nsContainerFrame*>(kidNextInFlow->GetParent())
->DeleteNextInFlowChild(kidNextInFlow, true);
}
}
else {
// Create a continuation for the child frame if it doesn't already
// have one.
if (!IsFloating()) {
nsIFrame* nextInFlow;
//.........这里部分代码省略.........
示例6: state
//.........这里部分代码省略.........
}
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());
computedSize.height = NS_CSS_MINMAX(computedSize.height,
aReflowState.ComputedMinHeight(),
aReflowState.ComputedMaxHeight());
computedSize.height += m.TopBottom();
nsRect r(mRect.x, mRect.y, computedSize.width, computedSize.height);
SetBounds(state, r);
// layout our children
Layout(state);
// ok our child could have gotten bigger. So lets get its bounds
aDesiredSize.Width() = mRect.width;
aDesiredSize.Height() = mRect.height;
aDesiredSize.SetTopAscent(GetBoxAscent(state));
// the overflow rect is set in SetBounds() above
aDesiredSize.mOverflowAreas = GetOverflowAreas();
#ifdef DO_NOISY_REFLOW
{
printf("%p ** nsLBF(done) W:%d H:%d ", this, aDesiredSize.Width(), aDesiredSize.Height());
if (maxElementWidth) {
printf("MW:%d\n", *maxElementWidth);
} else {
printf("MW:?\n");
}
}
#endif
}
示例7: availSize
void
nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aButtonDesiredSize,
const nsHTMLReflowState& aButtonReflowState,
nsIFrame* aFirstKid)
{
// Buttons have some bonus renderer-determined border/padding,
// which occupies part of the button's content-box area:
const nsMargin focusPadding = mRenderer.GetAddedButtonBorderAndPadding();
nsSize availSize(aButtonReflowState.ComputedWidth(), NS_INTRINSICSIZE);
// Indent the child inside us by the focus border. We must do this separate
// from the regular border.
availSize.width -= focusPadding.LeftRight();
// See whether out availSize's width is big enough. If it's smaller than our
// intrinsic min width, that means that the kid wouldn't really fit; for a
// better look in such cases we adjust the available width and our left
// offset to allow the kid to spill left into our padding.
nscoord xoffset = focusPadding.left +
aButtonReflowState.ComputedPhysicalBorderPadding().left;
nscoord extrawidth = GetMinWidth(aButtonReflowState.rendContext) -
aButtonReflowState.ComputedWidth();
if (extrawidth > 0) {
nscoord extraleft = extrawidth / 2;
nscoord extraright = extrawidth - extraleft;
NS_ASSERTION(extraright >=0, "How'd that happen?");
// Do not allow the extras to be bigger than the relevant padding
extraleft = std::min(extraleft, aButtonReflowState.ComputedPhysicalPadding().left);
extraright = std::min(extraright, aButtonReflowState.ComputedPhysicalPadding().right);
xoffset -= extraleft;
availSize.width += extraleft + extraright;
}
availSize.width = std::max(availSize.width,0);
// Give child a clone of the button's reflow state, with height/width reduced
// by focusPadding, so that descendants with height:100% don't protrude.
nsHTMLReflowState adjustedButtonReflowState =
CloneReflowStateWithReducedContentBox(aButtonReflowState, focusPadding);
nsHTMLReflowState contentsReflowState(aPresContext,
adjustedButtonReflowState,
aFirstKid, availSize);
nsReflowStatus contentsReflowStatus;
nsHTMLReflowMetrics contentsDesiredSize(aButtonReflowState.GetWritingMode());
ReflowChild(aFirstKid, aPresContext,
contentsDesiredSize, contentsReflowState,
xoffset,
focusPadding.top + aButtonReflowState.ComputedPhysicalBorderPadding().top,
0, contentsReflowStatus);
MOZ_ASSERT(NS_FRAME_IS_COMPLETE(contentsReflowStatus),
"We gave button-contents frame unconstrained available height, "
"so it should be complete");
// Compute the button's content-box height:
nscoord buttonContentBoxHeight = 0;
if (aButtonReflowState.ComputedHeight() != NS_INTRINSICSIZE) {
// Button has a fixed height -- that's its content-box height.
buttonContentBoxHeight = aButtonReflowState.ComputedHeight();
} else {
// Button is intrinsically sized -- it should shrinkwrap the
// button-contents' height, plus any focus-padding space:
buttonContentBoxHeight =
contentsDesiredSize.Height() + focusPadding.TopBottom();
// Make sure we obey min/max-height in the case when we're doing intrinsic
// sizing (we get it for free when we have a non-intrinsic
// aButtonReflowState.ComputedHeight()). Note that we do this before
// adjusting for borderpadding, since mComputedMaxHeight and
// mComputedMinHeight are content heights.
buttonContentBoxHeight =
NS_CSS_MINMAX(buttonContentBoxHeight,
aButtonReflowState.ComputedMinHeight(),
aButtonReflowState.ComputedMaxHeight());
}
// Center child vertically in the button
// (technically, inside of the button's focus-padding area)
nscoord extraSpace =
buttonContentBoxHeight - focusPadding.TopBottom() -
contentsDesiredSize.Height();
nscoord yoffset = std::max(0, extraSpace / 2);
// Adjust yoffset to be in terms of the button's frame-rect, instead of
// its focus-padding rect:
yoffset += focusPadding.top + aButtonReflowState.ComputedPhysicalBorderPadding().top;
// Place the child
FinishReflowChild(aFirstKid, aPresContext,
contentsDesiredSize, &contentsReflowState,
xoffset, yoffset, 0);
// Make sure we have a useful 'ascent' value for the child
if (contentsDesiredSize.TopAscent() == nsHTMLReflowMetrics::ASK_FOR_BASELINE) {
contentsDesiredSize.SetTopAscent(aFirstKid->GetBaseline());
}
//.........这里部分代码省略.........
示例8: DidReflowChildren
//.........这里部分代码省略.........
// values."
//
// "MathML renderers should ensure that, except for the effects of the
// attributes, the relative spacing between the contents of the mpadded
// element and surrounding MathML elements would not be modified by replacing
// an mpadded element with an mrow element with the same content, even if
// linebreaking occurs within the mpadded element."
//
// (http://www.w3.org/TR/MathML/chapter3.html#presm.mpadded)
//
// "In those discussions, the terms leading and trailing are used to specify
// a side of an object when which side to use depends on the directionality;
// ie. leading means left in LTR but right in RTL."
// (http://www.w3.org/TR/MathML/chapter3.html#presm.bidi.math)
nscoord lspace = 0;
// In MathML3, "width" will be the bounding box width and "advancewidth" will
// refer "to the horizontal distance between the positioning point of the
// mpadded and the positioning point for the following content". MathML2
// doesn't make the distinction.
nscoord width = aDesiredSize.Width();
nscoord voffset = 0;
int32_t pseudoUnit;
nscoord initialWidth = width;
// update width
pseudoUnit = (mWidthPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF)
? NS_MATHML_PSEUDO_UNIT_WIDTH : mWidthPseudoUnit;
UpdateValue(mWidthSign, pseudoUnit, mWidth,
aDesiredSize, width);
width = std::max(0, width);
// update "height" (this is the ascent in the terminology of the REC)
pseudoUnit = (mHeightPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF)
? NS_MATHML_PSEUDO_UNIT_HEIGHT : mHeightPseudoUnit;
UpdateValue(mHeightSign, pseudoUnit, mHeight,
aDesiredSize, height);
height = std::max(0, height);
// update "depth" (this is the descent in the terminology of the REC)
pseudoUnit = (mDepthPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF)
? NS_MATHML_PSEUDO_UNIT_DEPTH : mDepthPseudoUnit;
UpdateValue(mDepthSign, pseudoUnit, mDepth,
aDesiredSize, depth);
depth = std::max(0, depth);
// update lspace
if (mLeadingSpacePseudoUnit != NS_MATHML_PSEUDO_UNIT_ITSELF) {
pseudoUnit = mLeadingSpacePseudoUnit;
UpdateValue(mLeadingSpaceSign, pseudoUnit, mLeadingSpace,
aDesiredSize, lspace);
}
// update voffset
if (mVerticalOffsetPseudoUnit != NS_MATHML_PSEUDO_UNIT_ITSELF) {
pseudoUnit = mVerticalOffsetPseudoUnit;
UpdateValue(mVerticalOffsetSign, pseudoUnit, mVerticalOffset,
aDesiredSize, voffset);
}
// do the padding now that we have everything
// The idea here is to maintain the invariant that <mpadded>...</mpadded> (i.e.,
// with no attributes) looks the same as <mrow>...</mrow>. But when there are
// attributes, tweak our metrics and move children to achieve the desired visual
// effects.
if ((StyleVisibility()->mDirection ?
mWidthSign : mLeadingSpaceSign) != NS_MATHML_SIGN_INVALID) {
// there was padding on the left. dismiss the left italic correction now
// (so that our parent won't correct us)
mBoundingMetrics.leftBearing = 0;
}
if ((StyleVisibility()->mDirection ?
mLeadingSpaceSign : mWidthSign) != NS_MATHML_SIGN_INVALID) {
// there was padding on the right. dismiss the right italic correction now
// (so that our parent won't correct us)
mBoundingMetrics.width = width;
mBoundingMetrics.rightBearing = mBoundingMetrics.width;
}
nscoord dx = (StyleVisibility()->mDirection ?
width - initialWidth - lspace : lspace);
aDesiredSize.SetTopAscent(height);
aDesiredSize.Width() = mBoundingMetrics.width;
aDesiredSize.Height() = depth + aDesiredSize.TopAscent();
mBoundingMetrics.ascent = height;
mBoundingMetrics.descent = depth;
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
mReference.x = 0;
mReference.y = aDesiredSize.TopAscent();
if (aPlaceOrigin) {
// Finish reflowing child frames, positioning their origins.
PositionRowChildFrames(dx, aDesiredSize.TopAscent() - voffset);
}
return NS_OK;
}
示例9: baseSize
//.........这里部分代码省略.........
// Update vertical parameters
radicalAscent = bmBase.ascent + psi + mRuleThickness;
radicalDescent = std::max(bmBase.descent,
(bmRadicalChar.ascent + bmRadicalChar.descent -
radicalAscent));
mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent,
radicalAscent);
mBoundingMetrics.descent = std::max(mBoundingMetrics.descent,
radicalDescent);
}
}
///////////////
//
if (IsToDraw(NOTATION_CIRCLE) ||
IsToDraw(NOTATION_ROUNDEDBOX) ||
(IsToDraw(NOTATION_LEFT) && IsToDraw(NOTATION_RIGHT))) {
// center the menclose around the content (horizontally)
dx_left = dx_right = std::max(dx_left, dx_right);
}
///////////////
// The maximum size is now computed: set the remaining parameters
mBoundingMetrics.width = dx_left + bmBase.width + dx_right;
mBoundingMetrics.leftBearing = std::min(0, dx_left + bmBase.leftBearing);
mBoundingMetrics.rightBearing =
std::max(mBoundingMetrics.width, dx_left + bmBase.rightBearing);
aDesiredSize.Width() = mBoundingMetrics.width;
aDesiredSize.SetTopAscent(std::max(mBoundingMetrics.ascent, baseSize.TopAscent()));
aDesiredSize.Height() = aDesiredSize.TopAscent() +
std::max(mBoundingMetrics.descent, baseSize.Height() - baseSize.TopAscent());
if (IsToDraw(NOTATION_LONGDIV) || IsToDraw(NOTATION_RADICAL)) {
// get the leading to be left at the top of the resulting frame
// this seems more reliable than using fm->GetLeading() on suspicious
// fonts
nscoord leading = nscoord(0.2f * mEmHeight);
nscoord desiredSizeAscent = aDesiredSize.TopAscent();
nscoord desiredSizeDescent = aDesiredSize.Height() - aDesiredSize.TopAscent();
if (IsToDraw(NOTATION_LONGDIV)) {
desiredSizeAscent = std::max(desiredSizeAscent,
longdivAscent + leading);
desiredSizeDescent = std::max(desiredSizeDescent,
longdivDescent + mRuleThickness);
}
if (IsToDraw(NOTATION_RADICAL)) {
desiredSizeAscent = std::max(desiredSizeAscent,
radicalAscent + leading);
desiredSizeDescent = std::max(desiredSizeDescent,
radicalDescent + mRuleThickness);
}
aDesiredSize.SetTopAscent(desiredSizeAscent);
aDesiredSize.Height() = desiredSizeAscent + desiredSizeDescent;
}
if (IsToDraw(NOTATION_CIRCLE) ||
IsToDraw(NOTATION_ROUNDEDBOX) ||
(IsToDraw(NOTATION_TOP) && IsToDraw(NOTATION_BOTTOM))) {
示例10: availSize
nsresult
nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
nsresult rv;
aDesiredSize.Width() = aDesiredSize.Height() = 0;
aDesiredSize.SetTopAscent(0);
aDesiredSize.mBoundingMetrics = nsBoundingMetrics();
int32_t i;
const nsStyleFont* font = StyleFont();
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
aReflowState.rendContext->SetFont(fm);
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;
nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
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.GetWritingMode(),
aDesiredSize.mFlags
| NS_REFLOW_CALC_BOUNDING_METRICS);
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
childFrame, availSize);
rv = ReflowChild(childFrame, aPresContext, childDesiredSize,
childReflowState, childStatus);
//NS_ASSERTION(NS_FRAME_IS_COMPLETE(childStatus), "bad status");
if (NS_FAILED(rv)) {
// Call DidReflow() for the child frames we successfully did reflow.
DidReflowChildren(firstChild, childFrame);
return rv;
}
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
nscoord childDescent = childDesiredSize.Height() - childDesiredSize.TopAscent();
if (descent < childDescent)
descent = childDescent;
if (ascent < childDesiredSize.TopAscent())
ascent = childDesiredSize.TopAscent();
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.GetWritingMode());
// 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.TopAscent();
if (descent < childDescent)
descent = childDescent;
//.........这里部分代码省略.........
示例11: if
//.........这里部分代码省略.........
} // else align the baselines
mBoundingMetrics.ascent = height - mBoundingMetrics.descent;
}
}
}
// Fixup for the final height.
// On one hand, our stretchy height can sometimes be shorter than surrounding
// ASCII chars, e.g., arrow symbols have |mBoundingMetrics.ascent + leading|
// that is smaller than the ASCII's ascent, hence when painting the background
// later, it won't look uniform along the line.
// On the other hand, sometimes we may leave too much gap when our glyph happens
// to come from a font with tall glyphs. For example, since CMEX10 has very tall
// glyphs, its natural font metrics are large, even if we pick a small glyph
// whose size is comparable to the size of a normal ASCII glyph.
// So to avoid uneven spacing in either of these two cases, we use the height
// of the ASCII font as a reference and try to match it if possible.
// special case for accents... keep them short to improve mouse operations...
// an accent can only be the non-first child of <mover>, <munder>, <munderover>
bool isAccent =
NS_MATHML_EMBELLISH_IS_ACCENT(mEmbellishData.flags);
if (isAccent) {
nsEmbellishData parentData;
GetEmbellishDataFrom(mParent, parentData);
isAccent =
(NS_MATHML_EMBELLISH_IS_ACCENTOVER(parentData.flags) ||
NS_MATHML_EMBELLISH_IS_ACCENTUNDER(parentData.flags)) &&
parentData.coreFrame != this;
}
if (isAccent && firstChild) {
// see bug 188467 for what is going on here
nscoord dy = aDesiredStretchSize.TopAscent() - (mBoundingMetrics.ascent + leading);
aDesiredStretchSize.SetTopAscent(mBoundingMetrics.ascent + leading);
aDesiredStretchSize.Height() = aDesiredStretchSize.TopAscent() + mBoundingMetrics.descent;
firstChild->SetPosition(firstChild->GetPosition() - nsPoint(0, dy));
}
else if (useMathMLChar) {
nscoord ascent = fm->MaxAscent();
nscoord descent = fm->MaxDescent();
aDesiredStretchSize.SetTopAscent(std::max(mBoundingMetrics.ascent + leading, ascent));
aDesiredStretchSize.Height() = aDesiredStretchSize.TopAscent() +
std::max(mBoundingMetrics.descent + leading, descent);
}
aDesiredStretchSize.Width() = mBoundingMetrics.width;
aDesiredStretchSize.mBoundingMetrics = mBoundingMetrics;
mReference.x = 0;
mReference.y = aDesiredStretchSize.TopAscent();
// Place our mMathMLChar, its origin is in our coordinate system
if (useMathMLChar) {
nscoord dy = aDesiredStretchSize.TopAscent() - mBoundingMetrics.ascent;
mMathMLChar.SetRect(nsRect(0, dy, charSize.width, charSize.ascent + charSize.descent));
}
// Before we leave... there is a last item in the check-list:
// If our parent is not embellished, it means we are the outermost embellished
// container and so we put the spacing, otherwise we don't include the spacing,
// the outermost embellished container will take care of it.
if (!NS_MATHML_OPERATOR_HAS_EMBELLISH_ANCESTOR(mFlags)) {
// Account the spacing if we are not an accent with explicit attributes
nscoord leadingSpace = mEmbellishData.leadingSpace;
if (isAccent && !NS_MATHML_OPERATOR_HAS_LSPACE_ATTR(mFlags)) {
leadingSpace = 0;
示例12: wrappersDesiredSize
nsresult
nsNumberControlFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsNumberControlFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_ASSERTION(mOuterWrapper, "Outer wrapper div must exist!");
NS_ASSERTION(!GetPrevContinuation() && !GetNextContinuation(),
"nsNumberControlFrame should not have continuations; if it does we "
"need to call RegUnregAccessKey only for the first");
NS_ASSERTION(!mFrames.FirstChild() ||
!mFrames.FirstChild()->GetNextSibling(),
"We expect at most one direct child frame");
if (mState & NS_FRAME_FIRST_REFLOW) {
nsFormControlFrame::RegUnRegAccessKey(this, true);
}
// The width of our content box, which is the available width
// for our anonymous content:
const nscoord contentBoxWidth = aReflowState.ComputedWidth();
nscoord contentBoxHeight = aReflowState.ComputedHeight();
nsIFrame* outerWrapperFrame = mOuterWrapper->GetPrimaryFrame();
if (!outerWrapperFrame) { // display:none?
if (contentBoxHeight == NS_INTRINSICSIZE) {
contentBoxHeight = 0;
}
} else {
NS_ASSERTION(outerWrapperFrame == mFrames.FirstChild(), "huh?");
nsHTMLReflowMetrics wrappersDesiredSize(aReflowState.GetWritingMode());
nsHTMLReflowState wrapperReflowState(aPresContext, aReflowState,
outerWrapperFrame,
nsSize(contentBoxWidth,
NS_UNCONSTRAINEDSIZE));
// offsets of wrapper frame
nscoord xoffset = aReflowState.ComputedPhysicalBorderPadding().left +
wrapperReflowState.ComputedPhysicalMargin().left;
nscoord yoffset = aReflowState.ComputedPhysicalBorderPadding().top +
wrapperReflowState.ComputedPhysicalMargin().top;
nsReflowStatus childStatus;
nsresult rv = ReflowChild(outerWrapperFrame, aPresContext,
wrappersDesiredSize, wrapperReflowState,
xoffset, yoffset, 0, childStatus);
NS_ENSURE_SUCCESS(rv, rv);
MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(childStatus),
"We gave our child unconstrained height, so it should be complete");
nscoord wrappersMarginBoxHeight = wrappersDesiredSize.Height() +
wrapperReflowState.ComputedPhysicalMargin().TopBottom();
if (contentBoxHeight == NS_INTRINSICSIZE) {
// We are intrinsically sized -- we should shrinkwrap the outer wrapper's
// height:
contentBoxHeight = wrappersMarginBoxHeight;
// Make sure we obey min/max-height in the case when we're doing intrinsic
// sizing (we get it for free when we have a non-intrinsic
// aReflowState.ComputedHeight()). Note that we do this before
// adjusting for borderpadding, since mComputedMaxHeight and
// mComputedMinHeight are content heights.
contentBoxHeight =
NS_CSS_MINMAX(contentBoxHeight,
aReflowState.ComputedMinHeight(),
aReflowState.ComputedMaxHeight());
}
// Center child vertically
nscoord extraSpace = contentBoxHeight - wrappersMarginBoxHeight;
yoffset += std::max(0, extraSpace / 2);
// Place the child
rv = FinishReflowChild(outerWrapperFrame, aPresContext,
wrappersDesiredSize, &wrapperReflowState,
xoffset, yoffset, 0);
NS_ENSURE_SUCCESS(rv, rv);
aDesiredSize.SetTopAscent(wrappersDesiredSize.TopAscent() +
outerWrapperFrame->GetPosition().y);
}
aDesiredSize.Width() = contentBoxWidth +
aReflowState.ComputedPhysicalBorderPadding().LeftRight();
aDesiredSize.Height() = contentBoxHeight +
aReflowState.ComputedPhysicalBorderPadding().TopBottom();
aDesiredSize.SetOverflowAreasToDesiredBounds();
if (outerWrapperFrame) {
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, outerWrapperFrame);
//.........这里部分代码省略.........