本文整理汇总了C++中nsHTMLReflowMetrics::TopAscent方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowMetrics::TopAscent方法的具体用法?C++ nsHTMLReflowMetrics::TopAscent怎么用?C++ nsHTMLReflowMetrics::TopAscent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowMetrics
的用法示例。
在下文中一共展示了nsHTMLReflowMetrics::TopAscent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
nsMathMLmpaddedFrame::UpdateValue(int32_t aSign,
int32_t aPseudoUnit,
const nsCSSValue& aCSSValue,
const nsHTMLReflowMetrics& aDesiredSize,
nscoord& aValueToUpdate) const
{
nsCSSUnit unit = aCSSValue.GetUnit();
if (NS_MATHML_SIGN_INVALID != aSign && eCSSUnit_Null != unit) {
nscoord scaler = 0, amount = 0;
if (eCSSUnit_Percent == unit || eCSSUnit_Number == unit) {
switch(aPseudoUnit) {
case NS_MATHML_PSEUDO_UNIT_WIDTH:
scaler = aDesiredSize.Width();
break;
case NS_MATHML_PSEUDO_UNIT_HEIGHT:
scaler = aDesiredSize.TopAscent();
break;
case NS_MATHML_PSEUDO_UNIT_DEPTH:
scaler = aDesiredSize.Height() - aDesiredSize.TopAscent();
break;
default:
// if we ever reach here, it would mean something is wrong
// somewhere with the setup and/or the caller
NS_ERROR("Unexpected Pseudo Unit");
return;
}
}
if (eCSSUnit_Number == unit)
amount = NSToCoordRound(float(scaler) * aCSSValue.GetFloatValue());
else if (eCSSUnit_Percent == unit)
amount = NSToCoordRound(float(scaler) * aCSSValue.GetPercentValue());
else
amount = CalcLength(PresContext(), mStyleContext, aCSSValue);
if (NS_MATHML_SIGN_PLUS == aSign)
aValueToUpdate += amount;
else if (NS_MATHML_SIGN_MINUS == aSign)
aValueToUpdate -= amount;
else
aValueToUpdate = amount;
}
}
示例2: 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;
}
示例3: 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);
}
示例4: 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;
//.........这里部分代码省略.........
示例5: while
//.........这里部分代码省略.........
break;
}
// Keep reparenting the remaining siblings, but don't reflow them.
nsFrameList* pushedFrames = GetOverflowFrames();
if (pushedFrames && pushedFrames->FirstChild() == frame) {
// Don't bother if |frame| was pushed to our overflow list.
break;
}
} else {
irs.mPrevFrame = frame;
}
}
frame = frame->GetNextSibling();
}
// Attempt to pull frames from our next-in-flow until we can't
if (!done && GetNextInFlow()) {
while (true) {
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
bool isComplete;
if (!frame) { // Could be non-null if we pulled a first-letter frame and
// it created a continuation, since we don't push those.
frame = PullOneFrame(aPresContext, irs, &isComplete);
}
#ifdef NOISY_PUSHING
printf("%p pulled up %p\n", this, frame);
#endif
if (nullptr == frame) {
if (!isComplete) {
aStatus = NS_FRAME_NOT_COMPLETE;
}
break;
}
ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus);
if (NS_INLINE_IS_BREAK(aStatus) ||
(!reflowingFirstLetter && NS_FRAME_IS_NOT_COMPLETE(aStatus))) {
break;
}
irs.mPrevFrame = frame;
frame = frame->GetNextSibling();
}
}
NS_ASSERTION(!NS_FRAME_IS_COMPLETE(aStatus) || !GetOverflowFrames(),
"We can't be complete AND have overflow frames!");
// If after reflowing our children they take up no area then make
// sure that we don't either.
//
// Note: CSS demands that empty inline elements still affect the
// line-height calculations. However, continuations of an inline
// that are empty we force to empty so that things like collapsed
// whitespace in an inline element don't affect the line-height.
aMetrics.ISize(lineWM) = lineLayout->EndSpan(this);
// Compute final width.
// XXX Note that that the padding start and end are in the frame's
// writing mode, but the metrics' inline-size is in the line's
// writing mode. This makes sense if the line and frame are both
// vertical or both horizontal, but what should happen with
// orthogonal inlines?
// Make sure to not include our start border and padding if we have a prev
// continuation or if we're in a part of an {ib} split other than the first
// one. For box-decoration-break:clone we always include our start border
// and padding since all continuations have them.
if ((!GetPrevContinuation() && !FrameIsNonFirstInIBSplit()) ||
boxDecorationBreakClone) {
aMetrics.ISize(lineWM) += framePadding.IStart(frameWM);
}
/*
* We want to only apply the end border and padding if we're the last
* continuation and either not in an {ib} split or the last part of it. To
* be the last continuation we have to be complete (so that we won't get a
* next-in-flow) and have no non-fluid continuations on our continuation
* chain. For box-decoration-break:clone we always apply the end border and
* padding since all continuations have them.
*/
if ((NS_FRAME_IS_COMPLETE(aStatus) &&
!LastInFlow()->GetNextContinuation() &&
!FrameIsNonLastInIBSplit()) ||
boxDecorationBreakClone) {
aMetrics.ISize(lineWM) += framePadding.IEnd(frameWM);
}
nsLayoutUtils::SetBSizeFromFontMetrics(this, aMetrics, aReflowState,
framePadding, lineWM, frameWM);
// For now our overflow area is zero. The real value will be
// computed in |nsLineLayout::RelativePositionFrames|.
aMetrics.mOverflowAreas.Clear();
#ifdef NOISY_FINAL_SIZE
ListTag(stdout);
printf(": metrics=%d,%d ascent=%d\n",
aMetrics.Width(), aMetrics.Height(), aMetrics.TopAscent());
#endif
}
示例6: DidReflowChildren
/* virtual */ nsresult
nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
nsresult rv =
nsMathMLContainerFrame::Place(aRenderingContext, false, aDesiredSize);
if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) {
DidReflowChildren(GetFirstPrincipalChild());
return rv;
}
nscoord height = aDesiredSize.TopAscent();
nscoord depth = aDesiredSize.Height() - aDesiredSize.TopAscent();
// The REC says:
//
// "The lspace attribute ('leading' space) specifies the horizontal location
// of the positioning point of the child content with respect to the
// positioning point of the mpadded element. By default they coincide, and
// therefore absolute values for lspace have the same effect as relative
// 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;
}
//.........这里部分代码省略.........
示例7: 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))) {
示例8: 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;
//.........这里部分代码省略.........
示例9: if
//.........这里部分代码省略.........
(container.ascent + container.descent)/2 - container.ascent;
} // 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)) {
示例10: while
//.........这里部分代码省略.........
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
bool isComplete;
if (!frame) { // Could be non-null if we pulled a first-letter frame and
// it created a continuation, since we don't push those.
frame = PullOneFrame(aPresContext, irs, &isComplete);
}
#ifdef NOISY_PUSHING
printf("%p pulled up %p\n", this, frame);
#endif
if (nullptr == frame) {
if (!isComplete) {
aStatus = NS_FRAME_NOT_COMPLETE;
}
break;
}
rv = ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus);
if (NS_FAILED(rv) ||
NS_INLINE_IS_BREAK(aStatus) ||
(!reflowingFirstLetter && NS_FRAME_IS_NOT_COMPLETE(aStatus))) {
break;
}
irs.mPrevFrame = frame;
frame = frame->GetNextSibling();
}
}
NS_ASSERTION(!NS_FRAME_IS_COMPLETE(aStatus) || !GetOverflowFrames(),
"We can't be complete AND have overflow frames!");
// If after reflowing our children they take up no area then make
// sure that we don't either.
//
// Note: CSS demands that empty inline elements still affect the
// line-height calculations. However, continuations of an inline
// that are empty we force to empty so that things like collapsed
// whitespace in an inline element don't affect the line-height.
aMetrics.Width() = lineLayout->EndSpan(this);
// Compute final width.
// Make sure to not include our start border and padding if we have a prev
// continuation or if we're in a part of an {ib} split other than the first
// one.
if (!GetPrevContinuation() && !FrameIsNonFirstInIBSplit()) {
aMetrics.Width() += ltr ? aReflowState.ComputedPhysicalBorderPadding().left
: aReflowState.ComputedPhysicalBorderPadding().right;
}
/*
* We want to only apply the end border and padding if we're the last
* continuation and either not in an {ib} split or the last part of it. To
* be the last continuation we have to be complete (so that we won't get a
* next-in-flow) and have no non-fluid continuations on our continuation
* chain.
*/
if (NS_FRAME_IS_COMPLETE(aStatus) &&
!LastInFlow()->GetNextContinuation() &&
!FrameIsNonLastInIBSplit()) {
aMetrics.Width() += ltr ? aReflowState.ComputedPhysicalBorderPadding().right
: aReflowState.ComputedPhysicalBorderPadding().left;
}
nsRefPtr<nsFontMetrics> fm;
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), inflation);
aReflowState.rendContext->SetFont(fm);
if (fm) {
// Compute final height of the frame.
//
// Do things the standard css2 way -- though it's hard to find it
// in the css2 spec! It's actually found in the css1 spec section
// 4.4 (you will have to read between the lines to really see
// it).
//
// The height of our box is the sum of our font size plus the top
// and bottom border and padding. The height of children do not
// affect our height.
aMetrics.SetTopAscent(fm->MaxAscent());
aMetrics.Height() = fm->MaxHeight();
} else {
NS_WARNING("Cannot get font metrics - defaulting sizes to 0");
aMetrics.SetTopAscent(aMetrics.Height() = 0);
}
aMetrics.SetTopAscent(aMetrics.TopAscent() + aReflowState.ComputedPhysicalBorderPadding().top);
aMetrics.Height() += aReflowState.ComputedPhysicalBorderPadding().top +
aReflowState.ComputedPhysicalBorderPadding().bottom;
// For now our overflow area is zero. The real value will be
// computed in |nsLineLayout::RelativePositionFrames|.
aMetrics.mOverflowAreas.Clear();
#ifdef NOISY_FINAL_SIZE
ListTag(stdout);
printf(": metrics=%d,%d ascent=%d\n",
aMetrics.Width(), aMetrics.Height(), aMetrics.TopAscent());
#endif
return rv;
}