diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp index 6342a4a7f4b..d8c10585675 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -775,6 +775,41 @@ CompressWhitespace(nsIContent* aContent) } } +/* static */ void +nsMathMLContainerFrame::GetPresentationDataFrom(nsIFrame* aFrame, + nsPresentationData& aPresentationData) +{ + nsIFrame* frame = aFrame; + while (frame) { + nsIMathMLFrame* mathMLFrame; + frame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + if (mathMLFrame) { + nsPresentationData presentationData; + mathMLFrame->GetPresentationData(presentationData); + aPresentationData.mstyle = presentationData.mstyle; + aPresentationData.scriptLevel = presentationData.scriptLevel; + if (NS_MATHML_IS_DISPLAYSTYLE(presentationData.flags)) { + aPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + } + break; + } + // stop if we reach the root tag + nsCOMPtr tag; + nsCOMPtr content; + frame->GetContent(getter_AddRefs(content)); + content->GetTag(*getter_AddRefs(tag)); + if (tag.get() == nsMathMLAtoms::math) { + const nsStyleDisplay* display; + frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); + if (display->mDisplay == NS_STYLE_DISPLAY_BLOCK) { + aPresentationData.flags |= NS_MATHML_DISPLAYSTYLE; + } + break; + } + frame->GetParent(&frame); + } +} + // This method is called in a top-down manner, as we descend the frame tree // during its construction NS_IMETHODIMP @@ -793,39 +828,8 @@ nsMathMLContainerFrame::Init(nsIPresContext* aPresContext, nsresult rv; rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); - // 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. - - 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); - } + // now, inherit the scriptlevel and displaystyle from our parent + GetPresentationDataFrom(aParent, mPresentationData); return rv; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h index 82cd3afaf54..b696ea61bf7 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h @@ -170,6 +170,14 @@ public: // -------------------------------------------------------------------------- // Additional methods + // helper to get the presentation data of a frame. If we happen to + // be surrounded by non-MathML helper frames needed for our support, + // we walk up the frame hierarchy until we reach a MathML frame + // or the math element. + static void + GetPresentationDataFrom(nsIFrame* aFrame, + nsPresentationData& aPresentationData); + // helper to get the preferred size that a container frame should use to fire // the stretch on its stretchy child frames. virtual void diff --git a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp index b576c1c6657..a8e5c2c5dc6 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp @@ -272,32 +272,11 @@ nsMathMLmstyleFrame::AttributeChanged(nsIPresContext* aPresContext, // use the base method here because we really want to reflect any updates nsMathMLContainerFrame::UpdatePresentationDataFromChildAt(aPresContext, 0, -1, mPresentationData.scriptLevel - oldData.scriptLevel, newValues, whichFlags); - // now walk up to our immediate ancestor that implements the - // nsIMathMLFrame interface and grab its scriptlevel - PRInt32 parentScriptLevel = 0; - nsIFrame* parent = mParent; - while (parent) { - // if this frame is MathML frame, we are done - nsIMathMLFrame* mathMLFrame; - parent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); - if (mathMLFrame) { - nsPresentationData parentData; - mathMLFrame->GetPresentationData(parentData); - parentScriptLevel = parentData.scriptLevel; - 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) { - break; - } - parent->GetParent(&parent); - } + // now grab the scriptlevel of our parent + nsPresentationData parentData; + GetPresentationDataFrom(mParent, parentData); // re-resolve style data in our subtree to sync any change of script sizes - PropagateScriptStyleFor(aPresContext, this, parentScriptLevel); + PropagateScriptStyleFor(aPresContext, this, parentData.scriptLevel); } } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp index 02c66cbb97a..95030011658 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp @@ -283,41 +283,10 @@ nsMathMLmtableOuterFrame::Init(nsIPresContext* aPresContext, { nsresult rv = nsTableOuterFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); - // now, if our parent implements the nsIMathMLFrame interface, we inherit - // its scriptlevel and displaystyle. If the parent later wishes to increment - // with other values, it will do so in its SetInitialChildList() method. - // XXX the REC says that by default, displaystyle=false in - 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); - } + // now, inherit the scriptlevel and displaystyle from our parent + nsMathMLContainerFrame::GetPresentationDataFrom(aParent, mPresentationData); // see if the displaystyle attribute is there and let it override what we inherited nsAutoString value; @@ -474,38 +443,8 @@ nsMathMLmtdInnerFrame::Init(nsIPresContext* aPresContext, // record that children that are ignorable whitespace should be excluded mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE; - // now, get our outermost parent that implements the nsIMathMLFrame interface, - // we will inherit its scriptlevel and displaystyle. If that parent later wishes - // to increment with other values, it will do so in its SetInitialChildList() method. - 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); - } + // now, inherit the scriptlevel and displaystyle from our parent + nsMathMLContainerFrame::GetPresentationDataFrom(aParent, mPresentationData); return rv; }