From 526b3dfa826173a74178d6026fbe1d045eb3e21f Mon Sep 17 00:00:00 2001 From: "rbs%maths.uq.edu.au" Date: Thu, 10 Jan 2002 23:40:40 +0000 Subject: [PATCH] [MathML only] Rename the pointer on the embellished operator from |firstChild| to |next| because it is more clearer with the latter that it is an hierarchy. Also made the inheritance of the displaystyle more reliable by walking up to the root tag if necessary, e.g., if a MathML frame happens to be surrounded by non-MathML helper frames needed for its support git-svn-id: svn://10.0.0.236/trunk@111885 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout/mathml/base/src/nsIMathMLFrame.h | 4 +- .../base/src/nsMathMLContainerFrame.cpp | 168 ++++++++++-------- .../mathml/base/src/nsMathMLContainerFrame.h | 8 - .../layout/mathml/base/src/nsMathMLFrame.cpp | 26 ++- .../mathml/base/src/nsMathMLmactionFrame.cpp | 15 +- .../mathml/base/src/nsMathMLmfracFrame.cpp | 14 +- .../mathml/base/src/nsMathMLmfracFrame.h | 2 +- .../mathml/base/src/nsMathMLmoFrame.cpp | 5 +- .../mathml/base/src/nsMathMLmtableFrame.cpp | 74 +++++--- 9 files changed, 181 insertions(+), 135 deletions(-) diff --git a/mozilla/layout/mathml/base/src/nsIMathMLFrame.h b/mozilla/layout/mathml/base/src/nsIMathMLFrame.h index 2ff6aa65a24..789a9ff5d62 100644 --- a/mozilla/layout/mathml/base/src/nsIMathMLFrame.h +++ b/mozilla/layout/mathml/base/src/nsIMathMLFrame.h @@ -298,7 +298,7 @@ struct nsPresentationData { // struct used by an embellished container to keep track of its embellished child struct nsEmbellishData { PRUint32 flags; - nsIFrame* firstChild; // handy pointer on our embellished child + nsIFrame* next; // handy pointer on our embellished child to descend the hierarchy nsIFrame* core; // pointer on the mo frame at the core of the embellished hierarchy nsStretchDirection direction; nscoord leftSpace, rightSpace; @@ -306,7 +306,7 @@ struct nsEmbellishData { nsEmbellishData() { flags = 0; - firstChild = nsnull; + next = nsnull; core = nsnull; direction = NS_STRETCH_DIRECTION_UNSUPPORTED; leftSpace = rightSpace = 0; diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp index 23801b25129..d89d4fc5667 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -63,36 +63,6 @@ NS_IMPL_QUERY_INTERFACE_INHERITED1(nsMathMLContainerFrame, nsHTMLContainerFrame, // ============================================================================= -// This is the method used to set the frame as an embellished container. -// It checks if the first (non-empty) child is embellished. Hence, calls -// must be bottom-up. The method must only be called from within frames who are -// entitled to be potential embellished operators as per the MathML REC. -NS_IMETHODIMP -nsMathMLContainerFrame::EmbellishOperator() -{ - nsIFrame* firstChild = mFrames.FirstChild(); - if (firstChild && IsEmbellishOperator(firstChild)) { - // Cache the first child - mEmbellishData.flags |= NS_MATHML_EMBELLISH_OPERATOR; - mEmbellishData.firstChild = firstChild; - // Cache also the inner-most embellished frame at the core of the hierarchy - nsIMathMLFrame* mathMLFrame; - firstChild->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - nsEmbellishData embellishData; - mathMLFrame->GetEmbellishData(embellishData); - mEmbellishData.core = embellishData.core ? embellishData.core : firstChild; - mEmbellishData.direction = embellishData.direction; - } - else { - mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_OPERATOR; - mEmbellishData.firstChild = nsnull; - mEmbellishData.core = nsnull; - mEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED; - } - return NS_OK; -} - -// ------------------------- // error handlers // by default show the Unicode REPLACEMENT CHARACTER U+FFFD // when a frame with bad markup can not be rendered @@ -174,12 +144,40 @@ nsMathMLContainerFrame::PaintError(nsIPresContext* aPresContext, return NS_OK; } - /* ///////////// - * nsIMathMLFrame - support methods for precise positioning + * nsIMathMLFrame - support methods for stretchy elements * ============================================================================= */ +// This is the method used to set the frame as an embellished container. +// It checks if the first (non-empty) child is embellished. Hence, calls +// must be bottom-up. The method must only be called from within frames who are +// entitled to be potential embellished operators as per the MathML REC. +NS_IMETHODIMP +nsMathMLContainerFrame::EmbellishOperator() +{ + nsIFrame* firstChild = mFrames.FirstChild(); + if (firstChild && IsEmbellishOperator(firstChild)) { + // Cache the first child + mEmbellishData.flags |= NS_MATHML_EMBELLISH_OPERATOR; + mEmbellishData.next = firstChild; + // Cache also the inner-most embellished frame at the core of the hierarchy + nsIMathMLFrame* mathMLFrame; + firstChild->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + nsEmbellishData embellishData; + mathMLFrame->GetEmbellishData(embellishData); + mEmbellishData.core = embellishData.core; + mEmbellishData.direction = embellishData.direction; + } + else { + mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_OPERATOR; + mEmbellishData.next = nsnull; + mEmbellishData.core = nsnull; + mEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED; + } + return NS_OK; +} + // helper method to facilitate getting the reflow and bounding metrics void nsMathMLContainerFrame::GetReflowAndBoundingMetricsFor(nsIFrame* aFrame, @@ -201,8 +199,8 @@ nsMathMLContainerFrame::GetReflowAndBoundingMetricsFor(nsIFrame* aFra aBoundingMetrics.Clear(); nsIMathMLFrame* mathMLFrame; - nsresult rv = aFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (NS_SUCCEEDED(rv) && mathMLFrame) { + aFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { mathMLFrame->GetBoundingMetrics(aBoundingMetrics); } else { // aFrame is not a MathML frame, just return the reflow metrics @@ -213,11 +211,8 @@ nsMathMLContainerFrame::GetReflowAndBoundingMetricsFor(nsIFrame* aFra } } -/* ///////////// - * nsIMathMLFrame - support methods for stretchy elements - * ============================================================================= - */ - +// helper to get the preferred size that a container frame should use to fire +// the stretch on its stretchy child frames. void nsMathMLContainerFrame::GetPreferredStretchSize(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, @@ -257,17 +252,17 @@ nsMathMLContainerFrame::GetPreferredStretchSize(nsIPresContext* aPresContex bmChild.leftBearing = 0; nsIMathMLFrame* mathMLFrame; - nsresult rv = childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (NS_SUCCEEDED(rv) && mathMLFrame) { + childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { nsEmbellishData childData; mathMLFrame->GetEmbellishData(childData); if (NS_MATHML_IS_EMBELLISH_OPERATOR(childData.flags) && childData.direction == aStretchDirection && - childData.firstChild) { + childData.next) { // embellishements are not included, only consider the inner first child itself nsIMathMLFrame* mathMLchildFrame; - rv = childData.firstChild->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLchildFrame); - if (NS_SUCCEEDED(rv) && mathMLchildFrame) { + childData.next->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLchildFrame); + if (mathMLchildFrame) { mathMLFrame = mathMLchildFrame; } } @@ -316,7 +311,6 @@ nsMathMLContainerFrame::Stretch(nsIPresContext* aPresContext, nsBoundingMetrics& aContainerSize, nsHTMLReflowMetrics& aDesiredStretchSize) { - nsresult rv = NS_OK; if (NS_MATHML_IS_EMBELLISH_OPERATOR(mEmbellishData.flags)) { if (NS_MATHML_STRETCH_WAS_DONE(mEmbellishData.flags)) { @@ -332,12 +326,12 @@ nsMathMLContainerFrame::Stretch(nsIPresContext* aPresContext, // Pass the stretch to the first non-empty child ... - nsIFrame* childFrame = mEmbellishData.firstChild; + nsIFrame* childFrame = mEmbellishData.next; if (childFrame) { nsIMathMLFrame* mathMLFrame; - rv = childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - NS_ASSERTION(NS_SUCCEEDED(rv) && mathMLFrame, "Something is wrong somewhere"); - if (NS_SUCCEEDED(rv) && mathMLFrame) { + childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + NS_ASSERTION(mathMLFrame, "Something is wrong somewhere"); + if (mathMLFrame) { PRBool stretchAll = NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY(mEmbellishData.flags) || NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY(mEmbellishData.flags); @@ -395,9 +389,9 @@ nsMathMLContainerFrame::Stretch(nsIPresContext* aPresContext, childFrame = mFrames.FirstChild(); while (childFrame) { - if (childFrame != mEmbellishData.firstChild) { - rv = childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (NS_SUCCEEDED(rv) && mathMLFrame) { + if (childFrame != mEmbellishData.next) { + childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { // retrieve the metrics that was stored at the previous pass GetReflowAndBoundingMetricsFor(childFrame, childSize, childSize.mBoundingMetrics); @@ -480,7 +474,7 @@ nsMathMLContainerFrame::FinalizeReflow(nsIPresContext* aPresContext, // because it excludes the particular case of the core ... itself. // ( needs to fire stretch on its MathMLChar in any case to initialize it) PRBool placeOrigin = !NS_MATHML_IS_EMBELLISH_OPERATOR(mEmbellishData.flags) || - (mEmbellishData.core && !mEmbellishData.firstChild && + (mEmbellishData.core != this && !mEmbellishData.next && mEmbellishData.direction == NS_STRETCH_DIRECTION_UNSUPPORTED); Place(aPresContext, aRenderingContext, placeOrigin, aDesiredSize); @@ -491,13 +485,13 @@ nsMathMLContainerFrame::FinalizeReflow(nsIPresContext* aPresContext, PRBool parentWillFireStretch = PR_FALSE; nsEmbellishData parentData; nsIMathMLFrame* mathMLFrame; - nsresult rv = mParent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (NS_SUCCEEDED(rv) && mathMLFrame) { + mParent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { mathMLFrame->GetEmbellishData(parentData); if (NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY(parentData.flags) || NS_MATHML_WILL_STRETCH_ALL_CHILDREN_HORIZONTALLY(parentData.flags) || (NS_MATHML_IS_EMBELLISH_OPERATOR(parentData.flags) - && parentData.firstChild == this)) + && parentData.next == this)) { parentWillFireStretch = PR_TRUE; } @@ -781,6 +775,8 @@ CompressWhitespace(nsIContent* aContent) } } +// This method is called in a top-down manner, as we descend the frame tree +// during its construction NS_IMETHODIMP nsMathMLContainerFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, @@ -797,30 +793,45 @@ nsMathMLContainerFrame::Init(nsIPresContext* aPresContext, nsresult rv; rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); - // now, if our parent implements the nsIMathMLFrame interface, we inherit + // now, find our parent that implements the nsIMathMLFrame interface and inherit // its scriptlevel and displaystyle. If the parent later wishes to increment // with other values, it will do so in its SetInitialChildList() method. - nsIMathMLFrame* mathMLFrame; - aParent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (mathMLFrame) { - nsPresentationData parentData; - mathMLFrame->GetPresentationData(parentData); - mPresentationData.mstyle = parentData.mstyle; - mPresentationData.scriptLevel = parentData.scriptLevel; - if (NS_MATHML_IS_DISPLAYSTYLE(parentData.flags)) { - mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + nsIFrame* parent = aParent; + while (parent) { + nsIMathMLFrame* mathMLFrame; + parent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { + nsPresentationData parentData; + mathMLFrame->GetPresentationData(parentData); + mPresentationData.mstyle = parentData.mstyle; + mPresentationData.scriptLevel = parentData.scriptLevel; + if (NS_MATHML_IS_DISPLAYSTYLE(parentData.flags)) { + mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + } + break; } + // stop if we reach the root tag + nsCOMPtr parentTag; + nsCOMPtr parentContent; + parent->GetContent(getter_AddRefs(parentContent)); + parentContent->GetTag(*getter_AddRefs(parentTag)); + if (parentTag.get() == nsMathMLAtoms::math) { + const nsStyleDisplay* display; + parent->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); + if (display->mDisplay == NS_STYLE_DISPLAY_BLOCK) { + mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + } + break; + } + parent->GetParent(&parent); } - else { - // It could be that we are wrapped by several non-MathML frames. - // So we retain displaystyle=false, knowing that if our root - // is in displaystyle=true, it will propagate an update to us - // later and we will recover the right displaystyle state anyway. - } + return rv; } +// This method is called in a bottom-up manner, as we ascend the frame tree +// after its construction NS_IMETHODIMP nsMathMLContainerFrame::SetInitialChildList(nsIPresContext* aPresContext, nsIAtom* aListName, @@ -851,8 +862,8 @@ nsMathMLContainerFrame::SetInitialChildList(nsIPresContext* aPresContext, nsIFrame* child = next; next->GetNextSibling(&next); nsInlineFrame* inlineFrame = nsnull; - nsresult res = child->QueryInterface(nsInlineFrame::kInlineFrameCID, (void**)&inlineFrame); - if (NS_SUCCEEDED(res) && inlineFrame) { + child->QueryInterface(nsInlineFrame::kInlineFrameCID, (void**)&inlineFrame); + if (inlineFrame) { // create a new anonymous block frame to wrap this child... nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); @@ -1147,8 +1158,8 @@ printf("\n"); childFrame = mFrames.FirstChild(); while (childFrame) { nsIMathMLFrame* mathMLFrame; - rv = childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (NS_SUCCEEDED(rv) && mathMLFrame) { + childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { // retrieve the metrics that was stored at the previous pass GetReflowAndBoundingMetricsFor(childFrame, childDesiredSize, childDesiredSize.mBoundingMetrics); @@ -1384,9 +1395,8 @@ nsMathMLContainerFrame::FixInterFrameSpacing(nsIPresContext* aPresContext, nscoord gap = 0, leftCorrection, italicCorrection; if (prevSibling) { nsIMathMLFrame* mathMLFrame; - nsresult res = prevSibling->QueryInterface( - NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (NS_SUCCEEDED(res) && mathMLFrame) { + prevSibling->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { // get thinspace nsCOMPtr parentContext; mParent->GetStyleContext(getter_AddRefs(parentContext)); diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h index 94eb91bea7a..82cd3afaf54 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h @@ -294,14 +294,6 @@ public: rv = nsBlockFrame::SetInitialChildList(aPresContext, aListName, aChildList); - // notify our children that they are now in displaystyle=true - nsIFrame* childFrame = aChildList; - while (childFrame) { - nsMathMLContainerFrame::PropagatePresentationDataFor(aPresContext, - childFrame, 0, NS_MATHML_DISPLAYSTYLE, NS_MATHML_DISPLAYSTYLE); - childFrame->GetNextSibling(&childFrame); - } - // re-resolve our subtree to set any mathml-expected scriptsizes nsMathMLContainerFrame::PropagateScriptStyleFor(aPresContext, this, 0); diff --git a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp index 24f99890f78..af3604a1434 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp @@ -59,8 +59,8 @@ nsMathMLFrame::IsEmbellishOperator(nsIFrame* aFrame) NS_PRECONDITION(aFrame, "null arg"); if (!aFrame) return PR_FALSE; nsIMathMLFrame* mathMLFrame; - nsresult rv = aFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (NS_FAILED(rv) || !mathMLFrame) return PR_FALSE; + aFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (!mathMLFrame) return PR_FALSE; nsEmbellishData embellishData; mathMLFrame->GetEmbellishData(embellishData); return NS_MATHML_IS_EMBELLISH_OPERATOR(embellishData.flags); @@ -120,8 +120,8 @@ nsMathMLFrame::GetAttribute(nsIContent* aContent, if (mstyleParent) { nsIMathMLFrame* mathMLFrame; - rv = mstyleParent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (NS_SUCCEEDED(rv) && mathMLFrame) { + mstyleParent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { mathMLFrame->GetPresentationData(mstyleParentData); } } @@ -140,6 +140,15 @@ nsMathMLFrame::GetRuleThickness(nsIRenderingContext& aRenderingContext, { // get the bounding metrics of the overbar char, the rendering context // is assumed to have been set with the font of the current style context +#ifdef NS_DEBUG + const nsFont* myFont; + aFontMetrics->GetFont(myFont); + nsCOMPtr currFontMetrics; + aRenderingContext.GetFontMetrics(*getter_AddRefs(currFontMetrics)); + const nsFont* currFont; + currFontMetrics->GetFont(currFont); + NS_ASSERTION(currFont->Equals(*myFont), "unexpected state"); +#endif nscoord xHeight; aFontMetrics->GetXHeight(xHeight); PRUnichar overBar = 0x00AF; @@ -173,6 +182,15 @@ nsMathMLFrame::GetAxisHeight(nsIRenderingContext& aRenderingContext, { // get the bounding metrics of the minus sign, the rendering context // is assumed to have been set with the font of the current style context +#ifdef NS_DEBUG + const nsFont* myFont; + aFontMetrics->GetFont(myFont); + nsCOMPtr currFontMetrics; + aRenderingContext.GetFontMetrics(*getter_AddRefs(currFontMetrics)); + const nsFont* currFont; + currFontMetrics->GetFont(currFont); + NS_ASSERTION(currFont->Equals(*myFont), "unexpected state"); +#endif nscoord xHeight; aFontMetrics->GetXHeight(xHeight); PRUnichar minus = '-'; diff --git a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp index 49bc13df172..7e2d897412d 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmactionFrame.cpp @@ -222,18 +222,18 @@ nsMathMLmactionFrame::GetSelectedFrame() // if the selected child is an embellished operator, // we become embellished as well mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_OPERATOR; - mEmbellishData.firstChild = nsnull; + mEmbellishData.next = nsnull; mEmbellishData.core = nsnull; mEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED; if (mSelectedFrame) { - nsIMathMLFrame* mathMLFrame = nsnull; - rv = mSelectedFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (NS_SUCCEEDED(rv) && mathMLFrame) { + nsIMathMLFrame* mathMLFrame; + mSelectedFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { nsEmbellishData embellishData; mathMLFrame->GetEmbellishData(embellishData); - if (NS_MATHML_IS_EMBELLISH_OPERATOR(embellishData.flags) && embellishData.firstChild) { + if (NS_MATHML_IS_EMBELLISH_OPERATOR(embellishData.flags)) { mEmbellishData.flags |= NS_MATHML_EMBELLISH_OPERATOR; - mEmbellishData.firstChild = mSelectedFrame; // yes! + mEmbellishData.next = mSelectedFrame; // yes! mEmbellishData.core = embellishData.core; mEmbellishData.direction = embellishData.direction; } @@ -277,8 +277,7 @@ nsMathMLmactionFrame::GetFrameForPoint(nsIPresContext* aPresContext, pt.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y); return childFrame->GetFrameForPoint(aPresContext, pt, aWhichLayer, aFrame); } - else - return nsFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame); + return nsFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame); } // Only paint the selected child... diff --git a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp index e0f2b1d221f..f4294d60379 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp @@ -514,10 +514,20 @@ nsMathMLmfracFrame::UpdatePresentationDataFromChildAt(nsIPresContext* aPresConte PRUint32 aFlagsValues, PRUint32 aFlagsToUpdate) { - // The element sets displaystyle to "false" within numerator and - // denominator so we disable the displaystyle bit to retain what we set earlier + // The REC says "The element sets displaystyle to "false" within + // numerator and denominator" +#if 0 + // At one point I thought that it meant that the displaystyle state of + // the numerator and denominator cannot be modified by an ancestor, i.e., + // to change the displaystlye, one has to use displaystyle="true" with mstyle: + // numerator denominator + + // Commenting out for now until it is clear what the intention really is. + // See also the variants for , , + aFlagsToUpdate &= ~NS_MATHML_DISPLAYSTYLE; aFlagsValues &= ~NS_MATHML_DISPLAYSTYLE; +#endif return nsMathMLContainerFrame:: UpdatePresentationDataFromChildAt(aPresContext, aFirstIndex, aLastIndex, aScriptLevelIncrement, aFlagsValues, aFlagsToUpdate); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.h index cefd96df680..b578ace951b 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.h @@ -154,7 +154,7 @@ public: mEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED; // break the embellished hierarchy to stop propagating the stretching // process, but keep access to mEmbellishData.core for convenience - mEmbellishData.firstChild = nsnull; + mEmbellishData.next = nsnull; return rv; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp index f64a7cee3e2..7882ae4d055 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp @@ -204,9 +204,8 @@ nsMathMLmoFrame::SetInitialChildList(nsIPresContext* aPresContext, if (firstChild) { mEmbellishData.direction = mMathMLChar.GetStretchDirection(); mEmbellishData.flags |= NS_MATHML_EMBELLISH_OPERATOR; - // IMPORTANT: these two NULL tell us the core of the embellished hierarchy. - mEmbellishData.firstChild = nsnull; - mEmbellishData.core = nsnull; + mEmbellishData.next = nsnull; + mEmbellishData.core = this; // there are two extra things that we need to record so that if our // parent is , , or , they will treat us properly: diff --git a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp index c24e92dd504..e1528f8b2f4 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp @@ -289,27 +289,34 @@ nsMathMLmtableOuterFrame::Init(nsIPresContext* aPresContext, // XXX the REC says that by default, displaystyle=false in - nsIMathMLFrame* mathMLFrame = nsnull; - nsresult res = aParent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (NS_SUCCEEDED(res) && mathMLFrame) { - nsPresentationData parentData; - mathMLFrame->GetPresentationData(parentData); - - mPresentationData.mstyle = parentData.mstyle; - mPresentationData.scriptLevel = parentData.scriptLevel; - if (NS_MATHML_IS_DISPLAYSTYLE(parentData.flags)) - mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; - else - mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE; - } - else { - // see if our parent has 'display: block' - // XXX should we restrict this to the top level parent ? - const nsStyleDisplay* display; - aParent->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); - if (display->mDisplay == NS_STYLE_DISPLAY_BLOCK) { - mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + nsIFrame* parent = aParent; + while (parent) { + nsIMathMLFrame* mathMLFrame; + parent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { + nsPresentationData parentData; + mathMLFrame->GetPresentationData(parentData); + mPresentationData.mstyle = parentData.mstyle; + mPresentationData.scriptLevel = parentData.scriptLevel; + if (NS_MATHML_IS_DISPLAYSTYLE(parentData.flags)) { + mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + } + break; } + // stop if we reach the root tag + nsCOMPtr parentTag; + nsCOMPtr parentContent; + parent->GetContent(getter_AddRefs(parentContent)); + parentContent->GetTag(*getter_AddRefs(parentTag)); + if (parentTag.get() == nsMathMLAtoms::math) { + const nsStyleDisplay* display; + parent->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); + if (display->mDisplay == NS_STYLE_DISPLAY_BLOCK) { + mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + } + break; + } + parent->GetParent(&parent); } // see if the displaystyle attribute is there and let it override what we inherited @@ -403,7 +410,7 @@ nsMathMLmtableOuterFrame::Reflow(nsIPresContext* aPresContext, aPresContext->GetMetricsFor(font->mFont, getter_AddRefs(fm)); nscoord axisHeight; - nsMathMLContainerFrame::GetAxisHeight(*aReflowState.rendContext, fm, axisHeight); + GetAxisHeight(*aReflowState.rendContext, fm, axisHeight); aDesiredSize.ascent = aDesiredSize.height/2 + axisHeight; aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent; @@ -471,18 +478,29 @@ nsMathMLmtdInnerFrame::Init(nsIPresContext* aPresContext, // to increment with other values, it will do so in its SetInitialChildList() method. nsIFrame* parent = aParent; while (parent) { - nsIMathMLFrame* mathMLFrame = nsnull; - nsresult res = parent->QueryInterface( - NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (NS_SUCCEEDED(res) && mathMLFrame) { + nsIMathMLFrame* mathMLFrame; + parent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { nsPresentationData parentData; mathMLFrame->GetPresentationData(parentData); mPresentationData.mstyle = parentData.mstyle; mPresentationData.scriptLevel = parentData.scriptLevel; - if (NS_MATHML_IS_DISPLAYSTYLE(parentData.flags)) + if (NS_MATHML_IS_DISPLAYSTYLE(parentData.flags)) { mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; - else - mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE; + } + break; + } + // stop if we reach the root tag + nsCOMPtr parentTag; + nsCOMPtr parentContent; + parent->GetContent(getter_AddRefs(parentContent)); + parentContent->GetTag(*getter_AddRefs(parentTag)); + if (parentTag.get() == nsMathMLAtoms::math) { + const nsStyleDisplay* display; + parent->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); + if (display->mDisplay == NS_STYLE_DISPLAY_BLOCK) { + mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + } break; } parent->GetParent(&parent);