From e1737fe5319da490ce76b27578ee6aa0fa236b11 Mon Sep 17 00:00:00 2001 From: "rbs%maths.uq.edu.au" Date: Sat, 2 Oct 1999 06:20:30 +0000 Subject: [PATCH] Update to match recent changes in the nsIFrame API. git-svn-id: svn://10.0.0.236/trunk@49657 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/mathml/base/src/Makefile.in | 1 + mozilla/layout/mathml/base/src/makefile.win | 1 + .../layout/mathml/base/src/nsIMathMLFrame.h | 12 +- mozilla/layout/mathml/base/src/nsMathMLChar.h | 2 +- .../base/src/nsMathMLContainerFrame.cpp | 156 ++++++++++-------- .../mathml/base/src/nsMathMLContainerFrame.h | 42 ++--- .../layout/mathml/base/src/nsMathMLParts.h | 4 + .../mathml/base/src/nsMathMLmfracFrame.cpp | 4 +- .../mathml/base/src/nsMathMLmfracFrame.h | 2 +- .../mathml/base/src/nsMathMLmiFrame.cpp | 83 ++++++---- .../layout/mathml/base/src/nsMathMLmiFrame.h | 16 +- .../base/src/nsMathMLmmultiscriptsFrame.h | 2 +- .../mathml/base/src/nsMathMLmoverFrame.h | 2 +- .../mathml/base/src/nsMathMLmrowFrame.h | 13 -- .../mathml/base/src/nsMathMLmstyleFrame.cpp | 11 +- .../mathml/base/src/nsMathMLmstyleFrame.h | 3 +- .../mathml/base/src/nsMathMLmsubFrame.h | 2 +- .../mathml/base/src/nsMathMLmsubsupFrame.h | 2 +- .../mathml/base/src/nsMathMLmsupFrame.h | 2 +- .../mathml/base/src/nsMathMLmunderFrame.h | 2 +- .../mathml/base/src/nsMathMLmunderoverFrame.h | 2 +- 21 files changed, 179 insertions(+), 185 deletions(-) diff --git a/mozilla/layout/mathml/base/src/Makefile.in b/mozilla/layout/mathml/base/src/Makefile.in index dacdeb4e277..0fb729acbd3 100644 --- a/mozilla/layout/mathml/base/src/Makefile.in +++ b/mozilla/layout/mathml/base/src/Makefile.in @@ -31,6 +31,7 @@ LIBRARY_NAME = raptormathmlbase_s LOCAL_INCLUDES = \ -I$(srcdir)/../../../base/src \ + -I$(srcdir)/../../../base/public \ -I$(srcdir)/../../../html/style/src \ -I$(srcdir)/../../../html/base/src \ -I$(srcdir)/../../../html/content/src \ diff --git a/mozilla/layout/mathml/base/src/makefile.win b/mozilla/layout/mathml/base/src/makefile.win index d9208ba8434..1583cc2cff1 100644 --- a/mozilla/layout/mathml/base/src/makefile.win +++ b/mozilla/layout/mathml/base/src/makefile.win @@ -78,6 +78,7 @@ LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \ -I..\..\..\html\table\src \ -I$(PUBLIC)\dom \ -I..\..\content\src \ + -I..\..\..\base\public \ -I$(PUBLIC)\netlib -I..\..\..\base\src -I$(PUBLIC)\pref LCFLAGS = \ diff --git a/mozilla/layout/mathml/base/src/nsIMathMLFrame.h b/mozilla/layout/mathml/base/src/nsIMathMLFrame.h index a9c001524ea..a2d2b8f1aa5 100644 --- a/mozilla/layout/mathml/base/src/nsIMathMLFrame.h +++ b/mozilla/layout/mathml/base/src/nsIMathMLFrame.h @@ -37,10 +37,10 @@ public: /* SUPPORT FOR STRETCHY ELEMENTS: */ /*====================================================================*/ - /* method used to ask a stretchy MathML frame to stretch + /* Stretch : + * method used to ask a stretchy MathML frame to stretch * itself depending on its context */ - NS_IMETHOD Stretch(nsIPresContext& aPresContext, nsStretchDirection aStretchDirection, @@ -52,13 +52,14 @@ public: /*====================================================================*/ /* GetPresentationData : - /* returns the scriptlevel and displaystyle of the frame */ + * returns the scriptlevel and displaystyle of the frame + */ NS_IMETHOD GetPresentationData(PRInt32* aScriptLevel, PRBool* aDisplayStyle) = 0; /* UpdatePresentationData : - /* Increment the scriptlevel of the frame, and set its displaystyle. + * Increments the scriptlevel of the frame, and set its displaystyle. * Note that is the only tag which allows to set * * Therefore has its peculiar version of this method. @@ -67,9 +68,8 @@ public: UpdatePresentationData(PRInt32 aScriptLevelIncrement, PRBool aDisplayStyle) = 0; - /* UpdatePresentationDataFromChildAt : - /* Increments the scriplevel and set the display level on the whole tree. + * Increments the scriplevel and set the display level on the whole tree. * For child frames at: aIndex, aIndex+1, aIndex+2, etc, this method set * their mDisplayStyle to aDisplayStyle and increment their mScriptLevel * with aScriptLevelIncrement. The increment is propagated down to the diff --git a/mozilla/layout/mathml/base/src/nsMathMLChar.h b/mozilla/layout/mathml/base/src/nsMathMLChar.h index 3efb94ca947..b8cb048a4cd 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLChar.h +++ b/mozilla/layout/mathml/base/src/nsMathMLChar.h @@ -73,7 +73,7 @@ public: { } - ~nsMathMLChar() + virtual ~nsMathMLChar() { } diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp index 9f15d884f55..6593464b4ef 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -111,6 +111,8 @@ nsMathMLContainerFrame::IsOnlyWhitespace(nsIFrame* aFrame) // by empty frame we mean a leaf frame whose text content is empty... nsCOMPtr aContent; aFrame->GetContent(getter_AddRefs(aContent)); + if (nsnull == aContent) + return PR_TRUE; PRInt32 numKids; aContent->ChildCount(numKids); if (0 == numKids) { @@ -146,7 +148,7 @@ nsMathMLContainerFrame::ReflowEmptyChild(nsIFrame* aFrame) * munderover, mmultiscripts, mfrac, mroot, mtable). * ============================================================================= */ - + NS_IMETHODIMP nsMathMLContainerFrame::Stretch(nsIPresContext& aPresContext, nsStretchDirection aStretchDirection, @@ -199,6 +201,90 @@ nsMathMLContainerFrame::UpdatePresentationDataFromChildAt(PRInt32 aIndex, return NS_OK; } +// helper method to alter the style context +// This method is used for switching the font to a subscript/superscript font in +// mfrac, msub, msup, msubsup, munder, mover, munderover, mmultiscripts + +NS_IMETHODIMP +nsMathMLContainerFrame::InsertScriptLevelStyleContext(nsIPresContext& aPresContext) +{ + nsresult rv = NS_OK; + nsIFrame* nextFrame = mFrames.FirstChild(); + while (nsnull != nextFrame && NS_SUCCEEDED(rv)) { + nsIFrame* childFrame = nextFrame; + rv = nextFrame->GetNextSibling(&nextFrame); + if (!IsOnlyWhitespace(childFrame) && NS_SUCCEEDED(rv)) { + + // see if the child frame implements the nsIMathMLFrame interface + nsIMathMLFrame* aMathMLFrame; + rv = childFrame->QueryInterface(nsIMathMLFrame::GetIID(), (void**)&aMathMLFrame); + if (nsnull != aMathMLFrame && NS_SUCCEEDED(rv)) { + + // get the scriptlevel of the child + PRInt32 childLevel; + PRBool childDisplayStyle; + aMathMLFrame->GetPresentationData(&childLevel, &childDisplayStyle); + + // Iteration to set a style context for the script level font. + // Wow, here is what is happening: the style system requires that any style context + // *must* be uniquely associated to a frame. So we insert as many frames as needed + // to scale-down (or scale-up) the fontsize. + + PRInt32 gap = childLevel - mScriptLevel; + if (0 != gap) { + nsCOMPtr childContent; + childFrame->GetContent(getter_AddRefs(childContent)); + + nsIFrame* firstFrame = nsnull; + nsIFrame* lastFrame = this; + nsIStyleContext* lastStyleContext = mStyleContext; + nsCOMPtr newStyleContext; + + nsAutoString fontSize = (0 < gap) + ? ":-moz-math-font-size-smaller" + : ":-moz-math-font-size-larger"; + nsCOMPtr fontAtom(getter_AddRefs(NS_NewAtom(fontSize))); + if (0 > gap) gap = -gap; // absolute value + while (0 < gap--) { + + aPresContext.ResolvePseudoStyleContextFor(childContent, fontAtom, lastStyleContext, + PR_FALSE, getter_AddRefs(newStyleContext)); + if (nsnull == newStyleContext || lastStyleContext == newStyleContext) { + break; + } + else { + // create a new frame and append it as sole child of the last created frame + nsIFrame* newFrame = nsnull; + NS_NewMathMLContainerFrame(&newFrame); + NS_ASSERTION(newFrame, "Failed to create new frame"); + + newFrame->Init(aPresContext, childContent, lastFrame, newStyleContext, nsnull); + + if (nsnull == firstFrame) { + firstFrame = newFrame; + } + if (this != lastFrame) { + lastFrame->SetInitialChildList(aPresContext, nsnull, newFrame); + } + lastStyleContext = newStyleContext; + lastFrame = newFrame; + } + } + if (nsnull != firstFrame) { // at least one new frame was created + mFrames.ReplaceFrame(this, childFrame, firstFrame); + lastFrame->SetInitialChildList(aPresContext, nsnull, childFrame); + childFrame->SetParent(lastFrame); + childFrame->SetNextSibling(nsnull); + aPresContext.ReParentStyleContext(childFrame, lastStyleContext); + } + } + } + } + } + return rv; +} + + /* ////////////////// * Frame construction * ============================================================================= @@ -327,7 +413,7 @@ nsMathMLContainerFrame::Reflow(nsIPresContext& aPresContext, NS_ASSERTION(NS_SUCCEEDED(rv),"failed to get next child"); } aDesiredSize.height = aDesiredSize.ascent + aDesiredSize.descent; - + ///////////// // Place Children now by re-adjusting the origins to align the baselines @@ -350,69 +436,3 @@ nsMathMLContainerFrame::Reflow(nsIPresContext& aPresContext, aStatus = NS_FRAME_COMPLETE; return NS_OK; } - -// This method is an implementation of nsIFrame::ReResolveStyleContext -// It is used for switching the font to a subscript/superscript font in -// msub, msup, msubsup, munder, mover, munderover, mmultiscripts - -NS_IMETHODIMP -nsMathMLContainerFrame::ReResolveStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - PRInt32 aParentChange, - nsStyleChangeList* aChangeList, - PRInt32* aLocalChange) -{ - // re calculate our own style context - PRInt32 ourChange = aParentChange; - nsresult rv = nsFrame::ReResolveStyleContext(aPresContext, aParentContext, - ourChange, aChangeList, &ourChange); - if (NS_FAILED(rv)) { - return rv; - } - if (aLocalChange) { - *aLocalChange = ourChange; - } - - // re-resolve children - - nsIFrame* child = mFrames.FirstChild(); - while (nsnull != child && NS_SUCCEEDED(rv)) { - - if (!IsOnlyWhitespace(child)) { - - // default is to inherit the parent style - nsIStyleContext* aStyleContext = mStyleContext; - nsIStyleContext* newStyleContext = mStyleContext; - - // see if the child frame implements the nsIMathMLFrame interface - nsIMathMLFrame* aMathMLFrame; - rv = child->QueryInterface(nsIMathMLFrame::GetIID(), (void**)&aMathMLFrame); - if (NS_SUCCEEDED(rv) && nsnull != aMathMLFrame) { - - // get the scriptlevel of the child - PRInt32 childLevel; - PRBool childDisplayStyle; - aMathMLFrame->GetPresentationData(&childLevel, &childDisplayStyle); - - // iteration to get a pseudo style context for the script level font - nsAutoString fontSize; - PRInt32 gap = childLevel - mScriptLevel; - fontSize = (0 < gap)? ":-moz-math-font-size-smaller" : ":-moz-math-font-size-larger"; - nsCOMPtr fontAtom(getter_AddRefs(NS_NewAtom(fontSize))); - if (0 > gap) gap = -gap; // absolute value - while (0 < gap) { - aPresContext->ResolvePseudoStyleContextFor(mContent, fontAtom, aStyleContext, - PR_FALSE, &newStyleContext); - aStyleContext = newStyleContext; - gap--; - } - } - - PRInt32 childChange; - rv = child->ReResolveStyleContext(aPresContext, newStyleContext, - ourChange, aChangeList, &childChange); - } - child->GetNextSibling(&child); - } - return rv; -} diff --git a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h index 340d713bbb7..074ff4b1487 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLContainerFrame.h @@ -34,43 +34,23 @@ * mrow. By default, this frame uses its Reflow() method to lay its * children horizontally and ensure that their baselines are aligned. * - * This frame is a *math-aware frame* in the sense that given the - * markup base arguments, the method ReResolveStyleContext() + * This frame is a *math-aware frame* in the sense that given the markup + * base arguments, the method InsertScriptLevelStyleContext() * can be used to render the 'base' in normal-font, and the 'arguments' * in small-font. This is a common functionality to tags like msub, msup, * msubsup, mover, munder, munderover, mmultiscripts. All are derived * from this base class. They use SetInitialChildList() to trigger - * ReResolveStyleContext() for the very first time as soon as all their - * children are known. However, each of these tags has its own Reflow() + * InsertScriptLevelStyleContext() for the very first time as soon as all + * their children are known. However, each of these tags has its own Reflow() * method to lay its children as appropriate, thus overriding the default * Reflow() method in this base class. * * Other tags like mi that do not have 'arguments' can be derived from * this base class as well. The class caters for empty arguments. - * Notice that mi implements its own ReResolveStyleContext() method + * Notice that 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). * - * In general therefore, to derive other tags from this base class, - * ReResolveStyleContext() must be coded to produce the desired stylistic - * effects. For example, mfrac has its own ReResolveStyleContext() method - * to set both the numerator and denominator to a small font size, whereas - * mrow does not have its own implementation of ReResolveStyleContext(), - * and instead uses the one in the base class nsHTMLContainerFrame. - * - * The advantage provided by the default ReResolveStyleContext() herein is - * that MathML tags that need scriptstyle switching can be derived from this - * base class with minimum footprint. For the few tags that need different - * style switching or that do not need style switching at all, you *should* - * override the default ReResolveStyleContext() method provided in this base. - * Do not use this nsMathMLContainerFrame::ReResolveStyleContext for a - * base arguments not needing 'arguments' in small font size. - * Instead, you should use nsHTMLContainerFrame::ReResolveStyleContext or - * provide your own. - * - * ReResolveStyleContext() implements nsIFrame::ReResolveStyleContext(). - * See the documentation in nsIFrame.h for additional information on the - * frame API. */ class nsMathMLContainerFrame : public nsHTMLContainerFrame, public nsIMathMLFrame { @@ -114,12 +94,10 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); + // helper method for altering the style contexts of subscript/superscript elements + NS_IMETHOD - ReResolveStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - PRInt32 aParentChange, - nsStyleChangeList* aChangeList, - PRInt32* aLocalChange); + InsertScriptLevelStyleContext(nsIPresContext& aPresContext); // helper methods for processing empty MathML frames (with whitespace only) @@ -131,8 +109,8 @@ public: protected: - PRInt32 mScriptLevel; // Only relevant to nested frames within: msub, msup, msubsup, - // munder, mover, munderover, mmultiscripts, mfrac, mroot, mtable. + PRInt32 mScriptLevel; // Relevant to nested frames within: msub, msup, msubsup, munder, + // mover, munderover, mmultiscripts, mfrac, mroot, mtable. PRBool mDisplayStyle; // displaystyle="false" is intended to slightly alter how the // rendering in done in inline mode. diff --git a/mozilla/layout/mathml/base/src/nsMathMLParts.h b/mozilla/layout/mathml/base/src/nsMathMLParts.h index 9d03dcddbcf..e7d797d2f22 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLParts.h +++ b/mozilla/layout/mathml/base/src/nsMathMLParts.h @@ -43,4 +43,8 @@ extern nsresult NS_NewMathMLmmultiscriptsFrame ( nsIFrame** aNewFrame ); extern nsresult NS_NewMathMLmstyleFrame ( nsIFrame** aNewFrame ); extern nsresult NS_NewMathMLmtdFrame ( nsIFrame** aNewFrame ); +inline nsresult NS_NewMathMLContainerFrame( nsIFrame** aNewFrame ) { + return NS_NewMathMLmrowFrame(aNewFrame); +} + #endif /* nsMathMLParts_h___ */ diff --git a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp index c5078646460..cd87a091bf0 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.cpp @@ -114,7 +114,7 @@ nsMathMLmfracFrame::Init(nsIPresContext& aPresContext, mLineOrigin.x = 0; mLineOrigin.y = 0; - // TODO: other attributes like displaystyle... + // TODO: other attributes... return rv; } @@ -183,7 +183,7 @@ nsMathMLmfracFrame::Reflow(nsIPresContext& aPresContext, ////////////// // WHITESPACE: don't forget that whitespace doesn't count in MathML! if (IsOnlyWhitespace(childFrame)) { - childFrame->SetRect(nsRect(0,0,0,0)); + ReflowEmptyChild(childFrame); } else if (2 > count) { diff --git a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.h index 9d8aca8de51..f81cfac3637 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmfracFrame.h @@ -131,7 +131,7 @@ public: nsresult rv; rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); UpdatePresentationDataFromChildAt(0, 1, PR_FALSE); - ReResolveStyleContext(&aPresContext, mStyleContext, NS_STYLE_HINT_REFLOW, nsnull, nsnull); + InsertScriptLevelStyleContext(aPresContext); return rv; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmiFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmiFrame.cpp index 1fc6c459abd..6ff893daa6f 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmiFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmiFrame.cpp @@ -72,6 +72,7 @@ nsMathMLmiFrame::~nsMathMLmiFrame() { } + NS_IMETHODIMP nsMathMLmiFrame::Init(nsIPresContext& aPresContext, nsIContent* aContent, @@ -81,19 +82,25 @@ nsMathMLmiFrame::Init(nsIPresContext& aPresContext, { nsresult rv = NS_OK; rv = nsMathMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); - return rv; } - -// if our content is not a single character, we turn the font style to normal. -// XXX TrimWhitespace / CompressWhitespace? + +// if our content is a single character, we turn the font to italic +// if our content is not a single character, we turn the font to normal +// XXX TrimWhitespace / CompressWhitespace? + NS_IMETHODIMP -nsMathMLmiFrame::ReResolveStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - PRInt32 aParentChange, - nsStyleChangeList* aChangeList, - PRInt32* aLocalChange) +nsMathMLmiFrame::SetInitialChildList(nsIPresContext& aPresContext, + nsIAtom* aListName, + nsIFrame* aChildList) { + nsresult rv; + + // First, let the base class to its work + rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); + + + // Get the length of the text content that we enclose // our content can include comment-nodes, attribute-nodes, text-nodes... // we use to DOM to make sure that we are only looking at text-nodes... PRInt32 aLength = 0; @@ -116,33 +123,39 @@ nsMathMLmiFrame::ReResolveStyleContext(nsIPresContext* aPresContext, } } - // re calculate our own style context - PRInt32 ourChange = aParentChange; - nsresult rv = nsFrame::ReResolveStyleContext(aPresContext, aParentContext, - ourChange, aChangeList, &ourChange); - if (NS_FAILED(rv)) { - return rv; - } - if (aLocalChange) { - *aLocalChange = ourChange; + // Insert a new pseudo frame between our children and us, i.e., the new frame + // becomes our sole child, and our children become children of the new frame. + + // Get a pseudo style context for the appropriate style font + // XXX how important is the PseudoStyleContext? + nsAutoString fontStyle = (1 == aLength) + ? ":-moz-math-font-style-italic" + : ":-moz-math-font-style-normal"; + nsCOMPtr fontAtom(getter_AddRefs(NS_NewAtom(fontStyle))); + nsCOMPtr newStyleContext; + aPresContext.ResolvePseudoStyleContextFor(mContent, fontAtom, mStyleContext, + PR_FALSE, getter_AddRefs(newStyleContext)); + + if (nsnull != newStyleContext && mStyleContext != newStyleContext) { + + nsIFrame* newFrame = nsnull; + NS_NewMathMLContainerFrame(&newFrame); + NS_ASSERTION(newFrame, "Failed to create new frame"); + + newFrame->Init(aPresContext, mContent, this, newStyleContext, nsnull); + + // our children become children of the new frame + nsIFrame* childFrame = mFrames.FirstChild(); + newFrame->SetInitialChildList(aPresContext, nsnull, childFrame); + while (nsnull != childFrame) { + childFrame->SetParent(newFrame); + aPresContext.ReParentStyleContext(childFrame, newStyleContext); + childFrame->GetNextSibling(&childFrame); + } + + // the new frame becomes our sole child + mFrames.SetFrames(newFrame); } - // get a pseudo style context for the normal style font - nsCOMPtr fontAtom(getter_AddRefs(NS_NewAtom(":-moz-math-font-style-normal"))); - nsIStyleContext* newStyleContext; - aPresContext->ResolvePseudoStyleContextFor(mContent, fontAtom, mStyleContext, - PR_FALSE, &newStyleContext); - // re-resolve children - PRInt32 childChange; - nsIFrame* child = mFrames.FirstChild(); - while (nsnull != child && NS_SUCCEEDED(rv)) { - if (!IsOnlyWhitespace(child)) { - rv = child->ReResolveStyleContext(aPresContext, - (1 == aLength)? mStyleContext : newStyleContext, - ourChange, aChangeList, &childChange); - } - child->GetNextSibling(&child); - } return rv; } - diff --git a/mozilla/layout/mathml/base/src/nsMathMLmiFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmiFrame.h index 57321aa04f9..98e31a5d947 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmiFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmiFrame.h @@ -41,24 +41,10 @@ public: nsIStyleContext* aContext, nsIFrame* aPrevInFlow); - NS_IMETHOD - ReResolveStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - PRInt32 aParentChange, - nsStyleChangeList* aChangeList, - PRInt32* aLocalChange); - NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, - nsIFrame* aChildList) - { - nsresult rv; - rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); - ReResolveStyleContext(&aPresContext, mStyleContext, NS_STYLE_HINT_REFLOW, nsnull, nsnull); - return rv; - } - + nsIFrame* aChildList); protected: nsMathMLmiFrame(); virtual ~nsMathMLmiFrame(); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.h index cea4898c107..73bbda490ed 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.h @@ -48,7 +48,7 @@ public: nsresult rv; rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); UpdatePresentationDataFromChildAt(1, 1, PR_FALSE); - ReResolveStyleContext(&aPresContext, mStyleContext, NS_STYLE_HINT_REFLOW, nsnull, nsnull); + InsertScriptLevelStyleContext(aPresContext); return rv; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.h index 6321f959476..9e6177868e2 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmoverFrame.h @@ -48,7 +48,7 @@ public: nsresult rv; rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); UpdatePresentationDataFromChildAt(1, 1, PR_FALSE); - ReResolveStyleContext(&aPresContext, mStyleContext, NS_STYLE_HINT_REFLOW, nsnull, nsnull); + InsertScriptLevelStyleContext(aPresContext); return rv; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.h index 8ac1ff70a08..266c38c80c6 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmrowFrame.h @@ -41,19 +41,6 @@ public: nsIStyleContext* aContext, nsIFrame* aPrevInFlow); - // We override the nsMathMLContainerFrame::ReResolveStyleContext() method - // because this container base arguments does not need its - // 'arguments' in a smaller font size that the 'base'. - NS_IMETHOD - ReResolveStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext, - PRInt32 aParentChange, - nsStyleChangeList* aChangeList, - PRInt32* aLocalChange) - { - return nsHTMLContainerFrame::ReResolveStyleContext(aPresContext, aParentContext, aParentChange, aChangeList, aLocalChange); - } - protected: nsMathMLmrowFrame(); virtual ~nsMathMLmrowFrame(); diff --git a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp index 30a6b7a1b49..f6e04b6a3ba 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.cpp @@ -79,6 +79,7 @@ nsMathMLmstyleFrame::Init(nsIPresContext& aPresContext, nsresult rv = nsMathMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); mFlags = 0; + mInnerScriptLevelIncrement = 0; // see if the displaystyle attribute is there nsAutoString value; @@ -105,15 +106,15 @@ nsMathMLmstyleFrame::Init(nsIPresContext& aPresContext, mScriptLevel = aUserValue; // explicit value... } else { - mScriptLevel += aUserValue; // incremental value... +// mScriptLevel += aUserValue; // incremental value... + mInnerScriptLevelIncrement = aUserValue; } } } // TODO: -// Examine all other attributes and update the style context to be -// inherited by all children. +// Examine all other attributes return rv; } @@ -122,7 +123,9 @@ NS_IMETHODIMP nsMathMLmstyleFrame::UpdatePresentationData(PRInt32 aScriptLevelIncrement, PRBool aDisplayStyle) { - // The scriptlevel and displaystyle attributes of mstyle take precedence. + // mstyle is special... + // Since UpdatePresentationData() can be called by a parent frame, the + // scriptlevel and displaystyle attributes of mstyle must take precedence. // Update only if attributes are not there if (!(NS_MATHML_MSTYLE_HAS_DISPLAYSTYLE(mFlags))) { mDisplayStyle = aDisplayStyle; diff --git a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.h index 85aad8f4da8..e76ec0df0cf 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmstyleFrame.h @@ -67,7 +67,8 @@ public: { nsresult rv; rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); - ReResolveStyleContext(&aPresContext, mStyleContext, NS_STYLE_HINT_REFLOW, nsnull, nsnull); + UpdatePresentationDataFromChildAt(0, mInnerScriptLevelIncrement, mDisplayStyle); + InsertScriptLevelStyleContext(aPresContext); return rv; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmsubFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmsubFrame.h index 4067f2f7253..50fd4e0684a 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmsubFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmsubFrame.h @@ -48,7 +48,7 @@ public: nsresult rv; rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); UpdatePresentationDataFromChildAt(1, 1, PR_FALSE); - ReResolveStyleContext(&aPresContext, mStyleContext, NS_STYLE_HINT_REFLOW, nsnull, nsnull); + InsertScriptLevelStyleContext(aPresContext); return rv; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmsubsupFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmsubsupFrame.h index 417b74e5497..c86d021347d 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmsubsupFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmsubsupFrame.h @@ -48,7 +48,7 @@ public: nsresult rv; rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); UpdatePresentationDataFromChildAt(1, 1, PR_FALSE); - ReResolveStyleContext(&aPresContext, mStyleContext, NS_STYLE_HINT_REFLOW, nsnull, nsnull); + InsertScriptLevelStyleContext(aPresContext); return rv; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmsupFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmsupFrame.h index a5f7a059f61..f391288db99 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmsupFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmsupFrame.h @@ -48,7 +48,7 @@ public: nsresult rv; rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); UpdatePresentationDataFromChildAt(1, 1, PR_FALSE); - ReResolveStyleContext(&aPresContext, mStyleContext, NS_STYLE_HINT_REFLOW, nsnull, nsnull); + InsertScriptLevelStyleContext(aPresContext); return rv; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.h index 55305af5ec6..c66138d3ba6 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmunderFrame.h @@ -48,7 +48,7 @@ public: nsresult rv; rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); UpdatePresentationDataFromChildAt(1, 1, PR_FALSE); - ReResolveStyleContext(&aPresContext, mStyleContext, NS_STYLE_HINT_REFLOW, nsnull, nsnull); + InsertScriptLevelStyleContext(aPresContext); return rv; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.h b/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.h index ff1a914d193..490d8ea4d7e 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.h +++ b/mozilla/layout/mathml/base/src/nsMathMLmunderoverFrame.h @@ -48,7 +48,7 @@ public: nsresult rv; rv = nsMathMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); UpdatePresentationDataFromChildAt(1, 1, PR_FALSE); - ReResolveStyleContext(&aPresContext, mStyleContext, NS_STYLE_HINT_REFLOW, nsnull, nsnull); + InsertScriptLevelStyleContext(aPresContext); return rv; }