diff --git a/layout/mathml/nsMathMLContainerFrame.cpp b/layout/mathml/nsMathMLContainerFrame.cpp
index 43c1e9ec4e7..fa4365881ba 100644
--- a/layout/mathml/nsMathMLContainerFrame.cpp
+++ b/layout/mathml/nsMathMLContainerFrame.cpp
@@ -527,12 +527,12 @@ nsMathMLContainerFrame::FinalizeReflow(nsRenderingContext& aRenderingContext,
}
}
- // see if we should fix the spacing
- FixInterFrameSpacing(aDesiredSize);
-
// Also return our bounding metrics
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
+ // see if we should fix the spacing
+ FixInterFrameSpacing(aDesiredSize);
+
if (!parentWillFireStretch) {
// Not expecting a stretch.
// Finished with these:
@@ -971,6 +971,9 @@ nsMathMLContainerFrame::Reflow(nsPresContext* aPresContext,
return NS_OK;
}
+static nscoord AddInterFrameSpacingToSize(nsHTMLReflowMetrics& aDesiredSize,
+ nsMathMLContainerFrame* aFrame);
+
/* virtual */ nscoord
nsMathMLContainerFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
{
@@ -978,10 +981,12 @@ nsMathMLContainerFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
DISPLAY_MIN_WIDTH(this, result);
nsHTMLReflowMetrics desiredSize(GetWritingMode());
GetIntrinsicWidthMetrics(aRenderingContext, desiredSize);
- nsBoundingMetrics bm = desiredSize.mBoundingMetrics;
- // We include the overflow to compensate for FixInterFrameSpacing.
- result = std::max(bm.width, bm.rightBearing) - std::min(0, bm.leftBearing);
- return result;
+
+ // Include the additional width added by FixInterFrameSpacing to ensure
+ // consistent width calculations.
+ AddInterFrameSpacingToSize(desiredSize, this);
+
+ return desiredSize.Width();
}
/* virtual */ nscoord
@@ -991,10 +996,12 @@ nsMathMLContainerFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
DISPLAY_MIN_WIDTH(this, result);
nsHTMLReflowMetrics desiredSize(GetWritingMode());
GetIntrinsicWidthMetrics(aRenderingContext, desiredSize);
- nsBoundingMetrics bm = desiredSize.mBoundingMetrics;
- // We include the overflow to compensate for FixInterFrameSpacing.
- result = std::max(bm.width, bm.rightBearing) - std::min(0, bm.leftBearing);
- return result;
+
+ // Include the additional width added by FixInterFrameSpacing to ensure
+ // consistent width calculations.
+ AddInterFrameSpacingToSize(desiredSize, this);
+
+ return desiredSize.Width();
}
/* virtual */ void
@@ -1385,40 +1392,54 @@ GetInterFrameSpacingFor(int32_t aScriptLevel,
return 0;
}
-nscoord
-nsMathMLContainerFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
+static nscoord
+AddInterFrameSpacingToSize(nsHTMLReflowMetrics& aDesiredSize,
+ nsMathMLContainerFrame* aFrame)
{
nscoord gap = 0;
- nsIContent* parentContent = mParent->GetContent();
+ nsIFrame* parent = aFrame->GetParent();
+ nsIContent* parentContent = parent->GetContent();
if (MOZ_UNLIKELY(!parentContent)) {
return 0;
}
nsIAtom *parentTag = parentContent->Tag();
if (parentContent->GetNameSpaceID() == kNameSpaceID_MathML &&
(parentTag == nsGkAtoms::math || parentTag == nsGkAtoms::mtd_)) {
- gap = GetInterFrameSpacingFor(StyleFont()->mScriptLevel, mParent, this);
+ gap = GetInterFrameSpacingFor(aFrame->StyleFont()->mScriptLevel,
+ parent, aFrame);
// add our own italic correction
nscoord leftCorrection = 0, italicCorrection = 0;
- GetItalicCorrection(mBoundingMetrics, leftCorrection, italicCorrection);
+ aFrame->GetItalicCorrection(aDesiredSize.mBoundingMetrics,
+ leftCorrection, italicCorrection);
gap += leftCorrection;
- // see if we should shift our children to account for the correction
if (gap) {
- nsIFrame* childFrame = mFrames.FirstChild();
- while (childFrame) {
- childFrame->SetPosition(childFrame->GetPosition() + nsPoint(gap, 0));
- childFrame = childFrame->GetNextSibling();
- }
- mBoundingMetrics.leftBearing += gap;
- mBoundingMetrics.rightBearing += gap;
- mBoundingMetrics.width += gap;
+ aDesiredSize.mBoundingMetrics.leftBearing += gap;
+ aDesiredSize.mBoundingMetrics.rightBearing += gap;
+ aDesiredSize.mBoundingMetrics.width += gap;
aDesiredSize.Width() += gap;
}
- mBoundingMetrics.width += italicCorrection;
+ aDesiredSize.mBoundingMetrics.width += italicCorrection;
aDesiredSize.Width() += italicCorrection;
}
return gap;
}
+nscoord
+nsMathMLContainerFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
+{
+ nscoord gap = 0;
+ gap = AddInterFrameSpacingToSize(aDesiredSize, this);
+ if (gap) {
+ // Shift our children to account for the correction
+ nsIFrame* childFrame = mFrames.FirstChild();
+ while (childFrame) {
+ childFrame->SetPosition(childFrame->GetPosition() + nsPoint(gap, 0));
+ childFrame = childFrame->GetNextSibling();
+ }
+ }
+ return gap;
+}
+
/* static */ void
nsMathMLContainerFrame::DidReflowChildren(nsIFrame* aFirst, nsIFrame* aStop)
diff --git a/layout/mathml/nsMathMLTokenFrame.cpp b/layout/mathml/nsMathMLTokenFrame.cpp
index e66319ea917..fa045ee8f48 100644
--- a/layout/mathml/nsMathMLTokenFrame.cpp
+++ b/layout/mathml/nsMathMLTokenFrame.cpp
@@ -84,6 +84,7 @@ nsMathMLTokenFrame::MarkTextFramesAsTokenMathML()
if (isSingleCharacter) {
child->AddStateBits(NS_FRAME_IS_IN_SINGLE_CHAR_MI);
+ AddStateBits(NS_FRAME_IS_IN_SINGLE_CHAR_MI);
}
}
}
diff --git a/layout/reftests/mathml/mathvariant-2-ref.html b/layout/reftests/mathml/mathvariant-2-ref.html
index f30046b0228..fdb88514c5d 100644
--- a/layout/reftests/mathml/mathvariant-2-ref.html
+++ b/layout/reftests/mathml/mathvariant-2-ref.html
@@ -12,5 +12,14 @@
+