Bug 288117. Fix regressions in nsDocShell::SetCanvasHasFocus and in nsListBoxBodyFrame/nsListBoxObject where code made obsolete assumptions about scrollframe structure. r+sr=dbaron

This commit is contained in:
roc+%cs.cmu.edu 2005-04-03 21:02:47 +00:00
parent 20d333fbf6
commit fb05d807b2
4 changed files with 29 additions and 51 deletions

View File

@ -7129,9 +7129,10 @@ nsDocShell::SetCanvasHasFocus(PRBool aCanvasHasFocus)
if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsICanvasFrame), (void**)&canvasFrame))) { if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsICanvasFrame), (void**)&canvasFrame))) {
canvasFrame->SetHasFocus(aCanvasHasFocus); canvasFrame->SetHasFocus(aCanvasHasFocus);
nsIView* canvasView = frame->GetViewExternal(); nsIViewManager* vm = presShell->GetViewManager();
if (vm) {
canvasView->GetViewManager()->UpdateView(canvasView, NS_VMREFRESH_NO_SYNC); vm->UpdateAllViews(NS_VMREFRESH_NO_SYNC);
}
return NS_OK; return NS_OK;
} }

View File

@ -4635,18 +4635,9 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIContent* aDocElement,
rootFrame->Init(presContext, aDocElement, parentFrame, rootFrame->Init(presContext, aDocElement, parentFrame,
rootPseudoStyle, nsnull); rootPseudoStyle, nsnull);
if (!isPaginated || isPrintPreview) { if (isScrollable) {
if (isScrollable) { FinishBuildingScrollFrame(parentFrame, rootFrame);
FinishBuildingScrollFrame(parentFrame, rootFrame); }
// Don't set the root as the primary frame for aDocElement. Its
// primary frame will be set in ConstructDocElementFrame.
} else { // if not scrollable
if (!isXUL) { // if not XUL
parentFrame->SetInitialChildList(presContext, nsnull, rootFrame);
}
}
}
if (isPaginated) { // paginated if (isPaginated) { // paginated
// Create the first page // Create the first page
@ -4665,9 +4656,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIContent* aDocElement,
*aNewFrame = viewportFrame; *aNewFrame = viewportFrame;
return NS_OK;
return NS_OK;
} }
nsresult nsresult

View File

