From dfa6c41b877181385d25cdfaac085e274f38dab5 Mon Sep 17 00:00:00 2001 From: huxuan Date: Tue, 19 Nov 2013 09:08:30 -0500 Subject: [PATCH] Bug 685628 - Make mpadded apply height/depth to logical metrics. r=fredw, r=karlt --- layout/mathml/nsMathMLmpaddedFrame.cpp | 29 +++++++++++------------ layout/mathml/nsMathMLmpaddedFrame.h | 2 +- layout/reftests/mathml/mpadded-7-ref.html | 15 ++++++++++++ layout/reftests/mathml/mpadded-7.html | 16 +++++++++++++ layout/reftests/mathml/mpadded-8-ref.html | 15 ++++++++++++ layout/reftests/mathml/mpadded-8.html | 16 +++++++++++++ layout/reftests/mathml/mpadded-9-ref.html | 15 ++++++++++++ layout/reftests/mathml/mpadded-9.html | 16 +++++++++++++ layout/reftests/mathml/reftest.list | 3 +++ 9 files changed, 111 insertions(+), 16 deletions(-) create mode 100644 layout/reftests/mathml/mpadded-7-ref.html create mode 100644 layout/reftests/mathml/mpadded-7.html create mode 100644 layout/reftests/mathml/mpadded-8-ref.html create mode 100644 layout/reftests/mathml/mpadded-8.html create mode 100644 layout/reftests/mathml/mpadded-9-ref.html create mode 100644 layout/reftests/mathml/mpadded-9.html diff --git a/layout/mathml/nsMathMLmpaddedFrame.cpp b/layout/mathml/nsMathMLmpaddedFrame.cpp index 87a34e19686..987e18abbd6 100644 --- a/layout/mathml/nsMathMLmpaddedFrame.cpp +++ b/layout/mathml/nsMathMLmpaddedFrame.cpp @@ -266,7 +266,7 @@ void nsMathMLmpaddedFrame::UpdateValue(int32_t aSign, int32_t aPseudoUnit, const nsCSSValue& aCSSValue, - const nsBoundingMetrics& aBoundingMetrics, + const nsHTMLReflowMetrics& aDesiredSize, nscoord& aValueToUpdate) const { nsCSSUnit unit = aCSSValue.GetUnit(); @@ -276,15 +276,15 @@ nsMathMLmpaddedFrame::UpdateValue(int32_t aSign, if (eCSSUnit_Percent == unit || eCSSUnit_Number == unit) { switch(aPseudoUnit) { case NS_MATHML_PSEUDO_UNIT_WIDTH: - scaler = aBoundingMetrics.width; + scaler = aDesiredSize.width; break; case NS_MATHML_PSEUDO_UNIT_HEIGHT: - scaler = aBoundingMetrics.ascent; + scaler = aDesiredSize.ascent; break; case NS_MATHML_PSEUDO_UNIT_DEPTH: - scaler = aBoundingMetrics.descent; + scaler = aDesiredSize.height - aDesiredSize.ascent; break; default: @@ -339,8 +339,8 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext, return rv; } - nscoord height = mBoundingMetrics.ascent; - nscoord depth = mBoundingMetrics.descent; + nscoord height = aDesiredSize.ascent; + nscoord depth = aDesiredSize.height - aDesiredSize.ascent; // The REC says: // // "The lspace attribute ('leading' space) specifies the horizontal location @@ -366,7 +366,7 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext, // refer "to the horizontal distance between the positioning point of the // mpadded and the positioning point for the following content". MathML2 // doesn't make the distinction. - nscoord width = mBoundingMetrics.width; + nscoord width = aDesiredSize.width; nscoord voffset = 0; int32_t pseudoUnit; @@ -376,35 +376,35 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext, pseudoUnit = (mWidthPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF) ? NS_MATHML_PSEUDO_UNIT_WIDTH : mWidthPseudoUnit; UpdateValue(mWidthSign, pseudoUnit, mWidth, - mBoundingMetrics, width); + aDesiredSize, width); width = std::max(0, width); // update "height" (this is the ascent in the terminology of the REC) pseudoUnit = (mHeightPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF) ? NS_MATHML_PSEUDO_UNIT_HEIGHT : mHeightPseudoUnit; UpdateValue(mHeightSign, pseudoUnit, mHeight, - mBoundingMetrics, height); + aDesiredSize, height); height = std::max(0, height); // update "depth" (this is the descent in the terminology of the REC) pseudoUnit = (mDepthPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF) ? NS_MATHML_PSEUDO_UNIT_DEPTH : mDepthPseudoUnit; UpdateValue(mDepthSign, pseudoUnit, mDepth, - mBoundingMetrics, depth); + aDesiredSize, depth); depth = std::max(0, depth); // update lspace if (mLeadingSpacePseudoUnit != NS_MATHML_PSEUDO_UNIT_ITSELF) { pseudoUnit = mLeadingSpacePseudoUnit; UpdateValue(mLeadingSpaceSign, pseudoUnit, mLeadingSpace, - mBoundingMetrics, lspace); + aDesiredSize, lspace); } // update voffset if (mVerticalOffsetPseudoUnit != NS_MATHML_PSEUDO_UNIT_ITSELF) { pseudoUnit = mVerticalOffsetPseudoUnit; UpdateValue(mVerticalOffsetSign, pseudoUnit, mVerticalOffset, - mBoundingMetrics, voffset); + aDesiredSize, voffset); } // do the padding now that we have everything // The idea here is to maintain the invariant that ... (i.e., @@ -427,13 +427,12 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext, mBoundingMetrics.rightBearing = mBoundingMetrics.width; } - nscoord dy = height - mBoundingMetrics.ascent; nscoord dx = (StyleVisibility()->mDirection ? width - initialWidth - lspace : lspace); - aDesiredSize.ascent += dy; + aDesiredSize.ascent = height; aDesiredSize.width = mBoundingMetrics.width; - aDesiredSize.height += dy + depth - mBoundingMetrics.descent; + aDesiredSize.height = depth + aDesiredSize.ascent; mBoundingMetrics.ascent = height; mBoundingMetrics.descent = depth; aDesiredSize.mBoundingMetrics = mBoundingMetrics; diff --git a/layout/mathml/nsMathMLmpaddedFrame.h b/layout/mathml/nsMathMLmpaddedFrame.h index a08ef8984a1..a4dfabfe764 100644 --- a/layout/mathml/nsMathMLmpaddedFrame.h +++ b/layout/mathml/nsMathMLmpaddedFrame.h @@ -79,7 +79,7 @@ private: UpdateValue(int32_t aSign, int32_t aPseudoUnit, const nsCSSValue& aCSSValue, - const nsBoundingMetrics& aBoundingMetrics, + const nsHTMLReflowMetrics& aDesiredSize, nscoord& aValueToUpdate) const; }; diff --git a/layout/reftests/mathml/mpadded-7-ref.html b/layout/reftests/mathml/mpadded-7-ref.html new file mode 100644 index 00000000000..950df9c530a --- /dev/null +++ b/layout/reftests/mathml/mpadded-7-ref.html @@ -0,0 +1,15 @@ + + + + Test mpadded + + + + + + X + + + + + diff --git a/layout/reftests/mathml/mpadded-7.html b/layout/reftests/mathml/mpadded-7.html new file mode 100644 index 00000000000..e52dbeba2f2 --- /dev/null +++ b/layout/reftests/mathml/mpadded-7.html @@ -0,0 +1,16 @@ + + + + Test mpadded + + + + + + + _ + + + + + diff --git a/layout/reftests/mathml/mpadded-8-ref.html b/layout/reftests/mathml/mpadded-8-ref.html new file mode 100644 index 00000000000..949c042319b --- /dev/null +++ b/layout/reftests/mathml/mpadded-8-ref.html @@ -0,0 +1,15 @@ + + + + Test mpadded + + + + + + X + + + + + diff --git a/layout/reftests/mathml/mpadded-8.html b/layout/reftests/mathml/mpadded-8.html new file mode 100644 index 00000000000..fe0ab8d0957 --- /dev/null +++ b/layout/reftests/mathml/mpadded-8.html @@ -0,0 +1,16 @@ + + + + Test mpadded + + + + + + + | + + + + + diff --git a/layout/reftests/mathml/mpadded-9-ref.html b/layout/reftests/mathml/mpadded-9-ref.html new file mode 100644 index 00000000000..97c158913fa --- /dev/null +++ b/layout/reftests/mathml/mpadded-9-ref.html @@ -0,0 +1,15 @@ + + + + Test mpadded + + + + + + X + + + + + diff --git a/layout/reftests/mathml/mpadded-9.html b/layout/reftests/mathml/mpadded-9.html new file mode 100644 index 00000000000..a5234e11020 --- /dev/null +++ b/layout/reftests/mathml/mpadded-9.html @@ -0,0 +1,16 @@ + + + + Test mpadded + + + + + + + | + + + + + diff --git a/layout/reftests/mathml/reftest.list b/layout/reftests/mathml/reftest.list index 45907469250..e03148125b4 100644 --- a/layout/reftests/mathml/reftest.list +++ b/layout/reftests/mathml/reftest.list @@ -92,6 +92,9 @@ fails == mstyle-5.xhtml mstyle-5-ref.xhtml # Bug 787215 == mpadded-5.html mpadded-5-ref.html == mpadded-1-2.html mpadded-1-2-ref.html == mpadded-6.html mpadded-6-ref.html +== mpadded-7.html mpadded-7-ref.html +== mpadded-8.html mpadded-8-ref.html +== mpadded-9.html mpadded-9-ref.html == math-display.html math-display-ref.html == scriptlevel-movablelimits-1.html scriptlevel-movablelimits-1-ref.html == munderover-align-accent-false.html munderover-align-accent-false-ref.html