Bug 518592 - Fix single char <mi> frame type and add a test for dotless i. r=karlt

This commit is contained in:
James Kitchener 2014-03-19 10:36:27 -04:00
parent 648fc979d7
commit 2ca56ed2d0
6 changed files with 83 additions and 28 deletions

View File

@ -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)

View File

@ -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);
}
}
}

View File

@ -12,5 +12,14 @@
<mtext>&#x03DC;&#x03DD;</mtext>
</mrow>
</math>
<p>
<math>
<mrow>
<mi mathvariant="italic">&imath;</mi>
<mi mathvariant="italic">&jmath;</mi>
<mi mathvariant="normal">&imath;&imath;</mi>
<mi mathvariant="normal">&jmath;&jmath;</mi>
</mrow>
</math>
</body>
</html>

View File

@ -12,5 +12,14 @@
<mtext mathvariant="italic">&#x03DC;&#x03DD;</mtext>
</mrow>
</math>
<p>
<math>
<mrow>
<mi>&imath;</mi>
<mi>&jmath;</mi>
<mi>&imath;&imath;</mi>
<mi>&jmath;&jmath;</mi>
</mrow>
</math>
</body>
</html>

View File

@ -8,7 +8,7 @@
td { border: 1px solid white;
padding-top: 0;
padding-bottom: 0;
padding-right: 1px;
padding-right: 2px;
padding-left: 1px;
background-color: black;
color: black; }
@ -51,6 +51,13 @@
</td>
</tr>
</table>
<table>
<tr>
<td>
<math><mphantom><mi mathvariant="script">l</mi><mi>i</mi></mphantom></math>
</td>
</tr>
</table>
</body>
</html>

View File

@ -8,7 +8,7 @@
td { border: 1px solid white;
padding-top: 0;
padding-bottom: 0;
padding-right: 1px;
padding-right: 2px;
padding-left: 1px;
background-color: black;
color: black; }
@ -51,6 +51,14 @@
</td>
</tr>
</table>
<table>
<tr>
<td>
<math><mi mathvariant="script">l</mi>
<mi mathvariant="italic">i</mi></math>
</td>
</tr>
</table>
</body>
</html>