зеркало из https://github.com/mozilla/gecko-dev.git
Overall Directionality of formulas (bug 534963). r=karlt
This commit is contained in:
Родитель
05ba069e25
Коммит
d2d546b146
|
@ -467,3 +467,17 @@ msub > :not(:first-child),
|
||||||
msup > :not(:first-child),
|
msup > :not(:first-child),
|
||||||
msubsup > :not(:first-child),
|
msubsup > :not(:first-child),
|
||||||
mmultiscripts > :not(:first-child) { -moz-script-level:+1; }
|
mmultiscripts > :not(:first-child) { -moz-script-level:+1; }
|
||||||
|
|
||||||
|
/*****************************************/
|
||||||
|
/* Controlling directionality */
|
||||||
|
/*****************************************/
|
||||||
|
|
||||||
|
math[dir="rtl"], mstyle[dir="rtl"], mrow[dir="rtl"],
|
||||||
|
mi[dir="rtl"], mn[dir="rtl"], mo[dir="rtl"], mtext[dir="rtl"], ms[dir="rtl"] {
|
||||||
|
direction: rtl;
|
||||||
|
}
|
||||||
|
|
||||||
|
math[dir="ltr"], mstyle[dir="ltr"], mrow[dir="ltr"],
|
||||||
|
mi[dir="ltr"], mn[dir="ltr"], mo[dir="ltr"], mtext[dir="ltr"], ms[dir="ltr"] {
|
||||||
|
direction: ltr;
|
||||||
|
}
|
||||||
|
|
|
@ -1193,20 +1193,21 @@ class nsMathMLContainerFrame::RowChildFrameIterator {
|
||||||
public:
|
public:
|
||||||
explicit RowChildFrameIterator(nsMathMLContainerFrame* aParentFrame) :
|
explicit RowChildFrameIterator(nsMathMLContainerFrame* aParentFrame) :
|
||||||
mParentFrame(aParentFrame),
|
mParentFrame(aParentFrame),
|
||||||
mChildFrame(aParentFrame->mFrames.FirstChild()),
|
|
||||||
mX(0),
|
mX(0),
|
||||||
mCarrySpace(0),
|
mCarrySpace(0),
|
||||||
mFromFrameType(eMathMLFrameType_UNKNOWN)
|
mFromFrameType(eMathMLFrameType_UNKNOWN),
|
||||||
|
mRTL(NS_MATHML_IS_RTL(aParentFrame->mPresentationData.flags))
|
||||||
{
|
{
|
||||||
|
if (!mRTL) {
|
||||||
|
mChildFrame = aParentFrame->mFrames.FirstChild();
|
||||||
|
} else {
|
||||||
|
mChildFrame = aParentFrame->mFrames.LastChild();
|
||||||
|
}
|
||||||
|
|
||||||
if (!mChildFrame)
|
if (!mChildFrame)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
InitMetricsForChild();
|
InitMetricsForChild();
|
||||||
// Remove left correction in <msqrt> because the sqrt glyph itself is
|
|
||||||
// there first.
|
|
||||||
if (mParentFrame->GetContent()->Tag() == nsGkAtoms::msqrt_) {
|
|
||||||
mX = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RowChildFrameIterator& operator++()
|
RowChildFrameIterator& operator++()
|
||||||
|
@ -1214,7 +1215,12 @@ public:
|
||||||
// add child size + italic correction
|
// add child size + italic correction
|
||||||
mX += mSize.mBoundingMetrics.width + mItalicCorrection;
|
mX += mSize.mBoundingMetrics.width + mItalicCorrection;
|
||||||
|
|
||||||
|
if (!mRTL) {
|
||||||
mChildFrame = mChildFrame->GetNextSibling();
|
mChildFrame = mChildFrame->GetNextSibling();
|
||||||
|
} else {
|
||||||
|
mChildFrame = mChildFrame->GetPrevSibling();
|
||||||
|
}
|
||||||
|
|
||||||
if (!mChildFrame)
|
if (!mChildFrame)
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
|
@ -1251,16 +1257,29 @@ private:
|
||||||
PRInt32 mCarrySpace;
|
PRInt32 mCarrySpace;
|
||||||
eMathMLFrameType mFromFrameType;
|
eMathMLFrameType mFromFrameType;
|
||||||
|
|
||||||
|
bool mRTL;
|
||||||
|
|
||||||
void InitMetricsForChild()
|
void InitMetricsForChild()
|
||||||
{
|
{
|
||||||
GetReflowAndBoundingMetricsFor(mChildFrame, mSize, mSize.mBoundingMetrics,
|
GetReflowAndBoundingMetricsFor(mChildFrame, mSize, mSize.mBoundingMetrics,
|
||||||
&mChildFrameType);
|
&mChildFrameType);
|
||||||
nscoord leftCorrection;
|
nscoord leftCorrection, rightCorrection;
|
||||||
GetItalicCorrection(mSize.mBoundingMetrics, leftCorrection,
|
GetItalicCorrection(mSize.mBoundingMetrics,
|
||||||
mItalicCorrection);
|
leftCorrection, rightCorrection);
|
||||||
|
if (!mChildFrame->GetPrevSibling() &&
|
||||||
|
mParentFrame->GetContent()->Tag() == nsGkAtoms::msqrt_) {
|
||||||
|
// Remove leading correction in <msqrt> because the sqrt glyph itself is
|
||||||
|
// there first.
|
||||||
|
if (!mRTL) {
|
||||||
|
leftCorrection = 0;
|
||||||
|
} else {
|
||||||
|
rightCorrection = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
// add left correction -- this fixes the problem of the italic 'f'
|
// add left correction -- this fixes the problem of the italic 'f'
|
||||||
// e.g., <mo>q</mo> <mi>f</mi> <mo>I</mo>
|
// e.g., <mo>q</mo> <mi>f</mi> <mo>I</mo>
|
||||||
mX += leftCorrection;
|
mX += leftCorrection;
|
||||||
|
mItalicCorrection = rightCorrection;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,14 @@ public:
|
||||||
nsIAtom* aAttribute,
|
nsIAtom* aAttribute,
|
||||||
PRInt32 aModType);
|
PRInt32 aModType);
|
||||||
|
|
||||||
|
// helper function to apply mirroring to a horizontal coordinate, if needed.
|
||||||
|
nscoord
|
||||||
|
MirrorIfRTL(nscoord aParentWidth, nscoord aChildWidth, nscoord aChildLeading)
|
||||||
|
{
|
||||||
|
return (NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||||
|
aParentWidth - aChildWidth - aChildLeading : aChildLeading);
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// Additional methods
|
// Additional methods
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,8 @@ nsMathMLmencloseFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||||
|
|
||||||
nsRect rect;
|
nsRect rect;
|
||||||
mMathMLChar[mRadicalCharIndex].GetRect(rect);
|
mMathMLChar[mRadicalCharIndex].GetRect(rect);
|
||||||
rect.MoveBy(rect.width, 0);
|
rect.MoveBy(NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||||
|
-mContentWidth : rect.width, 0);
|
||||||
rect.SizeTo(mContentWidth, mRuleThickness);
|
rect.SizeTo(mContentWidth, mRuleThickness);
|
||||||
rv = DisplayBar(aBuilder, this, rect, aLists);
|
rv = DisplayBar(aBuilder, this, rect, aLists);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
@ -518,12 +519,15 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||||
///////////////
|
///////////////
|
||||||
// radical notation:
|
// radical notation:
|
||||||
if (IsToDraw(NOTATION_RADICAL)) {
|
if (IsToDraw(NOTATION_RADICAL)) {
|
||||||
|
nscoord *dx_leading =
|
||||||
|
NS_MATHML_IS_RTL(mPresentationData.flags) ? &dx_right : &dx_left;
|
||||||
|
|
||||||
if (aWidthOnly) {
|
if (aWidthOnly) {
|
||||||
nscoord radical_width = mMathMLChar[mRadicalCharIndex].
|
nscoord radical_width = mMathMLChar[mRadicalCharIndex].
|
||||||
GetMaxWidth(PresContext(), aRenderingContext);
|
GetMaxWidth(PresContext(), aRenderingContext);
|
||||||
|
|
||||||
// Update horizontal parameters
|
// Update horizontal parameters
|
||||||
dx_left = NS_MAX(dx_left, radical_width);
|
*dx_leading = NS_MAX(*dx_leading, radical_width);
|
||||||
} else {
|
} else {
|
||||||
// Stretch the radical symbol to the appropriate height if it is not
|
// Stretch the radical symbol to the appropriate height if it is not
|
||||||
// big enough.
|
// big enough.
|
||||||
|
@ -539,7 +543,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||||
mMathMLChar[mRadicalCharIndex].GetBoundingMetrics(bmRadicalChar);
|
mMathMLChar[mRadicalCharIndex].GetBoundingMetrics(bmRadicalChar);
|
||||||
|
|
||||||
// Update horizontal parameters
|
// Update horizontal parameters
|
||||||
dx_left = NS_MAX(dx_left, bmRadicalChar.width);
|
*dx_leading = NS_MAX(*dx_leading, bmRadicalChar.width);
|
||||||
|
|
||||||
// Update vertical parameters
|
// Update vertical parameters
|
||||||
radicalAscent = bmBase.ascent + psi + mRuleThickness;
|
radicalAscent = bmBase.ascent + psi + mRuleThickness;
|
||||||
|
@ -653,14 +657,17 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||||
bmLongdivChar.ascent +
|
bmLongdivChar.ascent +
|
||||||
bmLongdivChar.descent));
|
bmLongdivChar.descent));
|
||||||
|
|
||||||
if (IsToDraw(NOTATION_RADICAL))
|
if (IsToDraw(NOTATION_RADICAL)) {
|
||||||
mMathMLChar[mRadicalCharIndex].SetRect(nsRect(dx_left -
|
nscoord dx = NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||||
bmRadicalChar.width,
|
dx_left + bmBase.width : dx_left - bmRadicalChar.width;
|
||||||
|
|
||||||
|
mMathMLChar[mRadicalCharIndex].SetRect(nsRect(dx,
|
||||||
aDesiredSize.ascent -
|
aDesiredSize.ascent -
|
||||||
radicalAscent,
|
radicalAscent,
|
||||||
bmRadicalChar.width,
|
bmRadicalChar.width,
|
||||||
bmRadicalChar.ascent +
|
bmRadicalChar.ascent +
|
||||||
bmRadicalChar.descent));
|
bmRadicalChar.descent));
|
||||||
|
}
|
||||||
|
|
||||||
mContentWidth = bmBase.width;
|
mContentWidth = bmBase.width;
|
||||||
|
|
||||||
|
|
|
@ -383,13 +383,27 @@ nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
|
||||||
nscoord dx = 0;
|
nscoord dx = 0;
|
||||||
nsBoundingMetrics bm;
|
nsBoundingMetrics bm;
|
||||||
bool firstTime = true;
|
bool firstTime = true;
|
||||||
if (mOpenChar) {
|
nsMathMLChar *leftChar, *rightChar;
|
||||||
PlaceChar(mOpenChar, ascent, bm, dx);
|
bool isRTL = NS_MATHML_IS_RTL(mPresentationData.flags);
|
||||||
|
if (isRTL) {
|
||||||
|
leftChar = mCloseChar;
|
||||||
|
rightChar = mOpenChar;
|
||||||
|
} else {
|
||||||
|
leftChar = mOpenChar;
|
||||||
|
rightChar = mCloseChar;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leftChar) {
|
||||||
|
PlaceChar(leftChar, ascent, bm, dx);
|
||||||
aDesiredSize.mBoundingMetrics = bm;
|
aDesiredSize.mBoundingMetrics = bm;
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRTL) {
|
||||||
|
childFrame = this->GetLastChild(nsIFrame::kPrincipalList);
|
||||||
|
} else {
|
||||||
childFrame = firstChild;
|
childFrame = firstChild;
|
||||||
|
}
|
||||||
while (childFrame) {
|
while (childFrame) {
|
||||||
nsHTMLReflowMetrics childSize;
|
nsHTMLReflowMetrics childSize;
|
||||||
GetReflowAndBoundingMetricsFor(childFrame, childSize, bm);
|
GetReflowAndBoundingMetricsFor(childFrame, childSize, bm);
|
||||||
|
@ -405,16 +419,21 @@ nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
|
||||||
dx += childSize.width;
|
dx += childSize.width;
|
||||||
|
|
||||||
if (i < mSeparatorsCount) {
|
if (i < mSeparatorsCount) {
|
||||||
PlaceChar(&mSeparatorsChar[i], ascent, bm, dx);
|
PlaceChar(&mSeparatorsChar[isRTL ? mSeparatorsCount - 1 - i : i],
|
||||||
|
ascent, bm, dx);
|
||||||
aDesiredSize.mBoundingMetrics += bm;
|
aDesiredSize.mBoundingMetrics += bm;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
if (isRTL) {
|
||||||
|
childFrame = childFrame->GetPrevSibling();
|
||||||
|
} else {
|
||||||
childFrame = childFrame->GetNextSibling();
|
childFrame = childFrame->GetNextSibling();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mCloseChar) {
|
if (rightChar) {
|
||||||
PlaceChar(mCloseChar, ascent, bm, dx);
|
PlaceChar(rightChar, ascent, bm, dx);
|
||||||
if (firstTime)
|
if (firstTime)
|
||||||
aDesiredSize.mBoundingMetrics = bm;
|
aDesiredSize.mBoundingMetrics = bm;
|
||||||
else
|
else
|
||||||
|
|
|
@ -501,18 +501,26 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||||
mReference.y = aDesiredSize.ascent;
|
mReference.y = aDesiredSize.ascent;
|
||||||
|
|
||||||
if (aPlaceOrigin) {
|
if (aPlaceOrigin) {
|
||||||
FinishReflowChild(frameNum, presContext, nsnull, sizeNum,
|
nscoord dx, dy;
|
||||||
leftSpace,
|
|
||||||
aDesiredSize.ascent - numShift - sizeNum.ascent, 0);
|
|
||||||
|
|
||||||
mLineRect.SetRect(leftSpace + bmNum.width,
|
// place numerator
|
||||||
aDesiredSize.ascent - mBoundingMetrics.ascent,
|
dx = MirrorIfRTL(aDesiredSize.width, sizeNum.width,
|
||||||
mLineRect.width,
|
leftSpace);
|
||||||
aDesiredSize.height - 2 * padding);
|
dy = aDesiredSize.ascent - numShift - sizeNum.ascent;
|
||||||
|
FinishReflowChild(frameNum, presContext, nsnull, sizeNum, dx, dy, 0);
|
||||||
|
|
||||||
FinishReflowChild(frameDen, presContext, nsnull, sizeDen,
|
// place the fraction bar
|
||||||
leftSpace + bmNum.width + mLineRect.width,
|
dx = MirrorIfRTL(aDesiredSize.width, mLineRect.width,
|
||||||
aDesiredSize.ascent + denShift - sizeDen.ascent, 0);
|
leftSpace + bmNum.width);
|
||||||
|
dy = aDesiredSize.ascent - mBoundingMetrics.ascent;
|
||||||
|
mLineRect.SetRect(dx, dy,
|
||||||
|
mLineRect.width, aDesiredSize.height - 2 * padding);
|
||||||
|
|
||||||
|
// place denominator
|
||||||
|
dx = MirrorIfRTL(aDesiredSize.width, sizeDen.width,
|
||||||
|
leftSpace + bmNum.width + mLineRect.width);
|
||||||
|
dy = aDesiredSize.ascent + denShift - sizeDen.ascent;
|
||||||
|
FinishReflowChild(frameDen, presContext, nsnull, sizeDen, dx, dy, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -549,8 +557,9 @@ class nsDisplayMathMLSlash : public nsDisplayItem {
|
||||||
public:
|
public:
|
||||||
nsDisplayMathMLSlash(nsDisplayListBuilder* aBuilder,
|
nsDisplayMathMLSlash(nsDisplayListBuilder* aBuilder,
|
||||||
nsIFrame* aFrame, const nsRect& aRect,
|
nsIFrame* aFrame, const nsRect& aRect,
|
||||||
nscoord aThickness)
|
nscoord aThickness, bool aRTL)
|
||||||
: nsDisplayItem(aBuilder, aFrame), mRect(aRect), mThickness(aThickness) {
|
: nsDisplayItem(aBuilder, aFrame), mRect(aRect), mThickness(aThickness),
|
||||||
|
mRTL(aRTL) {
|
||||||
MOZ_COUNT_CTOR(nsDisplayMathMLSlash);
|
MOZ_COUNT_CTOR(nsDisplayMathMLSlash);
|
||||||
}
|
}
|
||||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||||
|
@ -565,6 +574,7 @@ public:
|
||||||
private:
|
private:
|
||||||
nsRect mRect;
|
nsRect mRect;
|
||||||
nscoord mThickness;
|
nscoord mThickness;
|
||||||
|
bool mRTL;
|
||||||
};
|
};
|
||||||
|
|
||||||
void nsDisplayMathMLSlash::Paint(nsDisplayListBuilder* aBuilder,
|
void nsDisplayMathMLSlash::Paint(nsDisplayListBuilder* aBuilder,
|
||||||
|
@ -581,10 +591,19 @@ void nsDisplayMathMLSlash::Paint(nsDisplayListBuilder* aBuilder,
|
||||||
gfxContext *gfxCtx = aCtx->ThebesContext();
|
gfxContext *gfxCtx = aCtx->ThebesContext();
|
||||||
gfxPoint delta = gfxPoint(presContext->AppUnitsToGfxUnits(mThickness), 0);
|
gfxPoint delta = gfxPoint(presContext->AppUnitsToGfxUnits(mThickness), 0);
|
||||||
gfxCtx->NewPath();
|
gfxCtx->NewPath();
|
||||||
|
|
||||||
|
if (mRTL) {
|
||||||
|
gfxCtx->MoveTo(rect.TopLeft());
|
||||||
|
gfxCtx->LineTo(rect.TopLeft() + delta);
|
||||||
|
gfxCtx->LineTo(rect.BottomRight());
|
||||||
|
gfxCtx->LineTo(rect.BottomRight() - delta);
|
||||||
|
} else {
|
||||||
gfxCtx->MoveTo(rect.BottomLeft());
|
gfxCtx->MoveTo(rect.BottomLeft());
|
||||||
gfxCtx->LineTo(rect.BottomLeft() + delta);
|
gfxCtx->LineTo(rect.BottomLeft() + delta);
|
||||||
gfxCtx->LineTo(rect.TopRight());
|
gfxCtx->LineTo(rect.TopRight());
|
||||||
gfxCtx->LineTo(rect.TopRight() - delta);
|
gfxCtx->LineTo(rect.TopRight() - delta);
|
||||||
|
}
|
||||||
|
|
||||||
gfxCtx->ClosePath();
|
gfxCtx->ClosePath();
|
||||||
gfxCtx->Fill();
|
gfxCtx->Fill();
|
||||||
}
|
}
|
||||||
|
@ -598,5 +617,6 @@ nsMathMLmfracFrame::DisplaySlash(nsDisplayListBuilder* aBuilder,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
return aLists.Content()->AppendNewToTop(new (aBuilder)
|
return aLists.Content()->AppendNewToTop(new (aBuilder)
|
||||||
nsDisplayMathMLSlash(aBuilder, aFrame, aRect, aThickness));
|
nsDisplayMathMLSlash(aBuilder, aFrame, aRect, aThickness,
|
||||||
|
NS_MATHML_IS_RTL(mPresentationData.flags)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,7 +417,11 @@ nsMathMLmmultiscriptsFrame::Place(nsRenderingContext& aRenderingContext,
|
||||||
// place the base ...
|
// place the base ...
|
||||||
childFrame = baseFrame;
|
childFrame = baseFrame;
|
||||||
dy = aDesiredSize.ascent - baseSize.ascent;
|
dy = aDesiredSize.ascent - baseSize.ascent;
|
||||||
FinishReflowChild (baseFrame, PresContext(), nsnull, baseSize, dx, dy, 0);
|
FinishReflowChild (baseFrame, PresContext(), nsnull, baseSize,
|
||||||
|
MirrorIfRTL(aDesiredSize.width,
|
||||||
|
baseSize.width,
|
||||||
|
dx),
|
||||||
|
dy, 0);
|
||||||
dx += bmBase.width + italicCorrection;
|
dx += bmBase.width + italicCorrection;
|
||||||
}
|
}
|
||||||
else if (mprescriptsFrame != childFrame) {
|
else if (mprescriptsFrame != childFrame) {
|
||||||
|
@ -440,13 +444,21 @@ nsMathMLmmultiscriptsFrame::Place(nsRenderingContext& aRenderingContext,
|
||||||
|
|
||||||
dy = aDesiredSize.ascent - subScriptSize.ascent +
|
dy = aDesiredSize.ascent - subScriptSize.ascent +
|
||||||
maxSubScriptShift;
|
maxSubScriptShift;
|
||||||
FinishReflowChild (subScriptFrame, PresContext(), nsnull, subScriptSize,
|
FinishReflowChild (subScriptFrame, PresContext(), nsnull,
|
||||||
dx + (width-subScriptSize.width)/2, dy, 0);
|
subScriptSize,
|
||||||
|
MirrorIfRTL(aDesiredSize.width,
|
||||||
|
subScriptSize.width,
|
||||||
|
dx + (width-subScriptSize.width)/2),
|
||||||
|
dy, 0);
|
||||||
|
|
||||||
dy = aDesiredSize.ascent - supScriptSize.ascent -
|
dy = aDesiredSize.ascent - supScriptSize.ascent -
|
||||||
maxSupScriptShift;
|
maxSupScriptShift;
|
||||||
FinishReflowChild (supScriptFrame, PresContext(), nsnull, supScriptSize,
|
FinishReflowChild (supScriptFrame, PresContext(), nsnull,
|
||||||
dx + (width-supScriptSize.width)/2, dy, 0);
|
supScriptSize,
|
||||||
|
MirrorIfRTL(aDesiredSize.width,
|
||||||
|
supScriptSize.width,
|
||||||
|
dx + (width-supScriptSize.width)/2),
|
||||||
|
dy, 0);
|
||||||
|
|
||||||
dx += width + scriptSpace;
|
dx += width + scriptSpace;
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,10 +133,11 @@ nsMathMLmpaddedFrame::ProcessAttributes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// lspace
|
// lspace
|
||||||
mLeftSpaceSign = NS_MATHML_SIGN_INVALID;
|
mLeadingSpaceSign = NS_MATHML_SIGN_INVALID;
|
||||||
GetAttribute(mContent, nsnull, nsGkAtoms::lspace_, value);
|
GetAttribute(mContent, nsnull, nsGkAtoms::lspace_, value);
|
||||||
if (!value.IsEmpty()) {
|
if (!value.IsEmpty()) {
|
||||||
ParseAttribute(value, mLeftSpaceSign, mLeftSpace, mLeftSpacePseudoUnit);
|
ParseAttribute(value, mLeadingSpaceSign, mLeadingSpace,
|
||||||
|
mLeadingSpacePseudoUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// voffset
|
// voffset
|
||||||
|
@ -380,23 +381,28 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext,
|
||||||
|
|
||||||
nscoord height = mBoundingMetrics.ascent;
|
nscoord height = mBoundingMetrics.ascent;
|
||||||
nscoord depth = mBoundingMetrics.descent;
|
nscoord depth = mBoundingMetrics.descent;
|
||||||
// In MathML2 (http://www.w3.org/TR/MathML2/chapter3.html#presm.mpadded),
|
// The REC says:
|
||||||
// lspace is "the amount of space between the left edge of a bounding box
|
|
||||||
// and the start of the rendering of its contents' bounding box" and the
|
|
||||||
// default is zero.
|
|
||||||
//
|
//
|
||||||
// In MathML3 draft
|
// "The lspace attribute ('leading' space) specifies the horizontal location
|
||||||
// http://www.w3.org/TR/2007/WD-MathML3-20070427/chapter3.html#id.3.3.6.2,
|
// of the positioning point of the child content with respect to the
|
||||||
// lspace is "the amount of space between the left edge of the bounding box
|
// positioning point of the mpadded element. By default they coincide, and
|
||||||
// and the positioning poin [sic] of the mpadded element" and the default is
|
// therefore absolute values for lspace have the same effect as relative
|
||||||
// "same as content".
|
// values."
|
||||||
//
|
//
|
||||||
// In both cases, "MathML renderers should ensure that, except for the
|
// "MathML renderers should ensure that, except for the effects of the
|
||||||
// effects of the attributes, relative spacing between the contents of
|
// attributes, the relative spacing between the contents of the mpadded
|
||||||
// mpadded and surrounding MathML elements is not modified by replacing an
|
// element and surrounding MathML elements would not be modified by replacing
|
||||||
// mpadded element with an mrow element with the same content."
|
// 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;
|
nscoord lspace = 0;
|
||||||
// In MATHML3, "width" will be the bounding box width and "advancewidth" will
|
// In MathML3, "width" will be the bounding box width and "advancewidth" will
|
||||||
// refer "to the horizontal distance between the positioning point of the
|
// refer "to the horizontal distance between the positioning point of the
|
||||||
// mpadded and the positioning point for the following content". MathML2
|
// mpadded and the positioning point for the following content". MathML2
|
||||||
// doesn't make the distinction.
|
// doesn't make the distinction.
|
||||||
|
@ -404,6 +410,7 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext,
|
||||||
nscoord voffset = 0;
|
nscoord voffset = 0;
|
||||||
|
|
||||||
PRInt32 pseudoUnit;
|
PRInt32 pseudoUnit;
|
||||||
|
nscoord initialWidth = width;
|
||||||
|
|
||||||
// update width
|
// update width
|
||||||
pseudoUnit = (mWidthPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF)
|
pseudoUnit = (mWidthPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF)
|
||||||
|
@ -427,9 +434,9 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext,
|
||||||
depth = NS_MAX(0, depth);
|
depth = NS_MAX(0, depth);
|
||||||
|
|
||||||
// update lspace
|
// update lspace
|
||||||
if (mLeftSpacePseudoUnit != NS_MATHML_PSEUDO_UNIT_ITSELF) {
|
if (mLeadingSpacePseudoUnit != NS_MATHML_PSEUDO_UNIT_ITSELF) {
|
||||||
pseudoUnit = mLeftSpacePseudoUnit;
|
pseudoUnit = mLeadingSpacePseudoUnit;
|
||||||
UpdateValue(mLeftSpaceSign, pseudoUnit, mLeftSpace,
|
UpdateValue(mLeadingSpaceSign, pseudoUnit, mLeadingSpace,
|
||||||
mBoundingMetrics, lspace);
|
mBoundingMetrics, lspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,19 +452,24 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext,
|
||||||
// attributes, tweak our metrics and move children to achieve the desired visual
|
// attributes, tweak our metrics and move children to achieve the desired visual
|
||||||
// effects.
|
// effects.
|
||||||
|
|
||||||
if (mLeftSpaceSign != NS_MATHML_SIGN_INVALID) { // there was padding on the left
|
if ((NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||||
// dismiss the left italic correction now (so that our parent won't correct us)
|
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;
|
mBoundingMetrics.leftBearing = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mWidthSign != NS_MATHML_SIGN_INVALID) { // there was padding on the right
|
if ((NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||||
// dismiss the right italic correction now (so that our parent won't correct us)
|
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.width = width;
|
||||||
mBoundingMetrics.rightBearing = mBoundingMetrics.width;
|
mBoundingMetrics.rightBearing = mBoundingMetrics.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord dy = height - mBoundingMetrics.ascent;
|
nscoord dy = height - mBoundingMetrics.ascent;
|
||||||
nscoord dx = lspace;
|
nscoord dx = NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||||
|
width - initialWidth - lspace : lspace;
|
||||||
|
|
||||||
aDesiredSize.ascent += dy;
|
aDesiredSize.ascent += dy;
|
||||||
aDesiredSize.width = mBoundingMetrics.width;
|
aDesiredSize.width = mBoundingMetrics.width;
|
||||||
|
|
|
@ -83,19 +83,19 @@ private:
|
||||||
nsCSSValue mWidth;
|
nsCSSValue mWidth;
|
||||||
nsCSSValue mHeight;
|
nsCSSValue mHeight;
|
||||||
nsCSSValue mDepth;
|
nsCSSValue mDepth;
|
||||||
nsCSSValue mLeftSpace;
|
nsCSSValue mLeadingSpace;
|
||||||
nsCSSValue mVerticalOffset;
|
nsCSSValue mVerticalOffset;
|
||||||
|
|
||||||
PRInt32 mWidthSign;
|
PRInt32 mWidthSign;
|
||||||
PRInt32 mHeightSign;
|
PRInt32 mHeightSign;
|
||||||
PRInt32 mDepthSign;
|
PRInt32 mDepthSign;
|
||||||
PRInt32 mLeftSpaceSign;
|
PRInt32 mLeadingSpaceSign;
|
||||||
PRInt32 mVerticalOffsetSign;
|
PRInt32 mVerticalOffsetSign;
|
||||||
|
|
||||||
PRInt32 mWidthPseudoUnit;
|
PRInt32 mWidthPseudoUnit;
|
||||||
PRInt32 mHeightPseudoUnit;
|
PRInt32 mHeightPseudoUnit;
|
||||||
PRInt32 mDepthPseudoUnit;
|
PRInt32 mDepthPseudoUnit;
|
||||||
PRInt32 mLeftSpacePseudoUnit;
|
PRInt32 mLeadingSpacePseudoUnit;
|
||||||
PRInt32 mVerticalOffsetPseudoUnit;
|
PRInt32 mVerticalOffsetPseudoUnit;
|
||||||
|
|
||||||
// helpers to process the attributes
|
// helpers to process the attributes
|
||||||
|
|
|
@ -356,35 +356,41 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
|
||||||
nscoord dxIndex, dxSqr;
|
nscoord dxIndex, dxSqr;
|
||||||
GetRadicalXOffsets(bmIndex.width, bmSqr.width, fm, &dxIndex, &dxSqr);
|
GetRadicalXOffsets(bmIndex.width, bmSqr.width, fm, &dxIndex, &dxSqr);
|
||||||
|
|
||||||
// place the index
|
mBoundingMetrics.width = dxSqr + bmSqr.width + bmBase.width;
|
||||||
nscoord dx = dxIndex;
|
|
||||||
nscoord dy = aDesiredSize.ascent - (indexRaisedAscent + indexSize.ascent - bmIndex.ascent);
|
|
||||||
FinishReflowChild(indexFrame, aPresContext, nsnull, indexSize, dx, dy, 0);
|
|
||||||
|
|
||||||
// place the radical symbol and the radical bar
|
|
||||||
dx = dxSqr;
|
|
||||||
dy = indexClearance + leading; // leave a leading at the top
|
|
||||||
mSqrChar.SetRect(nsRect(dx, dy, bmSqr.width, bmSqr.ascent + bmSqr.descent));
|
|
||||||
dx += bmSqr.width;
|
|
||||||
mBarRect.SetRect(dx, dy, bmBase.width, ruleThickness);
|
|
||||||
|
|
||||||
// place the base
|
|
||||||
dy = aDesiredSize.ascent - baseSize.ascent;
|
|
||||||
FinishReflowChild(baseFrame, aPresContext, nsnull, baseSize, dx, dy, 0);
|
|
||||||
|
|
||||||
mReference.x = 0;
|
|
||||||
mReference.y = aDesiredSize.ascent;
|
|
||||||
|
|
||||||
mBoundingMetrics.width = dx + bmBase.width;
|
|
||||||
mBoundingMetrics.leftBearing =
|
mBoundingMetrics.leftBearing =
|
||||||
NS_MIN(dxIndex + bmIndex.leftBearing, dxSqr + bmSqr.leftBearing);
|
NS_MIN(dxIndex + bmIndex.leftBearing, dxSqr + bmSqr.leftBearing);
|
||||||
mBoundingMetrics.rightBearing = dx +
|
mBoundingMetrics.rightBearing = dxSqr + bmSqr.width +
|
||||||
NS_MAX(bmBase.width, bmBase.rightBearing);
|
NS_MAX(bmBase.width, bmBase.rightBearing);
|
||||||
|
|
||||||
aDesiredSize.width = mBoundingMetrics.width;
|
aDesiredSize.width = mBoundingMetrics.width;
|
||||||
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
||||||
GatherAndStoreOverflow(&aDesiredSize);
|
GatherAndStoreOverflow(&aDesiredSize);
|
||||||
|
|
||||||
|
// place the index
|
||||||
|
nscoord dx = dxIndex;
|
||||||
|
nscoord dy = aDesiredSize.ascent - (indexRaisedAscent + indexSize.ascent - bmIndex.ascent);
|
||||||
|
FinishReflowChild(indexFrame, aPresContext, nsnull, indexSize,
|
||||||
|
MirrorIfRTL(aDesiredSize.width, indexSize.width, dx),
|
||||||
|
dy, 0);
|
||||||
|
|
||||||
|
// place the radical symbol and the radical bar
|
||||||
|
dx = dxSqr;
|
||||||
|
dy = indexClearance + leading; // leave a leading at the top
|
||||||
|
mSqrChar.SetRect(nsRect(MirrorIfRTL(aDesiredSize.width, bmSqr.width, dx),
|
||||||
|
dy, bmSqr.width, bmSqr.ascent + bmSqr.descent));
|
||||||
|
dx += bmSqr.width;
|
||||||
|
mBarRect.SetRect(MirrorIfRTL(aDesiredSize.width, bmBase.width, dx),
|
||||||
|
dy, bmBase.width, ruleThickness);
|
||||||
|
|
||||||
|
// place the base
|
||||||
|
dy = aDesiredSize.ascent - baseSize.ascent;
|
||||||
|
FinishReflowChild(baseFrame, aPresContext, nsnull, baseSize,
|
||||||
|
MirrorIfRTL(aDesiredSize.width, baseSize.width, dx),
|
||||||
|
dy, 0);
|
||||||
|
|
||||||
|
mReference.x = 0;
|
||||||
|
mReference.y = aDesiredSize.ascent;
|
||||||
|
|
||||||
aStatus = NS_FRAME_COMPLETE;
|
aStatus = NS_FRAME_COMPLETE;
|
||||||
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -203,10 +203,12 @@ nsMathMLmsubFrame::PlaceSubScript (nsPresContext* aPresContext,
|
||||||
if (aPlaceOrigin) {
|
if (aPlaceOrigin) {
|
||||||
nscoord dx, dy;
|
nscoord dx, dy;
|
||||||
// now place the base ...
|
// now place the base ...
|
||||||
dx = 0; dy = aDesiredSize.ascent - baseSize.ascent;
|
dx = aFrame->MirrorIfRTL(aDesiredSize.width, baseSize.width, 0);
|
||||||
|
dy = aDesiredSize.ascent - baseSize.ascent;
|
||||||
FinishReflowChild (baseFrame, aPresContext, nsnull, baseSize, dx, dy, 0);
|
FinishReflowChild (baseFrame, aPresContext, nsnull, baseSize, dx, dy, 0);
|
||||||
// ... and subscript
|
// ... and subscript
|
||||||
dx = bmBase.width;
|
dx = aFrame->MirrorIfRTL(aDesiredSize.width, subScriptSize.width,
|
||||||
|
bmBase.width);
|
||||||
dy = aDesiredSize.ascent - (subScriptSize.ascent - actualSubScriptShift);
|
dy = aDesiredSize.ascent - (subScriptSize.ascent - actualSubScriptShift);
|
||||||
FinishReflowChild (subScriptFrame, aPresContext, nsnull, subScriptSize, dx, dy, 0);
|
FinishReflowChild (subScriptFrame, aPresContext, nsnull, subScriptSize, dx, dy, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -336,16 +336,19 @@ nsMathMLmsubsupFrame::PlaceSubSupScript(nsPresContext* aPresContext,
|
||||||
if (aPlaceOrigin) {
|
if (aPlaceOrigin) {
|
||||||
nscoord dx, dy;
|
nscoord dx, dy;
|
||||||
// now place the base ...
|
// now place the base ...
|
||||||
dx = 0; dy = aDesiredSize.ascent - baseSize.ascent;
|
dx = aFrame->MirrorIfRTL(aDesiredSize.width, baseSize.width, 0);
|
||||||
|
dy = aDesiredSize.ascent - baseSize.ascent;
|
||||||
FinishReflowChild(baseFrame, aPresContext, nsnull,
|
FinishReflowChild(baseFrame, aPresContext, nsnull,
|
||||||
baseSize, dx, dy, 0);
|
baseSize, dx, dy, 0);
|
||||||
// ... and subscript
|
// ... and subscript
|
||||||
dx = bmBase.width;
|
dx = aFrame->MirrorIfRTL(aDesiredSize.width, subScriptSize.width,
|
||||||
|
bmBase.width);
|
||||||
dy = aDesiredSize.ascent - (subScriptSize.ascent - subScriptShift);
|
dy = aDesiredSize.ascent - (subScriptSize.ascent - subScriptShift);
|
||||||
FinishReflowChild(subScriptFrame, aPresContext, nsnull,
|
FinishReflowChild(subScriptFrame, aPresContext, nsnull,
|
||||||
subScriptSize, dx, dy, 0);
|
subScriptSize, dx, dy, 0);
|
||||||
// ... and the superscript
|
// ... and the superscript
|
||||||
dx = bmBase.width + italicCorrection;
|
dx = aFrame->MirrorIfRTL(aDesiredSize.width, supScriptSize.width,
|
||||||
|
bmBase.width + italicCorrection);
|
||||||
dy = aDesiredSize.ascent - (supScriptSize.ascent + supScriptShift);
|
dy = aDesiredSize.ascent - (supScriptSize.ascent + supScriptShift);
|
||||||
FinishReflowChild(supScriptFrame, aPresContext, nsnull,
|
FinishReflowChild(supScriptFrame, aPresContext, nsnull,
|
||||||
supScriptSize, dx, dy, 0);
|
supScriptSize, dx, dy, 0);
|
||||||
|
|
|
@ -241,10 +241,12 @@ nsMathMLmsupFrame::PlaceSuperScript(nsPresContext* aPresContext,
|
||||||
if (aPlaceOrigin) {
|
if (aPlaceOrigin) {
|
||||||
nscoord dx, dy;
|
nscoord dx, dy;
|
||||||
// now place the base ...
|
// now place the base ...
|
||||||
dx = 0; dy = aDesiredSize.ascent - baseSize.ascent;
|
dx = aFrame->MirrorIfRTL(aDesiredSize.width, baseSize.width, 0);
|
||||||
|
dy = aDesiredSize.ascent - baseSize.ascent;
|
||||||
FinishReflowChild (baseFrame, aPresContext, nsnull, baseSize, dx, dy, 0);
|
FinishReflowChild (baseFrame, aPresContext, nsnull, baseSize, dx, dy, 0);
|
||||||
// ... and supscript
|
// ... and supscript
|
||||||
dx = bmBase.width + italicCorrection;
|
dx = aFrame->MirrorIfRTL(aDesiredSize.width, supScriptSize.width,
|
||||||
|
bmBase.width + italicCorrection);
|
||||||
dy = aDesiredSize.ascent - (supScriptSize.ascent + actualSupScriptShift);
|
dy = aDesiredSize.ascent - (supScriptSize.ascent + actualSupScriptShift);
|
||||||
FinishReflowChild (supScriptFrame, aPresContext, nsnull, supScriptSize, dx, dy, 0);
|
FinishReflowChild (supScriptFrame, aPresContext, nsnull, supScriptSize, dx, dy, 0);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче