BUG 914031: Added menclose notation phasorangle and Reftest. r=fredw.

This commit is contained in:
Anuj Agarwal 2014-05-11 21:48:00 +02:00
parent ca4d4b49a6
commit 545faaa4e4
9 changed files with 189 additions and 2 deletions

View File

@ -28,6 +28,9 @@ static const char16_t kRadicalChar = 0x221A;
// updiagonalstrike
static const uint8_t kArrowHeadSize = 10;
// phasorangle
static const uint8_t kPhasorangleWidth = 8;
nsIFrame*
NS_NewMathMLmencloseFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
@ -122,6 +125,8 @@ nsresult nsMathMLmencloseFrame::AddNotation(const nsAString& aNotation)
mNotationsToDraw |= NOTATION_HORIZONTALSTRIKE;
} else if (aNotation.EqualsLiteral("madruwb")) {
mNotationsToDraw |= (NOTATION_RIGHT | NOTATION_BOTTOM);
} else if (aNotation.EqualsLiteral("phasorangle")) {
mNotationsToDraw |= (NOTATION_BOTTOM | NOTATION_PHASORANGLE);
}
return NS_OK;
@ -211,6 +216,11 @@ nsMathMLmencloseFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
DisplayBar(aBuilder, this, rect, aLists);
}
if (IsToDraw(NOTATION_PHASORANGLE)) {
DisplayNotation(aBuilder, this, mencloseRect, aLists,
mRuleThickness, NOTATION_PHASORANGLE);
}
if (IsToDraw(NOTATION_LONGDIV)) {
mMathMLChar[mLongDivCharIndex].Display(aBuilder, this, aLists, 1);
@ -387,7 +397,8 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
IsToDraw(NOTATION_CIRCLE) ||
IsToDraw(NOTATION_ROUNDEDBOX) ||
IsToDraw(NOTATION_RADICAL) ||
IsToDraw(NOTATION_LONGDIV)) {
IsToDraw(NOTATION_LONGDIV) ||
IsToDraw(NOTATION_PHASORANGLE)) {
// set a minimal value for the base height
bmBase.ascent = std::max(bmOne.ascent, bmBase.ascent);
bmBase.descent = std::max(0, bmBase.descent);
@ -410,6 +421,14 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
IsToDraw(NOTATION_CIRCLE))
mBoundingMetrics.descent += padding;
///////////////
// phasorangle notation
if (IsToDraw(NOTATION_PHASORANGLE)) {
nscoord phasorangleWidth = kPhasorangleWidth * mRuleThickness;
// Update horizontal parameters
dx_left = std::max(dx_left, phasorangleWidth);
}
///////////////
// updiagonal arrow notation. We need enough space at the top right corner to
// draw the arrow head.
@ -613,6 +632,11 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
IsToDraw(NOTATION_ROUNDEDBOX))
mBoundingMetrics.descent = aDesiredSize.Height() - aDesiredSize.TopAscent();
// phasorangle notation:
// move up from the bottom by the angled line height
if (IsToDraw(NOTATION_PHASORANGLE))
mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent, 2 * kPhasorangleWidth * mRuleThickness - mBoundingMetrics.descent);
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
mReference.x = 0;
@ -802,6 +826,20 @@ void nsDisplayNotation::Paint(nsDisplayListBuilder* aBuilder,
}
break;
case NOTATION_PHASORANGLE: {
// Compute some parameters to draw the angled line,
// that uses a slope of 2 (angle = tan^-1(2)).
// H = w * tan(angle) = w * 2
gfxFloat w = gfxFloat(kPhasorangleWidth) * e;
gfxFloat H = 2 * w;
// Draw the angled line
gfxCtx->NewPath();
gfxCtx->Line(rect.BottomLeft(), rect.BottomLeft() + gfxPoint(w, -H));
gfxCtx->Stroke();
break;
}
default:
NS_NOTREACHED("This notation can not be drawn using nsDisplayNotation");
break;

View File

