зеркало из https://github.com/mozilla/gecko-dev.git
Fix the inter-space for the fraction line and other special cases, b=308045, r+sr=roc
This commit is contained in:
Родитель
50fdf2b49f
Коммит
2f303ef684
|
@ -1188,13 +1188,13 @@ static PRInt32 kInterFrameSpacingTable[eMathMLFrameType_COUNT][eMathMLFrameType_
|
|||
// spacing is not to be used for scriptlevel > 0
|
||||
|
||||
/* Ord OpOrd OpInv OpUsr Inner Italic Upright */
|
||||
/*Ord */ {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00},
|
||||
/*Ord */ {0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00},
|
||||
/*OpOrd*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
/*OpInv*/ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
/*OpUsr*/ {0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01},
|
||||
/*Inner*/ {0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00},
|
||||
/*Italic*/ {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01},
|
||||
/*Upright*/ {0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01}
|
||||
/*Inner*/ {0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01},
|
||||
/*Italic*/ {0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01},
|
||||
/*Upright*/ {0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01}
|
||||
};
|
||||
|
||||
#define GET_INTERSPACE(scriptlevel_, frametype1_, frametype2_, space_) \
|
||||
|
@ -1454,15 +1454,15 @@ GetInterFrameSpacingFor(PRInt32 aScriptLevel,
|
|||
return 0;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nscoord
|
||||
nsMathMLContainerFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
|
||||
{
|
||||
nscoord gap = 0;
|
||||
nsIContent* parentContent = mParent->GetContent();
|
||||
nsIAtom *parentTag = parentContent->Tag();
|
||||
if (parentTag == nsMathMLAtoms::math ||
|
||||
parentTag == nsMathMLAtoms::mtd_) {
|
||||
nscoord gap = GetInterFrameSpacingFor(mPresentationData.scriptLevel,
|
||||
mParent, this);
|
||||
gap = GetInterFrameSpacingFor(mPresentationData.scriptLevel, mParent, this);
|
||||
// add our own italic correction
|
||||
nscoord leftCorrection = 0, italicCorrection = 0;
|
||||
GetItalicCorrection(mBoundingMetrics, leftCorrection, italicCorrection);
|
||||
|
@ -1482,7 +1482,7 @@ nsMathMLContainerFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
|
|||
mBoundingMetrics.width += italicCorrection;
|
||||
aDesiredSize.width += italicCorrection;
|
||||
}
|
||||
return NS_OK;
|
||||
return gap;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ public:
|
|||
// left to right on the childframes of <math>, and by so doing it will
|
||||
// emulate the spacing that would have been done by a <mrow> container.
|
||||
// e.g., it fixes <math> <mi>f</mi> <mo>q</mo> <mi>f</mi> <mo>I</mo> </math>
|
||||
virtual nsresult
|
||||
virtual nscoord
|
||||
FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize);
|
||||
|
||||
// helper method to complete the post-reflow hook and ensure that embellished
|
||||
|
|
|
@ -477,6 +477,9 @@ nsMathMLmfencedFrame::doReflow(nsPresContext* aPresContext,
|
|||
mathMLFrame->SetBoundingMetrics(aDesiredSize.mBoundingMetrics);
|
||||
mathMLFrame->SetReference(nsPoint(0, aDesiredSize.ascent));
|
||||
|
||||
// see if we should fix the spacing
|
||||
mathMLFrame->FixInterFrameSpacing(aDesiredSize);
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
||||
return NS_OK;
|
||||
|
@ -587,6 +590,31 @@ nsMathMLmfencedFrame::PlaceChar(nsMathMLChar* aMathMLChar,
|
|||
dx += rect.width;
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsMathMLmfencedFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
|
||||
{
|
||||
nscoord gap = nsMathMLContainerFrame::FixInterFrameSpacing(aDesiredSize);
|
||||
if (!gap) return 0;
|
||||
|
||||
nsRect rect;
|
||||
if (mOpenChar) {
|
||||
mOpenChar->GetRect(rect);
|
||||
rect.MoveBy(gap, 0);
|
||||
mOpenChar->SetRect(rect);
|
||||
}
|
||||
if (mCloseChar) {
|
||||
mCloseChar->GetRect(rect);
|
||||
rect.MoveBy(gap, 0);
|
||||
mCloseChar->SetRect(rect);
|
||||
}
|
||||
for (PRInt32 i = 0; i < mSeparatorsCount; i++) {
|
||||
mSeparatorsChar[i].GetRect(rect);
|
||||
rect.MoveBy(gap, 0);
|
||||
mSeparatorsChar[i].SetRect(rect);
|
||||
}
|
||||
return gap;
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
// the Style System will use these to pass the proper style context to our MathMLChar
|
||||
nsStyleContext*
|
||||
|
|
|
@ -86,6 +86,10 @@ public:
|
|||
virtual nsresult
|
||||
ChildListChanged(PRInt32 aModType);
|
||||
|
||||
// override the base method so that we can deal with fences and separators
|
||||
virtual nscoord
|
||||
FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize);
|
||||
|
||||
// exported routine that both mfenced and mfrac share.
|
||||
// mfrac uses this when its bevelled attribute is set.
|
||||
static nsresult
|
||||
|
|
|
@ -273,6 +273,24 @@ nsMathMLmfracFrame::Reflow(nsPresContext* aPresContext,
|
|||
aReflowState, aStatus);
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsMathMLmfracFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
|
||||
{
|
||||
nscoord gap = nsMathMLContainerFrame::FixInterFrameSpacing(aDesiredSize);
|
||||
if (!gap) return 0;
|
||||
|
||||
if (mSlashChar) {
|
||||
nsRect rect;
|
||||
mSlashChar->GetRect(rect);
|
||||
rect.MoveBy(gap, 0);
|
||||
mSlashChar->SetRect(rect);
|
||||
}
|
||||
else {
|
||||
mLineRect.MoveBy(gap, 0);
|
||||
}
|
||||
return gap;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMathMLmfracFrame::Place(nsIRenderingContext& aRenderingContext,
|
||||
PRBool aPlaceOrigin,
|
||||
|
|
|
@ -140,6 +140,10 @@ public:
|
|||
PRUint32 aFlagsValues,
|
||||
PRUint32 aFlagsToUpdate);
|
||||
|
||||
// override the base method so that we can deal with the fraction line
|
||||
virtual nscoord
|
||||
FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize);
|
||||
|
||||
// helper to translate the thickness attribute into a usable form
|
||||
static nscoord
|
||||
CalcLineThickness(nsPresContext* aPresContext,
|
||||
|
|
|
@ -313,6 +313,20 @@ nsMathMLmsqrtFrame::Reflow(nsPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsMathMLmsqrtFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
|
||||
{
|
||||
nscoord gap = nsMathMLContainerFrame::FixInterFrameSpacing(aDesiredSize);
|
||||
if (!gap) return 0;
|
||||
|
||||
nsRect rect;
|
||||
mSqrChar.GetRect(rect);
|
||||
rect.MoveBy(gap, 0);
|
||||
mSqrChar.SetRect(rect);
|
||||
mBarRect.MoveBy(gap, 0);
|
||||
return gap;
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
// the Style System will use these to pass the proper style context to our MathMLChar
|
||||
nsStyleContext*
|
||||
|
|
|
@ -107,15 +107,12 @@ public:
|
|||
NS_IMETHOD
|
||||
TransmitAutomaticData();
|
||||
|
||||
virtual nsresult
|
||||
FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
|
||||
{
|
||||
// XXX the base method doesn't work properly with <msqrt> because it
|
||||
// only slides child frames and has no idea that we have a sqrt glyph
|
||||
// that is part of the flow without being a frame. We need to shift our
|
||||
// sqrt glyph too, but since m0.9.9 is going out... do nothing for now
|
||||
return NS_OK;
|
||||
}
|
||||
// the base method doesn't deal fully with <msqrt> because it only
|
||||
// slides child frames and has no idea that we have a sqrt glyph that
|
||||
// is part of the flow without being a frame. We need to shift our
|
||||
// sqrt glyph too.
|
||||
virtual nscoord
|
||||
FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize);
|
||||
|
||||
protected:
|
||||
nsMathMLmsqrtFrame();
|
||||
|
|
Загрузка…
Ссылка в новой задаче