Bug 557478 - Defer mfrac operator spacing to outermost embellished operator. r=fredw

This commit is contained in:
James Kitchener 2014-04-07 06:56:00 +02:00
Родитель ff220a4c53
Коммит 43879c3235
6 изменённых файлов: 106 добавлений и 14 удалений

Просмотреть файл

@ -222,8 +222,12 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
GetRuleThickness(aRenderingContext, fm, defaultRuleThickness);
GetAxisHeight(aRenderingContext, fm, axisHeight);
nsEmbellishData coreData;
GetEmbellishDataFrom(mEmbellishData.coreFrame, coreData);
bool outermostEmbellished = false;
if (mEmbellishData.coreFrame) {
nsEmbellishData parentData;
GetEmbellishDataFrom(mParent, parentData);
outermostEmbellished = parentData.coreFrame != mEmbellishData.coreFrame;
}
// see if the linethickness attribute is there
nsAutoString value;
@ -237,16 +241,22 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
if (!mIsBevelled) {
mLineRect.height = mLineThickness;
// by default, leave at least one-pixel padding at either end, or use
// lspace & rspace that may come from <mo> if we are an embellished
// container (we fetch values from the core since they may use units that
// depend on style data, and style changes could have occurred in the
// core since our last visit there)
nscoord leftSpace = std::max(onePixel, StyleVisibility()->mDirection ?
coreData.trailingSpace : coreData.leadingSpace);
nscoord rightSpace = std::max(onePixel, StyleVisibility()->mDirection ?
coreData.leadingSpace : coreData.trailingSpace);
// by default, leave at least one-pixel padding at either end, and add
// lspace & rspace that may come from <mo> if we are an outermost
// embellished container (we fetch values from the core since they may use
// units that depend on style data, and style changes could have occurred
// in the core since our last visit there)
nscoord leftSpace = onePixel;
nscoord rightSpace = onePixel;
if (outermostEmbellished) {
nsEmbellishData coreData;
GetEmbellishDataFrom(mEmbellishData.coreFrame, coreData);
leftSpace += StyleVisibility()->mDirection ?
coreData.trailingSpace : coreData.leadingSpace;
rightSpace += StyleVisibility()->mDirection ?
coreData.leadingSpace : coreData.trailingSpace;
}
//////////////////
// Get shifts
@ -393,8 +403,14 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
nscoord slashMinHeight = slashRatio *
std::min(2 * mLineThickness, slashMaxWidthConstant);
nscoord leadingSpace = std::max(padding, coreData.leadingSpace);
nscoord trailingSpace = std::max(padding, coreData.trailingSpace);
nscoord leadingSpace = padding;
nscoord trailingSpace = padding;
if (outermostEmbellished) {
nsEmbellishData coreData;
GetEmbellishDataFrom(mEmbellishData.coreFrame, coreData);
leadingSpace += coreData.leadingSpace;
trailingSpace += coreData.trailingSpace;
}
nscoord delta;
// ___________

Просмотреть файл

@ -53,3 +53,17 @@ nsMathMLmrowFrame::AttributeChanged(int32_t aNameSpaceID,
return nsMathMLContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
}
/* virtual */ eMathMLFrameType
nsMathMLmrowFrame::GetMathMLFrameType()
{
if (!IsMrowLike()) {
nsIMathMLFrame* child = do_QueryFrame(mFrames.FirstChild());
if (child) {
// We only have one child, so we return the frame type of that child as if
// we didn't exist.
return child->GetMathMLFrameType();
}
}
return nsMathMLFrame::GetMathMLFrameType();
}

Просмотреть файл

@ -32,6 +32,9 @@ public:
return TransmitAutomaticDataForMrowLikeElement();
}
virtual eMathMLFrameType
GetMathMLFrameType() MOZ_OVERRIDE;
bool
IsMrowLike() MOZ_OVERRIDE {
// <mrow> elements with a single child are treated identically to the case

Просмотреть файл

@ -0,0 +1,31 @@
<!doctype html>
<html>
<body>
<p>
<math>
<mtext>_</mtext>
<mrow>
<mfrac>
<mo lspace="1em" rspace="2em">_</mo>
<mtext>_</mtext>
</mfrac>
</mrow>
<mtext>_</mtext>
</math>
</p>
<p>
<math>
<mtext>_</mtext>
<mrow>
<mfrac bevelled="true">
<mo lspace="1em" rspace="2em">_</mo>
<mtext>_</mtext>
</mfrac>
</mrow>
<mtext>_</mtext>
</math>
</p>
</body>
</html>

Просмотреть файл

@ -0,0 +1,27 @@
<!doctype html>
<html>
<body>
<p>
<math>
<mtext>_</mtext>
<mfrac>
<mo lspace="1em" rspace="2em">_</mo>
<mtext>_</mtext>
</mfrac>
<mtext>_</mtext>
</math>
</p>
<p>
<math>
<mtext>_</mtext>
<mfrac bevelled="true">
<mo lspace="1em" rspace="2em">_</mo>
<mtext>_</mtext>
</mfrac>
<mtext>_</mtext>
</math>
</p>
</body>
</html>

Просмотреть файл

@ -143,6 +143,7 @@ skip-if(B2G) == maction-dynamic-1.html maction-dynamic-1-ref.html # bug 773482
== mo-lspace-rspace.html mo-lspace-rspace-ref.html
== mo-lspace-rspace-2.html mo-lspace-rspace-2-ref.html
== mo-lspace-rspace-3.html mo-lspace-rspace-3-ref.html
== mo-lspace-rspace-4.html mo-lspace-rspace-4-ref.html
== mo-invisibleoperators.html mo-invisibleoperators-ref.html
== mo-invisibleoperators-2.html mo-invisibleoperators-2-ref.html
skip-if(B2G) == maction-dynamic-3.html maction-dynamic-3-ref.html # bug 773482