Back to index

lightning-sunbird  0.9+nobinonly
nsCSSFrameConstructor.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 nsCSSFrameConstructor_h___
00038 #define nsCSSFrameConstructor_h___
00039 
00040 #include "nsCOMPtr.h"
00041 #include "nsILayoutHistoryState.h"
00042 #include "nsIXBLService.h"
00043 #include "nsQuoteList.h"
00044 #include "nsCounterManager.h"
00045 #include "nsDataHashtable.h"
00046 #include "nsHashKeys.h"
00047 #include "plevent.h"
00048 #include "nsIEventQueueService.h"
00049 #include "nsIEventQueue.h"
00050 
00051 class nsIDocument;
00052 struct nsFrameItems;
00053 struct nsAbsoluteItems;
00054 struct nsTableCreator;
00055 class nsStyleContext;
00056 struct nsTableList;
00057 struct nsStyleContent;
00058 struct nsStyleDisplay;
00059 class nsIPresShell;
00060 class nsVoidArray;
00061 class nsFrameManager;
00062 class nsIDOMHTMLSelectElement;
00063 class nsPresContext;
00064 class nsStyleChangeList;
00065 class nsIFrame;
00066 
00067 struct nsFindFrameHint
00068 {
00069   nsIFrame *mPrimaryFrameForPrevSibling;  // weak ref to the primary frame for the content for which we need a frame
00070   nsFindFrameHint() : mPrimaryFrameForPrevSibling(nsnull) { }
00071 };
00072 
00073 class nsFrameConstructorState;
00074 class nsFrameConstructorSaveState;
00075   
00076 class nsCSSFrameConstructor
00077 {
00078 public:
00079   nsCSSFrameConstructor(nsIDocument *aDocument, nsIPresShell* aPresShell);
00080   ~nsCSSFrameConstructor(void) {}
00081 
00082   // Maintain global objects - gXBLService
00083   static nsIXBLService * GetXBLService();
00084   static void ReleaseGlobals() { NS_IF_RELEASE(gXBLService); }
00085 
00086   // get the alternate text for a content node
00087   static void GetAlternateTextFor(nsIContent*    aContent,
00088                                   nsIAtom*       aTag,  // content object's tag
00089                                   nsXPIDLString& aAltText);
00090 private: 
00091   // These are not supported and are not implemented! 
00092   nsCSSFrameConstructor(const nsCSSFrameConstructor& aCopy); 
00093   nsCSSFrameConstructor& operator=(const nsCSSFrameConstructor& aCopy); 
00094 
00095 public:
00096   // XXXbz this method needs to actually return errors!
00097   nsresult ConstructRootFrame(nsIContent*     aDocElement,
00098                               nsIFrame**      aNewFrame);
00099 
00100   nsresult ReconstructDocElementHierarchy();
00101 
00102   nsresult ContentAppended(nsIContent*     aContainer,
00103                            PRInt32         aNewIndexInContainer);
00104 
00105   nsresult ContentInserted(nsIContent*            aContainer,
00106                            nsIFrame*              aContainerFrame,
00107                            nsIContent*            aChild,
00108                            PRInt32                aIndexInContainer,
00109                            nsILayoutHistoryState* aFrameState,
00110                            PRBool                 aInReinsertContent);
00111 
00112   nsresult ContentRemoved(nsIContent*     aContainer,
00113                           nsIContent*     aChild,
00114                           PRInt32         aIndexInContainer,
00115                           PRBool          aInReinsertContent);
00116 
00117   nsresult CharacterDataChanged(nsIContent*     aContent,
00118                                 PRBool          aAppend);
00119 
00120   nsresult ContentStatesChanged(nsIContent*     aContent1,
00121                                 nsIContent*     aContent2,
00122                                 PRInt32         aStateMask);
00123 
00124   // Should be called when a frame is going to be destroyed and
00125   // WillDestroyFrameTree hasn't been called yet.
00126   void NotifyDestroyingFrame(nsIFrame* aFrame);
00127 
00128   nsresult AttributeChanged(nsIContent*     aContent,
00129                             PRInt32         aNameSpaceID,
00130                             nsIAtom*        aAttribute,
00131                             PRInt32         aModType);
00132 
00133   void BeginUpdate() { ++mUpdateCount; }
00134   void EndUpdate();
00135   void RecalcQuotesAndCounters();
00136 
00137   void WillDestroyFrameTree();
00138 
00139   // Note: It's the caller's responsibility to make sure to wrap a
00140   // ProcessRestyledFrames call in a view update batch.
00141   // This function does not call ProcessAttachedQueue() on the binding manager.
00142   // If the caller wants that to happen synchronously, it needs to handle that
00143   // itself.
00144   nsresult ProcessRestyledFrames(nsStyleChangeList& aRestyleArray);
00145 
00146 private:
00147   // This function does not call ProcessAttachedQueue() on the binding manager.
00148   // If the caller wants that to happen synchronously, it needs to handle that
00149   // itself.
00150   void ProcessOneRestyle(nsIContent* aContent, nsReStyleHint aRestyleHint,
00151                          nsChangeHint aChangeHint);
00152 
00153 public:
00154   // This function does not call ProcessAttachedQueue() on the binding manager.
00155   // If the caller wants that to happen synchronously, it needs to handle that
00156   // itself.
00157   void ProcessPendingRestyles();
00158 
00159   void PostRestyleEvent(nsIContent* aContent, nsReStyleHint aRestyleHint,
00160                         nsChangeHint aMinChangeHint);
00161 
00162   // Notification that we were unable to render a replaced element.
00163   nsresult CantRenderReplacedElement(nsIFrame* aFrame);
00164 
00165   // Request to create a continuing frame
00166   nsresult CreateContinuingFrame(nsPresContext* aPresContext,
00167                                  nsIFrame*       aFrame,
00168                                  nsIFrame*       aParentFrame,
00169                                  nsIFrame**      aContinuingFrame);
00170 
00171   // Request to find the primary frame associated with a given content object.
00172   // This is typically called by the pres shell when there is no mapping in
00173   // the pres shell hash table
00174   nsresult FindPrimaryFrameFor(nsFrameManager*  aFrameManager,
00175                                nsIContent*      aContent,
00176                                nsIFrame**       aFrame,
00177                                nsFindFrameHint* aHint);
00178 
00179   // Get the XBL insertion point for a child
00180   nsresult GetInsertionPoint(nsIFrame*     aParentFrame,
00181                              nsIContent*   aChildContent,
00182                              nsIFrame**    aInsertionPoint,
00183                              PRBool*       aMultiple = nsnull);
00184 
00185   nsresult CreateListBoxContent(nsPresContext* aPresContext,
00186                                 nsIFrame*       aParentFrame,
00187                                 nsIFrame*       aPrevFrame,
00188                                 nsIContent*     aChild,
00189                                 nsIFrame**      aResult,
00190                                 PRBool          aIsAppend,
00191                                 PRBool          aIsScrollbar,
00192                                 nsILayoutHistoryState* aFrameState);
00193 
00194   nsresult RemoveMappingsForFrameSubtree(nsIFrame*              aRemovedFrame,
00195                                          nsILayoutHistoryState* aFrameState);
00196 
00197   nsIFrame* GetInitialContainingBlock() { return mInitialContainingBlock; }
00198   nsIFrame* GetPageSequenceFrame() { return mPageSequenceFrame; }
00199 
00200 private:
00201 
00202   nsresult ReinsertContent(nsIContent*    aContainer,
00203                            nsIContent*    aChild);
00204 
00205   nsresult ConstructPageFrame(nsIPresShell*  aPresShell, 
00206                               nsPresContext* aPresContext,
00207                               nsIFrame*      aParentFrame,
00208                               nsIFrame*      aPrevPageFrame,
00209                               nsIFrame*&     aPageFrame,
00210                               nsIFrame*&     aPageContentFrame);
00211 
00212   void DoContentStateChanged(nsIContent*     aContent,
00213                              PRInt32         aStateMask);
00214 
00215 private:
00216   /* aMinHint is the minimal change that should be made to the element */
00217   void RestyleElement(nsIContent*     aContent,
00218                       nsIFrame*       aPrimaryFrame,
00219                       nsChangeHint    aMinHint);
00220 
00221   void RestyleLaterSiblings(nsIContent*     aContent);
00222 
00223   nsresult InitAndRestoreFrame (const nsFrameConstructorState& aState,
00224                                 nsIContent*                    aContent,
00225                                 nsIFrame*                      aParentFrame,
00226                                 nsStyleContext*                aStyleContext,
00227                                 nsIFrame*                      aPrevInFlow,
00228                                 nsIFrame*                      aNewFrame,
00229                                 PRBool                         aAllowCounters = PR_TRUE);
00230 
00231   already_AddRefed<nsStyleContext>
00232   ResolveStyleContext(nsIFrame*         aParentFrame,
00233                       nsIContent*       aContent);
00234 
00235   nsresult ConstructFrame(nsFrameConstructorState& aState,
00236                           nsIContent*              aContent,
00237                           nsIFrame*                aParentFrame,
00238                           nsFrameItems&            aFrameItems);
00239 
00240   nsresult ConstructDocElementFrame(nsFrameConstructorState& aState,
00241                                     nsIContent*              aDocElement,
00242                                     nsIFrame*                aParentFrame,
00243                                     nsIFrame**               aNewFrame);
00244 
00245   nsresult ConstructDocElementTableFrame(nsIContent*            aDocElement,
00246                                          nsIFrame*              aParentFrame,
00247                                          nsIFrame**             aNewTableFrame,
00248                                          nsFrameConstructorState& aState);
00249 
00250   nsresult CreateGeneratedFrameFor(nsIFrame*             aParentFrame,
00251                                    nsIContent*           aContent,
00252                                    nsStyleContext*       aStyleContext,
00253                                    const nsStyleContent* aStyleContent,
00254                                    PRUint32              aContentIndex,
00255                                    nsIFrame**            aFrame);
00256 
00257   PRBool CreateGeneratedContentFrame(nsFrameConstructorState& aState,
00258                                      nsIFrame*                aFrame,
00259                                      nsIContent*              aContent,
00260                                      nsStyleContext*          aStyleContext,
00261                                      nsIAtom*                 aPseudoElement,
00262                                      nsIFrame**               aResult);
00263 
00264   nsresult AppendFrames(const nsFrameConstructorState& aState,
00265                         nsIContent*                    aContainer,
00266                         nsIFrame*                      aParentFrame,
00267                         nsIFrame*                      aFrameList,
00268                         nsIFrame*                      aAfterFrame);
00269 
00270   // BEGIN TABLE SECTION
00281   nsresult ConstructTableFrame(nsFrameConstructorState& aState,
00282                                nsIContent*              aContent,
00283                                nsIFrame*                aContentParent,
00284                                nsStyleContext*          aStyleContext,
00285                                nsTableCreator&          aTableCreator,
00286                                PRBool                   aIsPseudo,
00287                                nsFrameItems&            aChildItems,
00288                                PRBool                   aAllowOutOfFlow,
00289                                nsIFrame*&               aNewOuterFrame,
00290                                nsIFrame*&               aNewInnerFrame);
00291 
00292   nsresult ConstructTableCaptionFrame(nsFrameConstructorState& aState,
00293                                       nsIContent*              aContent,
00294                                       nsIFrame*                aParent,
00295                                       nsStyleContext*          aStyleContext,
00296                                       nsTableCreator&          aTableCreator,
00297                                       nsFrameItems&            aChildItems,
00298                                       nsIFrame*&               aNewFrame,
00299                                       PRBool&                  aIsPseudoParent);
00300 
00301   nsresult ConstructTableRowGroupFrame(nsFrameConstructorState& aState,
00302                                        nsIContent*              aContent,
00303                                        nsIFrame*                aParent,
00304                                        nsStyleContext*          aStyleContext,
00305                                        nsTableCreator&          aTableCreator,
00306                                        PRBool                   aIsPseudo,
00307                                        nsFrameItems&            aChildItems,
00308                                        nsIFrame*&               aNewFrame,
00309                                        PRBool&                  aIsPseudoParent);
00310 
00311   nsresult ConstructTableColGroupFrame(nsFrameConstructorState& aState,
00312                                        nsIContent*              aContent,
00313                                        nsIFrame*                aParent,
00314                                        nsStyleContext*          aStyleContext,
00315                                        nsTableCreator&          aTableCreator,
00316                                        PRBool                   aIsPseudo,
00317                                        nsFrameItems&            aChildItems,
00318                                        nsIFrame*&               aNewFrame,
00319                                        PRBool&                  aIsPseudoParent);
00320 
00321   nsresult ConstructTableRowFrame(nsFrameConstructorState& aState,
00322                                   nsIContent*              aContent,
00323                                   nsIFrame*                aParent,
00324                                   nsStyleContext*          aStyleContext,
00325                                   nsTableCreator&          aTableCreator,
00326                                   PRBool                   aIsPseudo,
00327                                   nsFrameItems&            aChildItems,
00328                                   nsIFrame*&               aNewFrame,
00329                                   PRBool&                  aIsPseudoParent);
00330 
00331   nsresult ConstructTableColFrame(nsFrameConstructorState& aState,
00332                                   nsIContent*              aContent,
00333                                   nsIFrame*                aParent,
00334                                   nsStyleContext*          aStyleContext,
00335                                   nsTableCreator&          aTableCreator,
00336                                   PRBool                   aIsPseudo,
00337                                   nsFrameItems&            aChildItems,
00338                                   nsIFrame*&               aNewFrame,
00339                                   PRBool&                  aIsPseudoParent);
00340 
00341   nsresult ConstructTableCellFrame(nsFrameConstructorState& aState,
00342                                    nsIContent*              aContent,
00343                                    nsIFrame*                aParentFrame,
00344                                    nsStyleContext*          aStyleContext,
00345                                    nsTableCreator&          aTableCreator,
00346                                    PRBool                   aIsPseudo,
00347                                    nsFrameItems&            aChildItems,
00348                                    nsIFrame*&               aNewCellOuterFrame,
00349                                    nsIFrame*&               aNewCellInnerFrame,
00350                                    PRBool&                  aIsPseudoParent);
00351 
00359   nsresult ConstructTableForeignFrame(nsFrameConstructorState& aState,
00360                                       nsIContent*              aContent,
00361                                       nsIFrame*                aParentFrameIn,
00362                                       nsStyleContext*          aStyleContext,
00363                                       nsTableCreator&          aTableCreator,
00364                                       nsFrameItems&            aChildItems);
00365 
00366   nsresult CreatePseudoTableFrame(nsTableCreator&          aTableCreator,
00367                                   nsFrameConstructorState& aState, 
00368                                   nsIFrame*                aParentFrameIn = nsnull);
00369 
00370   nsresult CreatePseudoRowGroupFrame(nsTableCreator&          aTableCreator,
00371                                      nsFrameConstructorState& aState, 
00372                                      nsIFrame*                aParentFrameIn = nsnull);
00373 
00374   nsresult CreatePseudoColGroupFrame(nsTableCreator&          aTableCreator,
00375                                      nsFrameConstructorState& aState, 
00376                                      nsIFrame*                aParentFrameIn = nsnull);
00377 
00378   nsresult CreatePseudoRowFrame(nsTableCreator&          aTableCreator,
00379                                 nsFrameConstructorState& aState, 
00380                                 nsIFrame*                aParentFrameIn = nsnull);
00381 
00382   nsresult CreatePseudoCellFrame(nsTableCreator&          aTableCreator,
00383                                  nsFrameConstructorState& aState, 
00384                                  nsIFrame*                aParentFrameIn = nsnull);
00385 
00386   nsresult GetPseudoTableFrame(nsTableCreator&          aTableCreator,
00387                                nsFrameConstructorState& aState, 
00388                                nsIFrame&                aParentFrameIn);
00389 
00390   nsresult GetPseudoColGroupFrame(nsTableCreator&          aTableCreator,
00391                                   nsFrameConstructorState& aState, 
00392                                   nsIFrame&                aParentFrameIn);
00393 
00394   nsresult GetPseudoRowGroupFrame(nsTableCreator&          aTableCreator,
00395                                   nsFrameConstructorState& aState, 
00396                                   nsIFrame&                aParentFrameIn);
00397 
00398   nsresult GetPseudoRowFrame(nsTableCreator&          aTableCreator,
00399                              nsFrameConstructorState& aState, 
00400                              nsIFrame&                aParentFrameIn);
00401 
00402   nsresult GetPseudoCellFrame(nsTableCreator&          aTableCreator,
00403                               nsFrameConstructorState& aState, 
00404                               nsIFrame&                aParentFrameIn);
00405 
00406   nsresult GetParentFrame(nsTableCreator&          aTableCreator,
00407                           nsIFrame&                aParentFrameIn, 
00408                           nsIAtom*                 aChildFrameType, 
00409                           nsFrameConstructorState& aState, 
00410                           nsIFrame*&               aParentFrame,
00411                           PRBool&                  aIsPseudoParent);
00412 
00431   // XXXbz this function should really go away once we rework pseudo-frame
00432   // handling to be better. This should simply be part of the job of
00433   // GetGeometricParent, and stuff like the frameitems and parent frame should
00434   // be kept track of in the state...
00435   nsresult AdjustParentFrame(nsIContent* aChildContent,
00436                              const nsStyleDisplay* aChildDisplay,
00437                              nsIAtom* aTag,
00438                              PRInt32 aNameSpaceID,
00439                              nsStyleContext* aChildStyle,
00440                              nsIFrame* & aParentFrame,
00441                              nsFrameItems* & aFrameItems,
00442                              nsFrameConstructorState& aState,
00443                              nsFrameConstructorSaveState& aSaveState,
00444                              PRBool& aCreatedPseudo);
00445   
00446   nsresult TableProcessChildren(nsFrameConstructorState& aState,
00447                                 nsIContent*              aContent,
00448                                 nsIFrame*                aParentFrame,
00449                                 nsTableCreator&          aTableCreator,
00450                                 nsFrameItems&            aChildItems,
00451                                 nsIFrame*&               aCaption);
00452 
00453   nsresult TableProcessChild(nsFrameConstructorState& aState,
00454                              nsIContent*              aChildContent,
00455                              nsIContent*              aParentContent,
00456                              nsIFrame*                aParentFrame,
00457                              nsIAtom*                 aParentFrameType,
00458                              nsStyleContext*          aParentStyleContext,
00459                              nsTableCreator&          aTableCreator,
00460                              nsFrameItems&            aChildItems,
00461                              nsIFrame*&               aCaption);
00462 
00463   const nsStyleDisplay* GetDisplay(nsIFrame* aFrame);
00464 
00465   // END TABLE SECTION
00466 
00467 protected:
00468   static nsresult CreatePlaceholderFrameFor(nsIPresShell*    aPresShell, 
00469                                             nsPresContext*  aPresContext,
00470                                             nsFrameManager*  aFrameManager,
00471                                             nsIContent*      aContent,
00472                                             nsIFrame*        aFrame,
00473                                             nsStyleContext*  aStyleContext,
00474                                             nsIFrame*        aParentFrame,
00475                                             nsIFrame**       aPlaceholderFrame);
00476 
00477 private:
00478   nsresult ConstructAlternateFrame(nsIContent*      aContent,
00479                                    nsStyleContext*  aStyleContext,
00480                                    nsIFrame*        aGeometricParent,
00481                                    nsIFrame*        aContentParent,
00482                                    nsIFrame*&       aFrame);
00483 
00484   // @param OUT aNewFrame the new radio control frame
00485   nsresult ConstructRadioControlFrame(nsIFrame**         aNewFrame,
00486                                       nsIContent*        aContent,
00487                                       nsStyleContext*    aStyleContext);
00488 
00489   // @param OUT aNewFrame the new checkbox control frame
00490   nsresult ConstructCheckboxControlFrame(nsIFrame**       aNewFrame,
00491                                          nsIContent*      aContent,
00492                                          nsStyleContext*  aStyleContext);
00493 
00494   // ConstructSelectFrame puts the new frame in aFrameItems and
00495   // handles the kids of the select.
00496   nsresult ConstructSelectFrame(nsFrameConstructorState& aState,
00497                                 nsIContent*              aContent,
00498                                 nsIFrame*                aParentFrame,
00499                                 nsIAtom*                 aTag,
00500                                 nsStyleContext*          aStyleContext,
00501                                 nsIFrame*&               aNewFrame,
00502                                 const nsStyleDisplay*    aStyleDisplay,
00503                                 PRBool&                  aFrameHasBeenInitialized,
00504                                 nsFrameItems&            aFrameItems);
00505 
00506   // ConstructFieldSetFrame puts the new frame in aFrameItems and
00507   // handles the kids of the fieldset
00508   nsresult ConstructFieldSetFrame(nsFrameConstructorState& aState,
00509                                   nsIContent*              aContent,
00510                                   nsIFrame*                aParentFrame,
00511                                   nsIAtom*                 aTag,
00512                                   nsStyleContext*          aStyleContext,
00513                                   nsIFrame*&               aNewFrame,
00514                                   nsFrameItems&            aFrameItems,
00515                                   const nsStyleDisplay*    aStyleDisplay,
00516                                   PRBool&                  aFrameHasBeenInitialized);
00517 
00518   nsresult ConstructTextFrame(nsFrameConstructorState& aState,
00519                               nsIContent*              aContent,
00520                               nsIFrame*                aParentFrame,
00521                               nsStyleContext*          aStyleContext,
00522                               nsFrameItems&            aFrameItems,
00523                               PRBool                   aPseudoParent);
00524 
00525   nsresult ConstructPageBreakFrame(nsFrameConstructorState& aState,
00526                                    nsIContent*              aContent,
00527                                    nsIFrame*                aParentFrame,
00528                                    nsStyleContext*          aStyleContext,
00529                                    nsFrameItems&            aFrameItems);
00530 
00531   // Construct a page break frame if page-break-before:always is set in aStyleContext
00532   // and add it to aFrameItems. Return true if page-break-after:always is set on aStyleContext.
00533   // Don't do this for row groups, rows or cell, because tables handle those internally.
00534   PRBool PageBreakBefore(nsFrameConstructorState& aState,
00535                          nsIContent*              aContent,
00536                          nsIFrame*                aParentFrame,
00537                          nsStyleContext*          aStyleContext,
00538                          nsFrameItems&            aFrameItems);
00539 
00540   nsresult ConstructHTMLFrame(nsFrameConstructorState& aState,
00541                               nsIContent*              aContent,
00542                               nsIFrame*                aParentFrame,
00543                               nsIAtom*                 aTag,
00544                               PRInt32                  aNameSpaceID,
00545                               nsStyleContext*          aStyleContext,
00546                               nsFrameItems&            aFrameItems,
00547                               PRBool                   aHasPseudoParent);
00548 
00549   nsresult ConstructFrameInternal( nsFrameConstructorState& aState,
00550                                    nsIContent*              aContent,
00551                                    nsIFrame*                aParentFrame,
00552                                    nsIAtom*                 aTag,
00553                                    PRInt32                  aNameSpaceID,
00554                                    nsStyleContext*          aStyleContext,
00555                                    nsFrameItems&            aFrameItems,
00556                                    PRBool                   aXBLBaseTag);
00557 
00558   nsresult CreateAnonymousFrames(nsIAtom*                 aTag,
00559                                  nsFrameConstructorState& aState,
00560                                  nsIContent*              aParent,
00561                                  nsIFrame*                aNewFrame,
00562                                  PRBool                   aAppendToExisting,
00563                                  nsFrameItems&            aChildItems,
00564                                  PRBool                   aIsRoot = PR_FALSE);
00565 
00566   nsresult CreateAnonymousFrames(nsFrameConstructorState& aState,
00567                                  nsIContent*              aParent,
00568                                  nsIDocument*             aDocument,
00569                                  nsIFrame*                aNewFrame,
00570                                  PRBool                   aForceBindingParent,
00571                                  PRBool                   aAppendToExisting,
00572                                  nsFrameItems&            aChildItems,
00573                                  nsIFrame*                aAnonymousCreator,
00574                                  nsIContent*              aInsertionNode,
00575                                  PRBool                   aAnonymousParentIsBlock);
00576 
00577 //MathML Mod - RBS
00578 #ifdef MOZ_MATHML
00579   nsresult ConstructMathMLFrame(nsFrameConstructorState& aState,
00580                                 nsIContent*              aContent,
00581                                 nsIFrame*                aParentFrame,
00582                                 nsIAtom*                 aTag,
00583                                 PRInt32                  aNameSpaceID,
00584                                 nsStyleContext*          aStyleContext,
00585                                 nsFrameItems&            aFrameItems,
00586                                 PRBool                   aHasPseudoParent);
00587 #endif
00588 
00589   nsresult ConstructXULFrame(nsFrameConstructorState& aState,
00590                              nsIContent*              aContent,
00591                              nsIFrame*                aParentFrame,
00592                              nsIAtom*                 aTag,
00593                              PRInt32                  aNameSpaceID,
00594                              nsStyleContext*          aStyleContext,
00595                              nsFrameItems&            aFrameItems,
00596                              PRBool                   aXBLBaseTag,
00597                              PRBool                   aHasPseudoParent,
00598                              PRBool*                  aHaltProcessing);
00599 
00600 
00601 // XTF
00602 #ifdef MOZ_XTF
00603   nsresult ConstructXTFFrame(nsFrameConstructorState& aState,
00604                              nsIContent*              aContent,
00605                              nsIFrame*                aParentFrame,
00606                              nsIAtom*                 aTag,
00607                              PRInt32                  aNameSpaceID,
00608                              nsStyleContext*          aStyleContext,
00609                              nsFrameItems&            aFrameItems,
00610                              PRBool                   aHasPseudoParent);
00611 #endif
00612 
00613 // SVG - rods
00614 #ifdef MOZ_SVG
00615   nsresult TestSVGConditions(nsIContent* aContent,
00616                              PRBool&     aHasRequiredExtensions,
00617                              PRBool&     aHasRequiredFeatures,
00618                              PRBool&     aHasSystemLanguage);
00619  
00620   nsresult SVGSwitchProcessChildren(nsFrameConstructorState& aState,
00621                                     nsIContent*              aContent,
00622                                     nsIFrame*                aFrame,
00623                                     nsFrameItems&            aFrameItems);
00624 
00625   nsresult ConstructSVGFrame(nsFrameConstructorState& aState,
00626                              nsIContent*              aContent,
00627                              nsIFrame*                aParentFrame,
00628                              nsIAtom*                 aTag,
00629                              PRInt32                  aNameSpaceID,
00630                              nsStyleContext*          aStyleContext,
00631                              nsFrameItems&            aFrameItems,
00632                              PRBool                   aHasPseudoParent,
00633                              PRBool*                  aHaltProcessing);
00634 #endif
00635 
00636   nsresult ConstructFrameByDisplayType(nsFrameConstructorState& aState,
00637                                        const nsStyleDisplay*    aDisplay,
00638                                        nsIContent*              aContent,
00639                                        PRInt32                  aNameSpaceID,
00640                                        nsIAtom*                 aTag,
00641                                        nsIFrame*                aParentFrame,
00642                                        nsStyleContext*          aStyleContext,
00643                                        nsFrameItems&            aFrameItems,
00644                                        PRBool                   aHasPseudoParent);
00645 
00646   nsresult ProcessChildren(nsFrameConstructorState& aState,
00647                            nsIContent*              aContent,
00648                            nsIFrame*                aFrame,
00649                            PRBool                   aCanHaveGeneratedContent,
00650                            nsFrameItems&            aFrameItems,
00651                            PRBool                   aParentIsBlock,
00652                            nsTableCreator*          aTableCreator = nsnull);
00653 
00654   // @param OUT aFrame the newly created frame
00655   nsresult CreateInputFrame(nsIContent*      aContent,
00656                             nsIFrame**       aFrame,
00657                             nsStyleContext*  aStyleContext);
00658 
00659   nsresult AddDummyFrameToSelect(nsFrameConstructorState& aState,
00660                                  nsIFrame*                aListFrame,
00661                                  nsIFrame*                aParentFrame,
00662                                  nsFrameItems*            aChildItems,
00663                                  nsIContent*              aContainer,
00664                                  nsIDOMHTMLSelectElement* aSelectElement);
00665 
00666   nsresult RemoveDummyFrameFromSelect(nsIContent*               aContainer,
00667                                       nsIContent*               aChild,
00668                                       nsIDOMHTMLSelectElement*  aSelectElement);
00669 
00670   nsIFrame* GetFrameFor(nsIContent* aContent);
00671 
00672   nsIFrame* GetAbsoluteContainingBlock(nsIFrame* aFrame);
00673 
00674   nsIFrame* GetFloatContainingBlock(nsIFrame* aFrame);
00675 
00676   nsIContent* PropagateScrollToViewport();
00677 
00678   // Build a scroll frame: 
00679   //  Calls BeginBuildingScrollFrame, InitAndRestoreFrame, and then FinishBuildingScrollFrame.
00680   //  Sets the primary frame for the content to the output aNewFrame.
00681   // @param aNewFrame the created scrollframe --- output only
00682   nsresult
00683   BuildScrollFrame(nsFrameConstructorState& aState,
00684                    nsIContent*              aContent,
00685                    nsStyleContext*          aContentStyle,
00686                    nsIFrame*                aScrolledFrame,
00687                    nsIFrame*                aParentFrame,
00688                    nsIFrame*                aContentParentFrame,
00689                    nsIFrame*&               aNewFrame,
00690                    nsStyleContext*&         aScrolledChildStyle);
00691 
00692   // Builds the initial ScrollFrame
00693   already_AddRefed<nsStyleContext>
00694   BeginBuildingScrollFrame(nsFrameConstructorState& aState,
00695                            nsIContent*              aContent,
00696                            nsStyleContext*          aContentStyle,
00697                            nsIFrame*                aParentFrame,
00698                            nsIFrame*                aContentParentFrame,
00699                            nsIAtom*                 aScrolledPseudo,
00700                            PRBool                   aIsRoot,
00701                            nsIFrame*&               aNewFrame);
00702 
00703   // Completes the building of the scrollframe:
00704   // Creates a view for the scrolledframe and makes it the child of the scrollframe.
00705   void
00706   FinishBuildingScrollFrame(nsIFrame* aScrollFrame,
00707                             nsIFrame* aScrolledFrame);
00708 
00709   // InitializeSelectFrame puts scrollFrame in aFrameItems if aBuildCombobox is false
00710   nsresult
00711   InitializeSelectFrame(nsFrameConstructorState& aState,
00712                         nsIFrame*                scrollFrame,
00713                         nsIFrame*                scrolledFrame,
00714                         nsIContent*              aContent,
00715                         nsIFrame*                aParentFrame,
00716                         nsStyleContext*          aStyleContext,
00717                         PRBool                   aBuildCombobox,
00718                         nsFrameItems&            aFrameItems);
00719 
00720   nsresult MaybeRecreateFramesForContent(nsIContent*      aContent);
00721 
00722   nsresult RecreateFramesForContent(nsIContent*      aContent);
00723 
00724   PRBool MaybeRecreateContainerForIBSplitterFrame(nsIFrame* aFrame, nsresult* aResult);
00725 
00726   nsresult CreateContinuingOuterTableFrame(nsIPresShell*    aPresShell, 
00727                                            nsPresContext*  aPresContext,
00728                                            nsIFrame*        aFrame,
00729                                            nsIFrame*        aParentFrame,
00730                                            nsIContent*      aContent,
00731                                            nsStyleContext*  aStyleContext,
00732                                            nsIFrame**       aContinuingFrame);
00733 
00734   nsresult CreateContinuingTableFrame(nsIPresShell*    aPresShell, 
00735                                       nsPresContext*  aPresContext,
00736                                       nsIFrame*        aFrame,
00737                                       nsIFrame*        aParentFrame,
00738                                       nsIContent*      aContent,
00739                                       nsStyleContext*  aStyleContext,
00740                                       nsIFrame**       aContinuingFrame);
00741 
00742   //----------------------------------------
00743 
00744   // Methods support creating block frames and their children
00745 
00746   already_AddRefed<nsStyleContext>
00747   GetFirstLetterStyle(nsIContent*      aContent,
00748                       nsStyleContext*  aStyleContext);
00749 
00750   already_AddRefed<nsStyleContext>
00751   GetFirstLineStyle(nsIContent*      aContent,
00752                     nsStyleContext*  aStyleContext);
00753 
00754   PRBool HaveFirstLetterStyle(nsIContent*      aContent,
00755                               nsStyleContext*  aStyleContext);
00756 
00757   // Check whether a given block has first-letter style.  Make sure to
00758   // only pass in blocks!  And don't pass in null either.
00759   PRBool HaveFirstLetterStyle(nsIFrame* aBlockFrame);
00760 
00761   PRBool HaveFirstLineStyle(nsIContent*      aContent,
00762                             nsStyleContext*  aStyleContext);
00763 
00764   void HaveSpecialBlockStyle(nsIContent*      aContent,
00765                              nsStyleContext*  aStyleContext,
00766                              PRBool*          aHaveFirstLetterStyle,
00767                              PRBool*          aHaveFirstLineStyle);
00768 
00769   // |aContentParentFrame| should be null if it's really the same as
00770   // |aParentFrame|.
00771   // @param aFrameItems where we want to put the block in case it's in-flow.
00772   // @param aNewFrame an in/out parameter. On input it is the block to be
00773   // constructed. On output it is reset to the outermost
00774   // frame constructed (e.g. if we need to wrap the block in an
00775   // nsColumnSetFrame.
00776   // @param aParentFrame is the desired parent for the (possibly wrapped)
00777   // block
00778   // @param aContentParent is the parent the block would have if it
00779   // were in-flow
00780   nsresult ConstructBlock(nsFrameConstructorState& aState,
00781                           const nsStyleDisplay*    aDisplay,
00782                           nsIContent*              aContent,
00783                           nsIFrame*                aParentFrame,
00784                           nsIFrame*                aContentParentFrame,
00785                           nsStyleContext*          aStyleContext,
00786                           nsIFrame**               aNewFrame,
00787                           nsFrameItems&            aFrameItems,
00788                           PRBool                   aAbsPosContainer);
00789 
00790   nsresult ConstructInline(nsFrameConstructorState& aState,
00791                            const nsStyleDisplay*    aDisplay,
00792                            nsIContent*              aContent,
00793                            nsIFrame*                aParentFrame,
00794                            nsStyleContext*          aStyleContext,
00795                            PRBool                   aIsPositioned,
00796                            nsIFrame*                aNewFrame);
00797 
00798   nsresult ProcessInlineChildren(nsFrameConstructorState& aState,
00799                                  nsIContent*              aContent,
00800                                  nsIFrame*                aFrame,
00801                                  PRBool                   aCanHaveGeneratedContent,
00802                                  nsFrameItems&            aFrameItems,
00803                                  PRBool*                  aKidsAllInline);
00804 
00805   PRBool AreAllKidsInline(nsIFrame* aFrameList);
00806 
00807   PRBool WipeContainingBlock(nsFrameConstructorState& aState,
00808                              nsIFrame*                blockContent,
00809                              nsIFrame*                aFrame,
00810                              nsIFrame*                aFrameList);
00811 
00812   PRBool NeedSpecialFrameReframe(nsIContent*      aParent1,
00813                                  nsIContent*      aParent2,
00814                                  nsIFrame*&       aParentFrame,
00815                                  nsIContent*      aChild,
00816                                  PRInt32          aIndexInContainer,
00817                                  nsIFrame*&       aPrevSibling,
00818                                  nsIFrame*        aNextSibling);
00819 
00820   nsresult SplitToContainingBlock(nsFrameConstructorState& aState,
00821                                   nsIFrame*                aFrame,
00822                                   nsIFrame*                aLeftInlineChildFrame,
00823                                   nsIFrame*                aBlockChildFrame,
00824                                   nsIFrame*                aRightInlineChildFrame,
00825                                   PRBool                   aTransfer);
00826 
00827   nsresult ReframeContainingBlock(nsIFrame* aFrame);
00828 
00829   nsresult StyleChangeReflow(nsIFrame* aFrame, nsIAtom* aAttribute);
00830 
00840   nsIFrame* FindFrameWithContent(nsFrameManager*  aFrameManager,
00841                                  nsIFrame*        aParentFrame,
00842                                  nsIContent*      aParentContent,
00843                                  nsIContent*      aContent,
00844                                  nsFindFrameHint* aHint);
00845 
00846   //----------------------------------------
00847 
00848   // Methods support :first-letter style
00849 
00850   void CreateFloatingLetterFrame(nsFrameConstructorState& aState,
00851                                  nsIContent*              aTextContent,
00852                                  nsIFrame*                aTextFrame,
00853                                  nsIContent*              aBlockContent,
00854                                  nsIFrame*                aParentFrame,
00855                                  nsStyleContext*          aStyleContext,
00856                                  nsFrameItems&            aResult);
00857 
00858   nsresult CreateLetterFrame(nsFrameConstructorState& aState,
00859                              nsIContent*              aTextContent,
00860                              nsIFrame*                aParentFrame,
00861                              nsFrameItems&            aResult);
00862 
00863   nsresult WrapFramesInFirstLetterFrame(nsFrameConstructorState& aState,
00864                                         nsIContent*              aBlockContent,
00865                                         nsIFrame*                aBlockFrame,
00866                                         nsFrameItems&            aBlockFrames);
00867 
00868   nsresult WrapFramesInFirstLetterFrame(nsFrameConstructorState& aState,
00869                                         nsIFrame*                aParentFrame,
00870                                         nsIFrame*                aParentFrameList,
00871                                         nsIFrame**               aModifiedParent,
00872                                         nsIFrame**               aTextFrame,
00873                                         nsIFrame**               aPrevFrame,
00874                                         nsFrameItems&            aLetterFrame,
00875                                         PRBool*                  aStopLooking);
00876 
00877   nsresult RecoverLetterFrames(nsFrameConstructorState& aState,
00878                                nsIFrame*                aBlockFrame);
00879 
00880   // 
00881   nsresult RemoveLetterFrames(nsPresContext*  aPresContext,
00882                               nsIPresShell*    aPresShell,
00883                               nsFrameManager*  aFrameManager,
00884                               nsIFrame*        aBlockFrame);
00885 
00886   // Recursive helper for RemoveLetterFrames
00887   nsresult RemoveFirstLetterFrames(nsPresContext*  aPresContext,
00888                                    nsIPresShell*    aPresShell,
00889                                    nsFrameManager*  aFrameManager,
00890                                    nsIFrame*        aFrame,
00891                                    PRBool*          aStopLooking);
00892 
00893   // Special remove method for those pesky floating first-letter frames
00894   nsresult RemoveFloatingFirstLetterFrames(nsPresContext*  aPresContext,
00895                                            nsIPresShell*    aPresShell,
00896                                            nsFrameManager*  aFrameManager,
00897                                            nsIFrame*        aBlockFrame,
00898                                            PRBool*          aStopLooking);
00899 
00900   // Capture state for the frame tree rooted at the frame associated with the
00901   // content object, aContent
00902   nsresult CaptureStateForFramesOf(nsIContent* aContent,
00903                                    nsILayoutHistoryState* aHistoryState);
00904 
00905   // Capture state for the frame tree rooted at aFrame.
00906   nsresult CaptureStateFor(nsIFrame*              aFrame,
00907                            nsILayoutHistoryState* aHistoryState);
00908 
00909   //----------------------------------------
00910 
00911   // Methods support :first-line style
00912 
00913   nsresult WrapFramesInFirstLineFrame(nsFrameConstructorState& aState,
00914                                       nsIContent*              aContent,
00915                                       nsIFrame*                aFrame,
00916                                       nsFrameItems&            aFrameItems);
00917 
00918   nsresult AppendFirstLineFrames(nsFrameConstructorState& aState,
00919                                  nsIContent*              aContent,
00920                                  nsIFrame*                aBlockFrame,
00921                                  nsFrameItems&            aFrameItems);
00922 
00923   nsresult InsertFirstLineFrames(nsFrameConstructorState& aState,
00924                                  nsIContent*              aContent,
00925                                  nsIFrame*                aBlockFrame,
00926                                  nsIFrame**               aParentFrame,
00927                                  nsIFrame*                aPrevSibling,
00928                                  nsFrameItems&            aFrameItems);
00929 
00930   nsresult RemoveFixedItems(const nsFrameConstructorState& aState);
00931 
00932   // Find the ``rightmost'' frame for the content immediately preceding
00933   // aIndexInContainer, following continuations if necessary. If aChild is
00934   // not null, make sure it passes the call to IsValidSibling
00935   nsIFrame* FindPreviousSibling(nsIContent*       aContainer,
00936                                 nsIFrame*         aContainerFrame,
00937                                 PRInt32           aIndexInContainer,
00938                                 const nsIContent* aChild = nsnull);
00939 
00940   // Find the frame for the content node immediately following aIndexInContainer.
00941   // If aChild is not null, make sure it passes the call to IsValidSibling
00942   nsIFrame* FindNextSibling(nsIContent*       aContainer,
00943                             nsIFrame*         aContainerFrame,
00944                             PRInt32           aIndexInContainer,
00945                             const nsIContent* aChild = nsnull);
00946 
00947   // see if aContent and aSibling are legitimate siblings due to restrictions
00948   // imposed by table columns
00949   PRBool IsValidSibling(nsIFrame*              aParentFrame,
00950                         const nsIFrame&        aSibling,
00951                         PRUint8                aSiblingDisplay,
00952                         nsIContent&            aContent,
00953                         PRUint8&               aDisplay);
00954 
00955   void QuotesDirty() {
00956     if (mUpdateCount != 0)
00957       mQuotesDirty = PR_TRUE;
00958     else
00959       mQuoteList.RecalcAll();
00960   }
00961 
00962   void CountersDirty() {
00963     if (mUpdateCount != 0)
00964       mCountersDirty = PR_TRUE;
00965     else
00966       mCounterManager.RecalcAll();
00967   }
00968 
00969   inline NS_HIDDEN_(nsresult)
00970     CreateInsertionPointChildren(nsFrameConstructorState &aState,
00971                                  nsIFrame *aNewFrame,
00972                                  nsIContent *aContent,
00973                                  PRBool aUseInsertionFrame = PR_TRUE);
00974 
00975   NS_HIDDEN_(nsresult)
00976     CreateInsertionPointChildren(nsFrameConstructorState &aState,
00977                                  nsIFrame *aNewFrame,
00978                                  PRBool aUseInsertionFrame);
00979                                  
00980 public:
00981   struct RestyleData;
00982   friend struct RestyleData;
00983 
00984   struct RestyleData {
00985     nsReStyleHint mRestyleHint;  // What we want to restyle
00986     nsChangeHint  mChangeHint;   // The minimal change hint for "self"
00987   };
00988 
00989   struct RestyleEnumerateData : public RestyleData {
00990     nsCOMPtr<nsIContent> mContent;
00991   };
00992 
00993   struct RestyleEvent;
00994   friend struct RestyleEvent;
00995 
00996   struct RestyleEvent : public PLEvent {
00997     RestyleEvent(nsCSSFrameConstructor* aConstructor);
00998     ~RestyleEvent() { }
00999     void HandleEvent();
01000   };
01001 
01002   friend class nsFrameConstructorState;
01003 
01004 protected:
01005   nsCOMPtr<nsIEventQueue>        mRestyleEventQueue;
01006   
01007 private:
01008 #ifdef ACCESSIBILITY
01009   // If the frame is visible, return the frame type
01010   // If the frame is invisible, return nsnull
01011   nsIAtom *GetRenderedFrameType(nsIFrame *aFrame);
01012   
01013   // Using the rendered frame type from GetRenderedFrameType(), which is nsnull
01014   // for invisible frames, compare the previous rendering and new rendering, to
01015   // determine if the tree of accessibility objects may change. If it might,
01016   // notify the accessibility module of the change, and whether it is a generic
01017   // change, something is being made visible or something is being made hidden.
01018   void NotifyAccessibleChange(nsIAtom *aPreviousFrameType, nsIAtom *aFrameType,
01019                               nsIContent *aContent);
01020 #endif
01021 
01022   nsIDocument*        mDocument;  // Weak ref
01023   nsIPresShell*       mPresShell; // Weak ref
01024 
01025   nsIFrame*           mInitialContainingBlock;
01026   nsIFrame*           mFixedContainingBlock;
01027   nsIFrame*           mDocElementContainingBlock;
01028   nsIFrame*           mGfxScrollFrame;
01029   nsIFrame*           mPageSequenceFrame;
01030   nsQuoteList         mQuoteList;
01031   nsCounterManager    mCounterManager;
01032   PRUint16            mUpdateCount;
01033   PRPackedBool        mQuotesDirty : 1;
01034   PRPackedBool        mCountersDirty : 1;
01035   PRPackedBool        mInitialContainingBlockIsAbsPosContainer : 1;
01036   PRPackedBool        mIsDestroyingFrameTree : 1;
01037 
01038   nsCOMPtr<nsILayoutHistoryState> mTempFrameTreeState;
01039 
01040   nsCOMPtr<nsIEventQueueService> mEventQueueService;
01041 
01042   nsDataHashtable<nsISupportsHashKey, RestyleData> mPendingRestyles;
01043 
01044   static nsIXBLService * gXBLService;
01045 };
01046 
01047 #endif /* nsCSSFrameConstructor_h___ */