mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Bug 961365 - Part 3: Use MATH constants for fractions and stacks. r=jfkthame
This commit is contained in:
parent
48d4f1ae3d
commit
c9a9cf88b0
@ -219,7 +219,15 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||
aRenderingContext.SetFont(fm);
|
||||
|
||||
nscoord defaultRuleThickness, axisHeight;
|
||||
GetRuleThickness(aRenderingContext, fm, defaultRuleThickness);
|
||||
nscoord oneDevPixel = fm->AppUnitsPerDevPixel();
|
||||
gfxFont* mathFont = fm->GetThebesFontGroup()->GetFirstMathFont();
|
||||
if (mathFont) {
|
||||
defaultRuleThickness =
|
||||
mathFont->GetMathConstant(gfxFontEntry::FractionRuleThickness,
|
||||
oneDevPixel);
|
||||
} else {
|
||||
GetRuleThickness(aRenderingContext, fm, defaultRuleThickness);
|
||||
}
|
||||
GetAxisHeight(aRenderingContext, fm, axisHeight);
|
||||
|
||||
bool outermostEmbellished = false;
|
||||
@ -239,6 +247,8 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::bevelled_, value);
|
||||
mIsBevelled = value.EqualsLiteral("true");
|
||||
|
||||
bool displayStyle = StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK;
|
||||
|
||||
if (!mIsBevelled) {
|
||||
mLineRect.height = mLineThickness;
|
||||
|
||||
@ -258,6 +268,8 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||
coreData.leadingSpace : coreData.trailingSpace;
|
||||
}
|
||||
|
||||
nscoord actualRuleThickness = mLineThickness;
|
||||
|
||||
//////////////////
|
||||
// Get shifts
|
||||
nscoord numShift = 0;
|
||||
@ -269,28 +281,54 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||
|
||||
GetNumeratorShifts(fm, numShift1, numShift2, numShift3);
|
||||
GetDenominatorShifts(fm, denShift1, denShift2);
|
||||
if (StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK) {
|
||||
// C > T
|
||||
numShift = numShift1;
|
||||
denShift = denShift1;
|
||||
}
|
||||
else {
|
||||
numShift = (0 < mLineRect.height) ? numShift2 : numShift3;
|
||||
denShift = denShift2;
|
||||
}
|
||||
|
||||
nscoord minClearance = 0;
|
||||
nscoord actualClearance = 0;
|
||||
|
||||
nscoord actualRuleThickness = mLineThickness;
|
||||
if (0 == actualRuleThickness) {
|
||||
numShift = displayStyle ? numShift1 : numShift3;
|
||||
denShift = displayStyle ? denShift1 : denShift2;
|
||||
if (mathFont) {
|
||||
numShift = mathFont->
|
||||
GetMathConstant(displayStyle ?
|
||||
gfxFontEntry::StackTopDisplayStyleShiftUp :
|
||||
gfxFontEntry::StackTopShiftUp,
|
||||
oneDevPixel);
|
||||
denShift = mathFont->
|
||||
GetMathConstant(displayStyle ?
|
||||
gfxFontEntry::StackBottomDisplayStyleShiftDown :
|
||||
gfxFontEntry::StackBottomShiftDown,
|
||||
oneDevPixel);
|
||||
}
|
||||
} else {
|
||||
numShift = displayStyle ? numShift1 : numShift2;
|
||||
denShift = displayStyle ? denShift1 : denShift2;
|
||||
if (mathFont) {
|
||||
numShift = mathFont->
|
||||
GetMathConstant(displayStyle ?
|
||||
gfxFontEntry::FractionNumeratorDisplayStyleShiftUp :
|
||||
gfxFontEntry::FractionNumeratorShiftUp,
|
||||
oneDevPixel);
|
||||
denShift = mathFont->
|
||||
GetMathConstant(
|
||||
displayStyle ?
|
||||
gfxFontEntry::FractionDenominatorDisplayStyleShiftDown :
|
||||
gfxFontEntry::FractionDenominatorShiftDown,
|
||||
oneDevPixel);
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == actualRuleThickness) {
|
||||
// Rule 15c, App. G, TeXbook
|
||||
|
||||
// min clearance between numerator and denominator
|
||||
minClearance = StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK ?
|
||||
nscoord minClearance = displayStyle ?
|
||||
7 * defaultRuleThickness : 3 * defaultRuleThickness;
|
||||
actualClearance =
|
||||
if (mathFont) {
|
||||
minClearance =
|
||||
mathFont->GetMathConstant(displayStyle ?
|
||||
gfxFontEntry::StackDisplayStyleGapMin :
|
||||
gfxFontEntry::StackGapMin,
|
||||
oneDevPixel);
|
||||
}
|
||||
nscoord actualClearance =
|
||||
(numShift - bmNum.descent) - (bmDen.ascent - denShift);
|
||||
// actualClearance should be >= minClearance
|
||||
if (actualClearance < minClearance) {
|
||||
@ -306,27 +344,40 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||
|
||||
// TeX has a different interpretation of the thickness.
|
||||
// Try $a \above10pt b$ to see. Here is what TeX does:
|
||||
// minClearance = StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK
|
||||
// ? 3 * actualRuleThickness : actualRuleThickness;
|
||||
// minClearance = displayStyle ?
|
||||
// 3 * actualRuleThickness : actualRuleThickness;
|
||||
|
||||
// we slightly depart from TeX here. We use the defaultRuleThickness instead
|
||||
// of the value coming from the linethickness attribute, i.e., we recover what
|
||||
// TeX does if the user hasn't set linethickness. But when the linethickness
|
||||
// is set, we avoid the wide gap problem.
|
||||
minClearance = StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK ?
|
||||
3 * defaultRuleThickness : defaultRuleThickness + onePixel;
|
||||
|
||||
// adjust numShift to maintain minClearance if needed
|
||||
actualClearance =
|
||||
(numShift - bmNum.descent) - (axisHeight + actualRuleThickness/2);
|
||||
if (actualClearance < minClearance) {
|
||||
numShift += (minClearance - actualClearance);
|
||||
nscoord minClearanceNum = displayStyle ?
|
||||
3 * defaultRuleThickness : defaultRuleThickness + onePixel;
|
||||
nscoord minClearanceDen = minClearanceNum;
|
||||
if (mathFont) {
|
||||
minClearanceNum = mathFont->
|
||||
GetMathConstant(displayStyle ?
|
||||
gfxFontEntry::FractionNumDisplayStyleGapMin :
|
||||
gfxFontEntry::FractionNumeratorGapMin,
|
||||
oneDevPixel);
|
||||
minClearanceDen = mathFont->
|
||||
GetMathConstant(displayStyle ?
|
||||
gfxFontEntry::FractionDenomDisplayStyleGapMin :
|
||||
gfxFontEntry::FractionDenominatorGapMin,
|
||||
oneDevPixel);
|
||||
}
|
||||
// adjust denShift to maintain minClearance if needed
|
||||
actualClearance =
|
||||
|
||||
// adjust numShift to maintain minClearanceNum if needed
|
||||
nscoord actualClearanceNum =
|
||||
(numShift - bmNum.descent) - (axisHeight + actualRuleThickness/2);
|
||||
if (actualClearanceNum < minClearanceNum) {
|
||||
numShift += (minClearanceNum - actualClearanceNum);
|
||||
}
|
||||
// adjust denShift to maintain minClearanceDen if needed
|
||||
nscoord actualClearanceDen =
|
||||
(axisHeight - actualRuleThickness/2) - (bmDen.ascent - denShift);
|
||||
if (actualClearance < minClearance) {
|
||||
denShift += (minClearance - actualClearance);
|
||||
if (actualClearanceDen < minClearanceDen) {
|
||||
denShift += (minClearanceDen - actualClearanceDen);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user