@ -38,7 +38,8 @@ enum nsMencloseNotation
NOTATION_DOWNDIAGONALSTRIKE = 0x200,
NOTATION_VERTICALSTRIKE = 0x400,
NOTATION_HORIZONTALSTRIKE = 0x800,
NOTATION_UPDIAGONALARROW = 0x1000
NOTATION_UPDIAGONALARROW = 0x1000,
NOTATION_PHASORANGLE = 0x2000
};
class nsMathMLmencloseFrame : public nsMathMLContainerFrame {

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>Test menclose</title>
</head>
<body>
<math>
<menclose notation="phasorangle">
<mspace width="100px" height="50px"></mspace>
</menclose>
</math>
</body>
</html>

View File

@ -0,0 +1,41 @@
<!doctype html>
<html class="reftest-wait">
<head>
<title>menclose phasorangle</title>
<meta charset="utf-8"/>
<script type="text/javascript">
function doTest()
{
var box = document.getElementById("box").getBoundingClientRect();
var w = 8 * 2; // kPhasorangleWidth * rulethickness
var H = 2 * w; // slope 2
document.getElementById("path").setAttribute("d",
"M" + (box.right + "," + box.bottom) +
"L" + (box.left + "," + box.bottom ) +
"l" + ((w) + "," + (-H)));
document.documentElement.removeAttribute("class");
}
window.addEventListener("MozReftestInvalidate", doTest, false);
</script>
</head>
<body>
<div style="position: absolute; left: 20px; top: 20px;">
<math>
<mphantom>
<menclose id="box" notation="phasorangle">
<mspace width="200px" height="100px"></mspace>
</menclose>
</mphantom>
</math>
</div>
<div style="position: absolute; left: 0px; top: 0px;">
<svg width="500px" height="500px">
<path id="path" style="fill: none; stroke-width: 5px; stroke: green; stroke-linecap: round; shape-rendering: crispEdges;"></path>
</svg>
</div>
</body>
</html>

View File

@ -0,0 +1,39 @@
<!doctype html>
<html class="reftest-wait">
<head>
<title>menclose phasorangle</title>
<meta charset="utf-8"/>
<script type="text/javascript">
function doTest()
{
var box = document.getElementById("box").getBoundingClientRect();
var w = 8 * 2; // kPhasorangleWidth * rulethickness
var H = 2 * w; // slope 2
document.getElementById("path").setAttribute("d",
"M" + (box.right + "," + box.bottom) +
"L" + (box.left + "," + box.bottom ) +
"l" + ((w) + "," + (-H)));
document.documentElement.removeAttribute("class");
}
window.addEventListener("MozReftestInvalidate", doTest, false);
</script>
</head>
<body>
<div style="position: absolute; left: 20px; top: 20px;">
<math>
<menclose id="box" notation="phasorangle">
<mspace width="200px" height="100px"></mspace>
</menclose>
</math>
</div>
<div style="position: absolute; left: 0px; top: 0px;">
<svg width="500px" height="500px">
<path id="path" style="fill: none; stroke-width: 5px; stroke: green; stroke-linecap: round; shape-rendering: crispEdges;"></path>
</svg>
</div>
</body>
</html>

View File

@ -0,0 +1,11 @@
<!doctype html>
<html>
<head>
<title>menclose actuarial</title>
</head>
<body>
<p>
<math><menclose id="testMenclose" notation="phasorangle"><mspace width="100px" height="50px"></menclose></math>
</p>
</body>
</html>

View File

@ -0,0 +1,18 @@
<!doctype html>
<html class="reftest-wait">
<head>
<title>menclose phasorangle</title>
<script type="text/javascript">
function doTest() {
document.getElementById('testMenclose').setAttribute("notation","phasorangle");
document.documentElement.removeAttribute("class");
}
window.addEventListener("MozReftestInvalidate", doTest, false);
</script>
</head>
<body>
<p>
<math><menclose id="testMenclose"><mspace width="100px" height="50px"></menclose></math>
</p>
</body>
</html>

View File

@ -0,0 +1,22 @@
<!doctype html>
<html class="reftest-wait">
<head>
<title>menclose phasorangle</title>
<script type="text/javascript">
function doTest() {
document.getElementById('testMenclose').removeAttribute("notation");
document.documentElement.removeAttribute("class");
}
window.addEventListener("MozReftestInvalidate", doTest, false);
</script>
</head>
<body>
<p>
<math>
<menclose id="testMenclose" notation="phasorangle">
<mspace width="100px" height="50px" mathbackground="blue"></mspace>
</menclose>
</math>
</p>
</body>
</html>

View File

@ -175,6 +175,7 @@ fails-if(B2G) == multiscripts-1.html multiscripts-1-ref.html # B2G - slight heig
!= menclose-1n.html menclose-1-ref.html
!= menclose-1o.html menclose-1-ref.html
!= menclose-1p.html menclose-1-ref.html
!= menclose-1q.html menclose-1-ref.html
fails-if(B2G) == menclose-2-actuarial.html menclose-2-actuarial-ref.html # B2G slight thickness variation
== menclose-2-bottom.html menclose-2-bottom-ref.html
fails-if(B2G) == menclose-2-box.html menclose-2-box-ref.html # B2G slight thickness variation
@ -190,6 +191,7 @@ fails-if(B2G) == menclose-2-updiagonalarrow.html menclose-2-updiagonalarrow-ref.
== menclose-2-updiagonalstrike.html menclose-2-updiagonalstrike-ref.html
== menclose-2-verticalstrike.html menclose-2-verticalstrike-ref.html
fails-if(B2G) == menclose-2-roundedbox.html menclose-2-roundedbox-ref.html # B2G slight thickness variation
== menclose-2-phasorangle.html menclose-2-phasorangle-ref.html
== menclose-3-box.html menclose-3-box-ref.html
== menclose-3-madruwb.html menclose-3-madruwb-ref.html
fails random-if(winWidget) == menclose-3-radical.html menclose-3-radical-ref.html # Bug 973917
@ -214,6 +216,7 @@ fuzzy-if(OSX,1,100) == menclose-5-circle.html menclose-5-circle-ref.html
== menclose-5-updiagonalarrow.html menclose-5-updiagonalarrow-ref.html
== menclose-5-updiagonalstrike.html menclose-5-updiagonalstrike-ref.html
== menclose-5-verticalstrike.html menclose-5-verticalstrike-ref.html
== menclose-5-phasorangle.html menclose-5-phasorangle-ref.html
== menclose-6-actuarial.html menclose-6-ref.html
== menclose-6-bottom.html menclose-6-ref.html
== menclose-6-box.html menclose-6-ref.html
@ -230,6 +233,7 @@ fuzzy-if(OSX,1,100) == menclose-5-circle.html menclose-5-circle-ref.html
== menclose-6-updiagonalarrow.html menclose-6-ref.html
== menclose-6-updiagonalstrike.html menclose-6-ref.html
== menclose-6-verticalstrike.html menclose-6-ref.html
== menclose-6-phasorangle.html menclose-6-ref.html
== mmultiscript-align.html mmultiscript-align-ref.html
== subscript-italic-correction.html subscript-italic-correction-ref.html
== mathvariant-1a.html mathvariant-1a-ref.html