From 2ff8bf1765b05ce29fbd0cdc83ef458244fa008c Mon Sep 17 00:00:00 2001 From: "rbs%maths.uq.edu.au" Date: Sat, 2 Feb 2002 05:43:03 +0000 Subject: [PATCH] Continuing to factor handlers to rebuild automatic data during dynamic changes git-svn-id: svn://10.0.0.236/trunk@113515 18797224-902f-48f8-a5cc-f745e15eee43 --- .../base/src/nsMathMLContainerFrame.cpp | 4 +-- .../layout/mathml/base/src/nsMathMLFrame.cpp | 2 +- .../mathml/base/src/nsMathMLmiFrame.cpp | 31 ++++--------------- .../layout/mathml/base/src/nsMathMLmiFrame.h | 17 +++------- .../mathml/base/src/nsMathMLmoFrame.cpp | 14 +++------ .../layout/mathml/base/src/nsMathMLmoFrame.h | 8 ++--- .../mathml/base/src/nsMathMLmpaddedFrame.cpp | 12 +++---- .../mathml/base/src/nsMathMLmpaddedFrame.h | 7 ++--- .../mathml/base/src/nsMathMLmstyleFrame.cpp | 23 +++----------- 9 files changed, 32 insertions(+), 86 deletions(-) diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp index 2bd41671e41..54a2966ffd2 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -898,8 +898,8 @@ nsMathMLContainerFrame::SetInitialChildList(nsIPresContext* aPresContext, } // There are precise rules governing children of a MathML frame, -// and properties such as the scriptlevel or depends on those rules. -// Hence for things to work, caller must use Append/Insert/etc wisely. +// and properties such as the scriptlevel depends on those rules. +// Hence for things to work, callers must use Append/Insert/etc wisely. nsresult nsMathMLContainerFrame::ChildListChanged(nsIPresContext* aPresContext, diff --git a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp index 4b41c61cb13..d5c107ec483 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp @@ -32,8 +32,8 @@ nsMathMLFrame::InheritAutomaticData(nsIPresContext* aPresContext, mPresentationData.flags = 0; mPresentationData.mstyle = nsnull; mPresentationData.scriptLevel = 0; - mEmbellishData.flags = 0; + mEmbellishData.flags = 0; mEmbellishData.nextFrame = nsnull; mEmbellishData.coreFrame = nsnull; mEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED; diff --git a/mozilla/layout/mathml/base/src/nsMathMLmiFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmiFrame.cpp index fc7bfcce02d..70008af9d05 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmiFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmiFrame.cpp @@ -67,22 +67,6 @@ nsMathMLmiFrame::~nsMathMLmiFrame() { } -NS_IMETHODIMP -nsMathMLmiFrame::Init(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParent, - nsIStyleContext* aContext, - nsIFrame* aPrevInFlow) -{ - nsresult rv = NS_OK; - rv = nsMathMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); - -#if defined(NS_DEBUG) && defined(SHOW_BOUNDING_BOX) - mPresentationData.flags |= NS_MATHML_SHOW_BOUNDING_METRICS; -#endif - return rv; -} - static PRBool IsStyleInvariant(PRUnichar aChar) { @@ -91,14 +75,11 @@ IsStyleInvariant(PRUnichar aChar) // if our content is not a single character, we turn the font to normal NS_IMETHODIMP -nsMathMLmiFrame::SetInitialChildList(nsIPresContext* aPresContext, - nsIAtom* aListName, - nsIFrame* aChildList) +nsMathMLmiFrame::TransmitAutomaticData(nsIPresContext* aPresContext) { - nsresult rv; - - // First, let the base class do its work - rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); +#if defined(NS_DEBUG) && defined(SHOW_BOUNDING_BOX) + mPresentationData.flags |= NS_MATHML_SHOW_BOUNDING_METRICS; +#endif // Get the text content that we enclose and its length // our content can include comment-nodes, attribute-nodes, text-nodes... @@ -138,7 +119,7 @@ nsMathMLmiFrame::SetInitialChildList(nsIPresContext* aPresContext, nsMathMLAtoms::fontstyle_, fontstyle)) { if (fontstyle.Equals(NS_LITERAL_STRING("italic"))) - return rv; + return NS_OK; } } @@ -161,7 +142,7 @@ nsMathMLmiFrame::SetInitialChildList(nsIPresContext* aPresContext, } } } - return rv; + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/layout/mathml/base/src/nsMathMLmiFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmiFrame.h index 2a49ac9d078..3ecac6a8923 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmiFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmiFrame.h @@ -33,22 +33,13 @@ class nsMathMLmiFrame : public nsMathMLContainerFrame { public: friend nsresult NS_NewMathMLmiFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); - - NS_IMETHOD - Init(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParent, - nsIStyleContext* aContext, - nsIFrame* aPrevInFlow); - /* mi implements its own SetInitialChildList() method - * to switch to a normal-font (rather than italics) if its text - * content is not a single character (as per the MathML REC). + /* needs to switch to a normal-font (rather than italics) if + * its text content is not a single character (as per the MathML REC). + * special care is also needed for style-invariant chars - bug 65951 */ NS_IMETHOD - SetInitialChildList(nsIPresContext* aPresContext, - nsIAtom* aListName, - nsIFrame* aChildList); + TransmitAutomaticData(nsIPresContext* aPresContext); NS_IMETHOD Reflow(nsIPresContext* aPresContext, diff --git a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp index 80c9b78f4f4..aa776118e4d 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.cpp @@ -185,19 +185,15 @@ nsMathMLmoFrame::Init(nsIPresContext* aPresContext, mFlags |= NS_MATHML_OPERATOR_MUTABLE; } -#if defined(NS_DEBUG) && defined(SHOW_BOUNDING_BOX) - mPresentationData.flags |= NS_MATHML_SHOW_BOUNDING_METRICS; -#endif return rv; } NS_IMETHODIMP -nsMathMLmoFrame::SetInitialChildList(nsIPresContext* aPresContext, - nsIAtom* aListName, - nsIFrame* aChildList) +nsMathMLmoFrame::TransmitAutomaticData(nsIPresContext* aPresContext) { - nsresult rv; - rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); +#if defined(NS_DEBUG) && defined(SHOW_BOUNDING_BOX) + mPresentationData.flags |= NS_MATHML_SHOW_BOUNDING_METRICS; +#endif // fill our mEmbellishData member variable nsIFrame* firstChild = mFrames.FirstChild(); @@ -276,7 +272,7 @@ nsMathMLmoFrame::SetInitialChildList(nsIPresContext* aPresContext, } } } - return rv; + return NS_OK; } void diff --git a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.h index 7705f61b003..1f08620cc03 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmoFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmoFrame.h @@ -49,11 +49,6 @@ public: nsIStyleContext* aContext, nsIFrame* aPrevInFlow); - NS_IMETHOD - SetInitialChildList(nsIPresContext* aPresContext, - nsIAtom* aListName, - nsIFrame* aChildList); - NS_IMETHOD Paint(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext, @@ -73,6 +68,9 @@ public: PRBool aPlaceOrigin, nsHTMLReflowMetrics& aDesiredSize); + NS_IMETHOD + TransmitAutomaticData(nsIPresContext* aPresContext); + // This method is called by the parent frame to ask // to stretch itself. NS_IMETHOD diff --git a/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.cpp index bc1501cfd4f..1ff20fecd5f 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.cpp @@ -82,13 +82,11 @@ nsMathMLmpaddedFrame::~nsMathMLmpaddedFrame() } NS_IMETHODIMP -nsMathMLmpaddedFrame::Init(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParent, - nsIStyleContext* aContext, - nsIFrame* aPrevInFlow) +nsMathMLmpaddedFrame::InheritAutomaticData(nsIPresContext* aPresContext, + nsIFrame* aParent) { - nsresult rv = nsMathMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); + // let the base class get the default from our parent + nsMathMLContainerFrame::InheritAutomaticData(aPresContext, aParent); /* parse the attributes @@ -138,7 +136,7 @@ nsMathMLmpaddedFrame::Init(nsIPresContext* aPresContext, ParseAttribute(value, mLeftSpaceSign, mLeftSpace, mLeftSpacePseudoUnit); } - return rv; + return NS_OK; } PRBool diff --git a/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.h index 6b24c3517c3..5249d64cab9 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmpaddedFrame.h @@ -35,11 +35,8 @@ public: friend nsresult NS_NewMathMLmpaddedFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame); NS_IMETHOD - Init(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParent, - nsIStyleContext* aContext, - nsIFrame* aPrevInFlow); + InheritAutomaticData(nsIPresContext* aPresContext, + nsIFrame* aParent); NS_IMETHOD TransmitAutomaticData(nsIPresContext* aPresContext) diff --git a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp index b8605794c3b..9f89570b059 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp @@ -118,30 +118,15 @@ nsMathMLmstyleFrame::InheritAutomaticData(nsIPresContext* aPresContext, return NS_OK; } -// mstyle needs special care for its scriptlevel and displaystyle attributes NS_IMETHODIMP nsMathMLmstyleFrame::TransmitAutomaticData(nsIPresContext* aPresContext) { mEmbellishData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY; - // figure out our current presentation data - nsPresentationData oldData = mPresentationData; - - InheritAutomaticData(aPresContext, mParent); - - // propagate to our children if something changed - if (oldData.flags != mPresentationData.flags || - oldData.scriptLevel != mPresentationData.scriptLevel) { - PRUint32 whichFlags = NS_MATHML_DISPLAYSTYLE; - PRUint32 newValues = NS_MATHML_DISPLAYSTYLE & mPresentationData.flags; - if (newValues == (oldData.flags & NS_MATHML_DISPLAYSTYLE)) { - newValues = 0; - whichFlags = 0; - } - // use the base method here because we really want to reflect any updates - nsMathMLContainerFrame::UpdatePresentationDataFromChildAt(aPresContext, 0, -1, - mPresentationData.scriptLevel - oldData.scriptLevel, newValues, whichFlags); - } + // Nothing particular to do here, the values that we computed in + // InheritAutomaticData() are the values that we wanted to pass to + // our children. Our children would have inherited these values in + // their own InheritAutomaticData() as we descended the frame tree. return NS_OK; }