Back to index

lightning-sunbird  0.9+nobinonly
nsHTMLContainerFrame.cpp
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 #include "nsHTMLContainerFrame.h"
00038 #include "nsIRenderingContext.h"
00039 #include "nsPresContext.h"
00040 #include "nsIPresShell.h"
00041 #include "nsStyleContext.h"
00042 #include "nsStyleConsts.h"
00043 #include "nsIContent.h"
00044 #include "nsLayoutAtoms.h"
00045 #include "nsLayoutUtils.h"
00046 #include "nsCSSAnonBoxes.h"
00047 #include "nsIWidget.h"
00048 #include "nsILinkHandler.h"
00049 #include "nsGUIEvent.h"
00050 #include "nsIDocument.h"
00051 #include "nsIURL.h"
00052 #include "nsPlaceholderFrame.h"
00053 #include "nsHTMLParts.h"
00054 #include "nsIView.h"
00055 #include "nsIViewManager.h"
00056 #include "nsIDOMEvent.h"
00057 #include "nsIScrollableView.h"
00058 #include "nsWidgetsCID.h"
00059 #include "nsCOMPtr.h"
00060 #include "nsIDeviceContext.h"
00061 #include "nsIFontMetrics.h"
00062 #include "nsReflowPath.h"
00063 #include "nsCSSFrameConstructor.h"
00064 
00065 NS_IMETHODIMP
00066 nsHTMLContainerFrame::Paint(nsPresContext*      aPresContext,
00067                             nsIRenderingContext& aRenderingContext,
00068                             const nsRect&        aDirtyRect,
00069                             nsFramePaintLayer    aWhichLayer,
00070                             PRUint32             aFlags)
00071 {
00072   if (NS_FRAME_IS_UNFLOWABLE & mState) {
00073     return NS_OK;
00074   }
00075 
00076   // Paint inline element backgrounds in the foreground layer, but
00077   // others in the background (bug 36710).  (nsInlineFrame::Paint does
00078   // this differently.)
00079   if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
00080     PaintSelf(aPresContext, aRenderingContext, aDirtyRect);
00081   }
00082     
00083   PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
00084   return NS_OK;
00085 }
00086 
00087 void
00088 nsHTMLContainerFrame::PaintDecorationsAndChildren(
00089                                        nsPresContext*      aPresContext,
00090                                        nsIRenderingContext& aRenderingContext,
00091                                        const nsRect&        aDirtyRect,
00092                                        nsFramePaintLayer    aWhichLayer,
00093                                        PRBool               aIsBlock,
00094                                        PRUint32             aFlags)
00095 {
00096   // Do standards mode painting of 'text-decoration's: under+overline
00097   // behind children, line-through in front.  For Quirks mode, see
00098   // nsTextFrame::PaintTextDecorations.  (See bug 1777.)
00099   nscolor underColor, overColor, strikeColor;
00100   PRUint8 decorations = NS_STYLE_TEXT_DECORATION_NONE;
00101   nsCOMPtr<nsIFontMetrics> fm;
00102   PRBool isVisible;
00103 
00104   if (eCompatibility_NavQuirks != aPresContext->CompatibilityMode() && 
00105       NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer &&
00106       NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext,
00107                                         PR_TRUE, &isVisible)) &&
00108       isVisible) {
00109     GetTextDecorations(aPresContext, aIsBlock, decorations, underColor, 
00110                        overColor, strikeColor);
00111     if (decorations & (NS_STYLE_TEXT_DECORATION_UNDERLINE |
00112                        NS_STYLE_TEXT_DECORATION_OVERLINE |
00113                        NS_STYLE_TEXT_DECORATION_LINE_THROUGH)) {
00114       const nsStyleFont* font = GetStyleFont();
00115       NS_ASSERTION(font->mFont.decorations == NS_FONT_DECORATION_NONE,
00116                    "fonts on style structs shouldn't have decorations");
00117 
00118       // XXX This is relatively slow and shouldn't need to be used here.
00119       nsCOMPtr<nsIDeviceContext> deviceContext;
00120       aRenderingContext.GetDeviceContext(*getter_AddRefs(deviceContext));
00121       nsCOMPtr<nsIFontMetrics> normalFont;
00122       const nsStyleVisibility* visibility = GetStyleVisibility();      
00123       deviceContext->GetMetricsFor(font->mFont, visibility->mLangGroup, *getter_AddRefs(fm));
00124     }
00125     if (decorations & NS_STYLE_TEXT_DECORATION_UNDERLINE) {
00126       PaintTextDecorations(aRenderingContext, fm,
00127                            NS_STYLE_TEXT_DECORATION_UNDERLINE, underColor);
00128     }
00129     if (decorations & NS_STYLE_TEXT_DECORATION_OVERLINE) {
00130       PaintTextDecorations(aRenderingContext, fm,
00131                            NS_STYLE_TEXT_DECORATION_OVERLINE, overColor);
00132     }
00133   }
00134 
00135   PaintChildren(aPresContext, aRenderingContext, aDirtyRect,
00136                 aWhichLayer, aFlags);
00137 
00138   if (decorations & NS_STYLE_TEXT_DECORATION_LINE_THROUGH) {
00139     PaintTextDecorations(aRenderingContext, fm,
00140                          NS_STYLE_TEXT_DECORATION_LINE_THROUGH, strikeColor);
00141   }
00142 }
00143 
00144 static PRBool 
00145 HasTextFrameDescendantOrInFlow(nsPresContext* aPresContext, nsIFrame* aFrame);
00146 
00147 void
00148 nsHTMLContainerFrame::GetTextDecorations(nsPresContext* aPresContext, 
00149                                          PRBool aIsBlock,
00150                                          PRUint8& aDecorations,
00151                                          nscolor& aUnderColor, 
00152                                          nscolor& aOverColor, 
00153                                          nscolor& aStrikeColor)
00154 {
00155   aDecorations = NS_STYLE_TEXT_DECORATION_NONE;
00156   if (!mStyleContext->HasTextDecorations()) {
00157     // This is a necessary, but not sufficient, condition for text
00158     // decorations.
00159     return; 
00160   }
00161 
00162   // A mask of all possible decorations.
00163   PRUint8 decorMask = NS_STYLE_TEXT_DECORATION_UNDERLINE |
00164                       NS_STYLE_TEXT_DECORATION_OVERLINE |
00165                       NS_STYLE_TEXT_DECORATION_LINE_THROUGH; 
00166 
00167   if (!aIsBlock) {
00168     aDecorations = GetStyleTextReset()->mTextDecoration  & decorMask;
00169     if (aDecorations) {
00170       const nsStyleColor* styleColor = GetStyleColor();
00171       aUnderColor = styleColor->mColor;
00172       aOverColor = styleColor->mColor;
00173       aStrikeColor = styleColor->mColor;
00174     }
00175   }
00176   else {
00177     // walk tree
00178     for (nsIFrame *frame = this; frame && decorMask; frame = frame->GetParent()) {
00179       // find text-decorations.  "Inherit" from parent *block* frames
00180 
00181       nsStyleContext* styleContext = frame->GetStyleContext();
00182       const nsStyleDisplay* styleDisplay = styleContext->GetStyleDisplay();
00183       if (!styleDisplay->IsBlockLevel() &&
00184           styleDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL) {
00185         // If an inline frame is discovered while walking up the tree,
00186         // we should stop according to CSS3 draft. CSS2 is rather vague
00187         // about this.
00188         break;
00189       }
00190 
00191       const nsStyleTextReset* styleText = styleContext->GetStyleTextReset();
00192       PRUint8 decors = decorMask & styleText->mTextDecoration;
00193       if (decors) {
00194         // A *new* text-decoration is found.
00195         nscolor color = styleContext->GetStyleColor()->mColor;
00196 
00197         if (NS_STYLE_TEXT_DECORATION_UNDERLINE & decors) {
00198           aUnderColor = color;
00199           decorMask &= ~NS_STYLE_TEXT_DECORATION_UNDERLINE;
00200           aDecorations |= NS_STYLE_TEXT_DECORATION_UNDERLINE;
00201         }
00202         if (NS_STYLE_TEXT_DECORATION_OVERLINE & decors) {
00203           aOverColor = color;
00204           decorMask &= ~NS_STYLE_TEXT_DECORATION_OVERLINE;
00205           aDecorations |= NS_STYLE_TEXT_DECORATION_OVERLINE;
00206         }
00207         if (NS_STYLE_TEXT_DECORATION_LINE_THROUGH & decors) {
00208           aStrikeColor = color;
00209           decorMask &= ~NS_STYLE_TEXT_DECORATION_LINE_THROUGH;
00210           aDecorations |= NS_STYLE_TEXT_DECORATION_LINE_THROUGH;
00211         }
00212       }
00213     }
00214   }
00215   
00216   if (aDecorations) {
00217     // If this frame contains no text, we're required to ignore this property
00218     if (!HasTextFrameDescendantOrInFlow(aPresContext, this)) {
00219       aDecorations = NS_STYLE_TEXT_DECORATION_NONE;
00220     }
00221   }
00222 }
00223 
00224 static PRBool 
00225 HasTextFrameDescendant(nsPresContext* aPresContext, nsIFrame* aParent)
00226 {
00227   for (nsIFrame* kid = aParent->GetFirstChild(nsnull); kid;
00228        kid = kid->GetNextSibling())
00229   {
00230     if (kid->GetType() == nsLayoutAtoms::textFrame) {
00231       // This is only a candidate. We need to determine if this text
00232       // frame is empty, as in containing only (non-pre) whitespace.
00233       // See bug 20163.
00234       if (!kid->IsEmpty()) {
00235         return PR_TRUE;
00236       }
00237     }
00238     if (HasTextFrameDescendant(aPresContext, kid)) {
00239       return PR_TRUE;
00240     }
00241   }
00242   return PR_FALSE;
00243 }
00244 
00245 static PRBool 
00246 HasTextFrameDescendantOrInFlow(nsPresContext* aPresContext, nsIFrame* aFrame)
00247 {
00248   for (nsIFrame *f = aFrame->GetFirstInFlow(); f; f = f->GetNextInFlow()) {
00249     if (HasTextFrameDescendant(aPresContext, f))
00250       return PR_TRUE;
00251   }
00252   return PR_FALSE;
00253 }
00254 
00255 /*virtual*/ void
00256 nsHTMLContainerFrame::PaintTextDecorationLines(
00257                    nsIRenderingContext& aRenderingContext, 
00258                    nscolor aColor, 
00259                    nscoord aOffset, 
00260                    nscoord aAscent, 
00261                    nscoord aSize) 
00262 {
00263   nsMargin bp;
00264   CalcBorderPadding(bp);
00265   PRIntn skip = GetSkipSides();
00266   NS_FOR_CSS_SIDES(side) {
00267     if (skip & (1 << side)) {
00268       bp.side(side) = 0;
00269     }
00270   }
00271   aRenderingContext.SetColor(aColor);
00272   nscoord innerWidth = mRect.width - bp.left - bp.right;
00273   aRenderingContext.FillRect(bp.left, 
00274                              bp.top + aAscent - aOffset, innerWidth, aSize);
00275 }
00276 
00277 void
00278 nsHTMLContainerFrame::PaintTextDecorations(
00279                             nsIRenderingContext& aRenderingContext,
00280                             nsIFontMetrics* aFontMetrics,
00281                             PRUint8 aDecoration,
00282                             nscolor aColor)
00283 {
00284   nscoord ascent, offset, size;
00285   aFontMetrics->GetMaxAscent(ascent);
00286   if (aDecoration & 
00287       (NS_STYLE_TEXT_DECORATION_UNDERLINE 
00288        | NS_STYLE_TEXT_DECORATION_OVERLINE)) {
00289     aFontMetrics->GetUnderline(offset, size);
00290     if (NS_STYLE_TEXT_DECORATION_UNDERLINE & aDecoration) {
00291       PaintTextDecorationLines(aRenderingContext, aColor, offset, ascent, size);
00292     }
00293     else if (NS_STYLE_TEXT_DECORATION_OVERLINE & aDecoration) {
00294       PaintTextDecorationLines(aRenderingContext, aColor, ascent, ascent, size);
00295     }
00296   }
00297   else if (NS_STYLE_TEXT_DECORATION_LINE_THROUGH & aDecoration) {
00298     aFontMetrics->GetStrikeout(offset, size);
00299     PaintTextDecorationLines(aRenderingContext, aColor, offset, ascent, size);
00300   }
00301 }
00302 
00308 nsresult
00309 nsHTMLContainerFrame::CreateNextInFlow(nsPresContext* aPresContext,
00310                                        nsIFrame*       aOuterFrame,
00311                                        nsIFrame*       aFrame,
00312                                        nsIFrame*&      aNextInFlowResult)
00313 {
00314   aNextInFlowResult = nsnull;
00315 
00316   nsIFrame* nextInFlow = aFrame->GetNextInFlow();
00317   if (nsnull == nextInFlow) {
00318     // Create a continuation frame for the child frame and insert it
00319     // into our lines child list.
00320     nsIFrame* nextFrame = aFrame->GetNextSibling();
00321 
00322     nsresult rv = aPresContext->PresShell()->FrameConstructor()->
00323       CreateContinuingFrame(aPresContext, aFrame, aOuterFrame, &nextInFlow);
00324     if (NS_FAILED(rv)) {
00325       return rv;
00326     }
00327     aFrame->SetNextSibling(nextInFlow);
00328     nextInFlow->SetNextSibling(nextFrame);
00329 
00330     NS_FRAME_LOG(NS_FRAME_TRACE_NEW_FRAMES,
00331        ("nsHTMLContainerFrame::CreateNextInFlow: frame=%p nextInFlow=%p",
00332         aFrame, nextInFlow));
00333 
00334     aNextInFlowResult = nextInFlow;
00335   }
00336   return NS_OK;
00337 }
00338 
00339 static nsresult
00340 ReparentFrameViewTo(nsIFrame*       aFrame,
00341                     nsIViewManager* aViewManager,
00342                     nsIView*        aNewParentView,
00343                     nsIView*        aOldParentView)
00344 {
00345 
00346   // XXX What to do about placeholder views for "position: fixed" elements?
00347   // They should be reparented too.
00348 
00349   // Does aFrame have a view?
00350   if (aFrame->HasView()) {
00351     nsIView* view = aFrame->GetView();
00352     // Verify that the current parent view is what we think it is
00353     //nsIView*  parentView;
00354     //NS_ASSERTION(parentView == aOldParentView, "unexpected parent view");
00355 
00356     aViewManager->RemoveChild(view);
00357     
00358     // The view will remember the Z-order and other attributes that have been set on it.
00359     nsIView* insertBefore = nsLayoutUtils::FindSiblingViewFor(aNewParentView, aFrame);
00360     aViewManager->InsertChild(aNewParentView, view, insertBefore, insertBefore != nsnull);
00361   } else {
00362     PRInt32 listIndex = 0;
00363     nsIAtom* listName = nsnull;
00364     // This loop iterates through every child list name, and also
00365     // executes once with listName == nsnull.
00366     do {
00367       // Iterate the child frames, and check each child frame to see if it has
00368       // a view
00369       nsIFrame* childFrame = aFrame->GetFirstChild(listName);
00370       for (; childFrame; childFrame = childFrame->GetNextSibling()) {
00371         ReparentFrameViewTo(childFrame, aViewManager,
00372                             aNewParentView, aOldParentView);
00373       }
00374       listName = aFrame->GetAdditionalChildListName(listIndex++);
00375     } while (listName);
00376   }
00377 
00378   return NS_OK;
00379 }
00380 
00381 nsresult
00382 nsHTMLContainerFrame::ReparentFrameView(nsPresContext* aPresContext,
00383                                         nsIFrame*       aChildFrame,
00384                                         nsIFrame*       aOldParentFrame,
00385                                         nsIFrame*       aNewParentFrame)
00386 {
00387   NS_PRECONDITION(aChildFrame, "null child frame pointer");
00388   NS_PRECONDITION(aOldParentFrame, "null old parent frame pointer");
00389   NS_PRECONDITION(aNewParentFrame, "null new parent frame pointer");
00390   NS_PRECONDITION(aOldParentFrame != aNewParentFrame, "same old and new parent frame");
00391 
00392   // See if either the old parent frame or the new parent frame have a view
00393   while (!aOldParentFrame->HasView() && !aNewParentFrame->HasView()) {
00394     // Walk up both the old parent frame and the new parent frame nodes
00395     // stopping when we either find a common parent or views for one
00396     // or both of the frames.
00397     //
00398     // This works well in the common case where we push/pull and the old parent
00399     // frame and the new parent frame are part of the same flow. They will
00400     // typically be the same distance (height wise) from the
00401     aOldParentFrame = aOldParentFrame->GetParent();
00402     aNewParentFrame = aNewParentFrame->GetParent();
00403     
00404     // We should never walk all the way to the root frame without finding
00405     // a view
00406     NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
00407 
00408     // See if we reached a common ancestor
00409     if (aOldParentFrame == aNewParentFrame) {
00410       break;
00411     }
00412   }
00413 
00414   // See if we found a common parent frame
00415   if (aOldParentFrame == aNewParentFrame) {
00416     // We found a common parent and there are no views between the old parent
00417     // and the common parent or the new parent frame and the common parent.
00418     // Because neither the old parent frame nor the new parent frame have views,
00419     // then any child views don't need reparenting
00420     return NS_OK;
00421   }
00422 
00423   // We found views for one or both of the ancestor frames before we
00424   // found a common ancestor.
00425   nsIView* oldParentView = aOldParentFrame->GetClosestView();
00426   nsIView* newParentView = aNewParentFrame->GetClosestView();
00427   
00428   // See if the old parent frame and the new parent frame are in the
00429   // same view sub-hierarchy. If they are then we don't have to do
00430   // anything
00431   if (oldParentView != newParentView) {
00432     // They're not so we need to reparent any child views
00433     return ReparentFrameViewTo(aChildFrame, oldParentView->GetViewManager(), newParentView,
00434                                oldParentView);
00435   }
00436 
00437   return NS_OK;
00438 }
00439 
00440 nsresult
00441 nsHTMLContainerFrame::ReparentFrameViewList(nsPresContext* aPresContext,
00442                                             nsIFrame*       aChildFrameList,
00443                                             nsIFrame*       aOldParentFrame,
00444                                             nsIFrame*       aNewParentFrame)
00445 {
00446   NS_PRECONDITION(aChildFrameList, "null child frame list");
00447   NS_PRECONDITION(aOldParentFrame, "null old parent frame pointer");
00448   NS_PRECONDITION(aNewParentFrame, "null new parent frame pointer");
00449   NS_PRECONDITION(aOldParentFrame != aNewParentFrame, "same old and new parent frame");
00450 
00451   // See if either the old parent frame or the new parent frame have a view
00452   while (!aOldParentFrame->HasView() && !aNewParentFrame->HasView()) {
00453     // Walk up both the old parent frame and the new parent frame nodes
00454     // stopping when we either find a common parent or views for one
00455     // or both of the frames.
00456     //
00457     // This works well in the common case where we push/pull and the old parent
00458     // frame and the new parent frame are part of the same flow. They will
00459     // typically be the same distance (height wise) from the
00460     aOldParentFrame = aOldParentFrame->GetParent();
00461     aNewParentFrame = aNewParentFrame->GetParent();
00462     
00463     // We should never walk all the way to the root frame without finding
00464     // a view
00465     NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
00466 
00467     // See if we reached a common ancestor
00468     if (aOldParentFrame == aNewParentFrame) {
00469       break;
00470     }
00471   }
00472 
00473 
00474   // See if we found a common parent frame
00475   if (aOldParentFrame == aNewParentFrame) {
00476     // We found a common parent and there are no views between the old parent
00477     // and the common parent or the new parent frame and the common parent.
00478     // Because neither the old parent frame nor the new parent frame have views,
00479     // then any child views don't need reparenting
00480     return NS_OK;
00481   }
00482 
00483   // We found views for one or both of the ancestor frames before we
00484   // found a common ancestor.
00485   nsIView* oldParentView = aOldParentFrame->GetClosestView();
00486   nsIView* newParentView = aNewParentFrame->GetClosestView();
00487   
00488   // See if the old parent frame and the new parent frame are in the
00489   // same view sub-hierarchy. If they are then we don't have to do
00490   // anything
00491   if (oldParentView != newParentView) {
00492     nsIViewManager* viewManager = oldParentView->GetViewManager();
00493 
00494     // They're not so we need to reparent any child views
00495     for (nsIFrame* f = aChildFrameList; f; f = f->GetNextSibling()) {
00496       ReparentFrameViewTo(f, viewManager, newParentView,
00497                           oldParentView);
00498     }
00499   }
00500 
00501   return NS_OK;
00502 }
00503 
00504 nsresult
00505 nsHTMLContainerFrame::CreateViewForFrame(nsIFrame* aFrame,
00506                                          nsIFrame* aContentParentFrame,
00507                                          PRBool aForce)
00508 {
00509   if (aFrame->HasView()) {
00510     return NS_OK;
00511   }
00512 
00513   // If we don't yet have a view, see if we need a view
00514   if (!(aForce || FrameNeedsView(aFrame))) {
00515     // don't need a view
00516     return NS_OK;
00517   }
00518 
00519   nsIView* parentView = aFrame->GetParent()->GetParentViewForChildFrame(aFrame);
00520   NS_ASSERTION(parentView, "no parent with view");
00521 
00522   nsIViewManager* viewManager = parentView->GetViewManager();
00523   NS_ASSERTION(viewManager, "null view manager");
00524     
00525   // Create a view
00526   nsIView* view = viewManager->CreateView(aFrame->GetRect(), parentView);
00527   if (!view)
00528     return NS_ERROR_OUT_OF_MEMORY;
00529 
00530   SyncFrameViewProperties(aFrame->GetPresContext(), aFrame, nsnull, view);
00531 
00532   // Insert the view into the view hierarchy. If the parent view is a
00533   // scrolling view we need to do this differently
00534   nsIScrollableView*  scrollingView = parentView->ToScrollableView();
00535   if (scrollingView) {
00536     scrollingView->SetScrolledView(view);
00537   } else {
00538     nsIView* insertBefore = nsLayoutUtils::FindSiblingViewFor(parentView, aFrame);
00539     // we insert this view 'above' the insertBefore view, unless insertBefore is null,
00540     // in which case we want to call with aAbove == PR_FALSE to insert at the beginning
00541     // in document order
00542     viewManager->InsertChild(parentView, view, insertBefore, insertBefore != nsnull);
00543 
00544     if (nsnull != aContentParentFrame) {
00545       nsIView* zParentView = aContentParentFrame->GetClosestView();
00546       if (zParentView != parentView) {
00547         insertBefore = nsLayoutUtils::FindSiblingViewFor(zParentView, aFrame);
00548         viewManager->InsertZPlaceholder(zParentView, view, insertBefore, insertBefore != nsnull);
00549       }
00550     }
00551   }
00552 
00553   // XXX If it's fixed positioned, then create a widget so it floats
00554   // above the scrolling area
00555   const nsStyleDisplay* display = aFrame->GetStyleContext()->GetStyleDisplay();
00556   if (NS_STYLE_POSITION_FIXED == display->mPosition) {
00557     aFrame->CreateWidgetForView(view);
00558   }
00559 
00560   // Reparent views on any child frames (or their descendants) to this
00561   // view. We can just call ReparentFrameViewTo on this frame because
00562   // we know this frame has no view, so it will crawl the children. Also,
00563   // we know that any descendants with views must have 'parentView' as their
00564   // parent view.
00565   ReparentFrameViewTo(aFrame, viewManager, view, parentView);
00566 
00567   // Remember our view
00568   aFrame->SetView(view);
00569 
00570   NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
00571                ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p view=%p",
00572                 aFrame));
00573   return NS_OK;
00574 }