mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 961365 - Part 3: Use MATH constants for fractions and stacks. r=jfkthame
This commit is contained in:
parent
ca33bf0075
commit
38784472e4
@ -219,7 +219,15 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
|||||||
aRenderingContext.SetFont(fm);
|
aRenderingContext.SetFont(fm);
|
||||||
|
|
||||||
nscoord defaultRuleThickness, axisHeight;
|
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);
|
GetAxisHeight(aRenderingContext, fm, axisHeight);
|
||||||
|
|
||||||
bool outermostEmbellished = false;
|
bool outermostEmbellished = false;
|
||||||
@ -239,6 +247,8 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
|||||||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::bevelled_, value);
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::bevelled_, value);
|
||||||
mIsBevelled = value.EqualsLiteral("true");
|
mIsBevelled = value.EqualsLiteral("true");
|
||||||
|
|
||||||
|
bool displayStyle = StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK;
|
||||||
|
|
||||||
if (!mIsBevelled) {
|
if (!mIsBevelled) {
|
||||||
mLineRect.height = mLineThickness;
|
mLineRect.height = mLineThickness;
|
||||||
|
|
||||||
@ -258,6 +268,8 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
|||||||
coreData.leadingSpace : coreData.trailingSpace;
|
coreData.leadingSpace : coreData.trailingSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nscoord actualRuleThickness = mLineThickness;
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Get shifts
|
// Get shifts
|
||||||
nscoord numShift = 0;
|
nscoord numShift = 0;
|
||||||
@ -269,28 +281,54 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
|||||||
|
|
||||||
GetNumeratorShifts(fm, numShift1, numShift2, numShift3);
|
GetNumeratorShifts(fm, numShift1, numShift2, numShift3);
|
||||||
GetDenominatorShifts(fm, denShift1, denShift2);
|
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;
|
if (0 == actualRuleThickness) {
|
||||||
nscoord actualClearance = 0;
|
numShift = displayStyle ? numShift1 : numShift3;
|
||||||
|
denShift = displayStyle ? denShift1 : denShift2;
|
||||||
nscoord actualRuleThickness = mLineThickness;
|
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) {
|
if (0 == actualRuleThickness) {
|
||||||
// Rule 15c, App. G, TeXbook
|
// Rule 15c, App. G, TeXbook
|
||||||
|
|
||||||
// min clearance between numerator and denominator
|
// min clearance between numerator and denominator
|
||||||
minClearance = StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK ?
|
nscoord minClearance = displayStyle ?
|
||||||
7 * defaultRuleThickness : 3 * defaultRuleThickness;
|
7 * defaultRuleThickness : 3 * defaultRuleThickness;
|
||||||
actualClearance =
|
if (mathFont) {
|
||||||
|
minClearance =
|
||||||
|
mathFont->GetMathConstant(displayStyle ?
|
||||||
|
gfxFontEntry::StackDisplayStyleGapMin :
|
||||||
|
gfxFontEntry::StackGapMin,
|
||||||
|
oneDevPixel);
|
||||||
|
}
|
||||||
|
nscoord actualClearance =
|
||||||
(numShift - bmNum.descent) - (bmDen.ascent - denShift);
|
(numShift - bmNum.descent) - (bmDen.ascent - denShift);
|
||||||
// actualClearance should be >= minClearance
|
// actualClearance should be >= minClearance
|
||||||
if (actualClearance < minClearance) {
|
if (actualClearance < minClearance) {
|
||||||
@ -306,27 +344,40 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
|||||||
|
|
||||||
// TeX has a different interpretation of the thickness.
|
// TeX has a different interpretation of the thickness.
|
||||||
// Try $a \above10pt b$ to see. Here is what TeX does:
|
// Try $a \above10pt b$ to see. Here is what TeX does:
|
||||||
// minClearance = StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK
|
// minClearance = displayStyle ?
|
||||||
// ? 3 * actualRuleThickness : actualRuleThickness;
|
// 3 * actualRuleThickness : actualRuleThickness;
|
||||||
|
|
||||||
// we slightly depart from TeX here. We use the defaultRuleThickness instead
|
// we slightly depart from TeX here. We use the defaultRuleThickness instead
|
||||||
// of the value coming from the linethickness attribute, i.e., we recover what
|
// 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
|
// TeX does if the user hasn't set linethickness. But when the linethickness
|
||||||
// is set, we avoid the wide gap problem.
|
// is set, we avoid the wide gap problem.
|
||||||
minClearance = StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK ?
|
nscoord minClearanceNum = displayStyle ?
|
||||||
3 * defaultRuleThickness : defaultRuleThickness + onePixel;
|
3 * defaultRuleThickness : defaultRuleThickness + onePixel;
|
||||||
|
nscoord minClearanceDen = minClearanceNum;
|
||||||
// adjust numShift to maintain minClearance if needed
|
if (mathFont) {
|
||||||
actualClearance =
|
minClearanceNum = mathFont->
|
||||||
(numShift - bmNum.descent) - (axisHeight + actualRuleThickness/2);
|
GetMathConstant(displayStyle ?
|
||||||
if (actualClearance < minClearance) {
|
gfxFontEntry::FractionNumDisplayStyleGapMin :
|
||||||
numShift += (minClearance - actualClearance);
|
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);
|
(axisHeight - actualRuleThickness/2) - (bmDen.ascent - denShift);
|
||||||
if (actualClearance < minClearance) {
|
if (actualClearanceDen < minClearanceDen) {
|
||||||
denShift += (minClearance - actualClearance);
|
denShift += (minClearanceDen - actualClearanceDen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user