From bb9a09703e09e9bd814db258afb77554aa6ddb7d Mon Sep 17 00:00:00 2001 From: "evaughan%netscape.com" Date: Thu, 14 Sep 2000 23:02:26 +0000 Subject: [PATCH] Fix for bug #52124 --- layout/xul/base/src/nsBoxToBlockAdaptor.cpp | 42 +++++++++++++++++++++ layout/xul/base/src/nsBoxToBlockAdaptor.h | 2 + layout/xul/base/src/nsDeckFrame.cpp | 10 +++-- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/layout/xul/base/src/nsBoxToBlockAdaptor.cpp b/layout/xul/base/src/nsBoxToBlockAdaptor.cpp index 05060697f54b..75f1b902d336 100644 --- a/layout/xul/base/src/nsBoxToBlockAdaptor.cpp +++ b/layout/xul/base/src/nsBoxToBlockAdaptor.cpp @@ -53,6 +53,10 @@ #include "nsBoxToBlockAdaptor.h" #include "nsILineIterator.h" #include "nsIFontMetrics.h" +#include "nsHTMLContainerFrame.h" +#include "nsWidgetsCID.h" + +static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID); //#define DEBUG_REFLOW //#define DEBUG_GROW @@ -127,9 +131,46 @@ nsBoxToBlockAdaptor::nsBoxToBlockAdaptor(nsIPresShell* aPresShell, nsIFrame* aFr mOverflow.width = 0; mOverflow.height = 0; mIncludeOverflow = PR_TRUE; + mPresShell = aPresShell; NeedsRecalc(); } +NS_IMETHODIMP +nsBoxToBlockAdaptor::SetParentBox(nsIBox* aParent) +{ + nsresult rv = nsBox::SetParentBox(aParent); + + nsIBox* parent = aParent; + + + if (parent) { + PRBool needsWidget = PR_FALSE; + parent->ChildrenMustHaveWidgets(needsWidget); + if (needsWidget) { + nsCOMPtr context; + mPresShell->GetPresContext(getter_AddRefs(context)); + nsIView* view = nsnull; + mFrame->GetView(context, &view); + + if (!view) { + nsCOMPtr style; + mFrame->GetStyleContext(getter_AddRefs(style)); + nsHTMLContainerFrame::CreateViewForFrame(context,mFrame,style,nsnull,PR_TRUE); + mFrame->GetView(context, &view); + } + + nsIWidget* widget; + view->GetWidget(widget); + + if (!widget) + view->CreateWidget(kWidgetCID); + } + } + + + return rv; +} + PRBool nsBoxToBlockAdaptor::HasStyleChange() { @@ -687,6 +728,7 @@ nsBoxToBlockAdaptor::Reflow(nsBoxLayoutState& aState, if (needsReflow) { Redraw(aState); redrawAfterReflow = PR_TRUE; + //printf("Redrawing!!!/n"); } } break; diff --git a/layout/xul/base/src/nsBoxToBlockAdaptor.h b/layout/xul/base/src/nsBoxToBlockAdaptor.h index 156cc8067568..76662fb78d24 100644 --- a/layout/xul/base/src/nsBoxToBlockAdaptor.h +++ b/layout/xul/base/src/nsBoxToBlockAdaptor.h @@ -47,6 +47,7 @@ public: NS_IMETHOD SetIncludeOverflow(PRBool aInclude); NS_IMETHOD GetOverflow(nsSize& aOverflow); NS_IMETHOD NeedsRecalc(); + NS_IMETHOD SetParentBox(nsIBox* aParent); NS_IMETHOD Recycle(nsIPresShell* aPresShell); @@ -94,6 +95,7 @@ protected: PRBool mSizeSet; nsSize mOverflow; PRBool mIncludeOverflow; + nsCOMPtr mPresShell; }; #endif diff --git a/layout/xul/base/src/nsDeckFrame.cpp b/layout/xul/base/src/nsDeckFrame.cpp index 6d44ae22b5c6..94767d58a450 100644 --- a/layout/xul/base/src/nsDeckFrame.cpp +++ b/layout/xul/base/src/nsDeckFrame.cpp @@ -322,11 +322,13 @@ nsDeckFrame::Paint(nsIPresContext* aPresContext, // only paint the seleced box nsIBox* box = GetSelectedBox(); - nsIFrame* frame = nsnull; - box->GetFrame(&frame); + if (box) { + nsIFrame* frame = nsnull; + box->GetFrame(&frame); - if (frame != nsnull) - PaintChild(aPresContext, aRenderingContext, aDirtyRect, frame, aWhichLayer); + if (frame != nsnull) + PaintChild(aPresContext, aRenderingContext, aDirtyRect, frame, aWhichLayer); + } return NS_OK;