@ -236,11 +236,7 @@ nsListBoxBodyFrame::Init(nsPresContext* aPresContext, nsIContent* aContent,
mOnePixel = aPresContext->IntScaledPixelsToTwips(1); mOnePixel = aPresContext->IntScaledPixelsToTwips(1);
nsIFrame* box = aParent->GetParent(); nsIScrollableFrame* scrollFrame = nsLayoutUtils::GetScrollableFrameFor(this);
if (!box)
return rv;
nsCOMPtr<nsIScrollableFrame> scrollFrame(do_QueryInterface(box));
if (!scrollFrame) if (!scrollFrame)
return rv; return rv;
@ -264,7 +260,6 @@ nsListBoxBodyFrame::Init(nsPresContext* aPresContext, nsIContent* aContent,
fm->GetHeight(mRowHeight); fm->GetHeight(mRowHeight);
return rv; return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -344,6 +339,7 @@ nsListBoxBodyFrame::NeedsRecalc()
{ {
mStringWidth = -1; mStringWidth = -1;
return nsBoxFrame::NeedsRecalc(); return nsBoxFrame::NeedsRecalc();
printf("*** nsListBoxBodyFrame::NeedsRecalc %p\n", this);
} }
/////////// nsBox /////////////// /////////// nsBox ///////////////
@ -393,6 +389,10 @@ nsListBoxBodyFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize
nsresult rv = nsBoxFrame::GetPrefSize(aBoxLayoutState, aSize); nsresult rv = nsBoxFrame::GetPrefSize(aBoxLayoutState, aSize);
PRInt32 size = GetFixedRowSize(); PRInt32 size = GetFixedRowSize();
nsIBox* box = nsnull;
GetChildBox(&box);
printf("nsListBoxBodyFrame::GetPrefSize %p childbox=%p rowsize=%d height=%d newHeight=%d\n", this,
box, size, aSize.height, size*GetRowHeightTwips());
if (size > -1) if (size > -1)
aSize.height = size*GetRowHeightTwips(); aSize.height = size*GetRowHeightTwips();
@ -713,6 +713,8 @@ nsListBoxBodyFrame::GetFixedRowSize()
void void
nsListBoxBodyFrame::SetRowHeight(nscoord aRowHeight) nsListBoxBodyFrame::SetRowHeight(nscoord aRowHeight)
{ {
printf("*** Setting rowheight on %p to %d (current %d)\n", this,
aRowHeight, mRowHeight);
if (aRowHeight > mRowHeight) { if (aRowHeight > mRowHeight) {
mRowHeight = aRowHeight; mRowHeight = aRowHeight;
@ -737,20 +739,16 @@ nsListBoxBodyFrame::SetRowHeight(nscoord aRowHeight)
// so we can create or destory rows as needed // so we can create or destory rows as needed
mRowHeightWasSet = PR_TRUE; mRowHeightWasSet = PR_TRUE;
PostReflowCallback(); PostReflowCallback();
} }
} }
nscoord nscoord
nsListBoxBodyFrame::GetAvailableHeight() nsListBoxBodyFrame::GetAvailableHeight()
{ {
nsIBox* box; nsIScrollableFrame* scrollFrame
GetParentBox(&box); = nsLayoutUtils::GetScrollableFrameFor(this);
if (!box) nsIScrollableView* scrollView = scrollFrame->GetScrollableView();
return 0; return scrollView->View()->GetBounds().height;
nsRect contentRect;
box->GetContentRect(contentRect);
return contentRect.height;
} }
nscoord nscoord
@ -987,18 +985,8 @@ nsListBoxBodyFrame::GetSmoother()
void void
nsListBoxBodyFrame::VerticalScroll(PRInt32 aPosition) nsListBoxBodyFrame::VerticalScroll(PRInt32 aPosition)
{ {
nsIBox* box; nsIScrollableFrame* scrollFrame
GetParentBox(&box); = nsLayoutUtils::GetScrollableFrameFor(this);
if (!box)
return;
box->GetParentBox(&box);
if (!box)
return;
nsCOMPtr<nsIScrollableFrame> scrollFrame(do_QueryInterface(box));
if (!scrollFrame)
return;
nsPoint scrollPosition = scrollFrame->GetScrollPosition(); nsPoint scrollPosition = scrollFrame->GetScrollPosition();

View File

@ -46,6 +46,7 @@
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
#include "nsIDOMNodeList.h" #include "nsIDOMNodeList.h"
#include "nsXULAtoms.h" #include "nsXULAtoms.h"
#include "nsIScrollableFrame.h"
class nsListBoxObject : public nsIListBoxObject, public nsBoxObject class nsListBoxObject : public nsIListBoxObject, public nsBoxObject
{ {
@ -227,14 +228,13 @@ nsListBoxObject::GetListBoxBody()
mPresShell->GetPrimaryFrameFor(content, &frame); mPresShell->GetPrimaryFrameFor(content, &frame);
if (!frame) if (!frame)
return nsnull; return nsnull;
nsIScrollableFrame* scrollFrame;
// this frame will be a nsScrollBoxFrame CallQueryInterface(frame, &scrollFrame);
nsIFrame* scrollPort = frame->GetFirstChild(nsnull); if (!scrollFrame)
if (!scrollPort) return nsnull;
return nsnull;
// this frame will be the one we want // this frame will be the one we want
nsIFrame* yeahBaby = scrollPort->GetFirstChild(nsnull); nsIFrame* yeahBaby = scrollFrame->GetScrolledFrame();
if (!yeahBaby) if (!yeahBaby)
return nsnull; return nsnull;