--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -747,38 +747,30 @@ InitCharGlobals()
}
// -----------------------------------------------------------------------------
// And now the implementation of nsMathMLChar
nsMathMLChar::~nsMathMLChar()
{
MOZ_COUNT_DTOR(nsMathMLChar);
- mStyleContext->Release();
}
nsStyleContext*
nsMathMLChar::GetStyleContext() const
{
NS_ASSERTION(mStyleContext, "chars should always have style context");
return mStyleContext;
}
void
nsMathMLChar::SetStyleContext(nsStyleContext* aStyleContext)
{
- NS_PRECONDITION(aStyleContext, "null ptr");
- if (aStyleContext != mStyleContext) {
- if (mStyleContext)
- mStyleContext->Release();
- if (aStyleContext) {
- mStyleContext = aStyleContext;
- aStyleContext->AddRef();
- }
- }
+ MOZ_ASSERT(aStyleContext);
+ mStyleContext = aStyleContext;
}
void
nsMathMLChar::SetData(nsString& aData)
{
if (!gGlyphTableInitialized) {
InitCharGlobals();
}
@@ -1499,53 +1491,55 @@ InsertMathFallbacks(FontFamilyList& aFam
if (!inserted) {
aMergedList.Append(aFallbacks);
}
aFamilyList = aMergedList;
}
nsresult
-nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
+nsMathMLChar::StretchInternal(nsIFrame* aForFrame,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsStretchDirection& aStretchDirection,
const nsBoundingMetrics& aContainerSize,
nsBoundingMetrics& aDesiredStretchSize,
uint32_t aStretchHint,
// These are currently only used when
// aStretchHint & NS_STRETCH_MAXWIDTH:
float aMaxSize,
bool aMaxSizeIsAbsolute)
{
+ nsPresContext* presContext = aForFrame->PresContext();
+
// if we have been called before, and we didn't actually stretch, our
// direction may have been set to NS_STRETCH_DIRECTION_UNSUPPORTED.
// So first set our direction back to its instrinsic value
nsStretchDirection direction = nsMathMLOperators::GetStretchyDirection(mData);
// Set default font and get the default bounding metrics
// mStyleContext is a leaf context used only when stretching happens.
// For the base size, the default font should come from the parent context
- nsFont font = mStyleContext->GetParentAllowServo()->StyleFont()->mFont;
+ nsFont font = aForFrame->StyleFont()->mFont;
NormalizeDefaultFont(font, aFontSizeInflation);
const nsStyleFont* styleFont = mStyleContext->StyleFont();
nsFontMetrics::Params params;
params.language = styleFont->mLanguage;
params.explicitLanguage = styleFont->mExplicitLanguage;
- params.userFontSet = aPresContext->GetUserFontSet();
- params.textPerf = aPresContext->GetTextPerfMetrics();
+ params.userFontSet = presContext->GetUserFontSet();
+ params.textPerf = presContext->GetTextPerfMetrics();
RefPtr<nsFontMetrics> fm =
- aPresContext->DeviceContext()->GetMetricsFor(font, params);
+ presContext->DeviceContext()->GetMetricsFor(font, params);
uint32_t len = uint32_t(mData.Length());
mGlyphs[0] = fm->GetThebesFontGroup()->
MakeTextRun(static_cast<const char16_t*>(mData.get()), len, aDrawTarget,
- aPresContext->AppUnitsPerDevPixel(),
+ presContext->AppUnitsPerDevPixel(),
gfx::ShapedTextFlags(), nsTextFrameUtils::Flags(),
- aPresContext->MissingFontRecorder());
+ presContext->MissingFontRecorder());
aDesiredStretchSize = MeasureTextRun(aDrawTarget, mGlyphs[0].get());
bool maxWidth = (NS_STRETCH_MAXWIDTH & aStretchHint) != 0;
if (!maxWidth) {
mUnscaledAscent = aDesiredStretchSize.ascent;
}
//////////////////////////////////////////////////////////////////////////////
@@ -1651,17 +1645,17 @@ nsMathMLChar::StretchInternal(nsPresCont
#ifdef NOISY_SEARCH
nsAutoString fontlistStr;
font.fontlist.ToString(fontlistStr, false, true);
printf("Searching in "%s" for a glyph of appropriate size for: 0x%04X:%c\n",
NS_ConvertUTF16toUTF8(fontlistStr).get(), mData[0], mData[0]&0x00FF);
#endif
- StretchEnumContext enumData(this, aPresContext, aDrawTarget,
+ StretchEnumContext enumData(this, presContext, aDrawTarget,
aFontSizeInflation,
aStretchDirection, targetSize, aStretchHint,
aDesiredStretchSize, font.fontlist, glyphFound);
enumData.mTryParts = !largeopOnly;
const nsTArray<FontFamilyName>& fontlist = font.fontlist.GetFontlist();
uint32_t i, num = fontlist.Length();
bool next = true;
@@ -1679,17 +1673,17 @@ nsMathMLChar::StretchInternal(nsPresCont
if (glyphFound) {
return NS_OK;
}
// We did not find a size variant or a glyph assembly to stretch this
// operator. Verify whether a font with an OpenType MATH table is available
// and record missing math script otherwise.
- gfxMissingFontRecorder* MFR = aPresContext->MissingFontRecorder();
+ gfxMissingFontRecorder* MFR = presContext->MissingFontRecorder();
if (MFR && !fm->GetThebesFontGroup()->GetFirstMathFont()) {
MFR->RecordScript(unicode::Script::MATHEMATICAL_NOTATION);
}
// If the scale_stretchy_operators option is disabled, we are done.
if (!Preferences::GetBool("mathml.scale_stretchy_operators.enabled", true)) {
return NS_OK;
}
@@ -1763,17 +1757,17 @@ nsMathMLChar::StretchInternal(nsPresCont
aDesiredStretchSize.descent *= scale;
}
}
return NS_OK;
}
nsresult
-nsMathMLChar::Stretch(nsPresContext* aPresContext,
+nsMathMLChar::Stretch(nsIFrame* aForFrame,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsStretchDirection aStretchDirection,
const nsBoundingMetrics& aContainerSize,
nsBoundingMetrics& aDesiredStretchSize,
uint32_t aStretchHint,
bool aRTL)
{
@@ -1782,17 +1776,17 @@ nsMathMLChar::Stretch(nsPresContext*
NS_STRETCH_INTEGRAL)),
"Unexpected stretch flags");
mDraw = DRAW_NORMAL;
mMirrored = aRTL && nsMathMLOperators::IsMirrorableOperator(mData);
mScaleY = mScaleX = 1.0;
mDirection = aStretchDirection;
nsresult rv =
- StretchInternal(aPresContext, aDrawTarget, aFontSizeInflation, mDirection,
+ StretchInternal(aForFrame, aDrawTarget, aFontSizeInflation, mDirection,
aContainerSize, aDesiredStretchSize, aStretchHint);
// Record the metrics
mBoundingMetrics = aDesiredStretchSize;
return rv;
}
@@ -1804,25 +1798,27 @@ nsMathMLChar::Stretch(nsPresContext*
// In order to avoid considering widths of some characters in fonts that will
// not be used for any stretch size, StretchInternal sets the initial height
// to infinity and looks for any characters smaller than this height. When a
// character built from parts is considered, (it will be used by Stretch for
// any characters greater than its minimum size, so) the height is set to its
// minimum size, so that only widths of smaller subsequent characters are
// considered.
nscoord
-nsMathMLChar::GetMaxWidth(nsPresContext* aPresContext, DrawTarget* aDrawTarget,
- float aFontSizeInflation, uint32_t aStretchHint)
+nsMathMLChar::GetMaxWidth(nsIFrame* aForFrame,
+ DrawTarget* aDrawTarget,
+ float aFontSizeInflation,
+ uint32_t aStretchHint)
{
nsBoundingMetrics bm;
nsStretchDirection direction = NS_STRETCH_DIRECTION_VERTICAL;
const nsBoundingMetrics container; // zero target size
- StretchInternal(aPresContext, aDrawTarget, aFontSizeInflation, direction,
- container, bm, aStretchHint | NS_STRETCH_MAXWIDTH);
+ StretchInternal(aForFrame, aDrawTarget, aFontSizeInflation,
+ direction, container, bm, aStretchHint | NS_STRETCH_MAXWIDTH);
return std::max(bm.width, bm.rightBearing) - std::min(0, bm.leftBearing);
}
class nsDisplayMathMLSelectionRect : public nsDisplayItem {
public:
nsDisplayMathMLSelectionRect(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, const nsRect& aRect)
@@ -1883,18 +1879,17 @@ public:
// Bug 748220
temp.Inflate(mFrame->PresContext()->AppUnitsPerDevPixel());
return temp;
}
virtual void Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) override
{
- mChar->PaintForeground(mFrame->PresContext(), *aCtx,
- ToReferenceFrame(), mIsSelected);
+ mChar->PaintForeground(mFrame, *aCtx, ToReferenceFrame(), mIsSelected);
}
NS_DISPLAY_DECL_NAME("MathMLCharForeground", TYPE_MATHML_CHAR_FOREGROUND)
virtual nsRect GetComponentAlphaBounds(nsDisplayListBuilder* aBuilder) override
{
bool snap;
return GetBounds(aBuilder, &snap);
@@ -1960,17 +1955,17 @@ void nsDisplayMathMLCharDebug::Paint(nsD
void
nsMathMLChar::Display(nsDisplayListBuilder* aBuilder,
nsIFrame* aForFrame,
const nsDisplayListSet& aLists,
uint32_t aIndex,
const nsRect* aSelectedRect)
{
- nsStyleContext* parentContext = mStyleContext->GetParentAllowServo();
+ nsStyleContext* parentContext = aForFrame->StyleContext();
nsStyleContext* styleContext = mStyleContext;
if (mDraw == DRAW_NORMAL) {
// normal drawing if there is nothing special about this char
// Set default context to the parent context
styleContext = parentContext;
}
@@ -2033,23 +2028,24 @@ nsMathMLChar::ApplyTransforms(gfxContext
// update the bounding rectangle.
r.x = r.y = 0;
r.width /= mScaleX;
r.height /= mScaleY;
}
void
-nsMathMLChar::PaintForeground(nsPresContext* aPresContext,
+nsMathMLChar::PaintForeground(nsIFrame* aForFrame,
gfxContext& aRenderingContext,
nsPoint aPt,
bool aIsSelected)
{
- nsStyleContext* parentContext = mStyleContext->GetParentAllowServo();
+ nsStyleContext* parentContext = aForFrame->StyleContext();
nsStyleContext* styleContext = mStyleContext;
+ nsPresContext* presContext = aForFrame->PresContext();
if (mDraw == DRAW_NORMAL) {
// normal drawing if there is nothing special about this char
// Set default context to the parent context
styleContext = parentContext;
}
// Set color ...
@@ -2058,35 +2054,35 @@ nsMathMLChar::PaintForeground(nsPresCont
if (aIsSelected) {
// get color to use for selection from the look&feel object
fgColor = LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectForeground,
fgColor);
}
aRenderingContext.SetColor(Color::FromABGR(fgColor));
aRenderingContext.Save();
nsRect r = mRect + aPt;
- ApplyTransforms(&aRenderingContext, aPresContext->AppUnitsPerDevPixel(), r);
+ ApplyTransforms(&aRenderingContext, aForFrame->PresContext()->AppUnitsPerDevPixel(), r);
switch(mDraw)
{
case DRAW_NORMAL:
case DRAW_VARIANT:
// draw a single glyph (base size or size variant)
// XXXfredw verify if mGlyphs[0] is non-null to workaround bug 973322.
if (mGlyphs[0]) {
mGlyphs[0]->Draw(Range(mGlyphs[0].get()), gfxPoint(0.0, mUnscaledAscent),
gfxTextRun::DrawParams(&aRenderingContext));
}
break;
case DRAW_PARTS: {
// paint by parts
if (NS_STRETCH_DIRECTION_VERTICAL == mDirection)
- PaintVertically(aPresContext, &aRenderingContext, r, fgColor);
+ PaintVertically(presContext, &aRenderingContext, r, fgColor);
else if (NS_STRETCH_DIRECTION_HORIZONTAL == mDirection)
- PaintHorizontally(aPresContext, &aRenderingContext, r, fgColor);
+ PaintHorizontally(presContext, &aRenderingContext, r, fgColor);
break;
}
default:
NS_NOTREACHED("Unknown drawing method");
break;
}
aRenderingContext.Restore();
--- a/layout/mathml/nsMathMLChar.h
+++ b/layout/mathml/nsMathMLChar.h
@@ -101,26 +101,26 @@ public:
~nsMathMLChar();
void Display(nsDisplayListBuilder* aBuilder,
nsIFrame* aForFrame,
const nsDisplayListSet& aLists,
uint32_t aIndex,
const nsRect* aSelectedRect = nullptr);
- void PaintForeground(nsPresContext* aPresContext,
+ void PaintForeground(nsIFrame* aForFrame,
gfxContext& aRenderingContext,
nsPoint aPt,
bool aIsSelected);
// This is the method called to ask the char to stretch itself.
// @param aContainerSize - IN - suggested size for the stretched char
// @param aDesiredStretchSize - OUT - the size that the char wants
nsresult
- Stretch(nsPresContext* aPresContext,
+ Stretch(nsIFrame* aForFrame,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsStretchDirection aStretchDirection,
const nsBoundingMetrics& aContainerSize,
nsBoundingMetrics& aDesiredStretchSize,
uint32_t aStretchHint,
bool aRTL);
@@ -160,17 +160,17 @@ public:
}
// Get the maximum width that the character might have after a vertical
// Stretch().
//
// @param aStretchHint can be the value that will be passed to Stretch().
// It is used to determine whether the operator is stretchy or a largeop.
nscoord
- GetMaxWidth(nsPresContext* aPresContext,
+ GetMaxWidth(nsIFrame* aForFrame,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
uint32_t aStretchHint = NS_STRETCH_NORMAL);
// Metrics that _exactly_ enclose the char. The char *must* have *already*
// being stretched before you can call the GetBoundingMetrics() method.
// IMPORTANT: since chars have their own style contexts, and may be rendered
// with glyphs that are not in the parent font, just calling the default
@@ -198,17 +198,17 @@ protected:
friend class nsPropertiesTable;
friend class nsOpenTypeTable;
nsString mData;
private:
nsRect mRect;
nsStretchDirection mDirection;
nsBoundingMetrics mBoundingMetrics;
- nsStyleContext* mStyleContext;
+ RefPtr<nsStyleContext> mStyleContext;
// mGlyphs/mBmData are arrays describing the glyphs used to draw the operator.
// See the drawing methods below.
RefPtr<gfxTextRun> mGlyphs[4];
nsBoundingMetrics mBmData[4];
// mUnscaledAscent is the actual ascent of the char.
nscoord mUnscaledAscent;
// mScaleX, mScaleY are the factors by which we scale the char.
float mScaleX, mScaleY;
@@ -234,17 +234,17 @@ private:
SetFontFamily(nsPresContext* aPresContext,
const nsGlyphTable* aGlyphTable,
const nsGlyphCode& aGlyphCode,
const mozilla::FontFamilyList& aDefaultFamily,
nsFont& aFont,
RefPtr<gfxFontGroup>* aFontGroup);
nsresult
- StretchInternal(nsPresContext* aPresContext,
+ StretchInternal(nsIFrame* aForFrame,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsStretchDirection& aStretchDirection,
const nsBoundingMetrics& aContainerSize,
nsBoundingMetrics& aDesiredStretchSize,
uint32_t aStretchHint,
float aMaxSize = NS_MATHML_OPERATOR_SIZE_INFINITY,
bool aMaxSizeIsAbsolute = false);
--- a/layout/mathml/nsMathMLmencloseFrame.cpp
+++ b/layout/mathml/nsMathMLmencloseFrame.cpp
@@ -478,29 +478,29 @@ nsMathMLmencloseFrame::PlaceInternal(Dra
bmBase.descent + padding2);
}
///////////////
// longdiv notation:
if (IsToDraw(NOTATION_LONGDIV)) {
if (aWidthOnly) {
nscoord longdiv_width = mMathMLChar[mLongDivCharIndex].
- GetMaxWidth(PresContext(), aDrawTarget, fontSizeInflation);
+ GetMaxWidth(this, aDrawTarget, fontSizeInflation);
// Update horizontal parameters
dx_left = std::max(dx_left, longdiv_width);
} else {
// Stretch the parenthesis to the appropriate height if it is not
// big enough.
nsBoundingMetrics contSize = bmBase;
contSize.ascent = mRuleThickness;
contSize.descent = bmBase.ascent + bmBase.descent + psi;
// height(longdiv) should be >= height(base) + psi + mRuleThickness
- mMathMLChar[mLongDivCharIndex].Stretch(PresContext(), aDrawTarget,
+ mMathMLChar[mLongDivCharIndex].Stretch(this, aDrawTarget,
fontSizeInflation,
NS_STRETCH_DIRECTION_VERTICAL,
contSize, bmLongdivChar,
NS_STRETCH_LARGER, false);
mMathMLChar[mLongDivCharIndex].GetBoundingMetrics(bmLongdivChar);
// Update horizontal parameters
dx_left = std::max(dx_left, bmLongdivChar.width);
@@ -520,29 +520,29 @@ nsMathMLmencloseFrame::PlaceInternal(Dra
///////////////
// radical notation:
if (IsToDraw(NOTATION_RADICAL)) {
nscoord *dx_leading = StyleVisibility()->mDirection ? &dx_right : &dx_left;
if (aWidthOnly) {
nscoord radical_width = mMathMLChar[mRadicalCharIndex].
- GetMaxWidth(PresContext(), aDrawTarget, fontSizeInflation);
+ GetMaxWidth(this, aDrawTarget, fontSizeInflation);
// Update horizontal parameters
*dx_leading = std::max(*dx_leading, radical_width);
} else {
// Stretch the radical symbol to the appropriate height if it is not
// big enough.
nsBoundingMetrics contSize = bmBase;
contSize.ascent = mRadicalRuleThickness;
contSize.descent = bmBase.ascent + bmBase.descent + psi;
// height(radical) should be >= height(base) + psi + mRadicalRuleThickness
- mMathMLChar[mRadicalCharIndex].Stretch(PresContext(), aDrawTarget,
+ mMathMLChar[mRadicalCharIndex].Stretch(this, aDrawTarget,
fontSizeInflation,
NS_STRETCH_DIRECTION_VERTICAL,
contSize, bmRadicalChar,
NS_STRETCH_LARGER,
StyleVisibility()->mDirection);
mMathMLChar[mRadicalCharIndex].GetBoundingMetrics(bmRadicalChar);
// Update horizontal parameters
--- a/layout/mathml/nsMathMLmfencedFrame.cpp
+++ b/layout/mathml/nsMathMLmfencedFrame.cpp
@@ -185,26 +185,26 @@ nsMathMLmfencedFrame::BuildDisplayList(n
/* @param aMetrics is an IN/OUT. Provide the current metrics for the mFenced
frame and it will be enlarged as necessary.
For simplicity the width of the container is always incremented by the width
of the nsMathMLChar. As we only stretch fences and separators in the vertical
direction, this has no impact on overall appearance.
*/
static void
-ApplyUnstretchedMetrics(nsPresContext* aPresContext,
+ApplyUnstretchedMetrics(nsIFrame* aFrame,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsMathMLChar* aMathMLChar,
nsBoundingMetrics& aMetrics,
bool aIsRTL)
{
if (aMathMLChar && 0 < aMathMLChar->Length()) {
nsBoundingMetrics charSize;
- aMathMLChar->Stretch(aPresContext, aDrawTarget, aFontSizeInflation,
+ aMathMLChar->Stretch(aFrame, aDrawTarget, aFontSizeInflation,
NS_STRETCH_DIRECTION_DEFAULT,
aMetrics, // size is unimportant as we aren't stretching
charSize, NS_STRETCH_NONE, aIsRTL);
aMetrics += charSize;
}
}
void
@@ -317,55 +317,55 @@ nsMathMLmfencedFrame::Reflow(nsPresConte
// bug 121748: for surrounding fences & separators, use a size that covers everything
GetPreferredStretchSize(drawTarget, STRETCH_CONSIDER_EMBELLISHMENTS,
stretchDir, containerSize);
bool isRTL = StyleVisibility()->mDirection;
// To achieve a minimum size of "1", the container should be enlarged by the
// unstretched metrics of the fences and separators.
- ApplyUnstretchedMetrics(aPresContext, drawTarget,
+ ApplyUnstretchedMetrics(this, drawTarget,
fontSizeInflation, mOpenChar,
containerSize, isRTL);
for (i = 0; i < mSeparatorsCount; i++) {
- ApplyUnstretchedMetrics(aPresContext, drawTarget,
+ ApplyUnstretchedMetrics(this, drawTarget,
fontSizeInflation, &mSeparatorsChar[i],
containerSize, isRTL);
}
- ApplyUnstretchedMetrics(aPresContext, drawTarget,
+ ApplyUnstretchedMetrics(this, drawTarget,
fontSizeInflation, mCloseChar,
containerSize, isRTL);
//////////////////////////////////////////
// Prepare the opening fence, separators, and closing fence, and
// adjust the origin of children.
// we need to center around the axis
nscoord delta = std::max(containerSize.ascent - axisHeight,
containerSize.descent + axisHeight);
containerSize.ascent = delta + axisHeight;
containerSize.descent = delta - axisHeight;
/////////////////
// opening fence ...
- ReflowChar(aPresContext, drawTarget, *fm,
+ ReflowChar(drawTarget, *fm,
fontSizeInflation, mOpenChar,
NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel,
axisHeight, leading, em, containerSize, ascent, descent, isRTL);
/////////////////
// separators ...
for (i = 0; i < mSeparatorsCount; i++) {
- ReflowChar(aPresContext, drawTarget, *fm,
+ ReflowChar(drawTarget, *fm,
fontSizeInflation, &mSeparatorsChar[i],
NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel,
axisHeight, leading, em, containerSize, ascent, descent, isRTL);
}
/////////////////
// closing fence ...
- ReflowChar(aPresContext, drawTarget, *fm,
+ ReflowChar(drawTarget, *fm,
fontSizeInflation, mCloseChar,
NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel,
axisHeight, leading, em, containerSize, ascent, descent, isRTL);
//////////////////
// Adjust the origins of each child.
// and update our bounding metrics
@@ -471,19 +471,18 @@ GetCharSpacing(nsMathMLChar* aMat
rspace /= 2.0f;
}
aLeftSpace = NSToCoordRound(lspace * em);
aRightSpace = NSToCoordRound(rspace * em);
}
// helper functions to perform the common task of formatting our chars
-/*static*/ nsresult
-nsMathMLmfencedFrame::ReflowChar(nsPresContext* aPresContext,
- DrawTarget* aDrawTarget,
+nsresult
+nsMathMLmfencedFrame::ReflowChar(DrawTarget* aDrawTarget,
nsFontMetrics& aFontMetrics,
float aFontSizeInflation,
nsMathMLChar* aMathMLChar,
nsOperatorFlags aForm,
int32_t aScriptLevel,
nscoord axisHeight,
nscoord leading,
nscoord em,
@@ -494,17 +493,17 @@ nsMathMLmfencedFrame::ReflowChar(nsPresC
{
if (aMathMLChar && 0 < aMathMLChar->Length()) {
nscoord leftSpace;
nscoord rightSpace;
GetCharSpacing(aMathMLChar, aForm, aScriptLevel, em, leftSpace, rightSpace);
// stretch the char to the appropriate height if it is not big enough.
nsBoundingMetrics charSize;
- nsresult res = aMathMLChar->Stretch(aPresContext, aDrawTarget,
+ nsresult res = aMathMLChar->Stretch(this, aDrawTarget,
aFontSizeInflation,
NS_STRETCH_DIRECTION_VERTICAL,
aContainerSize, charSize,
NS_STRETCH_NORMAL, aRTL);
if (NS_STRETCH_DIRECTION_UNSUPPORTED != aMathMLChar->GetStretchDirection()) {
// has changed... so center the char around the axis
nscoord height = charSize.ascent + charSize.descent;
@@ -575,25 +574,25 @@ nsMathMLmfencedFrame::PlaceChar(nsMathML
bm.rightBearing += rect.x;
// return rect.width since it includes lspace and rspace
bm.width = rect.width;
dx += rect.width;
}
static nscoord
-GetMaxCharWidth(nsPresContext* aPresContext,
+GetMaxCharWidth(nsIFrame* aFrame,
DrawTarget* aDrawTarget,
float aFontSizeInflation,
nsMathMLChar* aMathMLChar,
nsOperatorFlags aForm,
int32_t aScriptLevel,
nscoord em)
{
- nscoord width = aMathMLChar->GetMaxWidth(aPresContext, aDrawTarget,
+ nscoord width = aMathMLChar->GetMaxWidth(aFrame, aDrawTarget,
aFontSizeInflation);
if (0 < aMathMLChar->Length()) {
nscoord leftSpace;
nscoord rightSpace;
GetCharSpacing(aMathMLChar, aForm, aScriptLevel, em, leftSpace, rightSpace);
width += leftSpace + rightSpace;
@@ -602,51 +601,50 @@ GetMaxCharWidth(nsPresContext* aPr
return width;
}
/* virtual */ void
nsMathMLmfencedFrame::GetIntrinsicISizeMetrics(gfxContext* aRenderingContext, ReflowOutput& aDesiredSize)
{
nscoord width = 0;
- nsPresContext* presContext = PresContext();
const nsStyleFont* font = StyleFont();
float fontSizeInflation = nsLayoutUtils:: FontSizeInflationFor(this);
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation);
nscoord em;
GetEmHeight(fm, em);
if (mOpenChar) {
width +=
- GetMaxCharWidth(presContext, aRenderingContext->GetDrawTarget(),
+ GetMaxCharWidth(this, aRenderingContext->GetDrawTarget(),
fontSizeInflation, mOpenChar,
NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel, em);
}
int32_t i = 0;
for (nsIFrame* childFrame : PrincipalChildList()) {
// XXX This includes margin while Reflow currently doesn't consider
// margin, so we may end up with too much space, but, with stretchy
// characters, this is an approximation anyway.
width += nsLayoutUtils::IntrinsicForContainer(aRenderingContext, childFrame,
nsLayoutUtils::PREF_ISIZE);
if (i < mSeparatorsCount) {
width +=
- GetMaxCharWidth(presContext, aRenderingContext->GetDrawTarget(),
+ GetMaxCharWidth(this, aRenderingContext->GetDrawTarget(),
fontSizeInflation, &mSeparatorsChar[i],
NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel, em);
}
i++;
}
if (mCloseChar) {
width +=
- GetMaxCharWidth(presContext, aRenderingContext->GetDrawTarget(),
+ GetMaxCharWidth(this, aRenderingContext->GetDrawTarget(),
fontSizeInflation, mCloseChar,
NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel, em);
}
aDesiredSize.Width() = width;
aDesiredSize.mBoundingMetrics.width = width;
aDesiredSize.mBoundingMetrics.leftBearing = 0;
aDesiredSize.mBoundingMetrics.rightBearing = width;
--- a/layout/mathml/nsMathMLmfencedFrame.h
+++ b/layout/mathml/nsMathMLmfencedFrame.h
@@ -57,19 +57,18 @@ public:
virtual nsresult
ChildListChanged(int32_t aModType) override;
// override the base method so that we can deal with fences and separators
virtual nscoord
FixInterFrameSpacing(ReflowOutput& aDesiredSize) override;
// helper routines to format the MathMLChars involved here
- static nsresult
- ReflowChar(nsPresContext* aPresContext,
- DrawTarget* aDrawTarget,
+ nsresult
+ ReflowChar(DrawTarget* aDrawTarget,
nsFontMetrics& aFontMetrics,
float aFontSizeInflation,
nsMathMLChar* aMathMLChar,
nsOperatorFlags aForm,
int32_t aScriptLevel,
nscoord axisHeight,
nscoord leading,
nscoord em,
--- a/layout/mathml/nsMathMLmoFrame.cpp
+++ b/layout/mathml/nsMathMLmoFrame.cpp
@@ -733,17 +733,18 @@ nsMathMLmoFrame::Stretch(DrawTarget*
height = container.ascent + container.descent;
container.descent = aContainerSize.descent;
container.ascent = height - container.descent;
}
}
}
// let the MathMLChar stretch itself...
- nsresult res = mMathMLChar.Stretch(PresContext(), aDrawTarget,
+ nsresult res = mMathMLChar.Stretch(this,
+ aDrawTarget,
fontSizeInflation,
aStretchDirection, container, charSize,
stretchHint,
StyleVisibility()->mDirection);
if (NS_FAILED(res)) {
// gracefully handle cases where stretching the char failed (i.e., GetBoundingMetrics failed)
// clear our 'form' to behave as if the operator wasn't in the dictionary
mFlags &= ~NS_MATHML_OPERATOR_FORM;
@@ -969,17 +970,17 @@ nsMathMLmoFrame::Place(DrawTarget*
This is a preliminary stretch - exact sizing/placement is handled by the
Stretch() method.
*/
if (!aPlaceOrigin &&
StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK &&
NS_MATHML_OPERATOR_IS_LARGEOP(mFlags) && UseMathMLChar()) {
nsBoundingMetrics newMetrics;
- rv = mMathMLChar.Stretch(PresContext(), aDrawTarget,
+ rv = mMathMLChar.Stretch(this, aDrawTarget,
nsLayoutUtils::FontSizeInflationFor(this),
NS_STRETCH_DIRECTION_VERTICAL,
aDesiredSize.mBoundingMetrics, newMetrics,
NS_STRETCH_LARGEOP, StyleVisibility()->mDirection);
if (NS_FAILED(rv)) {
// Just use the initial size
return NS_OK;
@@ -1030,17 +1031,17 @@ nsMathMLmoFrame::MarkIntrinsicISizesDirt
nsMathMLmoFrame::GetIntrinsicISizeMetrics(gfxContext* aRenderingContext,
ReflowOutput& aDesiredSize)
{
ProcessOperatorData();
if (UseMathMLChar()) {
uint32_t stretchHint = GetStretchHint(mFlags, mPresentationData, true,
StyleFont());
aDesiredSize.Width() = mMathMLChar.
- GetMaxWidth(PresContext(), aRenderingContext->GetDrawTarget(),
+ GetMaxWidth(this, aRenderingContext->GetDrawTarget(),
nsLayoutUtils::FontSizeInflationFor(this),
stretchHint);
}
else {
nsMathMLTokenFrame::GetIntrinsicISizeMetrics(aRenderingContext,
aDesiredSize);
}
--- a/layout/mathml/nsMathMLmrootFrame.cpp
+++ b/layout/mathml/nsMathMLmrootFrame.cpp
@@ -256,17 +256,17 @@ nsMathMLmrootFrame::Reflow(nsPresContext
// 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;
// height(radical) should be >= height(base) + psi + ruleThickness
nsBoundingMetrics radicalSize;
- mSqrChar.Stretch(aPresContext, drawTarget,
+ mSqrChar.Stretch(this, drawTarget,
fontSizeInflation,
NS_STRETCH_DIRECTION_VERTICAL,
contSize, radicalSize,
NS_STRETCH_LARGER,
StyleVisibility()->mDirection);
// radicalSize have changed at this point, and should match with
// the bounding metrics of the char
mSqrChar.GetBoundingMetrics(bmSqr);
@@ -372,17 +372,17 @@ nsMathMLmrootFrame::GetIntrinsicISizeMet
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this);
nscoord baseWidth =
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, baseFrame,
nsLayoutUtils::PREF_ISIZE);
nscoord indexWidth =
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, indexFrame,
nsLayoutUtils::PREF_ISIZE);
- nscoord sqrWidth = mSqrChar.GetMaxWidth(PresContext(),
+ nscoord sqrWidth = mSqrChar.GetMaxWidth(this,
aRenderingContext->GetDrawTarget(),
fontSizeInflation);
nscoord dxSqr;
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation);
GetRadicalXOffsets(indexWidth, sqrWidth, fm, nullptr, &dxSqr);