diff --git a/layout/mathml/nsMathMLmencloseFrame.cpp b/layout/mathml/nsMathMLmencloseFrame.cpp index 6385ac9434f9..3ab5a7364f9f 100644 --- a/layout/mathml/nsMathMLmencloseFrame.cpp +++ b/layout/mathml/nsMathMLmencloseFrame.cpp @@ -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; diff --git a/layout/mathml/nsMathMLmencloseFrame.h b/layout/mathml/nsMathMLmencloseFrame.h index df909d0f471f..2d0554aebd64 100644 --- a/layout/mathml/nsMathMLmencloseFrame.h +++ b/layout/mathml/nsMathMLmencloseFrame.h @@ -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 { diff --git a/layout/reftests/mathml/menclose-1q.html b/layout/reftests/mathml/menclose-1q.html new file mode 100644 index 000000000000..0e185e72fc4b --- /dev/null +++ b/layout/reftests/mathml/menclose-1q.html @@ -0,0 +1,13 @@ + + + + Test menclose + + + + + + + + + diff --git a/layout/reftests/mathml/menclose-2-phasorangle-ref.html b/layout/reftests/mathml/menclose-2-phasorangle-ref.html new file mode 100644 index 000000000000..da18a54b98a1 --- /dev/null +++ b/layout/reftests/mathml/menclose-2-phasorangle-ref.html @@ -0,0 +1,41 @@ + + + + menclose phasorangle + + + + + +
+ + + + + + + +
+ +
+ + + +
+ + + diff --git a/layout/reftests/mathml/menclose-2-phasorangle.html b/layout/reftests/mathml/menclose-2-phasorangle.html new file mode 100644 index 000000000000..a8ffbb90b1ad --- /dev/null +++ b/layout/reftests/mathml/menclose-2-phasorangle.html @@ -0,0 +1,39 @@ + + + + menclose phasorangle + + + + + +
+ + + + + +
+ +
+ + + +
+ + + diff --git a/layout/reftests/mathml/menclose-5-phasorangle-ref.html b/layout/reftests/mathml/menclose-5-phasorangle-ref.html new file mode 100644 index 000000000000..e8cc53a51096 --- /dev/null +++ b/layout/reftests/mathml/menclose-5-phasorangle-ref.html @@ -0,0 +1,11 @@ + + + + menclose actuarial + + +

+ +

+ + diff --git a/layout/reftests/mathml/menclose-5-phasorangle.html b/layout/reftests/mathml/menclose-5-phasorangle.html new file mode 100644 index 000000000000..a880ab24f09f --- /dev/null +++ b/layout/reftests/mathml/menclose-5-phasorangle.html @@ -0,0 +1,18 @@ + + + + menclose phasorangle + + + +

+ +

+ + diff --git a/layout/reftests/mathml/menclose-6-phasorangle.html b/layout/reftests/mathml/menclose-6-phasorangle.html new file mode 100644 index 000000000000..5cb5e6ace17e --- /dev/null +++ b/layout/reftests/mathml/menclose-6-phasorangle.html @@ -0,0 +1,22 @@ + + + + menclose phasorangle + + + +

+ + + + + +

+ + diff --git a/layout/reftests/mathml/reftest.list b/layout/reftests/mathml/reftest.list index a7e5b55521a5..aa9cf0bc59d1 100644 --- a/layout/reftests/mathml/reftest.list +++ b/layout/reftests/mathml/reftest.list @@ -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