Back to index

lightning-sunbird  0.9+nobinonly
nsHTMLContainerFrame.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
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 #ifndef nsHTMLContainerFrame_h___
00038 #define nsHTMLContainerFrame_h___
00039 
00040 #include "nsContainerFrame.h"
00041 class nsString;
00042 class nsAbsoluteFrame;
00043 class nsPlaceholderFrame;
00044 struct nsStyleDisplay;
00045 struct nsStylePosition;
00046 struct nsHTMLReflowMetrics;
00047 struct nsHTMLReflowState;
00048 
00049 // Some macros for container classes to do sanity checking on
00050 // width/height/x/y values computed during reflow.
00051 #ifdef DEBUG
00052 #define CRAZY_W 500000
00053 
00054 // 100000 lines, approximately. Assumes p2t is 15 and 15 pixels per line
00055 #define CRAZY_H 22500000
00056 
00057 #define CRAZY_WIDTH(_x) (((_x) < -CRAZY_W) || ((_x) > CRAZY_W))
00058 #define CRAZY_HEIGHT(_y) (((_y) < -CRAZY_H) || ((_y) > CRAZY_H))
00059 #endif
00060 
00061 // Base class for html container frames that provides common
00062 // functionality.
00063 class nsHTMLContainerFrame : public nsContainerFrame {
00064 public:
00065   NS_IMETHOD  Paint(nsPresContext*      aPresContext,
00066                     nsIRenderingContext& aRenderingContext,
00067                     const nsRect&        aDirtyRect,
00068                     nsFramePaintLayer    aWhichLayer,
00069                     PRUint32             aFlags = 0);
00070 
00080   static nsresult CreateNextInFlow(nsPresContext* aPresContext,
00081                                    nsIFrame*       aOuterFrame,
00082                                    nsIFrame*       aFrame,
00083                                    nsIFrame*&      aNextInFlowResult);
00084 
00095   static nsresult CreateViewForFrame(nsIFrame* aFrame,
00096                                      nsIFrame* aContentParentFrame,
00097                                      PRBool aForce);
00098 
00099   static nsresult ReparentFrameView(nsPresContext* aPresContext,
00100                                     nsIFrame*       aChildFrame,
00101                                     nsIFrame*       aOldParentFrame,
00102                                     nsIFrame*       aNewParentFrame);
00103 
00104   static nsresult ReparentFrameViewList(nsPresContext* aPresContext,
00105                                         nsIFrame*       aChildFrameList,
00106                                         nsIFrame*       aOldParentFrame,
00107                                         nsIFrame*       aNewParentFrame);
00108 
00109 protected:
00110   virtual PRIntn GetSkipSides() const = 0;
00111 
00112   void PaintSelf(nsPresContext*      aPresContext,
00113                  nsIRenderingContext& aRenderingContext,
00114                  const nsRect&        aDirtyRect) {
00115     nsContainerFrame::PaintSelf(aPresContext, aRenderingContext,
00116                                 aDirtyRect, GetSkipSides());
00117   }
00118 
00124   void PaintDecorationsAndChildren(nsPresContext*      aPresContext,
00125                                    nsIRenderingContext& aRenderingContext,
00126                                    const nsRect&        aDirtyRect,
00127                                    nsFramePaintLayer    aWhichLayer,
00128                                    PRBool               aIsBlock,
00129                                    PRUint32             aFlags = 0);
00130 
00139   void PaintTextDecorations(nsIRenderingContext& aRenderingContext,
00140                             nsIFontMetrics* aFontMetrics,
00141                             PRUint8 aDecoration,
00142                             nscolor aColor);
00143 
00160   void GetTextDecorations(nsPresContext* aPresContext, 
00161                           PRBool aIsBlock,
00162                           PRUint8& aDecorations, 
00163                           nscolor& aUnderColor, 
00164                           nscolor& aOverColor, 
00165                           nscolor& aStrikeColor);
00166 
00180   virtual void PaintTextDecorationLines(nsIRenderingContext& aRenderingContext,
00181                                         nscolor aColor,
00182                                         nscoord aOffset,
00183                                         nscoord aAscent,
00184                                         nscoord aSize);
00185 
00186 };
00187 
00188 #endif /* nsHTMLContainerFrame_h___ */