non-spacing marks in munder are off center or too long. b=428863 r+sr=roc

This commit is contained in:
Karl Tomlinson 2008-07-21 19:32:46 +12:00
parent cb75d58ea5
commit 59302b51ac
6 changed files with 83 additions and 8 deletions

View File

@ -308,6 +308,14 @@ nsMathMLContainerFrame::GetPreferredStretchSize(nsIRenderingContext& aRenderingC
// vertically and fire an horizontal stretch on each them. This is the case // vertically and fire an horizontal stretch on each them. This is the case
// for \munder, \mover, \munderover. We just sum-up the size vertically. // for \munder, \mover, \munderover. We just sum-up the size vertically.
bm.descent += bmChild.ascent + bmChild.descent; bm.descent += bmChild.ascent + bmChild.descent;
// Sometimes non-spacing marks (when width is zero) are positioned
// to the left of the origin, but it is the distance between left
// and right bearing that is important rather than the offsets from
// the origin.
if (bmChild.width == 0) {
bmChild.rightBearing -= bmChild.leftBearing;
bmChild.leftBearing = 0;
}
if (bm.leftBearing > bmChild.leftBearing) if (bm.leftBearing > bmChild.leftBearing)
bm.leftBearing = bmChild.leftBearing; bm.leftBearing = bmChild.leftBearing;
if (bm.rightBearing < bmChild.rightBearing) if (bm.rightBearing < bmChild.rightBearing)

View File

@ -317,13 +317,21 @@ nsMathMLmunderFrame::Place(nsIRenderingContext& aRenderingContext,
// empty under? // empty under?
if (!(bmUnder.ascent + bmUnder.descent)) delta1 = 0; if (!(bmUnder.ascent + bmUnder.descent)) delta1 = 0;
nscoord dxBase, dxUnder; nscoord dxBase, dxUnder = 0;
nscoord maxWidth = PR_MAX(bmBase.width, bmUnder.width);
// Width of non-spacing marks is zero so use left and right bearing.
nscoord underWidth = bmUnder.width;
if (!underWidth) {
underWidth = bmUnder.rightBearing - bmUnder.leftBearing;
dxUnder = -bmUnder.leftBearing;
}
nscoord maxWidth = PR_MAX(bmBase.width, underWidth);
if (NS_MATHML_EMBELLISH_IS_ACCENTUNDER(mEmbellishData.flags)) { if (NS_MATHML_EMBELLISH_IS_ACCENTUNDER(mEmbellishData.flags)) {
dxUnder = (maxWidth - bmUnder.width)/2; dxUnder += (maxWidth - underWidth)/2;
} }
else { else {
dxUnder = -correction/2 + (maxWidth - bmUnder.width)/2; dxUnder += -correction/2 + (maxWidth - underWidth)/2;
} }
dxBase = (maxWidth - bmBase.width)/2; dxBase = (maxWidth - bmBase.width)/2;

View File

@ -436,12 +436,19 @@ nsMathMLmunderoverFrame::Place(nsIRenderingContext& aRenderingContext,
GetItalicCorrection(bmAnonymousBase, correction); GetItalicCorrection(bmAnonymousBase, correction);
nscoord maxWidth = PR_MAX(bmAnonymousBase.width, bmUnder.width); // Width of non-spacing marks is zero so use left and right bearing.
if (NS_MATHML_EMBELLISH_IS_ACCENTUNDER(mEmbellishData.flags)) { nscoord underWidth = bmUnder.width;
dxUnder = (maxWidth - bmUnder.width)/2;; if (!underWidth) {
underWidth = bmUnder.rightBearing - bmUnder.leftBearing;
dxUnder = -bmUnder.leftBearing;
}
nscoord maxWidth = PR_MAX(bmAnonymousBase.width, underWidth);
if (NS_MATHML_EMBELLISH_IS_ACCENTUNDER(mEmbellishData.flags)) {
dxUnder += (maxWidth - underWidth)/2;;
} }
else { else {
dxUnder = -correction/2 + (maxWidth - bmUnder.width)/2; dxUnder += -correction/2 + (maxWidth - underWidth)/2;
} }
nscoord dxAnonymousBase = (maxWidth - bmAnonymousBase.width)/2; nscoord dxAnonymousBase = (maxWidth - bmAnonymousBase.width)/2;

View File

@ -2,5 +2,6 @@
== mi-mathvariant-2.xhtml mi-mathvariant-2-ref.xhtml == mi-mathvariant-2.xhtml mi-mathvariant-2-ref.xhtml
== table-width-1.xhtml table-width-1-ref.xhtml == table-width-1.xhtml table-width-1-ref.xhtml
== overbar-width-1.xhtml overbar-width-1-ref.xhtml == overbar-width-1.xhtml overbar-width-1-ref.xhtml
== underbar-width-1.xhtml underbar-width-1-ref.xhtml
!= non-spacing-accent-1.xhtml non-spacing-accent-1-ref.xhtml != non-spacing-accent-1.xhtml non-spacing-accent-1-ref.xhtml
!= stretchy-underbar-1.xhtml stretchy-underbar-1-ref.xhtml != stretchy-underbar-1.xhtml stretchy-underbar-1-ref.xhtml

View File

@ -0,0 +1,26 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
html { background-color: grey; }
div { display: inline-block;
font-size: 30px;
line-height: 60px; /* Ensure space for underbar */
border: 1px solid white;
padding: 2px; /* 10% error allowed in char selection */
background-color: black;
color: red; }
</style>
</head>
<body>
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mphantom>
<munder>
<mn>1</mn>
<mo>&#x332;</mo>
</munder>
</mphantom>
</math>
</div>
</body>
</html>

View File

@ -0,0 +1,25 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check width of stretchy OverBar</title>
<style type="text/css">
html { background-color: grey; }
div { display: inline-block;
font-size: 30px;
line-height: 60px; /* Ensure space for underbar */
border: 1px solid white;
padding: 2px; /* 10% error allowed in char selection */
background-color: black;
color: black; }
</style>
</head>
<body>
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<munder>
<mn>1</mn>
<mo>&#x332;</mo>
</munder>
</math>
</div>
</body>
</html>