Back to index

lightning-sunbird  0.9+nobinonly
nsMathMLForeignFrameWrapper.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is Mozilla MathML Project.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * The University Of Queensland.
00018  * Portions created by the Initial Developer are Copyright (C) 1999
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Roger B. Sidje <rbs@maths.uq.edu.au>
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 //
00039 // a helper frame class to wrap non-MathML frames so that foreign elements 
00040 // (e.g., html:img) can mix better with other surrounding MathML markups
00041 //
00042 
00043 #ifndef nsMathMLForeignFrameWrapper_h___
00044 #define nsMathMLForeignFrameWrapper_h___
00045 
00046 #include "nsCOMPtr.h"
00047 #include "nsMathMLContainerFrame.h"
00048 
00049 class nsMathMLForeignFrameWrapper : public nsBlockFrame,
00050                                     public nsMathMLFrame {
00051 public:
00052   friend nsresult NS_NewMathMLForeignFrameWrapper(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
00053 
00054   NS_DECL_ISUPPORTS_INHERITED
00055 
00056   // Overloaded nsIMathMLFrame methods
00057 
00058   NS_IMETHOD
00059   UpdatePresentationDataFromChildAt(PRInt32         aFirstIndex,
00060                                     PRInt32         aLastIndex,
00061                                     PRInt32         aScriptLevelIncrement,
00062                                     PRUint32        aFlagsValues,
00063                                     PRUint32        aFlagsToUpdate)
00064   {
00065     nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(this,
00066       aFirstIndex, aLastIndex, aScriptLevelIncrement, aFlagsValues, aFlagsToUpdate);
00067     return NS_OK;
00068   }
00069 
00070   NS_IMETHOD
00071   ReResolveScriptStyle(PRInt32 aParentScriptLevel)
00072   {
00073     nsMathMLContainerFrame::PropagateScriptStyleFor(this, aParentScriptLevel);
00074     return NS_OK;
00075   }
00076 
00077   // overloaded nsBlockFrame methods
00078 
00079   NS_IMETHOD
00080   Init(nsPresContext*  aPresContext,
00081        nsIContent*      aContent,
00082        nsIFrame*        aParent,
00083        nsStyleContext*  aContext,
00084        nsIFrame*        aPrevInFlow);
00085 
00086 #ifdef NS_DEBUG
00087   NS_IMETHOD
00088   SetInitialChildList(nsPresContext* aPresContext,
00089                       nsIAtom*        aListName,
00090                       nsIFrame*       aChildList)
00091   {
00092     nsresult rv = nsBlockFrame::SetInitialChildList(aPresContext, aListName, aChildList);
00093     // cannot use mFrames{.FirstChild()|.etc} since the block code doesn't set mFrames
00094     nsFrameList frameList(aChildList);
00095     NS_ASSERTION(frameList.FirstChild() && frameList.GetLength() == 1,
00096                  "there must be one and only one child frame");
00097     return rv;
00098   }
00099 #endif
00100 
00101   NS_IMETHOD
00102   Reflow(nsPresContext*          aPresContext,
00103          nsHTMLReflowMetrics&     aDesiredSize,
00104          const nsHTMLReflowState& aReflowState,
00105          nsReflowStatus&          aStatus);
00106 
00107   // we are just a wrapper and these methods shouldn't be called
00108   NS_IMETHOD
00109   AppendFrames(nsIAtom*        aListName,
00110                nsIFrame*       aFrameList)
00111   {
00112     NS_NOTREACHED("unsupported operation");
00113     return NS_ERROR_NOT_IMPLEMENTED;
00114   }
00115 
00116   NS_IMETHOD
00117   InsertFrames(nsIAtom*        aListName,
00118                nsIFrame*       aPrevFrame,
00119                nsIFrame*       aFrameList)
00120   {
00121     NS_NOTREACHED("unsupported operation");
00122     return NS_ERROR_NOT_IMPLEMENTED;
00123   }
00124 
00125   // need special care here because the base class implementation treats this
00126   // as two operations: remove & insert; In our case, removing the child will
00127   // remove us too... so we have to operate from our parent's perspective
00128   NS_IMETHOD
00129   ReplaceFrame(nsIAtom*        aListName,
00130                nsIFrame*       aOldFrame,
00131                nsIFrame*       aNewFrame)
00132   {
00133     nsresult rv = mParent->ReplaceFrame(aListName, this, aNewFrame);
00134     // XXX the usage of ReplaceFrame() vs. ReplaceFrameAndDestroy() is
00135     // XXX ambiguous - see bug 122748. The style system doesn't call ReplaceFrame()
00136     // XXX and that's why nobody seems to have been biten by the ambiguity yet
00137     aOldFrame->Destroy(GetPresContext());
00138     return rv;
00139   }
00140 
00141   // Our life is bound to the life of our unique child.
00142   // When our child goes away, we ask our parent to delete us
00143   NS_IMETHOD
00144   RemoveFrame(nsIAtom*        aListName,
00145               nsIFrame*       aOldFrame)
00146   {
00147     return mParent->RemoveFrame(aListName, this);
00148   }
00149 
00150 protected:
00151   nsMathMLForeignFrameWrapper() {}
00152   virtual ~nsMathMLForeignFrameWrapper() {}
00153 };
00154 
00155 #endif /* nsMathMLForeignFrameWrapper_h___ */